Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e771e66 authored by Nick Chalko's avatar Nick Chalko
Browse files

Fix possible NPE in tune

Test: atest CtsTvTestCases
Change-Id: I7eb2d57303f1a6026e8b713ee84a2ee97b610b24
parent 8b93b3d6
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -549,6 +549,11 @@ public final class TvInputManagerService extends SystemService {

    private SessionState getSessionStateLocked(IBinder sessionToken, int callingUid, int userId) {
        UserState userState = getOrCreateUserStateLocked(userId);
        return getSessionStateLocked(sessionToken, callingUid, userState);
    }

    private SessionState getSessionStateLocked(IBinder sessionToken,
            int callingUid, UserState userState) {
        SessionState sessionState = userState.sessionStateMap.get(sessionToken);
        if (sessionState == null) {
            throw new SessionNotFoundException("Session state not found for token " + sessionToken);
@@ -1436,12 +1441,11 @@ public final class TvInputManagerService extends SystemService {
                        getSessionLocked(sessionToken, callingUid, resolvedUserId).tune(
                                channelUri, params);
                        UserState userState = getOrCreateUserStateLocked(resolvedUserId);
                        SessionState sessionState = userState.sessionStateMap.get(sessionToken);
                        if (sessionState != null) {
                        SessionState sessionState = getSessionStateLocked(sessionToken, callingUid,
                                userState);
                        sessionState.isCurrent = true;
                        sessionState.currentChannel = channelUri;
                        notifyCurrentChannelInfosUpdatedLocked(userState);
                        }
                        if (TvContract.isChannelUriForPassthroughInput(channelUri)) {
                            // Do not log the watch history for passthrough inputs.
                            return;