diff options
9 files changed, 15 insertions, 178 deletions
diff --git a/core/java/com/android/internal/config/sysui/SystemUiSystemPropertiesFlags.java b/core/java/com/android/internal/config/sysui/SystemUiSystemPropertiesFlags.java index 81cd28023777..10336bd36c28 100644 --- a/core/java/com/android/internal/config/sysui/SystemUiSystemPropertiesFlags.java +++ b/core/java/com/android/internal/config/sysui/SystemUiSystemPropertiesFlags.java @@ -66,10 +66,6 @@ public class SystemUiSystemPropertiesFlags { public static final Flag SHOW_STICKY_HUN_FOR_DENIED_FSI = releasedFlag("persist.sysui.notification.show_sticky_hun_for_denied_fsi"); - /** Gating the ability for users to dismiss ongoing event notifications */ - public static final Flag ALLOW_DISMISS_ONGOING = - releasedFlag("persist.sysui.notification.ongoing_dismissal"); - /** Gating the redaction of OTP notifications on the lockscreen */ public static final Flag OTP_REDACTION = devFlag("persist.sysui.notification.otp_redaction"); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotifPipelineFlags.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotifPipelineFlags.kt index 577ad20cb5d4..bac898279c97 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotifPipelineFlags.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotifPipelineFlags.kt @@ -16,8 +16,6 @@ package com.android.systemui.statusbar.notification -import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.FlagResolver -import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags import javax.inject.Inject @@ -25,12 +23,8 @@ import javax.inject.Inject class NotifPipelineFlags @Inject constructor( - private val featureFlags: FeatureFlags, - private val sysPropFlags: FlagResolver, + private val featureFlags: FeatureFlags ) { fun isDevLoggingEnabled(): Boolean = featureFlags.isEnabled(Flags.NOTIFICATION_PIPELINE_DEVELOPER_LOGGING) - - fun allowDismissOngoing(): Boolean = - sysPropFlags.isEnabled(NotificationFlags.ALLOW_DISMISS_ONGOING) } 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 789873675bfa..affd2d186774 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 @@ -791,28 +791,6 @@ public final class NotificationEntry extends ListEntry { return !mSbn.isOngoing() || !isLocked; } - /** - * @return Can the underlying notification be individually dismissed? - * @see #canViewBeDismissed() - */ - // TODO: This logic doesn't belong on NotificationEntry. It should be moved to a controller - // that can be added as a dependency to any class that needs to answer this question. - public boolean legacyIsDismissableRecursive() { - if (mSbn.isOngoing()) { - return false; - } - List<NotificationEntry> children = getAttachedNotifChildren(); - if (children != null && children.size() > 0) { - for (int i = 0; i < children.size(); i++) { - NotificationEntry child = children.get(i); - if (child.getSbn().isOngoing()) { - return false; - } - } - } - return true; - } - public boolean canViewBeDismissed() { if (row == null) return true; return row.canViewBeDismissed(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/NotificationDismissibilityProviderImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/NotificationDismissibilityProviderImpl.kt index b31825207132..78e9a740a547 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/NotificationDismissibilityProviderImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/NotificationDismissibilityProviderImpl.kt @@ -20,7 +20,6 @@ import androidx.annotation.VisibleForTesting import com.android.systemui.Dumpable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager -import com.android.systemui.statusbar.notification.NotifPipelineFlags import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.util.asIndenting import com.android.systemui.util.withIncreasedIndent @@ -28,9 +27,7 @@ import java.io.PrintWriter import javax.inject.Inject @SysUISingleton -class NotificationDismissibilityProviderImpl -@Inject -constructor(private val notifPipelineFlags: NotifPipelineFlags, dumpManager: DumpManager) : +class NotificationDismissibilityProviderImpl @Inject constructor(dumpManager: DumpManager) : NotificationDismissibilityProvider, Dumpable { init { @@ -43,11 +40,7 @@ constructor(private val notifPipelineFlags: NotifPipelineFlags, dumpManager: Dum private set override fun isDismissable(entry: NotificationEntry): Boolean { - return if (notifPipelineFlags.allowDismissOngoing()) { - entry.key !in nonDismissableEntryKeys - } else { - entry.legacyIsDismissableRecursive() - } + return entry.key !in nonDismissableEntryKeys } @Synchronized diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java b/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java index a5365fbc3d5d..2acd4b92c5a2 100644 --- a/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java +++ b/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java @@ -621,13 +621,9 @@ public class BubblesManager { } private boolean isDismissableFromBubbles(NotificationEntry e) { - if (mNotifPipelineFlags.allowDismissOngoing()) { - // Bubbles are only accessible from the unlocked state, - // so we can calculate this from the Notification flags only. - return e.isDismissableForState(/*isLocked=*/ false); - } else { - return e.legacyIsDismissableRecursive(); - } + // Bubbles are only accessible from the unlocked state, + // so we can calculate this from the Notification flags only. + return e.isDismissableForState(/*isLocked=*/ false); } private boolean shouldBubbleUp(NotificationEntry e) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/DismissibilityCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/DismissibilityCoordinatorTest.kt index ed249471ed27..f91e5a8cf626 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/DismissibilityCoordinatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/DismissibilityCoordinatorTest.kt @@ -21,7 +21,6 @@ import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.dump.DumpManager -import com.android.systemui.statusbar.notification.NotifPipelineFlags import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder import com.android.systemui.statusbar.notification.collection.NotifPipeline import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder @@ -47,14 +46,11 @@ class DismissibilityCoordinatorTest : SysuiTestCase() { private lateinit var onBeforeRenderListListener: OnBeforeRenderListListener private val keyguardStateController: KeyguardStateController = mock() private val pipeline: NotifPipeline = mock() - private val flags: NotifPipelineFlags = mock() private val dumpManager: DumpManager = mock() @Before fun setUp() { - whenever(flags.allowDismissOngoing()).thenReturn(true) - - dismissibilityProvider = NotificationDismissibilityProviderImpl(flags, dumpManager) + dismissibilityProvider = NotificationDismissibilityProviderImpl(dumpManager) coordinator = DismissibilityCoordinator(keyguardStateController, dismissibilityProvider) coordinator.attach(pipeline) onBeforeRenderListListener = withArgCaptor { @@ -309,57 +305,4 @@ class DismissibilityCoordinatorTest : SysuiTestCase() { dismissibilityProvider.isDismissable(summary) ) } - - @Test - fun testFeatureToggleOffNonDismissibleEntry() { - whenever(flags.allowDismissOngoing()).thenReturn(false) - val entry = - NotificationEntryBuilder() - .setTag("entry") - .setFlag(mContext, Notification.FLAG_NO_DISMISS, true) - .build() - - onBeforeRenderListListener.onBeforeRenderList(listOf(entry)) - - assertTrue( - "FLAG_NO_DISMISS should be ignored, if the feature is off", - dismissibilityProvider.isDismissable(entry) - ) - } - - @Test - fun testFeatureToggleOffOngoingNotifWhenPhoneIsLocked() { - whenever(flags.allowDismissOngoing()).thenReturn(false) - whenever(keyguardStateController.isUnlocked).thenReturn(false) - val entry = - NotificationEntryBuilder() - .setTag("entry") - .setFlag(mContext, Notification.FLAG_ONGOING_EVENT, true) - .build() - - onBeforeRenderListListener.onBeforeRenderList(listOf(entry)) - - assertFalse( - "Ongoing Notifs should NOT be dismissible, if the feature is off", - dismissibilityProvider.isDismissable(entry) - ) - } - - @Test - fun testFeatureToggleOffOngoingNotifWhenPhoneIsUnLocked() { - whenever(flags.allowDismissOngoing()).thenReturn(false) - whenever(keyguardStateController.isUnlocked).thenReturn(true) - val entry = - NotificationEntryBuilder() - .setTag("entry") - .setFlag(mContext, Notification.FLAG_ONGOING_EVENT, true) - .build() - - onBeforeRenderListListener.onBeforeRenderList(listOf(entry)) - - assertFalse( - "Ongoing Notifs should NOT be dismissible, if the feature is off", - dismissibilityProvider.isDismissable(entry) - ) - } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index 17bb73b94ac2..820e2a031a0e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -1846,8 +1846,7 @@ public class BubblesTest extends SysuiTestCase { } @Test - public void testCreateBubbleFromOngoingNotification_OngoingDismissalEnabled() { - when(mNotifPipelineFlags.allowDismissOngoing()).thenReturn(true); + public void testCreateBubbleFromOngoingNotification() { NotificationEntry notif = new NotificationEntryBuilder() .setFlag(mContext, Notification.FLAG_ONGOING_EVENT, true) .setCanBubble(true) @@ -1860,8 +1859,7 @@ public class BubblesTest extends SysuiTestCase { @Test - public void testCreateBubbleFromNoDismissNotification_OngoingDismissalEnabled() { - when(mNotifPipelineFlags.allowDismissOngoing()).thenReturn(true); + public void testCreateBubbleFromNoDismissNotification() { NotificationEntry notif = new NotificationEntryBuilder() .setFlag(mContext, Notification.FLAG_NO_DISMISS, true) .setCanBubble(true) @@ -1873,37 +1871,6 @@ public class BubblesTest extends SysuiTestCase { } @Test - public void testCreateBubbleFromOngoingNotification_OngoingDismissalDisabled() { - NotificationEntry notif = new NotificationEntryBuilder() - .setFlag(mContext, Notification.FLAG_ONGOING_EVENT, true) - .setCanBubble(true) - .build(); - - BubbleEntry bubble = mBubblesManager.notifToBubbleEntry(notif); - - assertFalse( - "Ongoing Notifis should be dismissable, if the feature is off", - bubble.isDismissable() - ); - } - - - @Test - public void testCreateBubbleFromNoDismissNotification_OngoingDismissalDisabled() { - NotificationEntry notif = new NotificationEntryBuilder() - .setFlag(mContext, Notification.FLAG_NO_DISMISS, true) - .setCanBubble(true) - .build(); - - BubbleEntry bubble = mBubblesManager.notifToBubbleEntry(notif); - - assertTrue( - "FLAG_NO_DISMISS should be ignored, if the feature is off", - bubble.isDismissable() - ); - } - - @Test public void registerBubbleBarListener_barDisabled_largeScreen_shouldBeIgnored() { mBubbleProperties.mIsBubbleBarEnabled = false; mPositioner.setIsLargeScreen(true); diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index ba4ec91d84df..37879effc41c 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -118,7 +118,6 @@ import static android.service.notification.NotificationListenerService.TRIM_FULL import static android.service.notification.NotificationListenerService.TRIM_LIGHT; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; -import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.ALLOW_DISMISS_ONGOING; import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.WAKE_LOCK_FOR_POSTING_NOTIFICATION; import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES; @@ -1221,8 +1220,7 @@ public class NotificationManagerService extends SystemService { } } - int mustNotHaveFlags = mFlagResolver.isEnabled(ALLOW_DISMISS_ONGOING) - ? FLAG_NO_DISMISS : FLAG_ONGOING_EVENT; + int mustNotHaveFlags = FLAG_NO_DISMISS; cancelNotification(callingUid, callingPid, pkg, tag, id, /* mustHaveFlags= */ 0, /* mustNotHaveFlags= */ mustNotHaveFlags, @@ -6865,13 +6863,11 @@ public class NotificationManagerService extends SystemService { } // Only notifications that can be non-dismissible can have the flag FLAG_NO_DISMISS - if (mFlagResolver.isEnabled(ALLOW_DISMISS_ONGOING)) { - if (((notification.flags & FLAG_ONGOING_EVENT) > 0) - && canBeNonDismissible(ai, notification)) { - notification.flags |= FLAG_NO_DISMISS; - } else { - notification.flags &= ~FLAG_NO_DISMISS; - } + if (((notification.flags & FLAG_ONGOING_EVENT) > 0) + && canBeNonDismissible(ai, notification)) { + notification.flags |= FLAG_NO_DISMISS; + } else { + notification.flags &= ~FLAG_NO_DISMISS; } int canColorize = getContext().checkPermission( diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index f552ab2dab60..0292bca06813 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -81,7 +81,6 @@ import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; -import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.ALLOW_DISMISS_ONGOING; import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.FSI_FORCE_DEMOTE; import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.SHOW_STICKY_HUN_FOR_DENIED_FSI; import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.WAKE_LOCK_FOR_POSTING_NOTIFICATION; @@ -11204,8 +11203,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { ai.packageName)).thenReturn(AppOpsManager.MODE_IGNORED); // Given: a notification from an app on the system partition has the flag // FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); @@ -11221,8 +11218,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { public void fixMediaNotification_withOnGoingFlag_shouldBeNonDismissible() throws Exception { // Given: a media notification has the flag FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .setStyle(new Notification.MediaStyle() @@ -11251,8 +11246,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { ai.packageName)).thenReturn(AppOpsManager.MODE_IGNORED); // Given: a notification from an app on the system partition has the flag // FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); @@ -11268,9 +11261,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { public void fixCallNotification_withOnGoingFlag_shouldNotBeNonDismissible() throws Exception { // Given: a call notification has the flag FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); - Person person = new Person.Builder() .setName("caller") .build(); @@ -11291,8 +11281,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void fixNonExemptNotification_withOnGoingFlag_shouldBeDismissible() throws Exception { // Given: a non-exempt notification has the flag FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); @@ -11309,8 +11297,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { throws Exception { // Given: a non-exempt notification has the flag FLAG_NO_DISMISS set (even though this is // not allowed) - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); Notification n = new Notification.Builder(mContext, "test") .build(); n.flags |= Notification.FLAG_NO_DISMISS; @@ -11325,8 +11311,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void fixMediaNotification_withoutOnGoingFlag_shouldBeDismissible() throws Exception { // Given: a media notification doesn't have the flag FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(false) .setStyle(new Notification.MediaStyle() @@ -11345,8 +11329,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { throws Exception { // Given: a media notification doesn't have the flag FLAG_ONGOING_EVENT set, // but has the flag FLAG_NO_DISMISS set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(false) .setStyle(new Notification.MediaStyle() @@ -11365,8 +11347,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { public void fixNonExempt_Notification_withoutOnGoingFlag_shouldBeDismissible() throws Exception { // Given: a non-exempt notification has the flag FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(false) .build(); @@ -11383,8 +11363,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { throws Exception { when(mDevicePolicyManager.isActiveDeviceOwner(mUid)).thenReturn(true); // Given: a notification has the flag FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); setDpmAppOppsExemptFromDismissal(false); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) @@ -11411,8 +11389,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, mUid, PKG)).thenReturn(AppOpsManager.MODE_ALLOWED); // Given: a notification has the flag FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); setDpmAppOppsExemptFromDismissal(true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) @@ -11432,8 +11408,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, mUid, PKG)).thenReturn(AppOpsManager.MODE_ALLOWED); // Given: a notification has the flag FLAG_ONGOING_EVENT set - // feature flag: ALLOW_DISMISS_ONGOING is on - mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); setDpmAppOppsExemptFromDismissal(false); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) |