summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/res/res/values/config.xml5
-rw-r--r--core/res/res/values/symbols.xml2
-rw-r--r--services/core/java/com/android/server/policy/WindowOrientationListener.java15
-rw-r--r--services/core/java/com/android/server/wm/DisplayRotation.java10
4 files changed, 30 insertions, 2 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 1845faacc891..010d047c2c31 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -4610,4 +4610,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>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index c72a0cd63b36..20db4c6f2e3f 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -4146,4 +4146,6 @@
<java-symbol type="bool" name="config_attachNavBarToAppDuringTransition" />
<java-symbol type="bool" name="config_enableBackSound" />
+
+ <java-symbol type="bool" name="config_forceOrientationListenerEnabledWhileDreaming" />
</resources>
diff --git a/services/core/java/com/android/server/policy/WindowOrientationListener.java b/services/core/java/com/android/server/policy/WindowOrientationListener.java
index 0157706866c7..17e81daa80cc 100644
--- a/services/core/java/com/android/server/policy/WindowOrientationListener.java
+++ b/services/core/java/com/android/server/policy/WindowOrientationListener.java
@@ -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;
diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java
index c4aaf7c8a935..df5d3ea3c150 100644
--- a/services/core/java/com/android/server/wm/DisplayRotation.java
+++ b/services/core/java/com/android/server/wm/DisplayRotation.java
@@ -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();
}
}