• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2022 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Contains tables for relevant for Android."""
15
16from python.generators.trace_processor_table.public import Column as C
17from python.generators.trace_processor_table.public import ColumnDoc
18from python.generators.trace_processor_table.public import CppDouble
19from python.generators.trace_processor_table.public import CppInt32
20from python.generators.trace_processor_table.public import CppInt64
21from python.generators.trace_processor_table.public import CppOptional
22from python.generators.trace_processor_table.public import CppString
23from python.generators.trace_processor_table.public import Table
24from python.generators.trace_processor_table.public import TableDoc
25from python.generators.trace_processor_table.public import CppTableId
26from python.generators.trace_processor_table.public import CppUint32
27from python.generators.trace_processor_table.public import WrappingSqlView
28
29from src.trace_processor.tables.metadata_tables import THREAD_TABLE
30
31ANDROID_LOG_TABLE = Table(
32    python_module=__file__,
33    class_name="AndroidLogTable",
34    sql_name="__intrinsic_android_logs",
35    columns=[
36        C("ts", CppInt64()),
37        C("utid", CppTableId(THREAD_TABLE)),
38        C("prio", CppUint32()),
39        C("tag", CppOptional(CppString())),
40        C("msg", CppString()),
41    ],
42    tabledoc=TableDoc(
43        doc='''
44          Log entries from Android logcat.
45
46          NOTE: this table is not sorted by timestamp. This is why we omit the
47          sorted flag on the ts column.
48        ''',
49        group='Android',
50        columns={
51            'ts': 'Timestamp of log entry.',
52            'utid': 'Thread writing the log entry.',
53            'prio': 'Priority of the log. 3=DEBUG, 4=INFO, 5=WARN, 6=ERROR.',
54            'tag': 'Tag of the log entry.',
55            'msg': 'Content of the log entry.'
56        }))
57
58ANDROID_GAME_INTERVENTION_LIST_TABLE = Table(
59    python_module=__file__,
60    class_name='AndroidGameInterventionListTable',
61    sql_name='android_game_intervention_list',
62    columns=[
63        C('package_name', CppString()),
64        C('uid', CppInt64()),
65        C('current_mode', CppInt32()),
66        C('standard_mode_supported', CppInt32()),
67        C('standard_mode_downscale', CppOptional(CppDouble())),
68        C('standard_mode_use_angle', CppOptional(CppInt32())),
69        C('standard_mode_fps', CppOptional(CppDouble())),
70        C('perf_mode_supported', CppInt32()),
71        C('perf_mode_downscale', CppOptional(CppDouble())),
72        C('perf_mode_use_angle', CppOptional(CppInt32())),
73        C('perf_mode_fps', CppOptional(CppDouble())),
74        C('battery_mode_supported', CppInt32()),
75        C('battery_mode_downscale', CppOptional(CppDouble())),
76        C('battery_mode_use_angle', CppOptional(CppInt32())),
77        C('battery_mode_fps', CppOptional(CppDouble())),
78    ],
79    tabledoc=TableDoc(
80        doc='''
81          A table presenting all game modes and interventions
82          of games installed on the system.
83          This is generated by the game_mode_intervention data-source.
84        ''',
85        group='Android',
86        columns={
87            'package_name':
88                '''name of the pakcage, e.g. com.google.android.gm.''',
89            'uid':
90                '''UID processes of this package runs as.''',
91            'current_mode':
92                '''current game mode the game is running at.''',
93            'standard_mode_supported':
94                '''bool whether standard mode is supported.''',
95            'standard_mode_downscale':
96                '''
97                    resolution downscaling factor of standard
98                    mode.
99                ''',
100            'standard_mode_use_angle':
101                '''bool whether ANGLE is used in standard mode.''',
102            'standard_mode_fps':
103                '''
104                    frame rate that the game is throttled at in standard
105                    mode.
106                ''',
107            'perf_mode_supported':
108                '''bool whether performance mode is supported.''',
109            'perf_mode_downscale':
110                '''resolution downscaling factor of performance mode.''',
111            'perf_mode_use_angle':
112                '''bool whether ANGLE is used in performance mode.''',
113            'perf_mode_fps':
114                '''
115                    frame rate that the game is throttled at in performance
116                    mode.
117                ''',
118            'battery_mode_supported':
119                '''bool whether battery mode is supported.''',
120            'battery_mode_downscale':
121                '''resolution downscaling factor of battery mode.''',
122            'battery_mode_use_angle':
123                '''bool whether ANGLE is used in battery mode.''',
124            'battery_mode_fps':
125                '''
126                    frame rate that the game is throttled at in battery
127                    mode.
128                '''
129        }))
130
131ANDROID_DUMPSTATE_TABLE = Table(
132    python_module=__file__,
133    class_name='AndroidDumpstateTable',
134    sql_name='android_dumpstate',
135    columns=[
136        C('section', CppOptional(CppString())),
137        C('service', CppOptional(CppString())),
138        C('line', CppString()),
139    ],
140    tabledoc=TableDoc(
141        doc='''
142          Dumpsys entries from Android dumpstate.
143        ''',
144        group='Android',
145        columns={
146            'section':
147                '''name of the dumpstate section.''',
148            'service':
149                '''
150                    name of the dumpsys service. Only present when
151                    dumpstate=="dumpsys", NULL otherwise.
152                ''',
153            'line':
154                '''
155                    line-by-line contents of the section/service,
156                    one row per line.
157                '''
158        }))
159
160ANDROID_MOTION_EVENTS_TABLE = Table(
161    python_module=__file__,
162    class_name='AndroidMotionEventsTable',
163    sql_name='__intrinsic_android_motion_events',
164    columns=[
165        C('event_id', CppUint32()),
166        C('ts', CppInt64()),
167        C('arg_set_id', CppOptional(CppUint32())),
168        C('base64_proto_id', CppOptional(CppUint32())),
169    ],
170    tabledoc=TableDoc(
171        doc='Contains Android MotionEvents processed by the system',
172        group='Android',
173        columns={
174            'event_id':
175                '''
176                    The randomly-generated ID associated with each input event processed
177                    by Android Framework, used to track the event through the input pipeline.
178                ''',
179            'ts':
180                '''The timestamp of when the input event was processed by the system.''',
181            'arg_set_id':
182                ColumnDoc(
183                    doc='Details of the motion event parsed from the proto message.',
184                    joinable='args.arg_set_id'),
185            'base64_proto_id':
186                'String id for raw proto message',
187        }))
188
189ANDROID_KEY_EVENTS_TABLE = Table(
190    python_module=__file__,
191    class_name='AndroidKeyEventsTable',
192    sql_name='__intrinsic_android_key_events',
193    columns=[
194        C('event_id', CppUint32()),
195        C('ts', CppInt64()),
196        C('arg_set_id', CppOptional(CppUint32())),
197        C('base64_proto_id', CppOptional(CppUint32())),
198    ],
199    tabledoc=TableDoc(
200        doc='Contains Android KeyEvents processed by the system',
201        group='Android',
202        columns={
203            'event_id':
204                '''
205                    The randomly-generated ID associated with each input event processed
206                    by Android Framework, used to track the event through the input pipeline.
207                ''',
208            'ts':
209                '''The timestamp of when the input event was processed by the system.''',
210            'arg_set_id':
211                ColumnDoc(
212                    doc='Details of the key event parsed from the proto message.',
213                    joinable='args.arg_set_id'),
214            'base64_proto_id':
215                'String id for raw proto message',
216        }))
217
218ANDROID_INPUT_EVENT_DISPATCH_TABLE = Table(
219    python_module=__file__,
220    class_name='AndroidInputEventDispatchTable',
221    sql_name='__intrinsic_android_input_event_dispatch',
222    columns=[
223        C('event_id', CppUint32()),
224        C('arg_set_id', CppOptional(CppUint32())),
225        C('vsync_id', CppInt64()),
226        C('window_id', CppInt32()),
227        C('base64_proto_id', CppOptional(CppUint32())),
228    ],
229    tabledoc=TableDoc(
230        doc='''
231                Contains records of Android input events being dispatched to input windows
232                by the Android Framework.
233            ''',
234        group='Android',
235        columns={
236            'event_id':
237                ColumnDoc(
238                    doc='The id of the input event that was dispatched.',
239                    joinable='__intrinsic_android_motion_events.event_id'),
240            'arg_set_id':
241                ColumnDoc(
242                    doc='Details of the dispatched event parsed from the proto message.',
243                    joinable='args.arg_set_id'),
244            'vsync_id':
245                '''
246                    The id of the vsync during which the Framework made the decision to
247                    dispatch this input event, used to identify the state of the input windows
248                    when the dispatching decision was made.
249                ''',
250            'window_id':
251                'The id of the window to which the event was dispatched.',
252            'base64_proto_id':
253                'String id for raw proto message',
254        }))
255
256# Keep this list sorted.
257ALL_TABLES = [
258    ANDROID_LOG_TABLE,
259    ANDROID_DUMPSTATE_TABLE,
260    ANDROID_GAME_INTERVENTION_LIST_TABLE,
261    ANDROID_KEY_EVENTS_TABLE,
262    ANDROID_MOTION_EVENTS_TABLE,
263    ANDROID_INPUT_EVENT_DISPATCH_TABLE,
264]
265