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

Commit 7294e5fc authored by Hyundo Moon's avatar Hyundo Moon
Browse files

Make MR2ProviderProxy bind again when onBindingDied() is called

Bug: 148501442
Test: atest mediaroutertest
Change-Id: I8a37d3d9712b2a455ec5d8569cdc5831b5bfc175
parent c112861f
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import java.util.Objects;
/**
 * Maintains a connection to a particular media route provider service.
 */
// TODO: Need to revisit the bind/unbind/connect/disconnect logic in this class.
final class MediaRoute2ProviderProxy extends MediaRoute2Provider implements ServiceConnection {
    private static final String TAG = "MR2ProviderProxy";
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -252,6 +253,19 @@ final class MediaRoute2ProviderProxy extends MediaRoute2Provider implements Serv
        disconnect();
    }

    @Override
    public void onBindingDied(ComponentName name) {
        if (DEBUG) {
            Slog.d(TAG, this + ": Service binding died");
        }
        // TODO: Investigate whether it tries to bind endlessly when the service is
        //       badly implemented.
        if (shouldBind()) {
            unbind();
            bind();
        }
    }

    private void onConnectionReady(Connection connection) {
        if (mActiveConnection == connection) {
            mConnectionReady = true;