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

Commit f6f91b34 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Notify remote rotation with fixed rotation transform" into rvc-dev

parents 2be42fbe 06aeb069
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -1317,8 +1317,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        if (mDisplayRotation.isWaitingForRemoteRotation()) {
            return;
        }
        // Clear the record because the display will sync to current rotation.
        mFixedRotationLaunchingApp = null;

        final boolean configUpdated = updateDisplayOverrideConfigurationLocked();
        if (configUpdated) {
@@ -1509,7 +1507,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        startFixedRotationTransform(r, rotation);
        mAppTransition.registerListenerLocked(new WindowManagerInternal.AppTransitionListener() {
            void done() {
                r.clearFixedRotationTransform();
                r.finishFixedRotationTransform();
                mAppTransition.unregisterListener(this);
            }

@@ -1538,7 +1536,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        if (token != mFixedRotationLaunchingApp) {
            return false;
        }
        if (updateOrientation()) {
        // Update directly because the app which will change the orientation of display is ready.
        if (mDisplayRotation.updateOrientation(getOrientation(), false /* forceUpdate */)) {
            sendNewConfiguration();
            return true;
        }
@@ -1584,7 +1583,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
     * @param oldRotation the rotation we are coming from.
     * @param rotation the rotation to apply.
     */
    void applyRotationLocked(final int oldRotation, final int rotation) {
    private void applyRotation(final int oldRotation, final int rotation) {
        mDisplayRotation.applyCurrentRotation(rotation);
        final boolean rotateSeamlessly = mDisplayRotation.isRotatingSeamlessly();
        final Transaction transaction = getPendingTransaction();
@@ -6493,15 +6492,20 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

    @Override
    public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) {
        final int currRotation =
                getRequestedOverrideConfiguration().windowConfiguration.getRotation();
        if (currRotation != ROTATION_UNDEFINED
                && currRotation != overrideConfiguration.windowConfiguration.getRotation()) {
            applyRotationLocked(currRotation,
                    overrideConfiguration.windowConfiguration.getRotation());
        }
        mCurrentOverrideConfigurationChanges =
            getRequestedOverrideConfiguration().diff(overrideConfiguration);
        final Configuration currOverrideConfig = getRequestedOverrideConfiguration();
        final int currRotation = currOverrideConfig.windowConfiguration.getRotation();
        final int overrideRotation = overrideConfiguration.windowConfiguration.getRotation();
        if (currRotation != ROTATION_UNDEFINED && currRotation != overrideRotation) {
            if (mFixedRotationLaunchingApp != null) {
                mFixedRotationLaunchingApp.clearFixedRotationTransform(
                        () -> applyRotation(currRotation, overrideRotation));
                // Clear the record because the display will sync to current rotation.
                mFixedRotationLaunchingApp = null;
            } else {
                applyRotation(currRotation, overrideRotation);
            }
        }
        mCurrentOverrideConfigurationChanges = currOverrideConfig.diff(overrideConfiguration);
        super.onRequestedOverrideConfigurationChanged(overrideConfiguration);
        mCurrentOverrideConfigurationChanges = 0;
        mWmService.setNewDisplayOverrideConfiguration(overrideConfiguration, this);
+2 −5
Original line number Diff line number Diff line
@@ -484,11 +484,8 @@ public class DisplayRotation {
            prepareNormalRotationAnimation();
        }

        // TODO(b/147469351): Remove the restriction.
        if (mDisplayContent.mFixedRotationLaunchingApp == null) {
        // Give a remote handler (system ui) some time to reposition things.
        startRemoteRotation(oldRotation, mRotation);
        }

        return true;
    }
+1 −1
Original line number Diff line number Diff line
@@ -667,7 +667,7 @@ public class RecentsAnimationController implements DeathRecipient {
                        mTargetActivityRecord.token);
            }
            if (mTargetActivityRecord.hasFixedRotationTransform()) {
                mTargetActivityRecord.clearFixedRotationTransform();
                mTargetActivityRecord.finishFixedRotationTransform();
            }
        }

+28 −12
Original line number Diff line number Diff line
@@ -480,26 +480,42 @@ class WindowToken extends WindowContainer<WindowState> {
    }

    /**
     * Clears the transformation and continue updating the orientation change of display. Only the
     * state owner can clear the transform state.
     * Finishes the transform and continue updating the orientation change of display. Only the
     * state owner can finish the transform state.
     */
    void clearFixedRotationTransform() {
    void finishFixedRotationTransform() {
        if (mFixedRotationTransformState == null || mFixedRotationTransformState.mOwner != this) {
            return;
        }
        final boolean changed =
                mDisplayContent.continueUpdateOrientationForDiffOrienLaunchingApp(this);
        // If it is not the launching app or the display is not rotated, make sure the transform is
        // cleared and the configuration is restored from parent.
        if (!changed) {
            clearFixedRotationTransform(null /* applyDisplayRotation */);
            onConfigurationChanged(getParent().getConfiguration());
        }
    }

    /**
     * Clears the transform and apply display rotation if the action is given. The caller needs to
     * refresh the configuration of this container after this method call.
     */
    void clearFixedRotationTransform(Runnable applyDisplayRotation) {
        final FixedRotationTransformState state = mFixedRotationTransformState;
        if (state == null || state.mOwner != this) {
        if (state == null) {
            return;
        }

        state.resetTransform();
        // Clear the flag so if the display will be updated to the same orientation, the transform
        // won't take effect. The state is cleared at the end, because it is used to indicate that
        // other windows can use seamless rotation when applying rotation to display.
        // won't take effect.
        state.mIsTransforming = false;
        final boolean changed =
                mDisplayContent.continueUpdateOrientationForDiffOrienLaunchingApp(this);
        // If it is not the launching app or the display is not rotated, make sure the merged
        // override configuration is restored from parent.
        if (!changed) {
            onMergedOverrideConfigurationChanged();
        if (applyDisplayRotation != null) {
            applyDisplayRotation.run();
        }
        // The state is cleared at the end, because it is used to indicate that other windows can
        // use seamless rotation when applying rotation to display.
        for (int i = state.mAssociatedTokens.size() - 1; i >= 0; i--) {
            state.mAssociatedTokens.get(i).mFixedRotationTransformState = null;
        }
+2 −2
Original line number Diff line number Diff line
@@ -403,11 +403,11 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
                wallpapers.get(0).getConfiguration().orientation);

        // Wallpaper's transform state is controlled by home, so the invocation should be no-op.
        wallpaperWindowToken.clearFixedRotationTransform();
        wallpaperWindowToken.finishFixedRotationTransform();
        assertTrue(wallpaperWindowToken.hasFixedRotationTransform());

        // Wallpaper's transform state should be cleared with home.
        homeActivity.clearFixedRotationTransform();
        homeActivity.finishFixedRotationTransform();
        assertFalse(wallpaperWindowToken.hasFixedRotationTransform());
    }