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

Commit e1839072 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "AVRCP: fix crash on callback with no player"

parents f4a4968b da764157
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -1581,8 +1581,11 @@ public final class Avrcp {

    private void setAddressedMediaSessionPackage(String packageName) {
        if (DEBUG) Log.v(TAG, "Setting addressed media session to " + packageName);
        // Can't set no player, that handled by onActiveSessionsChanged
        if (packageName == null) return;
        if (packageName == null) {
            // Should only happen when there's no media players, reset to no available player.
            updateCurrentController(0, mCurrBrowsePlayerID);
            return;
        }
        // No change.
        if (getPackageName(mCurrAddrPlayerID).equals(packageName)) return;
        // If the player doesn't exist, we need to add it.
@@ -2653,8 +2656,12 @@ public final class Avrcp {

                @Override
                public void onAddressedPlayerChanged(ComponentName receiver) {
                    // We only get this if there isn't an active media session.
                    // We can still get a passthrough.
                    if (receiver == null) {
                        // No active sessions, and no session to revive, give up.
                        setAddressedMediaSessionPackage(null);
                        return;
                    }
                    // We can still get a passthrough which will revive this player.
                    setAddressedMediaSessionPackage(receiver.getPackageName());
                }
            };