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

Commit e9d6a427 authored by Kyunglyul Hyun's avatar Kyunglyul Hyun Committed by Automerger Merge Worker
Browse files

Merge "MediaRouterService binds services when necessary" am: 2f9749cd

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1552155

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ifbf0dcdbe627516fc11bd323f94233b0ed2a7f8b
parents dd744552 2f9749cd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ interface IMediaRouterService {
    void unregisterManager(IMediaRouter2Manager manager);
    void setRouteVolumeWithManager(IMediaRouter2Manager manager, int requestId,
            in MediaRoute2Info route, int volume);
    void startScan(IMediaRouter2Manager manager);
    void stopScan(IMediaRouter2Manager manager);

    void requestCreateSessionWithManager(IMediaRouter2Manager manager, int requestId,
            in RoutingSessionInfo oldSession, in @nullable MediaRoute2Info route);
+30 −0
Original line number Diff line number Diff line
@@ -146,6 +146,36 @@ public final class MediaRouter2Manager {
        }
    }

    /**
     * Starts scanning remote routes.
     * @see #stopScan(String)
     */
    public void startScan() {
        Client client = getOrCreateClient();
        if (client != null) {
            try {
                mMediaRouterService.startScan(client);
            } catch (RemoteException ex) {
                Log.e(TAG, "Unable to get sessions. Service probably died.", ex);
            }
        }
    }

    /**
     * Stops scanning remote routes to reduce resource consumption.
     * @see #startScan(String)
     */
    public void stopScan() {
        Client client = getOrCreateClient();
        if (client != null) {
            try {
                mMediaRouterService.stopScan(client);
            } catch (RemoteException ex) {
                Log.e(TAG, "Unable to get sessions. Service probably died.", ex);
            }
        }
    }

    /**
     * Gets a {@link android.media.session.MediaController} associated with the
     * given routing session.
+1 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ public final class RouteDiscoveryPreference implements Parcelable {
            return false;
        }
        RouteDiscoveryPreference other = (RouteDiscoveryPreference) o;
        //TODO: Make this order-free
        return Objects.equals(mPreferredFeatures, other.mPreferredFeatures)
                && mShouldPerformActiveScan == other.mShouldPerformActiveScan;
    }
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ abstract class MediaRoute2Provider {
    @NonNull
    public List<RoutingSessionInfo> getSessionInfos() {
        synchronized (mLock) {
            return mSessionInfos;
            return new ArrayList<>(mSessionInfos);
        }
    }

+5 −3
Original line number Diff line number Diff line
@@ -108,8 +108,8 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider
        mLastDiscoveryPreference = discoveryPreference;
        if (mConnectionReady) {
            mActiveConnection.updateDiscoveryPreference(discoveryPreference);
            updateBinding();
        }
        updateBinding();
    }

    @Override
@@ -205,9 +205,11 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider
    }

    private boolean shouldBind() {
        //TODO: Binding could be delayed until it's necessary.
        if (mRunning) {
            return true;
            // Bind when there is a discovery preference or an active route session.
            return (mLastDiscoveryPreference != null
                    && !mLastDiscoveryPreference.getPreferredFeatures().isEmpty())
                    || !getSessionInfos().isEmpty();
        }
        return false;
    }
Loading