Add dumpsys for bubble state
Test: adb shell dumpsys activity service com.android.systemui | grep -A 50 BubbleController
Change-Id: I33dfd315492870cd9a8d446d714be6a2e5fdf6be
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
index be93548..cf2b386 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
@@ -20,6 +20,7 @@
import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Notification;
import android.app.PendingIntent;
@@ -39,6 +40,8 @@
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.List;
import java.util.Objects;
@@ -293,6 +296,16 @@
}
}
+ String getDesiredHeightString() {
+ Notification.BubbleMetadata data = mEntry.getBubbleMetadata();
+ boolean useRes = data.getDesiredHeightResId() != 0;
+ if (useRes) {
+ return String.valueOf(data.getDesiredHeightResId());
+ } else {
+ return String.valueOf(data.getDesiredHeight());
+ }
+ }
+
@Nullable
PendingIntent getBubbleIntent(Context context) {
Notification notif = mEntry.notification.getNotification();
@@ -404,11 +417,30 @@
&& mEntry.getBubbleMetadata().isNotificationSuppressed();
}
+ boolean shouldAutoExpand() {
+ Notification.BubbleMetadata metadata = mEntry.getBubbleMetadata();
+ return metadata != null && metadata.getAutoExpandBubble();
+ }
+
@Override
public String toString() {
return "Bubble{" + mKey + '}';
}
+ /**
+ * Description of current bubble state.
+ */
+ public void dump(
+ @NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
+ pw.print("key: "); pw.println(mKey);
+ pw.print(" showInShade: "); pw.println(showInShadeWhenBubble());
+ pw.print(" showDot: "); pw.println(showBubbleDot());
+ pw.print(" showFlyout: "); pw.println(showFlyoutForBubble());
+ pw.print(" desiredHeight: "); pw.println(getDesiredHeightString());
+ pw.print(" suppressNotif: "); pw.println(shouldSuppressNotification());
+ pw.print(" autoExpand: "); pw.println(shouldAutoExpand());
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index 6e3c410..6e2bcc1 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -81,6 +81,8 @@
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ZenModeController;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.util.List;
@@ -653,6 +655,15 @@
return mStackView;
}
+ /**
+ * Description of current bubble state.
+ */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("BubbleController state:");
+ mBubbleData.dump(fd, pw, args);
+ pw.println();
+ }
+
static String formatBubblesString(List<Bubble> bubbles, Bubble selected) {
StringBuilder sb = new StringBuilder();
for (Bubble bubble : bubbles) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
index 3d07057..c9ec339 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
@@ -36,6 +36,8 @@
import com.android.systemui.bubbles.BubbleController.DismissReason;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -179,7 +181,7 @@
bubble.updateEntry(entry);
doUpdate(bubble);
}
- if (shouldAutoExpand(entry)) {
+ if (bubble.shouldAutoExpand()) {
setSelectedBubbleInternal(bubble);
if (!mExpanded) {
setExpandedInternal(true);
@@ -591,8 +593,17 @@
mListener = listener;
}
- boolean shouldAutoExpand(NotificationEntry entry) {
- Notification.BubbleMetadata metadata = entry.getBubbleMetadata();
- return metadata != null && metadata.getAutoExpandBubble();
+ /**
+ * Description of current bubble data state.
+ */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.print("selected: "); pw.println(mSelectedBubble != null
+ ? mSelectedBubble.getKey()
+ : "null");
+ pw.print("expanded: "); pw.println(mExpanded);
+ pw.print("count: "); pw.println(mBubbles.size());
+ for (Bubble bubble : mBubbles) {
+ bubble.dump(fd, pw, args);
+ }
}
}
\ No newline at end of file