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

Commit a03cc062 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Allow to use fixed rotation with remote swipe-unlock animation" into sc-dev

parents d8c85479 4b6d4c81
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -551,7 +551,13 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
            }
            final WindowManagerPolicy policy = mWmService.mPolicy;
            if (policy.isKeyguardHostWindow(w.mAttrs)) {
                if (mWmService.mKeyguardGoingAway) {
                // Ignore the orientation of keyguard if it is going away or is not showing while
                // the device is fully awake. In other words, use the orientation of keyguard if
                // its window is visible while the device is going to sleep or is sleeping.
                if (!mWmService.mAtmService.isKeyguardLocked()
                        && mDisplayContent.getDisplayPolicy().isAwake()
                        // Device is not going to sleep.
                        && policy.okToAnimate(true /* ignoreScreenOn */)) {
                    return false;
                }
                // Consider unoccluding only when all unknown visibilities have been
+0 −6
Original line number Diff line number Diff line
@@ -1564,12 +1564,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                // window was transferred ({@link #mSkipAppTransitionAnimation}).
                return false;
            }
            if ((mAppTransition.getTransitFlags()
                    & WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) != 0) {
                // The transition may be finished before keyguard hidden. In order to avoid the
                // intermediate orientation change, it is more stable to freeze the display.
                return false;
            }
            if (r.isState(RESUMED) && !r.getRootTask().mInResumeTopActivity) {
                // If the activity is executing or has done the lifecycle callback, use normal
                // rotation animation so the display info can be updated immediately (see
+2 −11
Original line number Diff line number Diff line
@@ -72,7 +72,6 @@ class KeyguardController {
    private boolean mAodShowing;
    private boolean mKeyguardGoingAway;
    private boolean mDismissalRequested;
    private int mBeforeUnoccludeTransit;
    private final SparseArray<KeyguardDisplayState> mDisplayStates = new SparseArray<>();
    private final ActivityTaskManagerService mService;
    private RootWindowContainer mRootWindowContainer;
@@ -191,14 +190,11 @@ class KeyguardController {
            // Irrelevant to AOD.
            dismissMultiWindowModeForTaskIfNeeded(null /* currentTaskControllsingOcclusion */,
                    false /* turningScreenOn */);
            setKeyguardGoingAway(false);
            mKeyguardGoingAway = false;
            if (keyguardShowing) {
                mDismissalRequested = false;
            }
        }
        // TODO(b/113840485): Check usage for non-default display
        mWindowManager.setKeyguardOrAodShowingOnDefaultDisplay(
                isKeyguardOrAodShowing(DEFAULT_DISPLAY));

        // Update the sleep token first such that ensureActivitiesVisible has correct sleep token
        // state when evaluating visibilities.
@@ -219,8 +215,8 @@ class KeyguardController {
        }
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "keyguardGoingAway");
        mService.deferWindowLayout();
        mKeyguardGoingAway = true;
        try {
            setKeyguardGoingAway(true);
            EventLogTags.writeWmSetKeyguardShown(
                    1 /* keyguardShowing */,
                    mAodShowing ? 1 : 0,
@@ -258,11 +254,6 @@ class KeyguardController {
        mWindowManager.dismissKeyguard(callback, message);
    }

    private void setKeyguardGoingAway(boolean keyguardGoingAway) {
        mKeyguardGoingAway = keyguardGoingAway;
        mWindowManager.setKeyguardGoingAway(keyguardGoingAway);
    }

    private void failCallback(IKeyguardDismissCallback callback) {
        try {
            callback.onDismissError();
+1 −15
Original line number Diff line number Diff line
@@ -483,10 +483,7 @@ public class WindowManagerService extends IWindowManager.Stub
    private final DisplayAreaPolicy.Provider mDisplayAreaPolicyProvider;

    final private KeyguardDisableHandler mKeyguardDisableHandler;
    // TODO: eventually unify all keyguard state in a common place instead of having it spread over
    // AM's KeyguardController and the policy's KeyguardServiceDelegate.
    boolean mKeyguardGoingAway;
    boolean mKeyguardOrAodShowingOnDefaultDisplay;

    // VR Vr2d Display Id.
    int mVr2dDisplayId = INVALID_DISPLAY;
    boolean mVrModeEnabled = false;
@@ -3072,17 +3069,6 @@ public class WindowManagerService extends IWindowManager.Stub
        mAtmInternal.notifyKeyguardFlagsChanged(callback, displayId);
    }

    public void setKeyguardGoingAway(boolean keyguardGoingAway) {
        synchronized (mGlobalLock) {
            mKeyguardGoingAway = keyguardGoingAway;
        }
    }

    public void setKeyguardOrAodShowingOnDefaultDisplay(boolean showing) {
        synchronized (mGlobalLock) {
            mKeyguardOrAodShowingOnDefaultDisplay = showing;
        }
    }

    // -------------------------------------------------------------
    // Misc IWindowSession methods
+5 −10
Original line number Diff line number Diff line
@@ -100,7 +100,6 @@ import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doCallRealMethod;

import android.annotation.SuppressLint;
import android.app.ActivityTaskManager;
import android.app.WindowConfiguration;
import android.app.servertransaction.FixedRotationAdjustmentsItem;
@@ -792,15 +791,9 @@ public class DisplayContentTests extends WindowTestsBase {
    }

    @Test
    @SuppressLint("InlinedApi")
    public void testOrientationDefinedByKeyguard() {
        final DisplayContent dc = createNewDisplay();

        // When display content is created its configuration is not yet initialized, which could
        // cause unnecessary configuration propagation, so initialize it here.
        final Configuration config = new Configuration();
        dc.computeScreenConfiguration(config);
        dc.onRequestedOverrideConfigurationChanged(config);
        final DisplayContent dc = mDisplayContent;
        dc.getDisplayPolicy().setAwake(true);

        // Create a window that requests landscape orientation. It will define device orientation
        // by default.
@@ -815,10 +808,12 @@ public class DisplayContentTests extends WindowTestsBase {
                SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation());

        keyguard.mAttrs.screenOrientation = SCREEN_ORIENTATION_PORTRAIT;
        mAtm.mKeyguardController.setKeyguardShown(true /* keyguardShowing */,
                false /* aodShowing */);
        assertEquals("Visible keyguard must influence device orientation",
                SCREEN_ORIENTATION_PORTRAIT, dc.getOrientation());

        mWm.setKeyguardGoingAway(true);
        mAtm.mKeyguardController.keyguardGoingAway(0 /* flags */);
        assertEquals("Keyguard that is going away must not influence device orientation",
                SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation());
    }