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 f1a6e001fd
commit 8f699a3dd2

View File

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