Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa7fab94 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "statsd: Add BatteryCycleCount atom"

parents b17eb4a7 8735b859
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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
+19 −13
Original line number Diff line number Diff line
@@ -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;
@@ -86,17 +86,23 @@ bool ResourceHealthManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* dat
            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);
            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);
        }
+4 −1
Original line number Diff line number Diff line
@@ -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},