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

Commit 36dd7b1d authored by Simon MacMullen's avatar Simon MacMullen
Browse files

Log plug type and battery status along with current and charge.

Bug: 173496998
Test: Traced with Perfetto, counters show up in trace.
Change-Id: I2719f9cd51e7043dc2117aa6cba964f64178efe2
parent 06f75983
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -437,6 +437,10 @@ public final class BatteryService extends SystemService {
                info.legacy.legacy.batteryChargeCounter);
        Trace.traceCounter(Trace.TRACE_TAG_POWER, "BatteryCurrent",
                info.legacy.legacy.batteryCurrent);
        Trace.traceCounter(Trace.TRACE_TAG_POWER, "PlugType",
                plugType(info.legacy.legacy));
        Trace.traceCounter(Trace.TRACE_TAG_POWER, "BatteryStatus",
                info.legacy.legacy.batteryStatus);

        synchronized (mLock) {
            if (!mUpdatesStopped) {
@@ -471,6 +475,18 @@ public final class BatteryService extends SystemService {
        dst.batteryTechnology = src.batteryTechnology;
    }

    private static int plugType(HealthInfo healthInfo) {
        if (healthInfo.chargerAcOnline) {
            return BatteryManager.BATTERY_PLUGGED_AC;
        } else if (healthInfo.chargerUsbOnline) {
            return BatteryManager.BATTERY_PLUGGED_USB;
        } else if (healthInfo.chargerWirelessOnline) {
            return BatteryManager.BATTERY_PLUGGED_WIRELESS;
        } else {
            return BATTERY_PLUGGED_NONE;
        }
    }

    private void processValuesLocked(boolean force) {
        boolean logOutlier = false;
        long dischargeDuration = 0;
@@ -478,15 +494,7 @@ public final class BatteryService extends SystemService {
        mBatteryLevelCritical =
            mHealthInfo.batteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN
            && mHealthInfo.batteryLevel <= mCriticalBatteryLevel;
        if (mHealthInfo.chargerAcOnline) {
            mPlugType = BatteryManager.BATTERY_PLUGGED_AC;
        } else if (mHealthInfo.chargerUsbOnline) {
            mPlugType = BatteryManager.BATTERY_PLUGGED_USB;
        } else if (mHealthInfo.chargerWirelessOnline) {
            mPlugType = BatteryManager.BATTERY_PLUGGED_WIRELESS;
        } else {
            mPlugType = BATTERY_PLUGGED_NONE;
        }
        mPlugType = plugType(mHealthInfo);

        if (DEBUG) {
            Slog.d(TAG, "Processing new values: "