Bug 1374572 - don't access disconnected remote binder. r=esawin

MozReview-Commit-ID: 6eYIbKgwRPd

--HG--
extra : rebase_source : 863a2e107c6a47ce5d428b4697d0a6190fae4aae
This commit is contained in:
John Lin 2017-07-19 12:53:04 +08:00
Родитель 6bd73cdf47
Коммит c016f71d92
1 изменённых файлов: 15 добавлений и 11 удалений

Просмотреть файл

@ -59,15 +59,7 @@ public final class RemoteManager implements IBinder.DeathRecipient {
@Override
public void onServiceDisconnected(ComponentName name) {
if (DEBUG) Log.d(LOGTAG, "service disconnected");
try {
mRemote.asBinder().unlinkToDeath(RemoteManager.this, 0);
} catch (NoSuchElementException e) {
Log.w(LOGTAG, "death recipient already released");
}
synchronized (this) {
mRemote = null;
notify();
}
unlink();
}
private boolean connect() {
@ -103,6 +95,19 @@ public final class RemoteManager implements IBinder.DeathRecipient {
}
}
}
private synchronized void unlink() {
if (mRemote == null) {
return;
}
try {
mRemote.asBinder().unlinkToDeath(RemoteManager.this, 0);
} catch (NoSuchElementException e) {
Log.w(LOGTAG, "death recipient already released");
}
mRemote = null;
notify();
}
};
RemoteConnection mConnection = new RemoteConnection();
@ -221,9 +226,8 @@ public final class RemoteManager implements IBinder.DeathRecipient {
private void release() {
if (DEBUG) Log.d(LOGTAG, "release remote manager " + this);
mConnection.unlink();
Context appCtxt = GeckoAppShell.getApplicationContext();
mRemote.asBinder().unlinkToDeath(this, 0);
mRemote = null;
appCtxt.unbindService(mConnection);
}
} // RemoteManager