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', CppUint32()), 168 C('base64_proto', CppString()), 169 C('base64_proto_id', CppOptional(CppUint32())), 170 ], 171 tabledoc=TableDoc( 172 doc='Contains Android MotionEvents processed by the system', 173 group='Android', 174 columns={ 175 'event_id': 176 ''' 177 The randomly-generated ID associated with each input event processed 178 by Android Framework, used to track the event through the input pipeline. 179 ''', 180 'ts': 181 '''The timestamp of when the input event was processed by the system.''', 182 'arg_set_id': 183 ColumnDoc( 184 doc='Details of the motion event parsed from the proto message.', 185 joinable='args.arg_set_id'), 186 'base64_proto': 'Raw proto message encoded in base64', 187 'base64_proto_id': 'String id for raw proto message', 188 })) 189 190ANDROID_KEY_EVENTS_TABLE = Table( 191 python_module=__file__, 192 class_name='AndroidKeyEventsTable', 193 sql_name='__intrinsic_android_key_events', 194 columns=[ 195 C('event_id', CppUint32()), 196 C('ts', CppInt64()), 197 C('arg_set_id', CppUint32()), 198 C('base64_proto', CppString()), 199 C('base64_proto_id', CppOptional(CppUint32())), 200 ], 201 tabledoc=TableDoc( 202 doc='Contains Android KeyEvents processed by the system', 203 group='Android', 204 columns={ 205 'event_id': 206 ''' 207 The randomly-generated ID associated with each input event processed 208 by Android Framework, used to track the event through the input pipeline. 209 ''', 210 'ts': 211 '''The timestamp of when the input event was processed by the system.''', 212 'arg_set_id': 213 ColumnDoc( 214 doc='Details of the key event parsed from the proto message.', 215 joinable='args.arg_set_id'), 216 'base64_proto': 'Raw proto message encoded in base64', 217 'base64_proto_id': 'String id for raw proto message', 218 })) 219 220ANDROID_INPUT_EVENT_DISPATCH_TABLE = Table( 221 python_module=__file__, 222 class_name='AndroidInputEventDispatchTable', 223 sql_name='__intrinsic_android_input_event_dispatch', 224 columns=[ 225 C('event_id', CppUint32()), 226 C('arg_set_id', CppUint32()), 227 C('vsync_id', CppInt64()), 228 C('window_id', CppInt32()), 229 C('base64_proto', CppString()), 230 C('base64_proto_id', CppOptional(CppUint32())), 231 ], 232 tabledoc=TableDoc( 233 doc=''' 234 Contains records of Android input events being dispatched to input windows 235 by the Android Framework. 236 ''', 237 group='Android', 238 columns={ 239 'event_id': 240 ColumnDoc( 241 doc='The id of the input event that was dispatched.', 242 joinable='__intrinsic_android_motion_events.event_id'), 243 'arg_set_id': 244 ColumnDoc( 245 doc='Details of the dispatched event parsed from the proto message.', 246 joinable='args.arg_set_id'), 247 'vsync_id': 248 ''' 249 The id of the vsync during which the Framework made the decision to 250 dispatch this input event, used to identify the state of the input windows 251 when the dispatching decision was made. 252 ''', 253 'window_id': 254 'The id of the window to which the event was dispatched.', 255 'base64_proto': 'Raw proto message encoded in base64', 256 'base64_proto_id': 'String id for raw proto message', 257 })) 258 259# Keep this list sorted. 260ALL_TABLES = [ 261 ANDROID_LOG_TABLE, 262 ANDROID_DUMPSTATE_TABLE, 263 ANDROID_GAME_INTERVENTION_LIST_TABLE, 264 ANDROID_KEY_EVENTS_TABLE, 265 ANDROID_MOTION_EVENTS_TABLE, 266 ANDROID_INPUT_EVENT_DISPATCH_TABLE, 267] 268