Merge "BatteryService: scheduleUpdate asynchronously"

This commit is contained in:
Yifan Hong
2019-08-19 20:14:15 +00:00
committed by Gerrit Code Review

View File

@@ -1227,14 +1227,21 @@ public final class BatteryService extends SystemService {
} }
@Override @Override
public void scheduleUpdate() throws RemoteException { public void scheduleUpdate() throws RemoteException {
mHealthServiceWrapper.getHandlerThread().getThreadHandler().post(() -> {
traceBegin("HealthScheduleUpdate"); traceBegin("HealthScheduleUpdate");
try { try {
IHealth service = mHealthServiceWrapper.getLastService(); IHealth service = mHealthServiceWrapper.getLastService();
if (service == null) throw new RemoteException("no health service"); if (service == null) {
Slog.e(TAG, "no health service");
return;
}
service.update(); service.update();
} catch (RemoteException ex) {
Slog.e(TAG, "Cannot call update on health HAL", ex);
} finally { } finally {
traceEnd(); traceEnd();
} }
});
} }
} }
@@ -1311,7 +1318,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;