Merge "Add MediaController.getHandlerForCallback() for testing"

This commit is contained in:
Hyundo Moon
2020-12-03 10:48:19 +00:00
committed by Android (Google) Code Review

View File

@@ -46,6 +46,8 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import com.android.internal.annotations.VisibleForTesting;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
@@ -437,7 +439,7 @@ public final class MediaController {
}
if (mSessionInfo == null) {
Log.w(TAG, "sessionInfo shouldn't be null.");
Log.d(TAG, "sessionInfo is not set.");
mSessionInfo = Bundle.EMPTY;
} else if (MediaSession.hasCustomParcelable(mSessionInfo)) {
Log.w(TAG, "sessionInfo contains custom parcelable. Ignoring.");
@@ -514,6 +516,17 @@ public final class MediaController {
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) {
if (cb == null) {
throw new IllegalArgumentException("Callback cannot be null");