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

Commit 04816e06 authored by Abel Tesfaye's avatar Abel Tesfaye Committed by Automerger Merge Worker
Browse files

Merge "Check for locked screen in DisplayRotation and disable rotation...

Merge "Check for locked screen in DisplayRotation and disable rotation resolver when power save mode is enabled" into sc-dev am: a025621b am: ee0c27a8

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

Change-Id: I3081ab4eac4b85b3c3a38cd36c157ab5ed555df2
parents 2b38769e ee0c27a8
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -186,6 +186,10 @@ public class DisplayRotation {
    @Surface.Rotation
    private int mUserRotation = Surface.ROTATION_0;

    private static final int CAMERA_ROTATION_DISABLED = 0;
    private static final int CAMERA_ROTATION_ENABLED = 1;
    private int mCameraRotationMode = CAMERA_ROTATION_DISABLED;

    /**
     * Flag that indicates this is a display that may run better when fixed to user rotation.
     */
@@ -1462,6 +1466,14 @@ public class DisplayRotation {
            if (shouldUpdateOrientationListener) {
                updateOrientationListenerLw(); // Enable or disable the orientation listener.
            }

            final int cameraRotationMode = Settings.Secure.getIntForUser(resolver,
                    Settings.Secure.CAMERA_AUTOROTATE, 0,
                    UserHandle.USER_CURRENT);
            if (mCameraRotationMode != cameraRotationMode) {
                mCameraRotationMode = cameraRotationMode;
                shouldUpdateRotation = true;
            }
        }

        return shouldUpdateRotation;
@@ -1491,6 +1503,7 @@ public class DisplayRotation {
        pw.print(prefix + "  mUserRotationMode="
                + WindowManagerPolicy.userRotationModeToString(mUserRotationMode));
        pw.print(" mUserRotation=" + Surface.rotationToString(mUserRotation));
        pw.print(" mCameraRotationMode=" + mCameraRotationMode);
        pw.println(" mAllowAllRotations=" + allowAllRotationsToString(mAllowAllRotations));

        pw.print(prefix + "  mDemoHdmiRotation=" + Surface.rotationToString(mDemoHdmiRotation));
@@ -1539,6 +1552,13 @@ public class DisplayRotation {
            }
        }

        @Override
        public boolean isRotationResolverEnabled() {
            return mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE
                    && mCameraRotationMode == CAMERA_ROTATION_ENABLED
                    && !mService.mPowerManager.isPowerSaveMode();
        }


        @Override
        public void onProposedRotationChanged(int rotation) {
@@ -1582,6 +1602,10 @@ public class DisplayRotation {
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.USER_ROTATION), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(
                    Settings.Secure.getUriFor(Settings.Secure.CAMERA_AUTOROTATE), false, this,
                    UserHandle.USER_ALL);

            updateSettings();
        }

+1 −8
Original line number Diff line number Diff line
@@ -31,9 +31,7 @@ import android.os.CancellationSignal;
import android.os.Handler;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.rotationresolver.RotationResolverInternal;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
@@ -66,7 +64,6 @@ public abstract class WindowOrientationListener {

    private static final boolean USE_GRAVITY_SENSOR = false;
    private static final int DEFAULT_BATCH_LATENCY = 100000;
    private static final int DEFAULT_ROTATION_RESOLVER_ENABLED = 0; // disabled
    private static final String KEY_ROTATION_RESOLVER_TIMEOUT = "rotation_resolver_timeout_millis";
    private static final long DEFAULT_ROTATION_RESOLVER_TIMEOUT_MILLIS = 700L;

@@ -278,11 +275,7 @@ public abstract class WindowOrientationListener {
     * screen rotation.
     */
    @VisibleForTesting
    boolean isRotationResolverEnabled() {
        return Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.CAMERA_AUTOROTATE, DEFAULT_ROTATION_RESOLVER_ENABLED,
                UserHandle.USER_CURRENT) == 1;
    }
    abstract boolean isRotationResolverEnabled();

    /**
     * Called when the rotation view of the device has changed.