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

Commit e51ae85f authored by Alessio Balsini's avatar Alessio Balsini
Browse files

Implement getBatteryHealthData in HealthServiceWrapper



Extend the HealthServiceWrapper with the new getBatteryHealthData API,
introduced in the AIDL Health HAL v3.

Flag: EXEMPT statsd atoms/metrics changes
Bug: 343691107
Test: statsd_testdrive 10220
Change-Id: I2f4a7c420f97314089c202297f3a2e07c0272bf7
Signed-off-by: default avatarAlessio Balsini <balsini@google.com>
parent 999a6a71
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -70,6 +70,21 @@ public abstract class HealthServiceWrapper {
     */
    public abstract android.hardware.health.HealthInfo getHealthInfo() throws RemoteException;

    /**
     * Calls into getBatteryHealthData() in the health HAL.
     * This function does not have a corresponding HIDL implementation, so
     * returns null by default, unless there is an AIDL class that overrides
     * this one.
     *
     * @return battery health data. {@code null} if no health HAL service.
     *     {@code null} if any service-specific error when calling {@code
     *     getBatteryHealthData}, e.g. it is unsupported.
     * @throws RemoteException for any transaction-level errors
     */
    public android.hardware.health.BatteryHealthData getBatteryHealthData() throws RemoteException {
        return null;
    }

    /**
     * Create a new HealthServiceWrapper instance.
     *
+11 −0
Original line number Diff line number Diff line
@@ -212,6 +212,17 @@ class HealthServiceWrapperAidl extends HealthServiceWrapper {
        }
    }

    @Override
    public BatteryHealthData getBatteryHealthData() throws RemoteException {
        IHealth service = mLastService.get();
        if (service == null) return null;
        try {
            return service.getBatteryHealthData();
        } catch (UnsupportedOperationException | ServiceSpecificException ex) {
            return null;
        }
    }

    public void setChargingPolicy(int policy) throws RemoteException {
        IHealth service = mLastService.get();
        if (service == null) return;