am 538dc6ac: Merge "Fix 5615747 Don\'t leak remote control client death handlers" into ics-mr1

* commit '538dc6acfd14ea59f0b294531f9417ca04ca621f':
  Fix 5615747 Don't leak remote control client death handlers
This commit is contained in:
Jean-Michel Trivi
2011-11-15 09:26:02 -08:00
committed by Android Git Automerger

View File

@ -3110,6 +3110,7 @@ public class AudioService extends IAudioService.Stub {
if ((mRcClientDeathHandler != null) && (mRcClientDeathHandler.mCb != null)) {
try {
mRcClientDeathHandler.mCb.unlinkToDeath(mRcClientDeathHandler, 0);
mRcClientDeathHandler = null;
} catch (java.util.NoSuchElementException e) {
// not much we can do here
Log.e(TAG, "Encountered " + e + " in unlinkToRcClientDeath()");
@ -3117,6 +3118,12 @@ public class AudioService extends IAudioService.Stub {
}
}
}
@Override
protected void finalize() throws Throwable {
unlinkToRcClientDeath();// unlink exception handled inside method
super.finalize();
}
}
/**
@ -3163,6 +3170,7 @@ public class AudioService extends IAudioService.Stub {
if (packageName.equalsIgnoreCase(rcse.mReceiverComponent.getPackageName())) {
// a stack entry is from the package being removed, remove it from the stack
stackIterator.remove();
rcse.unlinkToRcClientDeath();
}
}
if (mRCStack.empty()) {
@ -3243,6 +3251,7 @@ public class AudioService extends IAudioService.Stub {
RemoteControlStackEntry rcse = (RemoteControlStackEntry)stackIterator.next();
if(rcse.mMediaIntent.equals(pi)) {
stackIterator.remove();
rcse.unlinkToRcClientDeath();
break;
}
}
@ -3504,7 +3513,7 @@ public class AudioService extends IAudioService.Stub {
rcse.mCallingPackageName = callingPackageName;
rcse.mCallingUid = Binder.getCallingUid();
if (rcClient == null) {
rcse.mRcClientDeathHandler = null;
// here rcse.mRcClientDeathHandler is null;
break;
}
@ -3560,7 +3569,6 @@ public class AudioService extends IAudioService.Stub {
rcse.unlinkToRcClientDeath();
// reset the client-related fields
rcse.mRcClient = null;
rcse.mRcClientDeathHandler = null;
rcse.mCallingPackageName = null;
}
}