diff options
5 files changed, 43 insertions, 19 deletions
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt index cb16d7c3471f..dbdbdf6ee2ba 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt @@ -150,15 +150,16 @@ constructor( fun showFromDialog( dialog: Dialog, animateFrom: Dialog, + cuj: DialogCuj? = null, animateBackgroundBoundsChange: Boolean = false ) { val view = openedDialogs.firstOrNull { it.dialog == animateFrom }?.dialogContentWithBackground ?: throw IllegalStateException( "The animateFrom dialog was not animated using " + - "DialogLaunchAnimator.showFrom(View|Dialog)" - ) - showFromView(dialog, view, animateBackgroundBoundsChange = animateBackgroundBoundsChange) + "DialogLaunchAnimator.showFrom(View|Dialog)") + showFromView( + dialog, view, animateBackgroundBoundsChange = animateBackgroundBoundsChange, cuj = cuj) } /** diff --git a/packages/SystemUI/src/com/android/systemui/qs/user/UserSwitchDialogController.kt b/packages/SystemUI/src/com/android/systemui/qs/user/UserSwitchDialogController.kt index 260a3714a368..bdcc6b0b2a57 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/user/UserSwitchDialogController.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/user/UserSwitchDialogController.kt @@ -128,15 +128,16 @@ class UserSwitchDialogController @VisibleForTesting constructor( private val animateFrom: Dialog, private val dialogLaunchAnimator: DialogLaunchAnimator ) : DialogInterface by animateFrom, DialogShower { - override fun showDialog(dialog: Dialog) { + override fun showDialog(dialog: Dialog, cuj: DialogCuj) { dialogLaunchAnimator.showFromDialog( dialog, - animateFrom = animateFrom + animateFrom = animateFrom, + cuj ) } } interface DialogShower : DialogInterface { - fun showDialog(dialog: Dialog) + fun showDialog(dialog: Dialog, cuj: DialogCuj) } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java index f151d291cda3..40281a194b12 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -68,6 +68,7 @@ import com.android.systemui.GuestResetOrExitSessionReceiver; import com.android.systemui.GuestResumeSessionReceiver; import com.android.systemui.R; import com.android.systemui.SystemUISecondaryUserService; +import com.android.systemui.animation.DialogCuj; import com.android.systemui.animation.DialogLaunchAnimator; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.broadcast.BroadcastSender; @@ -116,6 +117,9 @@ public class UserSwitcherController implements Dumpable { private static final String PERMISSION_SELF = "com.android.systemui.permission.SELF"; private static final long MULTI_USER_JOURNEY_TIMEOUT = 20000l; + private static final String INTERACTION_JANK_ADD_NEW_USER_TAG = "add_new_user"; + private static final String INTERACTION_JANK_EXIT_GUEST_MODE_TAG = "exit_guest_mode"; + protected final Context mContext; protected final UserTracker mUserTracker; protected final UserManager mUserManager; @@ -597,7 +601,9 @@ public class UserSwitcherController implements Dumpable { } mExitGuestDialog = new ExitGuestDialog(mContext, id, isGuestEphemeral, targetId); if (dialogShower != null) { - dialogShower.showDialog(mExitGuestDialog); + dialogShower.showDialog(mExitGuestDialog, new DialogCuj( + InteractionJankMonitor.CUJ_USER_DIALOG_OPEN, + INTERACTION_JANK_EXIT_GUEST_MODE_TAG)); } else { mExitGuestDialog.show(); } @@ -609,7 +615,11 @@ public class UserSwitcherController implements Dumpable { } mAddUserDialog = new AddUserDialog(mContext); if (dialogShower != null) { - dialogShower.showDialog(mAddUserDialog); + dialogShower.showDialog(mAddUserDialog, + new DialogCuj( + InteractionJankMonitor.CUJ_USER_DIALOG_OPEN, + INTERACTION_JANK_ADD_NEW_USER_TAG + )); } else { mAddUserDialog.show(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt index 1e2074bfab98..4218e0904c43 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt @@ -170,19 +170,27 @@ class DialogLaunchAnimatorTest : SysuiTestCase() { @Test fun testCujSpecificationLogsInteraction() { val touchSurface = createTouchSurface() - return runOnMainThreadAndWaitForIdleSync { + runOnMainThreadAndWaitForIdleSync { val dialog = TestDialog(context) dialogLaunchAnimator.showFromView( - dialog, touchSurface, - cuj = DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN) - ) + dialog, touchSurface, cuj = DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN)) } - verify(interactionJankMonitor).begin( - any() - ) - verify(interactionJankMonitor) - .end(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN) + verify(interactionJankMonitor).begin(any()) + verify(interactionJankMonitor).end(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN) + } + + @Test + fun testShowFromDialogCujSpecificationLogsInteraction() { + val firstDialog = createAndShowDialog() + runOnMainThreadAndWaitForIdleSync { + val dialog = TestDialog(context) + dialogLaunchAnimator.showFromDialog( + dialog, firstDialog, cuj = DialogCuj(InteractionJankMonitor.CUJ_USER_DIALOG_OPEN)) + dialog + } + verify(interactionJankMonitor).begin(any()) + verify(interactionJankMonitor).end(InteractionJankMonitor.CUJ_USER_DIALOG_OPEN) } private fun createAndShowDialog(): TestDialog { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt index e0bf9e7b0081..1af8a77b1610 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt @@ -44,6 +44,7 @@ import com.android.systemui.GuestResumeSessionReceiver import com.android.systemui.GuestSessionNotification import com.android.systemui.R import com.android.systemui.SysuiTestCase +import com.android.systemui.animation.DialogCuj import com.android.systemui.animation.DialogLaunchAnimator import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.broadcast.BroadcastSender @@ -72,12 +73,12 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyInt import org.mockito.Mock -import org.mockito.Mockito.`when` import org.mockito.Mockito.doNothing import org.mockito.Mockito.doReturn import org.mockito.Mockito.eq import org.mockito.Mockito.mock import org.mockito.Mockito.verify +import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @RunWith(AndroidTestingRunner::class) @@ -362,7 +363,10 @@ class UserSwitcherControllerTest : SysuiTestCase() { userSwitcherController.onUserListItemClicked(currentGuestUserRecord, dialogShower) assertNotNull(userSwitcherController.mExitGuestDialog) testableLooper.processAllMessages() - verify(dialogShower).showDialog(userSwitcherController.mExitGuestDialog) + verify(dialogShower) + .showDialog( + userSwitcherController.mExitGuestDialog, + DialogCuj(InteractionJankMonitor.CUJ_USER_DIALOG_OPEN, "exit_guest_mode")) } @Test |