Make MR2ProviderProxy bind again when onBindingDied() is called

Bug: 148501442
Test: atest mediaroutertest
Change-Id: I8a37d3d9712b2a455ec5d8569cdc5831b5bfc175
This commit is contained in:
Hyundo Moon
2020-01-29 13:26:14 +09:00
parent c112861f0a
commit 7294e5fca0

View File

@@ -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;