• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.quickstep.logging;
17 
18 import android.content.Context;
19 import android.util.Log;
20 
21 import static com.android.launcher3.logging.LoggerUtils.newLauncherEvent;
22 import static com.android.launcher3.userevent.nano.LauncherLogProto.ControlType.CANCEL_TARGET;
23 import static com.android.systemui.shared.system.LauncherEventUtil.VISIBLE;
24 import static com.android.systemui.shared.system.LauncherEventUtil.DISMISS;
25 import static com.android.systemui.shared.system.LauncherEventUtil.RECENTS_QUICK_SCRUB_ONBOARDING_TIP;
26 import static com.android.systemui.shared.system.LauncherEventUtil.RECENTS_SWIPE_UP_ONBOARDING_TIP;
27 
28 import com.android.launcher3.logging.UserEventDispatcher;
29 import com.android.launcher3.userevent.nano.LauncherLogProto;
30 import com.android.systemui.shared.system.MetricsLoggerCompat;
31 
32 /**
33  * This class handles AOSP MetricsLogger function calls and logging around
34  * quickstep interactions.
35  */
36 @SuppressWarnings("unused")
37 public class UserEventDispatcherExtension extends UserEventDispatcher {
38 
39     private static final String TAG = "UserEventDispatcher";
40 
UserEventDispatcherExtension(Context context)41     public UserEventDispatcherExtension(Context context) { }
42 
logStateChangeAction(int action, int dir, int srcChildTargetType, int srcParentContainerType, int dstContainerType, int pageIndex)43     public void logStateChangeAction(int action, int dir, int srcChildTargetType,
44                                      int srcParentContainerType, int dstContainerType,
45                                      int pageIndex) {
46         new MetricsLoggerCompat().visibility(MetricsLoggerCompat.OVERVIEW_ACTIVITY,
47                 dstContainerType == LauncherLogProto.ContainerType.TASKSWITCHER);
48         super.logStateChangeAction(action, dir, srcChildTargetType, srcParentContainerType,
49                 dstContainerType, pageIndex);
50     }
51 
logActionTip(int actionType, int viewType)52     public void logActionTip(int actionType, int viewType) {
53         LauncherLogProto.Action action = new LauncherLogProto.Action();
54         LauncherLogProto.Target target = new LauncherLogProto.Target();
55         switch(actionType) {
56             case VISIBLE:
57                 action.type = LauncherLogProto.Action.Type.TIP;
58                 target.type = LauncherLogProto.Target.Type.CONTAINER;
59                 target.containerType = LauncherLogProto.ContainerType.TIP;
60                 break;
61             case DISMISS:
62                 action.type = LauncherLogProto.Action.Type.TOUCH;
63                 action.touch = LauncherLogProto.Action.Touch.TAP;
64                 target.type = LauncherLogProto.Target.Type.CONTROL;
65                 target.controlType = CANCEL_TARGET;
66                 break;
67             default:
68                 Log.e(TAG, "Unexpected action type = " + actionType);
69         }
70 
71         switch(viewType) {
72             case RECENTS_QUICK_SCRUB_ONBOARDING_TIP:
73                 target.tipType = LauncherLogProto.TipType.QUICK_SCRUB_TEXT;
74                 break;
75             case RECENTS_SWIPE_UP_ONBOARDING_TIP:
76                 target.tipType = LauncherLogProto.TipType.SWIPE_UP_TEXT;
77                 break;
78             default:
79                 Log.e(TAG, "Unexpected viewType = " + viewType);
80         }
81         LauncherLogProto.LauncherEvent event = newLauncherEvent(action, target);
82         dispatchUserEvent(event, null);
83     }
84 }
85