HealthServiceWrapperAidl fix NPE

It is possible that mRegCallback is null. Handle
the case when it is accessed without null check.

The mRegCallback is null because StatsPullAtomService
initializes HealthServiceWrapper with null callback.

Test: TH
Bug: 232899396
Change-Id: I45c4ebca8c5612fdfbab8ffd28b9c2799d74869a
Signed-off-by: Yifan Hong <elsk@google.com>
Merged-In: I45c4ebca8c5612fdfbab8ffd28b9c2799d74869a
This commit is contained in:
Yifan Hong
2022-06-03 11:03:25 -07:00
parent 1c51fb46b1
commit 30f2c7820c

View File

@@ -208,7 +208,9 @@ class HealthServiceWrapperAidl extends HealthServiceWrapper {
if (Objects.equals(newBinder, oldBinder)) return; if (Objects.equals(newBinder, oldBinder)) return;
Slog.i(TAG, "New health AIDL HAL service registered"); Slog.i(TAG, "New health AIDL HAL service registered");
if (mRegCallback != null) {
mRegCallback.onRegistration(oldService, newService); mRegCallback.onRegistration(oldService, newService);
}
}); });
} }
} }