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

Commit 28024844 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Sensor: Enable the motion accelerometer for screen orientation change"

parents d4d47f8a f38da014
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -221,6 +221,20 @@ public final class Sensor {
     */
    public static final int TYPE_GEOMAGNETIC_ROTATION_VECTOR = 20;

    /**
     * A constant describing the motion accelerometer sensor.
     * <p>
     * This sensor is similar to the accelerometer sensor, however it only
     * streams data when the device is in motion, and stops streaming data
     * when the device is stationary.
     * Generally this kind of sensor would consume less power than the generic
     * accelerometer sensor, and hence can be used in applications that do not
     * require accelerometer streaming when device is stationary, such as the
     * screen auto-rotation.
     * {@hide}
     */
    public static final int TYPE_MOTION_ACCEL = 33171011;

    /**
     * A constant describing all sensor types.
     */
+4 −0
Original line number Diff line number Diff line
@@ -1389,4 +1389,8 @@
    <!-- Configuration to restart radio upon PDP_DEACTIVATE with
         error cause as Regular deactivation(36). -->
    <bool name="config_radio_reset_on_regular_deactivation">true</bool>

    <!-- bool value to for enabling motion accelerometer -->
    <bool name="use_motion_accel">false</bool>

</resources>
+1 −0
Original line number Diff line number Diff line
@@ -1795,4 +1795,5 @@

  <!-- cpu boost for overscroller fling -->
  <java-symbol type="bool" name="config_enableCpuBoostForOverScrollerFling" />
  <java-symbol type="bool" name="use_motion_accel" />
</resources>
+11 −2
Original line number Diff line number Diff line
@@ -84,8 +84,17 @@ public abstract class WindowOrientationListener {
        mHandler = handler;
        mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
        mRate = rate;
        mSensor = null;

        if (context.getResources().getBoolean(
                                com.android.internal.R.bool.use_motion_accel) == true) {
                mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MOTION_ACCEL);
        }
        if (mSensor == null) {
                mSensor = mSensorManager.getDefaultSensor(USE_GRAVITY_SENSOR
                                ? Sensor.TYPE_GRAVITY : Sensor.TYPE_ACCELEROMETER);
        }

        if (mSensor != null) {
            // Create listener only if sensors do exist
            mSensorEventListener = new SensorEventListenerImpl();