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

Commit 17f0d8a8 authored by Bookatz's avatar Bookatz
Browse files

Statsd atoms: BatteryVoltage

Add battery voltage to statsd as a pulled atom.

Bug: 114451845
Test: run cts-dev -m CtsStatsdHostTestCases -t android.cts.statsd.atom.HostAtomTests#testBatteryVoltage

Change-Id: If40ed41663b57ad6144c69c52c4c63562f93c774
parent 456e4f5b
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ message Atom {
        AppSize app_size = 10027;
        CategorySize category_size = 10028;
        android.service.procstats.ProcessStatsSectionProto proc_stats = 10029;
        BatteryVoltage battery_voltage = 10030;
    }

    // DO NOT USE field numbers above 100,000 in AOSP. Field numbers above
@@ -2154,6 +2155,16 @@ message FullBatteryCapacity {
    optional int32 capacity_uAh = 1;
}

/**
 * Pulls battery voltage.
 * Pulled from:
 *   frameworks/base/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp
 */
message BatteryVoltage {
    // The voltage of the battery, in millivolts.
    optional int32 voltage_mV = 1;
}

/**
 * Pulls the temperature of various parts of the device.
 * The units are tenths of a degree Celsius. Eg: 30.3C is reported as 303.
+7 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ bool ResourceHealthManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* dat
    data->clear();
    bool result_success = true;

    // Get the data from the Health HAL (hardware/interfaces/health/1.0/types.hal).
    Return<void> ret = gHealthHal->getHealthInfo([&](Result r, HealthInfo v) {
        if (r != Result::SUCCESS) {
            result_success = false;
@@ -84,6 +85,12 @@ bool ResourceHealthManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* dat
            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);
            ptr->write(v.legacy.batteryVoltage);
            ptr->init();
            data->push_back(ptr);
        } else {
            ALOGE("Unsupported tag in ResourceHealthManagerPuller: %d", mTagId);
        }
+6 −0
Original line number Diff line number Diff line
@@ -161,6 +161,12 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
          {},
          1 * NS_PER_SEC,
          new ResourceHealthManagerPuller(android::util::FULL_BATTERY_CAPACITY)}},
        // battery_voltage
        {android::util::BATTERY_VOLTAGE,
         {{},
          {},
          1 * NS_PER_SEC,
          new ResourceHealthManagerPuller(android::util::BATTERY_VOLTAGE)}},
        // process_memory_state
        {android::util::PROCESS_MEMORY_STATE,
         {{4, 5, 6, 7, 8},