• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 INT,
20  -- Current average micro ampers.
21  current_avg_ua INT,
22  -- Current capacity percentage.
23  capacity_percent INT,
24  -- Current charge in micro ampers.
25  charge_uah INT,
26  -- Current micro ampers.
27  current_ua INT
28)  AS
29SELECT
30  all_ts.ts,
31  current_avg_ua,
32  capacity_percent,
33  charge_uah,
34  current_ua
35FROM (
36  SELECT DISTINCT(ts) AS ts
37  FROM counter c
38  JOIN counter_track t ON c.track_id = t.id
39  WHERE name GLOB 'batt.*'
40) AS all_ts
41LEFT JOIN (
42  SELECT ts, value AS current_avg_ua
43  FROM counter c
44  JOIN counter_track t ON c.track_id = t.id
45  WHERE name = 'batt.current.avg_ua'
46) USING(ts)
47LEFT JOIN (
48  SELECT ts, value AS capacity_percent
49  FROM counter c
50  JOIN counter_track t ON c.track_id = t.id
51  WHERE name = 'batt.capacity_pct'
52) USING(ts)
53LEFT JOIN (
54  SELECT ts, value AS charge_uah
55  FROM counter c
56  JOIN counter_track t ON c.track_id = t.id
57  WHERE name = 'batt.charge_uah'
58) USING(ts)
59LEFT JOIN (
60  SELECT ts, value AS current_ua
61  FROM counter c
62  JOIN counter_track t ON c.track_id = t.id
63  WHERE name = 'batt.current_ua'
64) USING(ts)
65ORDER BY ts;
66