diff options
| author | 2019-12-06 18:33:42 +0000 | |
|---|---|---|
| committer | 2019-12-06 18:33:42 +0000 | |
| commit | 7cf31e98d5996d2f099c43d931bf51da9080cb9b (patch) | |
| tree | 5fdd635ac57c75601c90cad98cc04cf7c1be4610 | |
| parent | addd10c6d20ee3aae00da1d87f20878e856e1a15 (diff) | |
| parent | ea13b234e5e4415d72408028c1b707de1c106427 (diff) | |
Merge "Allow a list of packages to be whitelisted to auto-bubble"
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java | 8 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java | 28 |
2 files changed, 33 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index 2966aeff5616..dbb193669083 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -699,6 +699,10 @@ public class BubbleController implements ConfigurationController.ConfigurationLi if (mNotificationInterruptionStateProvider.shouldBubbleUp(entry) && (canLaunchInActivityView(mContext, entry) || wasAdjusted)) { + if (wasAdjusted && !previouslyUserCreated) { + // Gotta treat the auto-bubbled / whitelisted packaged bubbles as usercreated + mUserCreatedBubbles.add(entry.getKey()); + } updateBubble(entry); } } @@ -715,6 +719,10 @@ public class BubbleController implements ConfigurationController.ConfigurationLi // It was previously a bubble but no longer a bubble -- lets remove it removeBubble(entry.getKey(), DISMISS_NO_LONGER_BUBBLE); } else if (shouldBubble) { + if (wasAdjusted && !previouslyUserCreated) { + // Gotta treat the auto-bubbled / whitelisted packaged bubbles as usercreated + mUserCreatedBubbles.add(entry.getKey()); + } updateBubble(entry); } } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java index fd7fff4112c8..e138d9387ca6 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java @@ -66,6 +66,8 @@ public class BubbleExperimentConfig { private static final String ALLOW_SHORTCUTS_TO_BUBBLE = "allow_shortcuts_to_bubble"; private static final boolean ALLOW_SHORTCUT_TO_BUBBLE_DEFAULT = false; + private static final String WHITELISTED_AUTO_BUBBLE_APPS = "whitelisted_auto_bubble_apps"; + /** * When true, if a notification has the information necessary to bubble (i.e. valid * contentIntent and an icon or image), then a {@link android.app.Notification.BubbleMetadata} @@ -103,6 +105,24 @@ public class BubbleExperimentConfig { } /** + * Returns whether the provided package is whitelisted to bubble. + */ + static boolean isPackageWhitelistedToAutoBubble(Context context, String packageName) { + String unsplitList = Settings.Secure.getString(context.getContentResolver(), + WHITELISTED_AUTO_BUBBLE_APPS); + if (unsplitList != null) { + // We expect the list to be separated by commas and no white space (but we trim in case) + String[] packageList = unsplitList.split(","); + for (int i = 0; i < packageList.length; i++) { + if (packageList[i].trim().equals(packageName)) { + return true; + } + } + } + return false; + } + + /** * If {@link #allowAnyNotifToBubble(Context)} is true, this method creates and adds * {@link android.app.Notification.BubbleMetadata} to the notification entry as long as * the notification has necessary info for BubbleMetadata. @@ -113,6 +133,8 @@ public class BubbleExperimentConfig { boolean previouslyUserCreated) { Notification.BubbleMetadata metadata = null; boolean addedMetadata = false; + boolean whiteListedToAutoBubble = + isPackageWhitelistedToAutoBubble(context, entry.getSbn().getPackageName()); Notification notification = entry.getSbn().getNotification(); boolean isMessage = Notification.MessagingStyle.class.equals( @@ -170,9 +192,9 @@ public class BubbleExperimentConfig { } } - if (previouslyUserCreated && addedMetadata) { - // Update to a previous bubble, set its flag now so the update goes - // to the bubble. + boolean bubbleForWhitelist = whiteListedToAutoBubble && (addedMetadata || hasMetadata); + if ((previouslyUserCreated && addedMetadata) || bubbleForWhitelist) { + // Update to a previous bubble (or new autobubble), set its flag now. if (DEBUG_EXPERIMENTS) { Log.d(TAG, "Setting FLAG_BUBBLE for: " + entry.getKey()); } |