Merge "Allow UDFPS to be triggerd from AOD_PAUSED state" into tm-qpr-dev
This commit is contained in:
@@ -28,6 +28,8 @@ import com.android.systemui.dagger.SysUISingleton;
|
|||||||
import com.android.systemui.dump.DumpManager;
|
import com.android.systemui.dump.DumpManager;
|
||||||
import com.android.systemui.statusbar.policy.DevicePostureController;
|
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||||
|
|
||||||
|
import com.google.errorprone.annotations.CompileTimeConstant;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
@@ -79,6 +81,13 @@ public class DozeLog implements Dumpable {
|
|||||||
dumpManager.registerDumpable("DumpStats", this);
|
dumpManager.registerDumpable("DumpStats", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log debug message to LogBuffer.
|
||||||
|
*/
|
||||||
|
public void d(@CompileTimeConstant String msg) {
|
||||||
|
mLogger.log(msg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends pickup wakeup event to the logs
|
* Appends pickup wakeup event to the logs
|
||||||
*/
|
*/
|
||||||
@@ -88,6 +97,10 @@ public class DozeLog implements Dumpable {
|
|||||||
: mPickupPulseNotNearVibrationStats).append();
|
: mPickupPulseNotNearVibrationStats).append();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void traceSetIgnoreTouchWhilePulsing(boolean ignoreTouch) {
|
||||||
|
mLogger.logSetIgnoreTouchWhilePulsing(ignoreTouch);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends pulse started event to the logs.
|
* Appends pulse started event to the logs.
|
||||||
* @param reason why the pulse started
|
* @param reason why the pulse started
|
||||||
|
|||||||
@@ -364,6 +364,14 @@ class DozeLogger @Inject constructor(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun logSetIgnoreTouchWhilePulsing(ignoreTouchWhilePulsing: Boolean) {
|
||||||
|
buffer.log(TAG, DEBUG, {
|
||||||
|
bool1 = ignoreTouchWhilePulsing
|
||||||
|
}, {
|
||||||
|
"Prox changed while pulsing. setIgnoreTouchWhilePulsing=$bool1"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fun log(@CompileTimeConstant msg: String) {
|
fun log(@CompileTimeConstant msg: String) {
|
||||||
buffer.log(TAG, DEBUG, msg)
|
buffer.log(TAG, DEBUG, msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,15 +333,18 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
}
|
}
|
||||||
gentleWakeUp(pulseReason);
|
gentleWakeUp(pulseReason);
|
||||||
} else if (isUdfpsLongPress) {
|
} else if (isUdfpsLongPress) {
|
||||||
final State state = mMachine.getState();
|
if (canPulse(mMachine.getState(), true)) {
|
||||||
if (state == State.DOZE_AOD || state == State.DOZE) {
|
mDozeLog.d("updfsLongPress - setting aodInterruptRunnable to run when "
|
||||||
|
+ "the display is on");
|
||||||
// Since the gesture won't be received by the UDFPS view, we need to
|
// Since the gesture won't be received by the UDFPS view, we need to
|
||||||
// manually inject an event once the display is ON
|
// manually inject an event once the display is ON
|
||||||
mAodInterruptRunnable = () ->
|
mAodInterruptRunnable = () ->
|
||||||
mAuthController.onAodInterrupt((int) screenX, (int) screenY,
|
mAuthController.onAodInterrupt((int) screenX, (int) screenY,
|
||||||
rawValues[3] /* major */, rawValues[4] /* minor */);
|
rawValues[3] /* major */, rawValues[4] /* minor */);
|
||||||
|
} else {
|
||||||
|
mDozeLog.d("udfpsLongPress - Not sending aodInterrupt. "
|
||||||
|
+ "Unsupported doze state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
requestPulse(DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS, true, null);
|
requestPulse(DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS, true, null);
|
||||||
} else {
|
} else {
|
||||||
mDozeHost.extendPulse(pulseReason);
|
mDozeHost.extendPulse(pulseReason);
|
||||||
@@ -380,7 +383,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
// when a new event is arriving. This means that a state transition might have happened
|
// when a new event is arriving. This means that a state transition might have happened
|
||||||
// and the proximity check is now obsolete.
|
// and the proximity check is now obsolete.
|
||||||
if (mMachine.isExecutingTransition()) {
|
if (mMachine.isExecutingTransition()) {
|
||||||
Log.w(TAG, "onProximityFar called during transition. Ignoring sensor response.");
|
mDozeLog.d("onProximityFar called during transition. Ignoring sensor response.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,21 +395,15 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
|
|
||||||
if (state == DozeMachine.State.DOZE_PULSING
|
if (state == DozeMachine.State.DOZE_PULSING
|
||||||
|| state == DozeMachine.State.DOZE_PULSING_BRIGHT) {
|
|| state == DozeMachine.State.DOZE_PULSING_BRIGHT) {
|
||||||
if (DEBUG) {
|
mDozeLog.traceSetIgnoreTouchWhilePulsing(near);
|
||||||
Log.i(TAG, "Prox changed, ignore touch = " + near);
|
|
||||||
}
|
|
||||||
mDozeHost.onIgnoreTouchWhilePulsing(near);
|
mDozeHost.onIgnoreTouchWhilePulsing(near);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (far && (paused || pausing)) {
|
if (far && (paused || pausing)) {
|
||||||
if (DEBUG) {
|
mDozeLog.d("Prox FAR, unpausing AOD");
|
||||||
Log.i(TAG, "Prox FAR, unpausing AOD");
|
|
||||||
}
|
|
||||||
mMachine.requestState(DozeMachine.State.DOZE_AOD);
|
mMachine.requestState(DozeMachine.State.DOZE_AOD);
|
||||||
} else if (near && aod) {
|
} else if (near && aod) {
|
||||||
if (DEBUG) {
|
mDozeLog.d("Prox NEAR, starting pausing AOD countdown");
|
||||||
Log.i(TAG, "Prox NEAR, pausing AOD");
|
|
||||||
}
|
|
||||||
mMachine.requestState(DozeMachine.State.DOZE_AOD_PAUSING);
|
mMachine.requestState(DozeMachine.State.DOZE_AOD_PAUSING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -551,12 +548,13 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mAllowPulseTriggers || mDozeHost.isPulsePending() || !canPulse(dozeState)) {
|
if (!mAllowPulseTriggers || mDozeHost.isPulsePending()
|
||||||
|
|| !canPulse(dozeState, performedProxCheck)) {
|
||||||
if (!mAllowPulseTriggers) {
|
if (!mAllowPulseTriggers) {
|
||||||
mDozeLog.tracePulseDropped("requestPulse - !mAllowPulseTriggers");
|
mDozeLog.tracePulseDropped("requestPulse - !mAllowPulseTriggers");
|
||||||
} else if (mDozeHost.isPulsePending()) {
|
} else if (mDozeHost.isPulsePending()) {
|
||||||
mDozeLog.tracePulseDropped("requestPulse - pulsePending");
|
mDozeLog.tracePulseDropped("requestPulse - pulsePending");
|
||||||
} else if (!canPulse(dozeState)) {
|
} else if (!canPulse(dozeState, performedProxCheck)) {
|
||||||
mDozeLog.tracePulseDropped("requestPulse - dozeState cannot pulse", dozeState);
|
mDozeLog.tracePulseDropped("requestPulse - dozeState cannot pulse", dozeState);
|
||||||
}
|
}
|
||||||
runIfNotNull(onPulseSuppressedListener);
|
runIfNotNull(onPulseSuppressedListener);
|
||||||
@@ -574,14 +572,15 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
// not in pocket, continue pulsing
|
// not in pocket, continue pulsing
|
||||||
final boolean isPulsePending = mDozeHost.isPulsePending();
|
final boolean isPulsePending = mDozeHost.isPulsePending();
|
||||||
mDozeHost.setPulsePending(false);
|
mDozeHost.setPulsePending(false);
|
||||||
if (!isPulsePending || mDozeHost.isPulsingBlocked() || !canPulse(dozeState)) {
|
if (!isPulsePending || mDozeHost.isPulsingBlocked()
|
||||||
|
|| !canPulse(dozeState, performedProxCheck)) {
|
||||||
if (!isPulsePending) {
|
if (!isPulsePending) {
|
||||||
mDozeLog.tracePulseDropped("continuePulseRequest - pulse no longer"
|
mDozeLog.tracePulseDropped("continuePulseRequest - pulse no longer"
|
||||||
+ " pending, pulse was cancelled before it could start"
|
+ " pending, pulse was cancelled before it could start"
|
||||||
+ " transitioning to pulsing state.");
|
+ " transitioning to pulsing state.");
|
||||||
} else if (mDozeHost.isPulsingBlocked()) {
|
} else if (mDozeHost.isPulsingBlocked()) {
|
||||||
mDozeLog.tracePulseDropped("continuePulseRequest - pulsingBlocked");
|
mDozeLog.tracePulseDropped("continuePulseRequest - pulsingBlocked");
|
||||||
} else if (!canPulse(dozeState)) {
|
} else if (!canPulse(dozeState, performedProxCheck)) {
|
||||||
mDozeLog.tracePulseDropped("continuePulseRequest"
|
mDozeLog.tracePulseDropped("continuePulseRequest"
|
||||||
+ " - doze state cannot pulse", dozeState);
|
+ " - doze state cannot pulse", dozeState);
|
||||||
}
|
}
|
||||||
@@ -598,10 +597,13 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
.ifPresent(uiEventEnum -> mUiEventLogger.log(uiEventEnum, getKeyguardSessionId()));
|
.ifPresent(uiEventEnum -> mUiEventLogger.log(uiEventEnum, getKeyguardSessionId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPulse(DozeMachine.State dozeState) {
|
private boolean canPulse(DozeMachine.State dozeState, boolean pulsePerformedProximityCheck) {
|
||||||
|
final boolean dozePausedOrPausing = dozeState == State.DOZE_AOD_PAUSED
|
||||||
|
|| dozeState == State.DOZE_AOD_PAUSING;
|
||||||
return dozeState == DozeMachine.State.DOZE
|
return dozeState == DozeMachine.State.DOZE
|
||||||
|| dozeState == DozeMachine.State.DOZE_AOD
|
|| dozeState == DozeMachine.State.DOZE_AOD
|
||||||
|| dozeState == DozeMachine.State.DOZE_AOD_DOCKED;
|
|| dozeState == DozeMachine.State.DOZE_AOD_DOCKED
|
||||||
|
|| (dozePausedOrPausing && pulsePerformedProximityCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -357,6 +357,44 @@ public class DozeTriggersTest extends SysuiTestCase {
|
|||||||
verify(mDozeLog).tracePulseDropped(anyString(), eq(null));
|
verify(mDozeLog).tracePulseDropped(anyString(), eq(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void udfpsLongPress_triggeredWhenAodPaused() {
|
||||||
|
// GIVEN device is DOZE_AOD_PAUSED
|
||||||
|
when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE_AOD_PAUSED);
|
||||||
|
|
||||||
|
// WHEN udfps long-press is triggered
|
||||||
|
mTriggers.onSensor(DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS, 100, 100,
|
||||||
|
new float[]{0, 1, 2, 3, 4});
|
||||||
|
|
||||||
|
// THEN the pulse is NOT dropped
|
||||||
|
verify(mDozeLog, never()).tracePulseDropped(anyString(), any());
|
||||||
|
|
||||||
|
// WHEN the screen state is ON
|
||||||
|
mTriggers.onScreenState(Display.STATE_ON);
|
||||||
|
|
||||||
|
// THEN aod interrupt is sent
|
||||||
|
verify(mAuthController).onAodInterrupt(anyInt(), anyInt(), anyFloat(), anyFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void udfpsLongPress_triggeredWhenAodPausing() {
|
||||||
|
// GIVEN device is DOZE_AOD_PAUSED
|
||||||
|
when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE_AOD_PAUSING);
|
||||||
|
|
||||||
|
// WHEN udfps long-press is triggered
|
||||||
|
mTriggers.onSensor(DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS, 100, 100,
|
||||||
|
new float[]{0, 1, 2, 3, 4});
|
||||||
|
|
||||||
|
// THEN the pulse is NOT dropped
|
||||||
|
verify(mDozeLog, never()).tracePulseDropped(anyString(), any());
|
||||||
|
|
||||||
|
// WHEN the screen state is ON
|
||||||
|
mTriggers.onScreenState(Display.STATE_ON);
|
||||||
|
|
||||||
|
// THEN aod interrupt is sent
|
||||||
|
verify(mAuthController).onAodInterrupt(anyInt(), anyInt(), anyFloat(), anyFloat());
|
||||||
|
}
|
||||||
|
|
||||||
private void waitForSensorManager() {
|
private void waitForSensorManager() {
|
||||||
mExecutor.runAllReady();
|
mExecutor.runAllReady();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user