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.DISMISS;
24 import static com.android.systemui.shared.system.LauncherEventUtil.RECENTS_QUICK_SCRUB_ONBOARDING_TIP;
25 import static com.android.systemui.shared.system.LauncherEventUtil.RECENTS_SWIPE_UP_ONBOARDING_TIP;
26 import static com.android.systemui.shared.system.LauncherEventUtil.VISIBLE;
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     public static final int ALL_APPS_PREDICTION_TIPS = 2;
40 
41     private static final String TAG = "UserEventDispatcher";
42 
UserEventDispatcherExtension(Context context)43     public UserEventDispatcherExtension(Context context) { }
44 
logStateChangeAction(int action, int dir, int downX, int downY, int srcChildTargetType, int srcParentContainerType, int dstContainerType, int pageIndex)45     public void logStateChangeAction(int action, int dir, int downX, int downY,
46                                      int srcChildTargetType, int srcParentContainerType,
47                                      int dstContainerType, int pageIndex) {
48         new MetricsLoggerCompat().visibility(MetricsLoggerCompat.OVERVIEW_ACTIVITY,
49                 dstContainerType == LauncherLogProto.ContainerType.TASKSWITCHER);
50         super.logStateChangeAction(action, dir, downX, downY, srcChildTargetType,
51                 srcParentContainerType, dstContainerType, pageIndex);
52     }
53 
logActionTip(int actionType, int viewType)54     public void logActionTip(int actionType, int viewType) {
55         LauncherLogProto.Action action = new LauncherLogProto.Action();
56         LauncherLogProto.Target target = new LauncherLogProto.Target();
57         switch(actionType) {
58             case VISIBLE:
59                 action.type = LauncherLogProto.Action.Type.TIP;
60                 target.type = LauncherLogProto.Target.Type.CONTAINER;
61                 target.containerType = LauncherLogProto.ContainerType.TIP;
62                 break;
63             case DISMISS:
64                 action.type = LauncherLogProto.Action.Type.TOUCH;
65                 action.touch = LauncherLogProto.Action.Touch.TAP;
66                 target.type = LauncherLogProto.Target.Type.CONTROL;
67                 target.controlType = CANCEL_TARGET;
68                 break;
69             default:
70                 Log.e(TAG, "Unexpected action type = " + actionType);
71         }
72 
73         switch(viewType) {
74             case RECENTS_QUICK_SCRUB_ONBOARDING_TIP:
75                 target.tipType = LauncherLogProto.TipType.QUICK_SCRUB_TEXT;
76                 break;
77             case RECENTS_SWIPE_UP_ONBOARDING_TIP:
78                 target.tipType = LauncherLogProto.TipType.SWIPE_UP_TEXT;
79                 break;
80             default:
81                 Log.e(TAG, "Unexpected viewType = " + viewType);
82         }
83         LauncherLogProto.LauncherEvent event = newLauncherEvent(action, target);
84         dispatchUserEvent(event, null);
85     }
86 }
87