Program: 2901
Project: 2901
Buggy source:
final boolean realStartActivityLocked(ActivityRecord r,ProcessRecord app,boolean andResume,boolean checkConfig) throws RemoteException {
  r.startFreezingScreenLocked(app,0);
  mService.mWindowManager.setAppVisibility(r.appToken,true);
  r.startLaunchTickingLocked();
  if (checkConfig) {
    Configuration config=mService.mWindowManager.updateOrientationFromAppTokens(mService.mConfiguration,r.mayFreezeScreenLocked(app) ? r.appToken : null);
    mService.updateConfigurationLocked(config,r,false,false);
  }
  r.app=app;
  app.waitingToKill=null;
  if (localLOGV)   Slog.v(TAG,"String_Node_Str" + r);
  int idx=app.activities.indexOf(r);
  if (idx < 0) {
    app.activities.add(r);
  }
  mService.updateLruProcessLocked(app,true);
  try {
    if (app.thread == null) {
      throw new RemoteException();
    }
    List<ResultInfo> results=null;
    List<Intent> newIntents=null;
    if (andResume) {
      results=r.results;
      newIntents=r.newIntents;
    }
    if (DEBUG_SWITCH)     Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str"+ r.icicle+ "String_Node_Str"+ results+ "String_Node_Str"+ newIntents+ "String_Node_Str"+ andResume);
    if (andResume) {
      EventLog.writeEvent(EventLogTags.AM_RESTART_ACTIVITY,r.userId,System.identityHashCode(r),r.task.taskId,r.shortComponentName);
    }
    if (r.isHomeActivity) {
      mService.mHomeProcess=app;
    }
    mService.ensurePackageDexOpt(r.intent.getComponent().getPackageName());
    r.sleeping=false;
    r.forceNewConfig=false;
    showAskCompatModeDialogLocked(r);
    r.compat=mService.compatibilityInfoForPackageLocked(r.info.applicationInfo);
    String profileFile=null;
    ParcelFileDescriptor profileFd=null;
    boolean profileAutoStop=false;
    if (mService.mProfileApp != null && mService.mProfileApp.equals(app.processName)) {
      if (mService.mProfileProc == null || mService.mProfileProc == app) {
        mService.mProfileProc=app;
        profileFile=mService.mProfileFile;
        profileFd=mService.mProfileFd;
        profileAutoStop=mService.mAutoStopProfiler;
      }
    }
    app.hasShownUi=true;
    app.pendingUiClean=true;
    if (profileFd != null) {
      try {
        profileFd=profileFd.dup();
      }
 catch (      IOException e) {
        profileFd=null;
      }
    }
    app.thread.scheduleLaunchActivity(new Intent(r.intent),r.appToken,System.identityHashCode(r),r.info,new Configuration(mService.mConfiguration),r.compat,r.icicle,results,newIntents,!andResume,mService.isNextTransitionForward(),profileFile,profileFd,profileAutoStop);
    if ((app.info.flags & ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) {
      if (app.processName.equals(app.info.packageName)) {
        if (mService.mHeavyWeightProcess != null && mService.mHeavyWeightProcess != app) {
          Log.w(TAG,"String_Node_Str" + app + "String_Node_Str"+ mService.mHeavyWeightProcess);
        }
        mService.mHeavyWeightProcess=app;
        Message msg=mService.mHandler.obtainMessage(ActivityManagerService.POST_HEAVY_NOTIFICATION_MSG);
        msg.obj=r;
        mService.mHandler.sendMessage(msg);
      }
    }
  }
 catch (  RemoteException e) {
    if (r.launchFailed) {
      Slog.e(TAG,"String_Node_Str" + r.intent.getComponent().flattenToShortString() + "String_Node_Str",e);
      mService.appDiedLocked(app,app.pid,app.thread);
      requestFinishActivityLocked(r.appToken,Activity.RESULT_CANCELED,null,"String_Node_Str",false);
      return false;
    }
    app.activities.remove(r);
    throw e;
  }
  r.launchFailed=false;
  if (updateLRUListLocked(r)) {
    Slog.w(TAG,"String_Node_Str" + r + "String_Node_Str");
  }
  if (andResume) {
    r.state=ActivityState.RESUMED;
    if (DEBUG_STATES)     Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str");
    r.stopped=false;
    mResumedActivity=r;
    r.task.touchActiveTime();
    if (mMainStack) {
      mService.addRecentTaskLocked(r.task);
    }
    completeResumeLocked(r);
    checkReadyForSleepLocked();
    if (DEBUG_SAVED_STATE)     Slog.i(TAG,"String_Node_Str" + r.icicle);
  }
 else {
    if (DEBUG_STATES)     Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str");
    r.state=ActivityState.STOPPED;
    r.stopped=true;
  }
  if (mMainStack) {
    mService.startSetupActivityLocked();
  }
  return true;
}

Fixed version (ground truth):
final boolean realStartActivityLocked(ActivityRecord r,ProcessRecord app,boolean andResume,boolean checkConfig) throws RemoteException {
  r.startFreezingScreenLocked(app,0);
  mService.mWindowManager.setAppVisibility(r.appToken,true);
  r.startLaunchTickingLocked();
  if (checkConfig) {
    Configuration config=mService.mWindowManager.updateOrientationFromAppTokens(mService.mConfiguration,r.mayFreezeScreenLocked(app) ? r.appToken : null);
    mService.updateConfigurationLocked(config,r,false,false);
  }
  r.app=app;
  app.waitingToKill=null;
  r.launchCount++;
  r.lastLaunchTime=SystemClock.uptimeMillis();
  if (localLOGV)   Slog.v(TAG,"String_Node_Str" + r);
  int idx=app.activities.indexOf(r);
  if (idx < 0) {
    app.activities.add(r);
  }
  mService.updateLruProcessLocked(app,true);
  try {
    if (app.thread == null) {
      throw new RemoteException();
    }
    List<ResultInfo> results=null;
    List<Intent> newIntents=null;
    if (andResume) {
      results=r.results;
      newIntents=r.newIntents;
    }
    if (DEBUG_SWITCH)     Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str"+ r.icicle+ "String_Node_Str"+ results+ "String_Node_Str"+ newIntents+ "String_Node_Str"+ andResume);
    if (andResume) {
      EventLog.writeEvent(EventLogTags.AM_RESTART_ACTIVITY,r.userId,System.identityHashCode(r),r.task.taskId,r.shortComponentName);
    }
    if (r.isHomeActivity) {
      mService.mHomeProcess=app;
    }
    mService.ensurePackageDexOpt(r.intent.getComponent().getPackageName());
    r.sleeping=false;
    r.forceNewConfig=false;
    showAskCompatModeDialogLocked(r);
    r.compat=mService.compatibilityInfoForPackageLocked(r.info.applicationInfo);
    String profileFile=null;
    ParcelFileDescriptor profileFd=null;
    boolean profileAutoStop=false;
    if (mService.mProfileApp != null && mService.mProfileApp.equals(app.processName)) {
      if (mService.mProfileProc == null || mService.mProfileProc == app) {
        mService.mProfileProc=app;
        profileFile=mService.mProfileFile;
        profileFd=mService.mProfileFd;
        profileAutoStop=mService.mAutoStopProfiler;
      }
    }
    app.hasShownUi=true;
    app.pendingUiClean=true;
    if (profileFd != null) {
      try {
        profileFd=profileFd.dup();
      }
 catch (      IOException e) {
        profileFd=null;
      }
    }
    app.thread.scheduleLaunchActivity(new Intent(r.intent),r.appToken,System.identityHashCode(r),r.info,new Configuration(mService.mConfiguration),r.compat,r.icicle,results,newIntents,!andResume,mService.isNextTransitionForward(),profileFile,profileFd,profileAutoStop);
    if ((app.info.flags & ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) {
      if (app.processName.equals(app.info.packageName)) {
        if (mService.mHeavyWeightProcess != null && mService.mHeavyWeightProcess != app) {
          Log.w(TAG,"String_Node_Str" + app + "String_Node_Str"+ mService.mHeavyWeightProcess);
        }
        mService.mHeavyWeightProcess=app;
        Message msg=mService.mHandler.obtainMessage(ActivityManagerService.POST_HEAVY_NOTIFICATION_MSG);
        msg.obj=r;
        mService.mHandler.sendMessage(msg);
      }
    }
  }
 catch (  RemoteException e) {
    if (r.launchFailed) {
      Slog.e(TAG,"String_Node_Str" + r.intent.getComponent().flattenToShortString() + "String_Node_Str",e);
      mService.appDiedLocked(app,app.pid,app.thread);
      requestFinishActivityLocked(r.appToken,Activity.RESULT_CANCELED,null,"String_Node_Str",false);
      return false;
    }
    app.activities.remove(r);
    throw e;
  }
  r.launchFailed=false;
  if (updateLRUListLocked(r)) {
    Slog.w(TAG,"String_Node_Str" + r + "String_Node_Str");
  }
  if (andResume) {
    r.state=ActivityState.RESUMED;
    if (DEBUG_STATES)     Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str");
    r.stopped=false;
    mResumedActivity=r;
    r.task.touchActiveTime();
    if (mMainStack) {
      mService.addRecentTaskLocked(r.task);
    }
    completeResumeLocked(r);
    checkReadyForSleepLocked();
    if (DEBUG_SAVED_STATE)     Slog.i(TAG,"String_Node_Str" + r.icicle);
  }
 else {
    if (DEBUG_STATES)     Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str");
    r.state=ActivityState.STOPPED;
    r.stopped=true;
  }
  if (mMainStack) {
    mService.startSetupActivityLocked();
  }
  return true;
}