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

Commit 9be3548c authored by Hyundo Moon's avatar Hyundo Moon
Browse files

MediaRouter2: Unify terms (select, add, group) to 'select'

This CL unifies the different terms ([select, add, group] route)
which actually have the same meaning - into 'select'.

Same applies for ([deselect, remove]) -> deselect.

Bug: 146400872
Test: atest mediaroutertest
Change-Id: Ic985359dd53f8b30bba654e6a451fcdf3be6cf24
parent a64ca9ec
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ oneway interface IMediaRoute2Provider {
            String controlCategory, int requestId);
    void releaseSession(int sessionId);

    void addRoute(int sessionId, String routeId);
    void removeRoute(int sessionId, String routeId);
    void selectRoute(int sessionId, String routeId);
    void deselectRoute(int sessionId, String routeId);
    void transferRoute(int sessionId, String routeId);

    void notifyControlRequestSent(String id, in Intent request);
+10 −10
Original line number Diff line number Diff line
@@ -230,8 +230,8 @@ public abstract class MediaRoute2ProviderService extends Service {

    //TODO: make a way to reject the request
    /**
     * Called when a client requests adding a route to a session.
     * After the route is added, call {@link #updateSessionInfo(RouteSessionInfo)} to update
     * Called when a client requests selecting a route for the session.
     * After the route is selected, call {@link #updateSessionInfo(RouteSessionInfo)} to update
     * session info and call {@link #updateProviderInfo(MediaRoute2ProviderInfo)} to notify
     * clients of updated session info.
     *
@@ -239,19 +239,19 @@ public abstract class MediaRoute2ProviderService extends Service {
     * @param routeId id of the route
     * @see #updateSessionInfo(RouteSessionInfo)
     */
    public abstract void onAddRoute(int sessionId, @NonNull String routeId);
    public abstract void onSelectRoute(int sessionId, @NonNull String routeId);

    //TODO: make a way to reject the request
    /**
     * Called when a client requests removing a route from a session.
     * After the route is removed, call {@link #updateSessionInfo(RouteSessionInfo)} to update
     * Called when a client requests deselecting a route from the session.
     * After the route is deselected, call {@link #updateSessionInfo(RouteSessionInfo)} to update
     * session info and call {@link #updateProviderInfo(MediaRoute2ProviderInfo)} to notify
     * clients of updated session info.
     *
     * @param sessionId id of the session
     * @param routeId id of the route
     */
    public abstract void onRemoveRoute(int sessionId, @NonNull String routeId);
    public abstract void onDeselectRoute(int sessionId, @NonNull String routeId);

    //TODO: make a way to reject the request
    /**
@@ -326,20 +326,20 @@ public abstract class MediaRoute2ProviderService extends Service {
        }

        @Override
        public void addRoute(int sessionId, String routeId) {
        public void selectRoute(int sessionId, String routeId) {
            if (!checkCallerisSystem()) {
                return;
            }
            mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onAddRoute,
            mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onSelectRoute,
                    MediaRoute2ProviderService.this, sessionId, routeId));
        }

        @Override
        public void removeRoute(int sessionId, String routeId) {
        public void deselectRoute(int sessionId, String routeId) {
            if (!checkCallerisSystem()) {
                return;
            }
            mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onRemoveRoute,
            mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onDeselectRoute,
                    MediaRoute2ProviderService.this, sessionId, routeId));
        }

+12 −12
Original line number Diff line number Diff line
@@ -679,8 +679,8 @@ public class MediaRouter2 {

    /**
     * A class to control media route session in media route provider.
     * For example, adding/removing/transferring routes to session can be done through this class.
     * Instances are created by {@link MediaRouter2}.
     * For example, selecting/deselcting/transferring routes to session can be done through this
     * class. Instances are created by {@link MediaRouter2}.
     *
     * @hide
     */
@@ -737,22 +737,22 @@ public class MediaRouter2 {
        }

        /**
         * @return the unmodifiable list of IDs of deselectable routes for the session.
         * @return the unmodifiable list of IDs of selectable routes for the session.
         */
        @NonNull
        public List<String> getDeselectableRoutes() {
        public List<String> getSelectableRoutes() {
            synchronized (mLock) {
                return Collections.unmodifiableList(mSessionInfo.getDeselectableRoutes());
                return Collections.unmodifiableList(mSessionInfo.getSelectableRoutes());
            }
        }

        /**
         * @return the unmodifiable list of IDs of groupable routes for the session.
         * @return the unmodifiable list of IDs of deselectable routes for the session.
         */
        @NonNull
        public List<String> getGroupableRoutes() {
        public List<String> getDeselectableRoutes() {
            synchronized (mLock) {
                return Collections.unmodifiableList(mSessionInfo.getGroupableRoutes());
                return Collections.unmodifiableList(mSessionInfo.getDeselectableRoutes());
            }
        }

@@ -781,25 +781,25 @@ public class MediaRouter2 {
        }

        /**
         * Add routes to the remote session. Route add requests that are currently in
         * Selects a route for the remote session. Route add requests that are currently in
         * {@link #getSelectedRoutes()} will be ignored.
         *
         * @see #getSelectedRoutes()
         * @see SessionCallback#onSessionInfoChanged
         */
        public void addRoute(MediaRoute2Info route) {
        public void selectRoute(MediaRoute2Info route) {
            // TODO: Implement this when the actual connection logic is implemented.
        }

        /**
         * Remove routes from this session. Media may be stopped on those devices.
         * Deselects a route from the remote session. Media may be stopped on those devices.
         * Route removal requests that are not currently in {@link #getSelectedRoutes()} will be
         * ignored.
         *
         * @see #getSelectedRoutes()
         * @see SessionCallback#onSessionInfoChanged
         */
        public void removeRoute(MediaRoute2Info route) {
        public void deselectRoute(MediaRoute2Info route) {
            // TODO: Implement this when the actual connection logic is implemented.
        }

+34 −34
Original line number Diff line number Diff line
@@ -52,8 +52,8 @@ public class RouteSessionInfo implements Parcelable {
    @Nullable
    final String mProviderId;
    final List<String> mSelectedRoutes;
    final List<String> mSelectableRoutes;
    final List<String> mDeselectableRoutes;
    final List<String> mGroupableRoutes;
    final List<String> mTransferrableRoutes;
    @Nullable
    final Bundle mControlHints;
@@ -67,8 +67,8 @@ public class RouteSessionInfo implements Parcelable {
        mProviderId = builder.mProviderId;

        mSelectedRoutes = Collections.unmodifiableList(builder.mSelectedRoutes);
        mSelectableRoutes = Collections.unmodifiableList(builder.mSelectableRoutes);
        mDeselectableRoutes = Collections.unmodifiableList(builder.mDeselectableRoutes);
        mGroupableRoutes = Collections.unmodifiableList(builder.mGroupableRoutes);
        mTransferrableRoutes = Collections.unmodifiableList(builder.mTransferrableRoutes);

        mControlHints = builder.mControlHints;
@@ -83,8 +83,8 @@ public class RouteSessionInfo implements Parcelable {
        mProviderId = src.readString();

        mSelectedRoutes = ensureList(src.createStringArrayList());
        mSelectableRoutes = ensureList(src.createStringArrayList());
        mDeselectableRoutes = ensureList(src.createStringArrayList());
        mGroupableRoutes = ensureList(src.createStringArrayList());
        mTransferrableRoutes = ensureList(src.createStringArrayList());

        mControlHints = src.readBundle();
@@ -156,19 +156,19 @@ public class RouteSessionInfo implements Parcelable {
    }

    /**
     * Gets the list of ids of deselectable routes for the session.
     * Gets the list of ids of selectable routes for the session.
     */
    @NonNull
    public List<String> getDeselectableRoutes() {
        return mDeselectableRoutes;
    public List<String> getSelectableRoutes() {
        return mSelectableRoutes;
    }

    /**
     * Gets the list of ids of groupable routes for the session.
     * Gets the list of ids of deselectable routes for the session.
     */
    @NonNull
    public List<String> getGroupableRoutes() {
        return mGroupableRoutes;
    public List<String> getDeselectableRoutes() {
        return mDeselectableRoutes;
    }

    /**
@@ -199,8 +199,8 @@ public class RouteSessionInfo implements Parcelable {
        dest.writeString(mControlCategory);
        dest.writeString(mProviderId);
        dest.writeStringList(mSelectedRoutes);
        dest.writeStringList(mSelectableRoutes);
        dest.writeStringList(mDeselectableRoutes);
        dest.writeStringList(mGroupableRoutes);
        dest.writeStringList(mTransferrableRoutes);
        dest.writeBundle(mControlHints);
    }
@@ -214,12 +214,12 @@ public class RouteSessionInfo implements Parcelable {
                .append(", selectedRoutes={")
                .append(String.join(",", mSelectedRoutes))
                .append("}")
                .append(", selectableRoutes={")
                .append(String.join(",", mSelectableRoutes))
                .append("}")
                .append(", deselectableRoutes={")
                .append(String.join(",", mDeselectableRoutes))
                .append("}")
                .append(", groupableRoutes={")
                .append(String.join(",", mGroupableRoutes))
                .append("}")
                .append(", transferrableRoutes={")
                .append(String.join(",", mTransferrableRoutes))
                .append("}")
@@ -236,8 +236,8 @@ public class RouteSessionInfo implements Parcelable {
        final String mControlCategory;
        String mProviderId;
        final List<String> mSelectedRoutes;
        final List<String> mSelectableRoutes;
        final List<String> mDeselectableRoutes;
        final List<String> mGroupableRoutes;
        final List<String> mTransferrableRoutes;
        Bundle mControlHints;

@@ -249,8 +249,8 @@ public class RouteSessionInfo implements Parcelable {
                    "controlCategory must not be null");

            mSelectedRoutes = new ArrayList<>();
            mSelectableRoutes = new ArrayList<>();
            mDeselectableRoutes = new ArrayList<>();
            mGroupableRoutes = new ArrayList<>();
            mTransferrableRoutes = new ArrayList<>();
        }

@@ -261,8 +261,8 @@ public class RouteSessionInfo implements Parcelable {
            mProviderId = sessionInfo.mProviderId;

            mSelectedRoutes = new ArrayList<>(sessionInfo.mSelectedRoutes);
            mSelectableRoutes = new ArrayList<>(sessionInfo.mSelectableRoutes);
            mDeselectableRoutes = new ArrayList<>(sessionInfo.mDeselectableRoutes);
            mGroupableRoutes = new ArrayList<>(sessionInfo.mGroupableRoutes);
            mTransferrableRoutes = new ArrayList<>(sessionInfo.mTransferrableRoutes);

            mControlHints = sessionInfo.mControlHints;
@@ -305,56 +305,56 @@ public class RouteSessionInfo implements Parcelable {
        }

        /**
         * Clears the deselectable routes.
         * Clears the selectable routes.
         */
        @NonNull
        public Builder clearDeselectableRoutes() {
            mDeselectableRoutes.clear();
        public Builder clearSelectableRoutes() {
            mSelectableRoutes.clear();
            return this;
        }

        /**
         * Adds a route to the deselectable routes.
         * Adds a route to the selectable routes.
         */
        @NonNull
        public Builder addDeselectableRoute(@NonNull String routeId) {
            mDeselectableRoutes.add(Objects.requireNonNull(routeId, "routeId must not be null"));
        public Builder addSelectableRoute(@NonNull String routeId) {
            mSelectableRoutes.add(Objects.requireNonNull(routeId, "routeId must not be null"));
            return this;
        }

        /**
         * Removes a route from the deselectable routes.
         * Removes a route from the selectable routes.
         */
        @NonNull
        public Builder removeDeselectableRoute(@NonNull String routeId) {
            mDeselectableRoutes.remove(Objects.requireNonNull(routeId, "routeId must not be null"));
        public Builder removeSelectableRoute(@NonNull String routeId) {
            mSelectableRoutes.remove(Objects.requireNonNull(routeId, "routeId must not be null"));
            return this;
        }

        /**
         * Clears the groupable routes.
         * Clears the deselectable routes.
         */
        @NonNull
        public Builder clearGroupableRoutes() {
            mGroupableRoutes.clear();
        public Builder clearDeselectableRoutes() {
            mDeselectableRoutes.clear();
            return this;
        }

        /**
         * Adds a route to the groupable routes.
         * Adds a route to the deselectable routes.
         */
        @NonNull
        public Builder addGroupableRoute(@NonNull String routeId) {
            mGroupableRoutes.add(Objects.requireNonNull(routeId, "routeId must not be null"));
        public Builder addDeselectableRoute(@NonNull String routeId) {
            mDeselectableRoutes.add(Objects.requireNonNull(routeId, "routeId must not be null"));
            return this;
        }

        /**
         * Removes a route from the groupable routes.
         * Removes a route from the deselectable routes.
         */
        @NonNull
        public Builder removeGroupableRoute(@NonNull String routeId) {
            mGroupableRoutes.remove(Objects.requireNonNull(routeId, "routeId must not be null"));
        public Builder removeDeselectableRoute(@NonNull String routeId) {
            mDeselectableRoutes.remove(Objects.requireNonNull(routeId, "routeId must not be null"));
            return this;
        }

+6 −6
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ public class SampleMediaRoute2ProviderService extends MediaRoute2ProviderService
            notifySessionCreated(/* sessionInfo= */ null, requestId);
            return;
        }
        maybeRemoveRoute(routeId);
        maybeDeselectRoute(routeId);

        final int sessionId = mNextSessionId;
        mNextSessionId++;
@@ -192,13 +192,13 @@ public class SampleMediaRoute2ProviderService extends MediaRoute2ProviderService
    }

    @Override
    public void onAddRoute(int sessionId, String routeId) {
    public void onSelectRoute(int sessionId, String routeId) {
        RouteSessionInfo sessionInfo = getSessionInfo(sessionId);
        MediaRoute2Info route = mRoutes.get(routeId);
        if (route == null || sessionInfo == null) {
            return;
        }
        maybeRemoveRoute(routeId);
        maybeDeselectRoute(routeId);

        mRoutes.put(routeId, new MediaRoute2Info.Builder(route)
                .setClientPackageName(sessionInfo.getPackageName())
@@ -213,7 +213,7 @@ public class SampleMediaRoute2ProviderService extends MediaRoute2ProviderService
    }

    @Override
    public void onRemoveRoute(int sessionId, String routeId) {
    public void onDeselectRoute(int sessionId, String routeId) {
        RouteSessionInfo sessionInfo = getSessionInfo(sessionId);
        MediaRoute2Info route = mRoutes.get(routeId);

@@ -243,13 +243,13 @@ public class SampleMediaRoute2ProviderService extends MediaRoute2ProviderService
        publishRoutes();
    }

    void maybeRemoveRoute(String routeId) {
    void maybeDeselectRoute(String routeId) {
        if (!mRouteSessionMap.containsKey(routeId)) {
            return;
        }

        int sessionId = mRouteSessionMap.get(routeId);
        onRemoveRoute(sessionId, routeId);
        onDeselectRoute(sessionId, routeId);
    }

    void publishRoutes() {
Loading