nus-yam/ex-repair huggingface dataset:
Program: 198831
Project: 198831
Buggy source:
@Override public boolean handleMessage(Message msg){
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE:
{
      TvInputHardwareInfo info=(TvInputHardwareInfo)msg.obj;
      retrieveStreamConfigs(info.getDeviceId());
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + info);
      }
      mCallback.onDeviceAvailable(info,mStreamConfigs);
      break;
    }
case EVENT_DEVICE_UNAVAILABLE:
{
    int deviceId=msg.arg1;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    mCallback.onDeviceUnavailable(deviceId);
    break;
  }
case EVENT_STREAM_CONFIGURATION_CHANGED:
{
  int deviceId=msg.arg1;
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + deviceId);
  }
  retrieveStreamConfigs(deviceId);
  mCallback.onStreamConfigurationChanged(deviceId,mStreamConfigs);
  break;
}
case EVENT_FIRST_FRAME_CAPTURED:
{
int deviceId=msg.arg1;
int streamId=msg.arg2;
mCallback.onFirstFrameCaptured(deviceId,streamId);
break;
}
default :
Slog.e(TAG,"String_Node_Str" + msg);
return false;
}
return true;
}

Fixed version (ground truth):
@Override public boolean handleMessage(Message msg){
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE:
{
      TvStreamConfig[] configs;
      TvInputHardwareInfo info=(TvInputHardwareInfo)msg.obj;
synchronized (mLock) {
        retrieveStreamConfigsLocked(info.getDeviceId());
        if (DEBUG) {
          Slog.d(TAG,"String_Node_Str" + info);
        }
        configs=mStreamConfigs.get(info.getDeviceId());
      }
      mCallback.onDeviceAvailable(info,configs);
      break;
    }
case EVENT_DEVICE_UNAVAILABLE:
{
    int deviceId=msg.arg1;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    mCallback.onDeviceUnavailable(deviceId);
    break;
  }
case EVENT_STREAM_CONFIGURATION_CHANGED:
{
  TvStreamConfig[] configs;
  int deviceId=msg.arg1;
synchronized (mLock) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    retrieveStreamConfigsLocked(deviceId);
    configs=mStreamConfigs.get(deviceId);
  }
  mCallback.onStreamConfigurationChanged(deviceId,configs);
  break;
}
case EVENT_FIRST_FRAME_CAPTURED:
{
int deviceId=msg.arg1;
int streamId=msg.arg2;
mCallback.onFirstFrameCaptured(deviceId,streamId);
break;
}
default :
Slog.e(TAG,"String_Node_Str" + msg);
return false;
}
return true;
}
Program: 198832
Project: 198832
Buggy source:
public synchronized int addStream(int deviceId,Surface surface,TvStreamConfig streamConfig){
  if (mPtr == 0) {
    return ERROR_NO_INIT;
  }
  if (mStreamConfigGeneration != streamConfig.getGeneration()) {
    return ERROR_STALE_CONFIG;
  }
  if (nativeAddStream(mPtr,deviceId,streamConfig.getStreamId(),surface) == 0) {
    return SUCCESS;
  }
 else {
    return ERROR_UNKNOWN;
  }
}

Fixed version (ground truth):
public int addStream(int deviceId,Surface surface,TvStreamConfig streamConfig){
synchronized (mLock) {
    if (mPtr == 0) {
      return ERROR_NO_INIT;
    }
    int generation=mStreamConfigGenerations.get(deviceId,0);
    if (generation != streamConfig.getGeneration()) {
      return ERROR_STALE_CONFIG;
    }
    if (nativeAddStream(mPtr,deviceId,streamConfig.getStreamId(),surface) == 0) {
      return SUCCESS;
    }
 else {
      return ERROR_UNKNOWN;
    }
  }
}
Program: 198833
Project: 198833
Buggy source:
public synchronized void close(){
  if (mPtr != 0l) {
    nativeClose(mPtr);
  }
}

Fixed version (ground truth):
public void close(){
synchronized (mLock) {
    if (mPtr != 0l) {
      nativeClose(mPtr);
    }
  }
}
Program: 198834
Project: 198834
Buggy source:
public synchronized void init(){
  mPtr=nativeOpen();
}

Fixed version (ground truth):
public void init(){
synchronized (mLock) {
    mPtr=nativeOpen();
  }
}
Program: 198835
Project: 198835
Buggy source:
public synchronized int removeStream(int deviceId,TvStreamConfig streamConfig){
  if (mPtr == 0) {
    return ERROR_NO_INIT;
  }
  if (mStreamConfigGeneration != streamConfig.getGeneration()) {
    return ERROR_STALE_CONFIG;
  }
  if (nativeRemoveStream(mPtr,deviceId,streamConfig.getStreamId()) == 0) {
    return SUCCESS;
  }
 else {
    return ERROR_UNKNOWN;
  }
}

Fixed version (ground truth):
public int removeStream(int deviceId,TvStreamConfig streamConfig){
synchronized (mLock) {
    if (mPtr == 0) {
      return ERROR_NO_INIT;
    }
    int generation=mStreamConfigGenerations.get(deviceId,0);
    if (generation != streamConfig.getGeneration()) {
      return ERROR_STALE_CONFIG;
    }
    if (nativeRemoveStream(mPtr,deviceId,streamConfig.getStreamId()) == 0) {
      return SUCCESS;
    }
 else {
      return ERROR_UNKNOWN;
    }
  }
}
Program: 198836
Project: 198836
Buggy source:
@Override public boolean handleMessage(Message msg){
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE:
{
      TvInputHardwareInfo info=(TvInputHardwareInfo)msg.obj;
      retrieveStreamConfigs(info.getDeviceId());
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + info);
      }
      mCallback.onDeviceAvailable(info,mStreamConfigs);
      break;
    }
case EVENT_DEVICE_UNAVAILABLE:
{
    int deviceId=msg.arg1;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    mCallback.onDeviceUnavailable(deviceId);
    break;
  }
case EVENT_STREAM_CONFIGURATION_CHANGED:
{
  int deviceId=msg.arg1;
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + deviceId);
  }
  retrieveStreamConfigs(deviceId);
  mCallback.onStreamConfigurationChanged(deviceId,mStreamConfigs);
  break;
}
case EVENT_FIRST_FRAME_CAPTURED:
{
int deviceId=msg.arg1;
int streamId=msg.arg2;
mCallback.onFirstFrameCaptured(deviceId,streamId);
break;
}
default :
Slog.e(TAG,"String_Node_Str" + msg);
return false;
}
return true;
}

Fixed version (ground truth):
@Override public boolean handleMessage(Message msg){
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE:
{
      TvStreamConfig[] configs;
      TvInputHardwareInfo info=(TvInputHardwareInfo)msg.obj;
synchronized (mLock) {
        retrieveStreamConfigsLocked(info.getDeviceId());
        if (DEBUG) {
          Slog.d(TAG,"String_Node_Str" + info);
        }
        configs=mStreamConfigs.get(info.getDeviceId());
      }
      mCallback.onDeviceAvailable(info,configs);
      break;
    }
case EVENT_DEVICE_UNAVAILABLE:
{
    int deviceId=msg.arg1;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    mCallback.onDeviceUnavailable(deviceId);
    break;
  }
case EVENT_STREAM_CONFIGURATION_CHANGED:
{
  TvStreamConfig[] configs;
  int deviceId=msg.arg1;
synchronized (mLock) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    retrieveStreamConfigsLocked(deviceId);
    configs=mStreamConfigs.get(deviceId);
  }
  mCallback.onStreamConfigurationChanged(deviceId,configs);
  break;
}
case EVENT_FIRST_FRAME_CAPTURED:
{
int deviceId=msg.arg1;
int streamId=msg.arg2;
mCallback.onFirstFrameCaptured(deviceId,streamId);
break;
}
default :
Slog.e(TAG,"String_Node_Str" + msg);
return false;
}
return true;
}
Program: 198837
Project: 198837
Buggy source:
public synchronized int addStream(int deviceId,Surface surface,TvStreamConfig streamConfig){
  if (mPtr == 0) {
    return ERROR_NO_INIT;
  }
  if (mStreamConfigGeneration != streamConfig.getGeneration()) {
    return ERROR_STALE_CONFIG;
  }
  if (nativeAddStream(mPtr,deviceId,streamConfig.getStreamId(),surface) == 0) {
    return SUCCESS;
  }
 else {
    return ERROR_UNKNOWN;
  }
}

Fixed version (ground truth):
public int addStream(int deviceId,Surface surface,TvStreamConfig streamConfig){
synchronized (mLock) {
    if (mPtr == 0) {
      return ERROR_NO_INIT;
    }
    int generation=mStreamConfigGenerations.get(deviceId,0);
    if (generation != streamConfig.getGeneration()) {
      return ERROR_STALE_CONFIG;
    }
    if (nativeAddStream(mPtr,deviceId,streamConfig.getStreamId(),surface) == 0) {
      return SUCCESS;
    }
 else {
      return ERROR_UNKNOWN;
    }
  }
}
Program: 198838
Project: 198838
Buggy source:
public synchronized void close(){
  if (mPtr != 0l) {
    nativeClose(mPtr);
  }
}

Fixed version (ground truth):
public void close(){
synchronized (mLock) {
    if (mPtr != 0l) {
      nativeClose(mPtr);
    }
  }
}
Program: 198840
Project: 198840
Buggy source:
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent and trailing whitespace.
 */
public float getLineWidth(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,true);
  return margin + signedExtent >= 0 ? signedExtent : -signedExtent;
}

Fixed version (ground truth):
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent and trailing whitespace.
 */
public float getLineWidth(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,true);
  return margin + (signedExtent >= 0 ? signedExtent : -signedExtent);
}
Program: 198841
Project: 198841
Buggy source:
static float measurePara(TextPaint paint,CharSequence text,int start,int end){
  MeasuredText mt=MeasuredText.obtain();
  TextLine tl=TextLine.obtain();
  try {
    mt.setPara(text,start,end,TextDirectionHeuristics.LTR);
    Directions directions;
    int dir;
    if (mt.mEasy) {
      directions=DIRS_ALL_LEFT_TO_RIGHT;
      dir=Layout.DIR_LEFT_TO_RIGHT;
    }
 else {
      directions=AndroidBidi.directions(mt.mDir,mt.mLevels,0,mt.mChars,0,mt.mLen);
      dir=mt.mDir;
    }
    char[] chars=mt.mChars;
    int len=mt.mLen;
    boolean hasTabs=false;
    TabStops tabStops=null;
    for (int i=0; i < len; ++i) {
      if (chars[i] == '\t') {
        hasTabs=true;
        if (text instanceof Spanned) {
          Spanned spanned=(Spanned)text;
          int spanEnd=spanned.nextSpanTransition(start,end,TabStopSpan.class);
          TabStopSpan[] spans=getParagraphSpans(spanned,start,spanEnd,TabStopSpan.class);
          if (spans.length > 0) {
            tabStops=new TabStops(TAB_INCREMENT,spans);
          }
        }
        break;
      }
    }
    tl.set(paint,text,start,end,dir,directions,hasTabs,tabStops);
    return tl.metrics(null);
  }
  finally {
    TextLine.recycle(tl);
    MeasuredText.recycle(mt);
  }
}

Fixed version (ground truth):
static float measurePara(TextPaint paint,CharSequence text,int start,int end){
  MeasuredText mt=MeasuredText.obtain();
  TextLine tl=TextLine.obtain();
  try {
    mt.setPara(text,start,end,TextDirectionHeuristics.LTR);
    Directions directions;
    int dir;
    if (mt.mEasy) {
      directions=DIRS_ALL_LEFT_TO_RIGHT;
      dir=Layout.DIR_LEFT_TO_RIGHT;
    }
 else {
      directions=AndroidBidi.directions(mt.mDir,mt.mLevels,0,mt.mChars,0,mt.mLen);
      dir=mt.mDir;
    }
    char[] chars=mt.mChars;
    int len=mt.mLen;
    boolean hasTabs=false;
    TabStops tabStops=null;
    int margin=0;
    if (text instanceof Spanned) {
      Spanned spanned=(Spanned)text;
      LeadingMarginSpan[] spans=getParagraphSpans(spanned,start,end,LeadingMarginSpan.class);
      for (      LeadingMarginSpan lms : spans) {
        margin+=lms.getLeadingMargin(true);
      }
    }
    for (int i=0; i < len; ++i) {
      if (chars[i] == '\t') {
        hasTabs=true;
        if (text instanceof Spanned) {
          Spanned spanned=(Spanned)text;
          int spanEnd=spanned.nextSpanTransition(start,end,TabStopSpan.class);
          TabStopSpan[] spans=getParagraphSpans(spanned,start,spanEnd,TabStopSpan.class);
          if (spans.length > 0) {
            tabStops=new TabStops(TAB_INCREMENT,spans);
          }
        }
        break;
      }
    }
    tl.set(paint,text,start,end,dir,directions,hasTabs,tabStops);
    return margin + tl.metrics(null);
  }
  finally {
    TextLine.recycle(tl);
    MeasuredText.recycle(mt);
  }
}
Program: 198842
Project: 198842
Buggy source:
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent, but excluding trailing whitespace.
 */
public float getLineMax(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,false);
  return margin + signedExtent >= 0 ? signedExtent : -signedExtent;
}

Fixed version (ground truth):
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent, but excluding trailing whitespace.
 */
public float getLineMax(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,false);
  return margin + (signedExtent >= 0 ? signedExtent : -signedExtent);
}
Program: 198843
Project: 198843
Buggy source:
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent and trailing whitespace.
 */
public float getLineWidth(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,true);
  return margin + signedExtent >= 0 ? signedExtent : -signedExtent;
}

Fixed version (ground truth):
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent and trailing whitespace.
 */
public float getLineWidth(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,true);
  return margin + (signedExtent >= 0 ? signedExtent : -signedExtent);
}
Program: 198844
Project: 198844
Buggy source:
static float measurePara(TextPaint paint,CharSequence text,int start,int end){
  MeasuredText mt=MeasuredText.obtain();
  TextLine tl=TextLine.obtain();
  try {
    mt.setPara(text,start,end,TextDirectionHeuristics.LTR);
    Directions directions;
    int dir;
    if (mt.mEasy) {
      directions=DIRS_ALL_LEFT_TO_RIGHT;
      dir=Layout.DIR_LEFT_TO_RIGHT;
    }
 else {
      directions=AndroidBidi.directions(mt.mDir,mt.mLevels,0,mt.mChars,0,mt.mLen);
      dir=mt.mDir;
    }
    char[] chars=mt.mChars;
    int len=mt.mLen;
    boolean hasTabs=false;
    TabStops tabStops=null;
    for (int i=0; i < len; ++i) {
      if (chars[i] == '\t') {
        hasTabs=true;
        if (text instanceof Spanned) {
          Spanned spanned=(Spanned)text;
          int spanEnd=spanned.nextSpanTransition(start,end,TabStopSpan.class);
          TabStopSpan[] spans=getParagraphSpans(spanned,start,spanEnd,TabStopSpan.class);
          if (spans.length > 0) {
            tabStops=new TabStops(TAB_INCREMENT,spans);
          }
        }
        break;
      }
    }
    tl.set(paint,text,start,end,dir,directions,hasTabs,tabStops);
    return tl.metrics(null);
  }
  finally {
    TextLine.recycle(tl);
    MeasuredText.recycle(mt);
  }
}

Fixed version (ground truth):
static float measurePara(TextPaint paint,CharSequence text,int start,int end){
  MeasuredText mt=MeasuredText.obtain();
  TextLine tl=TextLine.obtain();
  try {
    mt.setPara(text,start,end,TextDirectionHeuristics.LTR);
    Directions directions;
    int dir;
    if (mt.mEasy) {
      directions=DIRS_ALL_LEFT_TO_RIGHT;
      dir=Layout.DIR_LEFT_TO_RIGHT;
    }
 else {
      directions=AndroidBidi.directions(mt.mDir,mt.mLevels,0,mt.mChars,0,mt.mLen);
      dir=mt.mDir;
    }
    char[] chars=mt.mChars;
    int len=mt.mLen;
    boolean hasTabs=false;
    TabStops tabStops=null;
    int margin=0;
    if (text instanceof Spanned) {
      Spanned spanned=(Spanned)text;
      LeadingMarginSpan[] spans=getParagraphSpans(spanned,start,end,LeadingMarginSpan.class);
      for (      LeadingMarginSpan lms : spans) {
        margin+=lms.getLeadingMargin(true);
      }
    }
    for (int i=0; i < len; ++i) {
      if (chars[i] == '\t') {
        hasTabs=true;
        if (text instanceof Spanned) {
          Spanned spanned=(Spanned)text;
          int spanEnd=spanned.nextSpanTransition(start,end,TabStopSpan.class);
          TabStopSpan[] spans=getParagraphSpans(spanned,start,spanEnd,TabStopSpan.class);
          if (spans.length > 0) {
            tabStops=new TabStops(TAB_INCREMENT,spans);
          }
        }
        break;
      }
    }
    tl.set(paint,text,start,end,dir,directions,hasTabs,tabStops);
    return margin + tl.metrics(null);
  }
  finally {
    TextLine.recycle(tl);
    MeasuredText.recycle(mt);
  }
}
Program: 198845
Project: 198845
Buggy source:
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent, but excluding trailing whitespace.
 */
public float getLineMax(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,false);
  return margin + signedExtent >= 0 ? signedExtent : -signedExtent;
}

Fixed version (ground truth):
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent, but excluding trailing whitespace.
 */
public float getLineMax(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,false);
  return margin + (signedExtent >= 0 ? signedExtent : -signedExtent);
}
Program: 198846
Project: 198846
Buggy source:
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent and trailing whitespace.
 */
public float getLineWidth(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,true);
  return margin + signedExtent >= 0 ? signedExtent : -signedExtent;
}

Fixed version (ground truth):
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent and trailing whitespace.
 */
public float getLineWidth(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,true);
  return margin + (signedExtent >= 0 ? signedExtent : -signedExtent);
}
Program: 198847
Project: 198847
Buggy source:
static float measurePara(TextPaint paint,CharSequence text,int start,int end){
  MeasuredText mt=MeasuredText.obtain();
  TextLine tl=TextLine.obtain();
  try {
    mt.setPara(text,start,end,TextDirectionHeuristics.LTR);
    Directions directions;
    int dir;
    if (mt.mEasy) {
      directions=DIRS_ALL_LEFT_TO_RIGHT;
      dir=Layout.DIR_LEFT_TO_RIGHT;
    }
 else {
      directions=AndroidBidi.directions(mt.mDir,mt.mLevels,0,mt.mChars,0,mt.mLen);
      dir=mt.mDir;
    }
    char[] chars=mt.mChars;
    int len=mt.mLen;
    boolean hasTabs=false;
    TabStops tabStops=null;
    for (int i=0; i < len; ++i) {
      if (chars[i] == '\t') {
        hasTabs=true;
        if (text instanceof Spanned) {
          Spanned spanned=(Spanned)text;
          int spanEnd=spanned.nextSpanTransition(start,end,TabStopSpan.class);
          TabStopSpan[] spans=getParagraphSpans(spanned,start,spanEnd,TabStopSpan.class);
          if (spans.length > 0) {
            tabStops=new TabStops(TAB_INCREMENT,spans);
          }
        }
        break;
      }
    }
    tl.set(paint,text,start,end,dir,directions,hasTabs,tabStops);
    return tl.metrics(null);
  }
  finally {
    TextLine.recycle(tl);
    MeasuredText.recycle(mt);
  }
}

Fixed version (ground truth):
static float measurePara(TextPaint paint,CharSequence text,int start,int end){
  MeasuredText mt=MeasuredText.obtain();
  TextLine tl=TextLine.obtain();
  try {
    mt.setPara(text,start,end,TextDirectionHeuristics.LTR);
    Directions directions;
    int dir;
    if (mt.mEasy) {
      directions=DIRS_ALL_LEFT_TO_RIGHT;
      dir=Layout.DIR_LEFT_TO_RIGHT;
    }
 else {
      directions=AndroidBidi.directions(mt.mDir,mt.mLevels,0,mt.mChars,0,mt.mLen);
      dir=mt.mDir;
    }
    char[] chars=mt.mChars;
    int len=mt.mLen;
    boolean hasTabs=false;
    TabStops tabStops=null;
    int margin=0;
    if (text instanceof Spanned) {
      Spanned spanned=(Spanned)text;
      LeadingMarginSpan[] spans=getParagraphSpans(spanned,start,end,LeadingMarginSpan.class);
      for (      LeadingMarginSpan lms : spans) {
        margin+=lms.getLeadingMargin(true);
      }
    }
    for (int i=0; i < len; ++i) {
      if (chars[i] == '\t') {
        hasTabs=true;
        if (text instanceof Spanned) {
          Spanned spanned=(Spanned)text;
          int spanEnd=spanned.nextSpanTransition(start,end,TabStopSpan.class);
          TabStopSpan[] spans=getParagraphSpans(spanned,start,spanEnd,TabStopSpan.class);
          if (spans.length > 0) {
            tabStops=new TabStops(TAB_INCREMENT,spans);
          }
        }
        break;
      }
    }
    tl.set(paint,text,start,end,dir,directions,hasTabs,tabStops);
    return margin + tl.metrics(null);
  }
  finally {
    TextLine.recycle(tl);
    MeasuredText.recycle(mt);
  }
}
Program: 198848
Project: 198848
Buggy source:
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent, but excluding trailing whitespace.
 */
public float getLineMax(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,false);
  return margin + signedExtent >= 0 ? signedExtent : -signedExtent;
}

Fixed version (ground truth):
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent, but excluding trailing whitespace.
 */
public float getLineMax(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,false);
  return margin + (signedExtent >= 0 ? signedExtent : -signedExtent);
}
Program: 198849
Project: 198849
Buggy source:
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent and trailing whitespace.
 */
public float getLineWidth(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,true);
  return margin + signedExtent >= 0 ? signedExtent : -signedExtent;
}

Fixed version (ground truth):
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent and trailing whitespace.
 */
public float getLineWidth(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,true);
  return margin + (signedExtent >= 0 ? signedExtent : -signedExtent);
}
Program: 198850
Project: 198850
Buggy source:
static float measurePara(TextPaint paint,CharSequence text,int start,int end){
  MeasuredText mt=MeasuredText.obtain();
  TextLine tl=TextLine.obtain();
  try {
    mt.setPara(text,start,end,TextDirectionHeuristics.LTR);
    Directions directions;
    int dir;
    if (mt.mEasy) {
      directions=DIRS_ALL_LEFT_TO_RIGHT;
      dir=Layout.DIR_LEFT_TO_RIGHT;
    }
 else {
      directions=AndroidBidi.directions(mt.mDir,mt.mLevels,0,mt.mChars,0,mt.mLen);
      dir=mt.mDir;
    }
    char[] chars=mt.mChars;
    int len=mt.mLen;
    boolean hasTabs=false;
    TabStops tabStops=null;
    for (int i=0; i < len; ++i) {
      if (chars[i] == '\t') {
        hasTabs=true;
        if (text instanceof Spanned) {
          Spanned spanned=(Spanned)text;
          int spanEnd=spanned.nextSpanTransition(start,end,TabStopSpan.class);
          TabStopSpan[] spans=getParagraphSpans(spanned,start,spanEnd,TabStopSpan.class);
          if (spans.length > 0) {
            tabStops=new TabStops(TAB_INCREMENT,spans);
          }
        }
        break;
      }
    }
    tl.set(paint,text,start,end,dir,directions,hasTabs,tabStops);
    return tl.metrics(null);
  }
  finally {
    TextLine.recycle(tl);
    MeasuredText.recycle(mt);
  }
}

Fixed version (ground truth):
static float measurePara(TextPaint paint,CharSequence text,int start,int end){
  MeasuredText mt=MeasuredText.obtain();
  TextLine tl=TextLine.obtain();
  try {
    mt.setPara(text,start,end,TextDirectionHeuristics.LTR);
    Directions directions;
    int dir;
    if (mt.mEasy) {
      directions=DIRS_ALL_LEFT_TO_RIGHT;
      dir=Layout.DIR_LEFT_TO_RIGHT;
    }
 else {
      directions=AndroidBidi.directions(mt.mDir,mt.mLevels,0,mt.mChars,0,mt.mLen);
      dir=mt.mDir;
    }
    char[] chars=mt.mChars;
    int len=mt.mLen;
    boolean hasTabs=false;
    TabStops tabStops=null;
    int margin=0;
    if (text instanceof Spanned) {
      Spanned spanned=(Spanned)text;
      LeadingMarginSpan[] spans=getParagraphSpans(spanned,start,end,LeadingMarginSpan.class);
      for (      LeadingMarginSpan lms : spans) {
        margin+=lms.getLeadingMargin(true);
      }
    }
    for (int i=0; i < len; ++i) {
      if (chars[i] == '\t') {
        hasTabs=true;
        if (text instanceof Spanned) {
          Spanned spanned=(Spanned)text;
          int spanEnd=spanned.nextSpanTransition(start,end,TabStopSpan.class);
          TabStopSpan[] spans=getParagraphSpans(spanned,start,spanEnd,TabStopSpan.class);
          if (spans.length > 0) {
            tabStops=new TabStops(TAB_INCREMENT,spans);
          }
        }
        break;
      }
    }
    tl.set(paint,text,start,end,dir,directions,hasTabs,tabStops);
    return margin + tl.metrics(null);
  }
  finally {
    TextLine.recycle(tl);
    MeasuredText.recycle(mt);
  }
}
Program: 198851
Project: 198851
Buggy source:
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent, but excluding trailing whitespace.
 */
public float getLineMax(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,false);
  return margin + signedExtent >= 0 ? signedExtent : -signedExtent;
}

Fixed version (ground truth):
/** 
 * Gets the unsigned horizontal extent of the specified line, including leading margin indent, but excluding trailing whitespace.
 */
public float getLineMax(int line){
  float margin=getParagraphLeadingMargin(line);
  float signedExtent=getLineExtent(line,false);
  return margin + (signedExtent >= 0 ? signedExtent : -signedExtent);
}
Program: 198852
Project: 198852
Buggy source:
@Override public AdvertiseData createFromParcel(Parcel in){
  Builder builder=new Builder();
  if (in.readInt() > 0) {
    List<ParcelUuid> uuids=new ArrayList<ParcelUuid>();
    in.readList(uuids,ParcelUuid.class.getClassLoader());
    for (    ParcelUuid uuid : uuids) {
      builder.addServiceUuid(uuid);
    }
  }
  int manufacturerId=in.readInt();
  int manufacturerDataLength=in.readInt();
  if (manufacturerDataLength > 0) {
    byte[] manufacturerData=new byte[manufacturerDataLength];
    in.readByteArray(manufacturerData);
    builder.setManufacturerData(manufacturerId,manufacturerData);
  }
  if (in.readInt() == 1) {
    ParcelUuid serviceDataUuid=in.readParcelable(ParcelUuid.class.getClassLoader());
    int serviceDataLength=in.readInt();
    if (serviceDataLength > 0) {
      byte[] serviceData=new byte[serviceDataLength];
      in.readByteArray(serviceData);
      builder.setServiceData(serviceDataUuid,serviceData);
    }
  }
  builder.setIncludeTxPowerLevel(in.readByte() == 1);
  builder.setIncludeDeviceName(in.readByte() == 1);
  return builder.build();
}

Fixed version (ground truth):
@Override public AdvertiseData createFromParcel(Parcel in){
  Builder builder=new Builder();
  List<ParcelUuid> uuids=in.readArrayList(ParcelUuid.class.getClassLoader());
  if (uuids != null) {
    for (    ParcelUuid uuid : uuids) {
      builder.addServiceUuid(uuid);
    }
  }
  int manufacturerId=in.readInt();
  if (in.readInt() == 1) {
    int manufacturerDataLength=in.readInt();
    byte[] manufacturerData=new byte[manufacturerDataLength];
    in.readByteArray(manufacturerData);
    builder.setManufacturerData(manufacturerId,manufacturerData);
  }
  ParcelUuid serviceDataUuid=in.readParcelable(ParcelUuid.class.getClassLoader());
  if (in.readInt() == 1) {
    int serviceDataLength=in.readInt();
    byte[] serviceData=new byte[serviceDataLength];
    in.readByteArray(serviceData);
    builder.setServiceData(serviceDataUuid,serviceData);
  }
  builder.setIncludeTxPowerLevel(in.readByte() == 1);
  builder.setIncludeDeviceName(in.readByte() == 1);
  return builder.build();
}
Program: 198853
Project: 198853
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + mServiceUuids + "String_Node_Str"+ mManufacturerId+ "String_Node_Str"+ Arrays.toString(mManufacturerSpecificData)+ "String_Node_Str"+ mServiceDataUuid+ "String_Node_Str"+ Arrays.toString(mServiceData)+ "String_Node_Str"+ mIncludeTxPowerLevel+ "String_Node_Str"+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + mServiceUuids + "String_Node_Str"+ mManufacturerId+ "String_Node_Str"+ Arrays.toString(mManufacturerSpecificData)+ "String_Node_Str"+ mServiceDataUuid+ "String_Node_Str"+ Arrays.toString(mServiceData)+ "String_Node_Str"+ mIncludeTxPowerLevel+ "String_Node_Str"+ mIncludeDeviceName+ "String_Node_Str";
}
Program: 198854
Project: 198854
Buggy source:
@Override public void writeToParcel(Parcel dest,int flags){
  if (mServiceUuids == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(mServiceUuids.size());
    dest.writeList(mServiceUuids);
  }
  dest.writeInt(mManufacturerId);
  if (mManufacturerSpecificData == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(mManufacturerSpecificData.length);
    dest.writeByteArray(mManufacturerSpecificData);
  }
  if (mServiceDataUuid == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(1);
    dest.writeParcelable(mServiceDataUuid,flags);
    if (mServiceData == null) {
      dest.writeInt(0);
    }
 else {
      dest.writeInt(mServiceData.length);
      dest.writeByteArray(mServiceData);
    }
  }
  dest.writeByte((byte)(getIncludeTxPowerLevel() ? 1 : 0));
  dest.writeByte((byte)(getIncludeDeviceName() ? 1 : 0));
}

Fixed version (ground truth):
@Override public void writeToParcel(Parcel dest,int flags){
  dest.writeList(mServiceUuids);
  dest.writeInt(mManufacturerId);
  if (mManufacturerSpecificData == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(1);
    dest.writeInt(mManufacturerSpecificData.length);
    dest.writeByteArray(mManufacturerSpecificData);
  }
  dest.writeParcelable(mServiceDataUuid,flags);
  if (mServiceData == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(1);
    dest.writeInt(mServiceData.length);
    dest.writeByteArray(mServiceData);
  }
  dest.writeByte((byte)(getIncludeTxPowerLevel() ? 1 : 0));
  dest.writeByte((byte)(getIncludeDeviceName() ? 1 : 0));
}
Program: 198855
Project: 198855
Buggy source:
private void testReadWriteParcelForFilter(ScanFilter filter){
  Parcel parcel=Parcel.obtain();
  filter.writeToParcel(parcel,0);
  parcel.setDataPosition(0);
  ScanFilter filterFromParcel=ScanFilter.CREATOR.createFromParcel(parcel);
  System.out.println(filterFromParcel);
  assertEquals(filter,filterFromParcel);
}

Fixed version (ground truth):
private void testReadWriteParcelForFilter(ScanFilter filter){
  Parcel parcel=Parcel.obtain();
  filter.writeToParcel(parcel,0);
  parcel.setDataPosition(0);
  ScanFilter filterFromParcel=ScanFilter.CREATOR.createFromParcel(parcel);
  assertEquals(filter,filterFromParcel);
}
Program: 198856
Project: 198856
Buggy source:
@Override public AdvertiseData createFromParcel(Parcel in){
  Builder builder=new Builder();
  if (in.readInt() > 0) {
    List<ParcelUuid> uuids=new ArrayList<ParcelUuid>();
    in.readList(uuids,ParcelUuid.class.getClassLoader());
    for (    ParcelUuid uuid : uuids) {
      builder.addServiceUuid(uuid);
    }
  }
  int manufacturerId=in.readInt();
  int manufacturerDataLength=in.readInt();
  if (manufacturerDataLength > 0) {
    byte[] manufacturerData=new byte[manufacturerDataLength];
    in.readByteArray(manufacturerData);
    builder.setManufacturerData(manufacturerId,manufacturerData);
  }
  if (in.readInt() == 1) {
    ParcelUuid serviceDataUuid=in.readParcelable(ParcelUuid.class.getClassLoader());
    int serviceDataLength=in.readInt();
    if (serviceDataLength > 0) {
      byte[] serviceData=new byte[serviceDataLength];
      in.readByteArray(serviceData);
      builder.setServiceData(serviceDataUuid,serviceData);
    }
  }
  builder.setIncludeTxPowerLevel(in.readByte() == 1);
  builder.setIncludeDeviceName(in.readByte() == 1);
  return builder.build();
}

Fixed version (ground truth):
@Override public AdvertiseData createFromParcel(Parcel in){
  Builder builder=new Builder();
  List<ParcelUuid> uuids=in.readArrayList(ParcelUuid.class.getClassLoader());
  if (uuids != null) {
    for (    ParcelUuid uuid : uuids) {
      builder.addServiceUuid(uuid);
    }
  }
  int manufacturerId=in.readInt();
  if (in.readInt() == 1) {
    int manufacturerDataLength=in.readInt();
    byte[] manufacturerData=new byte[manufacturerDataLength];
    in.readByteArray(manufacturerData);
    builder.setManufacturerData(manufacturerId,manufacturerData);
  }
  ParcelUuid serviceDataUuid=in.readParcelable(ParcelUuid.class.getClassLoader());
  if (in.readInt() == 1) {
    int serviceDataLength=in.readInt();
    byte[] serviceData=new byte[serviceDataLength];
    in.readByteArray(serviceData);
    builder.setServiceData(serviceDataUuid,serviceData);
  }
  builder.setIncludeTxPowerLevel(in.readByte() == 1);
  builder.setIncludeDeviceName(in.readByte() == 1);
  return builder.build();
}
Program: 198857
Project: 198857
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + mServiceUuids + "String_Node_Str"+ mManufacturerId+ "String_Node_Str"+ Arrays.toString(mManufacturerSpecificData)+ "String_Node_Str"+ mServiceDataUuid+ "String_Node_Str"+ Arrays.toString(mServiceData)+ "String_Node_Str"+ mIncludeTxPowerLevel+ "String_Node_Str"+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + mServiceUuids + "String_Node_Str"+ mManufacturerId+ "String_Node_Str"+ Arrays.toString(mManufacturerSpecificData)+ "String_Node_Str"+ mServiceDataUuid+ "String_Node_Str"+ Arrays.toString(mServiceData)+ "String_Node_Str"+ mIncludeTxPowerLevel+ "String_Node_Str"+ mIncludeDeviceName+ "String_Node_Str";
}
Program: 198858
Project: 198858
Buggy source:
@Override public void writeToParcel(Parcel dest,int flags){
  if (mServiceUuids == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(mServiceUuids.size());
    dest.writeList(mServiceUuids);
  }
  dest.writeInt(mManufacturerId);
  if (mManufacturerSpecificData == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(mManufacturerSpecificData.length);
    dest.writeByteArray(mManufacturerSpecificData);
  }
  if (mServiceDataUuid == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(1);
    dest.writeParcelable(mServiceDataUuid,flags);
    if (mServiceData == null) {
      dest.writeInt(0);
    }
 else {
      dest.writeInt(mServiceData.length);
      dest.writeByteArray(mServiceData);
    }
  }
  dest.writeByte((byte)(getIncludeTxPowerLevel() ? 1 : 0));
  dest.writeByte((byte)(getIncludeDeviceName() ? 1 : 0));
}

Fixed version (ground truth):
@Override public void writeToParcel(Parcel dest,int flags){
  dest.writeList(mServiceUuids);
  dest.writeInt(mManufacturerId);
  if (mManufacturerSpecificData == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(1);
    dest.writeInt(mManufacturerSpecificData.length);
    dest.writeByteArray(mManufacturerSpecificData);
  }
  dest.writeParcelable(mServiceDataUuid,flags);
  if (mServiceData == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(1);
    dest.writeInt(mServiceData.length);
    dest.writeByteArray(mServiceData);
  }
  dest.writeByte((byte)(getIncludeTxPowerLevel() ? 1 : 0));
  dest.writeByte((byte)(getIncludeDeviceName() ? 1 : 0));
}
Program: 198859
Project: 198859
Buggy source:
private void testReadWriteParcelForFilter(ScanFilter filter){
  Parcel parcel=Parcel.obtain();
  filter.writeToParcel(parcel,0);
  parcel.setDataPosition(0);
  ScanFilter filterFromParcel=ScanFilter.CREATOR.createFromParcel(parcel);
  System.out.println(filterFromParcel);
  assertEquals(filter,filterFromParcel);
}

Fixed version (ground truth):
private void testReadWriteParcelForFilter(ScanFilter filter){
  Parcel parcel=Parcel.obtain();
  filter.writeToParcel(parcel,0);
  parcel.setDataPosition(0);
  ScanFilter filterFromParcel=ScanFilter.CREATOR.createFromParcel(parcel);
  assertEquals(filter,filterFromParcel);
}
Program: 198860
Project: 198860
Buggy source:
@Override public AdvertiseData createFromParcel(Parcel in){
  Builder builder=new Builder();
  if (in.readInt() > 0) {
    List<ParcelUuid> uuids=new ArrayList<ParcelUuid>();
    in.readList(uuids,ParcelUuid.class.getClassLoader());
    for (    ParcelUuid uuid : uuids) {
      builder.addServiceUuid(uuid);
    }
  }
  int manufacturerId=in.readInt();
  int manufacturerDataLength=in.readInt();
  if (manufacturerDataLength > 0) {
    byte[] manufacturerData=new byte[manufacturerDataLength];
    in.readByteArray(manufacturerData);
    builder.setManufacturerData(manufacturerId,manufacturerData);
  }
  if (in.readInt() == 1) {
    ParcelUuid serviceDataUuid=in.readParcelable(ParcelUuid.class.getClassLoader());
    int serviceDataLength=in.readInt();
    if (serviceDataLength > 0) {
      byte[] serviceData=new byte[serviceDataLength];
      in.readByteArray(serviceData);
      builder.setServiceData(serviceDataUuid,serviceData);
    }
  }
  builder.setIncludeTxPowerLevel(in.readByte() == 1);
  builder.setIncludeDeviceName(in.readByte() == 1);
  return builder.build();
}

Fixed version (ground truth):
@Override public AdvertiseData createFromParcel(Parcel in){
  Builder builder=new Builder();
  List<ParcelUuid> uuids=in.readArrayList(ParcelUuid.class.getClassLoader());
  if (uuids != null) {
    for (    ParcelUuid uuid : uuids) {
      builder.addServiceUuid(uuid);
    }
  }
  int manufacturerId=in.readInt();
  if (in.readInt() == 1) {
    int manufacturerDataLength=in.readInt();
    byte[] manufacturerData=new byte[manufacturerDataLength];
    in.readByteArray(manufacturerData);
    builder.setManufacturerData(manufacturerId,manufacturerData);
  }
  ParcelUuid serviceDataUuid=in.readParcelable(ParcelUuid.class.getClassLoader());
  if (in.readInt() == 1) {
    int serviceDataLength=in.readInt();
    byte[] serviceData=new byte[serviceDataLength];
    in.readByteArray(serviceData);
    builder.setServiceData(serviceDataUuid,serviceData);
  }
  builder.setIncludeTxPowerLevel(in.readByte() == 1);
  builder.setIncludeDeviceName(in.readByte() == 1);
  return builder.build();
}
Program: 198861
Project: 198861
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + mServiceUuids + "String_Node_Str"+ mManufacturerId+ "String_Node_Str"+ Arrays.toString(mManufacturerSpecificData)+ "String_Node_Str"+ mServiceDataUuid+ "String_Node_Str"+ Arrays.toString(mServiceData)+ "String_Node_Str"+ mIncludeTxPowerLevel+ "String_Node_Str"+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + mServiceUuids + "String_Node_Str"+ mManufacturerId+ "String_Node_Str"+ Arrays.toString(mManufacturerSpecificData)+ "String_Node_Str"+ mServiceDataUuid+ "String_Node_Str"+ Arrays.toString(mServiceData)+ "String_Node_Str"+ mIncludeTxPowerLevel+ "String_Node_Str"+ mIncludeDeviceName+ "String_Node_Str";
}
Program: 198862
Project: 198862
Buggy source:
@Override public void writeToParcel(Parcel dest,int flags){
  if (mServiceUuids == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(mServiceUuids.size());
    dest.writeList(mServiceUuids);
  }
  dest.writeInt(mManufacturerId);
  if (mManufacturerSpecificData == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(mManufacturerSpecificData.length);
    dest.writeByteArray(mManufacturerSpecificData);
  }
  if (mServiceDataUuid == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(1);
    dest.writeParcelable(mServiceDataUuid,flags);
    if (mServiceData == null) {
      dest.writeInt(0);
    }
 else {
      dest.writeInt(mServiceData.length);
      dest.writeByteArray(mServiceData);
    }
  }
  dest.writeByte((byte)(getIncludeTxPowerLevel() ? 1 : 0));
  dest.writeByte((byte)(getIncludeDeviceName() ? 1 : 0));
}

Fixed version (ground truth):
@Override public void writeToParcel(Parcel dest,int flags){
  dest.writeList(mServiceUuids);
  dest.writeInt(mManufacturerId);
  if (mManufacturerSpecificData == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(1);
    dest.writeInt(mManufacturerSpecificData.length);
    dest.writeByteArray(mManufacturerSpecificData);
  }
  dest.writeParcelable(mServiceDataUuid,flags);
  if (mServiceData == null) {
    dest.writeInt(0);
  }
 else {
    dest.writeInt(1);
    dest.writeInt(mServiceData.length);
    dest.writeByteArray(mServiceData);
  }
  dest.writeByte((byte)(getIncludeTxPowerLevel() ? 1 : 0));
  dest.writeByte((byte)(getIncludeDeviceName() ? 1 : 0));
}
Program: 198863
Project: 198863
Buggy source:
private void testReadWriteParcelForFilter(ScanFilter filter){
  Parcel parcel=Parcel.obtain();
  filter.writeToParcel(parcel,0);
  parcel.setDataPosition(0);
  ScanFilter filterFromParcel=ScanFilter.CREATOR.createFromParcel(parcel);
  System.out.println(filterFromParcel);
  assertEquals(filter,filterFromParcel);
}

Fixed version (ground truth):
private void testReadWriteParcelForFilter(ScanFilter filter){
  Parcel parcel=Parcel.obtain();
  filter.writeToParcel(parcel,0);
  parcel.setDataPosition(0);
  ScanFilter filterFromParcel=ScanFilter.CREATOR.createFromParcel(parcel);
  assertEquals(filter,filterFromParcel);
}
Program: 198864
Project: 198864
Buggy source:
@Override public void setMode(int code,int uid,String packageName,int mode){
  if (Binder.getCallingPid() == Process.myPid()) {
    return;
  }
  mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS,Binder.getCallingPid(),Binder.getCallingUid(),null);
  verifyIncomingOp(code);
  ArrayList<Callback> repCbs=null;
  code=AppOpsManager.opToSwitch(code);
synchronized (this) {
    Op op=getOpLocked(code,uid,packageName,true);
    if (op != null) {
      if (op.mode != mode) {
        op.mode=mode;
        ArrayList<Callback> cbs=mOpModeWatchers.get(code);
        if (cbs != null) {
          if (repCbs == null) {
            repCbs=new ArrayList<Callback>();
          }
          repCbs.addAll(cbs);
        }
        cbs=mPackageModeWatchers.get(packageName);
        if (cbs != null) {
          if (repCbs == null) {
            repCbs=new ArrayList<Callback>();
          }
          repCbs.addAll(cbs);
        }
        if (mode == AppOpsManager.opToDefaultMode(op.op)) {
          pruneOp(op,uid,packageName);
        }
        scheduleWriteNowLocked();
      }
    }
  }
  if (repCbs != null) {
    for (int i=0; i < repCbs.size(); i++) {
      try {
        repCbs.get(i).mCallback.opChanged(code,packageName);
      }
 catch (      RemoteException e) {
      }
    }
  }
}

Fixed version (ground truth):
@Override public void setMode(int code,int uid,String packageName,int mode){
  if (Binder.getCallingPid() != Process.myPid()) {
    mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS,Binder.getCallingPid(),Binder.getCallingUid(),null);
  }
  verifyIncomingOp(code);
  ArrayList<Callback> repCbs=null;
  code=AppOpsManager.opToSwitch(code);
synchronized (this) {
    Op op=getOpLocked(code,uid,packageName,true);
    if (op != null) {
      if (op.mode != mode) {
        op.mode=mode;
        ArrayList<Callback> cbs=mOpModeWatchers.get(code);
        if (cbs != null) {
          if (repCbs == null) {
            repCbs=new ArrayList<Callback>();
          }
          repCbs.addAll(cbs);
        }
        cbs=mPackageModeWatchers.get(packageName);
        if (cbs != null) {
          if (repCbs == null) {
            repCbs=new ArrayList<Callback>();
          }
          repCbs.addAll(cbs);
        }
        if (mode == AppOpsManager.opToDefaultMode(op.op)) {
          pruneOp(op,uid,packageName);
        }
        scheduleWriteNowLocked();
      }
    }
  }
  if (repCbs != null) {
    for (int i=0; i < repCbs.size(); i++) {
      try {
        repCbs.get(i).mCallback.opChanged(code,packageName);
      }
 catch (      RemoteException e) {
      }
    }
  }
}
Program: 198865
Project: 198865
Buggy source:
@Override public void setMode(int code,int uid,String packageName,int mode){
  if (Binder.getCallingPid() == Process.myPid()) {
    return;
  }
  mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS,Binder.getCallingPid(),Binder.getCallingUid(),null);
  verifyIncomingOp(code);
  ArrayList<Callback> repCbs=null;
  code=AppOpsManager.opToSwitch(code);
synchronized (this) {
    Op op=getOpLocked(code,uid,packageName,true);
    if (op != null) {
      if (op.mode != mode) {
        op.mode=mode;
        ArrayList<Callback> cbs=mOpModeWatchers.get(code);
        if (cbs != null) {
          if (repCbs == null) {
            repCbs=new ArrayList<Callback>();
          }
          repCbs.addAll(cbs);
        }
        cbs=mPackageModeWatchers.get(packageName);
        if (cbs != null) {
          if (repCbs == null) {
            repCbs=new ArrayList<Callback>();
          }
          repCbs.addAll(cbs);
        }
        if (mode == AppOpsManager.opToDefaultMode(op.op)) {
          pruneOp(op,uid,packageName);
        }
        scheduleWriteNowLocked();
      }
    }
  }
  if (repCbs != null) {
    for (int i=0; i < repCbs.size(); i++) {
      try {
        repCbs.get(i).mCallback.opChanged(code,packageName);
      }
 catch (      RemoteException e) {
      }
    }
  }
}

Fixed version (ground truth):
@Override public void setMode(int code,int uid,String packageName,int mode){
  if (Binder.getCallingPid() != Process.myPid()) {
    mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS,Binder.getCallingPid(),Binder.getCallingUid(),null);
  }
  verifyIncomingOp(code);
  ArrayList<Callback> repCbs=null;
  code=AppOpsManager.opToSwitch(code);
synchronized (this) {
    Op op=getOpLocked(code,uid,packageName,true);
    if (op != null) {
      if (op.mode != mode) {
        op.mode=mode;
        ArrayList<Callback> cbs=mOpModeWatchers.get(code);
        if (cbs != null) {
          if (repCbs == null) {
            repCbs=new ArrayList<Callback>();
          }
          repCbs.addAll(cbs);
        }
        cbs=mPackageModeWatchers.get(packageName);
        if (cbs != null) {
          if (repCbs == null) {
            repCbs=new ArrayList<Callback>();
          }
          repCbs.addAll(cbs);
        }
        if (mode == AppOpsManager.opToDefaultMode(op.op)) {
          pruneOp(op,uid,packageName);
        }
        scheduleWriteNowLocked();
      }
    }
  }
  if (repCbs != null) {
    for (int i=0; i < repCbs.size(); i++) {
      try {
        repCbs.get(i).mCallback.opChanged(code,packageName);
      }
 catch (      RemoteException e) {
      }
    }
  }
}