diff options
author | Hyunyoung Song <hyunyoungs@google.com> | 2018-10-25 14:09:50 -0700 |
---|---|---|
committer | Hyunyoung Song <hyunyoungs@google.com> | 2018-11-05 11:41:38 -0800 |
commit | fc007479090e3a64d6e24534605fe08e7dc5bc96 (patch) | |
tree | 2f7d21d2f7119167740157471d03faeeba4b3f13 /src/com/android/launcher3/logging | |
parent | f107c9ef6ddc59763c1b60507c6ea7b09ecee8f9 (diff) | |
download | android_packages_apps_Trebuchet-fc007479090e3a64d6e24534605fe08e7dc5bc96.tar.gz android_packages_apps_Trebuchet-fc007479090e3a64d6e24534605fe08e7dc5bc96.tar.bz2 android_packages_apps_Trebuchet-fc007479090e3a64d6e24534605fe08e7dc5bc96.zip |
Add StatsLog*Manager for logging.
Bug: 113043444
Verification: (19) is our event classifier number
11-05 11:24:28.188 932 994 I statsd : { 1541445868000000000 766293363001 (19)0x10000->1[I] 0x20000->0[I] 0x30000->0[I] 0x40000->[S] 0x50000->1[I] }
Change-Id: I75403837f9fa8e51efa012fb708bce7efc9c4488
Diffstat (limited to 'src/com/android/launcher3/logging')
4 files changed, 130 insertions, 62 deletions
diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java index 1c4327c49..4ef86265f 100644 --- a/src/com/android/launcher3/logging/LoggerUtils.java +++ b/src/com/android/launcher3/logging/LoggerUtils.java @@ -40,6 +40,7 @@ import java.lang.reflect.Modifier; /** * Helper methods for logging. */ +@Deprecated public class LoggerUtils { private static final ArrayMap<Class, SparseArray<String>> sNameCache = new ArrayMap<>(); private static final String UNKNOWN = "UNKNOWN"; diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java new file mode 100644 index 000000000..d332dc5ce --- /dev/null +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2018 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 android.content.Context; +import android.content.Intent; +import android.view.View; + +import com.android.launcher3.R; +import com.android.launcher3.util.ComponentKey; +import com.android.launcher3.util.ResourceBasedOverride; +import com.android.launcher3.logging.StatsLogUtils.LogStateProvider; + +/** + * Handles the user event logging in Q. + * Since the AOSP Launcher3 doesn't take part in the StatsLog logging, the class + * itself is abstract. + */ +public abstract class StatsLogManager implements ResourceBasedOverride { + + protected LogStateProvider mStateProvider; + public static StatsLogManager newInstance(Context context, LogStateProvider stateProvider) { + StatsLogManager mgr = Overrides.getObject(StatsLogManager.class, + context.getApplicationContext(), R.string.stats_log_manager_class); + mgr.mStateProvider = stateProvider; + mgr.verify(); + return mgr; + } + + public void logAppLaunch(View v, Intent intent) { } + public void logTaskLaunch(View v, ComponentKey key) { } + public void verify() {} // TODO: should move into robo tests +} diff --git a/src/com/android/launcher3/logging/StatsLogUtils.java b/src/com/android/launcher3/logging/StatsLogUtils.java new file mode 100644 index 000000000..647f255af --- /dev/null +++ b/src/com/android/launcher3/logging/StatsLogUtils.java @@ -0,0 +1,67 @@ +package com.android.launcher3.logging; + +import android.view.View; +import android.view.ViewParent; + +import com.android.launcher3.ItemInfo; +import com.android.launcher3.userevent.nano.LauncherLogProto.Target; + +import androidx.annotation.Nullable; + + +public class StatsLogUtils { + + // Defined in android.stats.launcher.nano + // As they cannot be linked in this file, defining again. + public final static int LAUNCHER_STATE_BACKGROUND = 0; + public final static int LAUNCHER_STATE_HOME = 1; + public final static int LAUNCHER_STATE_OVERVIEW = 2; + public final static int LAUNCHER_STATE_ALLAPPS = 3; + + private final static int MAXIMUM_VIEW_HIERARCHY_LEVEL = 5; + + public interface LogStateProvider { + int getCurrentState(); + } + + /** + * Implemented by containers to provide a container source for a given child. + * + * Currently, + */ + public interface LogContainerProvider { + + /** + * Copies data from the source to the destination proto. + * + * @param v source of the data + * @param info source of the data + * @param target dest of the data + * @param targetParent dest of the data + */ + void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent); + } + + /** + * Recursively finds the parent of the given child which implements IconLogInfoProvider + */ + public static LogContainerProvider getLaunchProviderRecursive(@Nullable View v) { + ViewParent parent; + if (v != null) { + parent = v.getParent(); + } else { + return null; + } + + // Optimization to only check up to 5 parents. + int count = MAXIMUM_VIEW_HIERARCHY_LEVEL; + while (parent != null && count-- > 0) { + if (parent instanceof LogContainerProvider) { + return (LogContainerProvider) parent; + } else { + parent = parent.getParent(); + } + } + return null; + } +} diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index a318dc0eb..e11516890 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -41,9 +41,9 @@ import com.android.launcher3.ItemInfo; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; +import com.android.launcher3.logging.StatsLogUtils.LogContainerProvider; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action; -import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.util.ComponentKey; @@ -62,10 +62,9 @@ import androidx.annotation.Nullable; * * $ adb shell setprop log.tag.UserEvent VERBOSE */ +@Deprecated public class UserEventDispatcher implements ResourceBasedOverride { - private final static int MAXIMUM_VIEW_HIERARCHY_LEVEL = 5; - private static final String TAG = "UserEvent"; private static final boolean IS_VERBOSE = FeatureFlags.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT); @@ -96,42 +95,19 @@ public class UserEventDispatcher implements ResourceBasedOverride { } /** - * Implemented by containers to provide a container source for a given child. - */ - public interface LogContainerProvider { - - /** - * Copies data from the source to the destination proto. - * - * @param v source of the data - * @param info source of the data - * @param target dest of the data - * @param targetParent dest of the data - */ - void fillInLogContainerData(View v, ItemInfo info, Target target, Target targetParent); - } - - /** - * Recursively finds the parent of the given child which implements IconLogInfoProvider + * Fills in the container data on the given event if the given view is not null. + * @return whether container data was added. */ - public static LogContainerProvider getLaunchProviderRecursive(@Nullable View v) { - ViewParent parent; - if (v != null) { - parent = v.getParent(); - } else { - return null; - } - - // Optimization to only check up to 5 parents. - int count = MAXIMUM_VIEW_HIERARCHY_LEVEL; - while (parent != null && count-- > 0) { - if (parent instanceof LogContainerProvider) { - return (LogContainerProvider) parent; - } else { - parent = parent.getParent(); - } + @Deprecated + public static boolean fillInLogContainerData(LauncherLogProto.LauncherEvent event, @Nullable View v) { + // Fill in grid(x,y), pageIndex of the child and container type of the parent + LogContainerProvider provider = StatsLogUtils.getLaunchProviderRecursive(v); + if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) { + return false; } - return null; + ItemInfo itemInfo = (ItemInfo) v.getTag(); + provider.fillInLogContainerData(v, itemInfo, event.srcTarget[0], event.srcTarget[1]); + return true; } private boolean mSessionStarted; @@ -150,21 +126,7 @@ public class UserEventDispatcher implements ResourceBasedOverride { // intentHash required // -------------------------------------------------------------- - /** - * Fills in the container data on the given event if the given view is not null. - * @return whether container data was added. - */ - protected boolean fillInLogContainerData(LauncherEvent event, @Nullable View v) { - // Fill in grid(x,y), pageIndex of the child and container type of the parent - LogContainerProvider provider = getLaunchProviderRecursive(v); - if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) { - return false; - } - ItemInfo itemInfo = (ItemInfo) v.getTag(); - provider.fillInLogContainerData(v, itemInfo, event.srcTarget[0], event.srcTarget[1]); - return true; - } - + @Deprecated public void logAppLaunch(View v, Intent intent) { LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP), newItemTarget(v, mInstantAppResolver), newTarget(Target.Type.CONTAINER)); @@ -181,6 +143,7 @@ public class UserEventDispatcher implements ResourceBasedOverride { public void logActionTip(int actionType, int viewType) { } + @Deprecated public void logTaskLaunchOrDismiss(int action, int direction, int taskIndex, ComponentKey componentKey) { LauncherEvent event = newLauncherEvent(newTouchAction(action), // TAP or SWIPE or FLING @@ -363,7 +326,7 @@ public class UserEventDispatcher implements ResourceBasedOverride { } public void logDeepShortcutsOpen(View icon) { - LogContainerProvider provider = getLaunchProviderRecursive(icon); + LogContainerProvider provider = StatsLogUtils.getLaunchProviderRecursive(icon); if (icon == null || !(icon.getTag() instanceof ItemInfo)) { return; } @@ -376,15 +339,6 @@ public class UserEventDispatcher implements ResourceBasedOverride { resetElapsedContainerMillis("deep shortcut open"); } - /* Currently we are only interested in whether this event happens or not and don't - * care about which screen moves to where. */ - public void logOverviewReorder() { - LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP), - newContainerTarget(ContainerType.WORKSPACE), - newContainerTarget(ContainerType.OVERVIEW)); - dispatchUserEvent(event, null); - } - public void logDragNDrop(DropTarget.DragObject dragObj, View dropTargetAsView) { LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP), newItemTarget(dragObj.originalDragInfo, mInstantAppResolver), |