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

Commit 80cec8a9 authored by Ji-Hwan Lee's avatar Ji-Hwan Lee Committed by Android Git Automerger
Browse files

am fe199929: Merge "TIF: Handle null main session" into lmp-dev

* commit 'fe199929d28aae569ec215b152e86f0d34214c43':
  TIF: Handle null main session
parents 4bf2b1f9 89a4f5d7
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -657,8 +657,12 @@ public final class TvInputManagerService extends SystemService {
    }

    private void removeSessionStateLocked(IBinder sessionToken, int userId) {
        // Remove the session state from the global session state map of the current user.
        UserState userState = getUserStateLocked(userId);
        if (sessionToken == userState.mainSessionToken) {
            userState.mainSessionToken = null;
        }

        // Remove the session state from the global session state map of the current user.
        SessionState sessionState = userState.sessionStateMap.remove(sessionToken);

        // Close the open log entry, if any.
@@ -936,18 +940,22 @@ public final class TvInputManagerService extends SystemService {
                        return;
                    }

                    SessionState prevMainSessionState = getSessionStateLocked(
                            userState.mainSessionToken, Process.SYSTEM_UID, resolvedUserId);
                    ServiceState prevMainServiceState = getServiceStateLocked(
                            prevMainSessionState.mInfo.getComponent(), resolvedUserId);
                    ITvInputSession prevMainSession = getSessionLocked(prevMainSessionState);

                    SessionState sessionState = getSessionStateLocked(sessionToken, callingUid,
                            resolvedUserId);
                    ServiceState serviceState = getServiceStateLocked(
                            sessionState.mInfo.getComponent(), resolvedUserId);
                    ITvInputSession session = getSessionLocked(sessionState);

                    ServiceState prevMainServiceState = null;
                    ITvInputSession prevMainSession = null;
                    if (userState.mainSessionToken != null) {
                        SessionState prevMainSessionState = getSessionStateLocked(
                                userState.mainSessionToken, Process.SYSTEM_UID, resolvedUserId);
                        prevMainServiceState = getServiceStateLocked(
                                prevMainSessionState.mInfo.getComponent(), resolvedUserId);
                        prevMainSession = getSessionLocked(prevMainSessionState);
                    }

                    userState.mainSessionToken = sessionToken;

                    // Inform the new main session first. See {@link TvInputService#onSetMain}.
@@ -958,7 +966,7 @@ public final class TvInputManagerService extends SystemService {
                            Slog.e(TAG, "error in setMainSession", e);
                        }
                    }
                    if (prevMainServiceState.mIsHardware) {
                    if (prevMainSession != null && prevMainServiceState.mIsHardware) {
                        try {
                            prevMainSession.setMainSession(false);
                        } catch (RemoteException e) {