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
This commit is contained in:
Robert Snoeberger
2020-09-29 14:16:00 -04:00
parent 993254c89e
commit ecc8fa8557
3 changed files with 5 additions and 6 deletions

View File

@@ -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

View File

@@ -33,7 +33,7 @@ data class MediaData(
/**
* Icon shown on player, close to app name.
*/
val appIcon: Drawable?,
val appIcon: Icon?,
/**
* Artist name.
*/

View File

@@ -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,