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