nus-yam/ex-repair huggingface dataset:
Program: 181916
Project: 181916
Buggy source:
private void unloadMediaPackages(HashMap<SdInstallArgs,String> processCids,int uidArr[]){
  if (DEBUG_SD_INSTALL)   Log.i(TAG,"String_Node_Str");
  ArrayList<String> pkgList=new ArrayList<String>();
  ArrayList<SdInstallArgs> failedList=new ArrayList<SdInstallArgs>();
  Set<SdInstallArgs> keys=processCids.keySet();
  for (  SdInstallArgs args : keys) {
    String cid=args.cid;
    String pkgName=args.getPackageName();
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str" + pkgName);
    PackageRemovedInfo outInfo=new PackageRemovedInfo();
synchronized (mInstallLock) {
      boolean res=deletePackageLI(pkgName,false,PackageManager.DONT_DELETE_DATA,outInfo);
      if (res) {
        pkgList.add(pkgName);
      }
 else {
        Slog.e(TAG,"String_Node_Str" + pkgName);
        failedList.add(args);
      }
    }
  }
  if (pkgList.size() > 0) {
    sendResourcesChangedBroadcast(false,pkgList,uidArr);
  }
  Runtime.getRuntime().gc();
  for (  SdInstallArgs args : keys) {
synchronized (mInstallLock) {
      args.doPostDeleteLI(false);
    }
  }
}

Fixed version (ground truth):
private void unloadMediaPackages(HashMap<SdInstallArgs,String> processCids,int uidArr[]){
  if (DEBUG_SD_INSTALL)   Log.i(TAG,"String_Node_Str");
  ArrayList<String> pkgList=new ArrayList<String>();
  ArrayList<SdInstallArgs> failedList=new ArrayList<SdInstallArgs>();
  Set<SdInstallArgs> keys=processCids.keySet();
  for (  SdInstallArgs args : keys) {
    String cid=args.cid;
    String pkgName=args.getPackageName();
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str" + pkgName);
    PackageRemovedInfo outInfo=new PackageRemovedInfo();
synchronized (mInstallLock) {
      boolean res=deletePackageLI(pkgName,false,PackageManager.DONT_DELETE_DATA,outInfo);
      if (res) {
        pkgList.add(pkgName);
      }
 else {
        Slog.e(TAG,"String_Node_Str" + pkgName);
        failedList.add(args);
      }
    }
  }
  if (pkgList.size() > 0) {
    sendResourcesChangedBroadcast(false,pkgList,uidArr,new IIntentReceiver.Stub(){
      public void performReceive(      Intent intent,      int resultCode,      String data,      Bundle extras,      boolean ordered,      boolean sticky) throws RemoteException {
        Runtime.getRuntime().gc();
      }
    }
);
  }
  for (  SdInstallArgs args : keys) {
synchronized (mInstallLock) {
      args.doPostDeleteLI(false);
    }
  }
}
Program: 181918
Project: 181918
Buggy source:
private static final void sendPackageBroadcast(String action,String pkg,Bundle extras){
  IActivityManager am=ActivityManagerNative.getDefault();
  if (am != null) {
    try {
      final Intent intent=new Intent(action,pkg != null ? Uri.fromParts("String_Node_Str",pkg,null) : null);
      if (extras != null) {
        intent.putExtras(extras);
      }
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
      am.broadcastIntent(null,intent,null,null,0,null,null,null,false,false);
    }
 catch (    RemoteException ex) {
    }
  }
}

Fixed version (ground truth):
private static final void sendPackageBroadcast(String action,String pkg,Bundle extras,IIntentReceiver finishedReceiver){
  IActivityManager am=ActivityManagerNative.getDefault();
  if (am != null) {
    try {
      final Intent intent=new Intent(action,pkg != null ? Uri.fromParts("String_Node_Str",pkg,null) : null);
      if (extras != null) {
        intent.putExtras(extras);
      }
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
      am.broadcastIntent(null,intent,null,finishedReceiver,0,null,null,null,finishedReceiver != null,false);
    }
 catch (    RemoteException ex) {
    }
  }
}
Program: 181919
Project: 181919
Buggy source:
private void sendPackageChangedBroadcast(String packageName,boolean killFlag,ArrayList<String> componentNames,int packageUid){
  if (false)   Log.v(TAG,"String_Node_Str" + packageName + "String_Node_Str"+ componentNames);
  Bundle extras=new Bundle(4);
  extras.putString(Intent.EXTRA_CHANGED_COMPONENT_NAME,componentNames.get(0));
  String nameList[]=new String[componentNames.size()];
  componentNames.toArray(nameList);
  extras.putStringArray(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST,nameList);
  extras.putBoolean(Intent.EXTRA_DONT_KILL_APP,killFlag);
  extras.putInt(Intent.EXTRA_UID,packageUid);
  sendPackageBroadcast(Intent.ACTION_PACKAGE_CHANGED,packageName,extras);
}

Fixed version (ground truth):
private void sendPackageChangedBroadcast(String packageName,boolean killFlag,ArrayList<String> componentNames,int packageUid){
  if (false)   Log.v(TAG,"String_Node_Str" + packageName + "String_Node_Str"+ componentNames);
  Bundle extras=new Bundle(4);
  extras.putString(Intent.EXTRA_CHANGED_COMPONENT_NAME,componentNames.get(0));
  String nameList[]=new String[componentNames.size()];
  componentNames.toArray(nameList);
  extras.putStringArray(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST,nameList);
  extras.putBoolean(Intent.EXTRA_DONT_KILL_APP,killFlag);
  extras.putInt(Intent.EXTRA_UID,packageUid);
  sendPackageBroadcast(Intent.ACTION_PACKAGE_CHANGED,packageName,extras,null);
}
Program: 181921
Project: 181921
Buggy source:
void sendBroadcast(boolean fullRemove,boolean replacing){
  Bundle extras=new Bundle(1);
  extras.putInt(Intent.EXTRA_UID,removedUid >= 0 ? removedUid : uid);
  extras.putBoolean(Intent.EXTRA_DATA_REMOVED,fullRemove);
  if (replacing) {
    extras.putBoolean(Intent.EXTRA_REPLACING,true);
  }
  if (removedPackage != null) {
    sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,removedPackage,extras);
  }
  if (removedUid >= 0) {
    sendPackageBroadcast(Intent.ACTION_UID_REMOVED,null,extras);
  }
}

Fixed version (ground truth):
void sendBroadcast(boolean fullRemove,boolean replacing){
  Bundle extras=new Bundle(1);
  extras.putInt(Intent.EXTRA_UID,removedUid >= 0 ? removedUid : uid);
  extras.putBoolean(Intent.EXTRA_DATA_REMOVED,fullRemove);
  if (replacing) {
    extras.putBoolean(Intent.EXTRA_REPLACING,true);
  }
  if (removedPackage != null) {
    sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,removedPackage,extras,null);
  }
  if (removedUid >= 0) {
    sendPackageBroadcast(Intent.ACTION_UID_REMOVED,null,extras,null);
  }
}
Program: 181923
Project: 181923
Buggy source:
private void sendResourcesChangedBroadcast(boolean mediaStatus,ArrayList<String> pkgList,int uidArr[]){
  int size=pkgList.size();
  if (size > 0) {
    Bundle extras=new Bundle();
    extras.putStringArray(Intent.EXTRA_CHANGED_PACKAGE_LIST,pkgList.toArray(new String[size]));
    if (uidArr != null) {
      extras.putIntArray(Intent.EXTRA_CHANGED_UID_LIST,uidArr);
    }
    String action=mediaStatus ? Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE : Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE;
    sendPackageBroadcast(action,null,extras);
  }
}

Fixed version (ground truth):
private void sendResourcesChangedBroadcast(boolean mediaStatus,ArrayList<String> pkgList,int uidArr[],IIntentReceiver finishedReceiver){
  int size=pkgList.size();
  if (size > 0) {
    Bundle extras=new Bundle();
    extras.putStringArray(Intent.EXTRA_CHANGED_PACKAGE_LIST,pkgList.toArray(new String[size]));
    if (uidArr != null) {
      extras.putIntArray(Intent.EXTRA_CHANGED_UID_LIST,uidArr);
    }
    String action=mediaStatus ? Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE : Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE;
    sendPackageBroadcast(action,null,extras,finishedReceiver);
  }
}
Program: 181927
Project: 181927
Buggy source:
private void unloadMediaPackages(HashMap<SdInstallArgs,String> processCids,int uidArr[]){
  if (DEBUG_SD_INSTALL)   Log.i(TAG,"String_Node_Str");
  ArrayList<String> pkgList=new ArrayList<String>();
  ArrayList<SdInstallArgs> failedList=new ArrayList<SdInstallArgs>();
  Set<SdInstallArgs> keys=processCids.keySet();
  for (  SdInstallArgs args : keys) {
    String cid=args.cid;
    String pkgName=args.getPackageName();
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str" + pkgName);
    PackageRemovedInfo outInfo=new PackageRemovedInfo();
synchronized (mInstallLock) {
      boolean res=deletePackageLI(pkgName,false,PackageManager.DONT_DELETE_DATA,outInfo);
      if (res) {
        pkgList.add(pkgName);
      }
 else {
        Slog.e(TAG,"String_Node_Str" + pkgName);
        failedList.add(args);
      }
    }
  }
  if (pkgList.size() > 0) {
    sendResourcesChangedBroadcast(false,pkgList,uidArr);
  }
  Runtime.getRuntime().gc();
  for (  SdInstallArgs args : keys) {
synchronized (mInstallLock) {
      args.doPostDeleteLI(false);
    }
  }
}

Fixed version (ground truth):
private void unloadMediaPackages(HashMap<SdInstallArgs,String> processCids,int uidArr[]){
  if (DEBUG_SD_INSTALL)   Log.i(TAG,"String_Node_Str");
  ArrayList<String> pkgList=new ArrayList<String>();
  ArrayList<SdInstallArgs> failedList=new ArrayList<SdInstallArgs>();
  Set<SdInstallArgs> keys=processCids.keySet();
  for (  SdInstallArgs args : keys) {
    String cid=args.cid;
    String pkgName=args.getPackageName();
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str" + pkgName);
    PackageRemovedInfo outInfo=new PackageRemovedInfo();
synchronized (mInstallLock) {
      boolean res=deletePackageLI(pkgName,false,PackageManager.DONT_DELETE_DATA,outInfo);
      if (res) {
        pkgList.add(pkgName);
      }
 else {
        Slog.e(TAG,"String_Node_Str" + pkgName);
        failedList.add(args);
      }
    }
  }
  if (pkgList.size() > 0) {
    sendResourcesChangedBroadcast(false,pkgList,uidArr,new IIntentReceiver.Stub(){
      public void performReceive(      Intent intent,      int resultCode,      String data,      Bundle extras,      boolean ordered,      boolean sticky) throws RemoteException {
        Runtime.getRuntime().gc();
      }
    }
);
  }
  for (  SdInstallArgs args : keys) {
synchronized (mInstallLock) {
      args.doPostDeleteLI(false);
    }
  }
}
Program: 181929
Project: 181929
Buggy source:
private static final void sendPackageBroadcast(String action,String pkg,Bundle extras){
  IActivityManager am=ActivityManagerNative.getDefault();
  if (am != null) {
    try {
      final Intent intent=new Intent(action,pkg != null ? Uri.fromParts("String_Node_Str",pkg,null) : null);
      if (extras != null) {
        intent.putExtras(extras);
      }
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
      am.broadcastIntent(null,intent,null,null,0,null,null,null,false,false);
    }
 catch (    RemoteException ex) {
    }
  }
}

Fixed version (ground truth):
private static final void sendPackageBroadcast(String action,String pkg,Bundle extras,IIntentReceiver finishedReceiver){
  IActivityManager am=ActivityManagerNative.getDefault();
  if (am != null) {
    try {
      final Intent intent=new Intent(action,pkg != null ? Uri.fromParts("String_Node_Str",pkg,null) : null);
      if (extras != null) {
        intent.putExtras(extras);
      }
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
      am.broadcastIntent(null,intent,null,finishedReceiver,0,null,null,null,finishedReceiver != null,false);
    }
 catch (    RemoteException ex) {
    }
  }
}
Program: 181930
Project: 181930
Buggy source:
private void sendPackageChangedBroadcast(String packageName,boolean killFlag,ArrayList<String> componentNames,int packageUid){
  if (false)   Log.v(TAG,"String_Node_Str" + packageName + "String_Node_Str"+ componentNames);
  Bundle extras=new Bundle(4);
  extras.putString(Intent.EXTRA_CHANGED_COMPONENT_NAME,componentNames.get(0));
  String nameList[]=new String[componentNames.size()];
  componentNames.toArray(nameList);
  extras.putStringArray(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST,nameList);
  extras.putBoolean(Intent.EXTRA_DONT_KILL_APP,killFlag);
  extras.putInt(Intent.EXTRA_UID,packageUid);
  sendPackageBroadcast(Intent.ACTION_PACKAGE_CHANGED,packageName,extras);
}

Fixed version (ground truth):
private void sendPackageChangedBroadcast(String packageName,boolean killFlag,ArrayList<String> componentNames,int packageUid){
  if (false)   Log.v(TAG,"String_Node_Str" + packageName + "String_Node_Str"+ componentNames);
  Bundle extras=new Bundle(4);
  extras.putString(Intent.EXTRA_CHANGED_COMPONENT_NAME,componentNames.get(0));
  String nameList[]=new String[componentNames.size()];
  componentNames.toArray(nameList);
  extras.putStringArray(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST,nameList);
  extras.putBoolean(Intent.EXTRA_DONT_KILL_APP,killFlag);
  extras.putInt(Intent.EXTRA_UID,packageUid);
  sendPackageBroadcast(Intent.ACTION_PACKAGE_CHANGED,packageName,extras,null);
}
Program: 181932
Project: 181932
Buggy source:
void sendBroadcast(boolean fullRemove,boolean replacing){
  Bundle extras=new Bundle(1);
  extras.putInt(Intent.EXTRA_UID,removedUid >= 0 ? removedUid : uid);
  extras.putBoolean(Intent.EXTRA_DATA_REMOVED,fullRemove);
  if (replacing) {
    extras.putBoolean(Intent.EXTRA_REPLACING,true);
  }
  if (removedPackage != null) {
    sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,removedPackage,extras);
  }
  if (removedUid >= 0) {
    sendPackageBroadcast(Intent.ACTION_UID_REMOVED,null,extras);
  }
}

Fixed version (ground truth):
void sendBroadcast(boolean fullRemove,boolean replacing){
  Bundle extras=new Bundle(1);
  extras.putInt(Intent.EXTRA_UID,removedUid >= 0 ? removedUid : uid);
  extras.putBoolean(Intent.EXTRA_DATA_REMOVED,fullRemove);
  if (replacing) {
    extras.putBoolean(Intent.EXTRA_REPLACING,true);
  }
  if (removedPackage != null) {
    sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,removedPackage,extras,null);
  }
  if (removedUid >= 0) {
    sendPackageBroadcast(Intent.ACTION_UID_REMOVED,null,extras,null);
  }
}
Program: 181934
Project: 181934
Buggy source:
private static final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,List list,String prefix,String[] args){
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  if (isCheckinRequest) {
    pw.println(uptime + "String_Node_Str" + realtime);
    pw.flush();
  }
 else {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + uptime + "String_Node_Str"+ realtime);
  }
  for (int i=list.size() - 1; i >= 0; i--) {
    ProcessRecord r=(ProcessRecord)list.get(i);
    if (r.thread != null) {
      if (!isCheckinRequest) {
        pw.println("String_Node_Str" + r.pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
        pw.flush();
      }
      try {
        r.thread.asBinder().dump(fd,args);
      }
 catch (      RemoteException e) {
        if (!isCheckinRequest) {
          pw.println("String_Node_Str");
          pw.flush();
        }
      }
    }
  }
}

Fixed version (ground truth):
static final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,List list,String prefix,String[] args){
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  if (isCheckinRequest) {
    pw.println(uptime + "String_Node_Str" + realtime);
    pw.flush();
  }
 else {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + uptime + "String_Node_Str"+ realtime);
  }
  for (int i=list.size() - 1; i >= 0; i--) {
    ProcessRecord r=(ProcessRecord)list.get(i);
    if (r.thread != null) {
      if (!isCheckinRequest) {
        pw.println("String_Node_Str" + r.pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
        pw.flush();
      }
      try {
        r.thread.asBinder().dump(fd,args);
      }
 catch (      RemoteException e) {
        if (!isCheckinRequest) {
          pw.println("String_Node_Str");
          pw.flush();
        }
      }
    }
  }
}
Program: 181935
Project: 181935
Buggy source:
private static final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,List list,String prefix,String[] args){
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  if (isCheckinRequest) {
    pw.println(uptime + "String_Node_Str" + realtime);
    pw.flush();
  }
 else {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + uptime + "String_Node_Str"+ realtime);
  }
  for (int i=list.size() - 1; i >= 0; i--) {
    ProcessRecord r=(ProcessRecord)list.get(i);
    if (r.thread != null) {
      if (!isCheckinRequest) {
        pw.println("String_Node_Str" + r.pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
        pw.flush();
      }
      try {
        r.thread.asBinder().dump(fd,args);
      }
 catch (      RemoteException e) {
        if (!isCheckinRequest) {
          pw.println("String_Node_Str");
          pw.flush();
        }
      }
    }
  }
}

Fixed version (ground truth):
static final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,List list,String prefix,String[] args){
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  if (isCheckinRequest) {
    pw.println(uptime + "String_Node_Str" + realtime);
    pw.flush();
  }
 else {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + uptime + "String_Node_Str"+ realtime);
  }
  for (int i=list.size() - 1; i >= 0; i--) {
    ProcessRecord r=(ProcessRecord)list.get(i);
    if (r.thread != null) {
      if (!isCheckinRequest) {
        pw.println("String_Node_Str" + r.pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
        pw.flush();
      }
      try {
        r.thread.asBinder().dump(fd,args);
      }
 catch (      RemoteException e) {
        if (!isCheckinRequest) {
          pw.println("String_Node_Str");
          pw.flush();
        }
      }
    }
  }
}
Program: 181936
Project: 181936
Buggy source:
private static final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,List list,String prefix,String[] args){
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  if (isCheckinRequest) {
    pw.println(uptime + "String_Node_Str" + realtime);
    pw.flush();
  }
 else {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + uptime + "String_Node_Str"+ realtime);
  }
  for (int i=list.size() - 1; i >= 0; i--) {
    ProcessRecord r=(ProcessRecord)list.get(i);
    if (r.thread != null) {
      if (!isCheckinRequest) {
        pw.println("String_Node_Str" + r.pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
        pw.flush();
      }
      try {
        r.thread.asBinder().dump(fd,args);
      }
 catch (      RemoteException e) {
        if (!isCheckinRequest) {
          pw.println("String_Node_Str");
          pw.flush();
        }
      }
    }
  }
}

Fixed version (ground truth):
static final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,List list,String prefix,String[] args){
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  if (isCheckinRequest) {
    pw.println(uptime + "String_Node_Str" + realtime);
    pw.flush();
  }
 else {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + uptime + "String_Node_Str"+ realtime);
  }
  for (int i=list.size() - 1; i >= 0; i--) {
    ProcessRecord r=(ProcessRecord)list.get(i);
    if (r.thread != null) {
      if (!isCheckinRequest) {
        pw.println("String_Node_Str" + r.pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
        pw.flush();
      }
      try {
        r.thread.asBinder().dump(fd,args);
      }
 catch (      RemoteException e) {
        if (!isCheckinRequest) {
          pw.println("String_Node_Str");
          pw.flush();
        }
      }
    }
  }
}
Program: 181937
Project: 181937
Buggy source:
private static final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,List list,String prefix,String[] args){
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  if (isCheckinRequest) {
    pw.println(uptime + "String_Node_Str" + realtime);
    pw.flush();
  }
 else {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + uptime + "String_Node_Str"+ realtime);
  }
  for (int i=list.size() - 1; i >= 0; i--) {
    ProcessRecord r=(ProcessRecord)list.get(i);
    if (r.thread != null) {
      if (!isCheckinRequest) {
        pw.println("String_Node_Str" + r.pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
        pw.flush();
      }
      try {
        r.thread.asBinder().dump(fd,args);
      }
 catch (      RemoteException e) {
        if (!isCheckinRequest) {
          pw.println("String_Node_Str");
          pw.flush();
        }
      }
    }
  }
}

Fixed version (ground truth):
static final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,List list,String prefix,String[] args){
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  if (isCheckinRequest) {
    pw.println(uptime + "String_Node_Str" + realtime);
    pw.flush();
  }
 else {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + uptime + "String_Node_Str"+ realtime);
  }
  for (int i=list.size() - 1; i >= 0; i--) {
    ProcessRecord r=(ProcessRecord)list.get(i);
    if (r.thread != null) {
      if (!isCheckinRequest) {
        pw.println("String_Node_Str" + r.pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
        pw.flush();
      }
      try {
        r.thread.asBinder().dump(fd,args);
      }
 catch (      RemoteException e) {
        if (!isCheckinRequest) {
          pw.println("String_Node_Str");
          pw.flush();
        }
      }
    }
  }
}
Program: 181938
Project: 181938
Buggy source:
private static final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,List list,String prefix,String[] args){
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  if (isCheckinRequest) {
    pw.println(uptime + "String_Node_Str" + realtime);
    pw.flush();
  }
 else {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + uptime + "String_Node_Str"+ realtime);
  }
  for (int i=list.size() - 1; i >= 0; i--) {
    ProcessRecord r=(ProcessRecord)list.get(i);
    if (r.thread != null) {
      if (!isCheckinRequest) {
        pw.println("String_Node_Str" + r.pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
        pw.flush();
      }
      try {
        r.thread.asBinder().dump(fd,args);
      }
 catch (      RemoteException e) {
        if (!isCheckinRequest) {
          pw.println("String_Node_Str");
          pw.flush();
        }
      }
    }
  }
}

Fixed version (ground truth):
static final void dumpApplicationMemoryUsage(FileDescriptor fd,PrintWriter pw,List list,String prefix,String[] args){
  final boolean isCheckinRequest=scanArgs(args,"String_Node_Str");
  long uptime=SystemClock.uptimeMillis();
  long realtime=SystemClock.elapsedRealtime();
  if (isCheckinRequest) {
    pw.println(uptime + "String_Node_Str" + realtime);
    pw.flush();
  }
 else {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + uptime + "String_Node_Str"+ realtime);
  }
  for (int i=list.size() - 1; i >= 0; i--) {
    ProcessRecord r=(ProcessRecord)list.get(i);
    if (r.thread != null) {
      if (!isCheckinRequest) {
        pw.println("String_Node_Str" + r.pid + "String_Node_Str"+ r.processName+ "String_Node_Str");
        pw.flush();
      }
      try {
        r.thread.asBinder().dump(fd,args);
      }
 catch (      RemoteException e) {
        if (!isCheckinRequest) {
          pw.println("String_Node_Str");
          pw.flush();
        }
      }
    }
  }
}
Program: 181939
Project: 181939
Buggy source:
@Override public void handleMessage(Message msg){
  if (msg.what == MSG_WRITE_STATUS) {
synchronized (mAccounts) {
      writeStatusLocked();
    }
  }
 else   if (msg.what == MSG_WRITE_STATISTICS) {
synchronized (mAccounts) {
      writeStatisticsLocked();
    }
  }
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (msg.what == MSG_WRITE_STATUS) {
synchronized (mAuthorities) {
      writeStatusLocked();
    }
  }
 else   if (msg.what == MSG_WRITE_STATISTICS) {
synchronized (mAuthorities) {
      writeStatisticsLocked();
    }
  }
}
Program: 181940
Project: 181940
Buggy source:
@Override public void handleMessage(Message msg){
  if (msg.what == MSG_WRITE_STATUS) {
synchronized (mAccounts) {
      writeStatusLocked();
    }
  }
 else   if (msg.what == MSG_WRITE_STATISTICS) {
synchronized (mAccounts) {
      writeStatisticsLocked();
    }
  }
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (msg.what == MSG_WRITE_STATUS) {
synchronized (mAuthorities) {
      writeStatusLocked();
    }
  }
 else   if (msg.what == MSG_WRITE_STATISTICS) {
synchronized (mAuthorities) {
      writeStatisticsLocked();
    }
  }
}
Program: 181941
Project: 181941
Buggy source:
@Override public void handleMessage(Message msg){
  if (msg.what == MSG_WRITE_STATUS) {
synchronized (mAccounts) {
      writeStatusLocked();
    }
  }
 else   if (msg.what == MSG_WRITE_STATISTICS) {
synchronized (mAccounts) {
      writeStatisticsLocked();
    }
  }
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (msg.what == MSG_WRITE_STATUS) {
synchronized (mAuthorities) {
      writeStatusLocked();
    }
  }
 else   if (msg.what == MSG_WRITE_STATISTICS) {
synchronized (mAuthorities) {
      writeStatisticsLocked();
    }
  }
}
Program: 181942
Project: 181942
Buggy source:
@Override public void handleMessage(Message msg){
  if (msg.what == MSG_WRITE_STATUS) {
synchronized (mAccounts) {
      writeStatusLocked();
    }
  }
 else   if (msg.what == MSG_WRITE_STATISTICS) {
synchronized (mAccounts) {
      writeStatisticsLocked();
    }
  }
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (msg.what == MSG_WRITE_STATUS) {
synchronized (mAuthorities) {
      writeStatusLocked();
    }
  }
 else   if (msg.what == MSG_WRITE_STATISTICS) {
synchronized (mAuthorities) {
      writeStatisticsLocked();
    }
  }
}
Program: 181943
Project: 181943
Buggy source:
@Override public void handleMessage(Message msg){
  if (msg.what == MSG_WRITE_STATUS) {
synchronized (mAccounts) {
      writeStatusLocked();
    }
  }
 else   if (msg.what == MSG_WRITE_STATISTICS) {
synchronized (mAccounts) {
      writeStatisticsLocked();
    }
  }
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (msg.what == MSG_WRITE_STATUS) {
synchronized (mAuthorities) {
      writeStatusLocked();
    }
  }
 else   if (msg.what == MSG_WRITE_STATISTICS) {
synchronized (mAuthorities) {
      writeStatisticsLocked();
    }
  }
}
Program: 181974
Project: 181974
Buggy source:
public int getOrientationFromWindowsLocked(){
  int pos=mWindows.size() - 1;
  while (pos >= 0) {
    WindowState wtoken=(WindowState)mWindows.get(pos);
    pos--;
    if (wtoken.mAppToken != null) {
      return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    }
    if (!wtoken.isVisibleLw()) {
      continue;
    }
    int req=wtoken.mAttrs.screenOrientation;
    if ((req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) || (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)) {
      continue;
    }
 else {
      return req;
    }
  }
  return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}

Fixed version (ground truth):
public int getOrientationFromWindowsLocked(){
  int pos=mWindows.size() - 1;
  while (pos >= 0) {
    WindowState wtoken=(WindowState)mWindows.get(pos);
    pos--;
    if (wtoken.mAppToken != null) {
      return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    }
    if (!wtoken.isVisibleLw() || !wtoken.mPolicyVisibilityAfterAnim) {
      continue;
    }
    int req=wtoken.mAttrs.screenOrientation;
    if ((req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) || (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)) {
      continue;
    }
 else {
      return req;
    }
  }
  return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}
Program: 181975
Project: 181975
Buggy source:
private void stopFreezingDisplayLocked(){
  if (!mDisplayFrozen) {
    return;
  }
  if (mWaitingForConfig || mAppsFreezingScreen > 0 || mWindowsFreezingScreen) {
    return;
  }
  mDisplayFrozen=false;
  mH.removeMessages(H.APP_FREEZE_TIMEOUT);
  if (PROFILE_ORIENTATION) {
    Debug.stopMethodTracing();
  }
  Surface.unfreezeDisplay(0);
synchronized (mKeyWaiter) {
    mKeyWaiter.mWasFrozen=true;
    mKeyWaiter.notifyAll();
  }
  mH.removeMessages(H.FORCE_GC);
  mH.sendMessageDelayed(mH.obtainMessage(H.FORCE_GC),2000);
  mScreenFrozenLock.release();
}

Fixed version (ground truth):
private void stopFreezingDisplayLocked(){
  if (!mDisplayFrozen) {
    return;
  }
  if (mWaitingForConfig || mAppsFreezingScreen > 0 || mWindowsFreezingScreen) {
    return;
  }
  mDisplayFrozen=false;
  mH.removeMessages(H.APP_FREEZE_TIMEOUT);
  if (PROFILE_ORIENTATION) {
    Debug.stopMethodTracing();
  }
  Surface.unfreezeDisplay(0);
synchronized (mKeyWaiter) {
    mKeyWaiter.mWasFrozen=true;
    mKeyWaiter.notifyAll();
  }
  if (updateOrientationFromAppTokensLocked()) {
    mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
  }
  mH.removeMessages(H.FORCE_GC);
  mH.sendMessageDelayed(mH.obtainMessage(H.FORCE_GC),2000);
  mScreenFrozenLock.release();
}
Program: 181977
Project: 181977
Buggy source:
boolean updateOrientationFromAppTokensLocked(){
  boolean changed=false;
  long ident=Binder.clearCallingIdentity();
  try {
    int req=computeForcedAppOrientationLocked();
    if (req != mForcedAppOrientation) {
      mForcedAppOrientation=req;
      mPolicy.setCurrentOrientationLw(req);
      if (setRotationUncheckedLocked(WindowManagerPolicy.USE_LAST_ROTATION,mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE)) {
        changed=true;
      }
    }
    return changed;
  }
  finally {
    Binder.restoreCallingIdentity(ident);
  }
}

Fixed version (ground truth):
boolean updateOrientationFromAppTokensLocked(){
  if (mDisplayFrozen) {
    return false;
  }
  boolean changed=false;
  long ident=Binder.clearCallingIdentity();
  try {
    int req=computeForcedAppOrientationLocked();
    if (req != mForcedAppOrientation) {
      mForcedAppOrientation=req;
      mPolicy.setCurrentOrientationLw(req);
      if (setRotationUncheckedLocked(WindowManagerPolicy.USE_LAST_ROTATION,mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE)) {
        changed=true;
      }
    }
    return changed;
  }
  finally {
    Binder.restoreCallingIdentity(ident);
  }
}
Program: 181979
Project: 181979
Buggy source:
public int getOrientationFromWindowsLocked(){
  int pos=mWindows.size() - 1;
  while (pos >= 0) {
    WindowState wtoken=(WindowState)mWindows.get(pos);
    pos--;
    if (wtoken.mAppToken != null) {
      return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    }
    if (!wtoken.isVisibleLw()) {
      continue;
    }
    int req=wtoken.mAttrs.screenOrientation;
    if ((req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) || (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)) {
      continue;
    }
 else {
      return req;
    }
  }
  return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}

Fixed version (ground truth):
public int getOrientationFromWindowsLocked(){
  int pos=mWindows.size() - 1;
  while (pos >= 0) {
    WindowState wtoken=(WindowState)mWindows.get(pos);
    pos--;
    if (wtoken.mAppToken != null) {
      return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    }
    if (!wtoken.isVisibleLw() || !wtoken.mPolicyVisibilityAfterAnim) {
      continue;
    }
    int req=wtoken.mAttrs.screenOrientation;
    if ((req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) || (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)) {
      continue;
    }
 else {
      return req;
    }
  }
  return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}
Program: 181980
Project: 181980
Buggy source:
private void stopFreezingDisplayLocked(){
  if (!mDisplayFrozen) {
    return;
  }
  if (mWaitingForConfig || mAppsFreezingScreen > 0 || mWindowsFreezingScreen) {
    return;
  }
  mDisplayFrozen=false;
  mH.removeMessages(H.APP_FREEZE_TIMEOUT);
  if (PROFILE_ORIENTATION) {
    Debug.stopMethodTracing();
  }
  Surface.unfreezeDisplay(0);
synchronized (mKeyWaiter) {
    mKeyWaiter.mWasFrozen=true;
    mKeyWaiter.notifyAll();
  }
  mH.removeMessages(H.FORCE_GC);
  mH.sendMessageDelayed(mH.obtainMessage(H.FORCE_GC),2000);
  mScreenFrozenLock.release();
}

Fixed version (ground truth):
private void stopFreezingDisplayLocked(){
  if (!mDisplayFrozen) {
    return;
  }
  if (mWaitingForConfig || mAppsFreezingScreen > 0 || mWindowsFreezingScreen) {
    return;
  }
  mDisplayFrozen=false;
  mH.removeMessages(H.APP_FREEZE_TIMEOUT);
  if (PROFILE_ORIENTATION) {
    Debug.stopMethodTracing();
  }
  Surface.unfreezeDisplay(0);
synchronized (mKeyWaiter) {
    mKeyWaiter.mWasFrozen=true;
    mKeyWaiter.notifyAll();
  }
  if (updateOrientationFromAppTokensLocked()) {
    mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
  }
  mH.removeMessages(H.FORCE_GC);
  mH.sendMessageDelayed(mH.obtainMessage(H.FORCE_GC),2000);
  mScreenFrozenLock.release();
}
Program: 181982
Project: 181982
Buggy source:
boolean updateOrientationFromAppTokensLocked(){
  boolean changed=false;
  long ident=Binder.clearCallingIdentity();
  try {
    int req=computeForcedAppOrientationLocked();
    if (req != mForcedAppOrientation) {
      mForcedAppOrientation=req;
      mPolicy.setCurrentOrientationLw(req);
      if (setRotationUncheckedLocked(WindowManagerPolicy.USE_LAST_ROTATION,mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE)) {
        changed=true;
      }
    }
    return changed;
  }
  finally {
    Binder.restoreCallingIdentity(ident);
  }
}

Fixed version (ground truth):
boolean updateOrientationFromAppTokensLocked(){
  if (mDisplayFrozen) {
    return false;
  }
  boolean changed=false;
  long ident=Binder.clearCallingIdentity();
  try {
    int req=computeForcedAppOrientationLocked();
    if (req != mForcedAppOrientation) {
      mForcedAppOrientation=req;
      mPolicy.setCurrentOrientationLw(req);
      if (setRotationUncheckedLocked(WindowManagerPolicy.USE_LAST_ROTATION,mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE)) {
        changed=true;
      }
    }
    return changed;
  }
  finally {
    Binder.restoreCallingIdentity(ident);
  }
}
Program: 181984
Project: 181984
Buggy source:
public int getOrientationFromWindowsLocked(){
  int pos=mWindows.size() - 1;
  while (pos >= 0) {
    WindowState wtoken=(WindowState)mWindows.get(pos);
    pos--;
    if (wtoken.mAppToken != null) {
      return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    }
    if (!wtoken.isVisibleLw()) {
      continue;
    }
    int req=wtoken.mAttrs.screenOrientation;
    if ((req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) || (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)) {
      continue;
    }
 else {
      return req;
    }
  }
  return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}

Fixed version (ground truth):
public int getOrientationFromWindowsLocked(){
  int pos=mWindows.size() - 1;
  while (pos >= 0) {
    WindowState wtoken=(WindowState)mWindows.get(pos);
    pos--;
    if (wtoken.mAppToken != null) {
      return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    }
    if (!wtoken.isVisibleLw() || !wtoken.mPolicyVisibilityAfterAnim) {
      continue;
    }
    int req=wtoken.mAttrs.screenOrientation;
    if ((req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) || (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)) {
      continue;
    }
 else {
      return req;
    }
  }
  return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}
Program: 181985
Project: 181985
Buggy source:
private void stopFreezingDisplayLocked(){
  if (!mDisplayFrozen) {
    return;
  }
  if (mWaitingForConfig || mAppsFreezingScreen > 0 || mWindowsFreezingScreen) {
    return;
  }
  mDisplayFrozen=false;
  mH.removeMessages(H.APP_FREEZE_TIMEOUT);
  if (PROFILE_ORIENTATION) {
    Debug.stopMethodTracing();
  }
  Surface.unfreezeDisplay(0);
synchronized (mKeyWaiter) {
    mKeyWaiter.mWasFrozen=true;
    mKeyWaiter.notifyAll();
  }
  mH.removeMessages(H.FORCE_GC);
  mH.sendMessageDelayed(mH.obtainMessage(H.FORCE_GC),2000);
  mScreenFrozenLock.release();
}

Fixed version (ground truth):
private void stopFreezingDisplayLocked(){
  if (!mDisplayFrozen) {
    return;
  }
  if (mWaitingForConfig || mAppsFreezingScreen > 0 || mWindowsFreezingScreen) {
    return;
  }
  mDisplayFrozen=false;
  mH.removeMessages(H.APP_FREEZE_TIMEOUT);
  if (PROFILE_ORIENTATION) {
    Debug.stopMethodTracing();
  }
  Surface.unfreezeDisplay(0);
synchronized (mKeyWaiter) {
    mKeyWaiter.mWasFrozen=true;
    mKeyWaiter.notifyAll();
  }
  if (updateOrientationFromAppTokensLocked()) {
    mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
  }
  mH.removeMessages(H.FORCE_GC);
  mH.sendMessageDelayed(mH.obtainMessage(H.FORCE_GC),2000);
  mScreenFrozenLock.release();
}
Program: 181987
Project: 181987
Buggy source:
boolean updateOrientationFromAppTokensLocked(){
  boolean changed=false;
  long ident=Binder.clearCallingIdentity();
  try {
    int req=computeForcedAppOrientationLocked();
    if (req != mForcedAppOrientation) {
      mForcedAppOrientation=req;
      mPolicy.setCurrentOrientationLw(req);
      if (setRotationUncheckedLocked(WindowManagerPolicy.USE_LAST_ROTATION,mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE)) {
        changed=true;
      }
    }
    return changed;
  }
  finally {
    Binder.restoreCallingIdentity(ident);
  }
}

Fixed version (ground truth):
boolean updateOrientationFromAppTokensLocked(){
  if (mDisplayFrozen) {
    return false;
  }
  boolean changed=false;
  long ident=Binder.clearCallingIdentity();
  try {
    int req=computeForcedAppOrientationLocked();
    if (req != mForcedAppOrientation) {
      mForcedAppOrientation=req;
      mPolicy.setCurrentOrientationLw(req);
      if (setRotationUncheckedLocked(WindowManagerPolicy.USE_LAST_ROTATION,mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE)) {
        changed=true;
      }
    }
    return changed;
  }
  finally {
    Binder.restoreCallingIdentity(ident);
  }
}
Program: 181988
Project: 181988
Buggy source:
public boolean onKey(DialogInterface dialog,int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_BACK) {
    if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
      Window win=mDialog.getWindow();
      if (win != null) {
        View decor=win.getDecorView();
        if (decor != null) {
          KeyEvent.DispatcherState ds=decor.getKeyDispatcherState();
          if (ds != null) {
            ds.startTracking(event,this);
            return true;
          }
        }
      }
    }
 else     if (event.getAction() == KeyEvent.ACTION_UP && event.isTracking() && !event.isCanceled()) {
      mMenu.close(true);
      dialog.dismiss();
      return true;
    }
  }
  return mMenu.performShortcut(keyCode,event,0);
}

Fixed version (ground truth):
public boolean onKey(DialogInterface dialog,int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_BACK) {
    if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
      Window win=mDialog.getWindow();
      if (win != null) {
        View decor=win.getDecorView();
        if (decor != null) {
          KeyEvent.DispatcherState ds=decor.getKeyDispatcherState();
          if (ds != null) {
            ds.startTracking(event,this);
            return true;
          }
        }
      }
    }
 else     if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {
      Window win=mDialog.getWindow();
      if (win != null) {
        View decor=win.getDecorView();
        if (decor != null) {
          KeyEvent.DispatcherState ds=decor.getKeyDispatcherState();
          if (ds != null && ds.isTracking(event)) {
            mMenu.close(true);
            dialog.dismiss();
            return true;
          }
        }
      }
    }
  }
  return mMenu.performShortcut(keyCode,event,0);
}
Program: 181989
Project: 181989
Buggy source:
public boolean onKey(DialogInterface dialog,int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_BACK) {
    if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
      Window win=mDialog.getWindow();
      if (win != null) {
        View decor=win.getDecorView();
        if (decor != null) {
          KeyEvent.DispatcherState ds=decor.getKeyDispatcherState();
          if (ds != null) {
            ds.startTracking(event,this);
            return true;
          }
        }
      }
    }
 else     if (event.getAction() == KeyEvent.ACTION_UP && event.isTracking() && !event.isCanceled()) {
      mMenu.close(true);
      dialog.dismiss();
      return true;
    }
  }
  return mMenu.performShortcut(keyCode,event,0);
}

Fixed version (ground truth):
public boolean onKey(DialogInterface dialog,int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_BACK) {
    if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
      Window win=mDialog.getWindow();
      if (win != null) {
        View decor=win.getDecorView();
        if (decor != null) {
          KeyEvent.DispatcherState ds=decor.getKeyDispatcherState();
          if (ds != null) {
            ds.startTracking(event,this);
            return true;
          }
        }
      }
    }
 else     if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {
      Window win=mDialog.getWindow();
      if (win != null) {
        View decor=win.getDecorView();
        if (decor != null) {
          KeyEvent.DispatcherState ds=decor.getKeyDispatcherState();
          if (ds != null && ds.isTracking(event)) {
            mMenu.close(true);
            dialog.dismiss();
            return true;
          }
        }
      }
    }
  }
  return mMenu.performShortcut(keyCode,event,0);
}
Program: 181990
Project: 181990
Buggy source:
public boolean onKey(DialogInterface dialog,int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_BACK) {
    if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
      Window win=mDialog.getWindow();
      if (win != null) {
        View decor=win.getDecorView();
        if (decor != null) {
          KeyEvent.DispatcherState ds=decor.getKeyDispatcherState();
          if (ds != null) {
            ds.startTracking(event,this);
            return true;
          }
        }
      }
    }
 else     if (event.getAction() == KeyEvent.ACTION_UP && event.isTracking() && !event.isCanceled()) {
      mMenu.close(true);
      dialog.dismiss();
      return true;
    }
  }
  return mMenu.performShortcut(keyCode,event,0);
}

Fixed version (ground truth):
public boolean onKey(DialogInterface dialog,int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_BACK) {
    if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
      Window win=mDialog.getWindow();
      if (win != null) {
        View decor=win.getDecorView();
        if (decor != null) {
          KeyEvent.DispatcherState ds=decor.getKeyDispatcherState();
          if (ds != null) {
            ds.startTracking(event,this);
            return true;
          }
        }
      }
    }
 else     if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {
      Window win=mDialog.getWindow();
      if (win != null) {
        View decor=win.getDecorView();
        if (decor != null) {
          KeyEvent.DispatcherState ds=decor.getKeyDispatcherState();
          if (ds != null && ds.isTracking(event)) {
            mMenu.close(true);
            dialog.dismiss();
            return true;
          }
        }
      }
    }
  }
  return mMenu.performShortcut(keyCode,event,0);
}
Program: 181996
Project: 181996
Buggy source:
/** 
 * Request audio focus. Send a request to obtain the audio focus for a specific stream type
 * @param l the listener to be notified of audio focus changes
 * @param streamType the main audio stream type affected by the focus request
 * @param durationHint use {@link #AUDIOFOCUS_GAIN_TRANSIENT} to indicate this focus requestis temporary, and focus will be abandonned shortly. Examples of transient requests are for the playback of driving directions, or notifications sounds. Use  {@link #AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK} to indicate also that it's ok forthe previous focus owner to keep playing if it ducks its audio output. Use  {@link #AUDIOFOCUS_GAIN} for a focus request of unknown duration suchas the playback of a song or a video.
 * @return {@link #AUDIOFOCUS_REQUEST_FAILED} or {@link #AUDIOFOCUS_REQUEST_GRANTED}
 */
public int requestAudioFocus(OnAudioFocusChangeListener l,int streamType,int durationHint){
  int status=AUDIOFOCUS_REQUEST_FAILED;
  registerAudioFocusListener(l);
  IAudioService service=getService();
  try {
    status=service.requestAudioFocus(streamType,durationHint,mICallBack,mAudioFocusDispatcher,getIdForAudioFocusListener(l));
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str" + e);
  }
  return status;
}

Fixed version (ground truth):
/** 
 * Request audio focus. Send a request to obtain the audio focus for a specific stream type
 * @param l the listener to be notified of audio focus changes
 * @param streamType the main audio stream type affected by the focus request
 * @param durationHint use {@link #AUDIOFOCUS_GAIN_TRANSIENT} to indicate this focus requestis temporary, and focus will be abandonned shortly. Examples of transient requests are for the playback of driving directions, or notifications sounds. Use  {@link #AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK} to indicate also that it's ok forthe previous focus owner to keep playing if it ducks its audio output. Use  {@link #AUDIOFOCUS_GAIN} for a focus request of unknown duration suchas the playback of a song or a video.
 * @return {@link #AUDIOFOCUS_REQUEST_FAILED} or {@link #AUDIOFOCUS_REQUEST_GRANTED}
 */
public int requestAudioFocus(OnAudioFocusChangeListener l,int streamType,int durationHint){
  int status=AUDIOFOCUS_REQUEST_FAILED;
  if ((durationHint < AUDIOFOCUS_GAIN) || (durationHint > AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK)) {
    Log.e(TAG,"String_Node_Str");
    return status;
  }
  registerAudioFocusListener(l);
  IAudioService service=getService();
  try {
    status=service.requestAudioFocus(streamType,durationHint,mICallBack,mAudioFocusDispatcher,getIdForAudioFocusListener(l));
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str" + e);
  }
  return status;
}