From 6b99a7d3977e62c2555e8a2decbd2769d92179a1 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Thu, 9 Apr 2020 14:40:43 -0700 Subject: [PATCH] Use UiEvent for constants inside StatsLogManager Bug: 137777105 Bug: 148533500 Change-Id: I8ebf1110e8d25ab28f7496add9734bd7386b272f --- Android.mk | 7 ++++- .../android/quickstep/views/RecentsView.java | 10 ++++--- .../com/android/quickstep/views/TaskView.java | 4 +-- .../launcher3/BaseDraggingActivity.java | 4 +-- .../launcher3/logging/LauncherUiEvent.java | 30 ------------------- .../launcher3/logging/StatsLogManager.java | 24 +++++++-------- 6 files changed, 27 insertions(+), 52 deletions(-) delete mode 100644 src/com/android/launcher3/logging/LauncherUiEvent.java diff --git a/Android.mk b/Android.mk index 9cfcf17b99..352885bcd9 100644 --- a/Android.mk +++ b/Android.mk @@ -32,7 +32,8 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \ LOCAL_STATIC_JAVA_LIBRARIES := \ LauncherPluginLib \ - launcher_log_protos_lite + launcher_log_protos_lite \ + uieventloggerlib LOCAL_SRC_FILES := \ $(call all-proto-files-under, protos) \ @@ -130,8 +131,10 @@ LOCAL_MODULE_TAGS := optional LOCAL_STATIC_JAVA_LIBRARIES := \ SystemUISharedLib \ + SystemUI-statsd \ launcherprotosnano \ launcher_log_protos_lite + ifneq (,$(wildcard frameworks/base)) LOCAL_PRIVATE_PLATFORM_APIS := true else @@ -202,8 +205,10 @@ LOCAL_MODULE_TAGS := optional LOCAL_STATIC_JAVA_LIBRARIES := \ SystemUISharedLib \ + SystemUI-statsd \ launcherprotosnano \ launcher_log_protos_lite + ifneq (,$(wildcard frameworks/base)) LOCAL_PRIVATE_PLATFORM_APIS := true else diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index 3e88ecb560..5046f4b4b8 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -30,8 +30,8 @@ import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; -import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.TASK_DISMISS_SWIPE_UP; -import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.TASK_LAUNCH_SWIPE_DOWN; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_DISMISS_SWIPE_UP; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_SWIPE_DOWN; import static com.android.launcher3.statehandlers.DepthController.DEPTH; import static com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController.SUCCESS_TRANSITION_PROGRESS; import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.TAP; @@ -1279,7 +1279,8 @@ public abstract class RecentsView extends PagedView impl ComponentKey compKey = TaskUtils.getLaunchComponentKeyForTask(taskView.getTask().key); mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss( endState.logAction, Direction.UP, index, compKey); - mActivity.getStatsLogManager().log(TASK_DISMISS_SWIPE_UP, taskView.buildProto()); + mActivity.getStatsLogManager().log(LAUNCHER_TASK_DISMISS_SWIPE_UP, + taskView.buildProto()); } } @@ -1829,7 +1830,8 @@ public abstract class RecentsView extends PagedView impl mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss( endState.logAction, Direction.DOWN, indexOfChild(tv), TaskUtils.getLaunchComponentKeyForTask(task.key)); - mActivity.getStatsLogManager().log(TASK_LAUNCH_SWIPE_DOWN, tv.buildProto() + mActivity.getStatsLogManager().log(LAUNCHER_TASK_LAUNCH_SWIPE_DOWN, + tv.buildProto() ); } } else { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java index 470b720f5e..171c91df34 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java @@ -29,7 +29,7 @@ import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; -import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.TASK_LAUNCH_TAP; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_TAP; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -209,7 +209,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss( Touch.TAP, Direction.NONE, getRecentsView().indexOfChild(this), TaskUtils.getLaunchComponentKeyForTask(getTask().key)); - mActivity.getStatsLogManager().log(TASK_LAUNCH_TAP, buildProto()); + mActivity.getStatsLogManager().log(LAUNCHER_TASK_LAUNCH_TAP, buildProto()); }); mCornerRadius = TaskCornerRadius.get(context); mWindowCornerRadius = QuickStepContract.getWindowCornerRadius(context.getResources()); diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index 6fa3c28b21..4732e73d17 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -16,7 +16,7 @@ package com.android.launcher3; -import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.APP_LAUNCH_TAP; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP; import static com.android.launcher3.util.DefaultDisplay.CHANGE_ROTATION; import android.app.ActivityOptions; @@ -182,7 +182,7 @@ public abstract class BaseDraggingActivity extends BaseActivity sourceContainer); } getUserEventDispatcher().logAppLaunch(v, intent, user); - getStatsLogManager().log(APP_LAUNCH_TAP, item.buildProto(null, null)); + getStatsLogManager().log(LAUNCHER_APP_LAUNCH_TAP, item.buildProto(null, null)); return true; } catch (NullPointerException|ActivityNotFoundException|SecurityException e) { Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); diff --git a/src/com/android/launcher3/logging/LauncherUiEvent.java b/src/com/android/launcher3/logging/LauncherUiEvent.java deleted file mode 100644 index 4507ff7d76..0000000000 --- a/src/com/android/launcher3/logging/LauncherUiEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.launcher3.logging; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.RetentionPolicy.SOURCE; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Retention(SOURCE) -@Target(FIELD) -public @interface LauncherUiEvent { - /** An explanation, suitable for Android analysts, of the UI event that this log represents. */ - String doc(); -} - diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index 2829951da2..60d790fd4b 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -17,6 +17,8 @@ package com.android.launcher3.logging; import android.content.Context; +import com.android.internal.logging.UiEvent; +import com.android.internal.logging.UiEventLogger; import com.android.launcher3.R; import com.android.launcher3.logger.LauncherAtom; import com.android.launcher3.logger.LauncherAtom.ItemInfo; @@ -28,19 +30,15 @@ import com.android.launcher3.util.ResourceBasedOverride; */ public class StatsLogManager implements ResourceBasedOverride { - interface EventEnum { - int getId(); - } - - public enum LauncherEvent implements EventEnum { - @LauncherUiEvent(doc = "App launched from workspace, hotseat or folder in launcher") - APP_LAUNCH_TAP(1), - @LauncherUiEvent(doc = "Task launched from overview using TAP") - TASK_LAUNCH_TAP(2), - @LauncherUiEvent(doc = "Task launched from overview using SWIPE DOWN") - TASK_LAUNCH_SWIPE_DOWN(2), - @LauncherUiEvent(doc = "TASK dismissed from overview using SWIPE UP") - TASK_DISMISS_SWIPE_UP(3); + public enum LauncherEvent implements UiEventLogger.UiEventEnum { + @UiEvent(doc = "App launched from workspace, hotseat or folder in launcher") + LAUNCHER_APP_LAUNCH_TAP(338), + @UiEvent(doc = "Task launched from overview using TAP") + LAUNCHER_TASK_LAUNCH_TAP(339), + @UiEvent(doc = "Task launched from overview using SWIPE DOWN") + LAUNCHER_TASK_LAUNCH_SWIPE_DOWN(340), + @UiEvent(doc = "TASK dismissed from overview using SWIPE UP") + LAUNCHER_TASK_DISMISS_SWIPE_UP(341); // ADD MORE private final int mId;