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

Commit 3f15a82e authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Do not consider finishing dream activity as occluded

Otherwise it causes the next activity to be visible with
redundant lifecycles. And if screen orientation is changed,
the next activity may get wrong configuration by performing
relayout with intermediate visibility.

Test: 1. Enable dream, off/on screen and wait screen timeout.
      2. Rotate device, touch dream activity and unlock keyguard.
      Check that home activity shows with correct layout.
Bug: 181837363
Change-Id: I46aac2f2ca4208de39ace98fc8bc3917d13880ac
parent 779ea7fe
Loading
Loading
Loading
Loading
+29 −32
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -524,20 +525,18 @@ class KeyguardController {

            boolean occludedByActivity = false;
            final Task task = getRootTaskForControllingOccluding(display);
            if (task != null) {
                final ActivityRecord r = task.getTopNonFinishingActivity();
                if (r != null) {
                    final boolean showWhenLocked = r.canShowWhenLocked();
                    if (r.containsDismissKeyguardWindow()) {
                        mDismissingKeyguardActivity = r;
            final ActivityRecord top = task != null ? task.getTopNonFinishingActivity() : null;
            if (top != null) {
                if (top.containsDismissKeyguardWindow()) {
                    mDismissingKeyguardActivity = top;
                }
                    if (r.getTurnScreenOnFlag()
                            && r.currentLaunchCanTurnScreenOn()) {
                        mTopTurnScreenOnActivity = r;
                if (top.getTurnScreenOnFlag() && top.currentLaunchCanTurnScreenOn()) {
                    mTopTurnScreenOnActivity = top;
                }

                final boolean showWhenLocked = top.canShowWhenLocked();
                if (showWhenLocked) {
                        mTopOccludesActivity = r;
                    mTopOccludesActivity = top;
                }

                // Only the top activity may control occluded, as we can't occlude the Keyguard
@@ -547,17 +546,15 @@ class KeyguardController {
                        && controller.canShowWhileOccluded(
                                true /* dismissKeyguard */, false /* showWhenLocked */));
                // FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD only apply for secondary display.
                    if (mDisplayId != DEFAULT_DISPLAY && task.mDisplayContent != null) {
                        occludedByActivity |=
                                task.mDisplayContent.canShowWithInsecureKeyguard()
                if (mDisplayId != DEFAULT_DISPLAY) {
                    occludedByActivity |= display.canShowWithInsecureKeyguard()
                            && controller.canDismissKeyguard();
                }
            }
            }
            // TODO(b/123372519): isShowingDream can only works on default display.
            mOccluded = occludedByActivity || (mDisplayId == DEFAULT_DISPLAY
                    && mService.mRootWindowContainer.getDefaultDisplay()
                    .getDisplayPolicy().isShowingDreamLw());

            final boolean dreaming = display.getDisplayPolicy().isShowingDreamLw() && (top != null
                    && top.getActivityType() == ACTIVITY_TYPE_DREAM);
            mOccluded = dreaming || occludedByActivity;
            mRequestDismissKeyguard = lastDismissKeyguardActivity != mDismissingKeyguardActivity
                    && !mOccluded
                    && mDismissingKeyguardActivity != null