nus-yam/ex-repair huggingface dataset:
Program: 41082
Project: 41082
Buggy source:
private void detachThemeAssets(AssetManager assets){
  String themePackageName=assets.getThemePackageName();
  int themeCookie=assets.getThemeCookie();
  if (!TextUtils.isEmpty(themePackageName) && themeCookie != 0) {
    assets.removeAssetPath(themePackageName,themeCookie);
    assets.setThemePackageName(null);
    assets.setThemeCookie(0);
    assets.clearRedirections();
  }
}

Fixed version (ground truth):
private void detachThemeAssets(AssetManager assets){
  String themePackageName=assets.getThemePackageName();
  int themeCookie=assets.getThemeCookie();
  if (!TextUtils.isEmpty(themePackageName) && themeCookie != 0) {
    assets.detachThemePath(themePackageName,themeCookie);
    assets.setThemePackageName(null);
    assets.setThemeCookie(0);
    assets.clearRedirections();
  }
}
Program: 41083
Project: 41083
Buggy source:
final int applyConfigurationToResourcesLocked(Configuration config){
  if (mResConfiguration == null) {
    mResConfiguration=new Configuration();
  }
  if (!mResConfiguration.isOtherSeqNewer(config)) {
    if (DEBUG_CONFIGURATION)     Slog.v(TAG,"String_Node_Str" + mResConfiguration.seq + "String_Node_Str"+ config.seq);
    return 0;
  }
  int changes=mResConfiguration.updateFrom(config);
  DisplayMetrics dm=getDisplayMetricsLocked(true);
  if (config.locale != null) {
    Locale.setDefault(config.locale);
  }
  Resources.updateSystemConfiguration(config,dm);
  ContextImpl.ApplicationPackageManager.configurationChanged();
  Iterator<WeakReference<Resources>> it=mActiveResources.values().iterator();
  while (it.hasNext()) {
    WeakReference<Resources> v=it.next();
    Resources r=v.get();
    if (r != null) {
      if (DEBUG_CONFIGURATION)       Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str"+ config);
      boolean themeChanged=(changes & ActivityInfo.CONFIG_THEME_RESOURCE) != 0;
      if (themeChanged) {
        AssetManager am=r.getAssets();
        if (am.hasThemeSupport()) {
          detachThemeAssets(am);
          if (!TextUtils.isEmpty(config.customTheme.getThemePackageName())) {
            attachThemeAssets(am,config.customTheme,true);
          }
        }
      }
      r.updateConfiguration(config,dm);
      if (themeChanged) {
        r.updateStringCache();
      }
    }
 else {
      it.remove();
    }
  }
  return changes;
}

Fixed version (ground truth):
final int applyConfigurationToResourcesLocked(Configuration config){
  if (mResConfiguration == null) {
    mResConfiguration=new Configuration();
  }
  if (!mResConfiguration.isOtherSeqNewer(config)) {
    if (DEBUG_CONFIGURATION)     Slog.v(TAG,"String_Node_Str" + mResConfiguration.seq + "String_Node_Str"+ config.seq);
    return 0;
  }
  int changes=mResConfiguration.updateFrom(config);
  DisplayMetrics dm=getDisplayMetricsLocked(true);
  if (config.locale != null) {
    Locale.setDefault(config.locale);
  }
  Resources.updateSystemConfiguration(config,dm);
  ContextImpl.ApplicationPackageManager.configurationChanged();
  Iterator<WeakReference<Resources>> it=mActiveResources.values().iterator();
  while (it.hasNext()) {
    WeakReference<Resources> v=it.next();
    Resources r=v.get();
    if (r != null) {
      if (DEBUG_CONFIGURATION)       Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str"+ config);
      boolean themeChanged=(changes & ActivityInfo.CONFIG_THEME_RESOURCE) != 0;
      if (themeChanged) {
        AssetManager am=r.getAssets();
        if (am.hasThemeSupport()) {
          detachThemeAssets(am);
          if (!TextUtils.isEmpty(config.customTheme.getThemePackageName())) {
            attachThemeAssets(am,config.customTheme);
          }
        }
      }
      r.updateConfiguration(config,dm);
      if (themeChanged) {
        r.updateStringCache();
      }
    }
 else {
      it.remove();
    }
  }
  return changes;
}
Program: 41087
Project: 41087
Buggy source:
@Override public void onDetached(){
  removeCallbacks(mHider);
}

Fixed version (ground truth):
@Override public void onDetached(){
}
Program: 41088
Project: 41088
Buggy source:
@Override public void onDetached(){
  removeCallbacks(mHider);
}

Fixed version (ground truth):
@Override public void onDetached(){
}
Program: 41089
Project: 41089
Buggy source:
/** 
 * Called when a status report is received.  This should correspond to a previously successful SEND.
 * @param ar AsyncResult passed into the message handler.  ar.result shouldbe a String representing the status report PDU, as ASCII hex.
 */
protected void handleStatusReport(AsyncResult ar){
  String pduString=(String)ar.result;
  SmsMessage sms=SmsMessage.newFromCDS(pduString);
  if (sms != null) {
    int messageRef=sms.messageRef;
    for (int i=0, count=deliveryPendingList.size(); i < count; i++) {
      SmsTracker tracker=deliveryPendingList.get(i);
      if (tracker.mMessageRef == messageRef) {
        deliveryPendingList.remove(i);
        PendingIntent intent=tracker.mDeliveryIntent;
        Intent fillIn=new Intent();
        fillIn.putExtra("String_Node_Str",IccUtils.hexStringToBytes(pduString));
        try {
          intent.send(mContext,Activity.RESULT_OK,fillIn);
        }
 catch (        CanceledException ex) {
        }
        break;
      }
    }
  }
  acknowledgeLastIncomingSms(true,Intents.RESULT_SMS_HANDLED,null);
}

Fixed version (ground truth):
/** 
 * Called when a status report is received.  This should correspond to a previously successful SEND.
 * @param ar AsyncResult passed into the message handler.  ar.result shouldbe a String representing the status report PDU, as ASCII hex.
 */
protected void handleStatusReport(AsyncResult ar){
  String pduString=(String)ar.result;
  SmsMessage sms=SmsMessage.newFromCDS(pduString);
  int tpStatus=sms.getStatus();
  if (sms != null) {
    int messageRef=sms.messageRef;
    for (int i=0, count=deliveryPendingList.size(); i < count; i++) {
      SmsTracker tracker=deliveryPendingList.get(i);
      if (tracker.mMessageRef == messageRef) {
        if (tpStatus >= Sms.STATUS_FAILED || tpStatus < Sms.STATUS_PENDING) {
          deliveryPendingList.remove(i);
        }
        PendingIntent intent=tracker.mDeliveryIntent;
        Intent fillIn=new Intent();
        fillIn.putExtra("String_Node_Str",IccUtils.hexStringToBytes(pduString));
        try {
          intent.send(mContext,Activity.RESULT_OK,fillIn);
        }
 catch (        CanceledException ex) {
        }
        break;
      }
    }
  }
  acknowledgeLastIncomingSms(true,Intents.RESULT_SMS_HANDLED,null);
}
Program: 41092
Project: 41092
Buggy source:
/** 
 * {@inheritDoc} 
 */
protected void sendMultipartText(String destinationAddress,String scAddress,ArrayList<String> parts,ArrayList<PendingIntent> sentIntents,ArrayList<PendingIntent> deliveryIntents){
  int refNumber=getNextConcatenatedRef() & 0x00FF;
  int msgCount=parts.size();
  int encoding=android.telephony.SmsMessage.ENCODING_UNKNOWN;
  for (int i=0; i < msgCount; i++) {
    TextEncodingDetails details=SmsMessage.calculateLength(parts.get(i),false);
    if (encoding != details.codeUnitSize && (encoding == android.telephony.SmsMessage.ENCODING_UNKNOWN || encoding == android.telephony.SmsMessage.ENCODING_7BIT)) {
      encoding=details.codeUnitSize;
    }
  }
  for (int i=0; i < msgCount; i++) {
    SmsHeader.ConcatRef concatRef=new SmsHeader.ConcatRef();
    concatRef.refNumber=refNumber;
    concatRef.seqNumber=i + 1;
    concatRef.msgCount=msgCount;
    concatRef.isEightBits=true;
    SmsHeader smsHeader=new SmsHeader();
    smsHeader.concatRef=concatRef;
    PendingIntent sentIntent=null;
    if (sentIntents != null && sentIntents.size() > i) {
      sentIntent=sentIntents.get(i);
    }
    PendingIntent deliveryIntent=null;
    if (deliveryIntents != null && deliveryIntents.size() > i) {
      deliveryIntent=deliveryIntents.get(i);
    }
    SmsMessage.SubmitPdu pdus=SmsMessage.getSubmitPdu(scAddress,destinationAddress,parts.get(i),deliveryIntent != null,SmsHeader.toByteArray(smsHeader),encoding);
    sendRawPdu(pdus.encodedScAddress,pdus.encodedMessage,sentIntent,deliveryIntent);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
protected void sendMultipartText(String destinationAddress,String scAddress,ArrayList<String> parts,ArrayList<PendingIntent> sentIntents,ArrayList<PendingIntent> deliveryIntents){
  int refNumber=getNextConcatenatedRef() & 0x00FF;
  int msgCount=parts.size();
  int encoding=android.telephony.SmsMessage.ENCODING_UNKNOWN;
  mRemainingMessages=msgCount;
  for (int i=0; i < msgCount; i++) {
    TextEncodingDetails details=SmsMessage.calculateLength(parts.get(i),false);
    if (encoding != details.codeUnitSize && (encoding == android.telephony.SmsMessage.ENCODING_UNKNOWN || encoding == android.telephony.SmsMessage.ENCODING_7BIT)) {
      encoding=details.codeUnitSize;
    }
  }
  for (int i=0; i < msgCount; i++) {
    SmsHeader.ConcatRef concatRef=new SmsHeader.ConcatRef();
    concatRef.refNumber=refNumber;
    concatRef.seqNumber=i + 1;
    concatRef.msgCount=msgCount;
    concatRef.isEightBits=true;
    SmsHeader smsHeader=new SmsHeader();
    smsHeader.concatRef=concatRef;
    PendingIntent sentIntent=null;
    if (sentIntents != null && sentIntents.size() > i) {
      sentIntent=sentIntents.get(i);
    }
    PendingIntent deliveryIntent=null;
    if (deliveryIntents != null && deliveryIntents.size() > i) {
      deliveryIntent=deliveryIntents.get(i);
    }
    SmsMessage.SubmitPdu pdus=SmsMessage.getSubmitPdu(scAddress,destinationAddress,parts.get(i),deliveryIntent != null,SmsHeader.toByteArray(smsHeader),encoding);
    sendRawPdu(pdus.encodedScAddress,pdus.encodedMessage,sentIntent,deliveryIntent);
  }
}
Program: 41093
Project: 41093
Buggy source:
/** 
 * Called when a status report is received.  This should correspond to a previously successful SEND.
 * @param ar AsyncResult passed into the message handler.  ar.result shouldbe a String representing the status report PDU, as ASCII hex.
 */
protected void handleStatusReport(AsyncResult ar){
  String pduString=(String)ar.result;
  SmsMessage sms=SmsMessage.newFromCDS(pduString);
  if (sms != null) {
    int messageRef=sms.messageRef;
    for (int i=0, count=deliveryPendingList.size(); i < count; i++) {
      SmsTracker tracker=deliveryPendingList.get(i);
      if (tracker.mMessageRef == messageRef) {
        deliveryPendingList.remove(i);
        PendingIntent intent=tracker.mDeliveryIntent;
        Intent fillIn=new Intent();
        fillIn.putExtra("String_Node_Str",IccUtils.hexStringToBytes(pduString));
        try {
          intent.send(mContext,Activity.RESULT_OK,fillIn);
        }
 catch (        CanceledException ex) {
        }
        break;
      }
    }
  }
  acknowledgeLastIncomingSms(true,Intents.RESULT_SMS_HANDLED,null);
}

Fixed version (ground truth):
/** 
 * Called when a status report is received.  This should correspond to a previously successful SEND.
 * @param ar AsyncResult passed into the message handler.  ar.result shouldbe a String representing the status report PDU, as ASCII hex.
 */
protected void handleStatusReport(AsyncResult ar){
  String pduString=(String)ar.result;
  SmsMessage sms=SmsMessage.newFromCDS(pduString);
  int tpStatus=sms.getStatus();
  if (sms != null) {
    int messageRef=sms.messageRef;
    for (int i=0, count=deliveryPendingList.size(); i < count; i++) {
      SmsTracker tracker=deliveryPendingList.get(i);
      if (tracker.mMessageRef == messageRef) {
        if (tpStatus >= Sms.STATUS_FAILED || tpStatus < Sms.STATUS_PENDING) {
          deliveryPendingList.remove(i);
        }
        PendingIntent intent=tracker.mDeliveryIntent;
        Intent fillIn=new Intent();
        fillIn.putExtra("String_Node_Str",IccUtils.hexStringToBytes(pduString));
        try {
          intent.send(mContext,Activity.RESULT_OK,fillIn);
        }
 catch (        CanceledException ex) {
        }
        break;
      }
    }
  }
  acknowledgeLastIncomingSms(true,Intents.RESULT_SMS_HANDLED,null);
}
Program: 41096
Project: 41096
Buggy source:
/** 
 * {@inheritDoc} 
 */
protected void sendMultipartText(String destinationAddress,String scAddress,ArrayList<String> parts,ArrayList<PendingIntent> sentIntents,ArrayList<PendingIntent> deliveryIntents){
  int refNumber=getNextConcatenatedRef() & 0x00FF;
  int msgCount=parts.size();
  int encoding=android.telephony.SmsMessage.ENCODING_UNKNOWN;
  for (int i=0; i < msgCount; i++) {
    TextEncodingDetails details=SmsMessage.calculateLength(parts.get(i),false);
    if (encoding != details.codeUnitSize && (encoding == android.telephony.SmsMessage.ENCODING_UNKNOWN || encoding == android.telephony.SmsMessage.ENCODING_7BIT)) {
      encoding=details.codeUnitSize;
    }
  }
  for (int i=0; i < msgCount; i++) {
    SmsHeader.ConcatRef concatRef=new SmsHeader.ConcatRef();
    concatRef.refNumber=refNumber;
    concatRef.seqNumber=i + 1;
    concatRef.msgCount=msgCount;
    concatRef.isEightBits=true;
    SmsHeader smsHeader=new SmsHeader();
    smsHeader.concatRef=concatRef;
    PendingIntent sentIntent=null;
    if (sentIntents != null && sentIntents.size() > i) {
      sentIntent=sentIntents.get(i);
    }
    PendingIntent deliveryIntent=null;
    if (deliveryIntents != null && deliveryIntents.size() > i) {
      deliveryIntent=deliveryIntents.get(i);
    }
    SmsMessage.SubmitPdu pdus=SmsMessage.getSubmitPdu(scAddress,destinationAddress,parts.get(i),deliveryIntent != null,SmsHeader.toByteArray(smsHeader),encoding);
    sendRawPdu(pdus.encodedScAddress,pdus.encodedMessage,sentIntent,deliveryIntent);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
protected void sendMultipartText(String destinationAddress,String scAddress,ArrayList<String> parts,ArrayList<PendingIntent> sentIntents,ArrayList<PendingIntent> deliveryIntents){
  int refNumber=getNextConcatenatedRef() & 0x00FF;
  int msgCount=parts.size();
  int encoding=android.telephony.SmsMessage.ENCODING_UNKNOWN;
  mRemainingMessages=msgCount;
  for (int i=0; i < msgCount; i++) {
    TextEncodingDetails details=SmsMessage.calculateLength(parts.get(i),false);
    if (encoding != details.codeUnitSize && (encoding == android.telephony.SmsMessage.ENCODING_UNKNOWN || encoding == android.telephony.SmsMessage.ENCODING_7BIT)) {
      encoding=details.codeUnitSize;
    }
  }
  for (int i=0; i < msgCount; i++) {
    SmsHeader.ConcatRef concatRef=new SmsHeader.ConcatRef();
    concatRef.refNumber=refNumber;
    concatRef.seqNumber=i + 1;
    concatRef.msgCount=msgCount;
    concatRef.isEightBits=true;
    SmsHeader smsHeader=new SmsHeader();
    smsHeader.concatRef=concatRef;
    PendingIntent sentIntent=null;
    if (sentIntents != null && sentIntents.size() > i) {
      sentIntent=sentIntents.get(i);
    }
    PendingIntent deliveryIntent=null;
    if (deliveryIntents != null && deliveryIntents.size() > i) {
      deliveryIntent=deliveryIntents.get(i);
    }
    SmsMessage.SubmitPdu pdus=SmsMessage.getSubmitPdu(scAddress,destinationAddress,parts.get(i),deliveryIntent != null,SmsHeader.toByteArray(smsHeader),encoding);
    sendRawPdu(pdus.encodedScAddress,pdus.encodedMessage,sentIntent,deliveryIntent);
  }
}
Program: 41099
Project: 41099
Buggy source:
private Drawable getCachedDrawable(long key){
synchronized (mTmpValue) {
    WeakReference<Drawable.ConstantState> wr=mDrawableCache.get(key);
    if (wr != null) {
      Drawable.ConstantState entry=wr.get();
      if (entry != null) {
        return entry.newDrawable(this);
      }
 else {
        mDrawableCache.delete(key);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private Drawable getCachedDrawable(LongSparseArray<WeakReference<ConstantState>> drawableCache,long key){
synchronized (mTmpValue) {
    WeakReference<Drawable.ConstantState> wr=drawableCache.get(key);
    if (wr != null) {
      Drawable.ConstantState entry=wr.get();
      if (entry != null) {
        return entry.newDrawable();
      }
 else {
        drawableCache.delete(key);
      }
    }
  }
  return null;
}
Program: 41101
Project: 41101
Buggy source:
public static ApplicationInfo generateApplicationInfo(Package p,int flags){
  if (p == null)   return null;
  if (!copyNeeded(flags,p,null)) {
    if (!sCompatibilityModeEnabled) {
      p.applicationInfo.disableCompatibilityMode();
    }
    return p.applicationInfo;
  }
  ApplicationInfo ai=new ApplicationInfo(p.applicationInfo);
  if ((flags & PackageManager.GET_META_DATA) != 0) {
    ai.metaData=p.mAppMetaData;
  }
  if ((flags & PackageManager.GET_SHARED_LIBRARY_FILES) != 0) {
    ai.sharedLibraryFiles=p.usesLibraryFiles;
  }
  if (!sCompatibilityModeEnabled) {
    ai.disableCompatibilityMode();
  }
  ai.enabled=p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
  return ai;
}

Fixed version (ground truth):
public static ApplicationInfo generateApplicationInfo(Package p,int flags){
  if (p == null)   return null;
  if (!copyNeeded(flags,p,null)) {
    if (!sCompatibilityModeEnabled) {
      p.applicationInfo.disableCompatibilityMode();
    }
    return p.applicationInfo;
  }
  ApplicationInfo ai=new ApplicationInfo(p.applicationInfo);
  if ((flags & PackageManager.GET_META_DATA) != 0) {
    ai.metaData=p.mAppMetaData;
  }
  if ((flags & PackageManager.GET_SHARED_LIBRARY_FILES) != 0) {
    ai.sharedLibraryFiles=p.usesLibraryFiles;
  }
  if (!sCompatibilityModeEnabled) {
    ai.disableCompatibilityMode();
  }
  if (p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
    ai.enabled=true;
  }
 else   if (p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
    ai.enabled=false;
  }
  return ai;
}
Program: 41104
Project: 41104
Buggy source:
PackageSetting(String name,String realName,File codePath,File resourcePath,String nativeLibraryPathString,int pVersionCode,int pkgFlags){
  super(name,realName,codePath,resourcePath,nativeLibraryPathString,pVersionCode,pkgFlags);
}

Fixed version (ground truth):
PackageSetting(PackageSetting orig){
  super(orig.name,orig.realName,orig.codePath,orig.resourcePath,orig.nativeLibraryPathString,orig.versionCode,orig.pkgFlags);
  copyFrom(orig);
}
Program: 41106
Project: 41106
Buggy source:
private boolean deleteSystemPackageLI(PackageParser.Package p,int flags,PackageRemovedInfo outInfo,boolean writeSettings){
  ApplicationInfo applicationInfo=p.applicationInfo;
  if (applicationInfo == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName + "String_Node_Str");
    return false;
  }
  PackageSetting ps=null;
synchronized (mPackages) {
    ps=mSettings.getDisabledSystemPkg(p.packageName);
  }
  if (ps == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName);
    return false;
  }
 else {
    Log.i(TAG,"String_Node_Str");
  }
  outInfo.isRemovedPackageSystemUpdate=true;
  final boolean deleteCodeAndResources;
  if (ps.versionCode < p.mVersionCode) {
    deleteCodeAndResources=true;
    flags&=~PackageManager.DONT_DELETE_DATA;
  }
 else {
    deleteCodeAndResources=false;
    flags|=PackageManager.DONT_DELETE_DATA;
  }
  boolean ret=deleteInstalledPackageLI(p,deleteCodeAndResources,flags,outInfo,writeSettings);
  if (!ret) {
    return false;
  }
synchronized (mPackages) {
    mSettings.enableSystemPackageLP(p.packageName);
    NativeLibraryHelper.removeNativeBinariesLI(p.applicationInfo.nativeLibraryDir);
  }
  PackageParser.Package newPkg=scanPackageLI(ps.codePath,PackageParser.PARSE_MUST_BE_APK | PackageParser.PARSE_IS_SYSTEM,SCAN_MONITOR | SCAN_NO_PATHS,0);
  if (newPkg == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName + "String_Node_Str"+ mLastScanError);
    return false;
  }
synchronized (mPackages) {
    updatePermissionsLP(newPkg.packageName,newPkg,true,true,false);
    if (writeSettings) {
      mSettings.writeLP();
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean deleteSystemPackageLI(PackageParser.Package p,int flags,PackageRemovedInfo outInfo,boolean writeSettings){
  ApplicationInfo applicationInfo=p.applicationInfo;
  if (applicationInfo == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName + "String_Node_Str");
    return false;
  }
  PackageSetting ps=null;
synchronized (mPackages) {
    ps=mSettings.getDisabledSystemPkg(p.packageName);
  }
  if (ps == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName);
    return false;
  }
 else {
    Log.i(TAG,"String_Node_Str");
  }
  outInfo.isRemovedPackageSystemUpdate=true;
  if (ps.versionCode < p.mVersionCode) {
    flags&=~PackageManager.DONT_DELETE_DATA;
  }
 else {
    flags|=PackageManager.DONT_DELETE_DATA;
  }
  boolean ret=deleteInstalledPackageLI(p,true,flags,outInfo,writeSettings);
  if (!ret) {
    return false;
  }
synchronized (mPackages) {
    mSettings.enableSystemPackageLP(p.packageName);
    NativeLibraryHelper.removeNativeBinariesLI(p.applicationInfo.nativeLibraryDir);
  }
  PackageParser.Package newPkg=scanPackageLI(ps.codePath,PackageParser.PARSE_MUST_BE_APK | PackageParser.PARSE_IS_SYSTEM,SCAN_MONITOR | SCAN_NO_PATHS,0);
  if (newPkg == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName + "String_Node_Str"+ mLastScanError);
    return false;
  }
synchronized (mPackages) {
    updatePermissionsLP(newPkg.packageName,newPkg,true,true,false);
    if (writeSettings) {
      mSettings.writeLP();
    }
  }
  return true;
}
Program: 41107
Project: 41107
Buggy source:
int disableSystemPackageLP(String name){
  PackageSetting p=mPackages.get(name);
  if (p == null) {
    Log.w(TAG,"String_Node_Str" + name + "String_Node_Str");
    return -1;
  }
  PackageSetting dp=mDisabledSysPackages.get(name);
  if (dp == null) {
    if ((p.pkg != null) && (p.pkg.applicationInfo != null)) {
      p.pkg.applicationInfo.flags|=ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
    }
    mDisabledSysPackages.put(name,p);
  }
  return removePackageLP(name);
}

Fixed version (ground truth):
boolean disableSystemPackageLP(String name){
  PackageSetting p=mPackages.get(name);
  if (p == null) {
    Log.w(TAG,"String_Node_Str" + name + "String_Node_Str");
    return false;
  }
  PackageSetting dp=mDisabledSysPackages.get(name);
  if (dp == null) {
    if ((p.pkg != null) && (p.pkg.applicationInfo != null)) {
      p.pkg.applicationInfo.flags|=ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
    }
    mDisabledSysPackages.put(name,p);
    PackageSetting newp=new PackageSetting(p);
    replacePackageLP(name,newp);
    return true;
  }
  return false;
}
Program: 41112
Project: 41112
Buggy source:
/** 
 * Set this object to the system defaults.
 */
public void setToDefaults(){
  fontScale=1;
  mcc=mnc=0;
  locale=null;
  userSetLocale=false;
  touchscreen=TOUCHSCREEN_UNDEFINED;
  keyboard=KEYBOARD_UNDEFINED;
  keyboardHidden=KEYBOARDHIDDEN_UNDEFINED;
  hardKeyboardHidden=HARDKEYBOARDHIDDEN_UNDEFINED;
  navigation=NAVIGATION_UNDEFINED;
  navigationHidden=NAVIGATIONHIDDEN_UNDEFINED;
  orientation=ORIENTATION_UNDEFINED;
  screenLayout=SCREENLAYOUT_SIZE_UNDEFINED;
  uiMode=UI_MODE_TYPE_UNDEFINED;
  seq=0;
  String themeResource=SystemProperties.get(THEME_ID_PERSISTENCE_PROPERTY,null);
  String themePackageName=SystemProperties.get(THEME_PACKAGE_NAME_PERSISTENCE_PROPERTY,null);
  if (themeResource != null && themePackageName != null) {
    customTheme=new CustomTheme(themeResource,themePackageName);
  }
 else {
    customTheme=CustomTheme.getDefault();
  }
}

Fixed version (ground truth):
/** 
 * Set this object to the system defaults.
 */
public void setToDefaults(){
  fontScale=1;
  mcc=mnc=0;
  locale=null;
  userSetLocale=false;
  touchscreen=TOUCHSCREEN_UNDEFINED;
  keyboard=KEYBOARD_UNDEFINED;
  keyboardHidden=KEYBOARDHIDDEN_UNDEFINED;
  hardKeyboardHidden=HARDKEYBOARDHIDDEN_UNDEFINED;
  navigation=NAVIGATION_UNDEFINED;
  navigationHidden=NAVIGATIONHIDDEN_UNDEFINED;
  orientation=ORIENTATION_UNDEFINED;
  screenLayout=SCREENLAYOUT_SIZE_UNDEFINED;
  uiMode=UI_MODE_TYPE_UNDEFINED;
  seq=0;
  customTheme=null;
}
Program: 41113
Project: 41113
Buggy source:
public int hashCode(){
  return ((int)this.fontScale) + this.mcc + this.mnc+ (this.locale != null ? this.locale.hashCode() : 0)+ this.touchscreen+ this.keyboard+ this.keyboardHidden+ this.hardKeyboardHidden+ this.navigation+ this.navigationHidden+ this.orientation+ this.screenLayout+ this.uiMode+ this.customTheme.hashCode();
}

Fixed version (ground truth):
public int hashCode(){
  return ((int)this.fontScale) + this.mcc + this.mnc+ (this.locale != null ? this.locale.hashCode() : 0)+ this.touchscreen+ this.keyboard+ this.keyboardHidden+ this.hardKeyboardHidden+ this.navigation+ this.navigationHidden+ this.orientation+ this.screenLayout+ this.uiMode+ (this.customTheme != null ? this.customTheme.hashCode() : 0);
}
Program: 41114
Project: 41114
Buggy source:
public void setTo(Configuration o){
  fontScale=o.fontScale;
  mcc=o.mcc;
  mnc=o.mnc;
  if (o.locale != null) {
    locale=(Locale)o.locale.clone();
  }
  userSetLocale=o.userSetLocale;
  touchscreen=o.touchscreen;
  keyboard=o.keyboard;
  keyboardHidden=o.keyboardHidden;
  hardKeyboardHidden=o.hardKeyboardHidden;
  navigation=o.navigation;
  navigationHidden=o.navigationHidden;
  orientation=o.orientation;
  screenLayout=o.screenLayout;
  uiMode=o.uiMode;
  seq=o.seq;
  if (o.customTheme != null) {
    customTheme=(CustomTheme)o.customTheme.clone();
  }
 else {
    customTheme=CustomTheme.getDefault();
  }
}

Fixed version (ground truth):
public void setTo(Configuration o){
  fontScale=o.fontScale;
  mcc=o.mcc;
  mnc=o.mnc;
  if (o.locale != null) {
    locale=(Locale)o.locale.clone();
  }
  userSetLocale=o.userSetLocale;
  touchscreen=o.touchscreen;
  keyboard=o.keyboard;
  keyboardHidden=o.keyboardHidden;
  hardKeyboardHidden=o.hardKeyboardHidden;
  navigation=o.navigation;
  navigationHidden=o.navigationHidden;
  orientation=o.orientation;
  screenLayout=o.screenLayout;
  uiMode=o.uiMode;
  seq=o.seq;
  if (o.customTheme != null) {
    customTheme=(CustomTheme)o.customTheme.clone();
  }
}
Program: 41115
Project: 41115
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (action.equals(Intent.ACTION_APP_LAUNCH_FAILURE)) {
    long currentTime=SystemClock.uptimeMillis();
    if (currentTime - mStartTime > EXPIRATION_TIME_IN_MILLISECONDS) {
      mStartTime=currentTime;
      mFailuresCount=0;
    }
    if (mFailuresCount <= FAILURES_THRESHOLD) {
      mFailuresCount++;
      if (mFailuresCount == FAILURES_THRESHOLD) {
        CustomTheme defaultTheme=CustomTheme.getDefault();
        ActivityManager am=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
        Configuration currentConfig=am.getConfiguration();
        currentConfig.customTheme=new CustomTheme(defaultTheme.getThemeId(),defaultTheme.getThemePackageName());
        am.updateConfiguration(currentConfig);
      }
    }
  }
 else   if (action.equals(Intent.ACTION_APP_LAUNCH_FAILURE_RESET)) {
    mFailuresCount=0;
    mStartTime=SystemClock.uptimeMillis();
  }
 else   if (action.equals(Intent.ACTION_PACKAGE_ADDED) || action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
    mFailuresCount=0;
    mStartTime=SystemClock.uptimeMillis();
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (action.equals(Intent.ACTION_APP_LAUNCH_FAILURE)) {
    long currentTime=SystemClock.uptimeMillis();
    if (currentTime - mStartTime > EXPIRATION_TIME_IN_MILLISECONDS) {
      mStartTime=currentTime;
      mFailuresCount=0;
    }
    if (mFailuresCount <= FAILURES_THRESHOLD) {
      mFailuresCount++;
      if (mFailuresCount == FAILURES_THRESHOLD) {
        CustomTheme defaultTheme=CustomTheme.getSystemTheme();
        ActivityManager am=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
        Configuration currentConfig=am.getConfiguration();
        currentConfig.customTheme=new CustomTheme(defaultTheme.getThemeId(),defaultTheme.getThemePackageName());
        am.updateConfiguration(currentConfig);
      }
    }
  }
 else   if (action.equals(Intent.ACTION_APP_LAUNCH_FAILURE_RESET)) {
    mFailuresCount=0;
    mStartTime=SystemClock.uptimeMillis();
  }
 else   if (action.equals(Intent.ACTION_PACKAGE_ADDED) || action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
    mFailuresCount=0;
    mStartTime=SystemClock.uptimeMillis();
  }
}
Program: 41117
Project: 41117
Buggy source:
private void saveThemeResourceLocked(CustomTheme customTheme,boolean isDiff){
  if (isDiff) {
    String themeId;
    String themePackage;
    String resourcePath;
    boolean hasParent;
    boolean forceUpdate;
    if (customTheme != null) {
      themeId=customTheme.getThemeId();
      themePackage=customTheme.getThemePackageName();
    }
 else {
      themeId=null;
      themePackage="String_Node_Str";
      resourcePath=null;
      hasParent=false;
      forceUpdate=false;
    }
    SystemProperties.set(Configuration.THEME_ID_PERSISTENCE_PROPERTY,themeId);
    SystemProperties.set(Configuration.THEME_PACKAGE_NAME_PERSISTENCE_PROPERTY,themePackage);
  }
}

Fixed version (ground truth):
private void saveThemeResourceLocked(CustomTheme t,boolean isDiff){
  if (isDiff) {
    SystemProperties.set(Configuration.THEME_ID_PERSISTENCE_PROPERTY,t.getThemeId());
    SystemProperties.set(Configuration.THEME_PACKAGE_NAME_PERSISTENCE_PROPERTY,t.getThemePackageName());
  }
}
Program: 41118
Project: 41118
Buggy source:
/** 
 * Called from the input dispatcher thread before a key is dispatched to a window. <p>Allows you to define behavior for keys that can not be overridden by applications or redirect key events to a different window.  This method is called from the input thread, with no locks held. <p>Note that if you change the window a key is dispatched to, the new target window will receive the key event without having input focus.
 * @param win The window that currently has focus.  This is where the keyevent will normally go.
 * @param action The key event action.
 * @param flags The key event flags.
 * @param keyCode The key code.
 * @param metaState bit mask of meta keys that are held.
 * @param repeatCount Number of times a key down has repeated.
 * @param policyFlags The policy flags associated with the key.
 * @return Returns true if the policy consumed the event and it shouldnot be further dispatched.
 */
public boolean interceptKeyBeforeDispatching(WindowState win,int action,int flags,int keyCode,int metaState,int repeatCount,int policyFlags);

Fixed version (ground truth):
/** 
 * Called from the input dispatcher thread before a key is dispatched to a window. <p>Allows you to define behavior for keys that can not be overridden by applications or redirect key events to a different window.  This method is called from the input thread, with no locks held. <p>Note that if you change the window a key is dispatched to, the new target window will receive the key event without having input focus.
 * @param win The window that currently has focus.  This is where the keyevent will normally go.
 * @param action The key event action.
 * @param flags The key event flags.
 * @param keyCode The key code.
 * @param scanCode The key's scan code.
 * @param metaState bit mask of meta keys that are held.
 * @param repeatCount Number of times a key down has repeated.
 * @param policyFlags The policy flags associated with the key.
 * @return Returns true if the policy consumed the event and it shouldnot be further dispatched.
 */
public boolean interceptKeyBeforeDispatching(WindowState win,int action,int flags,int keyCode,int scanCode,int metaState,int repeatCount,int policyFlags);
Program: 41119
Project: 41119
Buggy source:
/** 
 * Called from the input reader thread before a key is enqueued. <p>There are some actions that need to be handled here because they affect the power state of the device, for example, the power keys. Generally, it's best to keep as little as possible in the queue thread because it's the most fragile.
 * @param whenNanos The event time in uptime nanoseconds.
 * @param keyCode The key code.
 * @param down True if the key is down.
 * @param policyFlags The policy flags associated with the key.
 * @param isScreenOn True if the screen is already on
 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},  {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
 */
public int interceptKeyBeforeQueueing(long whenNanos,int keyCode,boolean down,int policyFlags,boolean isScreenOn);

Fixed version (ground truth):
/** 
 * Called from the input reader thread before a key is enqueued. <p>There are some actions that need to be handled here because they affect the power state of the device, for example, the power keys. Generally, it's best to keep as little as possible in the queue thread because it's the most fragile.
 * @param whenNanos The event time in uptime nanoseconds.
 * @param action The key event action.
 * @param flags The key event flags.
 * @param keyCode The key code.
 * @param scanCode The key's scan code.
 * @param policyFlags The policy flags associated with the key.
 * @param isScreenOn True if the screen is already on
 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},  {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
 */
public int interceptKeyBeforeQueueing(long whenNanos,int action,int flags,int keyCode,int scanCode,int policyFlags,boolean isScreenOn);
Program: 41120
Project: 41120
Buggy source:
@Override public Parcelable onSaveInstanceState(){
  dismissPopup();
  Parcelable superState=super.onSaveInstanceState();
  SavedState ss=new SavedState(superState);
  boolean haveChildren=getChildCount() > 0 && mItemCount > 0;
  long selectedId=getSelectedItemId();
  ss.selectedId=selectedId;
  ss.height=getHeight();
  if (selectedId >= 0) {
    ss.viewTop=mSelectedTop;
    ss.position=getSelectedItemPosition();
    ss.firstId=INVALID_POSITION;
  }
 else {
    if (haveChildren) {
      View v=getChildAt(0);
      ss.viewTop=v.getTop();
      int firstPos=mFirstPosition;
      if (firstPos >= mItemCount) {
        firstPos=mItemCount - 1;
      }
      ss.position=firstPos;
      ss.firstId=mAdapter.getItemId(firstPos);
    }
 else {
      ss.viewTop=0;
      ss.firstId=INVALID_POSITION;
      ss.position=0;
    }
  }
  ss.filter=null;
  if (mFiltered) {
    final EditText textFilter=mTextFilter;
    if (textFilter != null) {
      Editable filterText=textFilter.getText();
      if (filterText != null) {
        ss.filter=filterText.toString();
      }
    }
  }
  return ss;
}

Fixed version (ground truth):
@Override public Parcelable onSaveInstanceState(){
  dismissPopup();
  Parcelable superState=super.onSaveInstanceState();
  SavedState ss=new SavedState(superState);
  boolean haveChildren=getChildCount() > 0 && mItemCount > 0;
  long selectedId=getSelectedItemId();
  ss.selectedId=selectedId;
  ss.height=getHeight();
  if (selectedId >= 0) {
    ss.viewTop=mSelectedTop;
    ss.position=getSelectedItemPosition();
    ss.firstId=INVALID_POSITION;
  }
 else {
    if (haveChildren && mFirstPosition > 0) {
      View v=getChildAt(0);
      ss.viewTop=v.getTop();
      int firstPos=mFirstPosition;
      if (firstPos >= mItemCount) {
        firstPos=mItemCount - 1;
      }
      ss.position=firstPos;
      ss.firstId=mAdapter.getItemId(firstPos);
    }
 else {
      ss.viewTop=0;
      ss.firstId=INVALID_POSITION;
      ss.position=0;
    }
  }
  ss.filter=null;
  if (mFiltered) {
    final EditText textFilter=mTextFilter;
    if (textFilter != null) {
      Editable filterText=textFilter.getText();
      if (filterText != null) {
        ss.filter=filterText.toString();
      }
    }
  }
  return ss;
}
Program: 41121
Project: 41121
Buggy source:
@Override public Parcelable onSaveInstanceState(){
  dismissPopup();
  Parcelable superState=super.onSaveInstanceState();
  SavedState ss=new SavedState(superState);
  boolean haveChildren=getChildCount() > 0 && mItemCount > 0;
  long selectedId=getSelectedItemId();
  ss.selectedId=selectedId;
  ss.height=getHeight();
  if (selectedId >= 0) {
    ss.viewTop=mSelectedTop;
    ss.position=getSelectedItemPosition();
    ss.firstId=INVALID_POSITION;
  }
 else {
    if (haveChildren) {
      View v=getChildAt(0);
      ss.viewTop=v.getTop();
      int firstPos=mFirstPosition;
      if (firstPos >= mItemCount) {
        firstPos=mItemCount - 1;
      }
      ss.position=firstPos;
      ss.firstId=mAdapter.getItemId(firstPos);
    }
 else {
      ss.viewTop=0;
      ss.firstId=INVALID_POSITION;
      ss.position=0;
    }
  }
  ss.filter=null;
  if (mFiltered) {
    final EditText textFilter=mTextFilter;
    if (textFilter != null) {
      Editable filterText=textFilter.getText();
      if (filterText != null) {
        ss.filter=filterText.toString();
      }
    }
  }
  return ss;
}

Fixed version (ground truth):
@Override public Parcelable onSaveInstanceState(){
  dismissPopup();
  Parcelable superState=super.onSaveInstanceState();
  SavedState ss=new SavedState(superState);
  boolean haveChildren=getChildCount() > 0 && mItemCount > 0;
  long selectedId=getSelectedItemId();
  ss.selectedId=selectedId;
  ss.height=getHeight();
  if (selectedId >= 0) {
    ss.viewTop=mSelectedTop;
    ss.position=getSelectedItemPosition();
    ss.firstId=INVALID_POSITION;
  }
 else {
    if (haveChildren && mFirstPosition > 0) {
      View v=getChildAt(0);
      ss.viewTop=v.getTop();
      int firstPos=mFirstPosition;
      if (firstPos >= mItemCount) {
        firstPos=mItemCount - 1;
      }
      ss.position=firstPos;
      ss.firstId=mAdapter.getItemId(firstPos);
    }
 else {
      ss.viewTop=0;
      ss.firstId=INVALID_POSITION;
      ss.position=0;
    }
  }
  ss.filter=null;
  if (mFiltered) {
    final EditText textFilter=mTextFilter;
    if (textFilter != null) {
      Editable filterText=textFilter.getText();
      if (filterText != null) {
        ss.filter=filterText.toString();
      }
    }
  }
  return ss;
}
Program: 41122
Project: 41122
Buggy source:
/** 
 * Called from the input dispatcher thread before a key is dispatched to a window. <p>Allows you to define behavior for keys that can not be overridden by applications or redirect key events to a different window.  This method is called from the input thread, with no locks held. <p>Note that if you change the window a key is dispatched to, the new target window will receive the key event without having input focus.
 * @param win The window that currently has focus.  This is where the keyevent will normally go.
 * @param action The key event action.
 * @param flags The key event flags.
 * @param keyCode The key code.
 * @param metaState bit mask of meta keys that are held.
 * @param repeatCount Number of times a key down has repeated.
 * @param policyFlags The policy flags associated with the key.
 * @return Returns true if the policy consumed the event and it shouldnot be further dispatched.
 */
public boolean interceptKeyBeforeDispatching(WindowState win,int action,int flags,int keyCode,int metaState,int repeatCount,int policyFlags);

Fixed version (ground truth):
/** 
 * Called from the input dispatcher thread before a key is dispatched to a window. <p>Allows you to define behavior for keys that can not be overridden by applications or redirect key events to a different window.  This method is called from the input thread, with no locks held. <p>Note that if you change the window a key is dispatched to, the new target window will receive the key event without having input focus.
 * @param win The window that currently has focus.  This is where the keyevent will normally go.
 * @param action The key event action.
 * @param flags The key event flags.
 * @param keyCode The key code.
 * @param scanCode The key's scan code.
 * @param metaState bit mask of meta keys that are held.
 * @param repeatCount Number of times a key down has repeated.
 * @param policyFlags The policy flags associated with the key.
 * @return Returns true if the policy consumed the event and it shouldnot be further dispatched.
 */
public boolean interceptKeyBeforeDispatching(WindowState win,int action,int flags,int keyCode,int scanCode,int metaState,int repeatCount,int policyFlags);
Program: 41123
Project: 41123
Buggy source:
/** 
 * Called from the input reader thread before a key is enqueued. <p>There are some actions that need to be handled here because they affect the power state of the device, for example, the power keys. Generally, it's best to keep as little as possible in the queue thread because it's the most fragile.
 * @param whenNanos The event time in uptime nanoseconds.
 * @param keyCode The key code.
 * @param down True if the key is down.
 * @param policyFlags The policy flags associated with the key.
 * @param isScreenOn True if the screen is already on
 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},  {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
 */
public int interceptKeyBeforeQueueing(long whenNanos,int keyCode,boolean down,int policyFlags,boolean isScreenOn);

Fixed version (ground truth):
/** 
 * Called from the input reader thread before a key is enqueued. <p>There are some actions that need to be handled here because they affect the power state of the device, for example, the power keys. Generally, it's best to keep as little as possible in the queue thread because it's the most fragile.
 * @param whenNanos The event time in uptime nanoseconds.
 * @param action The key event action.
 * @param flags The key event flags.
 * @param keyCode The key code.
 * @param scanCode The key's scan code.
 * @param policyFlags The policy flags associated with the key.
 * @param isScreenOn True if the screen is already on
 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},  {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
 */
public int interceptKeyBeforeQueueing(long whenNanos,int action,int flags,int keyCode,int scanCode,int policyFlags,boolean isScreenOn);
Program: 41126
Project: 41126
Buggy source:
PackageSetting(String name,String realName,File codePath,File resourcePath,String nativeLibraryPathString,int pVersionCode,int pkgFlags){
  super(name,realName,codePath,resourcePath,nativeLibraryPathString,pVersionCode,pkgFlags);
}

Fixed version (ground truth):
PackageSetting(PackageSetting orig){
  super(orig.name,orig.realName,orig.codePath,orig.resourcePath,orig.nativeLibraryPathString,orig.versionCode,orig.pkgFlags);
  copyFrom(orig);
}
Program: 41128
Project: 41128
Buggy source:
private boolean deleteSystemPackageLI(PackageParser.Package p,int flags,PackageRemovedInfo outInfo,boolean writeSettings){
  ApplicationInfo applicationInfo=p.applicationInfo;
  if (applicationInfo == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName + "String_Node_Str");
    return false;
  }
  PackageSetting ps=null;
synchronized (mPackages) {
    ps=mSettings.getDisabledSystemPkg(p.packageName);
  }
  if (ps == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName);
    return false;
  }
 else {
    Log.i(TAG,"String_Node_Str");
  }
  outInfo.isRemovedPackageSystemUpdate=true;
  final boolean deleteCodeAndResources;
  if (ps.versionCode < p.mVersionCode) {
    deleteCodeAndResources=true;
    flags&=~PackageManager.DONT_DELETE_DATA;
  }
 else {
    deleteCodeAndResources=false;
    flags|=PackageManager.DONT_DELETE_DATA;
  }
  boolean ret=deleteInstalledPackageLI(p,deleteCodeAndResources,flags,outInfo,writeSettings);
  if (!ret) {
    return false;
  }
synchronized (mPackages) {
    mSettings.enableSystemPackageLP(p.packageName);
    NativeLibraryHelper.removeNativeBinariesLI(p.applicationInfo.nativeLibraryDir);
  }
  PackageParser.Package newPkg=scanPackageLI(ps.codePath,PackageParser.PARSE_MUST_BE_APK | PackageParser.PARSE_IS_SYSTEM,SCAN_MONITOR | SCAN_NO_PATHS,0);
  if (newPkg == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName + "String_Node_Str"+ mLastScanError);
    return false;
  }
synchronized (mPackages) {
    updatePermissionsLP(newPkg.packageName,newPkg,true,true,false);
    if (writeSettings) {
      mSettings.writeLP();
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean deleteSystemPackageLI(PackageParser.Package p,int flags,PackageRemovedInfo outInfo,boolean writeSettings){
  ApplicationInfo applicationInfo=p.applicationInfo;
  if (applicationInfo == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName + "String_Node_Str");
    return false;
  }
  PackageSetting ps=null;
synchronized (mPackages) {
    ps=mSettings.getDisabledSystemPkg(p.packageName);
  }
  if (ps == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName);
    return false;
  }
 else {
    Log.i(TAG,"String_Node_Str");
  }
  outInfo.isRemovedPackageSystemUpdate=true;
  if (ps.versionCode < p.mVersionCode) {
    flags&=~PackageManager.DONT_DELETE_DATA;
  }
 else {
    flags|=PackageManager.DONT_DELETE_DATA;
  }
  boolean ret=deleteInstalledPackageLI(p,true,flags,outInfo,writeSettings);
  if (!ret) {
    return false;
  }
synchronized (mPackages) {
    mSettings.enableSystemPackageLP(p.packageName);
    NativeLibraryHelper.removeNativeBinariesLI(p.applicationInfo.nativeLibraryDir);
  }
  PackageParser.Package newPkg=scanPackageLI(ps.codePath,PackageParser.PARSE_MUST_BE_APK | PackageParser.PARSE_IS_SYSTEM,SCAN_MONITOR | SCAN_NO_PATHS,0);
  if (newPkg == null) {
    Slog.w(TAG,"String_Node_Str" + p.packageName + "String_Node_Str"+ mLastScanError);
    return false;
  }
synchronized (mPackages) {
    updatePermissionsLP(newPkg.packageName,newPkg,true,true,false);
    if (writeSettings) {
      mSettings.writeLP();
    }
  }
  return true;
}
Program: 41129
Project: 41129
Buggy source:
int disableSystemPackageLP(String name){
  PackageSetting p=mPackages.get(name);
  if (p == null) {
    Log.w(TAG,"String_Node_Str" + name + "String_Node_Str");
    return -1;
  }
  PackageSetting dp=mDisabledSysPackages.get(name);
  if (dp == null) {
    if ((p.pkg != null) && (p.pkg.applicationInfo != null)) {
      p.pkg.applicationInfo.flags|=ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
    }
    mDisabledSysPackages.put(name,p);
  }
  return removePackageLP(name);
}

Fixed version (ground truth):
boolean disableSystemPackageLP(String name){
  PackageSetting p=mPackages.get(name);
  if (p == null) {
    Log.w(TAG,"String_Node_Str" + name + "String_Node_Str");
    return false;
  }
  PackageSetting dp=mDisabledSysPackages.get(name);
  if (dp == null) {
    if ((p.pkg != null) && (p.pkg.applicationInfo != null)) {
      p.pkg.applicationInfo.flags|=ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
    }
    mDisabledSysPackages.put(name,p);
    PackageSetting newp=new PackageSetting(p);
    replacePackageLP(name,newp);
    return true;
  }
  return false;
}
Program: 41131
Project: 41131
Buggy source:
@Override public Parcelable onSaveInstanceState(){
  dismissPopup();
  Parcelable superState=super.onSaveInstanceState();
  SavedState ss=new SavedState(superState);
  boolean haveChildren=getChildCount() > 0;
  long selectedId=getSelectedItemId();
  ss.selectedId=selectedId;
  ss.height=getHeight();
  if (selectedId >= 0) {
    ss.viewTop=mSelectedTop;
    ss.position=getSelectedItemPosition();
    ss.firstId=INVALID_POSITION;
  }
 else {
    if (haveChildren) {
      View v=getChildAt(0);
      ss.viewTop=v.getTop();
      ss.position=mFirstPosition;
      ss.firstId=mAdapter.getItemId(mFirstPosition);
    }
 else {
      ss.viewTop=0;
      ss.firstId=INVALID_POSITION;
      ss.position=0;
    }
  }
  ss.filter=null;
  if (mFiltered) {
    final EditText textFilter=mTextFilter;
    if (textFilter != null) {
      Editable filterText=textFilter.getText();
      if (filterText != null) {
        ss.filter=filterText.toString();
      }
    }
  }
  return ss;
}

Fixed version (ground truth):
@Override public Parcelable onSaveInstanceState(){
  dismissPopup();
  Parcelable superState=super.onSaveInstanceState();
  SavedState ss=new SavedState(superState);
  boolean haveChildren=getChildCount() > 0 && mItemCount > 0;
  long selectedId=getSelectedItemId();
  ss.selectedId=selectedId;
  ss.height=getHeight();
  if (selectedId >= 0) {
    ss.viewTop=mSelectedTop;
    ss.position=getSelectedItemPosition();
    ss.firstId=INVALID_POSITION;
  }
 else {
    if (haveChildren) {
      View v=getChildAt(0);
      ss.viewTop=v.getTop();
      int firstPos=mFirstPosition;
      if (firstPos >= mItemCount) {
        firstPos=mItemCount - 1;
      }
      ss.position=firstPos;
      ss.firstId=mAdapter.getItemId(firstPos);
    }
 else {
      ss.viewTop=0;
      ss.firstId=INVALID_POSITION;
      ss.position=0;
    }
  }
  ss.filter=null;
  if (mFiltered) {
    final EditText textFilter=mTextFilter;
    if (textFilter != null) {
      Editable filterText=textFilter.getText();
      if (filterText != null) {
        ss.filter=filterText.toString();
      }
    }
  }
  return ss;
}