Merge "BatteryService: scheduleUpdate asynchronously" am: 238a04ef59 am: 8eec5d9ee4

am: ba28a3a57e

Change-Id: I7f2840e00f6236ec1dd31e88140c9c55cfe2f072
This commit is contained in:
Yifan Hong
2019-08-19 14:21:10 -07:00
committed by android-build-merger

View File

@@ -1235,14 +1235,21 @@ public final class BatteryService extends SystemService {
} }
@Override @Override
public void scheduleUpdate() throws RemoteException { public void scheduleUpdate() throws RemoteException {
traceBegin("HealthScheduleUpdate"); mHealthServiceWrapper.getHandlerThread().getThreadHandler().post(() -> {
try { traceBegin("HealthScheduleUpdate");
IHealth service = mHealthServiceWrapper.getLastService(); try {
if (service == null) throw new RemoteException("no health service"); IHealth service = mHealthServiceWrapper.getLastService();
service.update(); if (service == null) {
} finally { Slog.e(TAG, "no health service");
traceEnd(); return;
} }
service.update();
} catch (RemoteException ex) {
Slog.e(TAG, "Cannot call update on health HAL", ex);
} finally {
traceEnd();
}
});
} }
} }
@@ -1319,7 +1326,7 @@ public final class BatteryService extends SystemService {
Arrays.asList(INSTANCE_VENDOR, INSTANCE_HEALTHD); Arrays.asList(INSTANCE_VENDOR, INSTANCE_HEALTHD);
private final IServiceNotification mNotification = new Notification(); private final IServiceNotification mNotification = new Notification();
private final HandlerThread mHandlerThread = new HandlerThread("HealthServiceRefresh"); private final HandlerThread mHandlerThread = new HandlerThread("HealthServiceHwbinder");
// These variables are fixed after init. // These variables are fixed after init.
private Callback mCallback; private Callback mCallback;
private IHealthSupplier mHealthSupplier; private IHealthSupplier mHealthSupplier;