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

This commit is contained in:
Abel Tesfaye
2021-05-18 18:27:38 +00:00
committed by Android (Google) Code Review
2 changed files with 25 additions and 8 deletions

View File

@@ -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();
}

View File

@@ -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.