nus-yam/ex-repair huggingface dataset:
Program: 1945
Project: 1945
Buggy source:
/** 
 * Change the security context of an existing file object.
 * @param path representing the path of file object to relabel.
 * @param con new security context given as a String.
 * @return a boolean indicating whether the operation succeeded.
 */
public static final native boolean setFileContext(String path,String context);

Fixed version (ground truth):
/** 
 * Change the security context of an existing file object.
 * @param path representing the path of file object to relabel.
 * @param context new security context given as a String.
 * @return a boolean indicating whether the operation succeeded.
 */
public static final native boolean setFileContext(String path,String context);
Program: 1946
Project: 1946
Buggy source:
/** 
 * Gets the value for the given SELinux boolean name.
 * @param String The name of the SELinux boolean.
 * @return a boolean indicating whether the SELinux boolean is set.
 */
public static final native boolean getBooleanValue(String name);

Fixed version (ground truth):
/** 
 * Gets the value for the given SELinux boolean name.
 * @param name The name of the SELinux boolean.
 * @return a boolean indicating whether the SELinux boolean is set.
 */
public static final native boolean getBooleanValue(String name);
Program: 1948
Project: 1948
Buggy source:
/** 
 * Used by   {@link #arrowScrollImpl(int)} to help determine the next selected positionto move to. This can return a position currently not represented by a view on screen but only in the direction given.
 * @param selectedPos Current selected position to move from
 * @param direction Direction to move in
 * @return Desired selected position after moving in the given direction
 */
private final int nextSelectedPositionForDirection(int selectedPos,int direction){
  int nextSelected;
  if (direction == View.FOCUS_DOWN) {
    nextSelected=selectedPos != INVALID_POSITION && selectedPos >= mFirstPosition ? selectedPos + 1 : mFirstPosition;
  }
 else {
    final int lastPos=mFirstPosition + getChildCount() - 1;
    nextSelected=selectedPos != INVALID_POSITION && selectedPos <= lastPos ? selectedPos - 1 : lastPos;
  }
  if (nextSelected < 0 || nextSelected >= mAdapter.getCount()) {
    return INVALID_POSITION;
  }
  return lookForSelectablePosition(nextSelected,direction == View.FOCUS_DOWN);
}

Fixed version (ground truth):
/** 
 * Used by   {@link #arrowScrollImpl(int)} to help determine the next selected positionto move to. This return a position in the direction given if the selected item is fully visible.
 * @param selectedView Current selected view to move from
 * @param selectedPos Current selected position to move from
 * @param direction Direction to move in
 * @return Desired selected position after moving in the given direction
 */
private final int nextSelectedPositionForDirection(View selectedView,int selectedPos,int direction){
  int nextSelected;
  if (direction == View.FOCUS_DOWN) {
    final int listBottom=getHeight() - mListPadding.bottom;
    if (selectedView != null && selectedView.getBottom() <= listBottom) {
      nextSelected=selectedPos != INVALID_POSITION && selectedPos >= mFirstPosition ? selectedPos + 1 : mFirstPosition;
    }
 else {
      return INVALID_POSITION;
    }
  }
 else {
    final int listTop=mListPadding.top;
    if (selectedView != null && selectedView.getTop() >= listTop) {
      final int lastPos=mFirstPosition + getChildCount() - 1;
      nextSelected=selectedPos != INVALID_POSITION && selectedPos <= lastPos ? selectedPos - 1 : lastPos;
    }
 else {
      return INVALID_POSITION;
    }
  }
  if (nextSelected < 0 || nextSelected >= mAdapter.getCount()) {
    return INVALID_POSITION;
  }
  return lookForSelectablePosition(nextSelected,direction == View.FOCUS_DOWN);
}
Program: 1949
Project: 1949
Buggy source:
private boolean doDeferEnable(Message msg){
  long delaySoFar=SystemClock.elapsedRealtime() - mDisabledTimestamp;
  if (delaySoFar > mReEnableDelayMillis) {
    return false;
  }
  log("String_Node_Str" + msg + "String_Node_Str"+ (mReEnableDelayMillis - delaySoFar)+ "String_Node_Str");
  Message deferredMsg=obtainMessage(CMD_DEFERRED_TOGGLE);
  deferredMsg.obj=Message.obtain(msg);
  deferredMsg.arg1=++mDeferredEnableSerialNumber;
  sendMessageDelayed(deferredMsg,mReEnableDelayMillis - delaySoFar);
  return true;
}

Fixed version (ground truth):
private boolean doDeferEnable(Message msg){
  long delaySoFar=SystemClock.elapsedRealtime() - mDisabledTimestamp;
  if (delaySoFar >= mReEnableDelayMillis) {
    return false;
  }
  log("String_Node_Str" + msg + "String_Node_Str"+ (mReEnableDelayMillis - delaySoFar)+ "String_Node_Str");
  Message deferredMsg=obtainMessage(CMD_DEFERRED_TOGGLE);
  deferredMsg.obj=Message.obtain(msg);
  deferredMsg.arg1=++mDeferredEnableSerialNumber;
  sendMessageDelayed(deferredMsg,mReEnableDelayMillis - delaySoFar);
  return true;
}
Program: 1955
Project: 1955
Buggy source:
/** 
 * Used by   {@link #arrowScrollImpl(int)} to help determine the next selected positionto move to. This can return a position currently not represented by a view on screen but only in the direction given.
 * @param selectedPos Current selected position to move from
 * @param direction Direction to move in
 * @return Desired selected position after moving in the given direction
 */
private final int nextSelectedPositionForDirection(int selectedPos,int direction){
  int nextSelected;
  if (direction == View.FOCUS_DOWN) {
    nextSelected=selectedPos != INVALID_POSITION && selectedPos >= mFirstPosition ? selectedPos + 1 : mFirstPosition;
  }
 else {
    final int lastPos=mFirstPosition + getChildCount() - 1;
    nextSelected=selectedPos != INVALID_POSITION && selectedPos <= lastPos ? selectedPos - 1 : lastPos;
  }
  if (nextSelected < 0 || nextSelected >= mAdapter.getCount()) {
    return INVALID_POSITION;
  }
  return lookForSelectablePosition(nextSelected,direction == View.FOCUS_DOWN);
}

Fixed version (ground truth):
/** 
 * Used by   {@link #arrowScrollImpl(int)} to help determine the next selected positionto move to. This return a position in the direction given if the selected item is fully visible.
 * @param selectedView Current selected view to move from
 * @param selectedPos Current selected position to move from
 * @param direction Direction to move in
 * @return Desired selected position after moving in the given direction
 */
private final int nextSelectedPositionForDirection(View selectedView,int selectedPos,int direction){
  int nextSelected;
  if (direction == View.FOCUS_DOWN) {
    final int listBottom=getHeight() - mListPadding.bottom;
    if (selectedView != null && selectedView.getBottom() <= listBottom) {
      nextSelected=selectedPos != INVALID_POSITION && selectedPos >= mFirstPosition ? selectedPos + 1 : mFirstPosition;
    }
 else {
      return INVALID_POSITION;
    }
  }
 else {
    final int listTop=mListPadding.top;
    if (selectedView != null && selectedView.getTop() >= listTop) {
      final int lastPos=mFirstPosition + getChildCount() - 1;
      nextSelected=selectedPos != INVALID_POSITION && selectedPos <= lastPos ? selectedPos - 1 : lastPos;
    }
 else {
      return INVALID_POSITION;
    }
  }
  if (nextSelected < 0 || nextSelected >= mAdapter.getCount()) {
    return INVALID_POSITION;
  }
  return lookForSelectablePosition(nextSelected,direction == View.FOCUS_DOWN);
}
Program: 1957
Project: 1957
Buggy source:
private boolean doDeferEnable(Message msg){
  long delaySoFar=SystemClock.elapsedRealtime() - mDisabledTimestamp;
  if (delaySoFar > mReEnableDelayMillis) {
    return false;
  }
  log("String_Node_Str" + msg + "String_Node_Str"+ (mReEnableDelayMillis - delaySoFar)+ "String_Node_Str");
  Message deferredMsg=obtainMessage(CMD_DEFERRED_TOGGLE);
  deferredMsg.obj=Message.obtain(msg);
  deferredMsg.arg1=++mDeferredEnableSerialNumber;
  sendMessageDelayed(deferredMsg,mReEnableDelayMillis - delaySoFar);
  return true;
}

Fixed version (ground truth):
private boolean doDeferEnable(Message msg){
  long delaySoFar=SystemClock.elapsedRealtime() - mDisabledTimestamp;
  if (delaySoFar >= mReEnableDelayMillis) {
    return false;
  }
  log("String_Node_Str" + msg + "String_Node_Str"+ (mReEnableDelayMillis - delaySoFar)+ "String_Node_Str");
  Message deferredMsg=obtainMessage(CMD_DEFERRED_TOGGLE);
  deferredMsg.obj=Message.obtain(msg);
  deferredMsg.arg1=++mDeferredEnableSerialNumber;
  sendMessageDelayed(deferredMsg,mReEnableDelayMillis - delaySoFar);
  return true;
}
Program: 1958
Project: 1958
Buggy source:
private boolean doDeferEnable(Message msg){
  long delaySoFar=SystemClock.elapsedRealtime() - mDisabledTimestamp;
  if (delaySoFar > mReEnableDelayMillis) {
    return false;
  }
  log("String_Node_Str" + msg + "String_Node_Str"+ (mReEnableDelayMillis - delaySoFar)+ "String_Node_Str");
  Message deferredMsg=obtainMessage(CMD_DEFERRED_TOGGLE);
  deferredMsg.obj=Message.obtain(msg);
  deferredMsg.arg1=++mDeferredEnableSerialNumber;
  sendMessageDelayed(deferredMsg,mReEnableDelayMillis - delaySoFar);
  return true;
}

Fixed version (ground truth):
private boolean doDeferEnable(Message msg){
  long delaySoFar=SystemClock.elapsedRealtime() - mDisabledTimestamp;
  if (delaySoFar >= mReEnableDelayMillis) {
    return false;
  }
  log("String_Node_Str" + msg + "String_Node_Str"+ (mReEnableDelayMillis - delaySoFar)+ "String_Node_Str");
  Message deferredMsg=obtainMessage(CMD_DEFERRED_TOGGLE);
  deferredMsg.obj=Message.obtain(msg);
  deferredMsg.arg1=++mDeferredEnableSerialNumber;
  sendMessageDelayed(deferredMsg,mReEnableDelayMillis - delaySoFar);
  return true;
}
Program: 1959
Project: 1959
Buggy source:
private boolean doDeferEnable(Message msg){
  long delaySoFar=SystemClock.elapsedRealtime() - mDisabledTimestamp;
  if (delaySoFar > mReEnableDelayMillis) {
    return false;
  }
  log("String_Node_Str" + msg + "String_Node_Str"+ (mReEnableDelayMillis - delaySoFar)+ "String_Node_Str");
  Message deferredMsg=obtainMessage(CMD_DEFERRED_TOGGLE);
  deferredMsg.obj=Message.obtain(msg);
  deferredMsg.arg1=++mDeferredEnableSerialNumber;
  sendMessageDelayed(deferredMsg,mReEnableDelayMillis - delaySoFar);
  return true;
}

Fixed version (ground truth):
private boolean doDeferEnable(Message msg){
  long delaySoFar=SystemClock.elapsedRealtime() - mDisabledTimestamp;
  if (delaySoFar >= mReEnableDelayMillis) {
    return false;
  }
  log("String_Node_Str" + msg + "String_Node_Str"+ (mReEnableDelayMillis - delaySoFar)+ "String_Node_Str");
  Message deferredMsg=obtainMessage(CMD_DEFERRED_TOGGLE);
  deferredMsg.obj=Message.obtain(msg);
  deferredMsg.arg1=++mDeferredEnableSerialNumber;
  sendMessageDelayed(deferredMsg,mReEnableDelayMillis - delaySoFar);
  return true;
}
Program: 1960
Project: 1960
Buggy source:
private void replacePackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,UserHandle user,String installerPackageName,PackageInstalledInfo res){
  PackageParser.Package oldPackage;
  String pkgName=pkg.packageName;
  int[] allUsers;
  boolean[] perUserInstalled;
synchronized (mPackages) {
    oldPackage=mPackages.get(pkgName);
    if (DEBUG_INSTALL)     Slog.d(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ oldPackage);
    if (compareSignatures(oldPackage.mSignatures,pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
      Slog.w(TAG,"String_Node_Str" + pkgName);
      res.returnCode=PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
      return;
    }
    PackageSetting ps=mSettings.mPackages.get(pkgName);
    allUsers=sUserManager.getUserIds();
    perUserInstalled=new boolean[allUsers.length];
    for (int i=0; i < allUsers.length; i++) {
      perUserInstalled[i]=ps.getInstalled(allUsers[i]);
    }
  }
  boolean sysPkg=(isSystemApp(oldPackage));
  if (sysPkg) {
    replaceSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
 else {
    replaceNonSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
}

Fixed version (ground truth):
private void replacePackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,UserHandle user,String installerPackageName,PackageInstalledInfo res){
  PackageParser.Package oldPackage;
  String pkgName=pkg.packageName;
  int[] allUsers;
  boolean[] perUserInstalled;
synchronized (mPackages) {
    oldPackage=mPackages.get(pkgName);
    if (DEBUG_INSTALL)     Slog.d(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ oldPackage);
    if (compareSignatures(oldPackage.mSignatures,pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
      Slog.w(TAG,"String_Node_Str" + pkgName);
      res.returnCode=PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
      return;
    }
    PackageSetting ps=mSettings.mPackages.get(pkgName);
    allUsers=sUserManager.getUserIds();
    perUserInstalled=new boolean[allUsers.length];
    for (int i=0; i < allUsers.length; i++) {
      perUserInstalled[i]=ps != null ? ps.getInstalled(allUsers[i]) : false;
    }
  }
  boolean sysPkg=(isSystemApp(oldPackage));
  if (sysPkg) {
    replaceSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
 else {
    replaceNonSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
}
Program: 1962
Project: 1962
Buggy source:
private void replacePackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,UserHandle user,String installerPackageName,PackageInstalledInfo res){
  PackageParser.Package oldPackage;
  String pkgName=pkg.packageName;
  int[] allUsers;
  boolean[] perUserInstalled;
synchronized (mPackages) {
    oldPackage=mPackages.get(pkgName);
    if (DEBUG_INSTALL)     Slog.d(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ oldPackage);
    if (compareSignatures(oldPackage.mSignatures,pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
      Slog.w(TAG,"String_Node_Str" + pkgName);
      res.returnCode=PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
      return;
    }
    PackageSetting ps=mSettings.mPackages.get(pkgName);
    allUsers=sUserManager.getUserIds();
    perUserInstalled=new boolean[allUsers.length];
    for (int i=0; i < allUsers.length; i++) {
      perUserInstalled[i]=ps.getInstalled(allUsers[i]);
    }
  }
  boolean sysPkg=(isSystemApp(oldPackage));
  if (sysPkg) {
    replaceSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
 else {
    replaceNonSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
}

Fixed version (ground truth):
private void replacePackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,UserHandle user,String installerPackageName,PackageInstalledInfo res){
  PackageParser.Package oldPackage;
  String pkgName=pkg.packageName;
  int[] allUsers;
  boolean[] perUserInstalled;
synchronized (mPackages) {
    oldPackage=mPackages.get(pkgName);
    if (DEBUG_INSTALL)     Slog.d(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ oldPackage);
    if (compareSignatures(oldPackage.mSignatures,pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
      Slog.w(TAG,"String_Node_Str" + pkgName);
      res.returnCode=PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
      return;
    }
    PackageSetting ps=mSettings.mPackages.get(pkgName);
    allUsers=sUserManager.getUserIds();
    perUserInstalled=new boolean[allUsers.length];
    for (int i=0; i < allUsers.length; i++) {
      perUserInstalled[i]=ps != null ? ps.getInstalled(allUsers[i]) : false;
    }
  }
  boolean sysPkg=(isSystemApp(oldPackage));
  if (sysPkg) {
    replaceSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
 else {
    replaceNonSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
}
Program: 1964
Project: 1964
Buggy source:
private void replacePackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,UserHandle user,String installerPackageName,PackageInstalledInfo res){
  PackageParser.Package oldPackage;
  String pkgName=pkg.packageName;
  int[] allUsers;
  boolean[] perUserInstalled;
synchronized (mPackages) {
    oldPackage=mPackages.get(pkgName);
    if (DEBUG_INSTALL)     Slog.d(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ oldPackage);
    if (compareSignatures(oldPackage.mSignatures,pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
      Slog.w(TAG,"String_Node_Str" + pkgName);
      res.returnCode=PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
      return;
    }
    PackageSetting ps=mSettings.mPackages.get(pkgName);
    allUsers=sUserManager.getUserIds();
    perUserInstalled=new boolean[allUsers.length];
    for (int i=0; i < allUsers.length; i++) {
      perUserInstalled[i]=ps.getInstalled(allUsers[i]);
    }
  }
  boolean sysPkg=(isSystemApp(oldPackage));
  if (sysPkg) {
    replaceSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
 else {
    replaceNonSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
}

Fixed version (ground truth):
private void replacePackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,UserHandle user,String installerPackageName,PackageInstalledInfo res){
  PackageParser.Package oldPackage;
  String pkgName=pkg.packageName;
  int[] allUsers;
  boolean[] perUserInstalled;
synchronized (mPackages) {
    oldPackage=mPackages.get(pkgName);
    if (DEBUG_INSTALL)     Slog.d(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ oldPackage);
    if (compareSignatures(oldPackage.mSignatures,pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
      Slog.w(TAG,"String_Node_Str" + pkgName);
      res.returnCode=PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
      return;
    }
    PackageSetting ps=mSettings.mPackages.get(pkgName);
    allUsers=sUserManager.getUserIds();
    perUserInstalled=new boolean[allUsers.length];
    for (int i=0; i < allUsers.length; i++) {
      perUserInstalled[i]=ps != null ? ps.getInstalled(allUsers[i]) : false;
    }
  }
  boolean sysPkg=(isSystemApp(oldPackage));
  if (sysPkg) {
    replaceSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
 else {
    replaceNonSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
}
Program: 1966
Project: 1966
Buggy source:
private void replacePackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,UserHandle user,String installerPackageName,PackageInstalledInfo res){
  PackageParser.Package oldPackage;
  String pkgName=pkg.packageName;
  int[] allUsers;
  boolean[] perUserInstalled;
synchronized (mPackages) {
    oldPackage=mPackages.get(pkgName);
    if (DEBUG_INSTALL)     Slog.d(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ oldPackage);
    if (compareSignatures(oldPackage.mSignatures,pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
      Slog.w(TAG,"String_Node_Str" + pkgName);
      res.returnCode=PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
      return;
    }
    PackageSetting ps=mSettings.mPackages.get(pkgName);
    allUsers=sUserManager.getUserIds();
    perUserInstalled=new boolean[allUsers.length];
    for (int i=0; i < allUsers.length; i++) {
      perUserInstalled[i]=ps.getInstalled(allUsers[i]);
    }
  }
  boolean sysPkg=(isSystemApp(oldPackage));
  if (sysPkg) {
    replaceSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
 else {
    replaceNonSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
}

Fixed version (ground truth):
private void replacePackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,UserHandle user,String installerPackageName,PackageInstalledInfo res){
  PackageParser.Package oldPackage;
  String pkgName=pkg.packageName;
  int[] allUsers;
  boolean[] perUserInstalled;
synchronized (mPackages) {
    oldPackage=mPackages.get(pkgName);
    if (DEBUG_INSTALL)     Slog.d(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ oldPackage);
    if (compareSignatures(oldPackage.mSignatures,pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
      Slog.w(TAG,"String_Node_Str" + pkgName);
      res.returnCode=PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
      return;
    }
    PackageSetting ps=mSettings.mPackages.get(pkgName);
    allUsers=sUserManager.getUserIds();
    perUserInstalled=new boolean[allUsers.length];
    for (int i=0; i < allUsers.length; i++) {
      perUserInstalled[i]=ps != null ? ps.getInstalled(allUsers[i]) : false;
    }
  }
  boolean sysPkg=(isSystemApp(oldPackage));
  if (sysPkg) {
    replaceSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
 else {
    replaceNonSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
}
Program: 1968
Project: 1968
Buggy source:
private void replacePackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,UserHandle user,String installerPackageName,PackageInstalledInfo res){
  PackageParser.Package oldPackage;
  String pkgName=pkg.packageName;
  int[] allUsers;
  boolean[] perUserInstalled;
synchronized (mPackages) {
    oldPackage=mPackages.get(pkgName);
    if (DEBUG_INSTALL)     Slog.d(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ oldPackage);
    if (compareSignatures(oldPackage.mSignatures,pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
      Slog.w(TAG,"String_Node_Str" + pkgName);
      res.returnCode=PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
      return;
    }
    PackageSetting ps=mSettings.mPackages.get(pkgName);
    allUsers=sUserManager.getUserIds();
    perUserInstalled=new boolean[allUsers.length];
    for (int i=0; i < allUsers.length; i++) {
      perUserInstalled[i]=ps.getInstalled(allUsers[i]);
    }
  }
  boolean sysPkg=(isSystemApp(oldPackage));
  if (sysPkg) {
    replaceSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
 else {
    replaceNonSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
}

Fixed version (ground truth):
private void replacePackageLI(PackageParser.Package pkg,int parseFlags,int scanMode,UserHandle user,String installerPackageName,PackageInstalledInfo res){
  PackageParser.Package oldPackage;
  String pkgName=pkg.packageName;
  int[] allUsers;
  boolean[] perUserInstalled;
synchronized (mPackages) {
    oldPackage=mPackages.get(pkgName);
    if (DEBUG_INSTALL)     Slog.d(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ oldPackage);
    if (compareSignatures(oldPackage.mSignatures,pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
      Slog.w(TAG,"String_Node_Str" + pkgName);
      res.returnCode=PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
      return;
    }
    PackageSetting ps=mSettings.mPackages.get(pkgName);
    allUsers=sUserManager.getUserIds();
    perUserInstalled=new boolean[allUsers.length];
    for (int i=0; i < allUsers.length; i++) {
      perUserInstalled[i]=ps != null ? ps.getInstalled(allUsers[i]) : false;
    }
  }
  boolean sysPkg=(isSystemApp(oldPackage));
  if (sysPkg) {
    replaceSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
 else {
    replaceNonSystemPackageLI(oldPackage,pkg,parseFlags,scanMode,user,allUsers,perUserInstalled,installerPackageName,res);
  }
}
Program: 1975
Project: 1975
Buggy source:
public AnimatedRotateState(AnimatedRotateState source,AnimatedRotateDrawable owner,Resources res){
  if (source != null) {
    if (res != null) {
      mDrawable=source.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=source.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mPivotXRel=source.mPivotXRel;
    mPivotX=source.mPivotX;
    mPivotYRel=source.mPivotYRel;
    mPivotY=source.mPivotY;
    mFramesCount=source.mFramesCount;
    mFrameDuration=source.mFrameDuration;
    mCanConstantState=mCheckedConstantState=true;
  }
}

Fixed version (ground truth):
public AnimatedRotateState(AnimatedRotateState source,AnimatedRotateDrawable owner,Resources res){
  if (source != null) {
    if (res != null) {
      mDrawable=source.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=source.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mDrawable.setLayoutDirection(source.mDrawable.getLayoutDirection());
    mPivotXRel=source.mPivotXRel;
    mPivotX=source.mPivotX;
    mPivotYRel=source.mPivotYRel;
    mPivotY=source.mPivotY;
    mFramesCount=source.mFramesCount;
    mFrameDuration=source.mFrameDuration;
    mCanConstantState=mCheckedConstantState=true;
  }
}
Program: 1976
Project: 1976
Buggy source:
ClipState(ClipState orig,ClipDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mOrientation=orig.mOrientation;
    mGravity=orig.mGravity;
    mCheckedConstantState=mCanConstantState=true;
  }
}

Fixed version (ground truth):
ClipState(ClipState orig,ClipDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mDrawable.setLayoutDirection(orig.mDrawable.getLayoutDirection());
    mOrientation=orig.mOrientation;
    mGravity=orig.mGravity;
    mCheckedConstantState=mCanConstantState=true;
  }
}
Program: 1977
Project: 1977
Buggy source:
DrawableContainerState(DrawableContainerState orig,DrawableContainer owner,Resources res){
  mOwner=owner;
  if (orig != null) {
    mChangingConfigurations=orig.mChangingConfigurations;
    mChildrenChangingConfigurations=orig.mChildrenChangingConfigurations;
    final Drawable[] origDr=orig.mDrawables;
    mDrawables=new Drawable[origDr.length];
    mNumChildren=orig.mNumChildren;
    final int N=mNumChildren;
    for (int i=0; i < N; i++) {
      if (res != null) {
        mDrawables[i]=origDr[i].getConstantState().newDrawable(res);
      }
 else {
        mDrawables[i]=origDr[i].getConstantState().newDrawable();
      }
      mDrawables[i].setCallback(owner);
    }
    mCheckedConstantState=mCanConstantState=true;
    mVariablePadding=orig.mVariablePadding;
    if (orig.mConstantPadding != null) {
      mConstantPadding=new Rect(orig.mConstantPadding);
    }
    mConstantSize=orig.mConstantSize;
    mComputedConstantSize=orig.mComputedConstantSize;
    mConstantWidth=orig.mConstantWidth;
    mConstantHeight=orig.mConstantHeight;
    mConstantMinimumWidth=orig.mConstantMinimumWidth;
    mConstantMinimumHeight=orig.mConstantMinimumHeight;
    mOpacity=orig.mOpacity;
    mHaveStateful=orig.mHaveStateful;
    mStateful=orig.mStateful;
    mDither=orig.mDither;
    mEnterFadeDuration=orig.mEnterFadeDuration;
    mExitFadeDuration=orig.mExitFadeDuration;
  }
 else {
    mDrawables=new Drawable[10];
    mNumChildren=0;
    mCheckedConstantState=mCanConstantState=false;
  }
}

Fixed version (ground truth):
DrawableContainerState(DrawableContainerState orig,DrawableContainer owner,Resources res){
  mOwner=owner;
  if (orig != null) {
    mChangingConfigurations=orig.mChangingConfigurations;
    mChildrenChangingConfigurations=orig.mChildrenChangingConfigurations;
    final Drawable[] origDr=orig.mDrawables;
    mDrawables=new Drawable[origDr.length];
    mNumChildren=orig.mNumChildren;
    final int N=mNumChildren;
    for (int i=0; i < N; i++) {
      if (res != null) {
        mDrawables[i]=origDr[i].getConstantState().newDrawable(res);
      }
 else {
        mDrawables[i]=origDr[i].getConstantState().newDrawable();
      }
      mDrawables[i].setCallback(owner);
      mDrawables[i].setLayoutDirection(origDr[i].getLayoutDirection());
    }
    mCheckedConstantState=mCanConstantState=true;
    mVariablePadding=orig.mVariablePadding;
    if (orig.mConstantPadding != null) {
      mConstantPadding=new Rect(orig.mConstantPadding);
    }
    mConstantSize=orig.mConstantSize;
    mComputedConstantSize=orig.mComputedConstantSize;
    mConstantWidth=orig.mConstantWidth;
    mConstantHeight=orig.mConstantHeight;
    mConstantMinimumWidth=orig.mConstantMinimumWidth;
    mConstantMinimumHeight=orig.mConstantMinimumHeight;
    mOpacity=orig.mOpacity;
    mHaveStateful=orig.mHaveStateful;
    mStateful=orig.mStateful;
    mDither=orig.mDither;
    mEnterFadeDuration=orig.mEnterFadeDuration;
    mExitFadeDuration=orig.mExitFadeDuration;
  }
 else {
    mDrawables=new Drawable[10];
    mNumChildren=0;
    mCheckedConstantState=mCanConstantState=false;
  }
}
Program: 1979
Project: 1979
Buggy source:
InsetState(InsetState orig,InsetDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mInsetLeft=orig.mInsetLeft;
    mInsetTop=orig.mInsetTop;
    mInsetRight=orig.mInsetRight;
    mInsetBottom=orig.mInsetBottom;
    mCheckedConstantState=mCanConstantState=true;
  }
}

Fixed version (ground truth):
InsetState(InsetState orig,InsetDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mDrawable.setLayoutDirection(orig.mDrawable.getLayoutDirection());
    mInsetLeft=orig.mInsetLeft;
    mInsetTop=orig.mInsetTop;
    mInsetRight=orig.mInsetRight;
    mInsetBottom=orig.mInsetBottom;
    mCheckedConstantState=mCanConstantState=true;
  }
}
Program: 1980
Project: 1980
Buggy source:
/** 
 * @hide 
 */
@Override public void setLayoutDirection(int layoutDirection){
  if (getLayoutDirection() != layoutDirection) {
    final ChildDrawable[] array=mLayerState.mChildren;
    final int N=mLayerState.mNum;
    for (int i=0; i < N; i++) {
      array[i].mDrawable.setLayoutDirection(layoutDirection);
    }
  }
  super.setLayoutDirection(layoutDirection);
}

Fixed version (ground truth):
/** 
 * @hide 
 */
@Override public void setLayoutDirection(int layoutDirection){
  final ChildDrawable[] array=mLayerState.mChildren;
  final int N=mLayerState.mNum;
  for (int i=0; i < N; i++) {
    array[i].mDrawable.setLayoutDirection(layoutDirection);
  }
  super.setLayoutDirection(layoutDirection);
}
Program: 1981
Project: 1981
Buggy source:
LayerState(LayerState orig,LayerDrawable owner,Resources res){
  if (orig != null) {
    final ChildDrawable[] origChildDrawable=orig.mChildren;
    final int N=orig.mNum;
    mNum=N;
    mChildren=new ChildDrawable[N];
    mChangingConfigurations=orig.mChangingConfigurations;
    mChildrenChangingConfigurations=orig.mChildrenChangingConfigurations;
    for (int i=0; i < N; i++) {
      final ChildDrawable r=mChildren[i]=new ChildDrawable();
      final ChildDrawable or=origChildDrawable[i];
      if (res != null) {
        r.mDrawable=or.mDrawable.getConstantState().newDrawable(res);
      }
 else {
        r.mDrawable=or.mDrawable.getConstantState().newDrawable();
      }
      r.mDrawable.setCallback(owner);
      r.mInsetL=or.mInsetL;
      r.mInsetT=or.mInsetT;
      r.mInsetR=or.mInsetR;
      r.mInsetB=or.mInsetB;
      r.mId=or.mId;
    }
    mHaveOpacity=orig.mHaveOpacity;
    mOpacity=orig.mOpacity;
    mHaveStateful=orig.mHaveStateful;
    mStateful=orig.mStateful;
    mCheckedConstantState=mCanConstantState=true;
  }
 else {
    mNum=0;
    mChildren=null;
  }
}

Fixed version (ground truth):
LayerState(LayerState orig,LayerDrawable owner,Resources res){
  if (orig != null) {
    final ChildDrawable[] origChildDrawable=orig.mChildren;
    final int N=orig.mNum;
    mNum=N;
    mChildren=new ChildDrawable[N];
    mChangingConfigurations=orig.mChangingConfigurations;
    mChildrenChangingConfigurations=orig.mChildrenChangingConfigurations;
    for (int i=0; i < N; i++) {
      final ChildDrawable r=mChildren[i]=new ChildDrawable();
      final ChildDrawable or=origChildDrawable[i];
      if (res != null) {
        r.mDrawable=or.mDrawable.getConstantState().newDrawable(res);
      }
 else {
        r.mDrawable=or.mDrawable.getConstantState().newDrawable();
      }
      r.mDrawable.setCallback(owner);
      r.mDrawable.setLayoutDirection(or.mDrawable.getLayoutDirection());
      r.mInsetL=or.mInsetL;
      r.mInsetT=or.mInsetT;
      r.mInsetR=or.mInsetR;
      r.mInsetB=or.mInsetB;
      r.mId=or.mId;
    }
    mHaveOpacity=orig.mHaveOpacity;
    mOpacity=orig.mOpacity;
    mHaveStateful=orig.mHaveStateful;
    mStateful=orig.mStateful;
    mCheckedConstantState=mCanConstantState=true;
  }
 else {
    mNum=0;
    mChildren=null;
  }
}
Program: 1982
Project: 1982
Buggy source:
public RotateState(RotateState source,RotateDrawable owner,Resources res){
  if (source != null) {
    if (res != null) {
      mDrawable=source.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=source.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mPivotXRel=source.mPivotXRel;
    mPivotX=source.mPivotX;
    mPivotYRel=source.mPivotYRel;
    mPivotY=source.mPivotY;
    mFromDegrees=mCurrentDegrees=source.mFromDegrees;
    mToDegrees=source.mToDegrees;
    mCanConstantState=mCheckedConstantState=true;
  }
}

Fixed version (ground truth):
public RotateState(RotateState source,RotateDrawable owner,Resources res){
  if (source != null) {
    if (res != null) {
      mDrawable=source.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=source.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mDrawable.setLayoutDirection(source.mDrawable.getLayoutDirection());
    mPivotXRel=source.mPivotXRel;
    mPivotX=source.mPivotX;
    mPivotYRel=source.mPivotYRel;
    mPivotY=source.mPivotY;
    mFromDegrees=mCurrentDegrees=source.mFromDegrees;
    mToDegrees=source.mToDegrees;
    mCanConstantState=mCheckedConstantState=true;
  }
}
Program: 1983
Project: 1983
Buggy source:
ScaleState(ScaleState orig,ScaleDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mScaleWidth=orig.mScaleWidth;
    mScaleHeight=orig.mScaleHeight;
    mGravity=orig.mGravity;
    mUseIntrinsicSizeAsMin=orig.mUseIntrinsicSizeAsMin;
    mCheckedConstantState=mCanConstantState=true;
  }
}

Fixed version (ground truth):
ScaleState(ScaleState orig,ScaleDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mDrawable.setLayoutDirection(orig.mDrawable.getLayoutDirection());
    mScaleWidth=orig.mScaleWidth;
    mScaleHeight=orig.mScaleHeight;
    mGravity=orig.mGravity;
    mUseIntrinsicSizeAsMin=orig.mUseIntrinsicSizeAsMin;
    mCheckedConstantState=mCanConstantState=true;
  }
}
Program: 1984
Project: 1984
Buggy source:
public AnimatedRotateState(AnimatedRotateState source,AnimatedRotateDrawable owner,Resources res){
  if (source != null) {
    if (res != null) {
      mDrawable=source.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=source.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mPivotXRel=source.mPivotXRel;
    mPivotX=source.mPivotX;
    mPivotYRel=source.mPivotYRel;
    mPivotY=source.mPivotY;
    mFramesCount=source.mFramesCount;
    mFrameDuration=source.mFrameDuration;
    mCanConstantState=mCheckedConstantState=true;
  }
}

Fixed version (ground truth):
public AnimatedRotateState(AnimatedRotateState source,AnimatedRotateDrawable owner,Resources res){
  if (source != null) {
    if (res != null) {
      mDrawable=source.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=source.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mDrawable.setLayoutDirection(source.mDrawable.getLayoutDirection());
    mPivotXRel=source.mPivotXRel;
    mPivotX=source.mPivotX;
    mPivotYRel=source.mPivotYRel;
    mPivotY=source.mPivotY;
    mFramesCount=source.mFramesCount;
    mFrameDuration=source.mFrameDuration;
    mCanConstantState=mCheckedConstantState=true;
  }
}
Program: 1985
Project: 1985
Buggy source:
ClipState(ClipState orig,ClipDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mOrientation=orig.mOrientation;
    mGravity=orig.mGravity;
    mCheckedConstantState=mCanConstantState=true;
  }
}

Fixed version (ground truth):
ClipState(ClipState orig,ClipDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mDrawable.setLayoutDirection(orig.mDrawable.getLayoutDirection());
    mOrientation=orig.mOrientation;
    mGravity=orig.mGravity;
    mCheckedConstantState=mCanConstantState=true;
  }
}
Program: 1986
Project: 1986
Buggy source:
DrawableContainerState(DrawableContainerState orig,DrawableContainer owner,Resources res){
  mOwner=owner;
  if (orig != null) {
    mChangingConfigurations=orig.mChangingConfigurations;
    mChildrenChangingConfigurations=orig.mChildrenChangingConfigurations;
    final Drawable[] origDr=orig.mDrawables;
    mDrawables=new Drawable[origDr.length];
    mNumChildren=orig.mNumChildren;
    final int N=mNumChildren;
    for (int i=0; i < N; i++) {
      if (res != null) {
        mDrawables[i]=origDr[i].getConstantState().newDrawable(res);
      }
 else {
        mDrawables[i]=origDr[i].getConstantState().newDrawable();
      }
      mDrawables[i].setCallback(owner);
    }
    mCheckedConstantState=mCanConstantState=true;
    mVariablePadding=orig.mVariablePadding;
    if (orig.mConstantPadding != null) {
      mConstantPadding=new Rect(orig.mConstantPadding);
    }
    mConstantSize=orig.mConstantSize;
    mComputedConstantSize=orig.mComputedConstantSize;
    mConstantWidth=orig.mConstantWidth;
    mConstantHeight=orig.mConstantHeight;
    mConstantMinimumWidth=orig.mConstantMinimumWidth;
    mConstantMinimumHeight=orig.mConstantMinimumHeight;
    mOpacity=orig.mOpacity;
    mHaveStateful=orig.mHaveStateful;
    mStateful=orig.mStateful;
    mDither=orig.mDither;
    mEnterFadeDuration=orig.mEnterFadeDuration;
    mExitFadeDuration=orig.mExitFadeDuration;
  }
 else {
    mDrawables=new Drawable[10];
    mNumChildren=0;
    mCheckedConstantState=mCanConstantState=false;
  }
}

Fixed version (ground truth):
DrawableContainerState(DrawableContainerState orig,DrawableContainer owner,Resources res){
  mOwner=owner;
  if (orig != null) {
    mChangingConfigurations=orig.mChangingConfigurations;
    mChildrenChangingConfigurations=orig.mChildrenChangingConfigurations;
    final Drawable[] origDr=orig.mDrawables;
    mDrawables=new Drawable[origDr.length];
    mNumChildren=orig.mNumChildren;
    final int N=mNumChildren;
    for (int i=0; i < N; i++) {
      if (res != null) {
        mDrawables[i]=origDr[i].getConstantState().newDrawable(res);
      }
 else {
        mDrawables[i]=origDr[i].getConstantState().newDrawable();
      }
      mDrawables[i].setCallback(owner);
      mDrawables[i].setLayoutDirection(origDr[i].getLayoutDirection());
    }
    mCheckedConstantState=mCanConstantState=true;
    mVariablePadding=orig.mVariablePadding;
    if (orig.mConstantPadding != null) {
      mConstantPadding=new Rect(orig.mConstantPadding);
    }
    mConstantSize=orig.mConstantSize;
    mComputedConstantSize=orig.mComputedConstantSize;
    mConstantWidth=orig.mConstantWidth;
    mConstantHeight=orig.mConstantHeight;
    mConstantMinimumWidth=orig.mConstantMinimumWidth;
    mConstantMinimumHeight=orig.mConstantMinimumHeight;
    mOpacity=orig.mOpacity;
    mHaveStateful=orig.mHaveStateful;
    mStateful=orig.mStateful;
    mDither=orig.mDither;
    mEnterFadeDuration=orig.mEnterFadeDuration;
    mExitFadeDuration=orig.mExitFadeDuration;
  }
 else {
    mDrawables=new Drawable[10];
    mNumChildren=0;
    mCheckedConstantState=mCanConstantState=false;
  }
}
Program: 1988
Project: 1988
Buggy source:
InsetState(InsetState orig,InsetDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mInsetLeft=orig.mInsetLeft;
    mInsetTop=orig.mInsetTop;
    mInsetRight=orig.mInsetRight;
    mInsetBottom=orig.mInsetBottom;
    mCheckedConstantState=mCanConstantState=true;
  }
}

Fixed version (ground truth):
InsetState(InsetState orig,InsetDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mDrawable.setLayoutDirection(orig.mDrawable.getLayoutDirection());
    mInsetLeft=orig.mInsetLeft;
    mInsetTop=orig.mInsetTop;
    mInsetRight=orig.mInsetRight;
    mInsetBottom=orig.mInsetBottom;
    mCheckedConstantState=mCanConstantState=true;
  }
}
Program: 1989
Project: 1989
Buggy source:
/** 
 * @hide 
 */
@Override public void setLayoutDirection(int layoutDirection){
  if (getLayoutDirection() != layoutDirection) {
    final ChildDrawable[] array=mLayerState.mChildren;
    final int N=mLayerState.mNum;
    for (int i=0; i < N; i++) {
      array[i].mDrawable.setLayoutDirection(layoutDirection);
    }
  }
  super.setLayoutDirection(layoutDirection);
}

Fixed version (ground truth):
/** 
 * @hide 
 */
@Override public void setLayoutDirection(int layoutDirection){
  final ChildDrawable[] array=mLayerState.mChildren;
  final int N=mLayerState.mNum;
  for (int i=0; i < N; i++) {
    array[i].mDrawable.setLayoutDirection(layoutDirection);
  }
  super.setLayoutDirection(layoutDirection);
}
Program: 1990
Project: 1990
Buggy source:
LayerState(LayerState orig,LayerDrawable owner,Resources res){
  if (orig != null) {
    final ChildDrawable[] origChildDrawable=orig.mChildren;
    final int N=orig.mNum;
    mNum=N;
    mChildren=new ChildDrawable[N];
    mChangingConfigurations=orig.mChangingConfigurations;
    mChildrenChangingConfigurations=orig.mChildrenChangingConfigurations;
    for (int i=0; i < N; i++) {
      final ChildDrawable r=mChildren[i]=new ChildDrawable();
      final ChildDrawable or=origChildDrawable[i];
      if (res != null) {
        r.mDrawable=or.mDrawable.getConstantState().newDrawable(res);
      }
 else {
        r.mDrawable=or.mDrawable.getConstantState().newDrawable();
      }
      r.mDrawable.setCallback(owner);
      r.mInsetL=or.mInsetL;
      r.mInsetT=or.mInsetT;
      r.mInsetR=or.mInsetR;
      r.mInsetB=or.mInsetB;
      r.mId=or.mId;
    }
    mHaveOpacity=orig.mHaveOpacity;
    mOpacity=orig.mOpacity;
    mHaveStateful=orig.mHaveStateful;
    mStateful=orig.mStateful;
    mCheckedConstantState=mCanConstantState=true;
  }
 else {
    mNum=0;
    mChildren=null;
  }
}

Fixed version (ground truth):
LayerState(LayerState orig,LayerDrawable owner,Resources res){
  if (orig != null) {
    final ChildDrawable[] origChildDrawable=orig.mChildren;
    final int N=orig.mNum;
    mNum=N;
    mChildren=new ChildDrawable[N];
    mChangingConfigurations=orig.mChangingConfigurations;
    mChildrenChangingConfigurations=orig.mChildrenChangingConfigurations;
    for (int i=0; i < N; i++) {
      final ChildDrawable r=mChildren[i]=new ChildDrawable();
      final ChildDrawable or=origChildDrawable[i];
      if (res != null) {
        r.mDrawable=or.mDrawable.getConstantState().newDrawable(res);
      }
 else {
        r.mDrawable=or.mDrawable.getConstantState().newDrawable();
      }
      r.mDrawable.setCallback(owner);
      r.mDrawable.setLayoutDirection(or.mDrawable.getLayoutDirection());
      r.mInsetL=or.mInsetL;
      r.mInsetT=or.mInsetT;
      r.mInsetR=or.mInsetR;
      r.mInsetB=or.mInsetB;
      r.mId=or.mId;
    }
    mHaveOpacity=orig.mHaveOpacity;
    mOpacity=orig.mOpacity;
    mHaveStateful=orig.mHaveStateful;
    mStateful=orig.mStateful;
    mCheckedConstantState=mCanConstantState=true;
  }
 else {
    mNum=0;
    mChildren=null;
  }
}
Program: 1991
Project: 1991
Buggy source:
public RotateState(RotateState source,RotateDrawable owner,Resources res){
  if (source != null) {
    if (res != null) {
      mDrawable=source.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=source.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mPivotXRel=source.mPivotXRel;
    mPivotX=source.mPivotX;
    mPivotYRel=source.mPivotYRel;
    mPivotY=source.mPivotY;
    mFromDegrees=mCurrentDegrees=source.mFromDegrees;
    mToDegrees=source.mToDegrees;
    mCanConstantState=mCheckedConstantState=true;
  }
}

Fixed version (ground truth):
public RotateState(RotateState source,RotateDrawable owner,Resources res){
  if (source != null) {
    if (res != null) {
      mDrawable=source.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=source.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mDrawable.setLayoutDirection(source.mDrawable.getLayoutDirection());
    mPivotXRel=source.mPivotXRel;
    mPivotX=source.mPivotX;
    mPivotYRel=source.mPivotYRel;
    mPivotY=source.mPivotY;
    mFromDegrees=mCurrentDegrees=source.mFromDegrees;
    mToDegrees=source.mToDegrees;
    mCanConstantState=mCheckedConstantState=true;
  }
}
Program: 1992
Project: 1992
Buggy source:
ScaleState(ScaleState orig,ScaleDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mScaleWidth=orig.mScaleWidth;
    mScaleHeight=orig.mScaleHeight;
    mGravity=orig.mGravity;
    mUseIntrinsicSizeAsMin=orig.mUseIntrinsicSizeAsMin;
    mCheckedConstantState=mCanConstantState=true;
  }
}

Fixed version (ground truth):
ScaleState(ScaleState orig,ScaleDrawable owner,Resources res){
  if (orig != null) {
    if (res != null) {
      mDrawable=orig.mDrawable.getConstantState().newDrawable(res);
    }
 else {
      mDrawable=orig.mDrawable.getConstantState().newDrawable();
    }
    mDrawable.setCallback(owner);
    mDrawable.setLayoutDirection(orig.mDrawable.getLayoutDirection());
    mScaleWidth=orig.mScaleWidth;
    mScaleHeight=orig.mScaleHeight;
    mGravity=orig.mGravity;
    mUseIntrinsicSizeAsMin=orig.mUseIntrinsicSizeAsMin;
    mCheckedConstantState=mCanConstantState=true;
  }
}