• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 
17 package com.android.systemui.assist
18 
19 import com.android.internal.logging.UiEvent
20 import com.android.internal.logging.UiEventLogger
21 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__AOD1
22 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__AOD2
23 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__APP_DEFAULT
24 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__APP_FULLSCREEN
25 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__APP_IMMERSIVE
26 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__BOUNCER
27 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__LAUNCHER_ALL_APPS
28 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__LAUNCHER_HOME
29 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__LAUNCHER_OVERVIEW
30 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__UNKNOWN_DEVICE_STATE
31 import com.android.internal.util.FrameworkStatsLog.ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__UNLOCKED_LOCKSCREEN
32 
33 enum class AssistantInvocationEvent(private val id: Int) : UiEventLogger.UiEventEnum {
34     @UiEvent(doc = "Assistant invoked by unknown method")
35     ASSISTANT_INVOCATION_UNKNOWN(442),
36 
37     @UiEvent(doc = "Assistant invoked by touch gesture")
38     ASSISTANT_INVOCATION_TOUCH_GESTURE(443),
39 
40     @UiEvent(doc = "Assistant invoked by alternate touch gesture")
41     ASSISTANT_INVOCATION_TOUCH_GESTURE_ALT(444),
42 
43     @UiEvent(doc = "Assistant invoked by hotword")
44     ASSISTANT_INVOCATION_HOTWORD(445),
45 
46     @UiEvent(doc = "Assistant invoked by tapping quick search bar icon")
47     ASSISTANT_INVOCATION_QUICK_SEARCH_BAR(446),
48 
49     @UiEvent(doc = "Assistant invoked by home button long press")
50     ASSISTANT_INVOCATION_HOME_LONG_PRESS(447),
51 
52     @UiEvent(doc = "Assistant invoked by physical gesture")
53     ASSISTANT_INVOCATION_PHYSICAL_GESTURE(448),
54 
55     @UiEvent(doc = "Assistant invocation started by unknown method")
56     ASSISTANT_INVOCATION_START_UNKNOWN(530),
57 
58     @UiEvent(doc = "Assistant invocation started by touch gesture")
59     ASSISTANT_INVOCATION_START_TOUCH_GESTURE(531),
60 
61     @UiEvent(doc = "Assistant invocation started by physical gesture")
62     ASSISTANT_INVOCATION_START_PHYSICAL_GESTURE(532),
63 
64     @UiEvent(doc = "Assistant invoked by long press on the physical power button")
65     ASSISTANT_INVOCATION_POWER_LONG_PRESS(758);
66 
getIdnull67     override fun getId(): Int {
68         return id
69     }
70 
71     companion object {
eventFromLegacyInvocationTypenull72         fun eventFromLegacyInvocationType(legacyInvocationType: Int, isInvocationComplete: Boolean):
73                 AssistantInvocationEvent {
74             return if (isInvocationComplete) {
75                 when (legacyInvocationType) {
76                     AssistManager.INVOCATION_TYPE_GESTURE ->
77                         ASSISTANT_INVOCATION_TOUCH_GESTURE
78 
79                     AssistManager.INVOCATION_TYPE_OTHER ->
80                         ASSISTANT_INVOCATION_PHYSICAL_GESTURE
81 
82                     AssistManager.INVOCATION_TYPE_VOICE ->
83                         ASSISTANT_INVOCATION_HOTWORD
84 
85                     AssistManager.INVOCATION_TYPE_QUICK_SEARCH_BAR ->
86                         ASSISTANT_INVOCATION_QUICK_SEARCH_BAR
87 
88                     AssistManager.INVOCATION_TYPE_HOME_BUTTON_LONG_PRESS ->
89                         ASSISTANT_INVOCATION_HOME_LONG_PRESS
90 
91                     AssistManager.INVOCATION_TYPE_POWER_BUTTON_LONG_PRESS ->
92                         ASSISTANT_INVOCATION_POWER_LONG_PRESS
93 
94                     else ->
95                         ASSISTANT_INVOCATION_UNKNOWN
96                 }
97             } else {
98                 when (legacyInvocationType) {
99                     AssistManager.INVOCATION_TYPE_GESTURE ->
100                         ASSISTANT_INVOCATION_START_TOUCH_GESTURE
101 
102                     AssistManager.INVOCATION_TYPE_OTHER ->
103                         ASSISTANT_INVOCATION_START_PHYSICAL_GESTURE
104 
105                     else -> ASSISTANT_INVOCATION_START_UNKNOWN
106                 }
107             }
108         }
109 
deviceStateFromLegacyDeviceStatenull110         fun deviceStateFromLegacyDeviceState(legacyDeviceState: Int): Int {
111             return when (legacyDeviceState) {
112                 PhoneStateMonitor.PHONE_STATE_AOD1 ->
113                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__AOD1
114 
115                 PhoneStateMonitor.PHONE_STATE_AOD2 ->
116                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__AOD2
117 
118                 PhoneStateMonitor.PHONE_STATE_BOUNCER ->
119                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__BOUNCER
120 
121                 PhoneStateMonitor.PHONE_STATE_UNLOCKED_LOCKSCREEN ->
122                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__UNLOCKED_LOCKSCREEN
123 
124                 PhoneStateMonitor.PHONE_STATE_HOME ->
125                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__LAUNCHER_HOME
126 
127                 PhoneStateMonitor.PHONE_STATE_OVERVIEW ->
128                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__LAUNCHER_OVERVIEW
129 
130                 PhoneStateMonitor.PHONE_STATE_ALL_APPS ->
131                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__LAUNCHER_ALL_APPS
132 
133                 PhoneStateMonitor.PHONE_STATE_APP_DEFAULT ->
134                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__APP_DEFAULT
135 
136                 PhoneStateMonitor.PHONE_STATE_APP_IMMERSIVE ->
137                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__APP_IMMERSIVE
138 
139                 PhoneStateMonitor.PHONE_STATE_APP_FULLSCREEN ->
140                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__APP_FULLSCREEN
141 
142                 else ->
143                     ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__UNKNOWN_DEVICE_STATE
144             }
145         }
146     }
147 }
148