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