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

Commit ee19f10e authored by Jaewan Kim's avatar Jaewan Kim Committed by Sungsoo Lim
Browse files

MediaSession2: Add onDataSourceMissingHelper

This allows a developer to create DataSourceDesc when the item is about
to be played. Typical example of the usages are,

    1. For a playlist consists of FileDescriptors, its developer may not
        want to open all files when MediaSession2.setPlaylist() is
        called.
    2. A controller has called setPlaylist(), addPlaylistItem(), or
        replacePlaylistItem(). Controller cannot know the
        DataSourceDesc, and only the session developer can know about
        it.

Bug: 64098437
Test: Run MediaComponents test
Change-Id: Ic109408f838405f5aec94dfba94c47ca97bc65c5
parent 20e21fd7
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -44,14 +44,11 @@ public class MediaItem2Impl implements MediaItem2Provider {
    private DataSourceDesc mDataSourceDesc;

    // From the public API
    public MediaItem2Impl(Context context, String mediaId,
            DataSourceDesc dsd, MediaMetadata2 metadata, @Flags int flags) {
    public MediaItem2Impl(@NonNull Context context, @NonNull String mediaId,
            @Nullable DataSourceDesc dsd, @Nullable MediaMetadata2 metadata, @Flags int flags) {
        if (mediaId == null) {
            throw new IllegalArgumentException("mediaId shouldn't be null");
        }
        if (dsd == null) {
            throw new IllegalArgumentException("dsd shouldn't be null");
        }
        if (metadata != null && !TextUtils.equals(mediaId, metadata.getMediaId())) {
            throw new IllegalArgumentException("metadata's id should be matched with the mediaid");
        }
@@ -186,10 +183,7 @@ public class MediaItem2Impl implements MediaItem2Provider {
        }

        @Override
        public Builder setDataSourceDesc_impl(@NonNull DataSourceDesc dataSourceDesc) {
            if (dataSourceDesc == null) {
                throw new IllegalArgumentException("dataSourceDesc shouldn't be null");
            }
        public Builder setDataSourceDesc_impl(@Nullable DataSourceDesc dataSourceDesc) {
            mDataSourceDesc = dataSourceDesc;
            return mInstance;
        }