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

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

Throw IllegalStateException in MediaBrowser.search()

This CL makes MediaBrowser.search() throw IllegalStateException
when the browser is not connected to the service.

Bug: 35346000
Test: Flashed the image on angler and locally tested.
Change-Id: I8fda53e31555337107c4e42f388ff82a7929b084
parent d5386fd4
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -471,6 +471,7 @@ public final class MediaBrowser {
     * @param extras The bundle of service-specific arguments to send to the media browser
     *            service. The contents of this bundle may affect the search result.
     * @param callback The callback to receive the search result.
     * @throws IllegalStateException if the browser is not connected to the media browser service.
     */
    public void search(@NonNull final String query, final Bundle extras, SearchCallback callback) {
        if (TextUtils.isEmpty(query)) {
@@ -480,14 +481,8 @@ public final class MediaBrowser {
            throw new IllegalArgumentException("callback cannot be null.");
        }
        if (mState != CONNECT_STATE_CONNECTED) {
            Log.i(TAG, "Not connected, unable to search.");
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    callback.onError(query, extras);
                }
            });
            return;
            throw new IllegalStateException("search() called while not connected (state="
                    + getStateLabel(mState) + ")");
        }
        ResultReceiver receiver = new ResultReceiver(mHandler) {
            @Override