Merge "Fix an NPE in BatteryService" into sc-dev

This commit is contained in:
Jeffrey Huang
2021-03-12 19:59:33 +00:00
committed by Android (Google) Code Review

View File

@@ -1595,6 +1595,8 @@ public final class BatteryService extends SystemService {
if (Objects.equals(newService, oldService)) return;
Slog.i(TAG, "health: new instance registered " + mInstanceName);
// #init() may be called with null callback. Skip null callbacks.
if (mCallback == null) return;
mCallback.onRegistration(oldService, newService, mInstanceName);
} catch (NoSuchElementException | RemoteException ex) {
Slog.e(TAG, "health: Cannot get instance '" + mInstanceName