Merge "MediaBrowserService: Clean up ConnectionRecord when browser is dead" into oc-mr1-dev
am: bbf55bb7ae
Change-Id: I4e14e80a31c0eed3c897e35720bff1f694f7a007
This commit is contained in:
@@ -110,12 +110,22 @@ public abstract class MediaBrowserService extends Service {
|
||||
/**
|
||||
* All the info about a connection.
|
||||
*/
|
||||
private class ConnectionRecord {
|
||||
private class ConnectionRecord implements IBinder.DeathRecipient {
|
||||
String pkg;
|
||||
Bundle rootHints;
|
||||
IMediaBrowserServiceCallbacks callbacks;
|
||||
BrowserRoot root;
|
||||
HashMap<String, List<Pair<IBinder, Bundle>>> subscriptions = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void binderDied() {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mConnections.remove(callbacks.asBinder());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +217,6 @@ public abstract class MediaBrowserService extends Service {
|
||||
connection.pkg = pkg;
|
||||
connection.rootHints = rootHints;
|
||||
connection.callbacks = callbacks;
|
||||
|
||||
connection.root = MediaBrowserService.this.onGetRoot(pkg, uid, rootHints);
|
||||
|
||||
// If they didn't return something, don't allow this client.
|
||||
@@ -223,6 +232,7 @@ public abstract class MediaBrowserService extends Service {
|
||||
} else {
|
||||
try {
|
||||
mConnections.put(b, connection);
|
||||
b.linkToDeath(connection, 0);
|
||||
if (mSession != null) {
|
||||
callbacks.onConnect(connection.root.getRootId(),
|
||||
mSession, connection.root.getExtras());
|
||||
@@ -248,6 +258,7 @@ public abstract class MediaBrowserService extends Service {
|
||||
final ConnectionRecord old = mConnections.remove(b);
|
||||
if (old != null) {
|
||||
// TODO
|
||||
old.callbacks.asBinder().unlinkToDeath(old, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user