1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
* Copyright (C) 2021 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.systemui.controls
import android.service.controls.DeviceTypes.DeviceType
import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
import com.android.systemui.controls.ui.ControlViewHolder
/**
* Interface for logging UI events related to controls
*/
interface ControlsMetricsLogger {
/**
* Assign a new instance id for this controls session, defined as when the controls area is
* made visible to when it is closed.
*/
fun assignInstanceId()
fun touch(cvh: ControlViewHolder, isLocked: Boolean) {
log(ControlsEvents.CONTROL_TOUCH.id, cvh.deviceType, cvh.uid, isLocked)
}
fun drag(cvh: ControlViewHolder, isLocked: Boolean) {
log(ControlsEvents.CONTROL_DRAG.id, cvh.deviceType, cvh.uid, isLocked)
}
fun longPress(cvh: ControlViewHolder, isLocked: Boolean) {
log(ControlsEvents.CONTROL_LONG_PRESS.id, cvh.deviceType, cvh.uid, isLocked)
}
fun refreshBegin(uid: Int, isLocked: Boolean) {
assignInstanceId()
log(ControlsEvents.CONTROL_REFRESH_BEGIN.id, 0, uid, isLocked)
}
fun refreshEnd(cvh: ControlViewHolder, isLocked: Boolean) {
log(ControlsEvents.CONTROL_REFRESH_END.id, cvh.deviceType, cvh.uid, isLocked)
}
/**
* Logs a controls-related event
*
* @param eventId Main UIEvent to capture
* @param deviceType One of {@link android.service.controls.DeviceTypes}
* @param packageName Package name of the service that receives the request
* @param isLocked Is the device locked at the start of the action?
*/
fun log(
eventId: Int,
@DeviceType deviceType: Int,
uid: Int,
isLocked: Boolean
)
private enum class ControlsEvents(val metricId: Int) : UiEventLogger.UiEventEnum {
@UiEvent(doc = "User touched a control")
CONTROL_TOUCH(714),
@UiEvent(doc = "User dragged a control")
CONTROL_DRAG(713),
@UiEvent(doc = "User long-pressed a control")
CONTROL_LONG_PRESS(715),
@UiEvent(doc = "User has opened controls, and a state refresh has begun")
CONTROL_REFRESH_BEGIN(716),
@UiEvent(doc = "User has opened controls, and a state refresh has ended")
CONTROL_REFRESH_END(717);
override fun getId() = metricId
}
}
|