File: AccessibilityTrace.java

package info (click to toggle)
android-platform-frameworks-base 1%3A14~beta1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 326,092 kB
  • sloc: java: 2,032,373; xml: 343,016; cpp: 304,181; python: 3,683; ansic: 2,090; sh: 1,871; makefile: 117; sed: 19
file content (216 lines) | stat: -rw-r--r-- 10,502 bytes parent folder | download | duplicates (2)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/**
 * 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 android.accessibilityservice;

import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Interface to log accessibility trace.
 *
 * @hide
 */
public interface AccessibilityTrace {
    String NAME_ACCESSIBILITY_SERVICE_CONNECTION = "IAccessibilityServiceConnection";
    String NAME_ACCESSIBILITY_SERVICE_CLIENT = "IAccessibilityServiceClient";
    String NAME_ACCESSIBILITY_MANAGER = "IAccessibilityManager";
    String NAME_ACCESSIBILITY_MANAGER_CLIENT = "IAccessibilityManagerClient";
    String NAME_ACCESSIBILITY_INTERACTION_CONNECTION = "IAccessibilityInteractionConnection";
    String NAME_ACCESSIBILITY_INTERACTION_CONNECTION_CALLBACK =
            "IAccessibilityInteractionConnectionCallback";
    String NAME_REMOTE_MAGNIFICATION_ANIMATION_CALLBACK = "IRemoteMagnificationAnimationCallback";
    String NAME_WINDOW_MAGNIFICATION_CONNECTION = "IWindowMagnificationConnection";
    String NAME_WINDOW_MAGNIFICATION_CONNECTION_CALLBACK = "IWindowMagnificationConnectionCallback";
    String NAME_WINDOW_MANAGER_INTERNAL = "WindowManagerInternal";
    String NAME_WINDOWS_FOR_ACCESSIBILITY_CALLBACK = "WindowsForAccessibilityCallback";
    String NAME_MAGNIFICATION_CALLBACK = "MagnificationCallbacks";
    String NAME_INPUT_FILTER = "InputFilter";
    String NAME_GESTURE = "Gesture";
    String NAME_ACCESSIBILITY_SERVICE = "AccessibilityService";
    String NAME_PACKAGE_BROADCAST_RECEIVER = "PMBroadcastReceiver";
    String NAME_USER_BROADCAST_RECEIVER = "UserBroadcastReceiver";
    String NAME_FINGERPRINT = "FingerprintGesture";
    String NAME_ACCESSIBILITY_INTERACTION_CLIENT = "AccessibilityInteractionClient";

    String NAME_ALL_LOGGINGS = "AllLoggings";
    String NAME_NONE = "None";

    long FLAGS_ACCESSIBILITY_SERVICE_CONNECTION = 0x0000000000000001L;
    long FLAGS_ACCESSIBILITY_SERVICE_CLIENT = 0x0000000000000002L;
    long FLAGS_ACCESSIBILITY_MANAGER = 0x0000000000000004L;
    long FLAGS_ACCESSIBILITY_MANAGER_CLIENT = 0x0000000000000008L;
    long FLAGS_ACCESSIBILITY_INTERACTION_CONNECTION = 0x0000000000000010L;
    long FLAGS_ACCESSIBILITY_INTERACTION_CONNECTION_CALLBACK = 0x0000000000000020L;
    long FLAGS_REMOTE_MAGNIFICATION_ANIMATION_CALLBACK = 0x0000000000000040L;
    long FLAGS_WINDOW_MAGNIFICATION_CONNECTION = 0x0000000000000080L;
    long FLAGS_WINDOW_MAGNIFICATION_CONNECTION_CALLBACK = 0x0000000000000100L;
    long FLAGS_WINDOW_MANAGER_INTERNAL = 0x0000000000000200L;
    long FLAGS_WINDOWS_FOR_ACCESSIBILITY_CALLBACK = 0x0000000000000400L;
    long FLAGS_MAGNIFICATION_CALLBACK = 0x0000000000000800L;
    long FLAGS_INPUT_FILTER = 0x0000000000001000L;
    long FLAGS_GESTURE = 0x0000000000002000L;
    long FLAGS_ACCESSIBILITY_SERVICE = 0x0000000000004000L;
    long FLAGS_PACKAGE_BROADCAST_RECEIVER = 0x0000000000008000L;
    long FLAGS_USER_BROADCAST_RECEIVER = 0x0000000000010000L;
    long FLAGS_FINGERPRINT = 0x0000000000020000L;
    long FLAGS_ACCESSIBILITY_INTERACTION_CLIENT = 0x0000000000040000L;

    long FLAGS_LOGGING_NONE = 0x0000000000000000L;
    long FLAGS_LOGGING_ALL = 0xFFFFFFFFFFFFFFFFL;

    long FLAGS_ACCESSIBILITY_MANAGER_CLIENT_STATES = FLAGS_ACCESSIBILITY_INTERACTION_CLIENT
            | FLAGS_ACCESSIBILITY_SERVICE
            | FLAGS_ACCESSIBILITY_INTERACTION_CONNECTION
            | FLAGS_ACCESSIBILITY_INTERACTION_CONNECTION_CALLBACK;

    Map<String, Long> sNamesToFlags = Map.ofEntries(
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_ACCESSIBILITY_SERVICE_CONNECTION, FLAGS_ACCESSIBILITY_SERVICE_CONNECTION),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_ACCESSIBILITY_SERVICE_CLIENT, FLAGS_ACCESSIBILITY_SERVICE_CLIENT),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_ACCESSIBILITY_MANAGER, FLAGS_ACCESSIBILITY_MANAGER),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_ACCESSIBILITY_MANAGER_CLIENT, FLAGS_ACCESSIBILITY_MANAGER_CLIENT),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_ACCESSIBILITY_INTERACTION_CONNECTION,
                    FLAGS_ACCESSIBILITY_INTERACTION_CONNECTION),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_ACCESSIBILITY_INTERACTION_CONNECTION_CALLBACK,
                    FLAGS_ACCESSIBILITY_INTERACTION_CONNECTION_CALLBACK),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_REMOTE_MAGNIFICATION_ANIMATION_CALLBACK,
                    FLAGS_REMOTE_MAGNIFICATION_ANIMATION_CALLBACK),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_WINDOW_MAGNIFICATION_CONNECTION, FLAGS_WINDOW_MAGNIFICATION_CONNECTION),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_WINDOW_MAGNIFICATION_CONNECTION_CALLBACK,
                    FLAGS_WINDOW_MAGNIFICATION_CONNECTION_CALLBACK),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_WINDOW_MANAGER_INTERNAL, FLAGS_WINDOW_MANAGER_INTERNAL),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_WINDOWS_FOR_ACCESSIBILITY_CALLBACK,
                    FLAGS_WINDOWS_FOR_ACCESSIBILITY_CALLBACK),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_MAGNIFICATION_CALLBACK, FLAGS_MAGNIFICATION_CALLBACK),
            new AbstractMap.SimpleEntry<String, Long>(NAME_INPUT_FILTER, FLAGS_INPUT_FILTER),
            new AbstractMap.SimpleEntry<String, Long>(NAME_GESTURE, FLAGS_GESTURE),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_ACCESSIBILITY_SERVICE, FLAGS_ACCESSIBILITY_SERVICE),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_PACKAGE_BROADCAST_RECEIVER, FLAGS_PACKAGE_BROADCAST_RECEIVER),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_USER_BROADCAST_RECEIVER, FLAGS_USER_BROADCAST_RECEIVER),
            new AbstractMap.SimpleEntry<String, Long>(NAME_FINGERPRINT, FLAGS_FINGERPRINT),
            new AbstractMap.SimpleEntry<String, Long>(
                    NAME_ACCESSIBILITY_INTERACTION_CLIENT, FLAGS_ACCESSIBILITY_INTERACTION_CLIENT),
            new AbstractMap.SimpleEntry<String, Long>(NAME_NONE, FLAGS_LOGGING_NONE),
            new AbstractMap.SimpleEntry<String, Long>(NAME_ALL_LOGGINGS, FLAGS_LOGGING_ALL));

    /**
     * Get the flags of the logging types by the given names.
     * The names list contains logging type names in lower case.
     */
    static long getLoggingFlagsFromNames(List<String> names) {
        long types = FLAGS_LOGGING_NONE;
        for (String name : names) {
            long flag = sNamesToFlags.get(name);
            types |= flag;
        }
        return types;
    }

    /**
     * Get the list of the names of logging types by the given flags.
     */
    static List<String> getNamesOfLoggingTypes(long flags) {
        List<String> list = new ArrayList<String>();

        for (Map.Entry<String, Long> entry : sNamesToFlags.entrySet()) {
            if ((entry.getValue() & flags) != FLAGS_LOGGING_NONE) {
                list.add(entry.getKey());
            }
        }

        return list;
    }

    /**
     * Whether the trace is enabled for any logging type.
     */
    boolean isA11yTracingEnabled();

    /**
     * Whether the trace is enabled for any of the given logging type.
     */
    boolean isA11yTracingEnabledForTypes(long typeIdFlags);

    /**
     * Get trace state to be sent to AccessibilityManager.
     */
    int getTraceStateForAccessibilityManagerClientState();

    /**
     * Start tracing for the given logging types.
     */
    void startTrace(long flagss);

    /**
     * Stop tracing.
     */
    void stopTrace();

    /**
     * Log one trace entry.
     * @param where A string to identify this log entry, which can be used to search through the
     *        tracing file.
     * @param loggingFlags Flags to identify which logging types this entry belongs to. This
     *        can be used to filter the log entries when generating tracing file.
     */
    void logTrace(String where, long loggingFlags);

    /**
     * Log one trace entry.
     * @param where A string to identify this log entry, which can be used to filter/search
     *        through the tracing file.
     * @param loggingFlags Flags to identify which logging types this entry belongs to. This
     *        can be used to filter the log entries when generating tracing file.
     * @param callingParams The parameters for the method to be logged.
     */
    void logTrace(String where, long loggingFlags, String callingParams);

    /**
     * Log one trace entry. Accessibility services using AccessibilityInteractionClient to
     * make screen content related requests use this API to log entry when receive callback.
     * @param timestamp The timestamp when a callback is received.
     * @param where A string to identify this log entry, which can be used to filter/search
     *        through the tracing file.
     * @param loggingFlags Flags to identify which logging types this entry belongs to. This
     *        can be used to filter the log entries when generating tracing file.
     * @param callingParams The parameters for the callback.
     * @param processId The process id of the calling component.
     * @param threadId The threadId of the calling component.
     * @param callingUid The calling uid of the callback.
     * @param callStack The call stack of the callback.
     * @param ignoreStackElements ignore these call stack element
     */
    void logTrace(long timestamp, String where, long loggingFlags, String callingParams,
            int processId, long threadId, int callingUid, StackTraceElement[] callStack,
            Set<String> ignoreStackElements);
}