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

Commit 5b0c25fc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "MediaLibrarySession: Add notifySearchResultChanged"

parents eaf29912 546a99d2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ oneway interface IMediaSession2Callback {
    void onItemLoaded(String mediaId, in Bundle result);
    void onChildrenLoaded(String parentId, int page, int pageSize, in Bundle extras,
            in List<Bundle> result);
    void onSearchResultChanged(String query, in Bundle extras, int itemCount);
    void onSearchResultLoaded(String query, int page, int pageSize, in Bundle extras,
            in List<Bundle> result);
}
+6 −1
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.content.Context;
import android.media.MediaBrowser2;
import android.media.MediaBrowser2.BrowserCallback;
import android.media.MediaItem2;
import android.media.MediaSession2.CommandButton;
import android.media.SessionToken2;
import android.media.update.MediaBrowser2Provider;
import android.os.Bundle;
@@ -177,6 +176,12 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow
        });
    }

    public void onSearchResultChanged(String query, Bundle extras, int itemCount) {
        getCallbackExecutor().execute(() -> {
            mCallback.onSearchResultChanged(query, extras, itemCount);
        });
    }

    public void onSearchResultLoaded(String query, int page, int pageSize, Bundle extras,
            List<MediaItem2> result) {
        getCallbackExecutor().execute(() -> {
+16 −3
Original line number Diff line number Diff line
@@ -26,12 +26,12 @@ import android.media.MediaLibraryService2.MediaLibrarySessionCallback;
import android.media.MediaPlayerInterface;
import android.media.MediaSession2;
import android.media.MediaSession2.ControllerInfo;
import android.media.MediaSession2.SessionCallback;
import android.media.MediaSessionService2;
import android.media.SessionToken2;
import android.media.VolumeProvider2;
import android.media.update.MediaLibraryService2Provider;
import android.os.Bundle;
import android.text.TextUtils;

import com.android.media.MediaSession2Impl.BuilderBaseImpl;

@@ -96,14 +96,27 @@ public class MediaLibraryService2Impl extends MediaSessionService2Impl implement

        @Override
        public void notifyChildrenChanged_impl(ControllerInfo controller, String parentId,
                Bundle options) {
                Bundle extras) {
            // TODO(jaewan): Implements
        }

        @Override
        public void notifyChildrenChanged_impl(String parentId, Bundle options) {
        public void notifyChildrenChanged_impl(String parentId, Bundle extras) {
            // TODO(jaewan): Implements
        }

        @Override
        public void notifySearchResultChanged_impl(ControllerInfo controller, String query,
                Bundle extras, int itemCount) {
            ensureCallingThread();
            if (controller == null) {
                throw new IllegalArgumentException("controller shouldn't be null");
            }
            if (TextUtils.isEmpty(query)) {
                throw new IllegalArgumentException("query shouldn't be empty");
            }
            getSessionStub().notifySearchResultChanged(controller, query, extras, itemCount);
        }
    }

    public static class BuilderImpl
+17 −0
Original line number Diff line number Diff line
@@ -268,6 +268,23 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub {
        browser.onChildrenLoaded(parentId, page, pageSize, extras, result);
    }

    @Override
    public void onSearchResultChanged(String query, Bundle extras, int itemCount)
            throws RuntimeException {
        final MediaBrowser2Impl browser;
        try {
            browser = getBrowser();
        } catch (IllegalStateException e) {
            Log.w(TAG, "Don't fail silently here. Highly likely a bug");
            return;
        }
        if (browser == null) {
            // TODO(jaewan): Revisit here. Could be a bug
            return;
        }
        browser.onSearchResultChanged(query, extras, itemCount);
    }

    @Override
    public void onSearchResultLoaded(String query, int page, int pageSize, Bundle extras,
            List<Bundle> itemBundleList) throws RuntimeException {
+5 −1
Original line number Diff line number Diff line
@@ -580,7 +580,7 @@ public class MediaSession2Impl implements MediaSession2Provider {
    //               1. Allow calls from random threads for all methods.
    //               2. Allow calls from random threads for all methods, except for the
    //                  {@link #setPlayer()}.
    private void ensureCallingThread() {
    void ensureCallingThread() {
        // TODO(jaewan): Uncomment or remove
        /*
        if (mHandler.getLooper() != Looper.myLooper()) {
@@ -621,6 +621,10 @@ public class MediaSession2Impl implements MediaSession2Provider {
        return mCallback;
    }

    MediaSession2Stub getSessionStub() {
        return mSessionStub;
    }

    VolumeProvider2 getVolumeProvider() {
        return mVolumeProvider;
    }
Loading