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

Commit 5342e2b7 authored by Abel Tesfaye's avatar Abel Tesfaye
Browse files

Check for locked screen in DisplayRotation and

disable rotation resolver when power save mode is enabled

Disable RotationResolver when the screen is rotation locked.
This fixes an issue where AiAiAutoRotate would run & print to logs
when screen rotation is locked. It also prevents smart auto rotate
from running when power save mode is enabled.

Test: local, enabled auto rotate & camera rotate then disabled
autorotate & checked AiAiAutoRotate didn't show up in logs,
by enabling power save mode and face detection then checking camera
rotation not working

Bug: 185822472
Bug: 186690152
Change-Id: Ie312e85f5d225bcb5cc1036d53e882f01f4f07a9
parent b5ddeefc
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.