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

Commit fd6cd7ff authored by Mariia Sandrikova's avatar Mariia Sandrikova Committed by Automerger Merge Worker
Browse files

Merge "Support respecting nosensor and locked when docked." into tm-qpr-dev...

Merge "Support respecting nosensor and locked when docked." into tm-qpr-dev am: 088907e9 am: 6bca0c3e am: aee5c182 am: daedd08c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22163991



Change-Id: I7ac6f2155272a58457a305d6140a3d5b0c46205a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 960b1490 daedd08c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -755,6 +755,11 @@
         we rely on gravity to determine the effective orientation. -->
    <bool name="config_deskDockEnablesAccelerometer">true</bool>

    <!-- Control whether nosensor and locked orientation requests are respected from the app when
         config_deskDockEnablesAccelerometer is set to false.
         TODO(b/274763533): Consider making true by default and removing this. -->
    <bool name="config_deskRespectsNoSensorAndLockedWithoutAccelerometer">false</bool>

    <!-- Car dock behavior -->

    <!-- The number of degrees to rotate the display when the device is in a car dock.
+1 −0
Original line number Diff line number Diff line
@@ -1692,6 +1692,7 @@
  <java-symbol type="bool" name="config_carDockEnablesAccelerometer" />
  <java-symbol type="bool" name="config_customUserSwitchUi" />
  <java-symbol type="bool" name="config_deskDockEnablesAccelerometer" />
  <java-symbol type="bool" name="config_deskRespectsNoSensorAndLockedWithoutAccelerometer" />
  <java-symbol type="bool" name="config_disableMenuKeyInLockScreen" />
  <java-symbol type="bool" name="config_enableCarDockHomeLaunch" />
  <java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" />
+9 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ public class DisplayPolicy {

    private final boolean mCarDockEnablesAccelerometer;
    private final boolean mDeskDockEnablesAccelerometer;
    private final boolean mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer;
    private final AccessibilityManager mAccessibilityManager;
    private final ImmersiveModeConfirmation mImmersiveModeConfirmation;
    private final ScreenshotHelper mScreenshotHelper;
@@ -387,6 +388,8 @@ public class DisplayPolicy {
        final Resources r = mContext.getResources();
        mCarDockEnablesAccelerometer = r.getBoolean(R.bool.config_carDockEnablesAccelerometer);
        mDeskDockEnablesAccelerometer = r.getBoolean(R.bool.config_deskDockEnablesAccelerometer);
        mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer =
                r.getBoolean(R.bool.config_deskRespectsNoSensorAndLockedWithoutAccelerometer);
        mCanSystemBarsBeShownByUser = !r.getBoolean(
                R.bool.config_remoteInsetsControllerControlsSystemBars) || r.getBoolean(
                R.bool.config_remoteInsetsControllerSystemBarsCanBeShownByUserAction);
@@ -698,6 +701,10 @@ public class DisplayPolicy {
        return mDeskDockEnablesAccelerometer;
    }

    boolean isDeskDockRespectsNoSensorAndLockedWithoutAccelerometer() {
        return mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer;
    }

    public void setPersistentVrModeEnabled(boolean persistentVrModeEnabled) {
        mPersistentVrModeEnabled = persistentVrModeEnabled;
    }
@@ -2443,6 +2450,8 @@ public class DisplayPolicy {
        pw.print("mCarDockEnablesAccelerometer="); pw.print(mCarDockEnablesAccelerometer);
        pw.print(" mDeskDockEnablesAccelerometer=");
        pw.println(mDeskDockEnablesAccelerometer);
        pw.print(" mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer=");
        pw.println(mDeskDockRespectsNoSensorAndLockedWithoutAccelerometer);
        pw.print(prefix); pw.print("mDockMode="); pw.print(Intent.dockStateToString(mDockMode));
        pw.print(" mLidState="); pw.println(WindowManagerFuncs.lidStateToString(mLidState));
        pw.print(prefix); pw.print("mAwake="); pw.print(mAwake);
+6 −1
Original line number Diff line number Diff line
@@ -1198,6 +1198,10 @@ public class DisplayRotation {
                mDisplayPolicy.isCarDockEnablesAccelerometer();
        final boolean deskDockEnablesAccelerometer =
                mDisplayPolicy.isDeskDockEnablesAccelerometer();
        final boolean deskDockRespectsNoSensorAndLockedWithoutAccelerometer =
                mDisplayPolicy.isDeskDockRespectsNoSensorAndLockedWithoutAccelerometer()
                        && (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED
                                || orientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);

        @Surface.Rotation
        final int preferredRotation;
@@ -1217,7 +1221,8 @@ public class DisplayRotation {
        } else if ((dockMode == Intent.EXTRA_DOCK_STATE_DESK
                || dockMode == Intent.EXTRA_DOCK_STATE_LE_DESK
                || dockMode == Intent.EXTRA_DOCK_STATE_HE_DESK)
                && (deskDockEnablesAccelerometer || mDeskDockRotation >= 0)) {
                && (deskDockEnablesAccelerometer || mDeskDockRotation >= 0)
                && !deskDockRespectsNoSensorAndLockedWithoutAccelerometer) {
            // Ignore sensor when in desk dock unless explicitly enabled.
            // This case can override the behavior of NOSENSOR, and can also
            // enable 180 degree rotation while docked.
+19 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.server.wm;

import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LOCKED;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
@@ -865,6 +867,23 @@ public class DisplayRotationTests {
                SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_90));
    }

    @Test
    public void testIgnoresDeskDockRotation_whenNoSensorAndLockedRespected() throws Exception {
        mBuilder.setDeskDockRotation(Surface.ROTATION_270).build();
        when(mMockDisplayPolicy.isDeskDockRespectsNoSensorAndLockedWithoutAccelerometer())
                .thenReturn(true);
        configureDisplayRotation(SCREEN_ORIENTATION_LANDSCAPE, false, false);

        when(mMockDisplayPolicy.getDockMode()).thenReturn(Intent.EXTRA_DOCK_STATE_DESK);

        freezeRotation(Surface.ROTATION_90);

        assertEquals(Surface.ROTATION_90, mTarget.rotationForOrientation(
                SCREEN_ORIENTATION_LOCKED, Surface.ROTATION_90));
        assertEquals(Surface.ROTATION_0, mTarget.rotationForOrientation(
                SCREEN_ORIENTATION_NOSENSOR, Surface.ROTATION_90));
    }

    @Test
    public void testReturnsUserRotation_FixedToUserRotation_IgnoreIncompatibleAppRequest()
            throws Exception {