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 CppDouble 18from python.generators.trace_processor_table.public import CppInt32 19from python.generators.trace_processor_table.public import CppInt64 20from python.generators.trace_processor_table.public import CppOptional 21from python.generators.trace_processor_table.public import CppSelfTableId 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='Events', 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 81of games installed on the system. 82This is generated by the game_mode_intervention data-source. 83 ''', 84 group='Misc', 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='Events', 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 159# Keep this list sorted. 160ALL_TABLES = [ 161 ANDROID_LOG_TABLE, 162 ANDROID_DUMPSTATE_TABLE, 163 ANDROID_GAME_INTERVENTION_LIST_TABLE, 164] 165