nus-yam/ex-repair huggingface dataset:
Program: 41867
Project: 41867
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: 41869
Project: 41869
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: 41870
Project: 41870
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: 41872
Project: 41872
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: 41874
Project: 41874
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: 41878
Project: 41878
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: 41880
Project: 41880
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: 41881
Project: 41881
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: 41883
Project: 41883
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: 41885
Project: 41885
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: 41886
Project: 41886
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: 41887
Project: 41887
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: 41888
Project: 41888
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: 41889
Project: 41889
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: 41890
Project: 41890
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: 41893
Project: 41893
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: 41894
Project: 41894
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: 41896
Project: 41896
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: 41897
Project: 41897
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: 41926
Project: 41926
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: 41927
Project: 41927
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: 41929
Project: 41929
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: 41934
Project: 41934
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: 41935
Project: 41935
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: 41937
Project: 41937
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: 41939
Project: 41939
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: 41940
Project: 41940
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: 41942
Project: 41942
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: 41944
Project: 41944
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: 41945
Project: 41945
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: 41946
Project: 41946
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: 41947
Project: 41947
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;
}