[TIAF] Add null checks to avoid NPEs

Bug: 278628657
Test: atest TvInputServiceTest
Change-Id: Ieae1481781b58b23a3449961fcaa0b51d02d8d0a
This commit is contained in:
shubang
2023-05-16 14:58:03 -07:00
parent 75faf08349
commit a15deadbd5
2 changed files with 8 additions and 0 deletions

View File

@@ -269,6 +269,10 @@ class TvInputHardwareManager implements TvInputHal.Callback {
@Override
public void onTvMessage(int deviceId, int type, Bundle data) {
synchronized (mLock) {
String inputId = mHardwareInputIdMap.get(deviceId);
if (inputId == null) {
return;
}
SomeArgs args = SomeArgs.obtain();
args.arg1 = mHardwareInputIdMap.get(deviceId);
args.arg2 = data;

View File

@@ -4152,6 +4152,10 @@ public final class TvInputManagerService extends SystemService {
synchronized (mLock) {
UserState userState = getOrCreateUserStateLocked(mCurrentUserId);
TvInputState inputState = userState.inputMap.get(inputId);
if (inputState == null) {
Slog.e(TAG, "failed to send TV message - unknown input id " + inputId);
return;
}
ServiceState serviceState = userState.serviceStateMap.get(inputState.info
.getComponent());
for (IBinder token : serviceState.sessionTokens) {