Program: 22259
Project: 22259
Buggy source:
private boolean deleteSystemPackageLI(PackageParser.Package p,int flags,PackageRemovedInfo outInfo){
  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;
  boolean deleteCodeAndResources=false;
  if (ps.versionCode < p.mVersionCode) {
    deleteCodeAndResources=true;
    if ((flags & PackageManager.DONT_DELETE_DATA) == 0) {
      flags&=~PackageManager.DONT_DELETE_DATA;
    }
  }
 else {
    if ((flags & PackageManager.DONT_DELETE_DATA) == 0) {
      flags|=PackageManager.DONT_DELETE_DATA;
    }
  }
  boolean ret=deleteInstalledPackageLI(p,deleteCodeAndResources,flags,outInfo);
  if (!ret) {
    return false;
  }
synchronized (mPackages) {
    mSettings.enableSystemPackageLP(p.packageName);
    removeNativeBinariesLI(p);
  }
  PackageParser.Package newPkg=scanPackageLI(ps.codePath,PackageParser.PARSE_MUST_BE_APK | PackageParser.PARSE_IS_SYSTEM,SCAN_MONITOR | SCAN_NO_PATHS);
  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);
    mSettings.writeLP();
  }
  return true;
}

Fixed version (ground truth):
private boolean deleteSystemPackageLI(PackageParser.Package p,int flags,PackageRemovedInfo outInfo){
  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;
  boolean deleteCodeAndResources=false;
  if (ps.versionCode < p.mVersionCode) {
    deleteCodeAndResources=true;
    if ((flags & PackageManager.DONT_DELETE_DATA) == 0) {
      flags&=~PackageManager.DONT_DELETE_DATA;
    }
  }
 else {
    if ((flags & PackageManager.DONT_DELETE_DATA) == 0) {
      flags|=PackageManager.DONT_DELETE_DATA;
    }
  }
  boolean ret=deleteInstalledPackageLI(p,deleteCodeAndResources,flags,outInfo);
  if (!ret) {
    return false;
  }
synchronized (mPackages) {
    mSettings.enableSystemPackageLP(p.packageName);
    removeNativeBinariesLI(p);
  }
  PackageParser.Package newPkg=scanPackageLI(ps.codePath,PackageParser.PARSE_MUST_BE_APK | PackageParser.PARSE_IS_SYSTEM,SCAN_MONITOR | SCAN_NO_PATHS);
  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);
    mSettings.writeLP();
  }
  return true;
}