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

Commit 428941a8 authored by flintman's avatar flintman Committed by Steve Kondik
Browse files

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
parent 975256bc
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2758,4 +2758,8 @@

    <!-- Whether to persist the notification for when a usb drive device is plugged in -->
    <bool name="config_persistUsbDriveNotification">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>
+1 −0
Original line number Diff line number Diff line
@@ -2756,4 +2756,5 @@
  <java-symbol type="string" name="adb_both_active_notification_title" />
  <java-symbol type="string" name="adb_active_generic_notification_message" />

  <java-symbol type="bool" name="config_useSystemClockforRotationSensor" />
</resources>
+6 −1
Original line number Diff line number Diff line
@@ -55,6 +55,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;
@@ -89,6 +90,9 @@ public abstract class WindowOrientationListener {
        mRate = rate;
        mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_DEVICE_ORIENTATION);

        mUseSystemClockforRotationSensor = context.getResources().getBoolean(
                com.android.internal.R.bool.config_useSystemClockforRotationSensor);

        if (mSensor != null) {
            mOrientationJudge = new OrientationSensorJudge();
        }
@@ -586,7 +590,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;