Consolidate debug flags for Bubbles.
Bug: 134734945
Test: refactoring, checked if existing tests pass.
Change-Id: Ia3f0361940c2040e6c09758cd1dede1a120e179b
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BadgeRenderer.java b/packages/SystemUI/src/com/android/systemui/bubbles/BadgeRenderer.java
index 74ad0fa..c91ba34 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BadgeRenderer.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BadgeRenderer.java
@@ -18,6 +18,9 @@
import static android.graphics.Paint.ANTI_ALIAS_FLAG;
import static android.graphics.Paint.FILTER_BITMAP_FLAG;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
+
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -33,7 +36,7 @@
*/
public class BadgeRenderer {
- private static final String TAG = "BadgeRenderer";
+ private static final String TAG = TAG_WITH_CLASS_NAME ? "BadgeRenderer" : TAG_BUBBLES;
/** The badge sizes are defined as percentages of the app icon size. */
private static final float SIZE_PERCENTAGE = 0.38f;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
index 5c6c397..47149f2 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
@@ -36,10 +36,6 @@
* Encapsulates the data and UI elements of a bubble.
*/
class Bubble {
-
- private static final boolean DEBUG = false;
- private static final String TAG = "Bubble";
-
private final String mKey;
private final String mGroupId;
private String mAppName;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index a23c99e..bde1eb0 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -31,6 +31,9 @@
import static android.view.View.VISIBLE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_CONTROLLER;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.systemui.statusbar.StatusBarState.SHADE;
import static com.android.systemui.statusbar.notification.NotificationEntryManager.UNDEFINED_DISMISS_REASON;
@@ -101,8 +104,7 @@
@Singleton
public class BubbleController implements ConfigurationController.ConfigurationListener {
- private static final String TAG = "BubbleController";
- private static final boolean DEBUG = false;
+ private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleController" : TAG_BUBBLES;
@Retention(SOURCE)
@IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED,
@@ -585,7 +587,7 @@
mNotificationEntryManager.updateNotifications();
updateStack();
- if (DEBUG) {
+ if (DEBUG_BUBBLE_CONTROLLER) {
Log.d(TAG, "[BubbleData]");
Log.d(TAG, formatBubblesString(mBubbleData.getBubbles(),
mBubbleData.getSelectedBubble()));
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
index 5575b35..d228a40 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
@@ -16,6 +16,9 @@
package com.android.systemui.bubbles;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE;
+import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_DATA;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static java.util.stream.Collectors.toList;
@@ -51,8 +54,7 @@
@Singleton
public class BubbleData {
- private static final String TAG = "BubbleData";
- private static final boolean DEBUG = false;
+ private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleData" : TAG_BUBBLES;
private static final int MAX_BUBBLES = 5;
@@ -148,7 +150,7 @@
}
public void setExpanded(boolean expanded) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "setExpanded: " + expanded);
}
setExpandedInternal(expanded);
@@ -156,7 +158,7 @@
}
public void setSelectedBubble(Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "setSelectedBubble: " + bubble);
}
setSelectedBubbleInternal(bubble);
@@ -164,7 +166,7 @@
}
public void notificationEntryUpdated(NotificationEntry entry) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "notificationEntryUpdated: " + entry);
}
Bubble bubble = getBubbleWithKey(entry.key);
@@ -190,7 +192,7 @@
}
public void notificationEntryRemoved(NotificationEntry entry, @DismissReason int reason) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "notificationEntryRemoved: entry=" + entry + " reason=" + reason);
}
doRemove(entry.key, reason);
@@ -223,7 +225,7 @@
}
private void doAdd(Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "doAdd: " + bubble);
}
int minInsertPoint = 0;
@@ -256,7 +258,7 @@
}
private void doUpdate(Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "doUpdate: " + bubble);
}
mStateChange.updatedBubble = bubble;
@@ -306,7 +308,7 @@
}
public void dismissAll(@DismissReason int reason) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "dismissAll: reason=" + reason);
}
if (mBubbles.isEmpty()) {
@@ -336,7 +338,7 @@
* @param bubble the new selected bubble
*/
private void setSelectedBubbleInternal(@Nullable Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "setSelectedBubbleInternal: " + bubble);
}
if (Objects.equals(bubble, mSelectedBubble)) {
@@ -361,7 +363,7 @@
* @param shouldExpand the new requested state
*/
private void setExpandedInternal(boolean shouldExpand) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "setExpandedInternal: shouldExpand=" + shouldExpand);
}
if (mExpanded == shouldExpand) {
@@ -466,7 +468,7 @@
* @return true if the position of any bubbles has changed as a result
*/
private boolean packGroup(int position) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "packGroup: position=" + position);
}
Bubble groupStart = mBubbles.get(position);
@@ -495,7 +497,7 @@
* @return true if the position of any bubbles changed as a result
*/
private boolean repackAll() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "repackAll()");
}
if (mBubbles.isEmpty()) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDebugConfig.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDebugConfig.java
new file mode 100644
index 0000000..5357f772
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDebugConfig.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.bubbles;
+
+/**
+ * Common class for the various debug {@link android.util.Log} output configuration in the Bubbles
+ * package.
+ */
+public class BubbleDebugConfig {
+
+ // All output logs in the Bubbles package use the {@link #TAG_BUBBLES} string for tagging their
+ // log output. This makes it easy to identify the origin of the log message when sifting
+ // through a large amount of log output from multiple sources. However, it also makes trying
+ // to figure-out the origin of a log message while debugging the Bubbles a little painful. By
+ // setting this constant to true, log messages from the Bubbles package will be tagged with
+ // their class names instead fot the generic tag.
+ static final boolean TAG_WITH_CLASS_NAME = false;
+
+ // Default log tag for the Bubbles package.
+ static final String TAG_BUBBLES = "Bubbles";
+
+ static final boolean DEBUG_BUBBLE_CONTROLLER = false;
+ static final boolean DEBUG_BUBBLE_DATA = false;
+ static final boolean DEBUG_BUBBLE_STACK_VIEW = false;
+}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
index 09d4b05..020ed34 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
@@ -19,6 +19,8 @@
import static android.view.Display.INVALID_DISPLAY;
import static com.android.systemui.bubbles.BubbleController.DEBUG_ENABLE_AUTO_BUBBLE;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import android.annotation.Nullable;
import android.app.ActivityOptions;
@@ -62,7 +64,7 @@
* Container for the expanded bubble view, handles rendering the caret and settings icon.
*/
public class BubbleExpandedView extends LinearLayout implements View.OnClickListener {
- private static final String TAG = "BubbleExpandedView";
+ private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleExpandedView" : TAG_BUBBLES;
// The triangle pointing to the expanded view
private View mPointerView;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 40fb6d2..2fd07a3 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -19,6 +19,10 @@
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_STACK_VIEW;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
@@ -79,8 +83,7 @@
* Renders bubbles in a stack and handles animating expanded and collapsed states.
*/
public class BubbleStackView extends FrameLayout {
- private static final String TAG = "BubbleStackView";
- private static final boolean DEBUG = false;
+ private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleStackView" : TAG_BUBBLES;
/** How far the flyout needs to be dragged before it's dismissed regardless of velocity. */
static final float FLYOUT_DRAG_PERCENT_DISMISS = 0.25f;
@@ -684,7 +687,7 @@
// via BubbleData.Listener
void addBubble(Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "addBubble: " + bubble);
}
bubble.inflate(mInflater, this);
@@ -702,7 +705,7 @@
// via BubbleData.Listener
void removeBubble(Bubble bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "removeBubble: " + bubble);
}
// Remove it from the views
@@ -737,7 +740,7 @@
*/
// via BubbleData.Listener
public void setSelectedBubble(@Nullable Bubble bubbleToSelect) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "setSelectedBubble: " + bubbleToSelect);
}
if (mExpandedBubble != null && mExpandedBubble.equals(bubbleToSelect)) {
@@ -774,7 +777,7 @@
*/
// via BubbleData.Listener
public void setExpanded(boolean shouldExpand) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "setExpanded: " + shouldExpand);
}
if (shouldExpand == mIsExpanded) {
@@ -798,7 +801,7 @@
*/
@Deprecated
void stackDismissed(int reason) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "stackDismissed: reason=" + reason);
}
mBubbleData.dismissAll(reason);
@@ -848,7 +851,7 @@
@Deprecated
@MainThread
void collapseStack() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "collapseStack()");
}
mBubbleData.setExpanded(false);
@@ -860,7 +863,7 @@
@Deprecated
@MainThread
void collapseStack(Runnable endRunnable) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "collapseStack(endRunnable)");
}
collapseStack();
@@ -878,7 +881,7 @@
@Deprecated
@MainThread
void expandStack() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "expandStack()");
}
mBubbleData.setExpanded(true);
@@ -974,7 +977,7 @@
/** Called when a drag operation on an individual bubble has started. */
public void onBubbleDragStart(View bubble) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "onBubbleDragStart: bubble=" + bubble);
}
mExpandedAnimationController.prepareForBubbleDrag(bubble);
@@ -993,7 +996,7 @@
/** Called when a drag operation on an individual bubble has finished. */
public void onBubbleDragFinish(
View bubble, float x, float y, float velX, float velY) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "onBubbleDragFinish: bubble=" + bubble);
}
@@ -1006,7 +1009,7 @@
}
void onDragStart() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "onDragStart()");
}
if (mIsExpanded || mIsExpansionAnimating) {
@@ -1030,7 +1033,7 @@
}
void onDragFinish(float x, float y, float velX, float velY) {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "onDragFinish");
}
@@ -1476,7 +1479,7 @@
}
private void updateExpandedBubble() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "updateExpandedBubble()");
}
mExpandedViewContainer.removeAllViews();
@@ -1489,7 +1492,7 @@
}
private void updateExpandedView() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "updateExpandedView: mIsExpanded=" + mIsExpanded);
}
@@ -1542,7 +1545,7 @@
}
private void updatePointerPosition() {
- if (DEBUG) {
+ if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "updatePointerPosition()");
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
index 8fe8bd3..21bb35d 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
@@ -45,7 +45,6 @@
*/
private static final float INDIVIDUAL_BUBBLE_DISMISS_MIN_VELOCITY = 6000f;
- private static final String TAG = "BubbleTouchHandler";
/**
* When the stack is flung towards the bottom of the screen, it'll be dismissed if it's flung
* towards the center of the screen (where the dismiss target is). This value is the width of
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
index 6f1ed28..af3667b 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
@@ -38,7 +38,6 @@
* A floating object on the screen that can post message updates.
*/
public class BubbleView extends FrameLayout {
- private static final String TAG = "BubbleView";
private static final int DARK_ICON_ALPHA = 180;
private static final double ICON_MIN_CONTRAST = 4.1;