nus-yam/ex-repair huggingface dataset:
Program: 193404
Project: 193404
Buggy source:
/** 
 * Check all running users' or specified user's apps to see if they enter an idle state. 
 */
void checkIdleStates(int checkUserId){
  if (!mAppIdleEnabled) {
    return;
  }
  final int[] userIds;
  try {
    if (checkUserId == UserHandle.USER_ALL) {
      userIds=ActivityManagerNative.getDefault().getRunningUserIds();
    }
 else {
      userIds=new int[]{checkUserId};
    }
  }
 catch (  RemoteException re) {
    return;
  }
  for (int i=0; i < userIds.length; i++) {
    final int userId=userIds[i];
    List<PackageInfo> packages=getContext().getPackageManager().getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_UNINSTALLED_PACKAGES,userId);
synchronized (mLock) {
      final long timeNow=checkAndGetTimeLocked();
      final long screenOnTime=getScreenOnTimeLocked(timeNow);
      UserUsageStatsService service=getUserDataAndInitializeIfNeededLocked(userId,timeNow);
      final int packageCount=packages.size();
      for (int p=0; p < packageCount; p++) {
        final String packageName=packages.get(p).packageName;
        final boolean isIdle=isAppIdleFiltered(packageName,userId,service,timeNow,screenOnTime);
        mHandler.sendMessage(mHandler.obtainMessage(MSG_INFORM_LISTENERS,userId,isIdle ? 1 : 0,packageName));
        mAppIdleHistory.addEntry(packageName,userId,isIdle,timeNow);
      }
    }
  }
  mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK_IDLE_STATES,checkUserId,0),mCheckIdleIntervalMillis);
}

Fixed version (ground truth):
/** 
 * Check all running users' or specified user's apps to see if they enter an idle state. 
 */
void checkIdleStates(int checkUserId){
  if (!mAppIdleEnabled) {
    return;
  }
  final int[] userIds;
  try {
    if (checkUserId == UserHandle.USER_ALL) {
      userIds=ActivityManagerNative.getDefault().getRunningUserIds();
    }
 else {
      userIds=new int[]{checkUserId};
    }
  }
 catch (  RemoteException re) {
    return;
  }
  for (int i=0; i < userIds.length; i++) {
    final int userId=userIds[i];
    List<PackageInfo> packages=getContext().getPackageManager().getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_UNINSTALLED_PACKAGES,userId);
synchronized (mLock) {
      final long timeNow=checkAndGetTimeLocked();
      final long screenOnTime=getScreenOnTimeLocked(timeNow);
      UserUsageStatsService service=getUserDataAndInitializeIfNeededLocked(userId,timeNow);
      final int packageCount=packages.size();
      for (int p=0; p < packageCount; p++) {
        final PackageInfo pi=packages.get(p);
        final String packageName=pi.packageName;
        final boolean isIdle=isAppIdleFiltered(packageName,UserHandle.getAppId(pi.applicationInfo.uid),userId,service,timeNow,screenOnTime);
        mHandler.sendMessage(mHandler.obtainMessage(MSG_INFORM_LISTENERS,userId,isIdle ? 1 : 0,packageName));
        mAppIdleHistory.addEntry(packageName,userId,isIdle,timeNow);
      }
    }
  }
  mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK_IDLE_STATES,checkUserId,0),mCheckIdleIntervalMillis);
}
Program: 193405
Project: 193405
Buggy source:
boolean isAppIdleFilteredOrParoled(String packageName,int userId,long timeNow){
  if (mAppIdleParoled) {
    return false;
  }
  return isAppIdleFiltered(packageName,userId,timeNow);
}

Fixed version (ground truth):
boolean isAppIdleFilteredOrParoled(String packageName,int userId,long timeNow){
  if (mAppIdleParoled) {
    return false;
  }
  try {
    ApplicationInfo ai=getContext().getPackageManager().getApplicationInfo(packageName,PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
    return isAppIdleFiltered(packageName,ai.uid,userId,timeNow);
  }
 catch (  PackageManager.NameNotFoundException e) {
  }
  return false;
}
Program: 193406
Project: 193406
Buggy source:
/** 
 * Checks if an app has been idle for a while and filters out apps that are excluded. It returns false if the current system state allows all apps to be considered active. This happens if the device is plugged in or temporarily allowed to make exceptions. Called by interface impls.
 */
private boolean isAppIdleFiltered(String packageName,int userId,UserUsageStatsService userService,long timeNow,long screenOnTime){
  if (packageName == null)   return false;
  if (!mAppIdleEnabled) {
    return false;
  }
  if (packageName.equals("String_Node_Str"))   return false;
  try {
    if (mDeviceIdleController.isPowerSaveWhitelistExceptIdleApp(packageName)) {
      return false;
    }
  }
 catch (  RemoteException re) {
  }
  if (isActiveDeviceAdmin(packageName,userId)) {
    return false;
  }
  if (isCarrierApp(packageName)) {
    return false;
  }
  if (isActiveNetworkScorer(packageName)) {
    return false;
  }
  if (mAppWidgetManager != null && mAppWidgetManager.isBoundWidgetPackage(packageName,userId)) {
    return false;
  }
  return isAppIdleUnfiltered(packageName,userService,timeNow,screenOnTime);
}

Fixed version (ground truth):
/** 
 * Checks if an app has been idle for a while and filters out apps that are excluded. It returns false if the current system state allows all apps to be considered active. This happens if the device is plugged in or temporarily allowed to make exceptions. Called by interface impls.
 */
private boolean isAppIdleFiltered(String packageName,int appId,int userId,UserUsageStatsService userService,long timeNow,long screenOnTime){
  if (packageName == null)   return false;
  if (!mAppIdleEnabled) {
    return false;
  }
  if (appId < Process.FIRST_APPLICATION_UID) {
    return false;
  }
  if (packageName.equals("String_Node_Str")) {
    return false;
  }
  try {
    if (mDeviceIdleController.isPowerSaveWhitelistExceptIdleApp(packageName)) {
      return false;
    }
  }
 catch (  RemoteException re) {
  }
  if (isActiveDeviceAdmin(packageName,userId)) {
    return false;
  }
  if (isCarrierApp(packageName)) {
    return false;
  }
  if (isActiveNetworkScorer(packageName)) {
    return false;
  }
  if (mAppWidgetManager != null && mAppWidgetManager.isBoundWidgetPackage(packageName,userId)) {
    return false;
  }
  return isAppIdleUnfiltered(packageName,userService,timeNow,screenOnTime);
}
Program: 193407
Project: 193407
Buggy source:
protected final void notifyExpandingFinished(){
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}

Fixed version (ground truth):
protected final void notifyExpandingFinished(){
  endClosing();
  if (mExpanding) {
    mExpanding=false;
    onExpandingFinished();
  }
}
Program: 193408
Project: 193408
Buggy source:
protected void onExpandingFinished(){
  endClosing();
  mBar.onExpandingFinished();
}

Fixed version (ground truth):
protected void onExpandingFinished(){
  mBar.onExpandingFinished();
}
Program: 193410
Project: 193410
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  if (!mDraggingDown) {
    return false;
  }
  final float x=event.getX();
  final float y=event.getY();
switch (event.getActionMasked()) {
case MotionEvent.ACTION_MOVE:
    mLastHeight=y - mInitialTouchY;
  captureStartingChild(mInitialTouchX,mInitialTouchY);
if (mStartingChild != null) {
  handleExpansion(mLastHeight,mStartingChild);
}
 else {
  mDragDownCallback.setEmptyDragAmount(mLastHeight);
}
if (mLastHeight > mMinDragDistance) {
if (!mDraggedFarEnough) {
  mDraggedFarEnough=true;
  mDragDownCallback.onThresholdReached();
}
}
 else {
if (mDraggedFarEnough) {
  mDraggedFarEnough=false;
  mDragDownCallback.onDragDownReset();
}
}
return true;
case MotionEvent.ACTION_UP:
if (!isFalseTouch() && mDragDownCallback.onDraggedDown(mStartingChild,(int)(y - mInitialTouchY))) {
if (mStartingChild == null) {
mDragDownCallback.setEmptyDragAmount(0f);
}
mDraggingDown=false;
}
 else {
stopDragging();
return false;
}
break;
case MotionEvent.ACTION_CANCEL:
stopDragging();
return false;
}
return false;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  if (!mDraggingDown) {
    return false;
  }
  final float x=event.getX();
  final float y=event.getY();
switch (event.getActionMasked()) {
case MotionEvent.ACTION_MOVE:
    mLastHeight=y - mInitialTouchY;
  captureStartingChild(mInitialTouchX,mInitialTouchY);
if (mStartingChild != null) {
  handleExpansion(mLastHeight,mStartingChild);
}
 else {
  mDragDownCallback.setEmptyDragAmount(mLastHeight);
}
if (mLastHeight > mMinDragDistance) {
if (!mDraggedFarEnough) {
  mDraggedFarEnough=true;
  mDragDownCallback.onThresholdReached();
}
}
 else {
if (mDraggedFarEnough) {
  mDraggedFarEnough=false;
  mDragDownCallback.onDragDownReset();
}
}
return true;
case MotionEvent.ACTION_UP:
if (!isFalseTouch() && mDragDownCallback.onDraggedDown(mStartingChild,(int)(y - mInitialTouchY))) {
if (mStartingChild == null) {
mDragDownCallback.setEmptyDragAmount(0f);
}
 else {
mCallback.setUserLockedChild(mStartingChild,false);
}
mDraggingDown=false;
}
 else {
stopDragging();
return false;
}
break;
case MotionEvent.ACTION_CANCEL:
stopDragging();
return false;
}
return false;
}
Program: 193411
Project: 193411
Buggy source:
/** 
 * If secure with redaction: Show bouncer, go to unlocked shade. <p>If secure without redaction or no security: Go to   {@link StatusBarState#SHADE_LOCKED}.</p>
 * @param expandView The view to expand after going to the shade.
 */
public void goToLockedShade(View expandView){
  ExpandableNotificationRow row=null;
  if (expandView instanceof ExpandableNotificationRow) {
    row=(ExpandableNotificationRow)expandView;
    row.setUserExpanded(true);
  }
  boolean fullShadeNeedsBouncer=!userAllowsPrivateNotificationsInPublic(mCurrentUserId) || !mShowLockscreenNotifications || mFalsingManager.shouldEnforceBouncer();
  if (isLockscreenPublicMode() && fullShadeNeedsBouncer) {
    mLeaveOpenOnKeyguardHide=true;
    showBouncer();
    mDraggedDownRow=row;
  }
 else {
    mNotificationPanel.animateToFullShade(0);
    setBarState(StatusBarState.SHADE_LOCKED);
    updateKeyguardState(false,false);
    if (row != null) {
      row.setUserLocked(false);
    }
  }
}

Fixed version (ground truth):
/** 
 * If secure with redaction: Show bouncer, go to unlocked shade. <p>If secure without redaction or no security: Go to   {@link StatusBarState#SHADE_LOCKED}.</p>
 * @param expandView The view to expand after going to the shade.
 */
public void goToLockedShade(View expandView){
  ExpandableNotificationRow row=null;
  if (expandView instanceof ExpandableNotificationRow) {
    row=(ExpandableNotificationRow)expandView;
    row.setUserExpanded(true);
  }
  boolean fullShadeNeedsBouncer=!userAllowsPrivateNotificationsInPublic(mCurrentUserId) || !mShowLockscreenNotifications || mFalsingManager.shouldEnforceBouncer();
  if (isLockscreenPublicMode() && fullShadeNeedsBouncer) {
    mLeaveOpenOnKeyguardHide=true;
    showBouncer();
    mDraggedDownRow=row;
  }
 else {
    mNotificationPanel.animateToFullShade(0);
    setBarState(StatusBarState.SHADE_LOCKED);
    updateKeyguardState(false,false);
  }
}
Program: 193414
Project: 193414
Buggy source:
public int getDefaultUsbCard(){
  for (  AlsaCardRecord rec : mCardRecords) {
    if (rec.mIsUsb) {
      return rec.mCardNum;
    }
  }
  return -1;
}

Fixed version (ground truth):
public int getDefaultUsbCard(){
  ArrayList<AlsaCardsParser.AlsaCardRecord> prevRecs=mCardRecords;
  if (DEBUG) {
    LogDevices("String_Node_Str",prevRecs);
  }
  scan();
  if (DEBUG) {
    LogDevices("String_Node_Str",mCardRecords);
  }
  ArrayList<AlsaCardRecord> newRecs=getNewCardRecords(prevRecs);
  if (DEBUG) {
    LogDevices("String_Node_Str",newRecs);
  }
  for (  AlsaCardRecord rec : newRecs) {
    if (DEBUG) {
      Slog.d(TAG,rec.mCardName + "String_Node_Str" + rec.mCardNum+ "String_Node_Str"+ rec.mIsUsb);
    }
    if (rec.mIsUsb) {
      return rec.mCardNum;
    }
  }
  for (  AlsaCardRecord rec : prevRecs) {
    if (DEBUG) {
      Slog.d(TAG,rec.mCardName + "String_Node_Str" + rec.mCardNum+ "String_Node_Str"+ rec.mIsUsb);
    }
    if (rec.mIsUsb) {
      return rec.mCardNum;
    }
  }
  return -1;
}
Program: 193415
Project: 193415
Buggy source:
public int getDefaultCard(){
  int card=getDefaultUsbCard();
  if (card < 0 && getNumCardRecords() > 0) {
    card=getCardRecordAt(getNumCardRecords() - 1).mCardNum;
  }
  return card;
}

Fixed version (ground truth):
public int getDefaultCard(){
  int card=getDefaultUsbCard();
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + card);
  }
  if (card < 0 && getNumCardRecords() > 0) {
    card=getCardRecordAt(getNumCardRecords() - 1).mCardNum;
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + card);
  }
  return card;
}
Program: 193416
Project: 193416
Buggy source:
private AlsaDevice waitForAlsaDevice(int card,int device,int type){
  AlsaDevice testDevice=new AlsaDevice(type,card,device);
  final int kWaitTime=2500;
synchronized (mAlsaDevices) {
    long timeout=SystemClock.elapsedRealtime() + kWaitTime;
    do {
      if (mAlsaDevices.values().contains(testDevice)) {
        return testDevice;
      }
      long waitTime=timeout - SystemClock.elapsedRealtime();
      if (waitTime > 0) {
        try {
          mAlsaDevices.wait(waitTime);
        }
 catch (        InterruptedException e) {
          Slog.d(TAG,"String_Node_Str");
        }
      }
    }
 while (timeout > SystemClock.elapsedRealtime());
  }
  Slog.e(TAG,"String_Node_Str" + testDevice);
  return null;
}

Fixed version (ground truth):
private AlsaDevice waitForAlsaDevice(int card,int device,int type){
  if (DEBUG) {
    Slog.e(TAG,"String_Node_Str" + card + "String_Node_Str"+ device+ "String_Node_Str");
  }
  AlsaDevice testDevice=new AlsaDevice(type,card,device);
  final int kWaitTime=2500;
synchronized (mAlsaDevices) {
    long timeout=SystemClock.elapsedRealtime() + kWaitTime;
    do {
      if (mAlsaDevices.values().contains(testDevice)) {
        return testDevice;
      }
      long waitTime=timeout - SystemClock.elapsedRealtime();
      if (waitTime > 0) {
        try {
          mAlsaDevices.wait(waitTime);
        }
 catch (        InterruptedException e) {
          Slog.d(TAG,"String_Node_Str");
        }
      }
    }
 while (timeout > SystemClock.elapsedRealtime());
  }
  Slog.e(TAG,"String_Node_Str" + testDevice);
  return null;
}
Program: 193417
Project: 193417
Buggy source:
UsbAudioDevice selectAudioCard(int card){
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + card);
  }
  if (!mCardsParser.isCardUsb(card)) {
    return null;
  }
  mDevicesParser.scan();
  int device=mDevicesParser.getDefaultDeviceNum(card);
  boolean hasPlayback=mDevicesParser.hasPlaybackDevices(card);
  boolean hasCapture=mDevicesParser.hasCaptureDevices(card);
  int deviceClass=(mCardsParser.isCardUsb(card) ? UsbAudioDevice.kAudioDeviceClass_External : UsbAudioDevice.kAudioDeviceClass_Internal) | UsbAudioDevice.kAudioDeviceMeta_Alsa;
  if (hasPlayback && (waitForAlsaDevice(card,device,AlsaDevice.TYPE_PLAYBACK) == null)) {
    return null;
  }
  if (hasCapture && (waitForAlsaDevice(card,device,AlsaDevice.TYPE_CAPTURE) == null)) {
    return null;
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + hasPlayback + "String_Node_Str"+ hasCapture);
  }
  UsbAudioDevice audioDevice=new UsbAudioDevice(card,device,hasPlayback,hasCapture,deviceClass);
  AlsaCardsParser.AlsaCardRecord cardRecord=mCardsParser.getCardRecordFor(card);
  audioDevice.mDeviceName=cardRecord.mCardName;
  audioDevice.mDeviceDescription=cardRecord.mCardDescription;
  notifyDeviceState(audioDevice,true);
  return audioDevice;
}

Fixed version (ground truth):
UsbAudioDevice selectAudioCard(int card){
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + card + "String_Node_Str"+ mCardsParser.isCardUsb(card));
  }
  if (!mCardsParser.isCardUsb(card)) {
    return null;
  }
  mDevicesParser.scan();
  int device=mDevicesParser.getDefaultDeviceNum(card);
  boolean hasPlayback=mDevicesParser.hasPlaybackDevices(card);
  boolean hasCapture=mDevicesParser.hasCaptureDevices(card);
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + hasPlayback + "String_Node_Str"+ hasCapture);
  }
  int deviceClass=(mCardsParser.isCardUsb(card) ? UsbAudioDevice.kAudioDeviceClass_External : UsbAudioDevice.kAudioDeviceClass_Internal) | UsbAudioDevice.kAudioDeviceMeta_Alsa;
  if (hasPlayback && (waitForAlsaDevice(card,device,AlsaDevice.TYPE_PLAYBACK) == null)) {
    return null;
  }
  if (hasCapture && (waitForAlsaDevice(card,device,AlsaDevice.TYPE_CAPTURE) == null)) {
    return null;
  }
  UsbAudioDevice audioDevice=new UsbAudioDevice(card,device,hasPlayback,hasCapture,deviceClass);
  AlsaCardsParser.AlsaCardRecord cardRecord=mCardsParser.getCardRecordFor(card);
  audioDevice.mDeviceName=cardRecord.mCardName;
  audioDevice.mDeviceDescription=cardRecord.mCardDescription;
  notifyDeviceState(audioDevice,true);
  return audioDevice;
}
Program: 193419
Project: 193419
Buggy source:
UsbAudioDevice selectDefaultDevice(){
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str");
  }
  mCardsParser.scan();
  return selectAudioCard(mCardsParser.getDefaultCard());
}

Fixed version (ground truth):
UsbAudioDevice selectDefaultDevice(){
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str");
  }
  return selectAudioCard(mCardsParser.getDefaultCard());
}
Program: 193420
Project: 193420
Buggy source:
public int getDefaultUsbCard(){
  for (  AlsaCardRecord rec : mCardRecords) {
    if (rec.mIsUsb) {
      return rec.mCardNum;
    }
  }
  return -1;
}

Fixed version (ground truth):
public int getDefaultUsbCard(){
  ArrayList<AlsaCardsParser.AlsaCardRecord> prevRecs=mCardRecords;
  if (DEBUG) {
    LogDevices("String_Node_Str",prevRecs);
  }
  scan();
  if (DEBUG) {
    LogDevices("String_Node_Str",mCardRecords);
  }
  ArrayList<AlsaCardRecord> newRecs=getNewCardRecords(prevRecs);
  if (DEBUG) {
    LogDevices("String_Node_Str",newRecs);
  }
  for (  AlsaCardRecord rec : newRecs) {
    if (DEBUG) {
      Slog.d(TAG,rec.mCardName + "String_Node_Str" + rec.mCardNum+ "String_Node_Str"+ rec.mIsUsb);
    }
    if (rec.mIsUsb) {
      return rec.mCardNum;
    }
  }
  for (  AlsaCardRecord rec : prevRecs) {
    if (DEBUG) {
      Slog.d(TAG,rec.mCardName + "String_Node_Str" + rec.mCardNum+ "String_Node_Str"+ rec.mIsUsb);
    }
    if (rec.mIsUsb) {
      return rec.mCardNum;
    }
  }
  return -1;
}
Program: 193421
Project: 193421
Buggy source:
public int getDefaultCard(){
  int card=getDefaultUsbCard();
  if (card < 0 && getNumCardRecords() > 0) {
    card=getCardRecordAt(getNumCardRecords() - 1).mCardNum;
  }
  return card;
}

Fixed version (ground truth):
public int getDefaultCard(){
  int card=getDefaultUsbCard();
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + card);
  }
  if (card < 0 && getNumCardRecords() > 0) {
    card=getCardRecordAt(getNumCardRecords() - 1).mCardNum;
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + card);
  }
  return card;
}
Program: 193422
Project: 193422
Buggy source:
private AlsaDevice waitForAlsaDevice(int card,int device,int type){
  AlsaDevice testDevice=new AlsaDevice(type,card,device);
  final int kWaitTime=2500;
synchronized (mAlsaDevices) {
    long timeout=SystemClock.elapsedRealtime() + kWaitTime;
    do {
      if (mAlsaDevices.values().contains(testDevice)) {
        return testDevice;
      }
      long waitTime=timeout - SystemClock.elapsedRealtime();
      if (waitTime > 0) {
        try {
          mAlsaDevices.wait(waitTime);
        }
 catch (        InterruptedException e) {
          Slog.d(TAG,"String_Node_Str");
        }
      }
    }
 while (timeout > SystemClock.elapsedRealtime());
  }
  Slog.e(TAG,"String_Node_Str" + testDevice);
  return null;
}

Fixed version (ground truth):
private AlsaDevice waitForAlsaDevice(int card,int device,int type){
  if (DEBUG) {
    Slog.e(TAG,"String_Node_Str" + card + "String_Node_Str"+ device+ "String_Node_Str");
  }
  AlsaDevice testDevice=new AlsaDevice(type,card,device);
  final int kWaitTime=2500;
synchronized (mAlsaDevices) {
    long timeout=SystemClock.elapsedRealtime() + kWaitTime;
    do {
      if (mAlsaDevices.values().contains(testDevice)) {
        return testDevice;
      }
      long waitTime=timeout - SystemClock.elapsedRealtime();
      if (waitTime > 0) {
        try {
          mAlsaDevices.wait(waitTime);
        }
 catch (        InterruptedException e) {
          Slog.d(TAG,"String_Node_Str");
        }
      }
    }
 while (timeout > SystemClock.elapsedRealtime());
  }
  Slog.e(TAG,"String_Node_Str" + testDevice);
  return null;
}
Program: 193423
Project: 193423
Buggy source:
UsbAudioDevice selectAudioCard(int card){
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + card);
  }
  if (!mCardsParser.isCardUsb(card)) {
    return null;
  }
  mDevicesParser.scan();
  int device=mDevicesParser.getDefaultDeviceNum(card);
  boolean hasPlayback=mDevicesParser.hasPlaybackDevices(card);
  boolean hasCapture=mDevicesParser.hasCaptureDevices(card);
  int deviceClass=(mCardsParser.isCardUsb(card) ? UsbAudioDevice.kAudioDeviceClass_External : UsbAudioDevice.kAudioDeviceClass_Internal) | UsbAudioDevice.kAudioDeviceMeta_Alsa;
  if (hasPlayback && (waitForAlsaDevice(card,device,AlsaDevice.TYPE_PLAYBACK) == null)) {
    return null;
  }
  if (hasCapture && (waitForAlsaDevice(card,device,AlsaDevice.TYPE_CAPTURE) == null)) {
    return null;
  }
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + hasPlayback + "String_Node_Str"+ hasCapture);
  }
  UsbAudioDevice audioDevice=new UsbAudioDevice(card,device,hasPlayback,hasCapture,deviceClass);
  AlsaCardsParser.AlsaCardRecord cardRecord=mCardsParser.getCardRecordFor(card);
  audioDevice.mDeviceName=cardRecord.mCardName;
  audioDevice.mDeviceDescription=cardRecord.mCardDescription;
  notifyDeviceState(audioDevice,true);
  return audioDevice;
}

Fixed version (ground truth):
UsbAudioDevice selectAudioCard(int card){
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + card + "String_Node_Str"+ mCardsParser.isCardUsb(card));
  }
  if (!mCardsParser.isCardUsb(card)) {
    return null;
  }
  mDevicesParser.scan();
  int device=mDevicesParser.getDefaultDeviceNum(card);
  boolean hasPlayback=mDevicesParser.hasPlaybackDevices(card);
  boolean hasCapture=mDevicesParser.hasCaptureDevices(card);
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + hasPlayback + "String_Node_Str"+ hasCapture);
  }
  int deviceClass=(mCardsParser.isCardUsb(card) ? UsbAudioDevice.kAudioDeviceClass_External : UsbAudioDevice.kAudioDeviceClass_Internal) | UsbAudioDevice.kAudioDeviceMeta_Alsa;
  if (hasPlayback && (waitForAlsaDevice(card,device,AlsaDevice.TYPE_PLAYBACK) == null)) {
    return null;
  }
  if (hasCapture && (waitForAlsaDevice(card,device,AlsaDevice.TYPE_CAPTURE) == null)) {
    return null;
  }
  UsbAudioDevice audioDevice=new UsbAudioDevice(card,device,hasPlayback,hasCapture,deviceClass);
  AlsaCardsParser.AlsaCardRecord cardRecord=mCardsParser.getCardRecordFor(card);
  audioDevice.mDeviceName=cardRecord.mCardName;
  audioDevice.mDeviceDescription=cardRecord.mCardDescription;
  notifyDeviceState(audioDevice,true);
  return audioDevice;
}
Program: 193425
Project: 193425
Buggy source:
UsbAudioDevice selectDefaultDevice(){
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str");
  }
  mCardsParser.scan();
  return selectAudioCard(mCardsParser.getDefaultCard());
}

Fixed version (ground truth):
UsbAudioDevice selectDefaultDevice(){
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str");
  }
  return selectAudioCard(mCardsParser.getDefaultCard());
}
Program: 193427
Project: 193427
Buggy source:
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    becomeInactiveIfAppropriateLocked();
  }
}

Fixed version (ground truth):
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    cancelSensingAlarmLocked();
    becomeInactiveIfAppropriateLocked();
  }
}
Program: 193429
Project: 193429
Buggy source:
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    becomeInactiveIfAppropriateLocked();
  }
}

Fixed version (ground truth):
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    cancelSensingAlarmLocked();
    becomeInactiveIfAppropriateLocked();
  }
}
Program: 193431
Project: 193431
Buggy source:
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    becomeInactiveIfAppropriateLocked();
  }
}

Fixed version (ground truth):
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    cancelSensingAlarmLocked();
    becomeInactiveIfAppropriateLocked();
  }
}
Program: 193433
Project: 193433
Buggy source:
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    becomeInactiveIfAppropriateLocked();
  }
}

Fixed version (ground truth):
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    cancelSensingAlarmLocked();
    becomeInactiveIfAppropriateLocked();
  }
}
Program: 193435
Project: 193435
Buggy source:
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    becomeInactiveIfAppropriateLocked();
  }
}

Fixed version (ground truth):
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    cancelSensingAlarmLocked();
    becomeInactiveIfAppropriateLocked();
  }
}
Program: 193437
Project: 193437
Buggy source:
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    becomeInactiveIfAppropriateLocked();
  }
}

Fixed version (ground truth):
void handleMotionDetectedLocked(long timeout,String type){
  if (mState != STATE_ACTIVE) {
    scheduleReportActiveLocked(type,Process.myUid());
    mState=STATE_ACTIVE;
    mInactiveTimeout=timeout;
    EventLogTags.writeDeviceIdle(mState,type);
    cancelSensingAlarmLocked();
    becomeInactiveIfAppropriateLocked();
  }
}
Program: 193438
Project: 193438
Buggy source:
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr=null;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}

Fixed version (ground truth):
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
        if (!isServiceNeeded(sr,false,false)) {
          bringDownServiceLocked(sr);
        }
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}
Program: 193439
Project: 193439
Buggy source:
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}

Fixed version (ground truth):
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  if (!isServiceNeeded(r,false,false)) {
    Slog.wtf(TAG,"String_Node_Str" + r);
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}
Program: 193442
Project: 193442
Buggy source:
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr=null;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}

Fixed version (ground truth):
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
        if (!isServiceNeeded(sr,false,false)) {
          bringDownServiceLocked(sr);
        }
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}
Program: 193443
Project: 193443
Buggy source:
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}

Fixed version (ground truth):
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  if (!isServiceNeeded(r,false,false)) {
    Slog.wtf(TAG,"String_Node_Str" + r);
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}
Program: 193446
Project: 193446
Buggy source:
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr=null;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}

Fixed version (ground truth):
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
        if (!isServiceNeeded(sr,false,false)) {
          bringDownServiceLocked(sr);
        }
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}
Program: 193447
Project: 193447
Buggy source:
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}

Fixed version (ground truth):
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  if (!isServiceNeeded(r,false,false)) {
    Slog.wtf(TAG,"String_Node_Str" + r);
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}
Program: 193450
Project: 193450
Buggy source:
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr=null;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}

Fixed version (ground truth):
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
        if (!isServiceNeeded(sr,false,false)) {
          bringDownServiceLocked(sr);
        }
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}
Program: 193451
Project: 193451
Buggy source:
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}

Fixed version (ground truth):
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  if (!isServiceNeeded(r,false,false)) {
    Slog.wtf(TAG,"String_Node_Str" + r);
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}
Program: 193454
Project: 193454
Buggy source:
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr=null;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}

Fixed version (ground truth):
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
        if (!isServiceNeeded(sr,false,false)) {
          bringDownServiceLocked(sr);
        }
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}
Program: 193455
Project: 193455
Buggy source:
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}

Fixed version (ground truth):
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  if (!isServiceNeeded(r,false,false)) {
    Slog.wtf(TAG,"String_Node_Str" + r);
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}
Program: 193458
Project: 193458
Buggy source:
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr=null;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}

Fixed version (ground truth):
boolean attachApplicationLocked(ProcessRecord proc,String processName) throws RemoteException {
  boolean didSomething=false;
  if (mPendingServices.size() > 0) {
    ServiceRecord sr=null;
    try {
      for (int i=0; i < mPendingServices.size(); i++) {
        sr=mPendingServices.get(i);
        if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
          continue;
        }
        mPendingServices.remove(i);
        i--;
        proc.addPackage(sr.appInfo.packageName,sr.appInfo.versionCode,mAm.mProcessStats);
        realStartServiceLocked(sr,proc,sr.createdFromFg);
        didSomething=true;
        if (!isServiceNeeded(sr,false,false)) {
          bringDownServiceLocked(sr);
        }
      }
    }
 catch (    RemoteException e) {
      Slog.w(TAG,"String_Node_Str" + sr.shortName,e);
      throw e;
    }
  }
  if (mRestartingServices.size() > 0) {
    ServiceRecord sr;
    for (int i=0; i < mRestartingServices.size(); i++) {
      sr=mRestartingServices.get(i);
      if (proc != sr.isolatedProc && (proc.uid != sr.appInfo.uid || !processName.equals(sr.processName))) {
        continue;
      }
      mAm.mHandler.removeCallbacks(sr.restarter);
      mAm.mHandler.post(sr.restarter);
    }
  }
  return didSomething;
}
Program: 193459
Project: 193459
Buggy source:
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}

Fixed version (ground truth):
final void performServiceRestartLocked(ServiceRecord r){
  if (!mRestartingServices.contains(r)) {
    return;
  }
  if (!isServiceNeeded(r,false,false)) {
    Slog.wtf(TAG,"String_Node_Str" + r);
    return;
  }
  try {
    bringUpServiceLocked(r,r.intent.getIntent().getFlags(),r.createdFromFg,true);
  }
 catch (  TransactionTooLargeException e) {
  }
}