diff options
| author | 2024-03-26 03:26:53 +0000 | |
|---|---|---|
| committer | 2024-03-26 03:26:53 +0000 | |
| commit | 0f1179c678d91bf9ef31f48ae5ab1c07b54c70bd (patch) | |
| tree | 0954f75007fdfa8ecc1176f0552cf4f816c85831 | |
| parent | 2947c318ff8245856740d12cc158e90ed81f653e (diff) | |
| parent | 550dabeacda23f0202d9ff57ac3d344d6b10d654 (diff) | |
Merge "Lazy async group notification views inflation" into main
6 files changed, 37 insertions, 38 deletions
diff --git a/core/java/android/service/notification/StatusBarNotification.java b/core/java/android/service/notification/StatusBarNotification.java index d8210742e331..264b53c6ee40 100644 --- a/core/java/android/service/notification/StatusBarNotification.java +++ b/core/java/android/service/notification/StatusBarNotification.java @@ -174,23 +174,6 @@ public class StatusBarNotification implements Parcelable { return sbnKey; } - /** - * @return Whether the Entry is a group child by the app or system - * @hide - */ - public boolean isAppOrSystemGroupChild() { - return isGroup() && !getNotification().isGroupSummary(); - } - - - /** - * @return Whether the Entry is a group summary by the app or system - * @hide - */ - public boolean isAppOrSystemGroupSummary() { - return isGroup() && getNotification().isGroupSummary(); - } - private String groupKey() { if (overrideGroupKey != null) { return user.getIdentifier() + "|" + pkg + "|" + "g:" + overrideGroupKey; 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 8cdf60b20786..c1dd992b64cd 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 @@ -171,6 +171,9 @@ public final class NotificationEntry extends ListEntry { private boolean mIsMarkedForUserTriggeredMovement; private boolean mIsHeadsUpEntry; + private boolean mHasEverBeenGroupSummary; + private boolean mHasEverBeenGroupChild; + public boolean mRemoteEditImeAnimatingAway; public boolean mRemoteEditImeVisible; private boolean mExpandAnimationRunning; @@ -217,6 +220,26 @@ public final class NotificationEntry extends ListEntry { mIsDemoted = true; } + /** called when entry is currently a summary of a group */ + public void markAsGroupSummary() { + mHasEverBeenGroupSummary = true; + } + + /** whether this entry has ever been marked as a summary */ + public boolean hasEverBeenGroupSummary() { + return mHasEverBeenGroupSummary; + } + + /** called when entry is currently a child in a group */ + public void markAsGroupChild() { + mHasEverBeenGroupChild = true; + } + + /** whether this entry has ever been marked as a child */ + public boolean hasEverBeenGroupChild() { + return mHasEverBeenGroupChild; + } + /** * @param sbn the StatusBarNotification from system server * @param ranking also from system server diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinator.java index 7a7b18450b48..9b075a650b48 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinator.java @@ -49,6 +49,8 @@ import com.android.systemui.statusbar.notification.collection.render.NotifViewBa import com.android.systemui.statusbar.notification.collection.render.NotifViewController; import com.android.systemui.statusbar.notification.row.NotifInflationErrorManager; import com.android.systemui.statusbar.notification.row.NotifInflationErrorManager.NotifInflationErrorListener; +import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation; +import com.android.systemui.statusbar.notification.row.shared.AsyncHybridViewInflation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -273,10 +275,14 @@ public class PreparationCoordinator implements Coordinator { private void inflateRequiredGroupViews(GroupEntry groupEntry) { NotificationEntry summary = groupEntry.getSummary(); + if (summary != null && AsyncGroupHeaderViewInflation.isEnabled()) { + summary.markAsGroupSummary(); + } List<NotificationEntry> children = groupEntry.getChildren(); inflateRequiredNotifViews(summary); for (int j = 0; j < children.size(); j++) { NotificationEntry child = children.get(j); + if (AsyncHybridViewInflation.isEnabled()) child.markAsGroupChild(); boolean childShouldBeBound = j < mChildBindCutoff; if (childShouldBeBound) { inflateRequiredNotifViews(child); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustment.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustment.kt index bab94b50018e..e70fb6b0fdf3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustment.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustment.kt @@ -52,11 +52,8 @@ class NotifUiAdjustment internal constructor( oldAdjustment.needsRedaction != newAdjustment.needsRedaction -> true areDifferent(oldAdjustment.smartActions, newAdjustment.smartActions) -> true newAdjustment.smartReplies != oldAdjustment.smartReplies -> true - // TODO(b/217799515): Here we decide whether to re-inflate the row on every group-status - // change if we want to keep the single-line view, the following line should be: - // !oldAdjustment.isChildInGroup && newAdjustment.isChildInGroup -> true AsyncHybridViewInflation.isEnabled && - oldAdjustment.isChildInGroup != newAdjustment.isChildInGroup -> true + !oldAdjustment.isChildInGroup && newAdjustment.isChildInGroup -> true AsyncGroupHeaderViewInflation.isEnabled && !oldAdjustment.isGroupSummary && newAdjustment.isGroupSummary -> true else -> false diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt index e0e5a3578c31..4c2ef8322731 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt @@ -141,7 +141,7 @@ class NotifUiAdjustmentProvider @Inject constructor( lockscreenUserManager.needsRedaction(entry) || (screenshareNotificationHiding() && sensitiveNotifProtectionController.shouldProtectNotification(entry)), - isChildInGroup = entry.sbn.isAppOrSystemGroupChild, - isGroupSummary = entry.sbn.isAppOrSystemGroupSummary, + isChildInGroup = entry.hasEverBeenGroupChild(), + isGroupSummary = entry.hasEverBeenGroupSummary(), ) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt index 34eeba05906a..8e6ceccbc14e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProviderTest.kt @@ -49,7 +49,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.clearInvocations import org.mockito.Mockito.inOrder -import org.mockito.Mockito.spy import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoMoreInteractions import org.mockito.Mockito.`when` as whenever @@ -158,17 +157,14 @@ class NotifUiAdjustmentProviderTest : SysuiTestCase() { @Test @EnableFlags(AsyncHybridViewInflation.FLAG_NAME) - fun changeIsChildInGroup_asyncHybirdFlagEnabled_needReInflation() { + fun becomeChildInGroup_asyncHybirdFlagEnabled_needReInflation() { // Given: an Entry that is not child in group // AsyncHybridViewInflation flag is enabled - val spySbn = spy(entry.sbn) - entry.sbn = spySbn - whenever(spySbn.isAppOrSystemGroupChild).thenReturn(false) val oldAdjustment = adjustmentProvider.calculateAdjustment(entry) assertThat(oldAdjustment.isChildInGroup).isFalse() // When: the Entry becomes a group child - whenever(spySbn.isAppOrSystemGroupChild).thenReturn(true) + entry.markAsGroupChild() val newAdjustment = adjustmentProvider.calculateAdjustment(entry) assertThat(newAdjustment.isChildInGroup).isTrue() assertThat(newAdjustment).isNotEqualTo(oldAdjustment) @@ -179,17 +175,14 @@ class NotifUiAdjustmentProviderTest : SysuiTestCase() { @Test @DisableFlags(AsyncHybridViewInflation.FLAG_NAME) - fun changeIsChildInGroup_asyncHybirdFlagDisabled_noNeedForReInflation() { + fun becomeChildInGroup_asyncHybirdFlagDisabled_noNeedForReInflation() { // Given: an Entry that is not child in group // AsyncHybridViewInflation flag is disabled - val spySbn = spy(entry.sbn) - entry.sbn = spySbn - whenever(spySbn.isAppOrSystemGroupChild).thenReturn(false) val oldAdjustment = adjustmentProvider.calculateAdjustment(entry) assertThat(oldAdjustment.isChildInGroup).isFalse() // When: the Entry becomes a group child - whenever(spySbn.isAppOrSystemGroupChild).thenReturn(true) + entry.markAsGroupChild() val newAdjustment = adjustmentProvider.calculateAdjustment(entry) assertThat(newAdjustment.isChildInGroup).isTrue() assertThat(newAdjustment).isNotEqualTo(oldAdjustment) @@ -202,14 +195,11 @@ class NotifUiAdjustmentProviderTest : SysuiTestCase() { @EnableFlags(AsyncGroupHeaderViewInflation.FLAG_NAME) fun changeIsGroupSummary_needReInflation() { // Given: an Entry that is not a group summary - val spySbn = spy(entry.sbn) - entry.sbn = spySbn - whenever(spySbn.isAppOrSystemGroupSummary).thenReturn(false) val oldAdjustment = adjustmentProvider.calculateAdjustment(entry) assertThat(oldAdjustment.isGroupSummary).isFalse() // When: the Entry becomes a group summary - whenever(spySbn.isAppOrSystemGroupSummary).thenReturn(true) + entry.markAsGroupSummary() val newAdjustment = adjustmentProvider.calculateAdjustment(entry) assertThat(newAdjustment.isGroupSummary).isTrue() assertThat(newAdjustment).isNotEqualTo(oldAdjustment) |