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

Commit 1fd0d9b2 authored by Brian Quezada's avatar Brian Quezada Committed by Automerger Merge Worker
Browse files

Merge "Add batching to Flip to Screen Off." into sc-dev am: bee94e56 am: 3d946fd0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14733693

Change-Id: I96fd401eac3d0b6f69cc935a13765a6f120b60a3
parents ab34e9bf 3d946fd0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1792,6 +1792,9 @@
    <!-- Boolean indicating if placing the phone face down will result in a screen off. -->
    <bool name="config_flipToScreenOffEnabled">true</bool>

    <!-- Integer to set a max latency the accelerometer will batch sensor requests with. -->
    <integer name="config_flipToScreenOffMaxLatencyMicros">2000000</integer>

    <!-- Boolean indicating if current platform supports bluetooth SCO for off call
    use cases -->
    <bool name="config_bluetooth_sco_off_call">true</bool>
+1 −0
Original line number Diff line number Diff line
@@ -276,6 +276,7 @@
  <java-symbol type="bool" name="config_avoidGfxAccel" />
  <java-symbol type="bool" name="config_bluetooth_address_validation" />
  <java-symbol type="bool" name="config_flipToScreenOffEnabled" />
  <java-symbol type="integer" name="config_flipToScreenOffMaxLatencyMicros" />
  <java-symbol type="bool" name="config_bluetooth_sco_off_call" />
  <java-symbol type="bool" name="config_bluetooth_le_peripheral_mode_supported" />
  <java-symbol type="bool" name="config_bluetooth_hfp_inband_ringing_support" />
+14 −1
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ public class FaceDownDetector implements SensorEventListener {

    private boolean mIsEnabled;

    private int mSensorMaxLatencyMicros;

    /**
     * DeviceConfig flag name, determines how long to disable sensor when user interacts while
     * device is flipped.
@@ -202,7 +204,11 @@ public class FaceDownDetector implements SensorEventListener {
        if (mActive != shouldBeActive) {
            if (shouldBeActive) {
                mSensorManager.registerListener(
                        this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
                        this,
                        mAccelerometer,
                        SensorManager.SENSOR_DELAY_NORMAL,
                        mSensorMaxLatencyMicros
                );
                if (mPreviousResultType == SCREEN_OFF_RESULT) {
                    logScreenOff();
                }
@@ -226,6 +232,7 @@ public class FaceDownDetector implements SensorEventListener {
        pw.println("  mFaceDown=" + mFaceDown);
        pw.println("  mActive=" + mActive);
        pw.println("  mLastFlipTime=" + mLastFlipTime);
        pw.println("  mSensorMaxLatencyMicros=" + mSensorMaxLatencyMicros);
        pw.println("  mUserInteractionBackoffMillis=" + mUserInteractionBackoffMillis);
        pw.println("  mPreviousResultTime=" + mPreviousResultTime);
        pw.println("  mPreviousResultType=" + mPreviousResultType);
@@ -356,6 +363,11 @@ public class FaceDownDetector implements SensorEventListener {
                3600_000);
    }

    private int getSensorMaxLatencyMicros() {
        return mContext.getResources().getInteger(
                com.android.internal.R.integer.config_flipToScreenOffMaxLatencyMicros);
    }

    private float getFloatFlagValue(String key, float defaultValue, float min, float max) {
        final float value = DeviceConfig.getFloat(NAMESPACE_ATTENTION_MANAGER_SERVICE,
                key,
@@ -416,6 +428,7 @@ public class FaceDownDetector implements SensorEventListener {
        mZAccelerationThreshold = getZAccelerationThreshold();
        mZAccelerationThresholdLenient = mZAccelerationThreshold + 1.0f;
        mTimeThreshold = getTimeThreshold();
        mSensorMaxLatencyMicros = getSensorMaxLatencyMicros();
        mUserInteractionBackoffMillis = getUserInteractionBackoffMillis();
        final boolean oldEnabled = mIsEnabled;
        mIsEnabled = isEnabled();