1-- 2-- Copyright 2022 The Android Open Source Project 3-- 4-- Licensed under the Apache License, Version 2.0 (the "License"); 5-- you may not use this file except in compliance with the License. 6-- You may obtain a copy of the License at 7-- 8-- https://www.apache.org/licenses/LICENSE-2.0 9-- 10-- Unless required by applicable law or agreed to in writing, software 11-- distributed under the License is distributed on an "AS IS" BASIS, 12-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13-- See the License for the specific language governing permissions and 14-- limitations under the License. 15 16-- Battery charge at timestamp. 17CREATE PERFETTO VIEW android_battery_charge ( 18 -- Timestamp. 19 ts TIMESTAMP, 20 -- Current average micro ampers. 21 current_avg_ua DOUBLE, 22 -- Current capacity percentage. 23 capacity_percent DOUBLE, 24 -- Current charge in micro ampers. 25 charge_uah DOUBLE, 26 -- Current micro ampers. 27 current_ua DOUBLE, 28 -- Current voltage in micro volts. 29 voltage_uv DOUBLE, 30 -- Current energy counter in microwatt-hours(µWh). 31 energy_counter_uwh DOUBLE 32) AS 33SELECT 34 all_ts.ts, 35 current_avg_ua, 36 capacity_percent, 37 charge_uah, 38 current_ua, 39 voltage_uv, 40 energy_counter_uwh 41FROM ( 42 SELECT DISTINCT 43 ( 44 ts 45 ) AS ts 46 FROM counter AS c 47 JOIN counter_track AS t 48 ON c.track_id = t.id 49 WHERE 50 name GLOB 'batt.*' 51) AS all_ts 52LEFT JOIN ( 53 SELECT 54 ts, 55 value AS current_avg_ua 56 FROM counter AS c 57 JOIN counter_track AS t 58 ON c.track_id = t.id 59 WHERE 60 name = 'batt.current.avg_ua' 61) 62 USING (ts) 63LEFT JOIN ( 64 SELECT 65 ts, 66 value AS capacity_percent 67 FROM counter AS c 68 JOIN counter_track AS t 69 ON c.track_id = t.id 70 WHERE 71 name = 'batt.capacity_pct' 72) 73 USING (ts) 74LEFT JOIN ( 75 SELECT 76 ts, 77 value AS charge_uah 78 FROM counter AS c 79 JOIN counter_track AS t 80 ON c.track_id = t.id 81 WHERE 82 name = 'batt.charge_uah' 83) 84 USING (ts) 85LEFT JOIN ( 86 SELECT 87 ts, 88 value AS current_ua 89 FROM counter AS c 90 JOIN counter_track AS t 91 ON c.track_id = t.id 92 WHERE 93 name = 'batt.current_ua' 94) 95 USING (ts) 96LEFT JOIN ( 97 SELECT 98 ts, 99 value AS voltage_uv 100 FROM counter AS c 101 JOIN counter_track AS t 102 ON c.track_id = t.id 103 WHERE 104 name = 'batt.voltage_uv' 105) 106 USING (ts) 107LEFT JOIN ( 108 SELECT 109 ts, 110 value AS energy_counter_uwh 111 FROM counter AS c 112 JOIN counter_track AS t 113 ON c.track_id = t.id 114 WHERE 115 name = 'batt.energy_counter_uwh' 116) 117 USING (ts) 118ORDER BY 119 ts; 120