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

Commit 24d32f5a authored by an.xi's avatar an.xi Committed by jie.yuan
Browse files

SystemServer: fix an infinite loop in TvInputManagerService [1/1]



PD#SWPL-6385
Bug:174639896

Problem:
There could be an infinite loop when TvInputManagerService processes
a DeathRecipient's callback and fails to remove its session

Solution:
Do the clear work to make sure the related session is removed finally

Verify:
verify it on Marconi

Change-Id: I9bd79fbc49b8283691870f1e745b324d1322b292
Signed-off-by: default avataran.xi <an.xi@amlogic.com>
parent 00995781
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -714,6 +714,7 @@ public final class TvInputManagerService extends SystemService {
        SessionState sessionState = userState.sessionStateMap.remove(sessionToken);

        if (sessionState == null) {
            Slog.e(TAG, "sessionState null, no more remove session action!");
            return;
        }

@@ -2278,8 +2279,16 @@ public final class TvInputManagerService extends SystemService {
                ClientState clientState = userState.clientStateMap.get(clientToken);
                if (clientState != null) {
                    while (clientState.sessionTokens.size() > 0) {
                        IBinder sessionToken = clientState.sessionTokens.get(0);
                        releaseSessionLocked(
                                clientState.sessionTokens.get(0), Process.SYSTEM_UID, userId);
                                sessionToken, Process.SYSTEM_UID, userId);
                        // the releaseSessionLocked function may return before the sessionToken
                        // is removed if the related sessionState is null. So need to check again
                        // to avoid death curculation.
                        if (clientState.sessionTokens.contains(sessionToken)) {
                            Slog.d(TAG, "remove sessionToken " + sessionToken + " for " + clientToken);
                            clientState.sessionTokens.remove(sessionToken);
                        }
                    }
                }
                clientToken = null;