From 1bf998e24d7a0d9397cd9918c719007ee55728a1 Mon Sep 17 00:00:00 2001 From: Steve Elliott Date: Mon, 22 Jun 2020 19:46:50 -0400 Subject: [PATCH] Fix race condition btwn row and shelf icon init Fixes: 154228740 Test: manual Change-Id: I4bedcc9c50817418a49c4a69d3132c01720cd206 --- .../notification/collection/NotificationEntry.java | 14 ++++++++++++++ .../statusbar/notification/icon/IconManager.kt | 6 ++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index 33771449abc9a..423f85f2ddd0f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -178,6 +178,7 @@ public final class NotificationEntry extends ListEntry { private int mBucket = BUCKET_ALERTING; @Nullable private Long mPendingAnimationDuration; private boolean mIsMarkedForUserTriggeredMovement; + private boolean mShelfIconVisible; /** * @param sbn the StatusBarNotification from system server @@ -431,6 +432,7 @@ public final class NotificationEntry extends ListEntry { //TODO: This will go away when we have a way to bind an entry to a row public void setRow(ExpandableNotificationRow row) { this.row = row; + updateShelfIconVisibility(); } public ExpandableNotificationRowController getRowController() { @@ -951,6 +953,18 @@ public final class NotificationEntry extends ListEntry { return mIsMarkedForUserTriggeredMovement; } + /** Whether or not the icon for this notification is visible in the shelf. */ + public void setShelfIconVisible(boolean shelfIconVisible) { + mShelfIconVisible = shelfIconVisible; + updateShelfIconVisibility(); + } + + private void updateShelfIconVisibility() { + if (row != null) { + row.setShelfIconVisible(mShelfIconVisible); + } + } + /** * Mark this entry for movement triggered by a user action (ex: changing the priorirty of a * conversation). This can then be used for custom animations. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconManager.kt index 011ad19b41db2..13f7a53f5e54d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconManager.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconManager.kt @@ -96,13 +96,11 @@ class IconManager @Inject constructor( val shelfIcon = iconBuilder.createIconView(entry) shelfIcon.scaleType = ImageView.ScaleType.CENTER_INSIDE - shelfIcon.visibility = View.INVISIBLE // TODO: This doesn't belong here shelfIcon.setOnVisibilityChangedListener { newVisibility: Int -> - if (entry.row != null) { - entry.row.setShelfIconVisible(newVisibility == View.VISIBLE) - } + entry.setShelfIconVisible(newVisibility == View.VISIBLE) } + shelfIcon.visibility = View.INVISIBLE // Construct the aod icon view. val aodIcon = iconBuilder.createIconView(entry)