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

Commit 8afdc1c6 authored by wei.jing's avatar wei.jing Committed by David Zhao
Browse files

Fix 'ConcurrentModificationException' issue

[Description]
solution for adding read and write protection to ‘mPendingAppPrivateCommands’.

[Test Report]
AC on/off PASS
can bootup to TvLauncher PASS
LiveTV open PASS
VTS/CTS cmd: NA
(cherry picked from https://partner-android-review.googlesource.com/q/commit:bc3a33fd8317bc43997721e51c18ce85543d6441)
Bug: 302245330
Merged-In: Ic80466518ca35c16dde74dbbaada92f28eaaf6ef
Change-Id: Ic80466518ca35c16dde74dbbaada92f28eaaf6ef
parent 5fcf035c
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -401,7 +401,9 @@ public class TvView extends ViewGroup {

    private void resetInternal() {
        mSessionCallback = null;
        synchronized (mPendingAppPrivateCommands) {
            mPendingAppPrivateCommands.clear();
        }
        if (mSession != null) {
            setSessionSurface(null);
            removeSessionOverlayView();
@@ -691,9 +693,12 @@ public class TvView extends ViewGroup {
        } else {
            Log.w(TAG, "sendAppPrivateCommand - session not yet created (action \"" + action
                    + "\" pending)");

            synchronized (mPendingAppPrivateCommands) {
                mPendingAppPrivateCommands.add(Pair.create(action, data));
            }
        }
    }

    /**
     * Dispatches an unhandled input event to the next receiver.
@@ -1320,10 +1325,13 @@ public class TvView extends ViewGroup {
            mSession = session;
            if (session != null) {
                // Sends the pending app private commands first.

                synchronized (mPendingAppPrivateCommands) {
                    for (Pair<String, Bundle> command : mPendingAppPrivateCommands) {
                        mSession.sendAppPrivateCommand(command.first, command.second);
                    }
                    mPendingAppPrivateCommands.clear();
                }

                synchronized (sMainTvViewLock) {
                    if (hasWindowFocus() && TvView.this == sMainTvView.get()