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

Commit cd2b8b2b authored by Paul Keith's avatar Paul Keith Committed by Sam Mortimer
Browse files

sensors: Allow opting out of default batch size



* In commit d49b1ee0,
  Google introduced a default batch size for the
  accelerometer, meant for Android Wear devices
* For some bizarre reason, this change breaks
  rotation on certain devices.
* Specifically, this behavior has been noticed
  by devices using Samsung's Sensorhub firmware
* As a result, add an overlay to allow opting out
  of this default accelerometer batch size in
  order to fix rotation on certain Samsung devices
* Thanks to Martin Bouchet <tincho5588@gmail.com>
  for pointing me to the offending commit in fw/b

Change-Id: I8769147e1b1553a8fbad03340745a7e7377b8510
Signed-off-by: default avatarPaul Keith <javelinanddart@gmail.com>
parent eaa636aa
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -28,4 +28,9 @@

    <!-- Whether to persist the notification for when a usb drive device is plugged in -->
    <bool name="config_persistUsbDriveNotification">false</bool>

    <!-- Certain sensor firmwares break with having a batch
         size set. By setting this to false, devices can opt
         out of setting a batch size, which fixes rotation. -->
    <bool name="config_useDefaultBatchingForAccel">true</bool>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -24,4 +24,6 @@

    <!-- Usb drive persistent notification -->
    <java-symbol type="bool" name="config_persistUsbDriveNotification" />

    <java-symbol type="bool" name="config_useDefaultBatchingForAccel" />
</resources>
+5 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ public abstract class WindowOrientationListener {
    private boolean mEnabled;
    private int mRate;
    private String mSensorType;
    private boolean mUseDefaultBatchingForAccel;
    private boolean mUseSystemClockforRotationSensor;
    private Sensor mSensor;
    private OrientationJudge mOrientationJudge;
@@ -91,6 +92,9 @@ public abstract class WindowOrientationListener {
        mRate = rate;
        mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_DEVICE_ORIENTATION);

        mUseDefaultBatchingForAccel = context.getResources().getBoolean(
            com.android.internal.R.bool.config_useDefaultBatchingForAccel);

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

@@ -137,7 +141,7 @@ public abstract class WindowOrientationListener {
                        + clearCurrentRotation);
            }
            mOrientationJudge.resetLocked(clearCurrentRotation);
            if (mSensor.getType() == Sensor.TYPE_ACCELEROMETER) {
            if (mSensor.getType() == Sensor.TYPE_ACCELEROMETER && mUseDefaultBatchingForAccel) {
                mSensorManager.registerListener(
                        mOrientationJudge, mSensor, mRate, DEFAULT_BATCH_LATENCY, mHandler);
            } else {