From 72d5d080a22d1edc55df3f44404cbfb66348c784 Mon Sep 17 00:00:00 2001 From: Ahan Wu Date: Tue, 10 Nov 2020 10:23:01 +0000 Subject: [PATCH] Support translation between interaction type and cuj type Support a helper method to translate the cuj name from interaction type. Bug: 172660959 Test: atest CollectorsHelperTest: com.android.helpers.UiInteractionFrameInfoHelperTest Change-Id: I3bcc64684b79fad7fc59b71a269231eb6dd91674 --- .../internal/jank/InteractionJankMonitor.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/core/java/com/android/internal/jank/InteractionJankMonitor.java b/core/java/com/android/internal/jank/InteractionJankMonitor.java index 137430b7de144..bb7e2af2db6bb 100644 --- a/core/java/com/android/internal/jank/InteractionJankMonitor.java +++ b/core/java/com/android/internal/jank/InteractionJankMonitor.java @@ -347,6 +347,57 @@ public class InteractionJankMonitor { } } + /** + * A helper method to translate interaction type to CUJ name. + * + * @param interactionType the interaction type defined in AtomsProto.java + * @return the name of the interaction type + */ + public static String getNameOfInteraction(int interactionType) { + // There is an offset amount of 1 between cujType and interactionType. + return getNameOfCuj(interactionType - 1); + } + + private static String getNameOfCuj(int cujType) { + switch (cujType) { + case CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE: + return "SHADE_EXPAND_COLLAPSE"; + case CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE_LOCK: + return "SHADE_EXPAND_COLLAPSE_LOCK"; + case CUJ_NOTIFICATION_SHADE_SCROLL_FLING: + return "SHADE_SCROLL_FLING"; + case CUJ_NOTIFICATION_SHADE_ROW_EXPAND: + return "SHADE_ROW_EXPAND"; + case CUJ_NOTIFICATION_SHADE_ROW_SWIPE: + return "SHADE_ROW_SWIPE"; + case CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE: + return "SHADE_QS_EXPAND_COLLAPSE"; + case CUJ_NOTIFICATION_SHADE_QS_SCROLL_SWIPE: + return "SHADE_QS_SCROLL_SWIPE"; + case CUJ_LAUNCHER_APP_LAUNCH_FROM_RECENTS: + return "LAUNCHER_APP_LAUNCH_FROM_RECENTS"; + case CUJ_LAUNCHER_APP_LAUNCH_FROM_ICON: + return "LAUNCHER_APP_LAUNCH_FROM_ICON"; + case CUJ_LAUNCHER_APP_CLOSE_TO_HOME: + return "LAUNCHER_APP_CLOSE_TO_HOME"; + case CUJ_LAUNCHER_APP_CLOSE_TO_PIP: + return "LAUNCHER_APP_CLOSE_TO_PIP"; + case CUJ_LAUNCHER_QUICK_SWITCH: + return "LAUNCHER_QUICK_SWITCH"; + case CUJ_NOTIFICATION_HEADS_UP_APPEAR: + return "NOTIFICATION_HEADS_UP_APPEAR"; + case CUJ_NOTIFICATION_HEADS_UP_DISAPPEAR: + return "NOTIFICATION_HEADS_UP_DISAPPEAR"; + case CUJ_NOTIFICATION_ADD: + return "NOTIFICATION_ADD"; + case CUJ_NOTIFICATION_REMOVE: + return "NOTIFICATION_REMOVE"; + case CUJ_NOTIFICATION_APP_START: + return "NOTIFICATION_APP_START"; + } + return "UNKNOWN"; + } + /** * A class to represent a session. */