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

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

Change-Id: I96fd401eac3d0b6f69cc935a13765a6f120b60a3
This commit is contained in:
Brian Quezada
2021-06-01 20:43:33 +00:00
committed by Automerger Merge Worker
3 changed files with 18 additions and 1 deletions

View File

@@ -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>

View File

@@ -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" />

View File

@@ -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();