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

Commit ecc8fa85 authored by Robert Snoeberger's avatar Robert Snoeberger
Browse files

Avoid loading app icon bitmap when possible

The layout file is using a CachingIconView for the app icon to avoid
reloading the icon when possible. But, the icon is being explicitly
loaded in MediaDataManager. This change eliminates this unnecessary
work.

Bug: 160591450
Test: manual - heap_profile sysui while toggling play/pause.
Change-Id: I5677e489229fc53f2d5cdc19023acf49a80c7caa
parent 993254c8
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -249,10 +249,9 @@ public class MediaControlPanel {
        // App icon
        ImageView appIcon = mViewHolder.getAppIcon();
        if (data.getAppIcon() != null) {
            appIcon.setImageDrawable(data.getAppIcon());
            appIcon.setImageIcon(data.getAppIcon());
        } else {
            Drawable iconDrawable = mContext.getDrawable(R.drawable.ic_music_note);
            appIcon.setImageDrawable(iconDrawable);
            appIcon.setImageResource(R.drawable.ic_music_note);
        }

        // Song name
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ data class MediaData(
    /**
     * Icon shown on player, close to app name.
     */
    val appIcon: Drawable?,
    val appIcon: Icon?,
    /**
     * Artist name.
     */
+2 −2
Original line number Diff line number Diff line
@@ -455,7 +455,7 @@ class MediaDataManager(
        val app = builder.loadHeaderAppName()

        // App Icon
        val smallIconDrawable: Drawable = sbn.notification.smallIcon.loadDrawable(context)
        val smallIcon = sbn.notification.smallIcon

        // Song name
        var song: CharSequence? = metadata?.getString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE)
@@ -518,7 +518,7 @@ class MediaDataManager(
            val hasCheckedForResume = mediaEntries[key]?.hasCheckedForResume == true
            val active = mediaEntries[key]?.active ?: true
            onMediaDataLoaded(key, oldKey, MediaData(sbn.normalizedUserId, true, bgColor, app,
                    smallIconDrawable, artist, song, artWorkIcon, actionIcons,
                    smallIcon, artist, song, artWorkIcon, actionIcons,
                    actionsToShowCollapsed, sbn.packageName, token, notif.contentIntent, null,
                    active, resumeAction = resumeAction, isLocalSession = isLocalSession,
                    notificationKey = key, hasCheckedForResume = hasCheckedForResume,