diff options
author | flintman <flintman@flintmancomputers.com> | 2015-11-21 20:51:06 -0500 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2019-10-27 19:06:57 +0100 |
commit | fbd4341a4f0a2564405afb65de9c83507471d915 (patch) | |
tree | 9606f4e1d6b9447458c9dbed750ae4145209d18f | |
parent | 57aed8dc3f4bbdce922037bfd9f9470df7715aec (diff) | |
download | android_frameworks_base-fbd4341a4f0a2564405afb65de9c83507471d915.tar.gz android_frameworks_base-fbd4341a4f0a2564405afb65de9c83507471d915.tar.bz2 android_frameworks_base-fbd4341a4f0a2564405afb65de9c83507471d915.zip |
sensors: Create bool to select what timestamp to use
Older devices may have an issue with rotation freezes up and
requires a reboot to fix. In deep sleep the sensor's timestamp
is far off, depending how long it's in sleep, causing rotation
not to work. onSensorChanged if true it will use
SystemClock.elapsedRealtimeNanos() instead of event.timestamp.
Possibly an update to the custom sensor libs.
Change-Id: Ie456e12cb65fbb921cb780112df301655b93b14f
-rw-r--r-- | core/res/res/values/lineage_config.xml | 4 | ||||
-rw-r--r-- | core/res/res/values/lineage_symbols.xml | 3 | ||||
-rw-r--r-- | services/core/java/com/android/server/policy/WindowOrientationListener.java | 7 |
3 files changed, 13 insertions, 1 deletions
diff --git a/core/res/res/values/lineage_config.xml b/core/res/res/values/lineage_config.xml index 91ed1c2f1fa..a3694ebe5dc 100644 --- a/core/res/res/values/lineage_config.xml +++ b/core/res/res/values/lineage_config.xml @@ -21,4 +21,8 @@ <!-- Whether to allow process with media UID to access CameraServiceProxy --> <bool name="config_allowMediaUidForCameraServiceProxy">false</bool> + + <!-- Older rotation sensors are not setting event.timestamp correctly. Setting to + true will use SystemClock.elapsedRealtimeNanos() to set timestamp. --> + <bool name="config_useSystemClockforRotationSensor">false</bool> </resources> diff --git a/core/res/res/values/lineage_symbols.xml b/core/res/res/values/lineage_symbols.xml index 0eb102b3c49..570c7d594b3 100644 --- a/core/res/res/values/lineage_symbols.xml +++ b/core/res/res/values/lineage_symbols.xml @@ -26,4 +26,7 @@ <!-- Whether to allow process with media UID to access CameraServiceProxy --> <java-symbol type="bool" name="config_allowMediaUidForCameraServiceProxy" /> + + <!-- Rotation sensor --> + <java-symbol type="bool" name="config_useSystemClockforRotationSensor" /> </resources> diff --git a/services/core/java/com/android/server/policy/WindowOrientationListener.java b/services/core/java/com/android/server/policy/WindowOrientationListener.java index 47370b644b9..c3d49cb2f08 100644 --- a/services/core/java/com/android/server/policy/WindowOrientationListener.java +++ b/services/core/java/com/android/server/policy/WindowOrientationListener.java @@ -59,6 +59,7 @@ public abstract class WindowOrientationListener { private boolean mEnabled; private int mRate; private String mSensorType; + private boolean mUseSystemClockforRotationSensor; private Sensor mSensor; private OrientationJudge mOrientationJudge; private int mCurrentRotation = -1; @@ -114,6 +115,9 @@ public abstract class WindowOrientationListener { mSensor = nonWakeUpDeviceOrientationSensor; } + mUseSystemClockforRotationSensor = context.getResources().getBoolean( + com.android.internal.R.bool.config_useSystemClockforRotationSensor); + if (mSensor != null) { mOrientationJudge = new OrientationSensorJudge(); } @@ -645,7 +649,8 @@ public abstract class WindowOrientationListener { // Reset the orientation listener state if the samples are too far apart in time // or when we see values of (0, 0, 0) which indicates that we polled the // accelerometer too soon after turning it on and we don't have any data yet. - final long now = event.timestamp; + final long now = mUseSystemClockforRotationSensor + ? SystemClock.elapsedRealtimeNanos() : event.timestamp; final long then = mLastFilteredTimestampNanos; final float timeDeltaMS = (now - then) * 0.000001f; final boolean skipSample; |