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

Commit dbcb603d authored by Yeabkal Wubshit's avatar Yeabkal Wubshit
Browse files

ADB command support for Current values

Bug: 315037695
Test: adb shell dumpsys battery get current_now
Test: adb shell dumpsys battery get current_average
Change-Id: I625fe726afddbb917bd853c79896493cab501eeb
parent 6aa30d3e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -76,3 +76,11 @@ flag {
    description: "Guards the ADPF GPU APIs."
    bug: "284324521"
}

flag {
    name: "battery_service_support_current_adb_command"
    namespace: "backstage_power"
    description: "Whether or not BatteryService supports adb commands for Current values."
    is_fixed_read_only: true
    bug: "315037695"
}
+27 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server;

import static android.os.Flags.stateOfHealthPublic;
import static android.os.Flags.batteryServiceSupportCurrentAdbCommand;

import static com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import static com.android.server.health.Utils.copyV1Battery;
@@ -927,9 +928,12 @@ public final class BatteryService extends SystemService {
        pw.println("Battery service (battery) commands:");
        pw.println("  help");
        pw.println("    Print this help text.");
        pw.println("  get [-f] [ac|usb|wireless|dock|status|level|temp|present|counter|invalid]");
        pw.println("  set [-f] "
                + "[ac|usb|wireless|dock|status|level|temp|present|counter|invalid] <value>");
        String getSetOptions = "ac|usb|wireless|dock|status|level|temp|present|counter|invalid";
        if (batteryServiceSupportCurrentAdbCommand()) {
            getSetOptions += "|current_now|current_average";
        }
        pw.println("  get [-f] [" + getSetOptions + "]");
        pw.println("  set [-f] [" + getSetOptions + "] <value>");
        pw.println("    Force a battery property value, freezing battery state.");
        pw.println("    -f: force a battery change broadcast be sent, prints new sequence.");
        pw.println("  unplug [-f]");
@@ -1001,6 +1005,16 @@ public final class BatteryService extends SystemService {
                    case "counter":
                        pw.println(mHealthInfo.batteryChargeCounterUah);
                        break;
                    case "current_now":
                        if (batteryServiceSupportCurrentAdbCommand()) {
                            pw.println(mHealthInfo.batteryCurrentMicroamps);
                        }
                        break;
                    case "current_average":
                        if (batteryServiceSupportCurrentAdbCommand()) {
                            pw.println(mHealthInfo.batteryCurrentAverageMicroamps);
                        }
                        break;
                    case "temp":
                        pw.println(mHealthInfo.batteryTemperatureTenthsCelsius);
                        break;
@@ -1058,6 +1072,16 @@ public final class BatteryService extends SystemService {
                        case "counter":
                            mHealthInfo.batteryChargeCounterUah = Integer.parseInt(value);
                            break;
                        case "current_now":
                            if (batteryServiceSupportCurrentAdbCommand()) {
                                mHealthInfo.batteryCurrentMicroamps = Integer.parseInt(value);
                            }
                            break;
                        case "current_average":
                            if (batteryServiceSupportCurrentAdbCommand()) {
                                mHealthInfo.batteryCurrentAverageMicroamps =
                                        Integer.parseInt(value);
                            }
                        case "temp":
                            mHealthInfo.batteryTemperatureTenthsCelsius = Integer.parseInt(value);
                            break;