diff options
author | 2019-01-22 17:56:55 +0000 | |
---|---|---|
committer | 2019-01-22 17:56:55 +0000 | |
commit | aa7fab948393bf689dedd4c1bf6e15cd67935ca7 (patch) | |
tree | 424a3bfa46dd2efa6a68937978d04e2c4908419d | |
parent | b17eb4a72c0139eca4f3883c0de4f7bf541fbd70 (diff) | |
parent | 8735b85958a5072cf5bd51bab8def92a1aeac772 (diff) |
Merge "statsd: Add BatteryCycleCount atom"
-rw-r--r-- | cmds/statsd/src/atoms.proto | 14 | ||||
-rw-r--r-- | cmds/statsd/src/external/ResourceHealthManagerPuller.cpp | 32 | ||||
-rw-r--r-- | cmds/statsd/src/external/StatsPullerManager.cpp | 5 |
3 files changed, 37 insertions, 14 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 79ef2cabc109..ab26d087b053 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -252,6 +252,7 @@ message Atom { ProcessMemoryHighWaterMark process_memory_high_water_mark = 10042; BatteryLevel battery_level = 10043; BuildInformation build_information = 10044; + BatteryCycleCount battery_cycle_count = 10045; } // DO NOT USE field numbers above 100,000 in AOSP. @@ -2522,6 +2523,19 @@ message UsbPortOverheatEvent { optional int32 time_to_inactive_secs = 5; }; +/** + * Logs total effective full charge and discharge cycles on a battery. + * Here are some examples of one effective cycle: + * 1) the battery charges from 0% to 100% and drains back to 0%, + * 2) charging from 50% to 100% and draining back to 50% twice. + * Pulled from: + * frameworks/base/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp + */ +message BatteryCycleCount { + /* Number of total charge and discharge cycles on the system battery. */ + optional int32 cycle_count = 1; +} + /* * Logs when a connection becomes available and lost. * Logged in StatsCompanionService.java diff --git a/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp b/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp index b878652f5cf1..75b63f4b5f9e 100644 --- a/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp +++ b/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp @@ -24,16 +24,16 @@ #include "ResourceHealthManagerPuller.h" #include "logd/LogEvent.h" -#include "statslog.h" #include "stats_log_util.h" +#include "statslog.h" using android::hardware::hidl_vec; +using android::hardware::Return; +using android::hardware::Void; using android::hardware::health::V2_0::get_health_service; using android::hardware::health::V2_0::HealthInfo; using android::hardware::health::V2_0::IHealth; using android::hardware::health::V2_0::Result; -using android::hardware::Return; -using android::hardware::Void; using std::make_shared; using std::shared_ptr; @@ -75,35 +75,41 @@ bool ResourceHealthManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* dat } if (mTagId == android::util::REMAINING_BATTERY_CAPACITY) { auto ptr = make_shared<LogEvent>(android::util::REMAINING_BATTERY_CAPACITY, - wallClockTimestampNs, elapsedTimestampNs); + wallClockTimestampNs, elapsedTimestampNs); ptr->write(v.legacy.batteryChargeCounter); ptr->init(); data->push_back(ptr); } else if (mTagId == android::util::FULL_BATTERY_CAPACITY) { auto ptr = make_shared<LogEvent>(android::util::FULL_BATTERY_CAPACITY, - wallClockTimestampNs, elapsedTimestampNs); + wallClockTimestampNs, elapsedTimestampNs); ptr->write(v.legacy.batteryFullCharge); ptr->init(); data->push_back(ptr); } else if (mTagId == android::util::BATTERY_VOLTAGE) { - auto ptr = make_shared<LogEvent>(android::util::BATTERY_VOLTAGE, - wallClockTimestampNs, elapsedTimestampNs); + auto ptr = make_shared<LogEvent>(android::util::BATTERY_VOLTAGE, wallClockTimestampNs, + elapsedTimestampNs); ptr->write(v.legacy.batteryVoltage); ptr->init(); data->push_back(ptr); } else if (mTagId == android::util::BATTERY_LEVEL) { - auto ptr = make_shared<LogEvent>(android::util::BATTERY_LEVEL, - wallClockTimestampNs, elapsedTimestampNs); - ptr->write(v.legacy.batteryLevel); - ptr->init(); - data->push_back(ptr); + auto ptr = make_shared<LogEvent>(android::util::BATTERY_LEVEL, wallClockTimestampNs, + elapsedTimestampNs); + ptr->write(v.legacy.batteryLevel); + ptr->init(); + data->push_back(ptr); + } else if (mTagId == android::util::BATTERY_CYCLE_COUNT) { + auto ptr = make_shared<LogEvent>(android::util::BATTERY_CYCLE_COUNT, + wallClockTimestampNs, elapsedTimestampNs); + ptr->write(v.legacy.batteryCycleCount); + ptr->init(); + data->push_back(ptr); } else { ALOGE("Unsupported tag in ResourceHealthManagerPuller: %d", mTagId); } }); if (!result_success || !ret.isOk()) { ALOGE("getHealthHal() failed: health HAL service not available. Description: %s", - ret.description().c_str()); + ret.description().c_str()); if (!ret.isOk() && ret.isDeadObject()) { gHealthHal = nullptr; } diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp index 4a716cf3fa77..19a7389cb3d9 100644 --- a/cmds/statsd/src/external/StatsPullerManager.cpp +++ b/cmds/statsd/src/external/StatsPullerManager.cpp @@ -131,9 +131,12 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = { // battery_voltage {android::util::BATTERY_VOLTAGE, {.puller = new ResourceHealthManagerPuller(android::util::BATTERY_VOLTAGE)}}, - // battery_voltage + // battery_level {android::util::BATTERY_LEVEL, {.puller = new ResourceHealthManagerPuller(android::util::BATTERY_LEVEL)}}, + // battery_cycle_count + {android::util::BATTERY_CYCLE_COUNT, + {.puller = new ResourceHealthManagerPuller(android::util::BATTERY_CYCLE_COUNT)}}, // process_memory_state {android::util::PROCESS_MEMORY_STATE, {.additiveFields = {4, 5, 6, 7, 8, 9}, |