Program: 197534
Project: 197534
Buggy source:
private void completePauseLocked(boolean resumeNext){
  ActivityRecord prev=mPausingActivity;
  if (DEBUG_PAUSE)   Slog.v(TAG,"String_Node_Str" + prev);
  if (prev != null) {
    prev.state=ActivityState.PAUSED;
    if (prev.finishing) {
      if (DEBUG_PAUSE)       Slog.v(TAG,"String_Node_Str" + prev);
      prev=finishCurrentActivityLocked(prev,FINISH_AFTER_VISIBLE,false);
    }
 else     if (prev.app != null) {
      if (DEBUG_PAUSE)       Slog.v(TAG,"String_Node_Str" + prev);
      if (prev.waitingVisible) {
        prev.waitingVisible=false;
        mStackSupervisor.mWaitingVisibleActivities.remove(prev);
        if (DEBUG_SWITCH || DEBUG_PAUSE)         Slog.v(TAG,"String_Node_Str" + prev);
      }
      if (prev.configDestroy) {
        if (DEBUG_PAUSE)         Slog.v(TAG,"String_Node_Str" + prev);
        destroyActivityLocked(prev,true,"String_Node_Str");
      }
 else       if (!hasVisibleBehindActivity()) {
        mStackSupervisor.mStoppingActivities.add(prev);
        if (mStackSupervisor.mStoppingActivities.size() > 3 || prev.frontOfTask && mTaskHistory.size() <= 1) {
          if (DEBUG_PAUSE)           Slog.v(TAG,"String_Node_Str");
          mStackSupervisor.scheduleIdleLocked();
        }
 else {
          mStackSupervisor.checkReadyForSleepLocked();
        }
      }
    }
 else {
      if (DEBUG_PAUSE)       Slog.v(TAG,"String_Node_Str" + prev);
      prev=null;
    }
    mPausingActivity=null;
  }
  if (resumeNext) {
    final ActivityStack topStack=mStackSupervisor.getFocusedStack();
    if (!mService.isSleepingOrShuttingDown()) {
      mStackSupervisor.resumeTopActivitiesLocked(topStack,prev,null);
    }
 else {
      mStackSupervisor.checkReadyForSleepLocked();
      ActivityRecord top=topStack.topRunningActivityLocked(null);
      if (top == null || (prev != null && top != prev)) {
        mStackSupervisor.resumeTopActivitiesLocked(topStack,null,null);
      }
    }
  }
  if (prev != null) {
    prev.resumeKeyDispatchingLocked();
    if (prev.app != null && prev.cpuTimeAtResume > 0 && mService.mBatteryStatsService.isOnBattery()) {
      long diff;
synchronized (mService.mProcessCpuThread) {
        diff=mService.mProcessCpuTracker.getCpuTimeForPid(prev.app.pid) - prev.cpuTimeAtResume;
      }
      if (diff > 0) {
        BatteryStatsImpl bsi=mService.mBatteryStatsService.getActiveStatistics();
synchronized (bsi) {
          BatteryStatsImpl.Uid.Proc ps=bsi.getProcessStatsLocked(prev.info.applicationInfo.uid,prev.info.packageName);
          if (ps != null) {
            ps.addForegroundTimeLocked(diff);
          }
        }
      }
    }
    prev.cpuTimeAtResume=0;
  }
}

Fixed version (ground truth):
private void completePauseLocked(boolean resumeNext){
  ActivityRecord prev=mPausingActivity;
  if (DEBUG_PAUSE)   Slog.v(TAG,"String_Node_Str" + prev);
  if (prev != null) {
    prev.state=ActivityState.PAUSED;
    if (prev.finishing) {
      if (DEBUG_PAUSE)       Slog.v(TAG,"String_Node_Str" + prev);
      prev=finishCurrentActivityLocked(prev,FINISH_AFTER_VISIBLE,false);
    }
 else     if (prev.app != null) {
      if (DEBUG_PAUSE)       Slog.v(TAG,"String_Node_Str" + prev);
      if (prev.waitingVisible) {
        prev.waitingVisible=false;
        mStackSupervisor.mWaitingVisibleActivities.remove(prev);
        if (DEBUG_SWITCH || DEBUG_PAUSE)         Slog.v(TAG,"String_Node_Str" + prev);
      }
      if (prev.configDestroy) {
        if (DEBUG_PAUSE)         Slog.v(TAG,"String_Node_Str" + prev);
        destroyActivityLocked(prev,true,"String_Node_Str");
      }
 else       if (!hasVisibleBehindActivity()) {
        mStackSupervisor.mStoppingActivities.add(prev);
        if (mStackSupervisor.mStoppingActivities.size() > 3 || prev.frontOfTask && mTaskHistory.size() <= 1) {
          if (DEBUG_PAUSE)           Slog.v(TAG,"String_Node_Str");
          mStackSupervisor.scheduleIdleLocked();
        }
 else {
          mStackSupervisor.checkReadyForSleepLocked();
        }
      }
    }
 else {
      if (DEBUG_PAUSE)       Slog.v(TAG,"String_Node_Str" + prev);
      prev=null;
    }
    mPausingActivity=null;
  }
  if (resumeNext) {
    final ActivityStack topStack=mStackSupervisor.getFocusedStack();
    if (!mService.isSleepingOrShuttingDown()) {
      mStackSupervisor.resumeTopActivitiesLocked(topStack,prev,null);
    }
 else {
      mStackSupervisor.checkReadyForSleepLocked();
      ActivityRecord top=topStack.topRunningActivityLocked(null);
      if (top == null || (prev != null && top != prev)) {
        mStackSupervisor.resumeTopActivitiesLocked(topStack,null,null);
      }
    }
  }
  if (prev != null) {
    prev.resumeKeyDispatchingLocked();
    if (prev.app != null && prev.cpuTimeAtResume > 0 && mService.mBatteryStatsService.isOnBattery()) {
      long diff=mService.mProcessCpuTracker.getCpuTimeForPid(prev.app.pid) - prev.cpuTimeAtResume;
      if (diff > 0) {
        BatteryStatsImpl bsi=mService.mBatteryStatsService.getActiveStatistics();
synchronized (bsi) {
          BatteryStatsImpl.Uid.Proc ps=bsi.getProcessStatsLocked(prev.info.applicationInfo.uid,prev.info.packageName);
          if (ps != null) {
            ps.addForegroundTimeLocked(diff);
          }
        }
      }
    }
    prev.cpuTimeAtResume=0;
  }
}