Program: 196056
Project: 196056
Buggy source:
/** 
 * Start pausing the currently resumed activity.  It is an error to call this if there is already an activity being paused or there is no resumed activity.
 * @param userLeaving True if this should result in an onUserLeaving to the current activity.
 * @param uiSleeping True if this is happening with the user interface going to sleep (thescreen turning off).
 * @param resuming True if this is being called as part of resuming the top activity, sowe shouldn't try to instigate a resume here.
 * @param dontWait True if the caller does not want to wait for the pause to complete.  Ifset to true, we will immediately complete the pause here before returning.
 * @return Returns true if an activity now is in the PAUSING state, and we are waiting forit to tell us when it is done.
 */
final boolean startPausingLocked(boolean userLeaving,boolean uiSleeping,boolean resuming,boolean dontWait){
  if (mPausingActivity != null) {
    Slog.wtf(TAG,"String_Node_Str" + mPausingActivity);
    completePauseLocked(false);
  }
  ActivityRecord prev=mResumedActivity;
  if (prev == null) {
    if (!resuming) {
      Slog.wtf(TAG,"String_Node_Str");
      mStackSupervisor.resumeTopActivitiesLocked();
    }
    return false;
  }
  if (mActivityContainer.mParentActivity == null) {
    mStackSupervisor.pauseChildStacks(prev,userLeaving,uiSleeping,resuming,dontWait);
  }
  if (DEBUG_STATES)   Slog.v(TAG,"String_Node_Str" + prev);
 else   if (DEBUG_PAUSE)   Slog.v(TAG,"String_Node_Str" + prev);
  mResumedActivity=null;
  mPausingActivity=prev;
  mLastPausedActivity=prev;
  mLastNoHistoryActivity=(prev.intent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY) != 0 || (prev.info.flags & ActivityInfo.FLAG_NO_HISTORY) != 0 ? prev : null;
  prev.state=ActivityState.PAUSING;
  prev.task.touchActiveTime();
  clearLaunchTime(prev);
  final ActivityRecord next=mStackSupervisor.topRunningActivityLocked();
  if (mService.mHasRecents && (next == null || next.noDisplay || next.task != prev.task)) {
    prev.updateThumbnail(screenshotActivities(prev),null);
  }
  stopFullyDrawnTraceIfNeeded();
  mService.updateCpuStats();
  if (prev.app != null && prev.app.thread != null) {
    if (DEBUG_PAUSE)     Slog.v(TAG,"String_Node_Str" + prev);
    try {
      EventLog.writeEvent(EventLogTags.AM_PAUSE_ACTIVITY,prev.userId,System.identityHashCode(prev),prev.shortComponentName);
      mService.updateUsageStats(prev,false);
      prev.app.thread.schedulePauseActivity(prev.appToken,prev.finishing,userLeaving,prev.configChangeFlags,dontWait);
    }
 catch (    Exception e) {
      Slog.w(TAG,"String_Node_Str",e);
      mPausingActivity=null;
      mLastPausedActivity=null;
      mLastNoHistoryActivity=null;
    }
  }
 else {
    mPausingActivity=null;
    mLastPausedActivity=null;
    mLastNoHistoryActivity=null;
  }
  if (!mService.isSleepingOrShuttingDown()) {
    mStackSupervisor.acquireLaunchWakelock();
  }
  if (mPausingActivity != null) {
    if (!uiSleeping) {
      prev.pauseKeyDispatchingLocked();
    }
 else {
      if (DEBUG_PAUSE)       Slog.v(TAG,"String_Node_Str");
    }
    if (dontWait) {
      completePauseLocked(false);
      return false;
    }
 else {
      Message msg=mHandler.obtainMessage(PAUSE_TIMEOUT_MSG);
      msg.obj=prev;
      prev.pauseTime=SystemClock.uptimeMillis();
      mHandler.sendMessageDelayed(msg,PAUSE_TIMEOUT);
      if (DEBUG_PAUSE)       Slog.v(TAG,"String_Node_Str");
      return true;
    }
  }
 else {
    if (DEBUG_PAUSE)     Slog.v(TAG,"String_Node_Str");
    if (!resuming) {
      mStackSupervisor.getFocusedStack().resumeTopActivityLocked(null);
    }
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Start pausing the currently resumed activity.  It is an error to call this if there is already an activity being paused or there is no resumed activity.
 * @param userLeaving True if this should result in an onUserLeaving to the current activity.
 * @param uiSleeping True if this is happening with the user interface going to sleep (thescreen turning off).
 * @param resuming True if this is being called as part of resuming the top activity, sowe shouldn't try to instigate a resume here.
 * @param dontWait True if the caller does not want to wait for the pause to complete.  Ifset to true, we will immediately complete the pause here before returning.
 * @return Returns true if an activity now is in the PAUSING state, and we are waiting forit to tell us when it is done.
 */
final boolean startPausingLocked(boolean userLeaving,boolean uiSleeping,boolean resuming,boolean dontWait){
  if (mPausingActivity != null) {
    Slog.wtf(TAG,"String_Node_Str" + mPausingActivity);
    completePauseLocked(false);
  }
  ActivityRecord prev=mResumedActivity;
  if (prev == null) {
    if (!resuming) {
      Slog.wtf(TAG,"String_Node_Str");
      mStackSupervisor.resumeTopActivitiesLocked();
    }
    return false;
  }
  if (mActivityContainer.mParentActivity == null) {
    mStackSupervisor.pauseChildStacks(prev,userLeaving,uiSleeping,resuming,dontWait);
  }
  if (DEBUG_STATES)   Slog.v(TAG,"String_Node_Str" + prev);
 else   if (DEBUG_PAUSE)   Slog.v(TAG,"String_Node_Str" + prev);
  mResumedActivity=null;
  mPausingActivity=prev;
  mLastPausedActivity=prev;
  mLastNoHistoryActivity=(prev.intent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY) != 0 || (prev.info.flags & ActivityInfo.FLAG_NO_HISTORY) != 0 ? prev : null;
  prev.state=ActivityState.PAUSING;
  prev.task.touchActiveTime();
  clearLaunchTime(prev);
  final ActivityRecord next=mStackSupervisor.topRunningActivityLocked();
  if (mService.mHasRecents && (next == null || next.noDisplay || next.task != prev.task || uiSleeping)) {
    prev.updateThumbnail(screenshotActivities(prev),null);
  }
  stopFullyDrawnTraceIfNeeded();
  mService.updateCpuStats();
  if (prev.app != null && prev.app.thread != null) {
    if (DEBUG_PAUSE)     Slog.v(TAG,"String_Node_Str" + prev);
    try {
      EventLog.writeEvent(EventLogTags.AM_PAUSE_ACTIVITY,prev.userId,System.identityHashCode(prev),prev.shortComponentName);
      mService.updateUsageStats(prev,false);
      prev.app.thread.schedulePauseActivity(prev.appToken,prev.finishing,userLeaving,prev.configChangeFlags,dontWait);
    }
 catch (    Exception e) {
      Slog.w(TAG,"String_Node_Str",e);
      mPausingActivity=null;
      mLastPausedActivity=null;
      mLastNoHistoryActivity=null;
    }
  }
 else {
    mPausingActivity=null;
    mLastPausedActivity=null;
    mLastNoHistoryActivity=null;
  }
  if (!mService.isSleepingOrShuttingDown()) {
    mStackSupervisor.acquireLaunchWakelock();
  }
  if (mPausingActivity != null) {
    if (!uiSleeping) {
      prev.pauseKeyDispatchingLocked();
    }
 else {
      if (DEBUG_PAUSE)       Slog.v(TAG,"String_Node_Str");
    }
    if (dontWait) {
      completePauseLocked(false);
      return false;
    }
 else {
      Message msg=mHandler.obtainMessage(PAUSE_TIMEOUT_MSG);
      msg.obj=prev;
      prev.pauseTime=SystemClock.uptimeMillis();
      mHandler.sendMessageDelayed(msg,PAUSE_TIMEOUT);
      if (DEBUG_PAUSE)       Slog.v(TAG,"String_Node_Str");
      return true;
    }
  }
 else {
    if (DEBUG_PAUSE)     Slog.v(TAG,"String_Node_Str");
    if (!resuming) {
      mStackSupervisor.getFocusedStack().resumeTopActivityLocked(null);
    }
    return false;
  }
}