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

Commit 2472c30d authored by Wei Jia's avatar Wei Jia
Browse files

MediaPlayer2: keep EventCallbacks when reset

Test: cts
Bug: 112549021
Change-Id: I1eb4f47bf1c289a35a45e1017a28d7bd4ab8c5e8
parent ce3083dc
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -436,13 +436,6 @@ public class MediaPlayer2 implements AutoCloseable
     */
    // This is a synchronous call.
    public void reset() {
        synchronized (mEventCbLock) {
            mEventCallbackRecords.clear();
        }
        synchronized (mDrmEventCbLock) {
            mDrmEventCallbackRecords.clear();
        }

        clearSourceInfos();

        stayAwake(false);
@@ -2758,6 +2751,12 @@ public class MediaPlayer2 implements AutoCloseable
                    "Illegal null Executor for the EventCallback");
        }
        synchronized (mEventCbLock) {
            for (Pair<Executor, EventCallback> cb : mEventCallbackRecords) {
                if (cb.first == executor && cb.second == eventCallback) {
                    Log.w(TAG, "The callback has been registered before.");
                    return;
                }
            }
            mEventCallbackRecords.add(new Pair(executor, eventCallback));
        }
    }