Merge "Doze - remove metrics logger, add uievent" into sc-dev
This commit is contained in:
@@ -376,8 +376,8 @@ public class DozeLog implements Dumpable {
|
||||
case REASON_SENSOR_DOUBLE_TAP: return "doubletap";
|
||||
case PULSE_REASON_SENSOR_LONG_PRESS: return "longpress";
|
||||
case PULSE_REASON_DOCKING: return "docking";
|
||||
case PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN: return "wakelockscreen";
|
||||
case REASON_SENSOR_WAKE_UP: return "wakeup";
|
||||
case PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN: return "reach-wakelockscreen";
|
||||
case REASON_SENSOR_WAKE_UP: return "presence-wakeup";
|
||||
case REASON_SENSOR_TAP: return "tap";
|
||||
case REASON_SENSOR_UDFPS_LONG_PRESS: return "udfps";
|
||||
case REASON_SENSOR_QUICK_PICKUP: return "quickPickup";
|
||||
|
||||
@@ -40,11 +40,9 @@ import android.view.Display;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.UiEvent;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.internal.logging.UiEventLoggerImpl;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.systemui.biometrics.AuthController;
|
||||
import com.android.systemui.plugins.SensorManagerPlugin;
|
||||
@@ -491,10 +489,6 @@ public class DozeSensors {
|
||||
mHandler.post(mWakeLock.wrap(() -> {
|
||||
if (DEBUG) Log.d(TAG, "onTrigger: " + triggerEventToString(event));
|
||||
if (mSensor != null && mSensor.getType() == Sensor.TYPE_PICK_UP_GESTURE) {
|
||||
int subType = (int) event.values[0];
|
||||
MetricsLogger.action(
|
||||
mContext, MetricsProto.MetricsEvent.ACTION_AMBIENT_GESTURE,
|
||||
subType);
|
||||
UI_EVENT_LOGGER.log(DozeSensorsUiEvent.ACTION_AMBIENT_GESTURE_PICKUP);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.display.AmbientDisplayConfiguration;
|
||||
import android.metrics.LogMaker;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.text.format.Formatter;
|
||||
@@ -33,12 +32,8 @@ import android.util.Log;
|
||||
import android.view.Display;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.UiEvent;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.internal.logging.UiEventLoggerImpl;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.biometrics.AuthController;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
@@ -70,8 +65,6 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
/** adb shell am broadcast -a com.android.systemui.doze.pulse com.android.systemui */
|
||||
private static final String PULSE_ACTION = "com.android.systemui.doze.pulse";
|
||||
|
||||
private static final UiEventLogger UI_EVENT_LOGGER = new UiEventLoggerImpl();
|
||||
|
||||
/**
|
||||
* Last value sent by the wake-display sensor.
|
||||
* Assuming that the screen should start on.
|
||||
@@ -99,12 +92,11 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||
private final AuthController mAuthController;
|
||||
private final DelayableExecutor mMainExecutor;
|
||||
private final UiEventLogger mUiEventLogger;
|
||||
|
||||
private long mNotificationPulseTime;
|
||||
private boolean mPulsePending;
|
||||
|
||||
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
|
||||
|
||||
/** see {@link #onProximityFar} prox for callback */
|
||||
private boolean mWantProxSensor;
|
||||
private boolean mWantTouchScreenSensors;
|
||||
@@ -143,7 +135,10 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
DOZING_UPDATE_AUTH_TRIGGERED(657),
|
||||
|
||||
@UiEvent(doc = "Dozing updated because quick pickup sensor woke up.")
|
||||
DOZING_UPDATE_QUICK_PICKUP(708);
|
||||
DOZING_UPDATE_QUICK_PICKUP(708),
|
||||
|
||||
@UiEvent(doc = "Dozing updated - sensor wakeup timed out (from quick pickup or presence)")
|
||||
DOZING_UPDATE_WAKE_TIMEOUT(794);
|
||||
|
||||
private final int mId;
|
||||
|
||||
@@ -182,7 +177,8 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
ProximitySensor proximitySensor, ProximitySensor.ProximityCheck proxCheck,
|
||||
DozeLog dozeLog, BroadcastDispatcher broadcastDispatcher,
|
||||
SecureSettings secureSettings, AuthController authController,
|
||||
@Main DelayableExecutor mainExecutor) {
|
||||
@Main DelayableExecutor mainExecutor,
|
||||
UiEventLogger uiEventLogger) {
|
||||
mContext = context;
|
||||
mDozeHost = dozeHost;
|
||||
mConfig = config;
|
||||
@@ -200,6 +196,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
mBroadcastDispatcher = broadcastDispatcher;
|
||||
mAuthController = authController;
|
||||
mMainExecutor = mainExecutor;
|
||||
mUiEventLogger = uiEventLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -328,11 +325,8 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
|
||||
private void gentleWakeUp(int reason) {
|
||||
// Log screen wake up reason (lift/pickup, tap, double-tap)
|
||||
mMetricsLogger.write(new LogMaker(MetricsEvent.DOZING)
|
||||
.setType(MetricsEvent.TYPE_UPDATE)
|
||||
.setSubtype(reason));
|
||||
Optional.ofNullable(DozingUpdateUiEvent.fromReason(reason))
|
||||
.ifPresent(UI_EVENT_LOGGER::log);
|
||||
.ifPresent(mUiEventLogger::log);
|
||||
if (mDozeParameters.getDisplayNeedsBlanking()) {
|
||||
// Let's prepare the display to wake-up by drawing black.
|
||||
// This will cover the hardware wake-up sequence, where the display
|
||||
@@ -401,10 +395,9 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
}
|
||||
if (state == DozeMachine.State.DOZE) {
|
||||
mMachine.requestState(DozeMachine.State.DOZE_AOD);
|
||||
// Logs AOD open due to sensor wake up.
|
||||
mMetricsLogger.write(new LogMaker(MetricsEvent.DOZING)
|
||||
.setType(MetricsEvent.TYPE_OPEN)
|
||||
.setSubtype(reason));
|
||||
// Log sensor triggered
|
||||
Optional.ofNullable(DozingUpdateUiEvent.fromReason(reason))
|
||||
.ifPresent(mUiEventLogger::log);
|
||||
|
||||
if (isQuickPickup) {
|
||||
// schedule runnable to go back to DOZE
|
||||
@@ -427,10 +420,8 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
return;
|
||||
}
|
||||
mMachine.requestState(DozeMachine.State.DOZE);
|
||||
// Logs AOD close due to sensor wake up.
|
||||
mMetricsLogger.write(new LogMaker(MetricsEvent.DOZING)
|
||||
.setType(MetricsEvent.TYPE_CLOSE)
|
||||
.setSubtype(reason));
|
||||
// log wake timeout
|
||||
mUiEventLogger.log(DozingUpdateUiEvent.DOZING_UPDATE_WAKE_TIMEOUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -563,10 +554,8 @@ public class DozeTriggers implements DozeMachine.Part {
|
||||
}, !mDozeParameters.getProxCheckBeforePulse() || performedProxCheck, reason);
|
||||
|
||||
// Logs request pulse reason on AOD screen.
|
||||
mMetricsLogger.write(new LogMaker(MetricsEvent.DOZING)
|
||||
.setType(MetricsEvent.TYPE_UPDATE).setSubtype(reason));
|
||||
Optional.ofNullable(DozingUpdateUiEvent.fromReason(reason))
|
||||
.ifPresent(UI_EVENT_LOGGER::log);
|
||||
.ifPresent(mUiEventLogger::log);
|
||||
}
|
||||
|
||||
private boolean canPulse() {
|
||||
|
||||
@@ -42,6 +42,7 @@ public class DozeConfigurationUtil {
|
||||
when(params.getSelectivelyRegisterSensorsUsingProx()).thenReturn(false);
|
||||
when(params.singleTapUsesProx()).thenReturn(true);
|
||||
when(params.longPressUsesProx()).thenReturn(true);
|
||||
when(params.getQuickPickupAodDuration()).thenReturn(500);
|
||||
|
||||
doneHolder[0] = true;
|
||||
return params;
|
||||
|
||||
@@ -35,10 +35,12 @@ import android.view.Display;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.biometrics.AuthController;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
import com.android.systemui.dock.DockManager;
|
||||
import com.android.systemui.doze.DozeTriggers.DozingUpdateUiEvent;
|
||||
import com.android.systemui.statusbar.phone.DozeParameters;
|
||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||
import com.android.systemui.util.concurrency.FakeThreadFactory;
|
||||
@@ -76,6 +78,8 @@ public class DozeTriggersTest extends SysuiTestCase {
|
||||
private ProximitySensor.ProximityCheck mProximityCheck;
|
||||
@Mock
|
||||
private AuthController mAuthController;
|
||||
@Mock
|
||||
private UiEventLogger mUiEventLogger;
|
||||
|
||||
private DozeTriggers mTriggers;
|
||||
private FakeSensorManager mSensors;
|
||||
@@ -107,7 +111,7 @@ public class DozeTriggersTest extends SysuiTestCase {
|
||||
mTriggers = new DozeTriggers(mContext, mHost, config, dozeParameters,
|
||||
asyncSensorManager, wakeLock, mDockManager, mProximitySensor,
|
||||
mProximityCheck, mock(DozeLog.class), mBroadcastDispatcher, new FakeSettings(),
|
||||
mAuthController, mExecutor);
|
||||
mAuthController, mExecutor, mUiEventLogger);
|
||||
mTriggers.setDozeMachine(mMachine);
|
||||
waitForSensorManager();
|
||||
}
|
||||
@@ -194,6 +198,40 @@ public class DozeTriggersTest extends SysuiTestCase {
|
||||
mTriggers.onSensor(DozeLog.REASON_SENSOR_TAP, 100, 100, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuickPickup() {
|
||||
// GIVEN device is in doze (screen blank, but running doze sensors)
|
||||
when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);
|
||||
|
||||
// WHEN quick pick up is triggered
|
||||
mTriggers.onSensor(DozeLog.REASON_SENSOR_QUICK_PICKUP, 100, 100, null);
|
||||
|
||||
// THEN device goes into aod (shows clock with black background)
|
||||
verify(mMachine).requestState(DozeMachine.State.DOZE_AOD);
|
||||
|
||||
// THEN a log is taken that quick pick up was triggered
|
||||
verify(mUiEventLogger).log(DozingUpdateUiEvent.DOZING_UPDATE_QUICK_PICKUP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuickPickupTimeOutAfterExecutables() {
|
||||
// GIVEN quick pickup is triggered when device is in DOZE
|
||||
when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);
|
||||
mTriggers.onSensor(DozeLog.REASON_SENSOR_QUICK_PICKUP, 100, 100, null);
|
||||
verify(mMachine).requestState(DozeMachine.State.DOZE_AOD);
|
||||
verify(mMachine, never()).requestState(DozeMachine.State.DOZE);
|
||||
|
||||
// WHEN next executable is run
|
||||
mExecutor.advanceClockToLast();
|
||||
mExecutor.runAllReady();
|
||||
|
||||
// THEN device goes back into DOZE
|
||||
verify(mMachine).requestState(DozeMachine.State.DOZE);
|
||||
|
||||
// THEN a log is taken that wake up timeout expired
|
||||
verify(mUiEventLogger).log(DozingUpdateUiEvent.DOZING_UPDATE_WAKE_TIMEOUT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnSensor_Fingerprint() {
|
||||
final int screenX = 100;
|
||||
|
||||
Reference in New Issue
Block a user