summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/res/res/values/config.xml4
-rw-r--r--core/res/res/values/symbols.xml2
-rw-r--r--services/core/java/com/android/server/policy/WindowOrientationListener.java7
3 files changed, 12 insertions, 1 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 7aa778b..894fbdb 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2527,4 +2527,8 @@
<!-- Show battery fully charged notification -->
<bool name="config_showBatteryFullyChargedNotification">false</bool>
+
+ <!-- Older sensors are not setting event.timestamp correctly. Setting to
+ true will use SystemClock.elapsedRealtimeNanos() to set timestamp. -->
+ <bool name="config_useSystemClockforSensors">false</bool>
</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index d31ab73..a17d258 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2408,4 +2408,6 @@
<java-symbol type="drawable" name="platlogo_m" />
<java-symbol type="string" name="config_packagedKeyboardName" />
+
+ <java-symbol type="bool" name="config_useSystemClockforSensors" />
</resources>
diff --git a/services/core/java/com/android/server/policy/WindowOrientationListener.java b/services/core/java/com/android/server/policy/WindowOrientationListener.java
index 9916223..9d8d713 100644
--- a/services/core/java/com/android/server/policy/WindowOrientationListener.java
+++ b/services/core/java/com/android/server/policy/WindowOrientationListener.java
@@ -55,6 +55,7 @@ public abstract class WindowOrientationListener {
private boolean mEnabled;
private int mRate;
private String mSensorType;
+ private boolean mUseSystemClockforSensors;
private Sensor mSensor;
private OrientationJudge mOrientationJudge;
private int mCurrentRotation = -1;
@@ -90,6 +91,9 @@ public abstract class WindowOrientationListener {
mSensorType = context.getResources().getString(
com.android.internal.R.string.config_orientationSensorType);
+ mUseSystemClockforSensors = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_useSystemClockforSensors);
+
if (!TextUtils.isEmpty(mSensorType)) {
List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
final int N = sensors.size();
@@ -598,7 +602,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 = mUseSystemClockforSensors
+ ? SystemClock.elapsedRealtimeNanos() : event.timestamp;
final long then = mLastFilteredTimestampNanos;
final float timeDeltaMS = (now - then) * 0.000001f;
final boolean skipSample;