Log UiEvents useful for calculating dream overlay start latency.
Bug: 213906448 Test: atest DreamOverlayServiceTest Test: Manually on device via `statsd_testdrive 90` Change-Id: I24b986b8d336e007bc8e0f39ddc9362c41c25cbf
This commit is contained in:
@@ -26,10 +26,13 @@ import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleRegistry;
|
||||
import androidx.lifecycle.ViewModelStore;
|
||||
|
||||
import com.android.internal.logging.UiEvent;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.internal.policy.PhoneWindow;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||
@@ -61,6 +64,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
|
||||
private final DreamOverlayContainerViewController mDreamOverlayContainerViewController;
|
||||
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private final DreamPreviewComplication mPreviewComplication;
|
||||
private final UiEventLogger mUiEventLogger;
|
||||
|
||||
// A reference to the {@link Window} used to hold the dream overlay.
|
||||
private Window mWindow;
|
||||
@@ -97,6 +101,25 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
|
||||
|
||||
private DreamOverlayStateController mStateController;
|
||||
|
||||
@VisibleForTesting
|
||||
public enum DreamOverlayEvent implements UiEventLogger.UiEventEnum {
|
||||
@UiEvent(doc = "The dream overlay has entered start.")
|
||||
DREAM_OVERLAY_ENTER_START(989),
|
||||
@UiEvent(doc = "The dream overlay has completed start.")
|
||||
DREAM_OVERLAY_COMPLETE_START(990);
|
||||
|
||||
private final int mId;
|
||||
|
||||
DreamOverlayEvent(int id) {
|
||||
mId = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return mId;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
public DreamOverlayService(
|
||||
Context context,
|
||||
@@ -104,13 +127,15 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
|
||||
DreamOverlayComponent.Factory dreamOverlayComponentFactory,
|
||||
DreamOverlayStateController stateController,
|
||||
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||
DreamPreviewComplication previewComplication) {
|
||||
DreamPreviewComplication previewComplication,
|
||||
UiEventLogger uiEventLogger) {
|
||||
mContext = context;
|
||||
mExecutor = executor;
|
||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||
mKeyguardUpdateMonitor.registerCallback(mKeyguardCallback);
|
||||
mStateController = stateController;
|
||||
mPreviewComplication = previewComplication;
|
||||
mUiEventLogger = uiEventLogger;
|
||||
|
||||
final DreamOverlayComponent component =
|
||||
dreamOverlayComponentFactory.create(mViewModelStore, mHost);
|
||||
@@ -143,6 +168,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
|
||||
|
||||
@Override
|
||||
public void onStartDream(@NonNull WindowManager.LayoutParams layoutParams) {
|
||||
mUiEventLogger.log(DreamOverlayEvent.DREAM_OVERLAY_ENTER_START);
|
||||
setCurrentState(Lifecycle.State.STARTED);
|
||||
mExecutor.execute(() -> {
|
||||
if (mDestroyed) {
|
||||
@@ -159,6 +185,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
|
||||
addOverlayWindowLocked(layoutParams);
|
||||
setCurrentState(Lifecycle.State.RESUMED);
|
||||
mStateController.setOverlayActive(true);
|
||||
mUiEventLogger.log(DreamOverlayEvent.DREAM_OVERLAY_COMPLETE_START);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.LifecycleRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.dreams.complication.DreamPreviewComplication;
|
||||
@@ -104,6 +105,9 @@ public class DreamOverlayServiceTest extends SysuiTestCase {
|
||||
@Mock
|
||||
ViewGroup mDreamOverlayContainerViewParent;
|
||||
|
||||
@Mock
|
||||
UiEventLogger mUiEventLogger;
|
||||
|
||||
DreamOverlayService mService;
|
||||
|
||||
@Before
|
||||
@@ -129,7 +133,22 @@ public class DreamOverlayServiceTest extends SysuiTestCase {
|
||||
mDreamOverlayComponentFactory,
|
||||
mStateController,
|
||||
mKeyguardUpdateMonitor,
|
||||
mPreviewComplication);
|
||||
mPreviewComplication,
|
||||
mUiEventLogger);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnStartMetricsLogged() throws Exception {
|
||||
final IBinder proxy = mService.onBind(new Intent());
|
||||
final IDreamOverlay overlay = IDreamOverlay.Stub.asInterface(proxy);
|
||||
|
||||
// Inform the overlay service of dream starting.
|
||||
overlay.startDream(mWindowParams, mDreamOverlayCallback);
|
||||
mMainExecutor.runAllReady();
|
||||
|
||||
verify(mUiEventLogger).log(DreamOverlayService.DreamOverlayEvent.DREAM_OVERLAY_ENTER_START);
|
||||
verify(mUiEventLogger).log(
|
||||
DreamOverlayService.DreamOverlayEvent.DREAM_OVERLAY_COMPLETE_START);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user