Add additional logging for ongoing and foreground bubble types.
Bug: 123543171
Test: manual
Change-Id: Id7045fa89632703dec48a3f53b4f3dc6cb11efd8
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index 89abd35..05f4aef 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -583,23 +583,24 @@
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());
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
index 285d4aab..17275ad 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
@@ -723,7 +723,9 @@
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) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 53e65e6..012bd06 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -1070,7 +1070,9 @@
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,
@@ -1082,7 +1084,9 @@
action,
getNormalizedXPosition(),
getNormalizedYPosition(),
- bubble.entry.showInShadeWhenBubble());
+ bubble.entry.showInShadeWhenBubble(),
+ bubble.entry.isForegroundService(),
+ BubbleController.isForegroundApp(mContext, notification.getPackageName()));
}
}
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 f69356e..ce9401c 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
@@ -830,4 +830,12 @@
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;
+ }
}