summaryrefslogtreecommitdiff
path: root/health
diff options
context:
space:
mode:
authorMaggie White <maggiewhite@google.com>2019-04-01 20:34:45 -0700
committerMaggie White <maggiewhite@google.com>2019-04-11 15:51:06 -0700
commita6969212604257c752f90e79ade3d051a00dd1ac (patch)
tree5aef10d5b33837bfeaf66a1dbed9b0ddd4061cca /health
parent6188dd09e6a53a2ad78d9ed4bf821ed36c657620 (diff)
downloadpixel-a6969212604257c752f90e79ade3d051a00dd1ac.tar.gz
health: pixelstats: Remove references to IPixelStats
Bug: 122904980 Change-Id: I3be3928c214de7cf788111cabb4ceda5806e9c6d Signed-off-by: Maggie White <maggiewhite@google.com> Merged-In: 7b2dc962f0154bceb81d18f9a8bec2e05cbe911e
Diffstat (limited to 'health')
-rw-r--r--health/Android.bp1
-rw-r--r--health/BatteryMetricsLogger.cpp94
-rw-r--r--health/LowBatteryShutdownMetrics.cpp9
-rw-r--r--health/include/pixelhealth/BatteryMetricsLogger.h28
-rw-r--r--health/include/pixelhealth/LowBatteryShutdownMetrics.h4
5 files changed, 37 insertions, 99 deletions
diff --git a/health/Android.bp b/health/Android.bp
index cff31327..99d65826 100644
--- a/health/Android.bp
+++ b/health/Android.bp
@@ -25,7 +25,6 @@ cc_library {
shared_libs: [
"android.frameworks.stats@1.0",
- "hardware.google.pixelstats@1.0",
"libbase",
"libcutils",
"libhidlbase",
diff --git a/health/BatteryMetricsLogger.cpp b/health/BatteryMetricsLogger.cpp
index 3a9beb5d..b5e89918 100644
--- a/health/BatteryMetricsLogger.cpp
+++ b/health/BatteryMetricsLogger.cpp
@@ -26,7 +26,6 @@ namespace health {
using android::sp;
using android::frameworks::stats::V1_0::BatteryHealthSnapshotArgs;
using android::frameworks::stats::V1_0::IStats;
-using ::hardware::google::pixelstats::V1_0::IPixelStats;
BatteryMetricsLogger::BatteryMetricsLogger(const char *const batt_res, const char *const batt_ocv,
int sample_period, int upload_period)
@@ -48,53 +47,29 @@ int64_t BatteryMetricsLogger::getTime(void) {
return nanoseconds_to_seconds(systemTime(SYSTEM_TIME_BOOTTIME));
}
-bool BatteryMetricsLogger::uploadOutlierMetric(sp<IPixelStats> client, sp<IStats> stats_client,
- sampleType type) {
- IPixelStats::BatteryHealthSnapshotArgs min_ss = {
- .type = static_cast<IPixelStats::BatterySnapshotType>(0),
- .temperatureDeciC = min_[type][TEMP],
- .voltageMicroV = min_[type][VOLT],
- .currentMicroA = min_[type][CURR],
- .openCircuitVoltageMicroV = min_[type][OCV],
- .resistanceMicroOhm = min_[type][RES],
- .levelPercent = min_[type][SOC]};
- IPixelStats::BatteryHealthSnapshotArgs max_ss = {
- .type = static_cast<IPixelStats::BatterySnapshotType>(0),
- .temperatureDeciC = max_[type][TEMP],
- .voltageMicroV = max_[type][VOLT],
- .currentMicroA = max_[type][CURR],
- .openCircuitVoltageMicroV = max_[type][OCV],
- .resistanceMicroOhm = max_[type][RES],
- .levelPercent = max_[type][SOC]};
-
+bool BatteryMetricsLogger::uploadOutlierMetric(sp<IStats> stats_client, sampleType type) {
BatteryHealthSnapshotArgs min_stats_ss = {
- .type = static_cast<BatteryHealthSnapshotArgs::BatterySnapshotType>(0),
- .temperatureDeciC = min_[type][TEMP],
- .voltageMicroV = min_[type][VOLT],
- .currentMicroA = min_[type][CURR],
- .openCircuitVoltageMicroV = min_[type][OCV],
- .resistanceMicroOhm = min_[type][RES],
- .levelPercent = min_[type][SOC]};
+ .type = static_cast<BatteryHealthSnapshotArgs::BatterySnapshotType>(0),
+ .temperatureDeciC = min_[type][TEMP],
+ .voltageMicroV = min_[type][VOLT],
+ .currentMicroA = min_[type][CURR],
+ .openCircuitVoltageMicroV = min_[type][OCV],
+ .resistanceMicroOhm = min_[type][RES],
+ .levelPercent = min_[type][SOC]};
BatteryHealthSnapshotArgs max_stats_ss = {
- .type = static_cast<BatteryHealthSnapshotArgs::BatterySnapshotType>(0),
- .temperatureDeciC = max_[type][TEMP],
- .voltageMicroV = max_[type][VOLT],
- .currentMicroA = max_[type][CURR],
- .openCircuitVoltageMicroV = max_[type][OCV],
- .resistanceMicroOhm = max_[type][RES],
- .levelPercent = max_[type][SOC]};
- if (kSnapshotType[type] < 0)
+ .type = static_cast<BatteryHealthSnapshotArgs::BatterySnapshotType>(0),
+ .temperatureDeciC = max_[type][TEMP],
+ .voltageMicroV = max_[type][VOLT],
+ .currentMicroA = max_[type][CURR],
+ .openCircuitVoltageMicroV = max_[type][OCV],
+ .resistanceMicroOhm = max_[type][RES],
+ .levelPercent = max_[type][SOC]};
+ if (kStatsSnapshotType[type] < 0)
return false;
- min_ss.type = (IPixelStats::BatterySnapshotType)kSnapshotType[type];
- max_ss.type = (IPixelStats::BatterySnapshotType)(kSnapshotType[type] + 1);
-
min_stats_ss.type = (BatteryHealthSnapshotArgs::BatterySnapshotType)kStatsSnapshotType[type];
max_stats_ss.type =
- (BatteryHealthSnapshotArgs::BatterySnapshotType)(kStatsSnapshotType[type] + 1);
-
- client->reportBatteryHealthSnapshot(min_ss);
- client->reportBatteryHealthSnapshot(max_ss);
+ (BatteryHealthSnapshotArgs::BatterySnapshotType)(kStatsSnapshotType[type] + 1);
stats_client->reportBatteryHealthSnapshot(min_stats_ss);
stats_client->reportBatteryHealthSnapshot(max_stats_ss);
@@ -123,15 +98,9 @@ bool BatteryMetricsLogger::uploadMetrics(void) {
return false;
}
- sp<IPixelStats> client = IPixelStats::tryGetService();
- if (!client) {
- LOG(ERROR) << "Unable to connect to PixelStats service";
- return false;
- }
-
// Only log and upload the min and max for metric types we want to upload
for (int metric = 0; metric < NUM_FIELDS; metric++) {
- if ((metric == RES && num_res_samples_ == 0) || kSnapshotType[metric] < 0)
+ if ((metric == RES && num_res_samples_ == 0) || kStatsSnapshotType[metric] < 0)
continue;
std::string log_min = "min-" + std::to_string(metric) + " ";
std::string log_max = "max-" + std::to_string(metric) + " ";
@@ -142,28 +111,19 @@ bool BatteryMetricsLogger::uploadMetrics(void) {
LOG(INFO) << log_min;
LOG(INFO) << log_max;
// Upload min/max metrics
- uploadOutlierMetric(client, stats_client, static_cast<sampleType>(metric));
+ uploadOutlierMetric(stats_client, static_cast<sampleType>(metric));
}
// Upload average metric
- IPixelStats::BatteryHealthSnapshotArgs avg_res_ss = {
- .type = IPixelStats::BatterySnapshotType::AVG_RESISTANCE,
- .temperatureDeciC = 0,
- .voltageMicroV = 0,
- .currentMicroA = 0,
- .openCircuitVoltageMicroV = 0,
- .resistanceMicroOhm = avg_resistance,
- .levelPercent = 0};
BatteryHealthSnapshotArgs avg_res_ss_stats = {
- .type = BatteryHealthSnapshotArgs::BatterySnapshotType::AVG_RESISTANCE,
- .temperatureDeciC = 0,
- .voltageMicroV = 0,
- .currentMicroA = 0,
- .openCircuitVoltageMicroV = 0,
- .resistanceMicroOhm = avg_resistance,
- .levelPercent = 0};
+ .type = BatteryHealthSnapshotArgs::BatterySnapshotType::AVG_RESISTANCE,
+ .temperatureDeciC = 0,
+ .voltageMicroV = 0,
+ .currentMicroA = 0,
+ .openCircuitVoltageMicroV = 0,
+ .resistanceMicroOhm = avg_resistance,
+ .levelPercent = 0};
if (num_res_samples_) {
- client->reportBatteryHealthSnapshot(avg_res_ss);
stats_client->reportBatteryHealthSnapshot(avg_res_ss_stats);
}
@@ -215,7 +175,7 @@ bool BatteryMetricsLogger::recordSample(struct android::BatteryProperties *props
for (int metric = 0; metric < NUM_FIELDS; metric++) {
// Discard resistance min/max when charging
if ((metric == RES && props->batteryStatus == android::BATTERY_STATUS_CHARGING) ||
- kSnapshotType[metric] < 0)
+ kStatsSnapshotType[metric] < 0)
continue;
if (num_samples_ == 0 || (metric == RES && num_res_samples_ == 0) ||
sample[metric] < min_[metric][metric]) {
diff --git a/health/LowBatteryShutdownMetrics.cpp b/health/LowBatteryShutdownMetrics.cpp
index 11b89cd9..2dd07d1e 100644
--- a/health/LowBatteryShutdownMetrics.cpp
+++ b/health/LowBatteryShutdownMetrics.cpp
@@ -16,7 +16,6 @@
*/
#include <android/frameworks/stats/1.0/IStats.h>
-#include <hardware/google/pixelstats/1.0/IPixelStats.h>
#include <pixelhealth/LowBatteryShutdownMetrics.h>
namespace hardware {
@@ -31,7 +30,6 @@ using android::base::ReadFileToString;
using android::base::SetProperty;
using android::frameworks::stats::V1_0::BatteryCausedShutdown;
using android::frameworks::stats::V1_0::IStats;
-using ::hardware::google::pixelstats::V1_0::IPixelStats;
LowBatteryShutdownMetrics::LowBatteryShutdownMetrics(const char *const voltage_avg,
const char *const persist_prop)
@@ -54,12 +52,6 @@ bool LowBatteryShutdownMetrics::uploadVoltageAvg(void) {
return false;
}
- sp<IPixelStats> client = IPixelStats::tryGetService();
- if (!client) {
- LOG(ERROR) << "Unable to connect to PixelStats service";
- return false;
- }
-
// Process and upload comma-delimited last voltage values
int32_t voltage_avg;
for (const auto &item : android::base::Split(prop_contents, ",")) {
@@ -68,7 +60,6 @@ bool LowBatteryShutdownMetrics::uploadVoltageAvg(void) {
continue;
}
LOG(INFO) << "Uploading voltage_avg: " << std::to_string(voltage_avg);
- client->reportBatteryCausedShutdown(voltage_avg);
BatteryCausedShutdown shutdown = {.voltageMicroV = voltage_avg};
stats_client->reportBatteryCausedShutdown(shutdown);
}
diff --git a/health/include/pixelhealth/BatteryMetricsLogger.h b/health/include/pixelhealth/BatteryMetricsLogger.h
index 2a92812a..bf1d8400 100644
--- a/health/include/pixelhealth/BatteryMetricsLogger.h
+++ b/health/include/pixelhealth/BatteryMetricsLogger.h
@@ -27,7 +27,6 @@
#include <string>
#include <android/frameworks/stats/1.0/IStats.h>
-#include <hardware/google/pixelstats/1.0/IPixelStats.h>
namespace hardware {
namespace google {
@@ -37,7 +36,6 @@ namespace health {
using android::sp;
using android::frameworks::stats::V1_0::BatteryHealthSnapshotArgs;
using android::frameworks::stats::V1_0::IStats;
-using ::hardware::google::pixelstats::V1_0::IPixelStats;
class BatteryMetricsLogger {
public:
@@ -57,24 +55,14 @@ class BatteryMetricsLogger {
NUM_FIELDS, // do not reference
};
- const int kSnapshotType[NUM_FIELDS] = {
- -1,
- (int)IPixelStats::BatterySnapshotType::MIN_CURRENT,
- (int)IPixelStats::BatterySnapshotType::MIN_VOLTAGE,
- (int)IPixelStats::BatterySnapshotType::MIN_TEMP,
- (int)IPixelStats::BatterySnapshotType::MIN_BATT_LEVEL,
- (int)IPixelStats::BatterySnapshotType::MIN_RESISTANCE,
- -1,
- };
-
const int kStatsSnapshotType[NUM_FIELDS] = {
- -1,
- (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_CURRENT,
- (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_VOLTAGE,
- (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_TEMP,
- (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_BATT_LEVEL,
- (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_RESISTANCE,
- -1,
+ -1,
+ (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_CURRENT,
+ (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_VOLTAGE,
+ (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_TEMP,
+ (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_BATT_LEVEL,
+ (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_RESISTANCE,
+ -1,
};
const char *const kBatteryResistance;
@@ -99,7 +87,7 @@ class BatteryMetricsLogger {
int64_t getTime();
bool recordSample(struct android::BatteryProperties *props);
bool uploadMetrics();
- bool uploadOutlierMetric(sp<IPixelStats> client, sp<IStats> stats_client, sampleType type);
+ bool uploadOutlierMetric(sp<IStats> stats_client, sampleType type);
};
} // namespace health
diff --git a/health/include/pixelhealth/LowBatteryShutdownMetrics.h b/health/include/pixelhealth/LowBatteryShutdownMetrics.h
index 7dc3ee6c..b49d5aed 100644
--- a/health/include/pixelhealth/LowBatteryShutdownMetrics.h
+++ b/health/include/pixelhealth/LowBatteryShutdownMetrics.h
@@ -35,8 +35,8 @@ namespace health {
class LowBatteryShutdownMetrics {
public:
LowBatteryShutdownMetrics(
- const char *const voltage_avg,
- const char *const persist_prop = "persist.vendor.shutdown.voltage_avg");
+ const char *const voltage_avg,
+ const char *const persist_prop = "persist.vendor.shutdown.voltage_avg");
void logShutdownVoltage(struct android::BatteryProperties *props);
private: