Loading cmds/statsd/src/atoms.proto +6 −0 Original line number Diff line number Diff line Loading @@ -5592,6 +5592,12 @@ message BubbleUIChanged { // Whether the bubble is unread. If it is unread, a dot is shown in the bubble stack icon. optional bool is_unread = 9; // Whether the bubble is an on-going one. optional bool is_ongoing = 10; // Whether the bubble is produced by an app running in foreground. optional bool is_foreground = 11; } /** Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +5 −4 Original line number Diff line number Diff line Loading @@ -585,23 +585,24 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe private boolean shouldAutoExpand(NotificationEntry entry) { Notification.BubbleMetadata metadata = entry.getBubbleMetadata(); return metadata != null && metadata.getAutoExpandBubble() && isForegroundApp(entry.notification.getPackageName()); && isForegroundApp(mContext, entry.notification.getPackageName()); } private void updateShowInShadeForSuppressNotification(NotificationEntry entry) { boolean suppressNotification = entry.getBubbleMetadata() != null && entry.getBubbleMetadata().getSuppressNotification() && isForegroundApp(entry.notification.getPackageName()); && isForegroundApp(mContext, entry.notification.getPackageName()); entry.setShowInShadeWhenBubble(!suppressNotification); } /** * Return true if the applications with the package name is running in foreground. * * @param context application context. * @param pkgName application package name. */ private boolean isForegroundApp(String pkgName) { ActivityManager am = mContext.getSystemService(ActivityManager.class); public static boolean isForegroundApp(Context context, String pkgName) { ActivityManager am = context.getSystemService(ActivityManager.class); List<RunningTaskInfo> tasks = am.getRunningTasks(1 /* maxNum */); return !tasks.isEmpty() && pkgName.equals(tasks.get(0).topActivity.getPackageName()); } Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +3 −1 Original line number Diff line number Diff line Loading @@ -723,7 +723,9 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList action, mStackView.getNormalizedXPosition(), mStackView.getNormalizedYPosition(), entry.showInShadeWhenBubble()); entry.showInShadeWhenBubble(), entry.isForegroundService(), BubbleController.isForegroundApp(mContext, notification.getPackageName())); } private int getDimenForPackageUser(int resId, String pkg, int userId) { Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +6 −2 Original line number Diff line number Diff line Loading @@ -1107,7 +1107,9 @@ public class BubbleStackView extends FrameLayout { action, getNormalizedXPosition(), getNormalizedYPosition(), false /* unread notification */); false /* unread bubble */, false /* on-going bubble */, false /* foreground bubble */); } else { StatusBarNotification notification = bubble.entry.notification; StatsLog.write(StatsLog.BUBBLE_UI_CHANGED, Loading @@ -1119,7 +1121,9 @@ public class BubbleStackView extends FrameLayout { action, getNormalizedXPosition(), getNormalizedYPosition(), bubble.entry.showInShadeWhenBubble()); bubble.entry.showInShadeWhenBubble(), bubble.entry.isForegroundService(), BubbleController.isForegroundApp(mContext, notification.getPackageName())); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +8 −0 Original line number Diff line number Diff line Loading @@ -830,4 +830,12 @@ public final class NotificationEntry { this.index = index; } } /** * Returns whether the notification is a foreground service. It shows that this is an ongoing * bubble. */ public boolean isForegroundService() { return (notification.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0; } } Loading
cmds/statsd/src/atoms.proto +6 −0 Original line number Diff line number Diff line Loading @@ -5592,6 +5592,12 @@ message BubbleUIChanged { // Whether the bubble is unread. If it is unread, a dot is shown in the bubble stack icon. optional bool is_unread = 9; // Whether the bubble is an on-going one. optional bool is_ongoing = 10; // Whether the bubble is produced by an app running in foreground. optional bool is_foreground = 11; } /** Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +5 −4 Original line number Diff line number Diff line Loading @@ -585,23 +585,24 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe private boolean shouldAutoExpand(NotificationEntry entry) { Notification.BubbleMetadata metadata = entry.getBubbleMetadata(); return metadata != null && metadata.getAutoExpandBubble() && isForegroundApp(entry.notification.getPackageName()); && isForegroundApp(mContext, entry.notification.getPackageName()); } private void updateShowInShadeForSuppressNotification(NotificationEntry entry) { boolean suppressNotification = entry.getBubbleMetadata() != null && entry.getBubbleMetadata().getSuppressNotification() && isForegroundApp(entry.notification.getPackageName()); && isForegroundApp(mContext, entry.notification.getPackageName()); entry.setShowInShadeWhenBubble(!suppressNotification); } /** * Return true if the applications with the package name is running in foreground. * * @param context application context. * @param pkgName application package name. */ private boolean isForegroundApp(String pkgName) { ActivityManager am = mContext.getSystemService(ActivityManager.class); public static boolean isForegroundApp(Context context, String pkgName) { ActivityManager am = context.getSystemService(ActivityManager.class); List<RunningTaskInfo> tasks = am.getRunningTasks(1 /* maxNum */); return !tasks.isEmpty() && pkgName.equals(tasks.get(0).topActivity.getPackageName()); } Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +3 −1 Original line number Diff line number Diff line Loading @@ -723,7 +723,9 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList action, mStackView.getNormalizedXPosition(), mStackView.getNormalizedYPosition(), entry.showInShadeWhenBubble()); entry.showInShadeWhenBubble(), entry.isForegroundService(), BubbleController.isForegroundApp(mContext, notification.getPackageName())); } private int getDimenForPackageUser(int resId, String pkg, int userId) { Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +6 −2 Original line number Diff line number Diff line Loading @@ -1107,7 +1107,9 @@ public class BubbleStackView extends FrameLayout { action, getNormalizedXPosition(), getNormalizedYPosition(), false /* unread notification */); false /* unread bubble */, false /* on-going bubble */, false /* foreground bubble */); } else { StatusBarNotification notification = bubble.entry.notification; StatsLog.write(StatsLog.BUBBLE_UI_CHANGED, Loading @@ -1119,7 +1121,9 @@ public class BubbleStackView extends FrameLayout { action, getNormalizedXPosition(), getNormalizedYPosition(), bubble.entry.showInShadeWhenBubble()); bubble.entry.showInShadeWhenBubble(), bubble.entry.isForegroundService(), BubbleController.isForegroundApp(mContext, notification.getPackageName())); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +8 −0 Original line number Diff line number Diff line Loading @@ -830,4 +830,12 @@ public final class NotificationEntry { this.index = index; } } /** * Returns whether the notification is a foreground service. It shows that this is an ongoing * bubble. */ public boolean isForegroundService() { return (notification.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0; } }