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

Commit 1d66400e authored by Iván Budnik's avatar Iván Budnik Committed by Android (Google) Code Review
Browse files

Merge "Copy lists to ensure deep immutability in RoutingSessionInfo"

parents 45788cbd ae74c912
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;

import com.android.internal.util.Preconditions;

@@ -117,6 +116,8 @@ public final class RoutingSessionInfo implements Parcelable {
        mProviderId = src.readString();

        mSelectedRoutes = ensureList(src.createStringArrayList());
        Preconditions.checkArgument(!mSelectedRoutes.isEmpty());

        mSelectableRoutes = ensureList(src.createStringArrayList());
        mDeselectableRoutes = ensureList(src.createStringArrayList());
        mTransferableRoutes = ensureList(src.createStringArrayList());
@@ -416,15 +417,21 @@ public final class RoutingSessionInfo implements Parcelable {
        return result.toString();
    }

    /**
     * Provides a new list with unique route IDs if {@link #mProviderId} is set, or the original IDs
     * otherwise.
     *
     * @param routeIds list of route IDs to convert
     * @return new list with unique IDs or original IDs
     */

    @NonNull
    private List<String> convertToUniqueRouteIds(@NonNull List<String> routeIds) {
        if (routeIds == null) {
            Log.w(TAG, "routeIds is null. Returning an empty list");
            return Collections.emptyList();
        }
        Objects.requireNonNull(routeIds, "RouteIds cannot be null.");

        // mProviderId can be null if not set. Return the original list for this case.
        if (TextUtils.isEmpty(mProviderId)) {
            return routeIds;
            return new ArrayList<>(routeIds);
        }

        List<String> result = new ArrayList<>();