SysUI: Correctly compare MediaControllers

Instead of comparing MediaControllers via reference equality
(which is never true), go deeper and check whether the two
controllers are connected to the same IBinder.

Bug: 17571414
Change-Id: Id25d70be0a60d1900e977310dedcc7063552e018
This commit is contained in:
Christoph Studer
2014-09-19 16:54:36 +02:00
parent da6ffa06b7
commit b5245d8904
2 changed files with 15 additions and 1 deletions

View File

@@ -434,6 +434,14 @@ public final class MediaController {
return mSessionBinder;
}
/**
* @hide
*/
public boolean controlsSameSession(MediaController other) {
if (other == null) return false;
return mSessionBinder.asBinder() == other.getSessionBinder().asBinder();
}
private void addCallbackLocked(Callback cb, Handler handler) {
if (getHandlerForCallbackLocked(cb) != null) {
Log.w(TAG, "Callback is already added, ignoring");

View File

@@ -1748,7 +1748,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
}
if (controller != mMediaController) {
if (!sameSessions(mMediaController, controller)) {
// We have a new media session
if (mMediaController != null) {
@@ -1797,6 +1797,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
updateMediaMetaData(metaDataChanged);
}
private boolean sameSessions(MediaController a, MediaController b) {
if (a == b) return true;
if (a == null) return false;
return a.controlsSameSession(b);
}
/**
* Hide the album artwork that is fading out and release its bitmap.
*/