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

Commit ac7c7dbd authored by Hyundo Moon's avatar Hyundo Moon Committed by Jaewan Kim
Browse files

MediaBrowser2: Fix naming inconsistencies

This CL modifies following APIs:

1. getLibraryRoot() related
 - onGetRoot => onGetLibraryRoot
 - onGetRootResult => onGetLibraryRootDone

2. getItem() related
 - onLoadItem => onGetItem
   - Also renamed argument: itemId => mediaId
 - onItemLoaded => onGetItemDone

3. getChildren() related
 - notifyChildrenChanged/onChildrenChanged
   - Renamed argument: childCount => itemCount
 - onLoadChildren => onGetChildren
 - onChildrenLoaded => onGetChildrenDone

4. getSearchResult() related
 - onLoadSearchResult => onGetSearchResult
 - onSearchResultLoaded => onGetSearchResultDone

Bug: 73711101
Test: Passed MediaBrowser2Test
Change-Id: I7f59686e21f4de9d4512cd19067c944e49faad39
parent 643825e4
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -47,12 +47,12 @@ oneway interface IMediaSession2Callback {
    //////////////////////////////////////////////////////////////////////////////////////////////
    // Browser sepcific
    //////////////////////////////////////////////////////////////////////////////////////////////
    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,
    void onGetLibraryRootDone(in Bundle rootHints, String rootMediaId, in Bundle rootExtra);
    void onGetItemDone(String mediaId, in Bundle result);
    void onChildrenChanged(String rootMediaId, int itemCount, in Bundle extras);
    void onGetChildrenDone(String parentId, int page, int pageSize, in List<Bundle> result,
            in Bundle extras);
    void onSearchResultChanged(String query, int itemCount, in Bundle extras);
    void onSearchResultLoaded(String query, int page, int pageSize, in List<Bundle> result,
    void onGetSearchResultDone(String query, int page, int pageSize, in List<Bundle> result,
            in Bundle extras);
}
+10 −10
Original line number Diff line number Diff line
@@ -180,23 +180,23 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow
        }
    }

    public void onGetRootResult(
    public void onGetLibraryRootDone(
            final Bundle rootHints, final String rootMediaId, final Bundle rootExtra) {
        getCallbackExecutor().execute(() -> {
            mCallback.onGetRootResult(rootHints, rootMediaId, rootExtra);
            mCallback.onGetLibraryRootDone(rootHints, rootMediaId, rootExtra);
        });
    }

    public void onItemLoaded(String mediaId, MediaItem2 item) {
    public void onGetItemDone(String mediaId, MediaItem2 item) {
        getCallbackExecutor().execute(() -> {
            mCallback.onItemLoaded(mediaId, item);
            mCallback.onGetItemDone(mediaId, item);
        });
    }

    public void onChildrenLoaded(String parentId, int page, int pageSize, List<MediaItem2> result,
    public void onGetChildrenDone(String parentId, int page, int pageSize, List<MediaItem2> result,
            Bundle extras) {
        getCallbackExecutor().execute(() -> {
            mCallback.onChildrenLoaded(parentId, page, pageSize, result, extras);
            mCallback.onGetChildrenDone(parentId, page, pageSize, result, extras);
        });
    }

@@ -206,16 +206,16 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow
        });
    }

    public void onSearchResultLoaded(String query, int page, int pageSize, List<MediaItem2> result,
    public void onGetSearchResultDone(String query, int page, int pageSize, List<MediaItem2> result,
            Bundle extras) {
        getCallbackExecutor().execute(() -> {
            mCallback.onSearchResultLoaded(query, page, pageSize, result, extras);
            mCallback.onGetSearchResultDone(query, page, pageSize, result, extras);
        });
    }

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

        @Override
        public void notifyChildrenChanged_impl(ControllerInfo controller, String parentId,
                int childCount, Bundle extras) {
                int itemCount, 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,
            getSessionStub().notifyChildrenChangedNotLocked(controller, parentId, itemCount,
                    extras);
        }

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

        @Override
+10 −10
Original line number Diff line number Diff line
@@ -209,7 +209,7 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub {
    // MediaBrowser specific
    ////////////////////////////////////////////////////////////////////////////////////////////
    @Override
    public void onGetRootResult(Bundle rootHints, String rootMediaId, Bundle rootExtra)
    public void onGetLibraryRootDone(Bundle rootHints, String rootMediaId, Bundle rootExtra)
            throws RuntimeException {
        final MediaBrowser2Impl browser;
        try {
@@ -222,12 +222,12 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub {
            // TODO(jaewan): Revisit here. Could be a bug
            return;
        }
        browser.onGetRootResult(rootHints, rootMediaId, rootExtra);
        browser.onGetLibraryRootDone(rootHints, rootMediaId, rootExtra);
    }


    @Override
    public void onItemLoaded(String mediaId, Bundle itemBundle) throws RuntimeException {
    public void onGetItemDone(String mediaId, Bundle itemBundle) throws RuntimeException {
        final MediaBrowser2Impl browser;
        try {
            browser = getBrowser();
@@ -239,12 +239,12 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub {
            // TODO(jaewan): Revisit here. Could be a bug
            return;
        }
        browser.onItemLoaded(mediaId,
        browser.onGetItemDone(mediaId,
                MediaItem2Impl.fromBundle(browser.getContext(), itemBundle));
    }

    @Override
    public void onChildrenLoaded(String parentId, int page, int pageSize,
    public void onGetChildrenDone(String parentId, int page, int pageSize,
            List<Bundle> itemBundleList, Bundle extras) throws RuntimeException {
        final MediaBrowser2Impl browser;
        try {
@@ -265,7 +265,7 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub {
                result.add(MediaItem2.fromBundle(browser.getContext(), bundle));
            }
        }
        browser.onChildrenLoaded(parentId, page, pageSize, result, extras);
        browser.onGetChildrenDone(parentId, page, pageSize, result, extras);
    }

    @Override
@@ -286,7 +286,7 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub {
    }

    @Override
    public void onSearchResultLoaded(String query, int page, int pageSize,
    public void onGetSearchResultDone(String query, int page, int pageSize,
            List<Bundle> itemBundleList, Bundle extras) throws RuntimeException {
        final MediaBrowser2Impl browser;
        try {
@@ -307,11 +307,11 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub {
                result.add(MediaItem2.fromBundle(browser.getContext(), bundle));
            }
        }
        browser.onSearchResultLoaded(query, page, pageSize, result, extras);
        browser.onGetSearchResultDone(query, page, pageSize, result, extras);
    }

    @Override
    public void onChildrenChanged(String parentId, int childCount, Bundle extras) {
    public void onChildrenChanged(String parentId, int itemCount, Bundle extras) {
        final MediaBrowser2Impl browser;
        try {
            browser = getBrowser();
@@ -323,6 +323,6 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub {
            // TODO(jaewan): Revisit here. Could be a bug
            return;
        }
        browser.onChildrenChanged(parentId, childCount, extras);
        browser.onChildrenChanged(parentId, itemCount, extras);
    }
}
+18 −18
Original line number Diff line number Diff line
@@ -554,9 +554,9 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
                return;
            }
            final ControllerInfoImpl controllerImpl = ControllerInfoImpl.from(controller);
            LibraryRoot root = session.getCallback().onGetRoot(controller, rootHints);
            LibraryRoot root = session.getCallback().onGetLibraryRoot(controller, rootHints);
            try {
                controllerImpl.getControllerBinder().onGetRootResult(rootHints,
                controllerImpl.getControllerBinder().onGetLibraryRootDone(rootHints,
                        root == null ? null : root.getRootId(),
                        root == null ? null : root.getExtras());
            } catch (RemoteException e) {
@@ -588,9 +588,9 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
                return;
            }
            final ControllerInfoImpl controllerImpl = ControllerInfoImpl.from(controller);
            MediaItem2 result = session.getCallback().onLoadItem(controller, mediaId);
            MediaItem2 result = session.getCallback().onGetItem(controller, mediaId);
            try {
                controllerImpl.getControllerBinder().onItemLoaded(
                controllerImpl.getControllerBinder().onGetItemDone(
                        mediaId, result == null ? null : result.toBundle());
            } catch (RemoteException e) {
                // Controller may be died prematurely.
@@ -629,10 +629,10 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
                return;
            }
            final ControllerInfoImpl controllerImpl = ControllerInfoImpl.from(controller);
            List<MediaItem2> result = session.getCallback().onLoadChildren(
            List<MediaItem2> result = session.getCallback().onGetChildren(
                    controller, parentId, page, pageSize, extras);
            if (result != null && result.size() > pageSize) {
                throw new IllegalArgumentException("onLoadChildren() shouldn't return media items "
                throw new IllegalArgumentException("onGetChildren() shouldn't return media items "
                        + "more than pageSize. result.size()=" + result.size() + " pageSize="
                        + pageSize);
            }
@@ -646,7 +646,7 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
            }

            try {
                controllerImpl.getControllerBinder().onChildrenLoaded(
                controllerImpl.getControllerBinder().onGetChildrenDone(
                        parentId, page, pageSize, bundleList, extras);
            } catch (RemoteException e) {
                // Controller may be died prematurely.
@@ -712,10 +712,10 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
                return;
            }
            final ControllerInfoImpl controllerImpl = ControllerInfoImpl.from(controller);
            List<MediaItem2> result = session.getCallback().onLoadSearchResult(
            List<MediaItem2> result = session.getCallback().onGetSearchResult(
                    controller, query, page, pageSize, extras);
            if (result != null && result.size() > pageSize) {
                throw new IllegalArgumentException("onLoadSearchResult() shouldn't return media "
                throw new IllegalArgumentException("onGetSearchResult() shouldn't return media "
                        + "items more than pageSize. result.size()=" + result.size() + " pageSize="
                        + pageSize);
            }
@@ -729,7 +729,7 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
            }

            try {
                controllerImpl.getControllerBinder().onSearchResultLoaded(
                controllerImpl.getControllerBinder().onGetSearchResultDone(
                        query, page, pageSize, bundleList, extras);
            } catch (RemoteException e) {
                // Controller may be died prematurely.
@@ -754,7 +754,7 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
            if (session == null) {
                return;
            }
            session.getCallback().onSubscribed(controller, parentId, option);
            session.getCallback().onSubscribe(controller, parentId, option);
            synchronized (mLock) {
                Set<String> subscription = mSubscriptions.get(controller);
                if (subscription == null) {
@@ -781,7 +781,7 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
            if (session == null) {
                return;
            }
            session.getCallback().onUnsubscribed(controller, parentId);
            session.getCallback().onUnsubscribe(controller, parentId);
            synchronized (mLock) {
                mSubscriptions.remove(controller);
            }
@@ -951,23 +951,23 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
    }

    public void notifyChildrenChangedNotLocked(ControllerInfo controller, String parentId,
            int childCount, Bundle extras) {
            int itemCount, Bundle extras) {
        // TODO(jaewan): Handle when controller is disconnected and no longer valid.
        //               Note: Commands may be sent while onConnected() is running. Should we also
        //                     consider it as error?
        notifyChildrenChangedInternalNotLocked(controller, parentId, childCount, extras);
        notifyChildrenChangedInternalNotLocked(controller, parentId, itemCount, extras);
    }

    public void notifyChildrenChangedNotLocked(String parentId, int childCount, Bundle extras) {
    public void notifyChildrenChangedNotLocked(String parentId, int itemCount, Bundle extras) {
        final List<ControllerInfo> controllers = getControllers();
        for (int i = 0; i < controllers.size(); i++) {
            notifyChildrenChangedInternalNotLocked(controllers.get(i), parentId, childCount,
            notifyChildrenChangedInternalNotLocked(controllers.get(i), parentId, itemCount,
                    extras);
        }
    }

    public void notifyChildrenChangedInternalNotLocked(final ControllerInfo controller,
            String parentId, int childCount, Bundle extras) {
            String parentId, int itemCount, Bundle extras) {
        // Ensure subscription
        synchronized (mLock) {
            Set<String> subscriptions = mSubscriptions.get(controller);
@@ -978,7 +978,7 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
        final IMediaSession2Callback callbackBinder =
                ControllerInfoImpl.from(controller).getControllerBinder();
        try {
            callbackBinder.onChildrenChanged(parentId, childCount, extras);
            callbackBinder.onChildrenChanged(parentId, itemCount, extras);
        } catch (RemoteException e) {
            // TODO(jaewan): Handle controller removed?
        }
Loading