From c4f298c72c2c89b4facb7ff9b5075db2b6badc91 Mon Sep 17 00:00:00 2001 From: Ibrahim Yilmaz Date: Fri, 19 May 2023 17:08:42 +0000 Subject: Fix isExpanded behavior for sensitive notifications ENR#isExpanded returns true for sensitive notifications when the state is not shade. Expected behavior for isExpanded method for this case is to return false. In order to achieve this, we return false in isExpanded for sensitive notifications when the system set setHideSensitive true. Bug: 275457408 Test: atest ExpandableNotificationRowTest Change-Id: I8509e910dc0ce2e7b3796c5682bc6949dfa87b6b --- .../row/ExpandableNotificationRow.java | 9 ++++++- .../row/ExpandableNotificationRowTest.java | 30 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 9f397fe9ac0c..0bfd3c3c0b2b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -2673,7 +2673,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } public boolean isExpanded(boolean allowOnKeyguard) { - return (!mOnKeyguard || allowOnKeyguard) + if (DEBUG) { + if (!mShowingPublicInitialized && !allowOnKeyguard) { + Log.d(TAG, "mShowingPublic is not initialized."); + } + } + return !mShowingPublic && (!mOnKeyguard || allowOnKeyguard) && (!hasUserChangedExpansion() && (isSystemExpanded() || isSystemChildExpanded()) || isUserExpanded()); } @@ -3620,6 +3625,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView pw.print(", mOnUserInteractionCallback null: " + (mOnUserInteractionCallback == null)); pw.print(", removed: " + isRemoved()); pw.print(", expandAnimationRunning: " + mExpandAnimationRunning); + pw.print(", mShowingPublic: " + mShowingPublic); + pw.print(", mShowingPublicInitialized: " + mShowingPublicInitialized); NotificationContentView showingLayout = getShowingLayout(); pw.print(", privateShowing: " + (showingLayout == mPrivateLayout)); pw.println(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java index 4c83194783ab..608778e05dad 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java @@ -733,6 +733,36 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { verify(lowPriVectorDrawable, times(1)).start(); } + @Test + public void isExpanded_hideSensitive_sensitiveNotExpanded() + throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setUserExpanded(true); + row.setOnKeyguard(false); + row.setSensitive(/* sensitive= */true, /* hideSensitive= */false); + row.setHideSensitive(/* hideSensitive= */true, /* animated= */false, + /* delay= */0L, /* duration= */0L); + + // THEN + assertThat(row.isExpanded()).isFalse(); + } + + @Test + public void isExpanded_hideSensitive_nonSensitiveExpanded() + throws Exception { + // GIVEN + final ExpandableNotificationRow row = mNotificationTestHelper.createRow(); + row.setUserExpanded(true); + row.setOnKeyguard(false); + row.setSensitive(/* sensitive= */true, /* hideSensitive= */false); + row.setHideSensitive(/* hideSensitive= */false, /* animated= */false, + /* delay= */0L, /* duration= */0L); + + // THEN + assertThat(row.isExpanded()).isTrue(); + } + private void setDrawableIconsInImageView(CachingIconView icon, Drawable iconDrawable, Drawable rightIconDrawable) { ImageView iconView = mock(ImageView.class); -- cgit v1.2.3-59-g8ed1b