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

Commit 502e6361 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Only notify prepare-surface callback from window animator

Since the surface operations are centralized to window animator,
the operations that expect to run after transaction applied
should also be only executed by window animator.

Otherwise there could be a race:
 system-relayout: T1 shows the surface and sends surface to client.
 client: T2 applies hide.
 system-vsync: T1 is merged to T0, T0 is applied.
  -> expected hide but got overridden to show.

Bug: 318760302
Test: Disable animation and launch an app which requests to hide
      status bar. Keep switching between the app and home. Check
      that when the app is on top, the status bar is hidden.
Change-Id: Ic6f99be2907690fa955f6cfb424c4d0f68abf004
parent f7a526b9
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -808,7 +808,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        mWmService.mAtmService.mTaskOrganizerController.dispatchPendingEvents();
        mWmService.mAtmService.mTaskFragmentOrganizerController.dispatchPendingEvents();
        mWmService.mSyncEngine.onSurfacePlacement();
        mWmService.mAnimator.executeAfterPrepareSurfacesRunnables();

        checkAppTransitionReady(surfacePlacer);

+3 −3
Original line number Diff line number Diff line
@@ -3309,7 +3309,7 @@ public class ActivityRecordTests extends WindowTestsBase {
        // keyguard to back to the app, expect IME insets is not frozen
        app.mActivityRecord.commitVisibility(true, false);
        mDisplayContent.updateImeInputAndControlTarget(app);
        mDisplayContent.mWmService.mRoot.performSurfacePlacement();
        performSurfacePlacementAndWaitForWindowAnimator();

        assertFalse(app.mActivityRecord.mImeInsetsFrozenUntilStartInput);

@@ -3358,7 +3358,7 @@ public class ActivityRecordTests extends WindowTestsBase {
        mDisplayContent.setImeLayeringTarget(app2);
        app2.mActivityRecord.commitVisibility(true, false);
        mDisplayContent.updateImeInputAndControlTarget(app2);
        mDisplayContent.mWmService.mRoot.performSurfacePlacement();
        performSurfacePlacementAndWaitForWindowAnimator();

        // Verify after unfreezing app2's IME insets state, we won't dispatch visible IME insets
        // to client if the app didn't request IME visible.
@@ -3412,7 +3412,7 @@ public class ActivityRecordTests extends WindowTestsBase {
        // frozen until the input started.
        mDisplayContent.setImeLayeringTarget(app1);
        mDisplayContent.updateImeInputAndControlTarget(app1);
        mDisplayContent.mWmService.mRoot.performSurfacePlacement();
        performSurfacePlacementAndWaitForWindowAnimator();

        assertEquals(app1, mDisplayContent.getImeInputTarget());
        assertFalse(activity1.mImeInsetsFrozenUntilStartInput);
+13 −0
Original line number Diff line number Diff line
@@ -1053,6 +1053,19 @@ class WindowTestsBase extends SystemServiceTestsBase {
        displayRotation.configure(dc.mBaseDisplayWidth, dc.mBaseDisplayHeight);
    }

    /**
     * Performs surface placement and waits for WindowAnimator to complete the frame. It is used
     * to execute the callbacks if the surface placement is expected to add some callbacks via
     * {@link WindowAnimator#addAfterPrepareSurfacesRunnable}.
     */
    void performSurfacePlacementAndWaitForWindowAnimator() {
        mWm.mAnimator.ready();
        if (!mWm.mWindowPlacerLocked.isTraversalScheduled()) {
            mRootWindowContainer.performSurfacePlacement();
        }
        waitUntilWindowAnimatorIdle();
    }

    /**
     * Avoids rotating screen disturbed by some conditions. It is usually used for the default
     * display that is not the instance of {@link TestDisplayContent} (it bypasses the conditions).