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

Commit 94b84028 authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "Mark activity as visible and not stopped after resume-relaunch." into nyc-dev

parents 5f05cf96 2b79af1e
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -62,7 +62,7 @@ class ActivityManagerDebugConfig {
    static final boolean DEBUG_LRU = DEBUG_ALL || false;
    static final boolean DEBUG_LRU = DEBUG_ALL || false;
    static final boolean DEBUG_MU = DEBUG_ALL || false;
    static final boolean DEBUG_MU = DEBUG_ALL || false;
    static final boolean DEBUG_OOM_ADJ = DEBUG_ALL || false;
    static final boolean DEBUG_OOM_ADJ = DEBUG_ALL || false;
    static final boolean DEBUG_PAUSE = DEBUG_ALL || true;
    static final boolean DEBUG_PAUSE = DEBUG_ALL || false;
    static final boolean DEBUG_POWER = DEBUG_ALL || false;
    static final boolean DEBUG_POWER = DEBUG_ALL || false;
    static final boolean DEBUG_POWER_QUICK = DEBUG_POWER || false;
    static final boolean DEBUG_POWER_QUICK = DEBUG_POWER || false;
    static final boolean DEBUG_PROCESS_OBSERVERS = DEBUG_ALL || false;
    static final boolean DEBUG_PROCESS_OBSERVERS = DEBUG_ALL || false;
@@ -85,7 +85,7 @@ class ActivityManagerDebugConfig {
    static final boolean DEBUG_UID_OBSERVERS = DEBUG_ALL || false;
    static final boolean DEBUG_UID_OBSERVERS = DEBUG_ALL || false;
    static final boolean DEBUG_URI_PERMISSION = DEBUG_ALL || false;
    static final boolean DEBUG_URI_PERMISSION = DEBUG_ALL || false;
    static final boolean DEBUG_USER_LEAVING = DEBUG_ALL || false;
    static final boolean DEBUG_USER_LEAVING = DEBUG_ALL || false;
    static final boolean DEBUG_VISIBILITY = DEBUG_ALL || true;
    static final boolean DEBUG_VISIBILITY = DEBUG_ALL || false;
    static final boolean DEBUG_VISIBLE_BEHIND = DEBUG_ALL_ACTIVITIES || false;
    static final boolean DEBUG_VISIBLE_BEHIND = DEBUG_ALL_ACTIVITIES || false;
    static final boolean DEBUG_USAGE_STATS = DEBUG_ALL || false;
    static final boolean DEBUG_USAGE_STATS = DEBUG_ALL || false;
    static final boolean DEBUG_PERMISSIONS_REVIEW = DEBUG_ALL || false;
    static final boolean DEBUG_PERMISSIONS_REVIEW = DEBUG_ALL || false;
+24 −6
Original line number Original line Diff line number Diff line
@@ -768,7 +768,6 @@ final class ActivityStack {
        r.state = ActivityState.RESUMED;
        r.state = ActivityState.RESUMED;
        if (DEBUG_STATES) Slog.v(TAG_STATES,
        if (DEBUG_STATES) Slog.v(TAG_STATES,
                "Moving to RESUMED: " + r + " (starting new instance)");
                "Moving to RESUMED: " + r + " (starting new instance)");
        r.stopped = false;
        mResumedActivity = r;
        mResumedActivity = r;
        r.task.touchActiveTime();
        r.task.touchActiveTime();
        mRecentTasks.addLocked(r.task);
        mRecentTasks.addLocked(r.task);
@@ -1228,9 +1227,11 @@ final class ActivityStack {
     * this function updates the rest of our state to match that fact.
     * this function updates the rest of our state to match that fact.
     */
     */
    private void completeResumeLocked(ActivityRecord next) {
    private void completeResumeLocked(ActivityRecord next) {
        next.visible = true;
        next.idle = false;
        next.idle = false;
        next.results = null;
        next.results = null;
        next.newIntents = null;
        next.newIntents = null;
        next.stopped = false;


        if (next.isHomeActivity()) {
        if (next.isHomeActivity()) {
            ProcessRecord app = next.task.mActivities.get(0).app;
            ProcessRecord app = next.task.mActivities.get(0).app;
@@ -1729,6 +1730,8 @@ final class ActivityStack {


        // This activity is not currently visible, but is running. Tell it to become visible.
        // This activity is not currently visible, but is running. Tell it to become visible.
        if (r.state == ActivityState.RESUMED || r == starting) {
        if (r.state == ActivityState.RESUMED || r == starting) {
            Slog.d(TAG_VISIBILITY, "Not making visible, r=" + r + " state=" + r.state
                    + " starting=" + starting);
            return;
            return;
        }
        }


@@ -2291,7 +2294,6 @@ final class ActivityStack {
            // From this point on, if something goes wrong there is no way
            // From this point on, if something goes wrong there is no way
            // to recover the activity.
            // to recover the activity.
            try {
            try {
                next.visible = true;
                completeResumeLocked(next);
                completeResumeLocked(next);
            } catch (Exception e) {
            } catch (Exception e) {
                // If any exception gets thrown, toss away this
                // If any exception gets thrown, toss away this
@@ -2302,8 +2304,6 @@ final class ActivityStack {
                if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked();
                if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked();
                return true;
                return true;
            }
            }
            next.stopped = false;

        } else {
        } else {
            // Whoops, need to restart this activity!
            // Whoops, need to restart this activity!
            if (!next.hasBeenLaunched) {
            if (!next.hasBeenLaunched) {
@@ -4283,6 +4283,12 @@ final class ActivityStack {
                // "restart!".
                // "restart!".
                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                        "Config is relaunching resumed " + r);
                        "Config is relaunching resumed " + r);

                if (DEBUG_STATES && !r.visible) {
                    Slog.v(TAG_STATES, "Config is relaunching resumed invisible activity " + r
                            + " called by " + Debug.getCallers(4));
                }

                relaunchActivityLocked(r, r.configChangeFlags, true, preserveWindow);
                relaunchActivityLocked(r, r.configChangeFlags, true, preserveWindow);
            } else {
            } else {
                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
@@ -4433,9 +4439,21 @@ final class ActivityStack {
        }
        }


        if (andResume) {
        if (andResume) {
            if (DEBUG_STATES) {
                Slog.d(TAG_STATES, "Resumed after relaunch " + r);
            }
            r.state = ActivityState.RESUMED;
            // Relaunch-resume could happen either when the app is already in the front,
            // or while it's being brought to front. In the latter case, it's marked RESUMED
            // but not yet visible (or stopped). We need to complete the resume here as the
            // code in resumeTopActivityInnerLocked to complete the resume might be skipped.
            if (!r.visible || r.stopped) {
                mWindowManager.setAppVisibility(r.appToken, true);
                completeResumeLocked(r);
            } else {
                r.results = null;
                r.results = null;
                r.newIntents = null;
                r.newIntents = null;
            r.state = ActivityState.RESUMED;
            }
        } else {
        } else {
            mHandler.removeMessages(PAUSE_TIMEOUT_MSG, r);
            mHandler.removeMessages(PAUSE_TIMEOUT_MSG, r);
            r.state = ActivityState.PAUSED;
            r.state = ActivityState.PAUSED;
+3 −3
Original line number Original line Diff line number Diff line
@@ -37,8 +37,8 @@ public class WindowManagerDebugConfig {
    static final boolean DEBUG = false;
    static final boolean DEBUG = false;
    static final boolean DEBUG_ADD_REMOVE = false;
    static final boolean DEBUG_ADD_REMOVE = false;
    static final boolean DEBUG_FOCUS = false;
    static final boolean DEBUG_FOCUS = false;
    static final boolean DEBUG_FOCUS_LIGHT = DEBUG_FOCUS || false;
    static final boolean DEBUG_FOCUS_LIGHT = DEBUG_FOCUS || true;
    static final boolean DEBUG_ANIM = false;
    static final boolean DEBUG_ANIM = true;
    static final boolean DEBUG_KEYGUARD = false;
    static final boolean DEBUG_KEYGUARD = false;
    static final boolean DEBUG_LAYOUT = false;
    static final boolean DEBUG_LAYOUT = false;
    static final boolean DEBUG_LAYERS = false;
    static final boolean DEBUG_LAYERS = false;
@@ -50,7 +50,7 @@ public class WindowManagerDebugConfig {
    static final boolean DEBUG_ORIENTATION = false;
    static final boolean DEBUG_ORIENTATION = false;
    static final boolean DEBUG_APP_ORIENTATION = false;
    static final boolean DEBUG_APP_ORIENTATION = false;
    static final boolean DEBUG_CONFIGURATION = false;
    static final boolean DEBUG_CONFIGURATION = false;
    static final boolean DEBUG_APP_TRANSITIONS = false;
    static final boolean DEBUG_APP_TRANSITIONS = true;
    static final boolean DEBUG_STARTING_WINDOW = false;
    static final boolean DEBUG_STARTING_WINDOW = false;
    static final boolean DEBUG_WALLPAPER = false;
    static final boolean DEBUG_WALLPAPER = false;
    static final boolean DEBUG_WALLPAPER_LIGHT = false || DEBUG_WALLPAPER;
    static final boolean DEBUG_WALLPAPER_LIGHT = false || DEBUG_WALLPAPER;
+4 −4
Original line number Original line Diff line number Diff line
@@ -1192,7 +1192,7 @@ public class WindowManagerService extends IWindowManager.Stub
                break;
                break;
            }
            }
        }
        }
        if (DEBUG_FOCUS_LIGHT || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
        if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
                "Based on layer: Adding window " + win + " at " + (i + 1) + " of "
                "Based on layer: Adding window " + win + " at " + (i + 1) + " of "
                        + windows.size());
                        + windows.size());
        windows.add(i + 1, win);
        windows.add(i + 1, win);
@@ -1224,7 +1224,7 @@ public class WindowManagerService extends IWindowManager.Stub
                //apptoken note that the window could be a floating window
                //apptoken note that the window could be a floating window
                //that was created later or a window at the top of the list of
                //that was created later or a window at the top of the list of
                //windows associated with this token.
                //windows associated with this token.
                if (DEBUG_FOCUS_LIGHT || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
                if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
                        "not Base app: Adding window " + win + " at " + (newIdx + 1) + " of "
                        "not Base app: Adding window " + win + " at " + (newIdx + 1) + " of "
                                + windows.size());
                                + windows.size());
                windows.add(newIdx + 1, win);
                windows.add(newIdx + 1, win);
@@ -1262,7 +1262,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }
            }
        }
        }
        i++;
        i++;
        if (DEBUG_FOCUS_LIGHT || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
        if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
                "Free window: Adding window " + win + " at " + i + " of " + windows.size());
                "Free window: Adding window " + win + " at " + i + " of " + windows.size());
        windows.add(i, win);
        windows.add(i, win);
        mWindowsChanged = true;
        mWindowsChanged = true;
@@ -1333,7 +1333,7 @@ public class WindowManagerService extends IWindowManager.Stub
    }
    }


    private void addWindowToListInOrderLocked(final WindowState win, boolean addToToken) {
    private void addWindowToListInOrderLocked(final WindowState win, boolean addToToken) {
        if (DEBUG_FOCUS_LIGHT) Slog.d(TAG_WM, "addWindowToListInOrderLocked: win=" + win +
        if (DEBUG_FOCUS) Slog.d(TAG_WM, "addWindowToListInOrderLocked: win=" + win +
                " Callers=" + Debug.getCallers(4));
                " Callers=" + Debug.getCallers(4));
        if (win.mAttachedWindow == null) {
        if (win.mAttachedWindow == null) {
            final WindowToken token = win.mToken;
            final WindowToken token = win.mToken;
+1 −1
Original line number Original line Diff line number Diff line
@@ -1347,7 +1347,7 @@ class WindowStateAnimator {
            }
            }
        } else {
        } else {
            if (DEBUG_ANIM && isAnimating()) {
            if (DEBUG_ANIM && isAnimating()) {
                Slog.v(TAG, "prepareSurface: No changes in animation for " + this);
                //Slog.v(TAG, "prepareSurface: No changes in animation for " + this);
            }
            }
            displayed = true;
            displayed = true;
        }
        }