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

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

Reduce upper limit of stored bitmaps to 32

This helps reduce the max amount of memory needed for storing images.
While we do lose some support for incredibly long playlists by default,
we do ensure the current playing track from a playlist will always be
stored

Tag: #stability
Bug: 186706117
Test: atest BluetoothInstrumentationTests
Change-Id: I3003adc85f9d09654a2838444b215e9a1a3ed730
parent 6c54751c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public class AvrcpCoverArtService {
    private static final String TAG = "AvrcpCoverArtService";
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);

    private static final int COVER_ART_STORAGE_MAX_ITEMS = 255;
    private static final int COVER_ART_STORAGE_MAX_ITEMS = 32;

    private final Context mContext;

+2 −2
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ final class AvrcpCoverArtStorage {
                        hash = key;
                    }
                }
                sb.append(String.format("\n\t\t%-8s : %-32s : %s\n", imageHandle, hash, coverArt));
                sb.append(String.format("\n\t\t%-8s : %-32s : %s", imageHandle, hash, coverArt));
                bytes += coverArt.size();
            }
        }
+18 −3
Original line number Diff line number Diff line
@@ -389,12 +389,27 @@ public class AvrcpTargetService extends ProfileService {
    }

    List<Metadata> getNowPlayingList() {
        String currentMediaId = getCurrentMediaId();
        Metadata currentTrack = null;
        String imageHandle = null;
        List<Metadata> nowPlayingList = mMediaPlayerList.getNowPlayingList();
        if (mAvrcpCoverArtService != null) {
            for (Metadata metadata : nowPlayingList) {
                if (metadata.image != null) {
                    String imageHandle = mAvrcpCoverArtService.storeImage(metadata.image);
                    if (imageHandle != null) metadata.image.setImageHandle(imageHandle);
                if (metadata.mediaId == currentMediaId) {
                    currentTrack = metadata;
                } else if (metadata.image != null) {
                    imageHandle = mAvrcpCoverArtService.storeImage(metadata.image);
                    if (imageHandle != null) {
                        metadata.image.setImageHandle(imageHandle);
                    }
                }
            }

            // Always store the current item from the queue last so we know the image is in storage
            if (currentTrack != null) {
                imageHandle = mAvrcpCoverArtService.storeImage(currentTrack.image);
                if (imageHandle != null) {
                    currentTrack.image.setImageHandle(imageHandle);
                }
            }
        }