nus-yam/ex-repair huggingface dataset:
Program: 199615
Project: 199615
Buggy source:
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}

Fixed version (ground truth):
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  if (!Thread.holdsLock(mLock)) {
    Slog.wtf(TAG,"String_Node_Str");
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}
Program: 199616
Project: 199616
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  mMenu.performItemAction(mAdapter.getItem(position),0);
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  mMenu.performItemAction(mAdapter.getItem(position),this,0);
}
Program: 199617
Project: 199617
Buggy source:
private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu){
  if (mPresenters.isEmpty())   return false;
  boolean result=false;
  for (  WeakReference<MenuPresenter> ref : mPresenters) {
    final MenuPresenter presenter=ref.get();
    if (presenter == null) {
      mPresenters.remove(ref);
    }
 else     if (!result) {
      result=presenter.onSubMenuSelected(subMenu);
    }
  }
  return result;
}

Fixed version (ground truth):
private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu,MenuPresenter preferredPresenter){
  if (mPresenters.isEmpty())   return false;
  boolean result=false;
  if (preferredPresenter != null) {
    result=preferredPresenter.onSubMenuSelected(subMenu);
  }
  for (  WeakReference<MenuPresenter> ref : mPresenters) {
    final MenuPresenter presenter=ref.get();
    if (presenter == null) {
      mPresenters.remove(ref);
    }
 else     if (!result) {
      result=presenter.onSubMenuSelected(subMenu);
    }
  }
  return result;
}
Program: 199618
Project: 199618
Buggy source:
public boolean performItemAction(MenuItem item,int flags){
  MenuItemImpl itemImpl=(MenuItemImpl)item;
  if (itemImpl == null || !itemImpl.isEnabled()) {
    return false;
  }
  boolean invoked=itemImpl.invoke();
  final ActionProvider provider=item.getActionProvider();
  final boolean providerHasSubMenu=provider != null && provider.hasSubMenu();
  if (itemImpl.hasCollapsibleActionView()) {
    invoked|=itemImpl.expandActionView();
    if (invoked)     close(true);
  }
 else   if (itemImpl.hasSubMenu() || providerHasSubMenu) {
    close(false);
    if (!itemImpl.hasSubMenu()) {
      itemImpl.setSubMenu(new SubMenuBuilder(getContext(),this,itemImpl));
    }
    final SubMenuBuilder subMenu=(SubMenuBuilder)itemImpl.getSubMenu();
    if (providerHasSubMenu) {
      provider.onPrepareSubMenu(subMenu);
    }
    invoked|=dispatchSubMenuSelected(subMenu);
    if (!invoked)     close(true);
  }
 else {
    if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
      close(true);
    }
  }
  return invoked;
}

Fixed version (ground truth):
public boolean performItemAction(MenuItem item,MenuPresenter preferredPresenter,int flags){
  MenuItemImpl itemImpl=(MenuItemImpl)item;
  if (itemImpl == null || !itemImpl.isEnabled()) {
    return false;
  }
  boolean invoked=itemImpl.invoke();
  final ActionProvider provider=item.getActionProvider();
  final boolean providerHasSubMenu=provider != null && provider.hasSubMenu();
  if (itemImpl.hasCollapsibleActionView()) {
    invoked|=itemImpl.expandActionView();
    if (invoked)     close(true);
  }
 else   if (itemImpl.hasSubMenu() || providerHasSubMenu) {
    close(false);
    if (!itemImpl.hasSubMenu()) {
      itemImpl.setSubMenu(new SubMenuBuilder(getContext(),this,itemImpl));
    }
    final SubMenuBuilder subMenu=(SubMenuBuilder)itemImpl.getSubMenu();
    if (providerHasSubMenu) {
      provider.onPrepareSubMenu(subMenu);
    }
    invoked|=dispatchSubMenuSelected(subMenu,preferredPresenter);
    if (!invoked)     close(true);
  }
 else {
    if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
      close(true);
    }
  }
  return invoked;
}
Program: 199619
Project: 199619
Buggy source:
public KeyguardPatternView(Context context,AttributeSet attrs){
  super(context,attrs);
}

Fixed version (ground truth):
public KeyguardPatternView(Context context,AttributeSet attrs){
  super(context,attrs);
  mKeyguardUpdateMonitor=KeyguardUpdateMonitor.getInstance(mContext);
}
Program: 199620
Project: 199620
Buggy source:
public void onPatternDetected(List<LockPatternView.Cell> pattern){
  if (mLockPatternUtils.checkPattern(pattern)) {
    mCallback.reportSuccessfulUnlockAttempt();
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
    mTotalFailedPatternAttempts=0;
    mCallback.dismiss(true);
  }
 else {
    if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
      mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
    }
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
    if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
      mTotalFailedPatternAttempts++;
      mFailedPatternAttemptsSinceLastTimeout++;
      mCallback.reportFailedUnlockAttempt();
    }
    if (mFailedPatternAttemptsSinceLastTimeout >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
      long deadline=mLockPatternUtils.setLockoutAttemptDeadline();
      handleAttemptLockout(deadline);
    }
 else {
      mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern,true);
      mLockPatternView.postDelayed(mCancelPatternRunnable,PATTERN_CLEAR_TIMEOUT_MS);
    }
  }
}

Fixed version (ground truth):
public void onPatternDetected(List<LockPatternView.Cell> pattern){
  if (mLockPatternUtils.checkPattern(pattern)) {
    mCallback.reportSuccessfulUnlockAttempt();
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
    mCallback.dismiss(true);
  }
 else {
    if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
      mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
    }
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
    boolean registeredAttempt=pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL;
    if (registeredAttempt) {
      mCallback.reportFailedUnlockAttempt();
    }
    int attempts=mKeyguardUpdateMonitor.getFailedUnlockAttempts();
    if (registeredAttempt && 0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
      long deadline=mLockPatternUtils.setLockoutAttemptDeadline();
      handleAttemptLockout(deadline);
    }
 else {
      mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern,true);
      mLockPatternView.postDelayed(mCancelPatternRunnable,PATTERN_CLEAR_TIMEOUT_MS);
    }
  }
}
Program: 199621
Project: 199621
Buggy source:
@Override public void onFinish(){
  mLockPatternView.setEnabled(true);
  displayDefaultSecurityMessage();
  mFailedPatternAttemptsSinceLastTimeout=0;
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}

Fixed version (ground truth):
@Override public void onFinish(){
  mLockPatternView.setEnabled(true);
  displayDefaultSecurityMessage();
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}
Program: 199622
Project: 199622
Buggy source:
private void displayDefaultSecurityMessage(){
  if (KeyguardUpdateMonitor.getInstance(mContext).getMaxBiometricUnlockAttemptsReached()) {
    mSecurityMessageDisplay.setMessage(R.string.faceunlock_multiple_failures,true);
  }
 else {
    mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions,false);
  }
}

Fixed version (ground truth):
private void displayDefaultSecurityMessage(){
  if (mKeyguardUpdateMonitor.getMaxBiometricUnlockAttemptsReached()) {
    mSecurityMessageDisplay.setMessage(R.string.faceunlock_multiple_failures,true);
  }
 else {
    mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions,false);
  }
}
Program: 199623
Project: 199623
Buggy source:
public void reset(){
  mLockPatternView.enableInput();
  mLockPatternView.setEnabled(true);
  mLockPatternView.clearPattern();
  long deadline=mLockPatternUtils.getLockoutAttemptDeadline();
  if (deadline != 0) {
    handleAttemptLockout(deadline);
  }
 else {
    displayDefaultSecurityMessage();
  }
  if (mCallback.isVerifyUnlockOnly()) {
    updateFooter(FooterMode.VerifyUnlocked);
  }
 else   if (mEnableFallback && (mTotalFailedPatternAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}

Fixed version (ground truth):
public void reset(){
  mLockPatternView.enableInput();
  mLockPatternView.setEnabled(true);
  mLockPatternView.clearPattern();
  long deadline=mLockPatternUtils.getLockoutAttemptDeadline();
  if (deadline != 0) {
    handleAttemptLockout(deadline);
  }
 else {
    displayDefaultSecurityMessage();
  }
  if (mCallback.isVerifyUnlockOnly()) {
    updateFooter(FooterMode.VerifyUnlocked);
  }
 else   if (mEnableFallback && (mKeyguardUpdateMonitor.getFailedUnlockAttempts() >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}
Program: 199624
Project: 199624
Buggy source:
private void handleAttemptLockout(long elapsedRealtimeDeadline){
  mLockPatternView.clearPattern();
  mLockPatternView.setEnabled(false);
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
  mCountdownTimer=new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime,1000){
    @Override public void onTick(    long millisUntilFinished){
      final int secondsRemaining=(int)(millisUntilFinished / 1000);
      mSecurityMessageDisplay.setMessage(R.string.kg_too_many_failed_attempts_countdown,true,secondsRemaining);
    }
    @Override public void onFinish(){
      mLockPatternView.setEnabled(true);
      displayDefaultSecurityMessage();
      mFailedPatternAttemptsSinceLastTimeout=0;
      if (mEnableFallback) {
        updateFooter(FooterMode.ForgotLockPattern);
      }
 else {
        updateFooter(FooterMode.Normal);
      }
    }
  }
.start();
}

Fixed version (ground truth):
private void handleAttemptLockout(long elapsedRealtimeDeadline){
  mLockPatternView.clearPattern();
  mLockPatternView.setEnabled(false);
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
  mCountdownTimer=new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime,1000){
    @Override public void onTick(    long millisUntilFinished){
      final int secondsRemaining=(int)(millisUntilFinished / 1000);
      mSecurityMessageDisplay.setMessage(R.string.kg_too_many_failed_attempts_countdown,true,secondsRemaining);
    }
    @Override public void onFinish(){
      mLockPatternView.setEnabled(true);
      displayDefaultSecurityMessage();
      if (mEnableFallback) {
        updateFooter(FooterMode.ForgotLockPattern);
      }
 else {
        updateFooter(FooterMode.Normal);
      }
    }
  }
.start();
}
Program: 199625
Project: 199625
Buggy source:
public KeyguardPatternView(Context context,AttributeSet attrs){
  super(context,attrs);
}

Fixed version (ground truth):
public KeyguardPatternView(Context context,AttributeSet attrs){
  super(context,attrs);
  mKeyguardUpdateMonitor=KeyguardUpdateMonitor.getInstance(mContext);
}
Program: 199626
Project: 199626
Buggy source:
public void onPatternDetected(List<LockPatternView.Cell> pattern){
  if (mLockPatternUtils.checkPattern(pattern)) {
    mCallback.reportSuccessfulUnlockAttempt();
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
    mTotalFailedPatternAttempts=0;
    mCallback.dismiss(true);
  }
 else {
    if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
      mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
    }
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
    if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
      mTotalFailedPatternAttempts++;
      mFailedPatternAttemptsSinceLastTimeout++;
      mCallback.reportFailedUnlockAttempt();
    }
    if (mFailedPatternAttemptsSinceLastTimeout >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
      long deadline=mLockPatternUtils.setLockoutAttemptDeadline();
      handleAttemptLockout(deadline);
    }
 else {
      mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern,true);
      mLockPatternView.postDelayed(mCancelPatternRunnable,PATTERN_CLEAR_TIMEOUT_MS);
    }
  }
}

Fixed version (ground truth):
public void onPatternDetected(List<LockPatternView.Cell> pattern){
  if (mLockPatternUtils.checkPattern(pattern)) {
    mCallback.reportSuccessfulUnlockAttempt();
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
    mCallback.dismiss(true);
  }
 else {
    if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
      mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
    }
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
    boolean registeredAttempt=pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL;
    if (registeredAttempt) {
      mCallback.reportFailedUnlockAttempt();
    }
    int attempts=mKeyguardUpdateMonitor.getFailedUnlockAttempts();
    if (registeredAttempt && 0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
      long deadline=mLockPatternUtils.setLockoutAttemptDeadline();
      handleAttemptLockout(deadline);
    }
 else {
      mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern,true);
      mLockPatternView.postDelayed(mCancelPatternRunnable,PATTERN_CLEAR_TIMEOUT_MS);
    }
  }
}
Program: 199627
Project: 199627
Buggy source:
@Override public void onFinish(){
  mLockPatternView.setEnabled(true);
  displayDefaultSecurityMessage();
  mFailedPatternAttemptsSinceLastTimeout=0;
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}

Fixed version (ground truth):
@Override public void onFinish(){
  mLockPatternView.setEnabled(true);
  displayDefaultSecurityMessage();
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}
Program: 199628
Project: 199628
Buggy source:
private void displayDefaultSecurityMessage(){
  if (KeyguardUpdateMonitor.getInstance(mContext).getMaxBiometricUnlockAttemptsReached()) {
    mSecurityMessageDisplay.setMessage(R.string.faceunlock_multiple_failures,true);
  }
 else {
    mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions,false);
  }
}

Fixed version (ground truth):
private void displayDefaultSecurityMessage(){
  if (mKeyguardUpdateMonitor.getMaxBiometricUnlockAttemptsReached()) {
    mSecurityMessageDisplay.setMessage(R.string.faceunlock_multiple_failures,true);
  }
 else {
    mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions,false);
  }
}
Program: 199629
Project: 199629
Buggy source:
public void reset(){
  mLockPatternView.enableInput();
  mLockPatternView.setEnabled(true);
  mLockPatternView.clearPattern();
  long deadline=mLockPatternUtils.getLockoutAttemptDeadline();
  if (deadline != 0) {
    handleAttemptLockout(deadline);
  }
 else {
    displayDefaultSecurityMessage();
  }
  if (mCallback.isVerifyUnlockOnly()) {
    updateFooter(FooterMode.VerifyUnlocked);
  }
 else   if (mEnableFallback && (mTotalFailedPatternAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}

Fixed version (ground truth):
public void reset(){
  mLockPatternView.enableInput();
  mLockPatternView.setEnabled(true);
  mLockPatternView.clearPattern();
  long deadline=mLockPatternUtils.getLockoutAttemptDeadline();
  if (deadline != 0) {
    handleAttemptLockout(deadline);
  }
 else {
    displayDefaultSecurityMessage();
  }
  if (mCallback.isVerifyUnlockOnly()) {
    updateFooter(FooterMode.VerifyUnlocked);
  }
 else   if (mEnableFallback && (mKeyguardUpdateMonitor.getFailedUnlockAttempts() >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}
Program: 199630
Project: 199630
Buggy source:
private void handleAttemptLockout(long elapsedRealtimeDeadline){
  mLockPatternView.clearPattern();
  mLockPatternView.setEnabled(false);
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
  mCountdownTimer=new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime,1000){
    @Override public void onTick(    long millisUntilFinished){
      final int secondsRemaining=(int)(millisUntilFinished / 1000);
      mSecurityMessageDisplay.setMessage(R.string.kg_too_many_failed_attempts_countdown,true,secondsRemaining);
    }
    @Override public void onFinish(){
      mLockPatternView.setEnabled(true);
      displayDefaultSecurityMessage();
      mFailedPatternAttemptsSinceLastTimeout=0;
      if (mEnableFallback) {
        updateFooter(FooterMode.ForgotLockPattern);
      }
 else {
        updateFooter(FooterMode.Normal);
      }
    }
  }
.start();
}

Fixed version (ground truth):
private void handleAttemptLockout(long elapsedRealtimeDeadline){
  mLockPatternView.clearPattern();
  mLockPatternView.setEnabled(false);
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
  mCountdownTimer=new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime,1000){
    @Override public void onTick(    long millisUntilFinished){
      final int secondsRemaining=(int)(millisUntilFinished / 1000);
      mSecurityMessageDisplay.setMessage(R.string.kg_too_many_failed_attempts_countdown,true,secondsRemaining);
    }
    @Override public void onFinish(){
      mLockPatternView.setEnabled(true);
      displayDefaultSecurityMessage();
      if (mEnableFallback) {
        updateFooter(FooterMode.ForgotLockPattern);
      }
 else {
        updateFooter(FooterMode.Normal);
      }
    }
  }
.start();
}
Program: 199631
Project: 199631
Buggy source:
/** 
 * Retrieve the statistics object for a particular service, creating if needed.
 */
public Uid.Pkg.Serv getServiceStatsLocked(int uid,String pkg,String name){
  Uid u=getUidStatsLocked(uid);
  return u.getServiceStatsLocked(pkg,name);
}

Fixed version (ground truth):
/** 
 * Retrieve the statistics object for a particular service, creating if needed.
 */
public Uid.Pkg.Serv getServiceStatsLocked(int uid,String pkg,String name){
  uid=mapUid(uid);
  Uid u=getUidStatsLocked(uid);
  return u.getServiceStatsLocked(pkg,name);
}
Program: 199632
Project: 199632
Buggy source:
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Pkg getPackageStatsLocked(int uid,String pkg){
  Uid u=getUidStatsLocked(uid);
  return u.getPackageStatsLocked(pkg);
}

Fixed version (ground truth):
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Pkg getPackageStatsLocked(int uid,String pkg){
  uid=mapUid(uid);
  Uid u=getUidStatsLocked(uid);
  return u.getPackageStatsLocked(pkg);
}
Program: 199633
Project: 199633
Buggy source:
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Proc getProcessStatsLocked(int uid,String name){
  Uid u=getUidStatsLocked(uid);
  return u.getProcessStatsLocked(name);
}

Fixed version (ground truth):
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Proc getProcessStatsLocked(int uid,String name){
  uid=mapUid(uid);
  Uid u=getUidStatsLocked(uid);
  return u.getProcessStatsLocked(name);
}
Program: 199634
Project: 199634
Buggy source:
public void noteWifiOffLocked(){
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mWifiOn) {
    mHistoryCur.states&=~HistoryItem.STATE_WIFI_ON_FLAG;
    if (DEBUG_HISTORY)     Slog.v(TAG,"String_Node_Str" + Integer.toHexString(mHistoryCur.states));
    addHistoryRecordLocked(elapsedRealtime);
    mWifiOn=false;
    mWifiOnTimer.stopRunningLocked(elapsedRealtime);
  }
  if (mWifiOnUid >= 0) {
    getUidStatsLocked(mWifiOnUid).noteWifiStoppedLocked(elapsedRealtime);
    mWifiOnUid=-1;
  }
}

Fixed version (ground truth):
public void noteWifiOffLocked(){
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mWifiOn) {
    mHistoryCur.states&=~HistoryItem.STATE_WIFI_ON_FLAG;
    if (DEBUG_HISTORY)     Slog.v(TAG,"String_Node_Str" + Integer.toHexString(mHistoryCur.states));
    addHistoryRecordLocked(elapsedRealtime);
    mWifiOn=false;
    mWifiOnTimer.stopRunningLocked(elapsedRealtime);
  }
}
Program: 199636
Project: 199636
Buggy source:
/** 
 * Called when a wake lock is changing.
 */
public void onWakeLockChanging(int flags,String tag,String packageName,int ownerUid,int ownerPid,WorkSource workSource,String historyTag,int newFlags,String newTag,String newPackageName,int newOwnerUid,int newOwnerPid,WorkSource newWorkSource,String newHistoryTag){
  final int monitorType=getBatteryStatsWakeLockMonitorType(flags);
  final int newMonitorType=getBatteryStatsWakeLockMonitorType(newFlags);
  boolean unimportantForLogging=(flags & PowerManager.UNIMPORTANT_FOR_LOGGING) != 0 && ownerUid == Process.SYSTEM_UID;
  if (workSource != null && newWorkSource != null) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + newFlags + "String_Node_Str"+ newTag+ "String_Node_Str"+ newPackageName+ "String_Node_Str"+ newOwnerUid+ "String_Node_Str"+ newOwnerPid+ "String_Node_Str"+ newWorkSource);
    }
    try {
      mBatteryStats.noteChangeWakelockFromSource(workSource,ownerPid,tag,monitorType,newWorkSource,newOwnerPid,newTag,newHistoryTag,newMonitorType,unimportantForLogging);
    }
 catch (    RemoteException ex) {
    }
  }
 else {
    onWakeLockReleased(flags,tag,packageName,ownerUid,ownerPid,workSource);
    onWakeLockAcquired(newFlags,newTag,newPackageName,newOwnerUid,newOwnerPid,newWorkSource,newHistoryTag);
  }
}

Fixed version (ground truth):
/** 
 * Called when a wake lock is changing.
 */
public void onWakeLockChanging(int flags,String tag,String packageName,int ownerUid,int ownerPid,WorkSource workSource,String historyTag,int newFlags,String newTag,String newPackageName,int newOwnerUid,int newOwnerPid,WorkSource newWorkSource,String newHistoryTag){
  if (workSource != null && newWorkSource != null) {
    final int monitorType=getBatteryStatsWakeLockMonitorType(flags);
    final int newMonitorType=getBatteryStatsWakeLockMonitorType(newFlags);
    boolean unimportantForLogging=(newFlags & PowerManager.UNIMPORTANT_FOR_LOGGING) != 0 && newOwnerUid == Process.SYSTEM_UID;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + newFlags + "String_Node_Str"+ newTag+ "String_Node_Str"+ newPackageName+ "String_Node_Str"+ newOwnerUid+ "String_Node_Str"+ newOwnerPid+ "String_Node_Str"+ newWorkSource);
    }
    try {
      mBatteryStats.noteChangeWakelockFromSource(workSource,ownerPid,tag,monitorType,newWorkSource,newOwnerPid,newTag,newHistoryTag,newMonitorType,unimportantForLogging);
    }
 catch (    RemoteException ex) {
    }
  }
 else {
    onWakeLockReleased(flags,tag,packageName,ownerUid,ownerPid,workSource);
    onWakeLockAcquired(newFlags,newTag,newPackageName,newOwnerUid,newOwnerPid,newWorkSource,newHistoryTag);
  }
}
Program: 199637
Project: 199637
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  mMenu.performItemAction(mAdapter.getItem(position),0);
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  mMenu.performItemAction(mAdapter.getItem(position),this,0);
}
Program: 199638
Project: 199638
Buggy source:
private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu){
  if (mPresenters.isEmpty())   return false;
  boolean result=false;
  for (  WeakReference<MenuPresenter> ref : mPresenters) {
    final MenuPresenter presenter=ref.get();
    if (presenter == null) {
      mPresenters.remove(ref);
    }
 else     if (!result) {
      result=presenter.onSubMenuSelected(subMenu);
    }
  }
  return result;
}

Fixed version (ground truth):
private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu,MenuPresenter preferredPresenter){
  if (mPresenters.isEmpty())   return false;
  boolean result=false;
  if (preferredPresenter != null) {
    result=preferredPresenter.onSubMenuSelected(subMenu);
  }
  for (  WeakReference<MenuPresenter> ref : mPresenters) {
    final MenuPresenter presenter=ref.get();
    if (presenter == null) {
      mPresenters.remove(ref);
    }
 else     if (!result) {
      result=presenter.onSubMenuSelected(subMenu);
    }
  }
  return result;
}
Program: 199639
Project: 199639
Buggy source:
public boolean performItemAction(MenuItem item,int flags){
  MenuItemImpl itemImpl=(MenuItemImpl)item;
  if (itemImpl == null || !itemImpl.isEnabled()) {
    return false;
  }
  boolean invoked=itemImpl.invoke();
  final ActionProvider provider=item.getActionProvider();
  final boolean providerHasSubMenu=provider != null && provider.hasSubMenu();
  if (itemImpl.hasCollapsibleActionView()) {
    invoked|=itemImpl.expandActionView();
    if (invoked)     close(true);
  }
 else   if (itemImpl.hasSubMenu() || providerHasSubMenu) {
    close(false);
    if (!itemImpl.hasSubMenu()) {
      itemImpl.setSubMenu(new SubMenuBuilder(getContext(),this,itemImpl));
    }
    final SubMenuBuilder subMenu=(SubMenuBuilder)itemImpl.getSubMenu();
    if (providerHasSubMenu) {
      provider.onPrepareSubMenu(subMenu);
    }
    invoked|=dispatchSubMenuSelected(subMenu);
    if (!invoked)     close(true);
  }
 else {
    if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
      close(true);
    }
  }
  return invoked;
}

Fixed version (ground truth):
public boolean performItemAction(MenuItem item,MenuPresenter preferredPresenter,int flags){
  MenuItemImpl itemImpl=(MenuItemImpl)item;
  if (itemImpl == null || !itemImpl.isEnabled()) {
    return false;
  }
  boolean invoked=itemImpl.invoke();
  final ActionProvider provider=item.getActionProvider();
  final boolean providerHasSubMenu=provider != null && provider.hasSubMenu();
  if (itemImpl.hasCollapsibleActionView()) {
    invoked|=itemImpl.expandActionView();
    if (invoked)     close(true);
  }
 else   if (itemImpl.hasSubMenu() || providerHasSubMenu) {
    close(false);
    if (!itemImpl.hasSubMenu()) {
      itemImpl.setSubMenu(new SubMenuBuilder(getContext(),this,itemImpl));
    }
    final SubMenuBuilder subMenu=(SubMenuBuilder)itemImpl.getSubMenu();
    if (providerHasSubMenu) {
      provider.onPrepareSubMenu(subMenu);
    }
    invoked|=dispatchSubMenuSelected(subMenu,preferredPresenter);
    if (!invoked)     close(true);
  }
 else {
    if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
      close(true);
    }
  }
  return invoked;
}
Program: 199640
Project: 199640
Buggy source:
public KeyguardPatternView(Context context,AttributeSet attrs){
  super(context,attrs);
}

Fixed version (ground truth):
public KeyguardPatternView(Context context,AttributeSet attrs){
  super(context,attrs);
  mKeyguardUpdateMonitor=KeyguardUpdateMonitor.getInstance(mContext);
}
Program: 199641
Project: 199641
Buggy source:
public void onPatternDetected(List<LockPatternView.Cell> pattern){
  if (mLockPatternUtils.checkPattern(pattern)) {
    mCallback.reportSuccessfulUnlockAttempt();
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
    mTotalFailedPatternAttempts=0;
    mCallback.dismiss(true);
  }
 else {
    if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
      mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
    }
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
    if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
      mTotalFailedPatternAttempts++;
      mFailedPatternAttemptsSinceLastTimeout++;
      mCallback.reportFailedUnlockAttempt();
    }
    if (mFailedPatternAttemptsSinceLastTimeout >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
      long deadline=mLockPatternUtils.setLockoutAttemptDeadline();
      handleAttemptLockout(deadline);
    }
 else {
      mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern,true);
      mLockPatternView.postDelayed(mCancelPatternRunnable,PATTERN_CLEAR_TIMEOUT_MS);
    }
  }
}

Fixed version (ground truth):
public void onPatternDetected(List<LockPatternView.Cell> pattern){
  if (mLockPatternUtils.checkPattern(pattern)) {
    mCallback.reportSuccessfulUnlockAttempt();
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
    mCallback.dismiss(true);
  }
 else {
    if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
      mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
    }
    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
    boolean registeredAttempt=pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL;
    if (registeredAttempt) {
      mCallback.reportFailedUnlockAttempt();
    }
    int attempts=mKeyguardUpdateMonitor.getFailedUnlockAttempts();
    if (registeredAttempt && 0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
      long deadline=mLockPatternUtils.setLockoutAttemptDeadline();
      handleAttemptLockout(deadline);
    }
 else {
      mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern,true);
      mLockPatternView.postDelayed(mCancelPatternRunnable,PATTERN_CLEAR_TIMEOUT_MS);
    }
  }
}
Program: 199642
Project: 199642
Buggy source:
@Override public void onFinish(){
  mLockPatternView.setEnabled(true);
  displayDefaultSecurityMessage();
  mFailedPatternAttemptsSinceLastTimeout=0;
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}

Fixed version (ground truth):
@Override public void onFinish(){
  mLockPatternView.setEnabled(true);
  displayDefaultSecurityMessage();
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}
Program: 199643
Project: 199643
Buggy source:
private void displayDefaultSecurityMessage(){
  if (KeyguardUpdateMonitor.getInstance(mContext).getMaxBiometricUnlockAttemptsReached()) {
    mSecurityMessageDisplay.setMessage(R.string.faceunlock_multiple_failures,true);
  }
 else {
    mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions,false);
  }
}

Fixed version (ground truth):
private void displayDefaultSecurityMessage(){
  if (mKeyguardUpdateMonitor.getMaxBiometricUnlockAttemptsReached()) {
    mSecurityMessageDisplay.setMessage(R.string.faceunlock_multiple_failures,true);
  }
 else {
    mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions,false);
  }
}
Program: 199644
Project: 199644
Buggy source:
public void reset(){
  mLockPatternView.enableInput();
  mLockPatternView.setEnabled(true);
  mLockPatternView.clearPattern();
  long deadline=mLockPatternUtils.getLockoutAttemptDeadline();
  if (deadline != 0) {
    handleAttemptLockout(deadline);
  }
 else {
    displayDefaultSecurityMessage();
  }
  if (mCallback.isVerifyUnlockOnly()) {
    updateFooter(FooterMode.VerifyUnlocked);
  }
 else   if (mEnableFallback && (mTotalFailedPatternAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}

Fixed version (ground truth):
public void reset(){
  mLockPatternView.enableInput();
  mLockPatternView.setEnabled(true);
  mLockPatternView.clearPattern();
  long deadline=mLockPatternUtils.getLockoutAttemptDeadline();
  if (deadline != 0) {
    handleAttemptLockout(deadline);
  }
 else {
    displayDefaultSecurityMessage();
  }
  if (mCallback.isVerifyUnlockOnly()) {
    updateFooter(FooterMode.VerifyUnlocked);
  }
 else   if (mEnableFallback && (mKeyguardUpdateMonitor.getFailedUnlockAttempts() >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
 else {
    updateFooter(FooterMode.Normal);
  }
}
Program: 199645
Project: 199645
Buggy source:
private void handleAttemptLockout(long elapsedRealtimeDeadline){
  mLockPatternView.clearPattern();
  mLockPatternView.setEnabled(false);
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
  mCountdownTimer=new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime,1000){
    @Override public void onTick(    long millisUntilFinished){
      final int secondsRemaining=(int)(millisUntilFinished / 1000);
      mSecurityMessageDisplay.setMessage(R.string.kg_too_many_failed_attempts_countdown,true,secondsRemaining);
    }
    @Override public void onFinish(){
      mLockPatternView.setEnabled(true);
      displayDefaultSecurityMessage();
      mFailedPatternAttemptsSinceLastTimeout=0;
      if (mEnableFallback) {
        updateFooter(FooterMode.ForgotLockPattern);
      }
 else {
        updateFooter(FooterMode.Normal);
      }
    }
  }
.start();
}

Fixed version (ground truth):
private void handleAttemptLockout(long elapsedRealtimeDeadline){
  mLockPatternView.clearPattern();
  mLockPatternView.setEnabled(false);
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mEnableFallback) {
    updateFooter(FooterMode.ForgotLockPattern);
  }
  mCountdownTimer=new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime,1000){
    @Override public void onTick(    long millisUntilFinished){
      final int secondsRemaining=(int)(millisUntilFinished / 1000);
      mSecurityMessageDisplay.setMessage(R.string.kg_too_many_failed_attempts_countdown,true,secondsRemaining);
    }
    @Override public void onFinish(){
      mLockPatternView.setEnabled(true);
      displayDefaultSecurityMessage();
      if (mEnableFallback) {
        updateFooter(FooterMode.ForgotLockPattern);
      }
 else {
        updateFooter(FooterMode.Normal);
      }
    }
  }
.start();
}
Program: 199646
Project: 199646
Buggy source:
/** 
 * Retrieve the statistics object for a particular service, creating if needed.
 */
public Uid.Pkg.Serv getServiceStatsLocked(int uid,String pkg,String name){
  Uid u=getUidStatsLocked(uid);
  return u.getServiceStatsLocked(pkg,name);
}

Fixed version (ground truth):
/** 
 * Retrieve the statistics object for a particular service, creating if needed.
 */
public Uid.Pkg.Serv getServiceStatsLocked(int uid,String pkg,String name){
  uid=mapUid(uid);
  Uid u=getUidStatsLocked(uid);
  return u.getServiceStatsLocked(pkg,name);
}
Program: 199647
Project: 199647
Buggy source:
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Pkg getPackageStatsLocked(int uid,String pkg){
  Uid u=getUidStatsLocked(uid);
  return u.getPackageStatsLocked(pkg);
}

Fixed version (ground truth):
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Pkg getPackageStatsLocked(int uid,String pkg){
  uid=mapUid(uid);
  Uid u=getUidStatsLocked(uid);
  return u.getPackageStatsLocked(pkg);
}
Program: 199648
Project: 199648
Buggy source:
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Proc getProcessStatsLocked(int uid,String name){
  Uid u=getUidStatsLocked(uid);
  return u.getProcessStatsLocked(name);
}

Fixed version (ground truth):
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Proc getProcessStatsLocked(int uid,String name){
  uid=mapUid(uid);
  Uid u=getUidStatsLocked(uid);
  return u.getProcessStatsLocked(name);
}
Program: 199649
Project: 199649
Buggy source:
public void noteWifiOffLocked(){
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mWifiOn) {
    mHistoryCur.states&=~HistoryItem.STATE_WIFI_ON_FLAG;
    if (DEBUG_HISTORY)     Slog.v(TAG,"String_Node_Str" + Integer.toHexString(mHistoryCur.states));
    addHistoryRecordLocked(elapsedRealtime);
    mWifiOn=false;
    mWifiOnTimer.stopRunningLocked(elapsedRealtime);
  }
  if (mWifiOnUid >= 0) {
    getUidStatsLocked(mWifiOnUid).noteWifiStoppedLocked(elapsedRealtime);
    mWifiOnUid=-1;
  }
}

Fixed version (ground truth):
public void noteWifiOffLocked(){
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mWifiOn) {
    mHistoryCur.states&=~HistoryItem.STATE_WIFI_ON_FLAG;
    if (DEBUG_HISTORY)     Slog.v(TAG,"String_Node_Str" + Integer.toHexString(mHistoryCur.states));
    addHistoryRecordLocked(elapsedRealtime);
    mWifiOn=false;
    mWifiOnTimer.stopRunningLocked(elapsedRealtime);
  }
}
Program: 199651
Project: 199651
Buggy source:
/** 
 * Called when a wake lock is changing.
 */
public void onWakeLockChanging(int flags,String tag,String packageName,int ownerUid,int ownerPid,WorkSource workSource,String historyTag,int newFlags,String newTag,String newPackageName,int newOwnerUid,int newOwnerPid,WorkSource newWorkSource,String newHistoryTag){
  final int monitorType=getBatteryStatsWakeLockMonitorType(flags);
  final int newMonitorType=getBatteryStatsWakeLockMonitorType(newFlags);
  boolean unimportantForLogging=(flags & PowerManager.UNIMPORTANT_FOR_LOGGING) != 0 && ownerUid == Process.SYSTEM_UID;
  if (workSource != null && newWorkSource != null) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + newFlags + "String_Node_Str"+ newTag+ "String_Node_Str"+ newPackageName+ "String_Node_Str"+ newOwnerUid+ "String_Node_Str"+ newOwnerPid+ "String_Node_Str"+ newWorkSource);
    }
    try {
      mBatteryStats.noteChangeWakelockFromSource(workSource,ownerPid,tag,monitorType,newWorkSource,newOwnerPid,newTag,newHistoryTag,newMonitorType,unimportantForLogging);
    }
 catch (    RemoteException ex) {
    }
  }
 else {
    onWakeLockReleased(flags,tag,packageName,ownerUid,ownerPid,workSource);
    onWakeLockAcquired(newFlags,newTag,newPackageName,newOwnerUid,newOwnerPid,newWorkSource,newHistoryTag);
  }
}

Fixed version (ground truth):
/** 
 * Called when a wake lock is changing.
 */
public void onWakeLockChanging(int flags,String tag,String packageName,int ownerUid,int ownerPid,WorkSource workSource,String historyTag,int newFlags,String newTag,String newPackageName,int newOwnerUid,int newOwnerPid,WorkSource newWorkSource,String newHistoryTag){
  if (workSource != null && newWorkSource != null) {
    final int monitorType=getBatteryStatsWakeLockMonitorType(flags);
    final int newMonitorType=getBatteryStatsWakeLockMonitorType(newFlags);
    boolean unimportantForLogging=(newFlags & PowerManager.UNIMPORTANT_FOR_LOGGING) != 0 && newOwnerUid == Process.SYSTEM_UID;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + newFlags + "String_Node_Str"+ newTag+ "String_Node_Str"+ newPackageName+ "String_Node_Str"+ newOwnerUid+ "String_Node_Str"+ newOwnerPid+ "String_Node_Str"+ newWorkSource);
    }
    try {
      mBatteryStats.noteChangeWakelockFromSource(workSource,ownerPid,tag,monitorType,newWorkSource,newOwnerPid,newTag,newHistoryTag,newMonitorType,unimportantForLogging);
    }
 catch (    RemoteException ex) {
    }
  }
 else {
    onWakeLockReleased(flags,tag,packageName,ownerUid,ownerPid,workSource);
    onWakeLockAcquired(newFlags,newTag,newPackageName,newOwnerUid,newOwnerPid,newWorkSource,newHistoryTag);
  }
}
Program: 199652
Project: 199652
Buggy source:
/** 
 * Retrieve the statistics object for a particular service, creating if needed.
 */
public Uid.Pkg.Serv getServiceStatsLocked(int uid,String pkg,String name){
  Uid u=getUidStatsLocked(uid);
  return u.getServiceStatsLocked(pkg,name);
}

Fixed version (ground truth):
/** 
 * Retrieve the statistics object for a particular service, creating if needed.
 */
public Uid.Pkg.Serv getServiceStatsLocked(int uid,String pkg,String name){
  uid=mapUid(uid);
  Uid u=getUidStatsLocked(uid);
  return u.getServiceStatsLocked(pkg,name);
}
Program: 199653
Project: 199653
Buggy source:
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Pkg getPackageStatsLocked(int uid,String pkg){
  Uid u=getUidStatsLocked(uid);
  return u.getPackageStatsLocked(pkg);
}

Fixed version (ground truth):
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Pkg getPackageStatsLocked(int uid,String pkg){
  uid=mapUid(uid);
  Uid u=getUidStatsLocked(uid);
  return u.getPackageStatsLocked(pkg);
}
Program: 199654
Project: 199654
Buggy source:
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Proc getProcessStatsLocked(int uid,String name){
  Uid u=getUidStatsLocked(uid);
  return u.getProcessStatsLocked(name);
}

Fixed version (ground truth):
/** 
 * Retrieve the statistics object for a particular process, creating if needed.
 */
public Uid.Proc getProcessStatsLocked(int uid,String name){
  uid=mapUid(uid);
  Uid u=getUidStatsLocked(uid);
  return u.getProcessStatsLocked(name);
}
Program: 199655
Project: 199655
Buggy source:
public void noteWifiOffLocked(){
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mWifiOn) {
    mHistoryCur.states&=~HistoryItem.STATE_WIFI_ON_FLAG;
    if (DEBUG_HISTORY)     Slog.v(TAG,"String_Node_Str" + Integer.toHexString(mHistoryCur.states));
    addHistoryRecordLocked(elapsedRealtime);
    mWifiOn=false;
    mWifiOnTimer.stopRunningLocked(elapsedRealtime);
  }
  if (mWifiOnUid >= 0) {
    getUidStatsLocked(mWifiOnUid).noteWifiStoppedLocked(elapsedRealtime);
    mWifiOnUid=-1;
  }
}

Fixed version (ground truth):
public void noteWifiOffLocked(){
  final long elapsedRealtime=SystemClock.elapsedRealtime();
  if (mWifiOn) {
    mHistoryCur.states&=~HistoryItem.STATE_WIFI_ON_FLAG;
    if (DEBUG_HISTORY)     Slog.v(TAG,"String_Node_Str" + Integer.toHexString(mHistoryCur.states));
    addHistoryRecordLocked(elapsedRealtime);
    mWifiOn=false;
    mWifiOnTimer.stopRunningLocked(elapsedRealtime);
  }
}
Program: 199657
Project: 199657
Buggy source:
/** 
 * Called when a wake lock is changing.
 */
public void onWakeLockChanging(int flags,String tag,String packageName,int ownerUid,int ownerPid,WorkSource workSource,String historyTag,int newFlags,String newTag,String newPackageName,int newOwnerUid,int newOwnerPid,WorkSource newWorkSource,String newHistoryTag){
  final int monitorType=getBatteryStatsWakeLockMonitorType(flags);
  final int newMonitorType=getBatteryStatsWakeLockMonitorType(newFlags);
  boolean unimportantForLogging=(flags & PowerManager.UNIMPORTANT_FOR_LOGGING) != 0 && ownerUid == Process.SYSTEM_UID;
  if (workSource != null && newWorkSource != null) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + newFlags + "String_Node_Str"+ newTag+ "String_Node_Str"+ newPackageName+ "String_Node_Str"+ newOwnerUid+ "String_Node_Str"+ newOwnerPid+ "String_Node_Str"+ newWorkSource);
    }
    try {
      mBatteryStats.noteChangeWakelockFromSource(workSource,ownerPid,tag,monitorType,newWorkSource,newOwnerPid,newTag,newHistoryTag,newMonitorType,unimportantForLogging);
    }
 catch (    RemoteException ex) {
    }
  }
 else {
    onWakeLockReleased(flags,tag,packageName,ownerUid,ownerPid,workSource);
    onWakeLockAcquired(newFlags,newTag,newPackageName,newOwnerUid,newOwnerPid,newWorkSource,newHistoryTag);
  }
}

Fixed version (ground truth):
/** 
 * Called when a wake lock is changing.
 */
public void onWakeLockChanging(int flags,String tag,String packageName,int ownerUid,int ownerPid,WorkSource workSource,String historyTag,int newFlags,String newTag,String newPackageName,int newOwnerUid,int newOwnerPid,WorkSource newWorkSource,String newHistoryTag){
  if (workSource != null && newWorkSource != null) {
    final int monitorType=getBatteryStatsWakeLockMonitorType(flags);
    final int newMonitorType=getBatteryStatsWakeLockMonitorType(newFlags);
    boolean unimportantForLogging=(newFlags & PowerManager.UNIMPORTANT_FOR_LOGGING) != 0 && newOwnerUid == Process.SYSTEM_UID;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + newFlags + "String_Node_Str"+ newTag+ "String_Node_Str"+ newPackageName+ "String_Node_Str"+ newOwnerUid+ "String_Node_Str"+ newOwnerPid+ "String_Node_Str"+ newWorkSource);
    }
    try {
      mBatteryStats.noteChangeWakelockFromSource(workSource,ownerPid,tag,monitorType,newWorkSource,newOwnerPid,newTag,newHistoryTag,newMonitorType,unimportantForLogging);
    }
 catch (    RemoteException ex) {
    }
  }
 else {
    onWakeLockReleased(flags,tag,packageName,ownerUid,ownerPid,workSource);
    onWakeLockAcquired(newFlags,newTag,newPackageName,newOwnerUid,newOwnerPid,newWorkSource,newHistoryTag);
  }
}
Program: 199658
Project: 199658
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  mMenu.performItemAction(mAdapter.getItem(position),0);
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  mMenu.performItemAction(mAdapter.getItem(position),this,0);
}
Program: 199659
Project: 199659
Buggy source:
private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu){
  if (mPresenters.isEmpty())   return false;
  boolean result=false;
  for (  WeakReference<MenuPresenter> ref : mPresenters) {
    final MenuPresenter presenter=ref.get();
    if (presenter == null) {
      mPresenters.remove(ref);
    }
 else     if (!result) {
      result=presenter.onSubMenuSelected(subMenu);
    }
  }
  return result;
}

Fixed version (ground truth):
private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu,MenuPresenter preferredPresenter){
  if (mPresenters.isEmpty())   return false;
  boolean result=false;
  if (preferredPresenter != null) {
    result=preferredPresenter.onSubMenuSelected(subMenu);
  }
  for (  WeakReference<MenuPresenter> ref : mPresenters) {
    final MenuPresenter presenter=ref.get();
    if (presenter == null) {
      mPresenters.remove(ref);
    }
 else     if (!result) {
      result=presenter.onSubMenuSelected(subMenu);
    }
  }
  return result;
}