diff options
| author | 2018-01-17 01:55:53 +0000 | |
|---|---|---|
| committer | 2018-01-17 01:55:53 +0000 | |
| commit | 972bad79243d9ffec1f04ef2b7b73cd8d3312808 (patch) | |
| tree | 809d0a4c75ab3cc6ed4e64e0b2bc9228435a0e6a | |
| parent | eda4bc6f27237712204fe8e12478c2d150dc51b0 (diff) | |
| parent | d121ac12fd44762dc7b799edb87b5f1a5c268365 (diff) | |
Merge "Orientation Listener looks for the "right" Device Orientation Sensor."
| -rw-r--r-- | services/core/java/com/android/server/policy/WindowOrientationListener.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/policy/WindowOrientationListener.java b/services/core/java/com/android/server/policy/WindowOrientationListener.java index 1b5a5216909d..48a196dfcff1 100644 --- a/services/core/java/com/android/server/policy/WindowOrientationListener.java +++ b/services/core/java/com/android/server/policy/WindowOrientationListener.java @@ -32,6 +32,7 @@ import android.util.proto.ProtoOutputStream; import android.view.Surface; import java.io.PrintWriter; +import java.util.List; /** * A special helper class used by the WindowManager @@ -90,7 +91,28 @@ public abstract class WindowOrientationListener { mHandler = handler; mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); mRate = rate; - mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_DEVICE_ORIENTATION); + List<Sensor> l = mSensorManager.getSensorList(Sensor.TYPE_DEVICE_ORIENTATION); + Sensor wakeUpDeviceOrientationSensor = null; + Sensor nonWakeUpDeviceOrientationSensor = null; + /** + * Prefer the wakeup form of the sensor if implemented. + * It's OK to look for just two types of this sensor and use + * the last found. Typical devices will only have one sensor of + * this type. + */ + for (Sensor s : l) { + if (s.isWakeUpSensor()) { + wakeUpDeviceOrientationSensor = s; + } else { + nonWakeUpDeviceOrientationSensor = s; + } + } + + if (wakeUpDeviceOrientationSensor != null) { + mSensor = wakeUpDeviceOrientationSensor; + } else { + mSensor = nonWakeUpDeviceOrientationSensor; + } if (mSensor != null) { mOrientationJudge = new OrientationSensorJudge(); |