Loading packages/MediaComponents/src/com/android/media/IMediaSession2.aidl +4 −1 Original line number Diff line number Diff line Loading @@ -65,5 +65,8 @@ oneway interface IMediaSession2 { void getBrowserRoot(IMediaSession2Callback callback, in Bundle rootHints); void getItem(IMediaSession2Callback callback, String mediaId); void getChildren(IMediaSession2Callback callback, String parentId, int page, int pageSize, in Bundle options); in Bundle extras); void search(IMediaSession2Callback callback, String query, in Bundle extras); void getSearchResult(IMediaSession2Callback callback, String query, int page, int pageSize, in Bundle extras); } packages/MediaComponents/src/com/android/media/IMediaSession2Callback.aidl +3 −1 Original line number Diff line number Diff line Loading @@ -49,6 +49,8 @@ oneway interface IMediaSession2Callback { ////////////////////////////////////////////////////////////////////////////////////////////// void onGetRootResult(in Bundle rootHints, String rootMediaId, in Bundle rootExtra); void onItemLoaded(String mediaId, in Bundle result); void onChildrenLoaded(String parentId, int page, int pageSize, in Bundle options, void onChildrenLoaded(String parentId, int page, int pageSize, in Bundle extras, in List<Bundle> result); void onSearchResultLoaded(String query, int page, int pageSize, in Bundle extras, in List<Bundle> result); } packages/MediaComponents/src/com/android/media/MediaBrowser2Impl.java +50 −8 Original line number Diff line number Diff line Loading @@ -63,12 +63,12 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow } @Override public void subscribe_impl(String parentId, Bundle options) { public void subscribe_impl(String parentId, Bundle extras) { // TODO(jaewan): Implement } @Override public void unsubscribe_impl(String parentId, Bundle options) { public void unsubscribe_impl(String parentId, Bundle extras) { // TODO(jaewan): Implement } Loading @@ -94,7 +94,7 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow } @Override public void getChildren_impl(String parentId, int page, int pageSize, Bundle options) { public void getChildren_impl(String parentId, int page, int pageSize, Bundle extras) { if (parentId == null) { throw new IllegalArgumentException("parentId shouldn't be null"); } Loading @@ -105,7 +105,7 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow final IMediaSession2 binder = getSessionBinder(); if (binder != null) { try { binder.getChildren(getControllerStub(), parentId, page, pageSize, options); binder.getChildren(getControllerStub(), parentId, page, pageSize, extras); } catch (RemoteException e) { // TODO(jaewan): Handle disconnect. if (DEBUG) { Loading @@ -118,8 +118,43 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow } @Override public void search_impl(String query, int page, int pageSize, Bundle extras) { // TODO(jaewan): Implement public void search_impl(String query, Bundle extras) { if (TextUtils.isEmpty(query)) { throw new IllegalArgumentException("query shouldn't be empty"); } final IMediaSession2 binder = getSessionBinder(); if (binder != null) { try { binder.search(getControllerStub(), query, extras); } catch (RemoteException e) { // TODO(jaewan): Handle disconnect. if (DEBUG) { Log.w(TAG, "Cannot connect to the service or the session is gone", e); } } } else { Log.w(TAG, "Session isn't active", new IllegalStateException()); } } @Override public void getSearchResult_impl(String query, int page, int pageSize, Bundle extras) { if (TextUtils.isEmpty(query)) { throw new IllegalArgumentException("query shouldn't be empty"); } final IMediaSession2 binder = getSessionBinder(); if (binder != null) { try { binder.getSearchResult(getControllerStub(), query, page, pageSize, extras); } catch (RemoteException e) { // TODO(jaewan): Handle disconnect. if (DEBUG) { Log.w(TAG, "Cannot connect to the service or the session is gone", e); } } } else { Log.w(TAG, "Session isn't active", new IllegalStateException()); } } public void onGetRootResult( Loading @@ -135,10 +170,17 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow }); } public void onChildrenLoaded(String parentId, int page, int pageSize, Bundle options, public void onChildrenLoaded(String parentId, int page, int pageSize, Bundle extras, List<MediaItem2> result) { getCallbackExecutor().execute(() -> { mCallback.onChildrenLoaded(parentId, page, pageSize, extras, result); }); } public void onSearchResultLoaded(String query, int page, int pageSize, Bundle extras, List<MediaItem2> result) { getCallbackExecutor().execute(() -> { mCallback.onChildrenLoaded(parentId, page, pageSize, options, result); mCallback.onSearchResultLoaded(query, page, pageSize, extras, result); }); } } packages/MediaComponents/src/com/android/media/MediaItem2Impl.java +9 −12 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ public class MediaItem2Impl implements MediaItem2Provider { throw new IllegalArgumentException("dsd shouldn't be null"); } if (metadata != null && !TextUtils.equals(mediaId, metadata.getMediaId())) { throw new IllegalArgumentException("metadata's id should be match with the mediaid"); throw new IllegalArgumentException("metadata's id should be matched with the mediaid"); } mContext = context; Loading @@ -71,7 +71,7 @@ public class MediaItem2Impl implements MediaItem2Provider { throw new IllegalArgumentException("mediaId shouldn't be null"); } if (metadata != null && !TextUtils.equals(mediaId, metadata.getMediaId())) { throw new IllegalArgumentException("metadata's id should be match with the mediaid"); throw new IllegalArgumentException("metadata's id should be matched with the mediaid"); } mContext = context; mId = mediaId; Loading Loading @@ -136,24 +136,21 @@ public class MediaItem2Impl implements MediaItem2Provider { } @Override public void setMetadata_impl(@NonNull MediaMetadata2 metadata) { if (metadata == null) { throw new IllegalArgumentException("metadata shouldn't be null"); } if (TextUtils.isEmpty(metadata.getMediaId())) { throw new IllegalArgumentException("metadata must have a non-empty media id"); public void setMetadata_impl(@Nullable MediaMetadata2 metadata) { if (metadata != null && !TextUtils.equals(mId, metadata.getMediaId())) { throw new IllegalArgumentException("metadata's id should be matched with the mediaId"); } mMetadata = metadata; } @Override public MediaMetadata2 getMetadata_impl() { public @Nullable MediaMetadata2 getMetadata_impl() { return mMetadata; } @Override public @Nullable String getMediaId_impl() { return mMetadata.getMediaId(); public @NonNull String getMediaId_impl() { return mId; } @Override Loading packages/MediaComponents/src/com/android/media/MediaSession2CallbackStub.java +27 −2 Original line number Diff line number Diff line Loading @@ -244,7 +244,7 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub { } @Override public void onChildrenLoaded(String parentId, int page, int pageSize, Bundle options, public void onChildrenLoaded(String parentId, int page, int pageSize, Bundle extras, List<Bundle> itemBundleList) throws RuntimeException { final MediaBrowser2Impl browser; try { Loading @@ -265,6 +265,31 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub { result.add(MediaItem2.fromBundle(browser.getContext(), bundle)); } } browser.onChildrenLoaded(parentId, page, pageSize, options, result); browser.onChildrenLoaded(parentId, page, pageSize, extras, result); } @Override public void onSearchResultLoaded(String query, int page, int pageSize, Bundle extras, List<Bundle> itemBundleList) 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; } List<MediaItem2> result = null; if (itemBundleList != null) { result = new ArrayList<>(); for (Bundle bundle : itemBundleList) { result.add(MediaItem2.fromBundle(browser.getContext(), bundle)); } } browser.onSearchResultLoaded(query, page, pageSize, extras, result); } } Loading
packages/MediaComponents/src/com/android/media/IMediaSession2.aidl +4 −1 Original line number Diff line number Diff line Loading @@ -65,5 +65,8 @@ oneway interface IMediaSession2 { void getBrowserRoot(IMediaSession2Callback callback, in Bundle rootHints); void getItem(IMediaSession2Callback callback, String mediaId); void getChildren(IMediaSession2Callback callback, String parentId, int page, int pageSize, in Bundle options); in Bundle extras); void search(IMediaSession2Callback callback, String query, in Bundle extras); void getSearchResult(IMediaSession2Callback callback, String query, int page, int pageSize, in Bundle extras); }
packages/MediaComponents/src/com/android/media/IMediaSession2Callback.aidl +3 −1 Original line number Diff line number Diff line Loading @@ -49,6 +49,8 @@ oneway interface IMediaSession2Callback { ////////////////////////////////////////////////////////////////////////////////////////////// void onGetRootResult(in Bundle rootHints, String rootMediaId, in Bundle rootExtra); void onItemLoaded(String mediaId, in Bundle result); void onChildrenLoaded(String parentId, int page, int pageSize, in Bundle options, void onChildrenLoaded(String parentId, int page, int pageSize, in Bundle extras, in List<Bundle> result); void onSearchResultLoaded(String query, int page, int pageSize, in Bundle extras, in List<Bundle> result); }
packages/MediaComponents/src/com/android/media/MediaBrowser2Impl.java +50 −8 Original line number Diff line number Diff line Loading @@ -63,12 +63,12 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow } @Override public void subscribe_impl(String parentId, Bundle options) { public void subscribe_impl(String parentId, Bundle extras) { // TODO(jaewan): Implement } @Override public void unsubscribe_impl(String parentId, Bundle options) { public void unsubscribe_impl(String parentId, Bundle extras) { // TODO(jaewan): Implement } Loading @@ -94,7 +94,7 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow } @Override public void getChildren_impl(String parentId, int page, int pageSize, Bundle options) { public void getChildren_impl(String parentId, int page, int pageSize, Bundle extras) { if (parentId == null) { throw new IllegalArgumentException("parentId shouldn't be null"); } Loading @@ -105,7 +105,7 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow final IMediaSession2 binder = getSessionBinder(); if (binder != null) { try { binder.getChildren(getControllerStub(), parentId, page, pageSize, options); binder.getChildren(getControllerStub(), parentId, page, pageSize, extras); } catch (RemoteException e) { // TODO(jaewan): Handle disconnect. if (DEBUG) { Loading @@ -118,8 +118,43 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow } @Override public void search_impl(String query, int page, int pageSize, Bundle extras) { // TODO(jaewan): Implement public void search_impl(String query, Bundle extras) { if (TextUtils.isEmpty(query)) { throw new IllegalArgumentException("query shouldn't be empty"); } final IMediaSession2 binder = getSessionBinder(); if (binder != null) { try { binder.search(getControllerStub(), query, extras); } catch (RemoteException e) { // TODO(jaewan): Handle disconnect. if (DEBUG) { Log.w(TAG, "Cannot connect to the service or the session is gone", e); } } } else { Log.w(TAG, "Session isn't active", new IllegalStateException()); } } @Override public void getSearchResult_impl(String query, int page, int pageSize, Bundle extras) { if (TextUtils.isEmpty(query)) { throw new IllegalArgumentException("query shouldn't be empty"); } final IMediaSession2 binder = getSessionBinder(); if (binder != null) { try { binder.getSearchResult(getControllerStub(), query, page, pageSize, extras); } catch (RemoteException e) { // TODO(jaewan): Handle disconnect. if (DEBUG) { Log.w(TAG, "Cannot connect to the service or the session is gone", e); } } } else { Log.w(TAG, "Session isn't active", new IllegalStateException()); } } public void onGetRootResult( Loading @@ -135,10 +170,17 @@ public class MediaBrowser2Impl extends MediaController2Impl implements MediaBrow }); } public void onChildrenLoaded(String parentId, int page, int pageSize, Bundle options, public void onChildrenLoaded(String parentId, int page, int pageSize, Bundle extras, List<MediaItem2> result) { getCallbackExecutor().execute(() -> { mCallback.onChildrenLoaded(parentId, page, pageSize, extras, result); }); } public void onSearchResultLoaded(String query, int page, int pageSize, Bundle extras, List<MediaItem2> result) { getCallbackExecutor().execute(() -> { mCallback.onChildrenLoaded(parentId, page, pageSize, options, result); mCallback.onSearchResultLoaded(query, page, pageSize, extras, result); }); } }
packages/MediaComponents/src/com/android/media/MediaItem2Impl.java +9 −12 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ public class MediaItem2Impl implements MediaItem2Provider { throw new IllegalArgumentException("dsd shouldn't be null"); } if (metadata != null && !TextUtils.equals(mediaId, metadata.getMediaId())) { throw new IllegalArgumentException("metadata's id should be match with the mediaid"); throw new IllegalArgumentException("metadata's id should be matched with the mediaid"); } mContext = context; Loading @@ -71,7 +71,7 @@ public class MediaItem2Impl implements MediaItem2Provider { throw new IllegalArgumentException("mediaId shouldn't be null"); } if (metadata != null && !TextUtils.equals(mediaId, metadata.getMediaId())) { throw new IllegalArgumentException("metadata's id should be match with the mediaid"); throw new IllegalArgumentException("metadata's id should be matched with the mediaid"); } mContext = context; mId = mediaId; Loading Loading @@ -136,24 +136,21 @@ public class MediaItem2Impl implements MediaItem2Provider { } @Override public void setMetadata_impl(@NonNull MediaMetadata2 metadata) { if (metadata == null) { throw new IllegalArgumentException("metadata shouldn't be null"); } if (TextUtils.isEmpty(metadata.getMediaId())) { throw new IllegalArgumentException("metadata must have a non-empty media id"); public void setMetadata_impl(@Nullable MediaMetadata2 metadata) { if (metadata != null && !TextUtils.equals(mId, metadata.getMediaId())) { throw new IllegalArgumentException("metadata's id should be matched with the mediaId"); } mMetadata = metadata; } @Override public MediaMetadata2 getMetadata_impl() { public @Nullable MediaMetadata2 getMetadata_impl() { return mMetadata; } @Override public @Nullable String getMediaId_impl() { return mMetadata.getMediaId(); public @NonNull String getMediaId_impl() { return mId; } @Override Loading
packages/MediaComponents/src/com/android/media/MediaSession2CallbackStub.java +27 −2 Original line number Diff line number Diff line Loading @@ -244,7 +244,7 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub { } @Override public void onChildrenLoaded(String parentId, int page, int pageSize, Bundle options, public void onChildrenLoaded(String parentId, int page, int pageSize, Bundle extras, List<Bundle> itemBundleList) throws RuntimeException { final MediaBrowser2Impl browser; try { Loading @@ -265,6 +265,31 @@ public class MediaSession2CallbackStub extends IMediaSession2Callback.Stub { result.add(MediaItem2.fromBundle(browser.getContext(), bundle)); } } browser.onChildrenLoaded(parentId, page, pageSize, options, result); browser.onChildrenLoaded(parentId, page, pageSize, extras, result); } @Override public void onSearchResultLoaded(String query, int page, int pageSize, Bundle extras, List<Bundle> itemBundleList) 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; } List<MediaItem2> result = null; if (itemBundleList != null) { result = new ArrayList<>(); for (Bundle bundle : itemBundleList) { result.add(MediaItem2.fromBundle(browser.getContext(), bundle)); } } browser.onSearchResultLoaded(query, page, pageSize, extras, result); } }