From a6969212604257c752f90e79ade3d051a00dd1ac Mon Sep 17 00:00:00 2001 From: Maggie White Date: Mon, 1 Apr 2019 20:34:45 -0700 Subject: health: pixelstats: Remove references to IPixelStats Bug: 122904980 Change-Id: I3be3928c214de7cf788111cabb4ceda5806e9c6d Signed-off-by: Maggie White Merged-In: 7b2dc962f0154bceb81d18f9a8bec2e05cbe911e --- health/Android.bp | 1 - health/BatteryMetricsLogger.cpp | 94 +++++++--------------- health/LowBatteryShutdownMetrics.cpp | 9 --- health/include/pixelhealth/BatteryMetricsLogger.h | 28 ++----- .../pixelhealth/LowBatteryShutdownMetrics.h | 4 +- 5 files changed, 37 insertions(+), 99 deletions(-) (limited to 'health') 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 client, sp stats_client, - sampleType type) { - IPixelStats::BatteryHealthSnapshotArgs min_ss = { - .type = static_cast(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(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 stats_client, sampleType type) { BatteryHealthSnapshotArgs min_stats_ss = { - .type = static_cast(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(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(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(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 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(metric)); + uploadOutlierMetric(stats_client, static_cast(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 -#include #include 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 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 #include -#include 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 client, sp stats_client, sampleType type); + bool uploadOutlierMetric(sp 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: -- cgit v1.2.3