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

Commit f98870a5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add ability to rotate screen in AoD."

parents 9be46619 c7200e18
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -4617,4 +4617,9 @@
         If omitted, image editing will not be offered via Chooser.
         This name is in the ComponentName flattened format (package/class) [DO NOT TRANSLATE]  -->
    <string name="config_systemImageEditor" translatable="false"></string>

    <!-- Whether to force WindowOrientationListener to keep listening to its sensor, even when
         dreaming. This allows the AoD to rotate on devices without a wake device_orientation
         sensor. Note that this flag should only be enabled for development/testing use. -->
    <bool name="config_forceOrientationListenerEnabledWhileDreaming">false</bool>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -4148,4 +4148,6 @@
  <java-symbol type="bool" name="config_attachNavBarToAppDuringTransition" />

  <java-symbol type="bool" name="config_enableBackSound" />

  <java-symbol type="bool" name="config_forceOrientationListenerEnabledWhileDreaming" />
</resources>
+15 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ public abstract class WindowOrientationListener {
    private Sensor mSensor;
    private OrientationJudge mOrientationJudge;
    private int mCurrentRotation = -1;
    private final Context mContext;

    private final Object mLock = new Object();

@@ -88,6 +89,7 @@ public abstract class WindowOrientationListener {
     * This constructor is private since no one uses it.
     */
    private WindowOrientationListener(Context context, Handler handler, int rate) {
        mContext = context;
        mHandler = handler;
        mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
        mRate = rate;
@@ -284,6 +286,19 @@ public abstract class WindowOrientationListener {
        }
    }

    /**
     * Returns whether this WindowOrientationListener can remain enabled while the device is dozing.
     * If this returns true, it implies that the underlying sensor can still run while the AP is
     * asleep, and that the underlying sensor will wake the AP on an event.
     */
    public boolean shouldStayEnabledWhileDreaming() {
        if (mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_forceOrientationListenerEnabledWhileDreaming)) {
            return true;
        }
        return mSensor.getType() == Sensor.TYPE_DEVICE_ORIENTATION && mSensor.isWakeUpSensor();
    }

    abstract class OrientationJudge implements SensorEventListener {
        // Number of nanoseconds per millisecond.
        protected static final long NANOS_PER_MS = 1000000;
+8 −2
Original line number Diff line number Diff line
@@ -955,10 +955,16 @@ public class DisplayRotation {
                keyguardDrawComplete, windowManagerDrawComplete);

        boolean disable = true;

        // If the orientation listener uses a wake sensor, keep the orientation listener on if the
        // screen is on (regardless of wake state). This allows the AoD to rotate.
        //
        // Note: We postpone the rotating of the screen until the keyguard as well as the
        // window manager have reported a draw complete or the keyguard is going away in dismiss
        // mode.
        if (screenOnEarly && awake && ((keyguardDrawComplete && windowManagerDrawComplete))) {
        if (screenOnEarly
                && (awake || mOrientationListener.shouldStayEnabledWhileDreaming())
                && ((keyguardDrawComplete && windowManagerDrawComplete))) {
            if (needSensorRunning()) {
                disable = false;
                // Enable listener if not already enabled.
@@ -974,7 +980,7 @@ public class DisplayRotation {
            }
        }
        // Check if sensors need to be disabled.
        if (disable && mOrientationListener.mEnabled) {
        if (disable) {
            mOrientationListener.disable();
        }
    }