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

Commit 9f303ea2 authored by Jaewan Kim's avatar Jaewan Kim
Browse files

MediaSession2: Implement MediaLibrarySession#notifyChildrenChanged()

Test: Run all MediaComponents tests once
Bug: 72787989
Change-Id: If9dd119667e74cc7c77288f3777be551b02ca462
parent 4ae300c5
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -52,12 +52,12 @@ oneway interface IMediaSession2 {
    void sendCustomCommand(IMediaSession2Callback caller, in Bundle command, in Bundle args,
            in ResultReceiver receiver);

    void prepareFromUri(IMediaSession2Callback caller, in Uri uri, in Bundle extra);
    void prepareFromSearch(IMediaSession2Callback caller, String query, in Bundle extra);
    void prepareFromMediaId(IMediaSession2Callback caller, String mediaId, in Bundle extra);
    void playFromUri(IMediaSession2Callback caller, in Uri uri, in Bundle extra);
    void playFromSearch(IMediaSession2Callback caller, String query, in Bundle extra);
    void playFromMediaId(IMediaSession2Callback caller, String mediaId, in Bundle extra);
    void prepareFromUri(IMediaSession2Callback caller, in Uri uri, in Bundle extras);
    void prepareFromSearch(IMediaSession2Callback caller, String query, in Bundle extras);
    void prepareFromMediaId(IMediaSession2Callback caller, String mediaId, in Bundle extras);
    void playFromUri(IMediaSession2Callback caller, in Uri uri, in Bundle extras);
    void playFromSearch(IMediaSession2Callback caller, String query, in Bundle extras);
    void playFromMediaId(IMediaSession2Callback caller, String mediaId, in Bundle extras);
    void setRating(IMediaSession2Callback caller, String mediaId, in Bundle rating);

    //////////////////////////////////////////////////////////////////////////////////////////////
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ oneway interface IMediaSession2Callback {
    //////////////////////////////////////////////////////////////////////////////////////////////
    void onGetRootResult(in Bundle rootHints, String rootMediaId, in Bundle rootExtra);
    void onItemLoaded(String mediaId, in Bundle result);
    void onChildrenChanged(String rootMediaId, int childCount, in Bundle extras);
    void onChildrenLoaded(String parentId, int page, int pageSize, in List<Bundle> result,
            in Bundle extras);
    void onSearchResultChanged(String query, int itemCount, in Bundle extras);
+6 −0
Original line number Diff line number Diff line
@@ -212,4 +212,10 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow
            mCallback.onSearchResultLoaded(query, page, pageSize, result, extras);
        });
    }

    public void onChildrenChanged(final String parentId, int childCount, final Bundle extras) {
        getCallbackExecutor().execute(() -> {
            mCallback.onChildrenChanged(parentId, childCount, extras);
        });
    }
}
+15 −5
Original line number Diff line number Diff line
@@ -95,13 +95,23 @@ public class MediaLibraryService2Impl extends MediaSessionService2Impl implement

        @Override
        public void notifyChildrenChanged_impl(ControllerInfo controller, String parentId,
                Bundle extras) {
            // TODO(jaewan): Implements
                int childCount, Bundle extras) {
            if (controller == null) {
                throw new IllegalArgumentException("controller shouldn't be null");
            }
            if (parentId == null) {
                throw new IllegalArgumentException("parentId shouldn't be null");
            }
            getSessionStub().notifyChildrenChangedNotLocked(controller, parentId, childCount,
                    extras);
        }

        @Override
        public void notifyChildrenChanged_impl(String parentId, Bundle extras) {
            // TODO(jaewan): Implements
        public void notifyChildrenChanged_impl(String parentId, int childCount, Bundle extras) {
            if (parentId == null) {
                throw new IllegalArgumentException("parentId shouldn't be null");
            }
            getSessionStub().notifyChildrenChangedNotLocked(parentId, childCount, extras);
        }

        @Override
+16 −0
Original line number Diff line number Diff line
@@ -309,4 +309,20 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub {
        }
        browser.onSearchResultLoaded(query, page, pageSize, result, extras);
    }

    @Override
    public void onChildrenChanged(String parentId, int childCount, Bundle extras) {
        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.onChildrenChanged(parentId, childCount, extras);
    }
}
Loading