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

Commit beda35e5 authored by Sal Savage's avatar Sal Savage
Browse files

Only trigger a metadata sync if we don't have any cover artwork

This change makes our solution to the race condition of cover art vs.
the control channel/track changed updates less aggressive.

Without this, every folder change causes a redownload of the current
artwork. This is a terrible UX. We can instead let the Target side tell
us when the backing data has changed if we already have artwork.

Tag: #compatibility
Bug: 158030613
Test: atest BluetoothInstrumentationTests
Change-Id: I3eee51b2b5fe6d7d99cfe3e4b821327303be1e26
parent a592120e
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -167,6 +167,16 @@ public class AvrcpControllerService extends ProfileService {
        return new AvrcpControllerStateMachine(device, this);
        return new AvrcpControllerStateMachine(device, this);
    }
    }


    protected void getCurrentMetadataIfNoCoverArt(BluetoothDevice device) {
        if (device == null) return;
        AvrcpControllerStateMachine stateMachine = getStateMachine(device);
        if (stateMachine == null) return;
        AvrcpItem track = stateMachine.getCurrentTrack();
        if (track != null && track.getCoverArtLocation() == null) {
            getCurrentMetadataNative(Utils.getByteAddress(device));
        }
    }

    private void refreshContents(BrowseTree.BrowseNode node) {
    private void refreshContents(BrowseTree.BrowseNode node) {
        BluetoothDevice device = node.getDevice();
        BluetoothDevice device = node.getDevice();
        if (device == null) {
        if (device == null) {
+7 −0
Original line number Original line Diff line number Diff line
@@ -207,6 +207,13 @@ class AvrcpControllerStateMachine extends StateMachine {
        sendMessage(DISCONNECT);
        sendMessage(DISCONNECT);
    }
    }


    /**
     * Get the current playing track
     */
    public AvrcpItem getCurrentTrack() {
        return mAddressedPlayer.getCurrentTrack();
    }

    /**
    /**
     * Dump the current State Machine to the string builder.
     * Dump the current State Machine to the string builder.
     *
     *
+2 −4
Original line number Original line Diff line number Diff line
@@ -22,8 +22,6 @@ import android.net.Uri;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.util.Log;
import android.util.Log;


import com.android.bluetooth.Utils;

import java.util.Map;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentHashMap;


@@ -284,8 +282,8 @@ public class AvrcpCoverArtManager {
                mCoverArtStorage.removeImagesForDevice(mDevice);
                mCoverArtStorage.removeImagesForDevice(mDevice);


                // Once we're connected fetch the current metadata again in case the target has an
                // Once we're connected fetch the current metadata again in case the target has an
                // image handle they can now give us
                // image handle they can now give us. Only do this if we don't already have one.
                mService.getCurrentMetadataNative(Utils.getByteAddress(mDevice));
                mService.getCurrentMetadataIfNoCoverArt(mDevice);
            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                AvrcpBipClient client = getClient(mDevice);
                AvrcpBipClient client = getClient(mDevice);
                boolean shouldReconnect = (client != null);
                boolean shouldReconnect = (client != null);