@@ -3424,16 +3424,19 @@ private final void startProcessLocked(ProcessRecord app, String hostingType,
34243424 app.killed = false;
34253425 app.killedByAm = false;
34263426 checkTime(startTime, "startProcess: starting to update pids map");
3427+ ProcessRecord oldApp;
3428+ synchronized (mPidsSelfLocked) {
3429+ oldApp = mPidsSelfLocked.get(startResult.pid);
3430+ }
3431+ // If there is already an app occupying that pid that hasn't been cleaned up
3432+ if (oldApp != null && !app.isolated) {
3433+ // Clean up anything relating to this pid first
3434+ Slog.w(TAG, "Reusing pid " + startResult.pid
3435+ + " while app is still mapped to it");
3436+ cleanUpApplicationRecordLocked(oldApp, false, false, -1,
3437+ true /*replacingPid*/);
3438+ }
34273439 synchronized (mPidsSelfLocked) {
3428- ProcessRecord oldApp;
3429- // If there is already an app occupying that pid that hasn't been cleaned up
3430- if ((oldApp = mPidsSelfLocked.get(startResult.pid)) != null && !app.isolated) {
3431- // Clean up anything relating to this pid first
3432- Slog.w(TAG, "Reusing pid " + startResult.pid
3433- + " while app is still mapped to it");
3434- cleanUpApplicationRecordLocked(oldApp, false, false, -1,
3435- true /*replacingPid*/);
3436- }
34373440 this.mPidsSelfLocked.put(startResult.pid, app);
34383441 if (isActivityProcess) {
34393442 Message msg = mHandler.obtainMessage(PROC_START_TIMEOUT_MSG);
0 commit comments