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

Commit 24f13a25 authored by Oliver Wang's avatar Oliver Wang Committed by Linux Build Service Account
Browse files

Sensor: Enable the motion accelerometer for screen orientation change

The screen orientation can be detected by the motion accelerometer
instead of generic accelerometer to save power.

Change-Id: Iaeb3e5958d2ef7cc33080d7091ed8a5462695c67
parent 2918c47c
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -502,6 +502,20 @@ public final class Sensor {
     */
     */
    public static final String STRING_TYPE_PICK_UP_GESTURE = "android.sensor.pick_up_gesture";
    public static final String STRING_TYPE_PICK_UP_GESTURE = "android.sensor.pick_up_gesture";


    /**
     * 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.
     * A constant describing all sensor types.
     */
     */
+4 −0
Original line number Original line Diff line number Diff line
@@ -1898,4 +1898,8 @@
    <!-- Configuration to restart radio upon PDP_DEACTIVATE with
    <!-- Configuration to restart radio upon PDP_DEACTIVATE with
         error cause as Regular deactivation(36). -->
         error cause as Regular deactivation(36). -->
    <bool name="config_radio_reset_on_regular_deactivation">true</bool>
    <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>
</resources>
+1 −0
Original line number Original line Diff line number Diff line
@@ -2102,6 +2102,7 @@
  <java-symbol type="bool" name="config_sms_force_7bit_encoding" />
  <java-symbol type="bool" name="config_sms_force_7bit_encoding" />
  <java-symbol type="string" name="config_partial_segment_expire_age" />
  <java-symbol type="string" name="config_partial_segment_expire_age" />
  <java-symbol type="bool" name="config_global_phone_enabled" />
  <java-symbol type="bool" name="config_global_phone_enabled" />
  <java-symbol type="bool" name="use_motion_accel" />


  <!-- sim refresh for dual mode card -->
  <!-- sim refresh for dual mode card -->
  <java-symbol type="bool" name="config_sim_refresh_for_dual_mode_card" />
  <java-symbol type="bool" name="config_sim_refresh_for_dual_mode_card" />
+11 −2
Original line number Original line Diff line number Diff line
@@ -87,8 +87,17 @@ public abstract class WindowOrientationListener {
        mHandler = handler;
        mHandler = handler;
        mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
        mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
        mRate = rate;
        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
                mSensor = mSensorManager.getDefaultSensor(USE_GRAVITY_SENSOR
                                ? Sensor.TYPE_GRAVITY : Sensor.TYPE_ACCELEROMETER);
                                ? Sensor.TYPE_GRAVITY : Sensor.TYPE_ACCELEROMETER);
        }

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