Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5245d89 authored by Christoph Studer's avatar Christoph Studer
Browse files

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
parent da6ffa06
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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");
+7 −1
Original line number Diff line number Diff line
@@ -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.
     */