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

Commit c5542dc7 authored by flintman's avatar flintman Committed by Arne Coucheron
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 ba5aa5b4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -17,4 +17,8 @@
<resources>
    <!-- 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>
+3 −0
Original line number Diff line number Diff line
@@ -17,4 +17,7 @@
<resources>
    <!-- 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>
+6 −1
Original line number Diff line number Diff line
@@ -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;