nus-yam/ex-repair huggingface dataset:
Program: 181787
Project: 181787
Buggy source:
void killAppAtUsersRequest(ProcessRecord app,Dialog fromDialog){
synchronized (this) {
    app.crashing=false;
    app.crashingReport=null;
    app.notResponding=false;
    app.notRespondingReport=null;
    if (app.anrDialog == fromDialog) {
      app.anrDialog=null;
    }
    if (app.waitDialog == fromDialog) {
      app.waitDialog=null;
    }
    if (app.pid > 0 && app.pid != MY_PID) {
      handleAppCrashLocked(app);
      Slog.i(ActivityManagerService.TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ app.pid+ "String_Node_Str");
      Process.killProcess(app.pid);
    }
  }
}

Fixed version (ground truth):
void killAppAtUsersRequest(ProcessRecord app,Dialog fromDialog){
synchronized (this) {
    app.crashing=false;
    app.crashingReport=null;
    app.notResponding=false;
    app.notRespondingReport=null;
    if (app.anrDialog == fromDialog) {
      app.anrDialog=null;
    }
    if (app.waitDialog == fromDialog) {
      app.waitDialog=null;
    }
    if (app.pid > 0 && app.pid != MY_PID) {
      handleAppCrashLocked(app);
      Slog.i(ActivityManagerService.TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ app.pid+ "String_Node_Str");
      EventLog.writeEvent(EventLogTags.AM_KILL,app.pid,app.processName,app.setAdj,"String_Node_Str");
      Process.killProcess(app.pid);
    }
  }
}
Program: 181788
Project: 181788
Buggy source:
private final boolean updateOomAdjLocked(){
  boolean didOomAdj=true;
  final HistoryRecord TOP_ACT=resumedAppLocked();
  final ProcessRecord TOP_APP=TOP_ACT != null ? TOP_ACT.app : null;
  if (false) {
    RuntimeException e=new RuntimeException();
    e.fillInStackTrace();
    Slog.i(TAG,"String_Node_Str" + TOP_ACT,e);
  }
  mAdjSeq++;
  int numSlots=HIDDEN_APP_MAX_ADJ - HIDDEN_APP_MIN_ADJ + 1;
  int factor=(mLruProcesses.size() - 4) / numSlots;
  if (factor < 1)   factor=1;
  int step=0;
  int i=mLruProcesses.size();
  int curHiddenAdj=HIDDEN_APP_MIN_ADJ;
  while (i > 0) {
    i--;
    ProcessRecord app=mLruProcesses.get(i);
    if (updateOomAdjLocked(app,curHiddenAdj,TOP_APP)) {
      if (curHiddenAdj < EMPTY_APP_ADJ && app.curAdj == curHiddenAdj) {
        step++;
        if (step >= factor) {
          step=0;
          curHiddenAdj++;
        }
      }
    }
 else {
      didOomAdj=false;
    }
  }
  return ENFORCE_PROCESS_LIMIT || mProcessLimit > 0 ? false : didOomAdj;
}

Fixed version (ground truth):
private final boolean updateOomAdjLocked(){
  boolean didOomAdj=true;
  final HistoryRecord TOP_ACT=resumedAppLocked();
  final ProcessRecord TOP_APP=TOP_ACT != null ? TOP_ACT.app : null;
  if (false) {
    RuntimeException e=new RuntimeException();
    e.fillInStackTrace();
    Slog.i(TAG,"String_Node_Str" + TOP_ACT,e);
  }
  mAdjSeq++;
  int numSlots=HIDDEN_APP_MAX_ADJ - HIDDEN_APP_MIN_ADJ + 1;
  int factor=(mLruProcesses.size() - 4) / numSlots;
  if (factor < 1)   factor=1;
  int step=0;
  int numHidden=0;
  int i=mLruProcesses.size();
  int curHiddenAdj=HIDDEN_APP_MIN_ADJ;
  while (i > 0) {
    i--;
    ProcessRecord app=mLruProcesses.get(i);
    if (updateOomAdjLocked(app,curHiddenAdj,TOP_APP)) {
      if (curHiddenAdj < EMPTY_APP_ADJ && app.curAdj == curHiddenAdj) {
        step++;
        if (step >= factor) {
          step=0;
          curHiddenAdj++;
        }
      }
      if (app.curAdj >= HIDDEN_APP_MIN_ADJ) {
        numHidden++;
        if (numHidden > MAX_HIDDEN_APPS) {
          Slog.i(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ app.pid+ "String_Node_Str"+ numHidden+ "String_Node_Str"+ MAX_HIDDEN_APPS);
          EventLog.writeEvent(EventLogTags.AM_KILL,app.pid,app.processName,app.setAdj,"String_Node_Str");
          Process.killProcess(app.pid);
        }
      }
    }
 else {
      didOomAdj=false;
    }
  }
  return ENFORCE_PROCESS_LIMIT || mProcessLimit > 0 ? false : didOomAdj;
}
Program: 181789
Project: 181789
Buggy source:
public boolean killPids(int[] pids,String pReason){
  if (Binder.getCallingUid() != Process.SYSTEM_UID) {
    throw new SecurityException("String_Node_Str");
  }
  String reason=(pReason == null) ? "String_Node_Str" : pReason;
  boolean killed=false;
synchronized (mPidsSelfLocked) {
    int[] types=new int[pids.length];
    int worstType=0;
    for (int i=0; i < pids.length; i++) {
      ProcessRecord proc=mPidsSelfLocked.get(pids[i]);
      if (proc != null) {
        int type=proc.setAdj;
        types[i]=type;
        if (type > worstType) {
          worstType=type;
        }
      }
    }
    if (worstType < EMPTY_APP_ADJ && worstType > HIDDEN_APP_MIN_ADJ) {
      worstType=HIDDEN_APP_MIN_ADJ;
    }
    Slog.w(TAG,"String_Node_Str" + reason + "String_Node_Str"+ worstType);
    for (int i=0; i < pids.length; i++) {
      ProcessRecord proc=mPidsSelfLocked.get(pids[i]);
      if (proc == null) {
        continue;
      }
      int adj=proc.setAdj;
      if (adj >= worstType) {
        Slog.w(TAG,"String_Node_Str" + reason + "String_Node_Str"+ proc+ "String_Node_Str"+ adj+ "String_Node_Str");
        EventLog.writeEvent(EventLogTags.AM_KILL,proc.pid,proc.processName,adj,reason);
        killed=true;
        Process.killProcess(pids[i]);
      }
    }
  }
  return killed;
}

Fixed version (ground truth):
public boolean killPids(int[] pids,String pReason){
  if (Binder.getCallingUid() != Process.SYSTEM_UID) {
    throw new SecurityException("String_Node_Str");
  }
  String reason=(pReason == null) ? "String_Node_Str" : pReason;
  boolean killed=false;
synchronized (mPidsSelfLocked) {
    int[] types=new int[pids.length];
    int worstType=0;
    for (int i=0; i < pids.length; i++) {
      ProcessRecord proc=mPidsSelfLocked.get(pids[i]);
      if (proc != null) {
        int type=proc.setAdj;
        types[i]=type;
        if (type > worstType) {
          worstType=type;
        }
      }
    }
    if (worstType < EMPTY_APP_ADJ && worstType > HIDDEN_APP_MIN_ADJ) {
      worstType=HIDDEN_APP_MIN_ADJ;
    }
    Slog.w(TAG,"String_Node_Str" + reason + "String_Node_Str"+ worstType);
    for (int i=0; i < pids.length; i++) {
      ProcessRecord proc=mPidsSelfLocked.get(pids[i]);
      if (proc == null) {
        continue;
      }
      int adj=proc.setAdj;
      if (adj >= worstType) {
        Slog.w(TAG,"String_Node_Str" + proc + "String_Node_Str"+ adj+ "String_Node_Str"+ reason);
        EventLog.writeEvent(EventLogTags.AM_KILL,proc.pid,proc.processName,adj,reason);
        killed=true;
        Process.killProcess(pids[i]);
      }
    }
  }
  return killed;
}
Program: 181790
Project: 181790
Buggy source:
private final void removeDyingProviderLocked(ProcessRecord proc,ContentProviderRecord cpr){
synchronized (cpr) {
    cpr.launchingApp=null;
    cpr.notifyAll();
  }
  mProvidersByClass.remove(cpr.info.name);
  String names[]=cpr.info.authority.split("String_Node_Str");
  for (int j=0; j < names.length; j++) {
    mProvidersByName.remove(names[j]);
  }
  Iterator<ProcessRecord> cit=cpr.clients.iterator();
  while (cit.hasNext()) {
    ProcessRecord capp=cit.next();
    if (!capp.persistent && capp.thread != null && capp.pid != 0 && capp.pid != MY_PID) {
      Slog.i(TAG,"String_Node_Str" + capp.processName + "String_Node_Str"+ capp.pid+ "String_Node_Str"+ cpr.info.name+ "String_Node_Str"+ proc.processName);
      Process.killProcess(capp.pid);
    }
  }
  mLaunchingProviders.remove(cpr);
}

Fixed version (ground truth):
private final void removeDyingProviderLocked(ProcessRecord proc,ContentProviderRecord cpr){
synchronized (cpr) {
    cpr.launchingApp=null;
    cpr.notifyAll();
  }
  mProvidersByClass.remove(cpr.info.name);
  String names[]=cpr.info.authority.split("String_Node_Str");
  for (int j=0; j < names.length; j++) {
    mProvidersByName.remove(names[j]);
  }
  Iterator<ProcessRecord> cit=cpr.clients.iterator();
  while (cit.hasNext()) {
    ProcessRecord capp=cit.next();
    if (!capp.persistent && capp.thread != null && capp.pid != 0 && capp.pid != MY_PID) {
      Slog.i(TAG,"String_Node_Str" + capp.processName + "String_Node_Str"+ capp.pid+ "String_Node_Str"+ cpr.info.name+ "String_Node_Str"+ proc.processName);
      EventLog.writeEvent(EventLogTags.AM_KILL,capp.pid,capp.processName,capp.setAdj,"String_Node_Str" + proc.processName);
      Process.killProcess(capp.pid);
    }
  }
  mLaunchingProviders.remove(cpr);
}
Program: 181791
Project: 181791
Buggy source:
public void setServiceForeground(ComponentName className,IBinder token,int id,Notification notification,boolean removeNotification){
  final long origId=Binder.clearCallingIdentity();
  try {
synchronized (this) {
      ServiceRecord r=findServiceLocked(className,token);
      if (r != null) {
        if (id != 0) {
          if (notification == null) {
            throw new IllegalArgumentException("String_Node_Str");
          }
          if (r.foregroundId != id) {
            r.cancelNotification();
            r.foregroundId=id;
          }
          notification.flags|=Notification.FLAG_FOREGROUND_SERVICE;
          r.foregroundNoti=notification;
          r.isForeground=true;
          r.postNotification();
          if (r.app != null) {
            updateServiceForegroundLocked(r.app,true);
          }
        }
 else {
          if (r.isForeground) {
            r.isForeground=false;
            if (r.app != null) {
              updateServiceForegroundLocked(r.app,true);
            }
          }
          if (removeNotification) {
            r.cancelNotification();
            r.foregroundId=0;
            r.foregroundNoti=null;
          }
        }
      }
    }
  }
  finally {
    Binder.restoreCallingIdentity(origId);
  }
}

Fixed version (ground truth):
public void setServiceForeground(ComponentName className,IBinder token,int id,Notification notification,boolean removeNotification){
  final long origId=Binder.clearCallingIdentity();
  try {
synchronized (this) {
      ServiceRecord r=findServiceLocked(className,token);
      if (r != null) {
        if (id != 0) {
          if (notification == null) {
            throw new IllegalArgumentException("String_Node_Str");
          }
          if (r.foregroundId != id) {
            r.cancelNotification();
            r.foregroundId=id;
          }
          notification.flags|=Notification.FLAG_FOREGROUND_SERVICE;
          r.foregroundNoti=notification;
          r.isForeground=true;
          r.postNotification();
          if (r.app != null) {
            updateServiceForegroundLocked(r.app,true);
          }
        }
 else {
          if (r.isForeground) {
            r.isForeground=false;
            if (r.app != null) {
              updateLruProcessLocked(r.app,false,true);
              updateServiceForegroundLocked(r.app,true);
            }
          }
          if (removeNotification) {
            r.cancelNotification();
            r.foregroundId=0;
            r.foregroundNoti=null;
          }
        }
      }
    }
  }
  finally {
    Binder.restoreCallingIdentity(origId);
  }
}
Program: 181793
Project: 181793
Buggy source:
public void cancel(IRecognitionListener listener){
  if (DBG)   Log.d(TAG,"String_Node_Str" + listener.asBinder());
  if (checkPermissions(listener)) {
    mHandler.sendMessage(Message.obtain(mHandler,MSG_CANCEL,listener));
  }
}

Fixed version (ground truth):
public void cancel(IRecognitionListener listener){
  if (DBG)   Log.d(TAG,"String_Node_Str" + listener.asBinder());
  if (mInternalService != null && mInternalService.checkPermissions(listener)) {
    mInternalService.mHandler.sendMessage(Message.obtain(mInternalService.mHandler,MSG_CANCEL,listener));
  }
}
Program: 181794
Project: 181794
Buggy source:
public void startListening(Intent recognizerIntent,IRecognitionListener listener){
  if (DBG)   Log.d(TAG,"String_Node_Str" + listener.asBinder());
  if (checkPermissions(listener)) {
    mHandler.sendMessage(Message.obtain(mHandler,MSG_START_LISTENING,new StartListeningArgs(recognizerIntent,listener)));
  }
}

Fixed version (ground truth):
public void startListening(Intent recognizerIntent,IRecognitionListener listener){
  if (DBG)   Log.d(TAG,"String_Node_Str" + listener.asBinder());
  if (mInternalService != null && mInternalService.checkPermissions(listener)) {
    mInternalService.mHandler.sendMessage(Message.obtain(mInternalService.mHandler,MSG_START_LISTENING,mInternalService.new StartListeningArgs(recognizerIntent,listener)));
  }
}
Program: 181795
Project: 181795
Buggy source:
public void stopListening(IRecognitionListener listener){
  if (DBG)   Log.d(TAG,"String_Node_Str" + listener.asBinder());
  if (checkPermissions(listener)) {
    mHandler.sendMessage(Message.obtain(mHandler,MSG_STOP_LISTENING,listener));
  }
}

Fixed version (ground truth):
public void stopListening(IRecognitionListener listener){
  if (DBG)   Log.d(TAG,"String_Node_Str" + listener.asBinder());
  if (mInternalService != null && mInternalService.checkPermissions(listener)) {
    mInternalService.mHandler.sendMessage(Message.obtain(mInternalService.mHandler,MSG_STOP_LISTENING,listener));
  }
}
Program: 181796
Project: 181796
Buggy source:
/** 
 * Destroys the   {@code SpeechRecognizer} object.
 */
public void destroy(){
  if (mConnection != null) {
    mContext.unbindService(mConnection);
  }
  mPendingTasks.clear();
  mService=null;
  mConnection=null;
}

Fixed version (ground truth):
/** 
 * Destroys the   {@code SpeechRecognizer} object.
 */
public void destroy(){
  if (mConnection != null) {
    mContext.unbindService(mConnection);
  }
  mPendingTasks.clear();
  mService=null;
  mConnection=null;
  mListener.mInternalListener=null;
}
Program: 181797
Project: 181797
Buggy source:
/** 
 * Try to parse this message as an email gateway message There are two ways specified in TS 23.040 Section 3.8 : - SMS message "may have its TP-PID set for internet electronic mail - MT SMS format: [<from-address><space>]<message> - "Depending on the nature of the gateway, the destination/origination address is either derived from the content of the SMS TP-OA or TP-DA field, or the TP-OA/TP-DA field contains a generic gateway address and the to/from address is added at the beginning as shown above." (which is supported here) - Multiple addreses separated by commas, no spaces, Subject field delimited by '()' or '##' and '#' Section 9.2.3.24.11 (which are NOT supported here)
 */
protected void extractEmailAddressFromMessageBody(){
  String[] parts=messageBody.split("String_Node_Str",2);
  if (parts.length < 2)   return;
  emailFrom=parts[0];
  emailBody=parts[1];
  isEmail=true;
}

Fixed version (ground truth):
/** 
 * Try to parse this message as an email gateway message There are two ways specified in TS 23.040 Section 3.8 : - SMS message "may have its TP-PID set for internet electronic mail - MT SMS format: [<from-address><space>]<message> - "Depending on the nature of the gateway, the destination/origination address is either derived from the content of the SMS TP-OA or TP-DA field, or the TP-OA/TP-DA field contains a generic gateway address and the to/from address is added at the beginning as shown above." (which is supported here) - Multiple addreses separated by commas, no spaces, Subject field delimited by '()' or '##' and '#' Section 9.2.3.24.11 (which are NOT supported here)
 */
protected void extractEmailAddressFromMessageBody(){
  String[] parts=messageBody.split("String_Node_Str",2);
  if (parts.length < 2)   return;
  emailFrom=parts[0];
  emailBody=parts[1];
  isEmail=Telephony.Mms.isEmailAddress(emailFrom);
}
Program: 181798
Project: 181798
Buggy source:
/** 
 * @hide 
 */
public AudioService(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]=SystemProperties.getInt("String_Node_Str",MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
  mVolumePanel=new VolumePanel(context,this);
  mSettingsObserver=new SettingsObserver();
  mForcedUseForComm=AudioSystem.FORCE_NONE;
  createAudioSystemThread();
  readPersistedSettings();
  createStreamStates();
  mMode=AudioSystem.MODE_INVALID;
  setMode(AudioSystem.MODE_NORMAL,null);
  mMediaServerOk=true;
  AudioSystem.setErrorCallback(mAudioSystemCallback);
  loadSoundEffects();
  mBluetoothHeadsetConnected=false;
  mBluetoothHeadset=new BluetoothHeadset(context,mBluetoothHeadsetServiceListener);
  IntentFilter intentFilter=new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
  intentFilter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
  intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
  intentFilter.addAction(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
  context.registerReceiver(mReceiver,intentFilter);
  intentFilter=new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
  intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
  context.registerReceiver(mMediaButtonReceiver,intentFilter);
}

Fixed version (ground truth):
/** 
 * @hide 
 */
public AudioService(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]=SystemProperties.getInt("String_Node_Str",MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
  mVolumePanel=new VolumePanel(context,this);
  mSettingsObserver=new SettingsObserver();
  mForcedUseForComm=AudioSystem.FORCE_NONE;
  createAudioSystemThread();
  readPersistedSettings();
  createStreamStates();
  mMode=AudioSystem.MODE_INVALID;
  setMode(AudioSystem.MODE_NORMAL,null);
  mMediaServerOk=true;
  mRingerModeMutedStreams=0;
  setRingerModeInt(getRingerMode(),false);
  AudioSystem.setErrorCallback(mAudioSystemCallback);
  loadSoundEffects();
  mBluetoothHeadsetConnected=false;
  mBluetoothHeadset=new BluetoothHeadset(context,mBluetoothHeadsetServiceListener);
  IntentFilter intentFilter=new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
  intentFilter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
  intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
  intentFilter.addAction(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
  context.registerReceiver(mReceiver,intentFilter);
  intentFilter=new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
  intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
  context.registerReceiver(mMediaButtonReceiver,intentFilter);
}
Program: 181799
Project: 181799
Buggy source:
/** 
 * @hide 
 */
public AudioService(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]=SystemProperties.getInt("String_Node_Str",MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
  mVolumePanel=new VolumePanel(context,this);
  mSettingsObserver=new SettingsObserver();
  mForcedUseForComm=AudioSystem.FORCE_NONE;
  createAudioSystemThread();
  readPersistedSettings();
  createStreamStates();
  mMode=AudioSystem.MODE_INVALID;
  setMode(AudioSystem.MODE_NORMAL,null);
  mMediaServerOk=true;
  AudioSystem.setErrorCallback(mAudioSystemCallback);
  loadSoundEffects();
  mBluetoothHeadsetConnected=false;
  mBluetoothHeadset=new BluetoothHeadset(context,mBluetoothHeadsetServiceListener);
  IntentFilter intentFilter=new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
  intentFilter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
  intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
  intentFilter.addAction(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
  context.registerReceiver(mReceiver,intentFilter);
  intentFilter=new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
  intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
  context.registerReceiver(mMediaButtonReceiver,intentFilter);
}

Fixed version (ground truth):
/** 
 * @hide 
 */
public AudioService(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]=SystemProperties.getInt("String_Node_Str",MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
  mVolumePanel=new VolumePanel(context,this);
  mSettingsObserver=new SettingsObserver();
  mForcedUseForComm=AudioSystem.FORCE_NONE;
  createAudioSystemThread();
  readPersistedSettings();
  createStreamStates();
  mMode=AudioSystem.MODE_INVALID;
  setMode(AudioSystem.MODE_NORMAL,null);
  mMediaServerOk=true;
  mRingerModeMutedStreams=0;
  setRingerModeInt(getRingerMode(),false);
  AudioSystem.setErrorCallback(mAudioSystemCallback);
  loadSoundEffects();
  mBluetoothHeadsetConnected=false;
  mBluetoothHeadset=new BluetoothHeadset(context,mBluetoothHeadsetServiceListener);
  IntentFilter intentFilter=new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
  intentFilter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
  intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
  intentFilter.addAction(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
  context.registerReceiver(mReceiver,intentFilter);
  intentFilter=new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
  intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
  context.registerReceiver(mMediaButtonReceiver,intentFilter);
}
Program: 181800
Project: 181800
Buggy source:
private void makeA2dpDeviceUnavailableLater(String address){
  mConnectedDevices.remove(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);
  Message msg=mAudioHandler.obtainMessage(MSG_BTA2DP_DOCK_TIMEOUT,address);
  mAudioHandler.sendMessageDelayed(msg,BTA2DP_DOCK_TIMEOUT_MILLIS);
}

Fixed version (ground truth):
private void makeA2dpDeviceUnavailableLater(String address){
  AudioSystem.setParameters("String_Node_Str");
  mConnectedDevices.remove(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);
  Message msg=mAudioHandler.obtainMessage(MSG_BTA2DP_DOCK_TIMEOUT,address);
  mAudioHandler.sendMessageDelayed(msg,BTA2DP_DOCK_TIMEOUT_MILLIS);
}
Program: 181801
Project: 181801
Buggy source:
/** 
 * This is called when the view is attached to a window.  At this point it has a Surface and will start drawing.  Note that this function is guaranteed to be called before   {@link #onDraw}, however it may be called any time before the first onDraw -- including before or after  {@link #onMeasure}.
 * @see #onDetachedFromWindow()
 */
protected void onAttachedToWindow(){
  if ((mPrivateFlags & REQUEST_TRANSPARENT_REGIONS) != 0) {
    mParent.requestTransparentRegion(this);
  }
}

Fixed version (ground truth):
/** 
 * This is called when the view is attached to a window.  At this point it has a Surface and will start drawing.  Note that this function is guaranteed to be called before   {@link #onDraw}, however it may be called any time before the first onDraw -- including before or after  {@link #onMeasure}.
 * @see #onDetachedFromWindow()
 */
protected void onAttachedToWindow(){
  if ((mPrivateFlags & REQUEST_TRANSPARENT_REGIONS) != 0) {
    mParent.requestTransparentRegion(this);
  }
  if ((mPrivateFlags & AWAKEN_SCROLL_BARS_ON_ATTACH) != 0) {
    initialAwakenScrollBars();
    mPrivateFlags&=~AWAKEN_SCROLL_BARS_ON_ATTACH;
  }
}
Program: 181802
Project: 181802
Buggy source:
/** 
 * Called when the visibility of the view or an ancestor of the view is changed.
 * @param changedView The view whose visibility changed. Could be 'this' oran ancestor view.
 * @param visibility The new visibility of changedView: {@link #VISIBLE},  {@link #INVISIBLE} or {@link #GONE}.
 */
protected void onVisibilityChanged(View changedView,int visibility){
}

Fixed version (ground truth):
/** 
 * Called when the visibility of the view or an ancestor of the view is changed.
 * @param changedView The view whose visibility changed. Could be 'this' oran ancestor view.
 * @param visibility The new visibility of changedView: {@link #VISIBLE},  {@link #INVISIBLE} or {@link #GONE}.
 */
protected void onVisibilityChanged(View changedView,int visibility){
  if (visibility == VISIBLE) {
    if (mAttachInfo != null) {
      initialAwakenScrollBars();
    }
 else {
      mPrivateFlags|=AWAKEN_SCROLL_BARS_ON_ATTACH;
    }
  }
}
Program: 181803
Project: 181803
Buggy source:
/** 
 * Called when the window containing has change its visibility (between   {@link #GONE},   {@link #INVISIBLE}, and   {@link #VISIBLE}).  Note that this tells you whether or not your window is being made visible to the window manager; this does <em>not</em> tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
 * @param visibility The new visibility of the window.
 */
protected void onWindowVisibilityChanged(int visibility){
}

Fixed version (ground truth):
/** 
 * Called when the window containing has change its visibility (between   {@link #GONE},   {@link #INVISIBLE}, and   {@link #VISIBLE}).  Note that this tells you whether or not your window is being made visible to the window manager; this does <em>not</em> tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
 * @param visibility The new visibility of the window.
 */
protected void onWindowVisibilityChanged(int visibility){
  if (visibility == VISIBLE) {
    initialAwakenScrollBars();
  }
}
Program: 181804
Project: 181804
Buggy source:
private void makeA2dpDeviceUnavailableLater(String address){
  mConnectedDevices.remove(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);
  Message msg=mAudioHandler.obtainMessage(MSG_BTA2DP_DOCK_TIMEOUT,address);
  mAudioHandler.sendMessageDelayed(msg,BTA2DP_DOCK_TIMEOUT_MILLIS);
}

Fixed version (ground truth):
private void makeA2dpDeviceUnavailableLater(String address){
  AudioSystem.setParameters("String_Node_Str");
  mConnectedDevices.remove(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);
  Message msg=mAudioHandler.obtainMessage(MSG_BTA2DP_DOCK_TIMEOUT,address);
  mAudioHandler.sendMessageDelayed(msg,BTA2DP_DOCK_TIMEOUT_MILLIS);
}
Program: 181805
Project: 181805
Buggy source:
private void makeA2dpDeviceUnavailableLater(String address){
  mConnectedDevices.remove(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);
  Message msg=mAudioHandler.obtainMessage(MSG_BTA2DP_DOCK_TIMEOUT,address);
  mAudioHandler.sendMessageDelayed(msg,BTA2DP_DOCK_TIMEOUT_MILLIS);
}

Fixed version (ground truth):
private void makeA2dpDeviceUnavailableLater(String address){
  AudioSystem.setParameters("String_Node_Str");
  mConnectedDevices.remove(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);
  Message msg=mAudioHandler.obtainMessage(MSG_BTA2DP_DOCK_TIMEOUT,address);
  mAudioHandler.sendMessageDelayed(msg,BTA2DP_DOCK_TIMEOUT_MILLIS);
}
Program: 181806
Project: 181806
Buggy source:
/** 
 * This is called when the view is attached to a window.  At this point it has a Surface and will start drawing.  Note that this function is guaranteed to be called before   {@link #onDraw}, however it may be called any time before the first onDraw -- including before or after  {@link #onMeasure}.
 * @see #onDetachedFromWindow()
 */
protected void onAttachedToWindow(){
  if ((mPrivateFlags & REQUEST_TRANSPARENT_REGIONS) != 0) {
    mParent.requestTransparentRegion(this);
  }
}

Fixed version (ground truth):
/** 
 * This is called when the view is attached to a window.  At this point it has a Surface and will start drawing.  Note that this function is guaranteed to be called before   {@link #onDraw}, however it may be called any time before the first onDraw -- including before or after  {@link #onMeasure}.
 * @see #onDetachedFromWindow()
 */
protected void onAttachedToWindow(){
  if ((mPrivateFlags & REQUEST_TRANSPARENT_REGIONS) != 0) {
    mParent.requestTransparentRegion(this);
  }
  if ((mPrivateFlags & AWAKEN_SCROLL_BARS_ON_ATTACH) != 0) {
    initialAwakenScrollBars();
    mPrivateFlags&=~AWAKEN_SCROLL_BARS_ON_ATTACH;
  }
}
Program: 181807
Project: 181807
Buggy source:
/** 
 * Called when the visibility of the view or an ancestor of the view is changed.
 * @param changedView The view whose visibility changed. Could be 'this' oran ancestor view.
 * @param visibility The new visibility of changedView: {@link #VISIBLE},  {@link #INVISIBLE} or {@link #GONE}.
 */
protected void onVisibilityChanged(View changedView,int visibility){
}

Fixed version (ground truth):
/** 
 * Called when the visibility of the view or an ancestor of the view is changed.
 * @param changedView The view whose visibility changed. Could be 'this' oran ancestor view.
 * @param visibility The new visibility of changedView: {@link #VISIBLE},  {@link #INVISIBLE} or {@link #GONE}.
 */
protected void onVisibilityChanged(View changedView,int visibility){
  if (visibility == VISIBLE) {
    if (mAttachInfo != null) {
      initialAwakenScrollBars();
    }
 else {
      mPrivateFlags|=AWAKEN_SCROLL_BARS_ON_ATTACH;
    }
  }
}
Program: 181808
Project: 181808
Buggy source:
/** 
 * Called when the window containing has change its visibility (between   {@link #GONE},   {@link #INVISIBLE}, and   {@link #VISIBLE}).  Note that this tells you whether or not your window is being made visible to the window manager; this does <em>not</em> tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
 * @param visibility The new visibility of the window.
 */
protected void onWindowVisibilityChanged(int visibility){
}

Fixed version (ground truth):
/** 
 * Called when the window containing has change its visibility (between   {@link #GONE},   {@link #INVISIBLE}, and   {@link #VISIBLE}).  Note that this tells you whether or not your window is being made visible to the window manager; this does <em>not</em> tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
 * @param visibility The new visibility of the window.
 */
protected void onWindowVisibilityChanged(int visibility){
  if (visibility == VISIBLE) {
    initialAwakenScrollBars();
  }
}
Program: 181809
Project: 181809
Buggy source:
/** 
 * This is called when the view is attached to a window.  At this point it has a Surface and will start drawing.  Note that this function is guaranteed to be called before   {@link #onDraw}, however it may be called any time before the first onDraw -- including before or after  {@link #onMeasure}.
 * @see #onDetachedFromWindow()
 */
protected void onAttachedToWindow(){
  if ((mPrivateFlags & REQUEST_TRANSPARENT_REGIONS) != 0) {
    mParent.requestTransparentRegion(this);
  }
}

Fixed version (ground truth):
/** 
 * This is called when the view is attached to a window.  At this point it has a Surface and will start drawing.  Note that this function is guaranteed to be called before   {@link #onDraw}, however it may be called any time before the first onDraw -- including before or after  {@link #onMeasure}.
 * @see #onDetachedFromWindow()
 */
protected void onAttachedToWindow(){
  if ((mPrivateFlags & REQUEST_TRANSPARENT_REGIONS) != 0) {
    mParent.requestTransparentRegion(this);
  }
  if ((mPrivateFlags & AWAKEN_SCROLL_BARS_ON_ATTACH) != 0) {
    initialAwakenScrollBars();
    mPrivateFlags&=~AWAKEN_SCROLL_BARS_ON_ATTACH;
  }
}
Program: 181810
Project: 181810
Buggy source:
/** 
 * Called when the visibility of the view or an ancestor of the view is changed.
 * @param changedView The view whose visibility changed. Could be 'this' oran ancestor view.
 * @param visibility The new visibility of changedView: {@link #VISIBLE},  {@link #INVISIBLE} or {@link #GONE}.
 */
protected void onVisibilityChanged(View changedView,int visibility){
}

Fixed version (ground truth):
/** 
 * Called when the visibility of the view or an ancestor of the view is changed.
 * @param changedView The view whose visibility changed. Could be 'this' oran ancestor view.
 * @param visibility The new visibility of changedView: {@link #VISIBLE},  {@link #INVISIBLE} or {@link #GONE}.
 */
protected void onVisibilityChanged(View changedView,int visibility){
  if (visibility == VISIBLE) {
    if (mAttachInfo != null) {
      initialAwakenScrollBars();
    }
 else {
      mPrivateFlags|=AWAKEN_SCROLL_BARS_ON_ATTACH;
    }
  }
}
Program: 181811
Project: 181811
Buggy source:
/** 
 * Called when the window containing has change its visibility (between   {@link #GONE},   {@link #INVISIBLE}, and   {@link #VISIBLE}).  Note that this tells you whether or not your window is being made visible to the window manager; this does <em>not</em> tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
 * @param visibility The new visibility of the window.
 */
protected void onWindowVisibilityChanged(int visibility){
}

Fixed version (ground truth):
/** 
 * Called when the window containing has change its visibility (between   {@link #GONE},   {@link #INVISIBLE}, and   {@link #VISIBLE}).  Note that this tells you whether or not your window is being made visible to the window manager; this does <em>not</em> tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
 * @param visibility The new visibility of the window.
 */
protected void onWindowVisibilityChanged(int visibility){
  if (visibility == VISIBLE) {
    initialAwakenScrollBars();
  }
}
Program: 181812
Project: 181812
Buggy source:
/** 
 * @hide 
 */
public AudioService(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]=SystemProperties.getInt("String_Node_Str",MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
  mVolumePanel=new VolumePanel(context,this);
  mSettingsObserver=new SettingsObserver();
  mForcedUseForComm=AudioSystem.FORCE_NONE;
  createAudioSystemThread();
  readPersistedSettings();
  createStreamStates();
  mMode=AudioSystem.MODE_INVALID;
  setMode(AudioSystem.MODE_NORMAL,null);
  mMediaServerOk=true;
  AudioSystem.setErrorCallback(mAudioSystemCallback);
  loadSoundEffects();
  mBluetoothHeadsetConnected=false;
  mBluetoothHeadset=new BluetoothHeadset(context,mBluetoothHeadsetServiceListener);
  IntentFilter intentFilter=new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
  intentFilter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
  intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
  intentFilter.addAction(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
  context.registerReceiver(mReceiver,intentFilter);
  intentFilter=new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
  intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
  context.registerReceiver(mMediaButtonReceiver,intentFilter);
}

Fixed version (ground truth):
/** 
 * @hide 
 */
public AudioService(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]=SystemProperties.getInt("String_Node_Str",MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
  mVolumePanel=new VolumePanel(context,this);
  mSettingsObserver=new SettingsObserver();
  mForcedUseForComm=AudioSystem.FORCE_NONE;
  createAudioSystemThread();
  readPersistedSettings();
  createStreamStates();
  mMode=AudioSystem.MODE_INVALID;
  setMode(AudioSystem.MODE_NORMAL,null);
  mMediaServerOk=true;
  mRingerModeMutedStreams=0;
  setRingerModeInt(getRingerMode(),false);
  AudioSystem.setErrorCallback(mAudioSystemCallback);
  loadSoundEffects();
  mBluetoothHeadsetConnected=false;
  mBluetoothHeadset=new BluetoothHeadset(context,mBluetoothHeadsetServiceListener);
  IntentFilter intentFilter=new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
  intentFilter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
  intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
  intentFilter.addAction(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
  context.registerReceiver(mReceiver,intentFilter);
  intentFilter=new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
  intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
  context.registerReceiver(mMediaButtonReceiver,intentFilter);
}
Program: 181813
Project: 181813
Buggy source:
/** 
 * This is called when the view is attached to a window.  At this point it has a Surface and will start drawing.  Note that this function is guaranteed to be called before   {@link #onDraw}, however it may be called any time before the first onDraw -- including before or after  {@link #onMeasure}.
 * @see #onDetachedFromWindow()
 */
protected void onAttachedToWindow(){
  if ((mPrivateFlags & REQUEST_TRANSPARENT_REGIONS) != 0) {
    mParent.requestTransparentRegion(this);
  }
}

Fixed version (ground truth):
/** 
 * This is called when the view is attached to a window.  At this point it has a Surface and will start drawing.  Note that this function is guaranteed to be called before   {@link #onDraw}, however it may be called any time before the first onDraw -- including before or after  {@link #onMeasure}.
 * @see #onDetachedFromWindow()
 */
protected void onAttachedToWindow(){
  if ((mPrivateFlags & REQUEST_TRANSPARENT_REGIONS) != 0) {
    mParent.requestTransparentRegion(this);
  }
  if ((mPrivateFlags & AWAKEN_SCROLL_BARS_ON_ATTACH) != 0) {
    initialAwakenScrollBars();
    mPrivateFlags&=~AWAKEN_SCROLL_BARS_ON_ATTACH;
  }
}
Program: 181814
Project: 181814
Buggy source:
/** 
 * Called when the visibility of the view or an ancestor of the view is changed.
 * @param changedView The view whose visibility changed. Could be 'this' oran ancestor view.
 * @param visibility The new visibility of changedView: {@link #VISIBLE},  {@link #INVISIBLE} or {@link #GONE}.
 */
protected void onVisibilityChanged(View changedView,int visibility){
}

Fixed version (ground truth):
/** 
 * Called when the visibility of the view or an ancestor of the view is changed.
 * @param changedView The view whose visibility changed. Could be 'this' oran ancestor view.
 * @param visibility The new visibility of changedView: {@link #VISIBLE},  {@link #INVISIBLE} or {@link #GONE}.
 */
protected void onVisibilityChanged(View changedView,int visibility){
  if (visibility == VISIBLE) {
    if (mAttachInfo != null) {
      initialAwakenScrollBars();
    }
 else {
      mPrivateFlags|=AWAKEN_SCROLL_BARS_ON_ATTACH;
    }
  }
}
Program: 181815
Project: 181815
Buggy source:
/** 
 * Called when the window containing has change its visibility (between   {@link #GONE},   {@link #INVISIBLE}, and   {@link #VISIBLE}).  Note that this tells you whether or not your window is being made visible to the window manager; this does <em>not</em> tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
 * @param visibility The new visibility of the window.
 */
protected void onWindowVisibilityChanged(int visibility){
}

Fixed version (ground truth):
/** 
 * Called when the window containing has change its visibility (between   {@link #GONE},   {@link #INVISIBLE}, and   {@link #VISIBLE}).  Note that this tells you whether or not your window is being made visible to the window manager; this does <em>not</em> tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
 * @param visibility The new visibility of the window.
 */
protected void onWindowVisibilityChanged(int visibility){
  if (visibility == VISIBLE) {
    initialAwakenScrollBars();
  }
}
Program: 181816
Project: 181816
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    mPlayer.setOnCompletionListener(this);
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 181817
Project: 181817
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    mPlayer.setOnCompletionListener(this);
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 181818
Project: 181818
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    mPlayer.setOnCompletionListener(this);
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 181819
Project: 181819
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    mPlayer.setOnCompletionListener(this);
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 181824
Project: 181824
Buggy source:
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.muteCount() != 0) {
    streamState.setLastAudibleIndex(index);
    sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
  }
 else {
    if (streamState.setIndex(index,lastAudible) || force) {
      if (mRingerMode == AudioManager.RINGER_MODE_NORMAL || !isStreamAffectedByRingerMode(streamType) || index == 0) {
        sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
      }
 else {
        sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.muteCount() != 0) {
    if (index != 0) {
      streamState.setLastAudibleIndex(index);
      sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
    }
  }
 else {
    if (streamState.setIndex(index,lastAudible) || force) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
    }
  }
}
Program: 181825
Project: 181825
Buggy source:
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.muteCount() != 0) {
    streamState.setLastAudibleIndex(index);
    sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
  }
 else {
    if (streamState.setIndex(index,lastAudible) || force) {
      if (mRingerMode == AudioManager.RINGER_MODE_NORMAL || !isStreamAffectedByRingerMode(streamType) || index == 0) {
        sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
      }
 else {
        sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.muteCount() != 0) {
    if (index != 0) {
      streamState.setLastAudibleIndex(index);
      sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
    }
  }
 else {
    if (streamState.setIndex(index,lastAudible) || force) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
    }
  }
}