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

Commit 332a9410 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Fix extra configuration change when unlocking directly

When unlocking the device directly, if the top activity has different
orientation than keyguard, the orientation of display be updated first.
Otherwise the activity may be updated to the orientation requested by
keyguard, and then update again according to the activity.

If fixed rotation is active in this case, it only increase useless cost
because the display is not frozen, the orientation changes will have
some intermediate states, such as keyguard-going-away is just cleared
but the specified orientation of keyguard still exists a while.

Also make the cleanup of fixed rotation more robust to avoid other
unexpected paths retain the stale state.

Bug: 160131683
Bug: 160239395
Test: atest RootActivityContainerTests# \
      testAwakeFromSleepingWithAppConfiguration

Change-Id: I3552b81ffaaff062aa2ee90c51928c92dfb83c48
parent e5e4c105
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -954,8 +954,6 @@ class ActivityStack extends Task {
    void awakeFromSleepingLocked() {
        // Ensure activities are no longer sleeping.
        forAllActivities((Consumer<ActivityRecord>) (r) -> r.setSleeping(false));
        ensureActivitiesVisible(null /* starting */, 0 /* configChanges */,
                false /* preserveWindows */);
        if (mPausingActivity != null) {
            Slog.d(TAG, "awakeFromSleepingLocked: previously pausing activity didn't pause");
            mPausingActivity.activityPaused(true);
+1 −0
Original line number Diff line number Diff line
@@ -253,6 +253,7 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
                    req = mLastKeyguardForcedOrientation;
                }
            }
            mLastOrientationSource = win;
            return req;
        }
    }
+16 −3
Original line number Diff line number Diff line
@@ -1189,6 +1189,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

        activity.onRemovedFromDisplay();
        if (activity == mFixedRotationLaunchingApp) {
            // Make sure the states of associated tokens are also cleared.
            activity.finishFixedRotationTransform();
            setFixedRotationLaunchingAppUnchecked(null);
        }
    }
@@ -1487,6 +1489,12 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                // window was transferred ({@link #mSkipAppTransitionAnimation}).
                return false;
            }
            if ((mAppTransition.getTransitFlags()
                    & WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) != 0) {
                // The transition may be finished before keyguard hidden. In order to avoid the
                // intermediate orientation change, it is more stable to freeze the display.
                return false;
            }
        } else if (r != topRunningActivity()) {
            // If the transition has not started yet, the activity must be the top.
            return false;
@@ -2310,6 +2318,13 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    void onAppTransitionDone() {
        super.onAppTransitionDone();
        mWmService.mWindowsChanged = true;
        // If the transition finished callback cannot match the token for some reason, make sure the
        // rotated state is cleared if it is already invisible.
        if (mFixedRotationLaunchingApp != null && !mFixedRotationLaunchingApp.mVisibleRequested
                && !mFixedRotationLaunchingApp.isVisible()
                && !mDisplayRotation.isRotatingSeamlessly()) {
            clearFixedRotationLaunchingApp();
        }
    }

    @Override
@@ -3011,11 +3026,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

        final ScreenRotationAnimation rotationAnimation = getRotationAnimation();
        if (rotationAnimation != null) {
            pw.print(subPrefix);
            pw.println("  mScreenRotationAnimation:");
            rotationAnimation.printTo("  ", pw);
            rotationAnimation.printTo(subPrefix, pw);
        } else if (dumpAll) {
            pw.print(subPrefix);
            pw.println("  no ScreenRotationAnimation ");
        }

+6 −0
Original line number Diff line number Diff line
@@ -2391,6 +2391,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                            // activity here.
                            resumeFocusedStacksTopActivities();
                        }
                        // The visibility update must not be called before resuming the top, so the
                        // display orientation can be updated first if needed. Otherwise there may
                        // have redundant configuration changes due to apply outdated display
                        // orientation (from keyguard) to activity.
                        stack.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */,
                                false /* preserveWindows */);
                    }
                }
            }
+4 −4
Original line number Diff line number Diff line
@@ -1827,14 +1827,14 @@ final class TaskDisplayArea extends DisplayArea<ActivityStack> {
    @Override
    void dump(PrintWriter pw, String prefix, boolean dumpAll) {
        pw.println(prefix + "TaskDisplayArea " + getName());
        super.dump(pw, prefix, dumpAll);
        final String doublePrefix = prefix + "  ";
        super.dump(pw, doublePrefix, dumpAll);
        if (mPreferredTopFocusableStack != null) {
            pw.println(prefix + "  mPreferredTopFocusableStack=" + mPreferredTopFocusableStack);
            pw.println(doublePrefix + "mPreferredTopFocusableStack=" + mPreferredTopFocusableStack);
        }
        if (mLastFocusedStack != null) {
            pw.println(prefix + "  mLastFocusedStack=" + mLastFocusedStack);
            pw.println(doublePrefix + "mLastFocusedStack=" + mLastFocusedStack);
        }
        final String doublePrefix = prefix + "  ";
        final String triplePrefix = doublePrefix + "  ";
        pw.println(doublePrefix + "Application tokens in top down Z order:");
        for (int stackNdx = getChildCount() - 1; stackNdx >= 0; --stackNdx) {
Loading