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

Commit b921e031 authored by Hyundo Moon's avatar Hyundo Moon
Browse files

Add MediaController.getHandlerForCallback() for testing

Bug: 173571399
Test: Passed CTS
Change-Id: If8780f4fb5177259061e546ce65684a670781c60
parent a33f9405
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -46,6 +46,8 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.Log;
import android.view.KeyEvent;
import android.view.KeyEvent;


import com.android.internal.annotations.VisibleForTesting;

import java.lang.annotation.Retention;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import java.lang.ref.WeakReference;
@@ -437,7 +439,7 @@ public final class MediaController {
        }
        }


        if (mSessionInfo == null) {
        if (mSessionInfo == null) {
            Log.w(TAG, "sessionInfo shouldn't be null.");
            Log.d(TAG, "sessionInfo is not set.");
            mSessionInfo = Bundle.EMPTY;
            mSessionInfo = Bundle.EMPTY;
        } else if (MediaSession.hasCustomParcelable(mSessionInfo)) {
        } else if (MediaSession.hasCustomParcelable(mSessionInfo)) {
            Log.w(TAG, "sessionInfo contains custom parcelable. Ignoring.");
            Log.w(TAG, "sessionInfo contains custom parcelable. Ignoring.");
@@ -514,6 +516,17 @@ public final class MediaController {
        return success;
        return success;
    }
    }


    /**
     * Gets associated handler for the given callback.
     * @hide
     */
    @VisibleForTesting
    public Handler getHandlerForCallback(Callback cb) {
        synchronized (mLock) {
            return getHandlerForCallbackLocked(cb);
        }
    }

    private MessageHandler getHandlerForCallbackLocked(Callback cb) {
    private MessageHandler getHandlerForCallbackLocked(Callback cb) {
        if (cb == null) {
        if (cb == null) {
            throw new IllegalArgumentException("Callback cannot be null");
            throw new IllegalArgumentException("Callback cannot be null");