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

Commit 9b3d0531 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "MediaRouter: Renames supportControlCategory as supportControlCategories"

parents cf0e5738 5c9a55ea
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -249,22 +249,36 @@ public final class MediaRoute2Info implements Parcelable {
        return mExtras;
    }

    /**
     * Returns if the route supports the specified control category
     *
     * @param controlCategory control category to consider
     * @return true if the route supports at the category
     */
    public boolean supportsControlCategory(@NonNull String controlCategory) {
        Objects.requireNonNull(controlCategory, "control category must not be null");
        for (String supportedCategory : getSupportedCategories()) {
            if (TextUtils.equals(controlCategory, supportedCategory)) {
                return true;
            }
        }
        return false;
    }

    //TODO: Move this if we re-define control category / selector things.
    /**
     * Returns true if the route supports at least one of the specified control categories
     * Returns if the route supports at least one of the specified control categories
     *
     * @param controlCategories the list of control categories to consider
     * @return true if the route supports at least one category
     */
    public boolean supportsControlCategory(@NonNull Collection<String> controlCategories) {
    public boolean supportsControlCategories(@NonNull Collection<String> controlCategories) {
        Objects.requireNonNull(controlCategories, "control categories must not be null");
        for (String controlCategory : controlCategories) {
            for (String supportedCategory : getSupportedCategories()) {
                if (TextUtils.equals(controlCategory, supportedCategory)) {
            if (supportsControlCategory(controlCategory)) {
                return true;
            }
        }
        }
        return false;
    }

+6 −6
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ public class MediaRouter2 {

                List<MediaRoute2Info> filteredRoutes = new ArrayList<>();
                for (MediaRoute2Info route : mRoutes.values()) {
                    if (route.supportsControlCategory(mControlCategories)) {
                    if (route.supportsControlCategories(mControlCategories)) {
                        filteredRoutes.add(route);
                    }
                }
@@ -399,8 +399,8 @@ public class MediaRouter2 {
        mControlCategories = newControlCategories;

        for (MediaRoute2Info route : mRoutes.values()) {
            boolean preSupported = route.supportsControlCategory(prevControlCategories);
            boolean postSupported = route.supportsControlCategory(newControlCategories);
            boolean preSupported = route.supportsControlCategories(prevControlCategories);
            boolean postSupported = route.supportsControlCategories(newControlCategories);
            if (preSupported == postSupported) {
                continue;
            }
@@ -430,7 +430,7 @@ public class MediaRouter2 {
        synchronized (sLock) {
            for (MediaRoute2Info route : routes) {
                mRoutes.put(route.getUniqueId(), route);
                if (route.supportsControlCategory(mControlCategories)) {
                if (route.supportsControlCategories(mControlCategories)) {
                    addedRoutes.add(route);
                }
            }
@@ -446,7 +446,7 @@ public class MediaRouter2 {
        synchronized (sLock) {
            for (MediaRoute2Info route : routes) {
                mRoutes.remove(route.getUniqueId());
                if (route.supportsControlCategory(mControlCategories)) {
                if (route.supportsControlCategories(mControlCategories)) {
                    removedRoutes.add(route);
                }
            }
@@ -462,7 +462,7 @@ public class MediaRouter2 {
        synchronized (sLock) {
            for (MediaRoute2Info route : routes) {
                mRoutes.put(route.getUniqueId(), route);
                if (route.supportsControlCategory(mControlCategories)) {
                if (route.supportsControlCategories(mControlCategories)) {
                    changedRoutes.add(route);
                }
            }
+1 −1
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ public class MediaRouter2Manager {
        List<MediaRoute2Info> routes = new ArrayList<>();
        synchronized (mRoutesLock) {
            for (MediaRoute2Info route : mRoutes.values()) {
                if (route.supportsControlCategory(controlCategories)) {
                if (route.supportsControlCategories(controlCategories)) {
                    routes.add(route);
                }
            }