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

Commit d4fdc622 authored by Jaewan Kim's avatar Jaewan Kim
Browse files

MediaSession2: Implement MediaLibrarySession#notifyChildrenChanged()

Test: Run all MediaComponents tests once
Bug: 72787989
Change-Id: I5bdcb8460109831fb5349d1437b775f8f7b7ddf0
parent acdbf49a
Loading
Loading
Loading
Loading
+12 −3
Original line number Original line Diff line number Diff line
@@ -20,6 +20,8 @@ import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Context;
import android.media.MediaLibraryService2.MediaLibrarySession;
import android.media.MediaSession2.ControllerInfo;
import android.media.update.ApiLoader;
import android.media.update.ApiLoader;
import android.media.update.MediaBrowser2Provider;
import android.media.update.MediaBrowser2Provider;
import android.os.Bundle;
import android.os.Bundle;
@@ -54,11 +56,18 @@ public class MediaBrowser2 extends MediaController2 {


        /**
        /**
         * Called when there's change in the parent's children.
         * Called when there's change in the parent's children.
         * <p>
         * This API is called when the library service called
         * {@link MediaLibrarySession#notifyChildrenChanged(ControllerInfo, String, int, Bundle)} or
         * {@link MediaLibrarySession#notifyChildrenChanged(String, int, Bundle)} for the parent.
         *
         *
         * @param parentId parent id that you've specified with {@link #subscribe(String, Bundle)}
         * @param parentId parent id that you've specified with {@link #subscribe(String, Bundle)}
         * @param extras extra bundle from the library service
         * @param childCount number of children
         * @param extras extra bundle from the library service. Can be differ from extras that
         *               you've specified with {@link #subscribe(String, Bundle)}.
         */
         */
        public void onChildrenChanged(@NonNull String parentId, @Nullable Bundle extras) { }
        public void onChildrenChanged(@NonNull String parentId, int childCount,
                @Nullable Bundle extras) { }


        /**
        /**
         * Called when the list of items has been returned by the library service for the previous
         * Called when the list of items has been returned by the library service for the previous
@@ -142,7 +151,7 @@ public class MediaBrowser2 extends MediaController2 {


    /**
    /**
     * Subscribe to a parent id for the change in its children. When there's a change,
     * Subscribe to a parent id for the change in its children. When there's a change,
     * {@link BrowserCallback#onChildrenChanged(String, Bundle)} will be called with the bundle
     * {@link BrowserCallback#onChildrenChanged(String, int, Bundle)} will be called with the bundle
     * that you've specified. You should call {@link #getChildren(String, int, int, Bundle)} to get
     * that you've specified. You should call {@link #getChildren(String, int, int, Bundle)} to get
     * the actual contents for the parent.
     * the actual contents for the parent.
     *
     *
+19 −9
Original line number Original line Diff line number Diff line
@@ -78,26 +78,36 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
        }
        }


        /**
        /**
         * Notify subscribed controller about change in a parent's children.
         * Notify the controller of the change in a parent's children.
         * <p>
         * If the controller hasn't subscribed to the parent, the API will do nothing.
         * <p>
         * Controllers will use {@link MediaBrowser2#getChildren(String, int, int, Bundle)} to get
         * the list of children.
         *
         *
         * @param controller controller to notify
         * @param controller controller to notify
         * @param parentId
         * @param parentId parent id with changes in its children
         * @param extras
         * @param childCount number of children.
         * @param extras extra information from session to controller
         */
         */
        public void notifyChildrenChanged(@NonNull ControllerInfo controller,
        public void notifyChildrenChanged(@NonNull ControllerInfo controller,
                @NonNull String parentId, @NonNull Bundle extras) {
                @NonNull String parentId, int childCount, @Nullable Bundle extras) {
            mProvider.notifyChildrenChanged_impl(controller, parentId, extras);
            mProvider.notifyChildrenChanged_impl(controller, parentId, childCount, extras);
        }
        }


        /**
        /**
         * Notify subscribed controller about change in a parent's children.
         * Notify all controllers that subscribed to the parent about change in the parent's
         * children, regardless of the extra bundle supplied by
         * {@link MediaBrowser2#subscribe(String, Bundle)}.
         *
         *
         * @param parentId parent id
         * @param parentId parent id
         * @param extras extra bundle
         * @param childCount number of children
         * @param extras extra information from session to controller
         */
         */
        // This is for the backward compatibility.
        // This is for the backward compatibility.
        public void notifyChildrenChanged(@NonNull String parentId, @Nullable Bundle extras) {
        public void notifyChildrenChanged(@NonNull String parentId, int childCount,
            mProvider.notifyChildrenChanged_impl(parentId, extras);
                @Nullable Bundle extras) {
            mProvider.notifyChildrenChanged_impl(parentId, childCount, extras);
        }
        }


        /**
        /**
+3 −2
Original line number Original line Diff line number Diff line
@@ -30,8 +30,9 @@ public interface MediaLibraryService2Provider extends MediaSessionService2Provid
    // Nothing new for now
    // Nothing new for now


    interface MediaLibrarySessionProvider extends MediaSession2Provider {
    interface MediaLibrarySessionProvider extends MediaSession2Provider {
        void notifyChildrenChanged_impl(ControllerInfo controller, String parentId, Bundle extras);
        void notifyChildrenChanged_impl(ControllerInfo controller, String parentId,
        void notifyChildrenChanged_impl(String parentId, Bundle extras);
                int childCount, Bundle extras);
        void notifyChildrenChanged_impl(String parentId, int childCount, Bundle extras);
        void notifySearchResultChanged_impl(ControllerInfo controller, String query, int itemCount,
        void notifySearchResultChanged_impl(ControllerInfo controller, String query, int itemCount,
                Bundle extras);
                Bundle extras);
    }
    }