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

Commit c69e2569 authored by Hyundo Moon's avatar Hyundo Moon Committed by Android (Google) Code Review
Browse files

Merge "MediaRoute2ProviderService: Resolve API review"

parents c2ac82cd 891c94f5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -26799,7 +26799,6 @@ package android.media {
    method public abstract void onSelectRoute(@NonNull String, @NonNull String);
    method public abstract void onSetVolume(@NonNull String, int);
    method public abstract void onTransferToRoute(@NonNull String, @NonNull String);
    method public abstract void onUpdateVolume(@NonNull String, int);
    field public static final long REQUEST_ID_UNKNOWN = 0L; // 0x0L
    field public static final String SERVICE_INTERFACE = "android.media.MediaRoute2ProviderService";
  }
+0 −1
Original line number Diff line number Diff line
@@ -37,5 +37,4 @@ oneway interface IMediaRoute2Provider {

    void notifyControlRequestSent(String id, in Intent request);
    void requestSetVolume(String id, int volume);
    void requestUpdateVolume(String id, int delta);
}
+0 −3
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ interface IMediaRouterService {
    void sendControlRequest(IMediaRouter2Client client, in MediaRoute2Info route,
            in Intent request);
    void requestSetVolume2(IMediaRouter2Client client, in MediaRoute2Info route, int volume);
    void requestUpdateVolume2(IMediaRouter2Client client, in MediaRoute2Info route, int direction);

    void requestCreateSession(IMediaRouter2Client client, in MediaRoute2Info route, int requestId,
            in @nullable Bundle sessionHints);
@@ -70,8 +69,6 @@ interface IMediaRouterService {

    void requestSetVolume2Manager(IMediaRouter2Manager manager,
            in MediaRoute2Info route, int volume);
    void requestUpdateVolume2Manager(IMediaRouter2Manager manager,
            in MediaRoute2Info route, int direction);

    List<RoutingSessionInfo> getActiveSessions(IMediaRouter2Manager manager);
    void selectClientRoute(IMediaRouter2Manager manager,
+14 −23
Original line number Diff line number Diff line
@@ -46,13 +46,20 @@ import java.util.concurrent.atomic.AtomicBoolean;
/**
 * Base class for media route provider services.
 * <p>
 * Media route provider services are used to publish {@link MediaRoute2Info media routes} such as
 * speakers, TVs, etc. The routes are published by calling {@link #notifyRoutes(Collection)}.
 * Media apps which use {@link MediaRouter2} can request to play their media on the routes.
 * </p><p>
 * When {@link MediaRouter2 media router} wants to play media on a route,
 * {@link #onCreateSession(String, String, long, Bundle)} will be called to handle the request.
 * A session can be considered as a group of currently selected routes for each connection.
 * Create and manage the sessions by yourself, and notify the {@link RoutingSessionInfo
 * session infos} when there are any changes.
 * </p><p>
 * The system media router service will bind to media route provider services when a
 * {@link RouteDiscoveryPreference discovery preference} is registered via
 * a {@link MediaRouter2 media router} by an application.
 * </p><p>
 * To implement your own media route provider service, extend this class and
 * override {@link #onDiscoveryPreferenceChanged(RouteDiscoveryPreference)} to publish
 * {@link MediaRoute2Info routes}.
 * a {@link MediaRouter2 media router} by an application. See
 * {@link #onDiscoveryPreferenceChanged(RouteDiscoveryPreference)} for the details.
 * </p>
 */
public abstract class MediaRoute2ProviderService extends Service {
@@ -118,21 +125,14 @@ public abstract class MediaRoute2ProviderService extends Service {
    public abstract void onControlRequest(@NonNull String routeId, @NonNull Intent request);

    /**
     * Called when requestSetVolume is called on a route of the provider
     * Called when requestSetVolume is called on a route of the provider.
     *
     * @param routeId the id of the route
     * @param volume the target volume
     * @see MediaRoute2Info#getVolumeMax()
     */
    public abstract void onSetVolume(@NonNull String routeId, int volume);

    /**
     * Called when requestUpdateVolume is called on a route of the provider
     *
     * @param routeId id of the route
     * @param delta the delta to add to the current volume
     */
    public abstract void onUpdateVolume(@NonNull String routeId, int delta);

    /**
     * Gets information of the session with the given id.
     *
@@ -520,14 +520,5 @@ public abstract class MediaRoute2ProviderService extends Service {
            mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onSetVolume,
                    MediaRoute2ProviderService.this, routeId, volume));
        }

        @Override
        public void requestUpdateVolume(String routeId, int delta) {
            if (!checkCallerisSystem()) {
                return;
            }
            mHandler.sendMessage(obtainMessage(MediaRoute2ProviderService::onUpdateVolume,
                    MediaRoute2ProviderService.this, routeId, delta));
        }
    }
}
+0 −25
Original line number Diff line number Diff line
@@ -462,31 +462,6 @@ public class MediaRouter2 {
        }
    }

    /**
     * Requests an incremental volume update  for the route asynchronously.
     * <p>
     * It may have no effect if the route is currently not selected.
     * </p>
     *
     * @param delta The delta to add to the current volume.
     * @hide
     */
    public void requestUpdateVolume(@NonNull MediaRoute2Info route, int delta) {
        Objects.requireNonNull(route, "route must not be null");

        Client2 client;
        synchronized (sRouterLock) {
            client = mClient;
        }
        if (client != null) {
            try {
                mMediaRouterService.requestUpdateVolume2(client, route, delta);
            } catch (RemoteException ex) {
                Log.e(TAG, "Unable to send control request.", ex);
            }
        }
    }

    void addRoutesOnHandler(List<MediaRoute2Info> routes) {
        // TODO: When onRoutesAdded is first called,
        //  1) clear mRoutes before adding the routes
Loading