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

Commit 2189f58e authored by Sungsoo Lim's avatar Sungsoo Lim
Browse files

MediaBrowser: Handle null results properly in onLoadChildren

Bug: 19127753
Change-Id: I7ddad87e5ec6338a74c340485fed583107709acf
parent 0477e978
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import android.util.Log;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.List;

/**
@@ -519,13 +518,10 @@ public final class MediaBrowser {
                    return;
                }

                List<MediaItem> data = list.getList();
                List<MediaItem> data = list == null ? null : list.getList();
                if (DBG) {
                    Log.d(TAG, "onLoadChildren for " + mServiceComponent + " id=" + parentId);
                }
                if (data == null) {
                    data = Collections.emptyList();
                }

                // Check that the subscription is still subscribed.
                final Subscription subscription = mSubscriptions.get(parentId);
@@ -730,10 +726,9 @@ public final class MediaBrowser {
         * Called when the list of children is loaded or updated.
         *
         * @param parentId The media id of the parent media item.
         * @param children The children which were loaded.
         * @param children The children which were loaded, or null if the id is invalid.
         */
        public void onChildrenLoaded(@NonNull String parentId,
                                     @NonNull List<MediaItem> children) {
        public void onChildrenLoaded(@NonNull String parentId, List<MediaItem> children) {
        }

        /**
+2 −5
Original line number Diff line number Diff line
@@ -469,10 +469,6 @@ public abstract class MediaBrowserService extends Service {
                = new Result<List<MediaBrowser.MediaItem>>(parentId) {
            @Override
            void onResultSent(List<MediaBrowser.MediaItem> list) {
                if (list == null) {
                    throw new IllegalStateException("onLoadChildren sent null list for id "
                            + parentId);
                }
                if (mConnections.get(connection.callbacks.asBinder()) != connection) {
                    if (DBG) {
                        Log.d(TAG, "Not sending onLoadChildren result for connection that has"
@@ -481,7 +477,8 @@ public abstract class MediaBrowserService extends Service {
                    return;
                }

                final ParceledListSlice<MediaBrowser.MediaItem> pls = new ParceledListSlice(list);
                final ParceledListSlice<MediaBrowser.MediaItem> pls =
                        list == null ? null : new ParceledListSlice(list);
                try {
                    connection.callbacks.onLoadChildren(parentId, pls);
                } catch (RemoteException ex) {