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

Commit 943589cf authored by Tiger Huang's avatar Tiger Huang Committed by Android (Google) Code Review
Browse files

Merge "Update requested state after applying pending frames" into rvc-qpr-dev

parents 16206cbc 1a53789b
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -629,7 +629,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            if (DEBUG) Log.d(TAG, "onStateChanged, notifyInsetsChanged");
            if (DEBUG) Log.d(TAG, "onStateChanged, notifyInsetsChanged");
            mHost.notifyInsetsChanged();
            mHost.notifyInsetsChanged();
        }
        }
        if (!mState.equals(state, true /* excludingCaptionInsets */,
        if (!mState.equals(mLastDispatchedState, true /* excludingCaptionInsets */,
                true /* excludeInvisibleIme */)) {
                true /* excludeInvisibleIme */)) {
            if (DEBUG) Log.d(TAG, "onStateChanged, send state to WM: " + mState);
            if (DEBUG) Log.d(TAG, "onStateChanged, send state to WM: " + mState);
            updateRequestedState();
            updateRequestedState();
@@ -1138,15 +1138,14 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        if (invokeCallback) {
        if (invokeCallback) {
            control.cancel();
            control.cancel();
        }
        }
        boolean stateChanged = false;
        for (int i = mRunningAnimations.size() - 1; i >= 0; i--) {
        for (int i = mRunningAnimations.size() - 1; i >= 0; i--) {
            RunningAnimation runningAnimation = mRunningAnimations.get(i);
            RunningAnimation runningAnimation = mRunningAnimations.get(i);
            if (runningAnimation.runner == control) {
            if (runningAnimation.runner == control) {
                mRunningAnimations.remove(i);
                mRunningAnimations.remove(i);
                ArraySet<Integer> types = toInternalType(control.getTypes());
                ArraySet<Integer> types = toInternalType(control.getTypes());
                for (int j = types.size() - 1; j >= 0; j--) {
                for (int j = types.size() - 1; j >= 0; j--) {
                    if (getSourceConsumer(types.valueAt(j)).notifyAnimationFinished()) {
                    stateChanged |= getSourceConsumer(types.valueAt(j)).notifyAnimationFinished();
                        mHost.notifyInsetsChanged();
                    }
                }
                }
                if (invokeCallback && runningAnimation.startDispatched) {
                if (invokeCallback && runningAnimation.startDispatched) {
                    dispatchAnimationEnd(runningAnimation.runner.getAnimation());
                    dispatchAnimationEnd(runningAnimation.runner.getAnimation());
@@ -1154,6 +1153,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                break;
                break;
            }
            }
        }
        }
        if (stateChanged) {
            mHost.notifyInsetsChanged();
            updateRequestedState();
        }
    }
    }


    private void applyLocalVisibilityOverride() {
    private void applyLocalVisibilityOverride() {
+14 −0
Original line number Original line Diff line number Diff line
@@ -746,6 +746,20 @@ public class InsetsControllerTest {
            mController.onControlsChanged(createSingletonControl(ITYPE_IME));
            mController.onControlsChanged(createSingletonControl(ITYPE_IME));
            assertEquals(newState.getSource(ITYPE_IME),
            assertEquals(newState.getSource(ITYPE_IME),
                    mTestHost.getModifiedState().peekSource(ITYPE_IME));
                    mTestHost.getModifiedState().peekSource(ITYPE_IME));

            // The modified frames cannot be updated if there is an animation.
            mController.onControlsChanged(createSingletonControl(ITYPE_NAVIGATION_BAR));
            mController.hide(navigationBars());
            newState = new InsetsState(mController.getState(), true /* copySource */);
            newState.getSource(ITYPE_NAVIGATION_BAR).getFrame().top--;
            mController.onStateChanged(newState);
            assertNotEquals(newState.getSource(ITYPE_NAVIGATION_BAR),
                    mTestHost.getModifiedState().peekSource(ITYPE_NAVIGATION_BAR));

            // The modified frames can be updated while the animation is done.
            mController.cancelExistingAnimations();
            assertEquals(newState.getSource(ITYPE_NAVIGATION_BAR),
                    mTestHost.getModifiedState().peekSource(ITYPE_NAVIGATION_BAR));
        });
        });
    }
    }