Database restructure: use protobuf to save battery information fields.

This patch only updates the existing fields.
There will be 2 following patches to:
1. Expose the new fields (foreground / foreground service / background x
   usage time / power consumption) to UI.
2. Get the full charge cycle start time from Database and remove the
   SharedPreference.

Test: make RunSettingsRoboTests + manual
Bug: 253553141
Change-Id: Iee02dc7e671f97899cb1495323acfa0173e31df2
This commit is contained in:
Kuan Wang
2022-11-09 16:24:23 +08:00
parent 45c9b11655
commit 1493fa2fea
19 changed files with 528 additions and 513 deletions

View File

@@ -41,3 +41,11 @@ java_library {
},
srcs: ["fuelgauge_log.proto"],
}
java_library {
name: "fuelgauge-usage-state-protos-lite",
proto: {
type: "lite",
},
srcs: ["fuelgauge_usage_state.proto"],
}

View File

@@ -0,0 +1,41 @@
syntax = "proto2";
package com.android.settings.intelligence;
option java_multiple_files = true;
option java_package = "com.android.settings.fuelgauge.batteryusage";
option java_outer_classname = "FuelgaugeUsageStateProto";
// Stores device battery relative information.
message DeviceBatteryState {
optional int32 battery_level = 1;
optional int32 battery_status = 2;
optional int32 battery_health = 3;
}
message BatteryInformation {
// Records device battery relative information.
optional DeviceBatteryState device_battery_state = 1;
// Whether the data is represented as a system component or not?
optional bool is_hidden = 2;
// Records the timestamp relative information.
optional int64 boot_timestamp = 3;
optional string zone_id = 4;
// Records app relative information.
optional string app_label = 7;
// Records the battery usage relative information.
optional double total_power = 10;
optional double consume_power = 11;
optional double percent_of_total = 12;
optional int32 drain_type = 13;
optional int64 foreground_usage_time_in_ms = 14;
optional int64 foreground_service_usage_time_in_ms = 15;
optional int64 background_usage_time_in_ms = 16;
optional double foreground_usage_consume_power = 17;
optional double foreground_service_usage_consume_power = 18;
optional double background_usage_consume_power = 19;
optional double cached_usage_consume_power = 20;
}