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

Commit e3f5afaf authored by Evan Rosky's avatar Evan Rosky
Browse files

Don't send configuration updates to apps that are going-away

Specifically, this adds checks for isVisibleRequested == false and
avoids sending new configs or other events. If an app is going to
be hidden, usually it means we're in an animation and don't want
it to relayout.

Bug: 179270750
Test: existing tests pass and phone behavior remains unchanged.
Change-Id: I8e8e21fcd3b8f4ff0f9b22d04c1abb908e719422
parent 26737223
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6533,7 +6533,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // Allowing closing {@link ActivityRecord} to participate can lead to an Activity in another
        // task being started in the wrong orientation during the transition.
        if (!getDisplayContent().mClosingApps.contains(this)
                && (isVisible() || getDisplayContent().mOpeningApps.contains(this))) {
                && (isVisibleRequested() || getDisplayContent().mOpeningApps.contains(this))) {
            return mOrientation;
        }

+4 −2
Original line number Diff line number Diff line
@@ -948,7 +948,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }

        final ActivityRecord activity = w.mActivityRecord;
        if (activity != null) {
        if (activity != null && activity.isVisibleRequested()) {
            activity.updateLetterboxSurface(w);
            final boolean updateAllDrawn = activity.updateDrawnWindowStates(w);
            if (updateAllDrawn && !mTmpUpdateAllDrawn.contains(activity)) {
@@ -1447,7 +1447,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }
            config = new Configuration();
            computeScreenConfiguration(config);
        } else if (currentConfig != null) {
        } else if (currentConfig != null
                // If waiting for a remote rotation, don't prematurely update configuration.
                && !mDisplayRotation.isWaitingForRemoteRotation()) {
            // No obvious action we need to take, but if our current state mismatches the
            // activity manager's, update it, disregarding font scale, which should remain set
            // to the value of the previous configuration.
+2 −2
Original line number Diff line number Diff line
@@ -481,12 +481,12 @@ public class DisplayRotation {

        mRotation = rotation;

        mDisplayContent.setLayoutNeeded();

        mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_ACTIVE;
        mService.mH.sendNewMessageDelayed(WindowManagerService.H.WINDOW_FREEZE_TIMEOUT,
                mDisplayContent, WINDOW_FREEZE_TIMEOUT_DURATION);

        mDisplayContent.setLayoutNeeded();

        if (shouldRotateSeamlessly(oldRotation, rotation, forceUpdate)) {
            // The screen rotation animation uses a screenshot to freeze the screen while windows
            // resize underneath. When we are rotating seamlessly, we allow the elements to
+9 −3
Original line number Diff line number Diff line
@@ -1722,7 +1722,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP

    @Override
    boolean isVisibleRequested() {
        return isVisible();
        return isVisible() && (mActivityRecord == null || mActivityRecord.isVisibleRequested());
    }

    /**
@@ -2133,7 +2133,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                && !mAnimatingExit
                && (mWindowFrames.mRelFrame.top != mWindowFrames.mLastRelFrame.top
                    || mWindowFrames.mRelFrame.left != mWindowFrames.mLastRelFrame.left)
                && (!mIsChildWindow || !getParentWindow().hasMoved());
                && (!mIsChildWindow || !getParentWindow().hasMoved())
                && !mWmService.mAtmService.getTransitionController().isCollecting();
    }

    boolean isObscuringDisplay() {
@@ -3642,6 +3643,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        if (mActivityRecord != null && mActivityRecord.isRelaunching()) {
            return;
        }
        // If the activity is invisible or going invisible, don't report either since it is going
        // away. This is likely during a transition so we want to preserve the original state.
        if (mActivityRecord != null && !mActivityRecord.isVisibleRequested()) {
            return;
        }

        if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) {
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "wm.reportResized_" + getWindowTag());
@@ -5326,7 +5332,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        updateSurfacePositionNonOrganized();
        // Send information to SufaceFlinger about the priority of the current window.
        updateFrameRateSelectionPriorityIfNeeded();
        updateGlobalScaleIfNeeded();
        if (isVisibleRequested()) updateGlobalScaleIfNeeded();

        mWinAnimator.prepareSurfaceLocked(getSyncTransaction());
        super.prepareSurfaces();
+2 −1
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
                .setTask(mTrampolineActivity.getTask())
                .setComponent(createRelative(DEFAULT_COMPONENT_PACKAGE_NAME, "TopActivity"))
                .build();
        // becomes invisible when covered by mTopActivity
        mTrampolineActivity.mVisibleRequested = false;
    }

    @After
@@ -230,7 +232,6 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {

    @Test
    public void testOnActivityLaunchCancelled_finishedBeforeDrawn() {
        mTopActivity.mVisibleRequested = true;
        doReturn(true).when(mTopActivity).isReportedDrawn();

        // Create an activity with different process that meets process switch.
Loading