Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +34 −9 Original line number Original line Diff line number Diff line Loading @@ -23,10 +23,10 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static com.android.systemui.bubbles.BubbleMovementHelper.EDGE_OVERLAP; import static com.android.systemui.bubbles.BubbleMovementHelper.EDGE_OVERLAP; import android.app.Notification; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.content.Context; import android.graphics.Point; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Rect; import android.provider.Settings; import android.service.notification.StatusBarNotification; import android.service.notification.StatusBarNotification; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.WindowManager; import android.view.WindowManager; Loading Loading @@ -57,6 +57,11 @@ public class BubbleController { // When a bubble is dismissed, recreate it as a notification // When a bubble is dismissed, recreate it as a notification public static final boolean DEBUG_DEMOTE_TO_NOTIF = false; public static final boolean DEBUG_DEMOTE_TO_NOTIF = false; // Secure settings private static final String ENABLE_AUTO_BUBBLE_MESSAGES = "experiment_autobubble_messaging"; private static final String ENABLE_AUTO_BUBBLE_ONGOING = "experiment_autobubble_ongoing"; private static final String ENABLE_AUTO_BUBBLE_ALL = "experiment_autobubble_all"; private Context mContext; private Context mContext; private BubbleDismissListener mDismissListener; private BubbleDismissListener mDismissListener; private BubbleStateChangeListener mStateChangeListener; private BubbleStateChangeListener mStateChangeListener; Loading Loading @@ -318,11 +323,15 @@ public class BubbleController { /** /** * Whether the notification should bubble or not. * Whether the notification should bubble or not. */ */ public static boolean shouldAutoBubble(NotificationData.Entry entry, int priority, public static boolean shouldAutoBubble(Context context, NotificationData.Entry entry) { boolean canAppOverlay) { if (entry.isBubbleDismissed()) { if (!DEBUG_ENABLE_AUTO_BUBBLE || entry.isBubbleDismissed()) { return false; return false; } } boolean autoBubbleMessages = shouldAutoBubbleMessages(context) || DEBUG_ENABLE_AUTO_BUBBLE; boolean autoBubbleOngoing = shouldAutoBubbleOngoing(context) || DEBUG_ENABLE_AUTO_BUBBLE; boolean autoBubbleAll = shouldAutoBubbleAll(context) || DEBUG_ENABLE_AUTO_BUBBLE; StatusBarNotification n = entry.notification; StatusBarNotification n = entry.notification; boolean hasRemoteInput = false; boolean hasRemoteInput = false; if (n.getNotification().actions != null) { if (n.getNotification().actions != null) { Loading @@ -333,12 +342,28 @@ public class BubbleController { } } } } } } Class<? extends Notification.Style> style = n.getNotification().getNotificationStyle(); Class<? extends Notification.Style> style = n.getNotification().getNotificationStyle(); boolean shouldBubble = priority >= NotificationManager.IMPORTANCE_HIGH boolean isMessageType = Notification.MessagingStyle.class.equals(style) || Notification.MessagingStyle.class.equals(style) || Notification.CATEGORY_MESSAGE.equals(n.getNotification().category) || Notification.CATEGORY_MESSAGE.equals(n.getNotification().category) || hasRemoteInput || hasRemoteInput; || canAppOverlay; return (isMessageType && autoBubbleMessages) return shouldBubble && !entry.isBubbleDismissed(); || (n.isOngoing() && autoBubbleOngoing) || autoBubbleAll; } private static boolean shouldAutoBubbleMessages(Context context) { return Settings.Secure.getInt(context.getContentResolver(), ENABLE_AUTO_BUBBLE_MESSAGES, 0) != 0; } private static boolean shouldAutoBubbleOngoing(Context context) { return Settings.Secure.getInt(context.getContentResolver(), ENABLE_AUTO_BUBBLE_ONGOING, 0) != 0; } private static boolean shouldAutoBubbleAll(Context context) { return Settings.Secure.getInt(context.getContentResolver(), ENABLE_AUTO_BUBBLE_ALL, 0) != 0; } } } } packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +1 −13 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,6 @@ import static com.android.systemui.statusbar.notification.row.NotificationInflat import android.annotation.Nullable; import android.annotation.Nullable; import android.app.Notification; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.PendingIntent; import android.content.Context; import android.content.Context; Loading Loading @@ -766,7 +765,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } } NotificationData.Entry entry = new NotificationData.Entry(sbn, ranking); NotificationData.Entry entry = new NotificationData.Entry(sbn, ranking); if (shouldAutoBubble(entry)) { if (BubbleController.shouldAutoBubble(getContext(), entry)) { entry.setIsBubble(true); entry.setIsBubble(true); } } Loading Loading @@ -1207,17 +1206,6 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } } } } /** * Whether a bubble is appropriate to auto-bubble or not. */ private boolean shouldAutoBubble(NotificationData.Entry entry) { int priority = mNotificationData.getImportance(entry.key); NotificationChannel channel = mNotificationData.getChannel(entry.key); boolean canAppOverlay = channel != null && channel.canOverlayApps(); return BubbleController.shouldAutoBubble(entry, priority, canAppOverlay); } /** /** * Callback for NotificationEntryManager. * Callback for NotificationEntryManager. */ */ Loading Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +34 −9 Original line number Original line Diff line number Diff line Loading @@ -23,10 +23,10 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static com.android.systemui.bubbles.BubbleMovementHelper.EDGE_OVERLAP; import static com.android.systemui.bubbles.BubbleMovementHelper.EDGE_OVERLAP; import android.app.Notification; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.content.Context; import android.graphics.Point; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Rect; import android.provider.Settings; import android.service.notification.StatusBarNotification; import android.service.notification.StatusBarNotification; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.WindowManager; import android.view.WindowManager; Loading Loading @@ -57,6 +57,11 @@ public class BubbleController { // When a bubble is dismissed, recreate it as a notification // When a bubble is dismissed, recreate it as a notification public static final boolean DEBUG_DEMOTE_TO_NOTIF = false; public static final boolean DEBUG_DEMOTE_TO_NOTIF = false; // Secure settings private static final String ENABLE_AUTO_BUBBLE_MESSAGES = "experiment_autobubble_messaging"; private static final String ENABLE_AUTO_BUBBLE_ONGOING = "experiment_autobubble_ongoing"; private static final String ENABLE_AUTO_BUBBLE_ALL = "experiment_autobubble_all"; private Context mContext; private Context mContext; private BubbleDismissListener mDismissListener; private BubbleDismissListener mDismissListener; private BubbleStateChangeListener mStateChangeListener; private BubbleStateChangeListener mStateChangeListener; Loading Loading @@ -318,11 +323,15 @@ public class BubbleController { /** /** * Whether the notification should bubble or not. * Whether the notification should bubble or not. */ */ public static boolean shouldAutoBubble(NotificationData.Entry entry, int priority, public static boolean shouldAutoBubble(Context context, NotificationData.Entry entry) { boolean canAppOverlay) { if (entry.isBubbleDismissed()) { if (!DEBUG_ENABLE_AUTO_BUBBLE || entry.isBubbleDismissed()) { return false; return false; } } boolean autoBubbleMessages = shouldAutoBubbleMessages(context) || DEBUG_ENABLE_AUTO_BUBBLE; boolean autoBubbleOngoing = shouldAutoBubbleOngoing(context) || DEBUG_ENABLE_AUTO_BUBBLE; boolean autoBubbleAll = shouldAutoBubbleAll(context) || DEBUG_ENABLE_AUTO_BUBBLE; StatusBarNotification n = entry.notification; StatusBarNotification n = entry.notification; boolean hasRemoteInput = false; boolean hasRemoteInput = false; if (n.getNotification().actions != null) { if (n.getNotification().actions != null) { Loading @@ -333,12 +342,28 @@ public class BubbleController { } } } } } } Class<? extends Notification.Style> style = n.getNotification().getNotificationStyle(); Class<? extends Notification.Style> style = n.getNotification().getNotificationStyle(); boolean shouldBubble = priority >= NotificationManager.IMPORTANCE_HIGH boolean isMessageType = Notification.MessagingStyle.class.equals(style) || Notification.MessagingStyle.class.equals(style) || Notification.CATEGORY_MESSAGE.equals(n.getNotification().category) || Notification.CATEGORY_MESSAGE.equals(n.getNotification().category) || hasRemoteInput || hasRemoteInput; || canAppOverlay; return (isMessageType && autoBubbleMessages) return shouldBubble && !entry.isBubbleDismissed(); || (n.isOngoing() && autoBubbleOngoing) || autoBubbleAll; } private static boolean shouldAutoBubbleMessages(Context context) { return Settings.Secure.getInt(context.getContentResolver(), ENABLE_AUTO_BUBBLE_MESSAGES, 0) != 0; } private static boolean shouldAutoBubbleOngoing(Context context) { return Settings.Secure.getInt(context.getContentResolver(), ENABLE_AUTO_BUBBLE_ONGOING, 0) != 0; } private static boolean shouldAutoBubbleAll(Context context) { return Settings.Secure.getInt(context.getContentResolver(), ENABLE_AUTO_BUBBLE_ALL, 0) != 0; } } } }
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +1 −13 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,6 @@ import static com.android.systemui.statusbar.notification.row.NotificationInflat import android.annotation.Nullable; import android.annotation.Nullable; import android.app.Notification; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.PendingIntent; import android.content.Context; import android.content.Context; Loading Loading @@ -766,7 +765,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } } NotificationData.Entry entry = new NotificationData.Entry(sbn, ranking); NotificationData.Entry entry = new NotificationData.Entry(sbn, ranking); if (shouldAutoBubble(entry)) { if (BubbleController.shouldAutoBubble(getContext(), entry)) { entry.setIsBubble(true); entry.setIsBubble(true); } } Loading Loading @@ -1207,17 +1206,6 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } } } } /** * Whether a bubble is appropriate to auto-bubble or not. */ private boolean shouldAutoBubble(NotificationData.Entry entry) { int priority = mNotificationData.getImportance(entry.key); NotificationChannel channel = mNotificationData.getChannel(entry.key); boolean canAppOverlay = channel != null && channel.canOverlayApps(); return BubbleController.shouldAutoBubble(entry, priority, canAppOverlay); } /** /** * Callback for NotificationEntryManager. * Callback for NotificationEntryManager. */ */ Loading