nus-yam/ex-repair huggingface dataset:
Program: 22589
Project: 22589
Buggy source:
/** 
 * Show the dim surface.
 */
void show(int dw,int dh){
  if (!mDimShown) {
    if (SHOW_TRANSACTIONS)     Slog.i(TAG,"String_Node_Str" + mDimSurface + "String_Node_Str"+ dw+ "String_Node_Str"+ dh+ "String_Node_Str");
    mDimShown=true;
    try {
      mDimSurface.setPosition(0,0);
      mDimSurface.setSize(dw,dh);
      mDimSurface.show();
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Show the dim surface.
 */
void show(int dw,int dh){
  if (!mDimShown) {
    if (SHOW_TRANSACTIONS)     Slog.i(TAG,"String_Node_Str" + mDimSurface + "String_Node_Str"+ dw+ "String_Node_Str"+ dh+ "String_Node_Str");
    mDimShown=true;
    try {
      mLastDimWidth=dw;
      mLastDimHeight=dh;
      mDimSurface.setPosition(0,0);
      mDimSurface.setSize(dw,dh);
      mDimSurface.show();
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str",e);
    }
  }
 else   if (mLastDimWidth != dw || mLastDimHeight != dh) {
    mLastDimWidth=dw;
    mLastDimHeight=dh;
    mDimSurface.setSize(dw,dh);
  }
}
Program: 22591
Project: 22591
Buggy source:
private final int indexOfTokenLocked(IBinder token){
  int count=mHistory.size();
  HistoryRecord r=null;
  int index=-1;
  for (int i=count - 1; i >= 0; i--) {
    Object o=mHistory.get(i);
    if (o == token) {
      r=(HistoryRecord)o;
      index=i;
      break;
    }
  }
  return index;
}

Fixed version (ground truth):
private final int indexOfTokenLocked(IBinder token){
  int count=mHistory.size();
  int index=-1;
  for (int i=count - 1; i >= 0; i--) {
    Object o=mHistory.get(i);
    if (o == token) {
      index=i;
      break;
    }
  }
  return index;
}
Program: 22593
Project: 22593
Buggy source:
@Override public void computeScroll(){
  if (mScroller.computeScrollOffset()) {
    int oldX=mScrollX;
    int oldY=mScrollY;
    int x=mScroller.getCurrX();
    int y=mScroller.getCurrY();
    if (getChildCount() > 0) {
      View child=getChildAt(0);
      x=clamp(x,getWidth() - mPaddingRight - mPaddingLeft,child.getWidth());
      y=clamp(y,getHeight() - mPaddingBottom - mPaddingTop,child.getHeight());
      if (x != oldX || y != oldY) {
        mScrollX=x;
        mScrollY=y;
        onScrollChanged(x,y,oldX,oldY);
      }
    }
    postInvalidate();
  }
}

Fixed version (ground truth):
@Override public void computeScroll(){
  if (mScroller.computeScrollOffset()) {
    int oldX=mScrollX;
    int oldY=mScrollY;
    int x=mScroller.getCurrX();
    int y=mScroller.getCurrY();
    if (getChildCount() > 0) {
      View child=getChildAt(0);
      x=clamp(x,getWidth() - mPaddingRight - mPaddingLeft,child.getWidth());
      y=clamp(y,getHeight() - mPaddingBottom - mPaddingTop,child.getHeight());
      if (x != oldX || y != oldY) {
        mScrollX=x;
        mScrollY=y;
        onScrollChanged(x,y,oldX,oldY);
      }
    }
    awakenScrollBars();
    postInvalidate();
  }
}
Program: 22594
Project: 22594
Buggy source:
@Override public void computeScroll(){
  if (mScroller.computeScrollOffset()) {
    int oldX=mScrollX;
    int oldY=mScrollY;
    int x=mScroller.getCurrX();
    int y=mScroller.getCurrY();
    if (getChildCount() > 0) {
      View child=getChildAt(0);
      x=clamp(x,getWidth() - mPaddingRight - mPaddingLeft,child.getWidth());
      y=clamp(y,getHeight() - mPaddingBottom - mPaddingTop,child.getHeight());
      if (x != oldX || y != oldY) {
        mScrollX=x;
        mScrollY=y;
        onScrollChanged(x,y,oldX,oldY);
      }
    }
    postInvalidate();
  }
}

Fixed version (ground truth):
@Override public void computeScroll(){
  if (mScroller.computeScrollOffset()) {
    int oldX=mScrollX;
    int oldY=mScrollY;
    int x=mScroller.getCurrX();
    int y=mScroller.getCurrY();
    if (getChildCount() > 0) {
      View child=getChildAt(0);
      x=clamp(x,getWidth() - mPaddingRight - mPaddingLeft,child.getWidth());
      y=clamp(y,getHeight() - mPaddingBottom - mPaddingTop,child.getHeight());
      if (x != oldX || y != oldY) {
        mScrollX=x;
        mScrollY=y;
        onScrollChanged(x,y,oldX,oldY);
      }
    }
    awakenScrollBars();
    postInvalidate();
  }
}
Program: 22596
Project: 22596
Buggy source:
private void installNewPackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,String installerPackageName,PackageInstalledInfo res){
  String pkgName=pkg.packageName;
  boolean dataDirExists=getDataPathForPackage(pkg).exists();
  res.name=pkgName;
synchronized (mPackages) {
    if (mPackages.containsKey(pkgName) || mAppDirs.containsKey(pkg.mPath)) {
      Slog.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str");
      res.returnCode=PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
      return;
    }
  }
  mLastScanError=PackageManager.INSTALL_SUCCEEDED;
  PackageParser.Package newPackage=scanPackageLI(pkg,parseFlags,scanMode);
  if (newPackage == null) {
    Slog.w(TAG,"String_Node_Str" + pkg.mPath);
    if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
      res.returnCode=PackageManager.INSTALL_FAILED_INVALID_APK;
    }
  }
 else {
    updateSettingsLI(newPackage,installerPackageName,res);
    if (res.returnCode != PackageManager.INSTALL_SUCCEEDED) {
      deletePackageLI(pkgName,false,dataDirExists ? PackageManager.DONT_DELETE_DATA : 0,res.removedInfo);
    }
  }
}

Fixed version (ground truth):
private void installNewPackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,String installerPackageName,PackageInstalledInfo res){
  String pkgName=pkg.packageName;
  boolean dataDirExists=getDataPathForPackage(pkg).exists();
  res.name=pkgName;
synchronized (mPackages) {
    if (mSettings.mRenamedPackages.containsKey(pkgName)) {
      Slog.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str"+ mSettings.mRenamedPackages.get(pkgName));
      res.returnCode=PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
      return;
    }
    if (mPackages.containsKey(pkgName) || mAppDirs.containsKey(pkg.mPath)) {
      Slog.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str");
      res.returnCode=PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
      return;
    }
  }
  mLastScanError=PackageManager.INSTALL_SUCCEEDED;
  PackageParser.Package newPackage=scanPackageLI(pkg,parseFlags,scanMode);
  if (newPackage == null) {
    Slog.w(TAG,"String_Node_Str" + pkg.mPath);
    if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
      res.returnCode=PackageManager.INSTALL_FAILED_INVALID_APK;
    }
  }
 else {
    updateSettingsLI(newPackage,installerPackageName,res);
    if (res.returnCode != PackageManager.INSTALL_SUCCEEDED) {
      deletePackageLI(pkgName,false,dataDirExists ? PackageManager.DONT_DELETE_DATA : 0,res.removedInfo);
    }
  }
}
Program: 22598
Project: 22598
Buggy source:
private void installNewPackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,String installerPackageName,PackageInstalledInfo res){
  String pkgName=pkg.packageName;
  boolean dataDirExists=getDataPathForPackage(pkg).exists();
  res.name=pkgName;
synchronized (mPackages) {
    if (mPackages.containsKey(pkgName) || mAppDirs.containsKey(pkg.mPath)) {
      Slog.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str");
      res.returnCode=PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
      return;
    }
  }
  mLastScanError=PackageManager.INSTALL_SUCCEEDED;
  PackageParser.Package newPackage=scanPackageLI(pkg,parseFlags,scanMode);
  if (newPackage == null) {
    Slog.w(TAG,"String_Node_Str" + pkg.mPath);
    if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
      res.returnCode=PackageManager.INSTALL_FAILED_INVALID_APK;
    }
  }
 else {
    updateSettingsLI(newPackage,installerPackageName,res);
    if (res.returnCode != PackageManager.INSTALL_SUCCEEDED) {
      deletePackageLI(pkgName,false,dataDirExists ? PackageManager.DONT_DELETE_DATA : 0,res.removedInfo);
    }
  }
}

Fixed version (ground truth):
private void installNewPackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,String installerPackageName,PackageInstalledInfo res){
  String pkgName=pkg.packageName;
  boolean dataDirExists=getDataPathForPackage(pkg).exists();
  res.name=pkgName;
synchronized (mPackages) {
    if (mSettings.mRenamedPackages.containsKey(pkgName)) {
      Slog.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str"+ mSettings.mRenamedPackages.get(pkgName));
      res.returnCode=PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
      return;
    }
    if (mPackages.containsKey(pkgName) || mAppDirs.containsKey(pkg.mPath)) {
      Slog.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str");
      res.returnCode=PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
      return;
    }
  }
  mLastScanError=PackageManager.INSTALL_SUCCEEDED;
  PackageParser.Package newPackage=scanPackageLI(pkg,parseFlags,scanMode);
  if (newPackage == null) {
    Slog.w(TAG,"String_Node_Str" + pkg.mPath);
    if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
      res.returnCode=PackageManager.INSTALL_FAILED_INVALID_APK;
    }
  }
 else {
    updateSettingsLI(newPackage,installerPackageName,res);
    if (res.returnCode != PackageManager.INSTALL_SUCCEEDED) {
      deletePackageLI(pkgName,false,dataDirExists ? PackageManager.DONT_DELETE_DATA : 0,res.removedInfo);
    }
  }
}
Program: 22600
Project: 22600
Buggy source:
private void installNewPackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,String installerPackageName,PackageInstalledInfo res){
  String pkgName=pkg.packageName;
  boolean dataDirExists=getDataPathForPackage(pkg).exists();
  res.name=pkgName;
synchronized (mPackages) {
    if (mPackages.containsKey(pkgName) || mAppDirs.containsKey(pkg.mPath)) {
      Slog.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str");
      res.returnCode=PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
      return;
    }
  }
  mLastScanError=PackageManager.INSTALL_SUCCEEDED;
  PackageParser.Package newPackage=scanPackageLI(pkg,parseFlags,scanMode);
  if (newPackage == null) {
    Slog.w(TAG,"String_Node_Str" + pkg.mPath);
    if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
      res.returnCode=PackageManager.INSTALL_FAILED_INVALID_APK;
    }
  }
 else {
    updateSettingsLI(newPackage,installerPackageName,res);
    if (res.returnCode != PackageManager.INSTALL_SUCCEEDED) {
      deletePackageLI(pkgName,false,dataDirExists ? PackageManager.DONT_DELETE_DATA : 0,res.removedInfo);
    }
  }
}

Fixed version (ground truth):
private void installNewPackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,String installerPackageName,PackageInstalledInfo res){
  String pkgName=pkg.packageName;
  boolean dataDirExists=getDataPathForPackage(pkg).exists();
  res.name=pkgName;
synchronized (mPackages) {
    if (mSettings.mRenamedPackages.containsKey(pkgName)) {
      Slog.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str"+ mSettings.mRenamedPackages.get(pkgName));
      res.returnCode=PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
      return;
    }
    if (mPackages.containsKey(pkgName) || mAppDirs.containsKey(pkg.mPath)) {
      Slog.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str");
      res.returnCode=PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
      return;
    }
  }
  mLastScanError=PackageManager.INSTALL_SUCCEEDED;
  PackageParser.Package newPackage=scanPackageLI(pkg,parseFlags,scanMode);
  if (newPackage == null) {
    Slog.w(TAG,"String_Node_Str" + pkg.mPath);
    if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
      res.returnCode=PackageManager.INSTALL_FAILED_INVALID_APK;
    }
  }
 else {
    updateSettingsLI(newPackage,installerPackageName,res);
    if (res.returnCode != PackageManager.INSTALL_SUCCEEDED) {
      deletePackageLI(pkgName,false,dataDirExists ? PackageManager.DONT_DELETE_DATA : 0,res.removedInfo);
    }
  }
}
Program: 22614
Project: 22614
Buggy source:
/** 
 * Retrieve the current textual label associated with this item.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the item's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  if (labelRes != 0) {
    CharSequence label=pm.getText(packageName,labelRes,null);
    if (label != null) {
      return label;
    }
  }
  if (name != null) {
    return name;
  }
  return packageName;
}

Fixed version (ground truth):
/** 
 * Retrieve the current textual label associated with this item.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the item's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  if (labelRes != 0) {
    CharSequence label=pm.getText(packageName,labelRes,null);
    if (label != null) {
      return label.toString().trim();
    }
  }
  if (name != null) {
    return name;
  }
  return packageName;
}
Program: 22615
Project: 22615
Buggy source:
/** 
 * Retrieve the current textual label associated with this resolution.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the resolutions's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  CharSequence label;
  if (resolvePackageName != null && labelRes != 0) {
    label=pm.getText(resolvePackageName,labelRes,null);
    if (label != null) {
      return label;
    }
  }
  ComponentInfo ci=activityInfo != null ? activityInfo : serviceInfo;
  ApplicationInfo ai=ci.applicationInfo;
  if (labelRes != 0) {
    label=pm.getText(ci.packageName,labelRes,ai);
    if (label != null) {
      return label;
    }
  }
  return ci.loadLabel(pm);
}

Fixed version (ground truth):
/** 
 * Retrieve the current textual label associated with this resolution.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the resolutions's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  CharSequence label;
  if (resolvePackageName != null && labelRes != 0) {
    label=pm.getText(resolvePackageName,labelRes,null);
    if (label != null) {
      return label.toString().trim();
    }
  }
  ComponentInfo ci=activityInfo != null ? activityInfo : serviceInfo;
  ApplicationInfo ai=ci.applicationInfo;
  if (labelRes != 0) {
    label=pm.getText(ci.packageName,labelRes,ai);
    if (label != null) {
      return label.toString().trim();
    }
  }
  CharSequence data=ci.loadLabel(pm);
  if (data != null)   data=data.toString().trim();
  return data;
}
Program: 22616
Project: 22616
Buggy source:
/** 
 * Retrieve the current textual label associated with this item.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the item's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  if (labelRes != 0) {
    CharSequence label=pm.getText(packageName,labelRes,null);
    if (label != null) {
      return label;
    }
  }
  if (name != null) {
    return name;
  }
  return packageName;
}

Fixed version (ground truth):
/** 
 * Retrieve the current textual label associated with this item.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the item's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  if (labelRes != 0) {
    CharSequence label=pm.getText(packageName,labelRes,null);
    if (label != null) {
      return label.toString().trim();
    }
  }
  if (name != null) {
    return name;
  }
  return packageName;
}
Program: 22617
Project: 22617
Buggy source:
/** 
 * Retrieve the current textual label associated with this resolution.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the resolutions's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  CharSequence label;
  if (resolvePackageName != null && labelRes != 0) {
    label=pm.getText(resolvePackageName,labelRes,null);
    if (label != null) {
      return label;
    }
  }
  ComponentInfo ci=activityInfo != null ? activityInfo : serviceInfo;
  ApplicationInfo ai=ci.applicationInfo;
  if (labelRes != 0) {
    label=pm.getText(ci.packageName,labelRes,ai);
    if (label != null) {
      return label;
    }
  }
  return ci.loadLabel(pm);
}

Fixed version (ground truth):
/** 
 * Retrieve the current textual label associated with this resolution.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the resolutions's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  CharSequence label;
  if (resolvePackageName != null && labelRes != 0) {
    label=pm.getText(resolvePackageName,labelRes,null);
    if (label != null) {
      return label.toString().trim();
    }
  }
  ComponentInfo ci=activityInfo != null ? activityInfo : serviceInfo;
  ApplicationInfo ai=ci.applicationInfo;
  if (labelRes != 0) {
    label=pm.getText(ci.packageName,labelRes,ai);
    if (label != null) {
      return label.toString().trim();
    }
  }
  CharSequence data=ci.loadLabel(pm);
  if (data != null)   data=data.toString().trim();
  return data;
}
Program: 22618
Project: 22618
Buggy source:
/** 
 * Retrieve the current textual label associated with this item.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the item's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  if (labelRes != 0) {
    CharSequence label=pm.getText(packageName,labelRes,null);
    if (label != null) {
      return label;
    }
  }
  if (name != null) {
    return name;
  }
  return packageName;
}

Fixed version (ground truth):
/** 
 * Retrieve the current textual label associated with this item.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the item's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  if (labelRes != 0) {
    CharSequence label=pm.getText(packageName,labelRes,null);
    if (label != null) {
      return label.toString().trim();
    }
  }
  if (name != null) {
    return name;
  }
  return packageName;
}
Program: 22619
Project: 22619
Buggy source:
/** 
 * Retrieve the current textual label associated with this resolution.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the resolutions's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  CharSequence label;
  if (resolvePackageName != null && labelRes != 0) {
    label=pm.getText(resolvePackageName,labelRes,null);
    if (label != null) {
      return label;
    }
  }
  ComponentInfo ci=activityInfo != null ? activityInfo : serviceInfo;
  ApplicationInfo ai=ci.applicationInfo;
  if (labelRes != 0) {
    label=pm.getText(ci.packageName,labelRes,ai);
    if (label != null) {
      return label;
    }
  }
  return ci.loadLabel(pm);
}

Fixed version (ground truth):
/** 
 * Retrieve the current textual label associated with this resolution.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the resolutions's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  CharSequence label;
  if (resolvePackageName != null && labelRes != 0) {
    label=pm.getText(resolvePackageName,labelRes,null);
    if (label != null) {
      return label.toString().trim();
    }
  }
  ComponentInfo ci=activityInfo != null ? activityInfo : serviceInfo;
  ApplicationInfo ai=ci.applicationInfo;
  if (labelRes != 0) {
    label=pm.getText(ci.packageName,labelRes,ai);
    if (label != null) {
      return label.toString().trim();
    }
  }
  CharSequence data=ci.loadLabel(pm);
  if (data != null)   data=data.toString().trim();
  return data;
}
Program: 22620
Project: 22620
Buggy source:
/** 
 * Retrieve the current textual label associated with this item.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the item's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  if (labelRes != 0) {
    CharSequence label=pm.getText(packageName,labelRes,null);
    if (label != null) {
      return label;
    }
  }
  if (name != null) {
    return name;
  }
  return packageName;
}

Fixed version (ground truth):
/** 
 * Retrieve the current textual label associated with this item.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the item's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  if (labelRes != 0) {
    CharSequence label=pm.getText(packageName,labelRes,null);
    if (label != null) {
      return label.toString().trim();
    }
  }
  if (name != null) {
    return name;
  }
  return packageName;
}
Program: 22621
Project: 22621
Buggy source:
/** 
 * Retrieve the current textual label associated with this resolution.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the resolutions's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  CharSequence label;
  if (resolvePackageName != null && labelRes != 0) {
    label=pm.getText(resolvePackageName,labelRes,null);
    if (label != null) {
      return label;
    }
  }
  ComponentInfo ci=activityInfo != null ? activityInfo : serviceInfo;
  ApplicationInfo ai=ci.applicationInfo;
  if (labelRes != 0) {
    label=pm.getText(ci.packageName,labelRes,ai);
    if (label != null) {
      return label;
    }
  }
  return ci.loadLabel(pm);
}

Fixed version (ground truth):
/** 
 * Retrieve the current textual label associated with this resolution.  This will call back on the given PackageManager to load the label from the application.
 * @param pm A PackageManager from which the label can be loaded; usuallythe PackageManager from which you originally retrieved this item.
 * @return Returns a CharSequence containing the resolutions's label.  If theitem does not have a label, its name is returned.
 */
public CharSequence loadLabel(PackageManager pm){
  if (nonLocalizedLabel != null) {
    return nonLocalizedLabel;
  }
  CharSequence label;
  if (resolvePackageName != null && labelRes != 0) {
    label=pm.getText(resolvePackageName,labelRes,null);
    if (label != null) {
      return label.toString().trim();
    }
  }
  ComponentInfo ci=activityInfo != null ? activityInfo : serviceInfo;
  ApplicationInfo ai=ci.applicationInfo;
  if (labelRes != 0) {
    label=pm.getText(ci.packageName,labelRes,ai);
    if (label != null) {
      return label.toString().trim();
    }
  }
  CharSequence data=ci.loadLabel(pm);
  if (data != null)   data=data.toString().trim();
  return data;
}
Program: 22622
Project: 22622
Buggy source:
private static void showUsage(){
  System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
private static void showUsage(){
  System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 22625
Project: 22625
Buggy source:
private static void showUsage(){
  System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
private static void showUsage(){
  System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 22628
Project: 22628
Buggy source:
private static void showUsage(){
  System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
private static void showUsage(){
  System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 22631
Project: 22631
Buggy source:
void startSpringback(){
  if (mScroller.springback(0,mScrollY,0,0,0,0)) {
    mTouchMode=TOUCH_MODE_OVERFLING;
    invalidate();
    post(this);
  }
}

Fixed version (ground truth):
void startSpringback(){
  if (mScroller.springback(0,mScrollY,0,0,0,0)) {
    mTouchMode=TOUCH_MODE_OVERFLING;
    invalidate();
    post(this);
  }
 else {
    mTouchMode=TOUCH_MODE_REST;
  }
}
Program: 22632
Project: 22632
Buggy source:
void startSpringback(){
  if (mScroller.springback(0,mScrollY,0,0,0,0)) {
    mTouchMode=TOUCH_MODE_OVERFLING;
    invalidate();
    post(this);
  }
}

Fixed version (ground truth):
void startSpringback(){
  if (mScroller.springback(0,mScrollY,0,0,0,0)) {
    mTouchMode=TOUCH_MODE_OVERFLING;
    invalidate();
    post(this);
  }
 else {
    mTouchMode=TOUCH_MODE_REST;
  }
}
Program: 22634
Project: 22634
Buggy source:
/** 
 * Have the surface flinger show a surface, robustly dealing with error conditions.  In particular, if there is not enough memory to show the surface, then we will try to get rid of other surfaces in order to succeed.
 * @return Returns true if the surface was successfully shown.
 */
boolean showSurfaceRobustlyLocked(WindowState win){
  try {
    if (win.mSurface != null) {
      win.mSurface.show();
      if (win.mTurnOnScreen) {
        if (DEBUG_VISIBILITY)         Slog.v(TAG,"String_Node_Str" + win);
        win.mTurnOnScreen=false;
        mTurnOnScreen=true;
      }
    }
    return true;
  }
 catch (  RuntimeException e) {
    Slog.w(TAG,"String_Node_Str" + win.mSurface + "String_Node_Str"+ win);
  }
  reclaimSomeSurfaceMemoryLocked(win,"String_Node_Str");
  return false;
}

Fixed version (ground truth):
/** 
 * Have the surface flinger show a surface, robustly dealing with error conditions.  In particular, if there is not enough memory to show the surface, then we will try to get rid of other surfaces in order to succeed.
 * @return Returns true if the surface was successfully shown.
 */
boolean showSurfaceRobustlyLocked(WindowState win){
  try {
    if (win.mSurface != null) {
      win.mSurfaceShown=true;
      win.mSurface.show();
      if (win.mTurnOnScreen) {
        if (DEBUG_VISIBILITY)         Slog.v(TAG,"String_Node_Str" + win);
        win.mTurnOnScreen=false;
        mTurnOnScreen=true;
      }
    }
    return true;
  }
 catch (  RuntimeException e) {
    Slog.w(TAG,"String_Node_Str" + win.mSurface + "String_Node_Str"+ win);
  }
  reclaimSomeSurfaceMemoryLocked(win,"String_Node_Str");
  return false;
}
Program: 22636
Project: 22636
Buggy source:
/** 
 * Show the dim surface.
 */
void show(int dw,int dh){
  if (SHOW_TRANSACTIONS)   Slog.i(TAG,"String_Node_Str" + mDimSurface + "String_Node_Str"+ dw+ "String_Node_Str"+ dh+ "String_Node_Str");
  mDimShown=true;
  try {
    mDimSurface.setPosition(0,0);
    mDimSurface.setSize(dw,dh);
    mDimSurface.show();
  }
 catch (  RuntimeException e) {
    Slog.w(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Show the dim surface.
 */
void show(int dw,int dh){
  if (!mDimShown) {
    if (SHOW_TRANSACTIONS)     Slog.i(TAG,"String_Node_Str" + mDimSurface + "String_Node_Str"+ dw+ "String_Node_Str"+ dh+ "String_Node_Str");
    mDimShown=true;
    try {
      mDimSurface.setPosition(0,0);
      mDimSurface.setSize(dw,dh);
      mDimSurface.show();
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str",e);
    }
  }
}
Program: 22637
Project: 22637
Buggy source:
void finishExit(){
  if (DEBUG_ANIM)   Slog.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ mExiting+ "String_Node_Str"+ mRemoveOnExit+ "String_Node_Str"+ isWindowAnimating());
  final int N=mChildWindows.size();
  for (int i=0; i < N; i++) {
    ((WindowState)mChildWindows.get(i)).finishExit();
  }
  if (!mExiting) {
    return;
  }
  if (isWindowAnimating()) {
    return;
  }
  if (localLOGV)   Slog.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ mRemoveOnExit);
  if (mSurface != null) {
    mDestroySurface.add(this);
    mDestroying=true;
    if (SHOW_TRANSACTIONS)     logSurface(this,"String_Node_Str",null);
    try {
      mSurface.hide();
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str" + this,e);
    }
    mLastHidden=true;
    mKeyWaiter.releasePendingPointerLocked(mSession);
  }
  mExiting=false;
  if (mRemoveOnExit) {
    mPendingRemove.add(this);
    mRemoveOnExit=false;
  }
}

Fixed version (ground truth):
void finishExit(){
  if (DEBUG_ANIM)   Slog.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ mExiting+ "String_Node_Str"+ mRemoveOnExit+ "String_Node_Str"+ isWindowAnimating());
  final int N=mChildWindows.size();
  for (int i=0; i < N; i++) {
    ((WindowState)mChildWindows.get(i)).finishExit();
  }
  if (!mExiting) {
    return;
  }
  if (isWindowAnimating()) {
    return;
  }
  if (localLOGV)   Slog.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ mRemoveOnExit);
  if (mSurface != null) {
    mDestroySurface.add(this);
    mDestroying=true;
    if (SHOW_TRANSACTIONS)     logSurface(this,"String_Node_Str",null);
    mSurfaceShown=false;
    try {
      mSurface.hide();
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str" + this,e);
    }
    mLastHidden=true;
    mKeyWaiter.releasePendingPointerLocked(mSession);
  }
  mExiting=false;
  if (mRemoveOnExit) {
    mPendingRemove.add(this);
    mRemoveOnExit=false;
  }
}
Program: 22641
Project: 22641
Buggy source:
/** 
 * Have the surface flinger show a surface, robustly dealing with error conditions.  In particular, if there is not enough memory to show the surface, then we will try to get rid of other surfaces in order to succeed.
 * @return Returns true if the surface was successfully shown.
 */
boolean showSurfaceRobustlyLocked(WindowState win){
  try {
    if (win.mSurface != null) {
      win.mSurface.show();
      if (win.mTurnOnScreen) {
        if (DEBUG_VISIBILITY)         Slog.v(TAG,"String_Node_Str" + win);
        win.mTurnOnScreen=false;
        mTurnOnScreen=true;
      }
    }
    return true;
  }
 catch (  RuntimeException e) {
    Slog.w(TAG,"String_Node_Str" + win.mSurface + "String_Node_Str"+ win);
  }
  reclaimSomeSurfaceMemoryLocked(win,"String_Node_Str");
  return false;
}

Fixed version (ground truth):
/** 
 * Have the surface flinger show a surface, robustly dealing with error conditions.  In particular, if there is not enough memory to show the surface, then we will try to get rid of other surfaces in order to succeed.
 * @return Returns true if the surface was successfully shown.
 */
boolean showSurfaceRobustlyLocked(WindowState win){
  try {
    if (win.mSurface != null) {
      win.mSurfaceShown=true;
      win.mSurface.show();
      if (win.mTurnOnScreen) {
        if (DEBUG_VISIBILITY)         Slog.v(TAG,"String_Node_Str" + win);
        win.mTurnOnScreen=false;
        mTurnOnScreen=true;
      }
    }
    return true;
  }
 catch (  RuntimeException e) {
    Slog.w(TAG,"String_Node_Str" + win.mSurface + "String_Node_Str"+ win);
  }
  reclaimSomeSurfaceMemoryLocked(win,"String_Node_Str");
  return false;
}
Program: 22643
Project: 22643
Buggy source:
/** 
 * Show the dim surface.
 */
void show(int dw,int dh){
  if (SHOW_TRANSACTIONS)   Slog.i(TAG,"String_Node_Str" + mDimSurface + "String_Node_Str"+ dw+ "String_Node_Str"+ dh+ "String_Node_Str");
  mDimShown=true;
  try {
    mDimSurface.setPosition(0,0);
    mDimSurface.setSize(dw,dh);
    mDimSurface.show();
  }
 catch (  RuntimeException e) {
    Slog.w(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Show the dim surface.
 */
void show(int dw,int dh){
  if (!mDimShown) {
    if (SHOW_TRANSACTIONS)     Slog.i(TAG,"String_Node_Str" + mDimSurface + "String_Node_Str"+ dw+ "String_Node_Str"+ dh+ "String_Node_Str");
    mDimShown=true;
    try {
      mDimSurface.setPosition(0,0);
      mDimSurface.setSize(dw,dh);
      mDimSurface.show();
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str",e);
    }
  }
}
Program: 22644
Project: 22644
Buggy source:
void finishExit(){
  if (DEBUG_ANIM)   Slog.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ mExiting+ "String_Node_Str"+ mRemoveOnExit+ "String_Node_Str"+ isWindowAnimating());
  final int N=mChildWindows.size();
  for (int i=0; i < N; i++) {
    ((WindowState)mChildWindows.get(i)).finishExit();
  }
  if (!mExiting) {
    return;
  }
  if (isWindowAnimating()) {
    return;
  }
  if (localLOGV)   Slog.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ mRemoveOnExit);
  if (mSurface != null) {
    mDestroySurface.add(this);
    mDestroying=true;
    if (SHOW_TRANSACTIONS)     logSurface(this,"String_Node_Str",null);
    try {
      mSurface.hide();
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str" + this,e);
    }
    mLastHidden=true;
    mKeyWaiter.releasePendingPointerLocked(mSession);
  }
  mExiting=false;
  if (mRemoveOnExit) {
    mPendingRemove.add(this);
    mRemoveOnExit=false;
  }
}

Fixed version (ground truth):
void finishExit(){
  if (DEBUG_ANIM)   Slog.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ mExiting+ "String_Node_Str"+ mRemoveOnExit+ "String_Node_Str"+ isWindowAnimating());
  final int N=mChildWindows.size();
  for (int i=0; i < N; i++) {
    ((WindowState)mChildWindows.get(i)).finishExit();
  }
  if (!mExiting) {
    return;
  }
  if (isWindowAnimating()) {
    return;
  }
  if (localLOGV)   Slog.v(TAG,"String_Node_Str" + this + "String_Node_Str"+ mRemoveOnExit);
  if (mSurface != null) {
    mDestroySurface.add(this);
    mDestroying=true;
    if (SHOW_TRANSACTIONS)     logSurface(this,"String_Node_Str",null);
    mSurfaceShown=false;
    try {
      mSurface.hide();
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str" + this,e);
    }
    mLastHidden=true;
    mKeyWaiter.releasePendingPointerLocked(mSession);
  }
  mExiting=false;
  if (mRemoveOnExit) {
    mPendingRemove.add(this);
    mRemoveOnExit=false;
  }
}
Program: 22648
Project: 22648
Buggy source:
private void doUpdateWifiState(){
  boolean wifiEnabled=getPersistedWifiEnabled();
  boolean airplaneMode=isAirplaneModeOn() && !mAirplaneModeOverwridden;
  boolean lockHeld=mLocks.hasLocks();
  int strongestLockMode;
  boolean wifiShouldBeEnabled=wifiEnabled && !airplaneMode;
  boolean wifiShouldBeStarted=!mDeviceIdle || lockHeld;
  if (mDeviceIdle && lockHeld) {
    strongestLockMode=mLocks.getStrongestLockMode();
  }
 else {
    strongestLockMode=WifiManager.WIFI_MODE_FULL;
  }
synchronized (mWifiHandler) {
    if ((mWifiStateTracker.getWifiState() == WIFI_STATE_ENABLING) && !airplaneMode) {
      return;
    }
    if (wifiShouldBeEnabled) {
      if (wifiShouldBeStarted) {
        sWakeLock.acquire();
        sendEnableMessage(true,false,mLastEnableUid);
        sWakeLock.acquire();
        sendStartMessage(strongestLockMode == WifiManager.WIFI_MODE_SCAN_ONLY);
      }
 else {
        int wakeLockTimeout=Settings.Secure.getInt(mContext.getContentResolver(),Settings.Secure.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS,DEFAULT_WAKELOCK_TIMEOUT);
        sDriverStopWakeLock.acquire();
        mWifiHandler.sendEmptyMessage(MESSAGE_STOP_WIFI);
        mWifiHandler.sendEmptyMessageDelayed(MESSAGE_RELEASE_WAKELOCK,wakeLockTimeout);
      }
    }
 else {
      sWakeLock.acquire();
      sendEnableMessage(false,false,mLastEnableUid);
    }
  }
}

Fixed version (ground truth):
private void doUpdateWifiState(){
  boolean wifiEnabled=getPersistedWifiEnabled();
  boolean airplaneMode=isAirplaneModeOn() && !mAirplaneModeOverwridden;
  boolean lockHeld=mLocks.hasLocks();
  int strongestLockMode;
  boolean wifiShouldBeEnabled=wifiEnabled && !airplaneMode;
  boolean wifiShouldBeStarted=!mDeviceIdle || lockHeld;
  if (mDeviceIdle && lockHeld) {
    strongestLockMode=mLocks.getStrongestLockMode();
  }
 else {
    strongestLockMode=WifiManager.WIFI_MODE_FULL;
  }
synchronized (mWifiHandler) {
    if ((mWifiStateTracker.getWifiState() == WIFI_STATE_ENABLING) && !airplaneMode) {
      return;
    }
    if (wifiShouldBeEnabled) {
      if (wifiShouldBeStarted) {
        sWakeLock.acquire();
        sendEnableMessage(true,false,mLastEnableUid);
        sWakeLock.acquire();
        sendStartMessage(strongestLockMode == WifiManager.WIFI_MODE_SCAN_ONLY);
      }
 else       if (!mWifiStateTracker.isDriverStopped()) {
        int wakeLockTimeout=Settings.Secure.getInt(mContext.getContentResolver(),Settings.Secure.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS,DEFAULT_WAKELOCK_TIMEOUT);
        sDriverStopWakeLock.acquire();
        mWifiHandler.sendEmptyMessage(MESSAGE_STOP_WIFI);
        mWifiHandler.sendEmptyMessageDelayed(MESSAGE_RELEASE_WAKELOCK,wakeLockTimeout);
      }
    }
 else {
      sWakeLock.acquire();
      sendEnableMessage(false,false,mLastEnableUid);
    }
  }
}
Program: 22649
Project: 22649
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MESSAGE_ENABLE_WIFI:
    if (mWifiWatchdogService == null) {
      mWifiWatchdogService=new WifiWatchdogService(mContext,mWifiStateTracker);
    }
  setWifiEnabledBlocking(true,msg.arg1 == 1,msg.arg2);
sWakeLock.release();
break;
case MESSAGE_START_WIFI:
mWifiStateTracker.setScanOnlyMode(msg.arg1 != 0);
mWifiStateTracker.restart();
sWakeLock.release();
break;
case MESSAGE_UPDATE_STATE:
doUpdateWifiState();
break;
case MESSAGE_DISABLE_WIFI:
setWifiEnabledBlocking(false,msg.arg1 == 1,msg.arg2);
if (mWifiWatchdogService != null) {
mWifiWatchdogService.quit();
mWifiWatchdogService=null;
}
sWakeLock.release();
break;
case MESSAGE_STOP_WIFI:
mWifiStateTracker.disconnectAndStop();
break;
case MESSAGE_RELEASE_WAKELOCK:
synchronized (sDriverStopWakeLock) {
if (sDriverStopWakeLock.isHeld()) {
sDriverStopWakeLock.release();
}
}
break;
case MESSAGE_START_ACCESS_POINT:
setWifiApEnabledBlocking(true,msg.arg1,(WifiConfiguration)msg.obj);
sWakeLock.release();
break;
case MESSAGE_STOP_ACCESS_POINT:
setWifiApEnabledBlocking(false,msg.arg1,(WifiConfiguration)msg.obj);
sWakeLock.release();
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MESSAGE_ENABLE_WIFI:
    if (mWifiWatchdogService == null) {
      mWifiWatchdogService=new WifiWatchdogService(mContext,mWifiStateTracker);
    }
  setWifiEnabledBlocking(true,msg.arg1 == 1,msg.arg2);
sWakeLock.release();
break;
case MESSAGE_START_WIFI:
mWifiStateTracker.setScanOnlyMode(msg.arg1 != 0);
mWifiStateTracker.restart();
sWakeLock.release();
break;
case MESSAGE_UPDATE_STATE:
doUpdateWifiState();
break;
case MESSAGE_DISABLE_WIFI:
setWifiEnabledBlocking(false,msg.arg1 == 1,msg.arg2);
if (mWifiWatchdogService != null) {
mWifiWatchdogService.quit();
mWifiWatchdogService=null;
}
sWakeLock.release();
break;
case MESSAGE_STOP_WIFI:
mWifiStateTracker.disconnectAndStop();
break;
case MESSAGE_RELEASE_WAKELOCK:
sDriverStopWakeLock.release();
break;
case MESSAGE_START_ACCESS_POINT:
setWifiApEnabledBlocking(true,msg.arg1,(WifiConfiguration)msg.obj);
sWakeLock.release();
break;
case MESSAGE_STOP_ACCESS_POINT:
setWifiApEnabledBlocking(false,msg.arg1,(WifiConfiguration)msg.obj);
sWakeLock.release();
break;
}
}
Program: 22650
Project: 22650
Buggy source:
/** 
 * We want to stop the driver, but if we're connected to a network, we first want to disconnect, so that the supplicant is always in a known state (DISCONNECTED) when the driver is stopped.
 * @return {@code true} if the operation succeeds, which means that thedisconnect or stop command was initiated.
 */
public synchronized boolean disconnectAndStop(){
  if (mRunState != RUN_STATE_STOPPING && mRunState != RUN_STATE_STOPPED) {
    setNotificationVisible(false,0,false,0);
    mRunState=RUN_STATE_STOPPING;
    if (mWifiInfo.getSupplicantState() == SupplicantState.DORMANT) {
      return stopDriver();
    }
 else {
      return disconnect();
    }
  }
 else {
    releaseWakeLock();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * We want to stop the driver, but if we're connected to a network, we first want to disconnect, so that the supplicant is always in a known state (DISCONNECTED) when the driver is stopped.
 * @return {@code true} if the operation succeeds, which means that thedisconnect or stop command was initiated.
 */
public synchronized boolean disconnectAndStop(){
  if (mRunState != RUN_STATE_STOPPING && mRunState != RUN_STATE_STOPPED) {
    setNotificationVisible(false,0,false,0);
    mRunState=RUN_STATE_STOPPING;
    if (mWifiInfo.getSupplicantState() == SupplicantState.DORMANT) {
      return stopDriver();
    }
 else {
      return disconnect();
    }
  }
  return true;
}
Program: 22651
Project: 22651
Buggy source:
private synchronized boolean isDriverStopped(){
  return mRunState == RUN_STATE_STOPPED || mRunState == RUN_STATE_STOPPING;
}

Fixed version (ground truth):
/** 
 * TODO: mRunState is not synchronized in some places address this as part of re-architect. TODO: We are exposing an additional public synchronized call for a wakelock optimization in WifiService. Remove it when we handle the wakelock in ConnectivityService.
 */
public synchronized boolean isDriverStopped(){
  return mRunState == RUN_STATE_STOPPED || mRunState == RUN_STATE_STOPPING;
}