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

Commit 8e297b47 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android Build Coastguard Worker
Browse files

Skip assigning ImeContainer layer in finish transaction

Since Id4c1c49ecb58b9f19718cb926f1ff2d76d791ad7, assignLayer
will always set to transaction for building finish transaction
of transition. That may cause potential transaction order issue,
such as the new layer is set when the transition is playing,
but the finish transaction sets to old layer when the transition
is finished.

Instead of skipping assigning layer of ImeContainer when a
transition is playing or collecting, just simply skip when
building finish transaction. Because it is common that IME
can show or hide when a transition is playing, it is better
to reflect current state immediately to avoid weird jumpcut
of IME appearance.

Bug: 443345373
Flag: EXEMPT BUGFIX
Test: WindowContainerTests#testAssignLayer
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:5e2a6fff03a55324e5c2d5d8d39babe8c75ad4ca
Merged-In: Icb50c80bc256e338d8fe197bebeb6fd2435f7eb2
Change-Id: Icb50c80bc256e338d8fe197bebeb6fd2435f7eb2
parent f94c5576
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -5449,7 +5449,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

        @Override
        void assignLayer(Transaction t, int layer) {
            if (!mNeedsLayer) {
            if (!mNeedsLayer || mTransitionController.mBuildingFinishLayers) {
                return;
            }
            super.assignLayer(t, layer);
@@ -5459,7 +5459,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        @Override
        void assignRelativeLayer(Transaction t, SurfaceControl relativeTo, int layer,
                boolean forceUpdate) {
            if (!mNeedsLayer) {
            if (!mNeedsLayer || mTransitionController.mBuildingFinishLayers) {
                return;
            }
            super.assignRelativeLayer(t, relativeTo, layer, forceUpdate);
@@ -5609,6 +5609,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            // When using FEATURE_IME, Organizer assumes the responsibility for placing the surface.
            return;
        }
        if (mTransitionController.mBuildingFinishLayers) {
            // IME layer can be updated during transition, e.g. an activity can request to show
            // IME when it is opening. So it doesn't need to enforce the end state with finish
            // transaction of transition. This also avoids replacing new state with old state due
            // to transaction order issues (e.g. finish transaction contains old state).
            return;
        }

        mImeWindowsContainer.setNeedsLayer();
        final WindowState imeLayeringTarget = mImeLayeringTarget;
+5 −0
Original line number Diff line number Diff line
@@ -1144,6 +1144,11 @@ public class WindowContainerTests extends WindowTestsBase {
        clearInvocations(mTransaction);
        container.assignLayer(mTransaction, 1 /* layer */);
        verify(mTransaction).setLayer(container.mSurfaceControl, 1 /* layer */);
        // The layer of ImeContainer can only be updated from explicit IME state changes.
        mDisplayContent.assignChildLayers(mTransaction);
        final SurfaceControl imeContainerSc = mDisplayContent.getImeContainer().mSurfaceControl;
        verify(mTransaction, never()).setLayer(eq(imeContainerSc), anyInt());
        verify(mTransaction, never()).setRelativeLayer(eq(imeContainerSc), any(), anyInt());
        container.mTransitionController.mBuildingTransitionLayers = false;
        container.mTransitionController.mBuildingFinishLayers = false;