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

Commit 8b3f4d83 authored by Shubang Lu's avatar Shubang Lu
Browse files

[TIF CTS] logExternalInputEvent only when release sessions of current input

This can also fix an NPE cause by null mCurrentInputId

Bug: 294054428
Test: CTS
Change-Id: Ib49d594a0fbb8f0a248664717621c5350d086817
parent 539ed414
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -890,10 +890,13 @@ public final class TvInputManagerService extends SystemService {
                sessionState.session = null;
                sessionState.session = null;
            }
            }
        }
        }
        if (mCurrentSessionState == sessionState) {
            // only log when releasing the current on-screen session
            logExternalInputEvent(FrameworkStatsLog.EXTERNAL_TV_INPUT_EVENT__EVENT_TYPE__RELEASED,
            logExternalInputEvent(FrameworkStatsLog.EXTERNAL_TV_INPUT_EVENT__EVENT_TYPE__RELEASED,
                    mCurrentInputId, sessionState);
                    mCurrentInputId, sessionState);
            mCurrentInputId = null;
            mCurrentInputId = null;
            mCurrentSessionState = null;
            mCurrentSessionState = null;
        }
        removeSessionStateLocked(sessionToken, userId);
        removeSessionStateLocked(sessionToken, userId);
        return sessionState;
        return sessionState;
    }
    }
@@ -3057,6 +3060,7 @@ public final class TvInputManagerService extends SystemService {
    }
    }


    private void logExternalInputEvent(int eventType, String inputId, SessionState sessionState) {
    private void logExternalInputEvent(int eventType, String inputId, SessionState sessionState) {
        // TODO: handle recording sessions
        UserState userState = getOrCreateUserStateLocked(sessionState.userId);
        UserState userState = getOrCreateUserStateLocked(sessionState.userId);
        TvInputState tvInputState = userState.inputMap.get(inputId);
        TvInputState tvInputState = userState.inputMap.get(inputId);
        TvInputInfo tvInputInfo = tvInputState.info;
        TvInputInfo tvInputInfo = tvInputState.info;