diff options
| author | 2019-12-11 13:15:41 -0800 | |
|---|---|---|
| committer | 2019-12-11 13:30:12 -0800 | |
| commit | 3b86a4f26a46ff770d263dffefcaadec6310d655 (patch) | |
| tree | 34998a8e87befdaf875b215f0b1aec10bc13793f | |
| parent | 701fa18ee308d9ea69f92b25b75be426024ddb05 (diff) | |
Track bubbles that were whitelisted & blocked, don't bubble blocked ones
The experiment to whitelist packages to auto-bubble doesn't allow you
to specify specific notifs to be blocked (you can longpress on the notif
and change it but it won't work). This CL fixes that behaviour by tracking
when a user blocks one of these.
Bug: 145763712
Test: manual:
1) In people version of test app, disable bubble metadata
2) adb shell settings put secure allow_message_notifs_to_bubble 1
3) adb shell settings put secure whitelisted_auto_bubble_apps com.google.android.samples.bubbles
4) double tap on each person in test app to produce notifs
=> notice they are all bubbles
5) longpress on a notif and put it to "alert" instead of bubble
=> notice that that bubble is removed from stack if it was there
6) get notif from person you blocked
=> it does not bubble
7) longpress on that notif to "bubble" it again
=> it bubbles
8) dismiss stack & get new notif from that person
=> it bubbles
Change-Id: I89977fa63d7581c83d539af76e4e70ae82737cbf
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java | 18 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java | 6 |
2 files changed, 20 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index 19381940543e..4b75696fa256 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -162,6 +162,10 @@ public class BubbleController implements ConfigurationController.ConfigurationLi // Saves notification keys of user created "fake" bubbles so that we can allow notifications // like these to bubble by default. Doesn't persist across reboots, not a long-term solution. private final HashSet<String> mUserCreatedBubbles; + // If we're auto-bubbling bubbles via a whitelist, we need to track which notifs from that app + // have been "demoted" back to a notification so that we don't auto-bubbles those again. + // Doesn't persist across reboots, not a long-term solution. + private final HashSet<String> mUserBlockedBubbles; // Bubbles get added to the status bar view private final StatusBarWindowController mStatusBarWindowController; @@ -348,6 +352,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi }); mUserCreatedBubbles = new HashSet<>(); + mUserBlockedBubbles = new HashSet<>(); mScreenshotHelper = new ScreenshotHelper(context); } @@ -583,6 +588,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi entry.setFlagBubble(true); updateBubble(entry, true /* suppressFlyout */, false /* showInShade */); mUserCreatedBubbles.add(entry.getKey()); + mUserBlockedBubbles.remove(entry.getKey()); } /** @@ -598,6 +604,12 @@ public class BubbleController implements ConfigurationController.ConfigurationLi entry.setFlagBubble(false); removeBubble(entry.getKey(), DISMISS_BLOCKED); mUserCreatedBubbles.remove(entry.getKey()); + if (BubbleExperimentConfig.isPackageWhitelistedToAutoBubble( + mContext, entry.getSbn().getPackageName())) { + // This package is whitelist but user demoted the bubble, let's save it so we don't + // auto-bubble for the whitelist again. + mUserBlockedBubbles.add(entry.getKey()); + } } /** @@ -727,8 +739,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi @Override public void onPendingEntryAdded(NotificationEntry entry) { boolean previouslyUserCreated = mUserCreatedBubbles.contains(entry.getKey()); + boolean userBlocked = mUserBlockedBubbles.contains(entry.getKey()); boolean wasAdjusted = BubbleExperimentConfig.adjustForExperiments( - mContext, entry, previouslyUserCreated); + mContext, entry, previouslyUserCreated, userBlocked); if (mNotificationInterruptionStateProvider.shouldBubbleUp(entry) && (canLaunchInActivityView(mContext, entry) || wasAdjusted)) { @@ -743,8 +756,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi @Override public void onPreEntryUpdated(NotificationEntry entry) { boolean previouslyUserCreated = mUserCreatedBubbles.contains(entry.getKey()); + boolean userBlocked = mUserBlockedBubbles.contains(entry.getKey()); boolean wasAdjusted = BubbleExperimentConfig.adjustForExperiments( - mContext, entry, previouslyUserCreated); + mContext, entry, previouslyUserCreated, userBlocked); boolean shouldBubble = mNotificationInterruptionStateProvider.shouldBubbleUp(entry) && (canLaunchInActivityView(mContext, entry) || wasAdjusted); diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java index 8299f2261b8e..ac0e7bb226c4 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java @@ -143,7 +143,7 @@ public class BubbleExperimentConfig { * @return whether an adjustment was made. */ static boolean adjustForExperiments(Context context, NotificationEntry entry, - boolean previouslyUserCreated) { + boolean previouslyUserCreated, boolean userBlocked) { Notification.BubbleMetadata metadata = null; boolean addedMetadata = false; boolean whiteListedToAutoBubble = @@ -205,7 +205,9 @@ public class BubbleExperimentConfig { } } - boolean bubbleForWhitelist = whiteListedToAutoBubble && (addedMetadata || hasMetadata); + boolean bubbleForWhitelist = !userBlocked + && whiteListedToAutoBubble + && (addedMetadata || hasMetadata); if ((previouslyUserCreated && addedMetadata) || bubbleForWhitelist) { // Update to a previous bubble (or new autobubble), set its flag now. if (DEBUG_EXPERIMENTS) { |