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

Commit 2bc846ca authored by wilsonshih's avatar wilsonshih
Browse files

Fixed an issue that activity might be invisible after unlocking.

A just resumed activity can be stopped due to the API
setLockScreenShown been called after keyguardGoingAway.
When receive keyguardGoingAway, AM will goes to resume top activity,
and WM goes to prepare transition, at this moment isKeyguardOrAodShowing
return false.
However if user has enable AOD, systemUI will also receive AOD change and
call setLockScreenShown because AOD turns from on to off, but
setLockScreenShown is post to another thread, so it cannot be ensured to
be called before keyguardGoingAway. If this happen after
keyguardGoingAway, isKeyguardOrAodShowing would become true and push
the resumed activity to stopped list.

Solution:
- Post keyguardGoingAway to the same thread so those calls to ATM will
be in order.
- setKeyguardGoingAway is irrelevant to AOD state.
- Switch the sequence of updateKeyguardSleepToken and
ensureActivitiesVisible, if there is an display awake from sleep, the
top activity can be resumed then visible.

Bug: 130311385
Test: atest KeyguardTests KeyguardLockedTests MultiDisplayLockedKeyguardTests
	    MultiDisplayKeyguardTests ActivityLifecycleKeyguardTests

Change-Id: I7ecad050e6db9ab3486afedf9b4101965e800eba
parent e967fe3d
Loading
Loading
Loading
Loading
+29 −23
Original line number Diff line number Diff line
@@ -1785,7 +1785,6 @@ public class KeyguardViewMediator extends SystemUI {
        public void run() {
            Trace.beginSection("KeyguardViewMediator.mKeyGuardGoingAwayRunnable");
            if (DEBUG) Log.d(TAG, "keyguardGoingAway");
            try {
            mStatusBarKeyguardViewManager.keyguardGoingAway();

            int flags = 0;
@@ -1803,13 +1802,20 @@ public class KeyguardViewMediator extends SystemUI {
            }

            mUpdateMonitor.setKeyguardGoingAway(true /* goingAway */);

            // Don't actually hide the Keyguard at the moment, wait for window
            // manager until it tells us it's safe to do so with
            // startKeyguardExitAnimation.
                ActivityTaskManager.getService().keyguardGoingAway(flags);
            // Posting to mUiOffloadThread to ensure that calls to ActivityTaskManager will be in
            // order.
            final int keyguardFlag = flags;
            mUiOffloadThread.submit(() -> {
                try {
                    ActivityTaskManager.getService().keyguardGoingAway(keyguardFlag);
                } catch (RemoteException e) {
                    Log.e(TAG, "Error while calling WindowManager", e);
                }
            });
            Trace.endSection();
        }
    };
+14 −8
Original line number Diff line number Diff line
@@ -133,27 +133,33 @@ class KeyguardController {
     * Update the Keyguard showing state.
     */
    void setKeyguardShown(boolean keyguardShowing, boolean aodShowing) {
        boolean showingChanged = keyguardShowing != mKeyguardShowing || aodShowing != mAodShowing;
        // If keyguard is going away, but SystemUI aborted the transition, need to reset state.
        showingChanged |= mKeyguardGoingAway && keyguardShowing;
        if (!showingChanged) {
        final boolean keyguardChanged = keyguardShowing != mKeyguardShowing
                || mKeyguardGoingAway && keyguardShowing;
        final boolean aodChanged = aodShowing != mAodShowing;
        if (!keyguardChanged && !aodChanged) {
            return;
        }
        mKeyguardShowing = keyguardShowing;
        mAodShowing = aodShowing;
        mWindowManager.setAodShowing(aodShowing);
        if (showingChanged) {

        if (keyguardChanged) {
            // Irrelevant to AOD.
            dismissDockedStackIfNeeded();
            setKeyguardGoingAway(false);
            // TODO(b/113840485): Check usage for non-default display
            mWindowManager.setKeyguardOrAodShowingOnDefaultDisplay(
                    isKeyguardOrAodShowing(DEFAULT_DISPLAY));
            if (keyguardShowing) {
                mDismissalRequested = false;
            }
        }
        mRootActivityContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
        // TODO(b/113840485): Check usage for non-default display
        mWindowManager.setKeyguardOrAodShowingOnDefaultDisplay(
                isKeyguardOrAodShowing(DEFAULT_DISPLAY));

        // Update the sleep token first such that ensureActivitiesVisible has correct sleep token
        // state when evaluating visibilities.
        updateKeyguardSleepToken();
        mRootActivityContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
    }

    /**