Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a5a7bd9 authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Yet more movement from ActivityStack to Supervisor"

parents df294cf4 e79d4268
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4370,7 +4370,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            synchronized (this) {
                ActivityStack stack = ActivityRecord.getStackLocked(token);
                if (stack != null) {
                    ActivityRecord r = stack.activityIdleInternal(token, false, config);
                    ActivityRecord r = stack.activityIdleInternalLocked(token, false, config);
                    if ((mProfileProc == r.app) && (mProfileFd != null)) {
                        try {
                            mProfileFd.close();
+108 −95
Original line number Diff line number Diff line
@@ -368,7 +368,9 @@ final class ActivityStack {
                    // so we need to be conservative and assume it isn't.
                    ActivityRecord r = (ActivityRecord)msg.obj;
                    Slog.w(TAG, "Activity idle timeout for " + r);
                    activityIdleInternal(r != null ? r.appToken : null, true, null);
                    synchronized (this) {
                        activityIdleInternalLocked(r != null ? r.appToken : null, true, null);
                    }
                } break;
                case LAUNCH_TICK_MSG: {
                    ActivityRecord r = (ActivityRecord)msg.obj;
@@ -390,7 +392,9 @@ final class ActivityStack {
                } break;
                case IDLE_NOW_MSG: {
                    ActivityRecord r = (ActivityRecord)msg.obj;
                    activityIdleInternal(r != null ? r.appToken : null, false, null);
                    synchronized (mService) {
                        activityIdleInternalLocked(r != null ? r.appToken : null, false, null);
                    }
                } break;
                case LAUNCH_TIMEOUT_MSG: {
                    if (mService.mDidDexOpt) {
@@ -663,12 +667,7 @@ final class ActivityStack {
        if (DEBUG_SAVED_STATE) Slog.i(TAG, "Launch completed; removing icicle of " + r.icicle);
    }

    private final void startSpecificActivityLocked(ActivityRecord r,
            boolean andResume, boolean checkConfig) {
        // Is this activity's application already running?
        ProcessRecord app = mService.getProcessRecordLocked(r.processName,
                r.info.applicationInfo.uid);

    void setLaunchTime(ActivityRecord r) {
        if (r.launchTime == 0) {
            r.launchTime = SystemClock.uptimeMillis();
            if (mInitialStartTime == 0) {
@@ -677,23 +676,6 @@ final class ActivityStack {
        } else if (mInitialStartTime == 0) {
            mInitialStartTime = SystemClock.uptimeMillis();
        }

        if (app != null && app.thread != null) {
            try {
                app.addPackage(r.info.packageName);
                mStackSupervisor.realStartActivityLocked(r, app, andResume, checkConfig);
                return;
            } catch (RemoteException e) {
                Slog.w(TAG, "Exception when starting activity "
                        + r.intent.getComponent().flattenToShortString(), e);
            }

            // If a dead object exception was thrown -- fall through to
            // restart the application.
        }

        mService.startProcessLocked(r.processName, r.info.applicationInfo, true, 0,
                "activity", r.intent.getComponent(), false, false);
    }

    void stopIfSleepingLocked() {
@@ -733,6 +715,7 @@ final class ActivityStack {
        checkReadyForSleepLocked();
    }

    // Checked.
    void checkReadyForSleepLocked() {
        if (!mService.isSleepingOrShuttingDown()) {
            // Do not care.
@@ -1066,6 +1049,7 @@ final class ActivityStack {
        prev.cpuTimeAtResume = 0; // reset it
    }

    // Checked.
    /**
     * Once we know that we have asked an application to put an activity in
     * the resumed state (either by launching it or explicitly telling it),
@@ -1092,6 +1076,7 @@ final class ActivityStack {
        }

        if (mStackSupervisor.isMainStack(this)) {
            // Should this be done for all stacks, not just mMainStack?
            mService.reportResumedActivityLocked(next);
        }

@@ -1115,6 +1100,7 @@ final class ActivityStack {
        }
    }

    // Checked.
    /**
     * Make sure that all activities that need to be visible (that is, they
     * currently can be seen by the user) actually are.
@@ -1171,7 +1157,7 @@ final class ActivityStack {
                                mService.mWindowManager.setAppVisibility(r.appToken, true);
                            }
                            if (r != starting) {
                                startSpecificActivityLocked(r, false, false);
                                mStackSupervisor.startSpecificActivityLocked(r, false, false);
                            }
                        }

@@ -1244,6 +1230,7 @@ final class ActivityStack {
        }
    }

    // Checked.
    /**
     * Version of ensureActivitiesVisible that can easily be called anywhere.
     */
@@ -1603,7 +1590,7 @@ final class ActivityStack {
                                null, true);
                    }
                }
                startSpecificActivityLocked(next, true, false);
                mStackSupervisor.startSpecificActivityLocked(next, true, false);
                return true;
            }

@@ -1638,7 +1625,7 @@ final class ActivityStack {
                }
                if (DEBUG_SWITCH) Slog.v(TAG, "Restarting: " + next);
            }
            startSpecificActivityLocked(next, true, true);
            mStackSupervisor.startSpecificActivityLocked(next, true, true);
        }

        return true;
@@ -2893,7 +2880,8 @@ final class ActivityStack {
        mHandler.sendMessage(msg);
    }

    final ActivityRecord activityIdleInternal(IBinder token, boolean fromTimeout,
    // Checked.
    final ActivityRecord activityIdleInternalLocked(IBinder token, boolean fromTimeout,
            Configuration config) {
        if (localLOGV) Slog.v(TAG, "Activity idle: " + token);

@@ -2911,7 +2899,6 @@ final class ActivityStack {
        boolean enableScreen = false;
        boolean activityRemoved = false;

        synchronized (mService) {
        ActivityRecord r = ActivityRecord.forToken(token);
        if (r != null) {
            mHandler.removeMessages(IDLE_TIMEOUT_MSG, r);
@@ -2986,7 +2973,6 @@ final class ActivityStack {
            startingUsers = new ArrayList<UserStartedState>(mStartingUsers);
            mStartingUsers.clear();
        }
        }

        int i;

@@ -3003,7 +2989,7 @@ final class ActivityStack {
        // Stop any activities that are scheduled to do so but have been
        // waiting for the next one to start.
        for (i=0; i<NS; i++) {
            ActivityRecord r = stops.get(i);
            r = stops.get(i);
            synchronized (mService) {
                if (r.finishing) {
                    finishCurrentActivityLocked(r, FINISH_IMMEDIATELY, false);
@@ -3016,7 +3002,7 @@ final class ActivityStack {
        // Finish any activities that are scheduled to do so but have been
        // waiting for the next one to start.
        for (i=0; i<NF; i++) {
            ActivityRecord r = finishes.get(i);
            r = finishes.get(i);
            synchronized (mService) {
                activityRemoved = destroyActivityLocked(r, true, false, "finish-idle");
            }
@@ -3024,7 +3010,7 @@ final class ActivityStack {

        // Report back to any thumbnail receivers.
        for (i=0; i<NT; i++) {
            ActivityRecord r = thumbnails.get(i);
            r = thumbnails.get(i);
            mService.sendPendingThumbnail(r, null, null, null, true);
        }

@@ -4364,6 +4350,33 @@ final class ActivityStack {
        }
    }

    void handleAppDiedLocked(ProcessRecord app, boolean restarting) {
        if (mPausingActivity != null && mPausingActivity.app == app) {
            if (DEBUG_PAUSE || DEBUG_CLEANUP) Slog.v(TAG,
                    "App died while pausing: " + mPausingActivity);
            mPausingActivity = null;
        }
        if (mLastPausedActivity != null && mLastPausedActivity.app == app) {
            mLastPausedActivity = null;
        }

        // Remove this application's activities from active lists.
        boolean hasVisibleActivities = removeHistoryRecordsForAppLocked(app);

        if (!restarting) {
            if (!resumeTopActivityLocked(null)) {
                // If there was nothing to resume, and we are not already
                // restarting this process, but there is a visible activity that
                // is hosted by the process...  then make sure all visible
                // activities are running, taking care of restarting this
                // process.
                if (hasVisibleActivities) {
                    ensureActivitiesVisibleLocked(null, 0);
                }
            }
        }
    }

    void handleAppCrashLocked(ProcessRecord app) {
        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
            final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities;
+27 −27
Original line number Diff line number Diff line
@@ -17,9 +17,7 @@
package com.android.server.am;

import static com.android.server.am.ActivityManagerService.localLOGV;
import static com.android.server.am.ActivityManagerService.DEBUG_CLEANUP;
import static com.android.server.am.ActivityManagerService.DEBUG_CONFIGURATION;
import static com.android.server.am.ActivityManagerService.DEBUG_PAUSE;
import static com.android.server.am.ActivityManagerService.DEBUG_SWITCH;
import static com.android.server.am.ActivityManagerService.TAG;

@@ -671,35 +669,37 @@ public class ActivityStackSupervisor {
        return true;
    }

    void handleAppDiedLocked(ProcessRecord app, boolean restarting) {
        // Just in case.
        final int numStacks = mStacks.size();
        for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) {
            final ActivityStack stack = mStacks.get(stackNdx);
            if (stack.mPausingActivity != null && stack.mPausingActivity.app == app) {
                if (DEBUG_PAUSE || DEBUG_CLEANUP) Slog.v(TAG,
                        "App died while pausing: " + stack.mPausingActivity);
                stack.mPausingActivity = null;
            }
            if (stack.mLastPausedActivity != null && stack.mLastPausedActivity.app == app) {
                stack.mLastPausedActivity = null;
            }
    void startSpecificActivityLocked(ActivityRecord r,
            boolean andResume, boolean checkConfig) {
        // Is this activity's application already running?
        ProcessRecord app = mService.getProcessRecordLocked(r.processName,
                r.info.applicationInfo.uid);

            // Remove this application's activities from active lists.
            boolean hasVisibleActivities = stack.removeHistoryRecordsForAppLocked(app);
        r.task.stack.setLaunchTime(r);

            if (!restarting) {
                if (!stack.resumeTopActivityLocked(null)) {
                    // If there was nothing to resume, and we are not already
                    // restarting this process, but there is a visible activity that
                    // is hosted by the process...  then make sure all visible
                    // activities are running, taking care of restarting this
                    // process.
                    if (hasVisibleActivities) {
                        stack.ensureActivitiesVisibleLocked(null, 0);
        if (app != null && app.thread != null) {
            try {
                app.addPackage(r.info.packageName);
                realStartActivityLocked(r, app, andResume, checkConfig);
                return;
            } catch (RemoteException e) {
                Slog.w(TAG, "Exception when starting activity "
                        + r.intent.getComponent().flattenToShortString(), e);
            }

            // If a dead object exception was thrown -- fall through to
            // restart the application.
        }

        mService.startProcessLocked(r.processName, r.info.applicationInfo, true, 0,
                "activity", r.intent.getComponent(), false, false);
    }

    void handleAppDiedLocked(ProcessRecord app, boolean restarting) {
        // Just in case.
        final int numStacks = mStacks.size();
        for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) {
            mStacks.get(stackNdx).handleAppDiedLocked(app, restarting);
        }
    }

+0 −1
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ import com.android.internal.util.FastXmlSerializer;

import android.app.ActivityManager;
import android.app.AppGlobals;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.res.CompatibilityInfo;