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 getIdnull64 override fun getId(): Int { 65 return id 66 } 67 68 companion object { eventFromLegacyInvocationTypenull69 fun eventFromLegacyInvocationType(legacyInvocationType: Int, isInvocationComplete: Boolean) 70 : AssistantInvocationEvent { 71 return if (isInvocationComplete) { 72 when (legacyInvocationType) { 73 AssistManager.INVOCATION_TYPE_GESTURE -> 74 ASSISTANT_INVOCATION_TOUCH_GESTURE 75 76 AssistManager.INVOCATION_TYPE_OTHER -> 77 ASSISTANT_INVOCATION_PHYSICAL_GESTURE 78 79 AssistManager.INVOCATION_TYPE_VOICE -> 80 ASSISTANT_INVOCATION_HOTWORD 81 82 AssistManager.INVOCATION_TYPE_QUICK_SEARCH_BAR -> 83 ASSISTANT_INVOCATION_QUICK_SEARCH_BAR 84 85 AssistManager.INVOCATION_HOME_BUTTON_LONG_PRESS -> 86 ASSISTANT_INVOCATION_HOME_LONG_PRESS 87 88 else -> 89 ASSISTANT_INVOCATION_UNKNOWN 90 } 91 } else { 92 when (legacyInvocationType) { 93 AssistManager.INVOCATION_TYPE_GESTURE -> 94 ASSISTANT_INVOCATION_START_TOUCH_GESTURE 95 96 AssistManager.INVOCATION_TYPE_OTHER -> 97 ASSISTANT_INVOCATION_START_PHYSICAL_GESTURE 98 99 else -> ASSISTANT_INVOCATION_START_UNKNOWN 100 } 101 } 102 } 103 deviceStateFromLegacyDeviceStatenull104 fun deviceStateFromLegacyDeviceState(legacyDeviceState: Int): Int { 105 return when (legacyDeviceState) { 106 PhoneStateMonitor.PHONE_STATE_AOD1 -> 107 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__AOD1 108 109 PhoneStateMonitor.PHONE_STATE_AOD2 -> 110 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__AOD2 111 112 PhoneStateMonitor.PHONE_STATE_BOUNCER -> 113 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__BOUNCER 114 115 PhoneStateMonitor.PHONE_STATE_UNLOCKED_LOCKSCREEN -> 116 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__UNLOCKED_LOCKSCREEN 117 118 PhoneStateMonitor.PHONE_STATE_HOME -> 119 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__LAUNCHER_HOME 120 121 PhoneStateMonitor.PHONE_STATE_OVERVIEW -> 122 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__LAUNCHER_OVERVIEW 123 124 PhoneStateMonitor.PHONE_STATE_ALL_APPS -> 125 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__LAUNCHER_ALL_APPS 126 127 PhoneStateMonitor.PHONE_STATE_APP_DEFAULT -> 128 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__APP_DEFAULT 129 130 PhoneStateMonitor.PHONE_STATE_APP_IMMERSIVE -> 131 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__APP_IMMERSIVE 132 133 PhoneStateMonitor.PHONE_STATE_APP_FULLSCREEN -> 134 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__APP_FULLSCREEN 135 136 else -> 137 ASSISTANT_INVOCATION_REPORTED__DEVICE_STATE__UNKNOWN_DEVICE_STATE 138 } 139 } 140 } 141 }