summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java92
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java7
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java9
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java8
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java2
5 files changed, 62 insertions, 56 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
index 947dbd276d3a..d77c177437b8 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
@@ -192,10 +192,10 @@ public class Bubble implements BubbleViewProvider {
* that bubble being added back to the stack anyways.
*/
@Nullable
- private PendingIntent mIntent;
- private boolean mIntentActive;
+ private PendingIntent mPendingIntent;
+ private boolean mPendingIntentActive;
@Nullable
- private PendingIntent.CancelListener mIntentCancelListener;
+ private PendingIntent.CancelListener mPendingIntentCancelListener;
/**
* Sent when the bubble & notification are no longer visible to the user (i.e. no
@@ -205,12 +205,10 @@ public class Bubble implements BubbleViewProvider {
private PendingIntent mDeleteIntent;
/**
- * Used only for a special bubble in the stack that has {@link #mIsAppBubble} set to true.
- * There can only be one of these bubbles in the stack and this intent will be populated for
- * that bubble.
+ * Used for app & note bubbles.
*/
@Nullable
- private Intent mAppIntent;
+ private Intent mIntent;
/**
* Set while preparing a transition for animation. Several steps are needed before animation
@@ -275,7 +273,7 @@ public class Bubble implements BubbleViewProvider {
mMainExecutor = mainExecutor;
mBgExecutor = bgExecutor;
mTaskId = INVALID_TASK_ID;
- mAppIntent = intent;
+ mIntent = intent;
mDesiredHeight = Integer.MAX_VALUE;
mPackageName = intent.getPackage();
}
@@ -294,7 +292,7 @@ public class Bubble implements BubbleViewProvider {
mMainExecutor = mainExecutor;
mBgExecutor = bgExecutor;
mTaskId = INVALID_TASK_ID;
- mAppIntent = null;
+ mIntent = null;
mDesiredHeight = Integer.MAX_VALUE;
mPackageName = info.getPackage();
mShortcutInfo = info;
@@ -319,7 +317,7 @@ public class Bubble implements BubbleViewProvider {
mMainExecutor = mainExecutor;
mBgExecutor = bgExecutor;
mTaskId = task.taskId;
- mAppIntent = null;
+ mIntent = null;
mDesiredHeight = Integer.MAX_VALUE;
mPackageName = task.baseActivity.getPackageName();
}
@@ -413,9 +411,9 @@ public class Bubble implements BubbleViewProvider {
mGroupKey = entry.getGroupKey();
mLocusId = entry.getLocusId();
mBubbleMetadataFlagListener = listener;
- mIntentCancelListener = intent -> {
- if (mIntent != null) {
- mIntent.unregisterCancelListener(mIntentCancelListener);
+ mPendingIntentCancelListener = intent -> {
+ if (mPendingIntent != null) {
+ mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener);
}
mainExecutor.execute(() -> {
intentCancelListener.onPendingIntentCanceled(this);
@@ -601,10 +599,10 @@ public class Bubble implements BubbleViewProvider {
if (cleanupTaskView) {
cleanupTaskView();
}
- if (mIntent != null) {
- mIntent.unregisterCancelListener(mIntentCancelListener);
+ if (mPendingIntent != null) {
+ mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener);
}
- mIntentActive = false;
+ mPendingIntentActive = false;
}
/** Cleans-up the taskview associated with this bubble (possibly removing the task from wm) */
@@ -874,19 +872,19 @@ public class Bubble implements BubbleViewProvider {
mDesiredHeightResId = entry.getBubbleMetadata().getDesiredHeightResId();
mIcon = entry.getBubbleMetadata().getIcon();
- if (!mIntentActive || mIntent == null) {
- if (mIntent != null) {
- mIntent.unregisterCancelListener(mIntentCancelListener);
+ if (!mPendingIntentActive || mPendingIntent == null) {
+ if (mPendingIntent != null) {
+ mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener);
}
- mIntent = entry.getBubbleMetadata().getIntent();
- if (mIntent != null) {
- mIntent.registerCancelListener(mIntentCancelListener);
+ mPendingIntent = entry.getBubbleMetadata().getIntent();
+ if (mPendingIntent != null) {
+ mPendingIntent.registerCancelListener(mPendingIntentCancelListener);
}
- } else if (mIntent != null && entry.getBubbleMetadata().getIntent() == null) {
+ } else if (mPendingIntent != null && entry.getBubbleMetadata().getIntent() == null) {
// Was an intent bubble now it's a shortcut bubble... still unregister the listener
- mIntent.unregisterCancelListener(mIntentCancelListener);
- mIntentActive = false;
- mIntent = null;
+ mPendingIntent.unregisterCancelListener(mPendingIntentCancelListener);
+ mPendingIntentActive = false;
+ mPendingIntent = null;
}
mDeleteIntent = entry.getBubbleMetadata().getDeleteIntent();
}
@@ -926,12 +924,15 @@ public class Bubble implements BubbleViewProvider {
* Sets if the intent used for this bubble is currently active (i.e. populating an
* expanded view, expanded or not).
*/
- void setIntentActive() {
- mIntentActive = true;
+ void setPendingIntentActive() {
+ mPendingIntentActive = true;
}
- boolean isIntentActive() {
- return mIntentActive;
+ /**
+ * Whether the pending intent of this bubble is active (i.e. has been sent).
+ */
+ boolean isPendingIntentActive() {
+ return mPendingIntentActive;
}
public InstanceId getInstanceId() {
@@ -1118,9 +1119,12 @@ public class Bubble implements BubbleViewProvider {
}
}
+ /**
+ * Returns the pending intent used to populate the bubble.
+ */
@Nullable
- PendingIntent getBubbleIntent() {
- return mIntent;
+ PendingIntent getPendingIntent() {
+ return mPendingIntent;
}
/**
@@ -1128,31 +1132,33 @@ public class Bubble implements BubbleViewProvider {
* intent for an app. In this case we don't show a badge on the icon.
*/
public boolean isAppLaunchIntent() {
- if (BubbleAnythingFlagHelper.enableCreateAnyBubble() && mAppIntent != null) {
- return mAppIntent.hasCategory("android.intent.category.LAUNCHER");
+ if (BubbleAnythingFlagHelper.enableCreateAnyBubble() && mIntent != null) {
+ return mIntent.hasCategory("android.intent.category.LAUNCHER");
}
return false;
}
+ /**
+ * Returns the pending intent to send when a bubble is dismissed (set via the notification API).
+ */
@Nullable
PendingIntent getDeleteIntent() {
return mDeleteIntent;
}
+ /**
+ * Returns the intent used to populate the bubble.
+ */
@Nullable
- @VisibleForTesting
- public Intent getAppBubbleIntent() {
- return mAppIntent;
+ public Intent getIntent() {
+ return mIntent;
}
/**
- * Sets the intent for a bubble that is an app bubble (one for which {@link #mIsAppBubble} is
- * true).
- *
- * @param appIntent The intent to set for the app bubble.
+ * Sets the intent used to populate the bubble.
*/
- void setAppBubbleIntent(Intent appIntent) {
- mAppIntent = appIntent;
+ void setIntent(Intent intent) {
+ mIntent = intent;
}
/**
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
index 9120e0894ccf..436e479796ac 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
@@ -419,10 +419,11 @@ public class BubbleController implements ConfigurationChangeListener,
mBubbleData.setSuppressionChangedListener(this::onBubbleMetadataFlagChanged);
mDataRepository.setSuppressionChangedListener(this::onBubbleMetadataFlagChanged);
mBubbleData.setPendingIntentCancelledListener(bubble -> {
- if (bubble.getBubbleIntent() == null) {
+ if (bubble.getPendingIntent() == null) {
return;
}
- if (bubble.isIntentActive() || mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) {
+ if (bubble.isPendingIntentActive()
+ || mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) {
bubble.setPendingIntentCanceled();
return;
}
@@ -1663,7 +1664,7 @@ public class BubbleController implements ConfigurationChangeListener,
// It's in the overflow, so remove it & reinflate
mBubbleData.dismissBubbleWithKey(noteBubbleKey, Bubbles.DISMISS_NOTIF_CANCEL);
// Update the bubble entry in the overflow with the latest intent.
- b.setAppBubbleIntent(intent);
+ b.setIntent(intent);
} else {
// Notes bubble does not exist, lets add and expand it
b = Bubble.createNotesBubble(intent, user, icon, mMainExecutor,
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java
index ac74a42d1359..ad9ab7a722ee 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java
@@ -237,8 +237,7 @@ public class BubbleExpandedView extends LinearLayout {
PendingIntent pi = PendingIntent.getActivity(
context,
/* requestCode= */ 0,
- mBubble.getAppBubbleIntent()
- .addFlags(FLAG_ACTIVITY_MULTIPLE_TASK),
+ mBubble.getIntent().addFlags(FLAG_ACTIVITY_MULTIPLE_TASK),
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT,
/* options= */ null);
mTaskView.startActivity(pi, /* fillInIntent= */ null, options,
@@ -252,7 +251,7 @@ public class BubbleExpandedView extends LinearLayout {
} else {
options.setLaunchedFromBubble(true);
if (mBubble != null) {
- mBubble.setIntentActive();
+ mBubble.setPendingIntentActive();
}
final Intent fillInIntent = new Intent();
// Apply flags to make behaviour match documentLaunchMode=always.
@@ -920,7 +919,7 @@ public class BubbleExpandedView extends LinearLayout {
});
if (isNew) {
- mPendingIntent = mBubble.getBubbleIntent();
+ mPendingIntent = mBubble.getPendingIntent();
if ((mPendingIntent != null || mBubble.hasMetadataShortcutId())
&& mTaskView != null) {
setContentVisibility(false);
@@ -947,7 +946,7 @@ public class BubbleExpandedView extends LinearLayout {
*/
private boolean didBackingContentChange(Bubble newBubble) {
boolean prevWasIntentBased = mBubble != null && mPendingIntent != null;
- boolean newIsIntentBased = newBubble.getBubbleIntent() != null;
+ boolean newIsIntentBased = newBubble.getPendingIntent() != null;
return prevWasIntentBased != newIsIntentBased;
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java
index 83d311ed6cd9..0d89bb260bf5 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java
@@ -119,7 +119,7 @@ public class BubbleTaskViewHelper {
PendingIntent pi = PendingIntent.getActivity(
context,
/* requestCode= */ 0,
- mBubble.getAppBubbleIntent()
+ mBubble.getIntent()
.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK),
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT,
/* options= */ null);
@@ -133,7 +133,7 @@ public class BubbleTaskViewHelper {
} else {
options.setLaunchedFromBubble(true);
if (mBubble != null) {
- mBubble.setIntentActive();
+ mBubble.setPendingIntentActive();
}
final Intent fillInIntent = new Intent();
// Apply flags to make behaviour match documentLaunchMode=always.
@@ -231,7 +231,7 @@ public class BubbleTaskViewHelper {
boolean isNew = mBubble == null || didBackingContentChange(bubble);
mBubble = bubble;
if (isNew) {
- mPendingIntent = mBubble.getBubbleIntent();
+ mPendingIntent = mBubble.getPendingIntent();
return true;
}
return false;
@@ -276,7 +276,7 @@ public class BubbleTaskViewHelper {
*/
private boolean didBackingContentChange(Bubble newBubble) {
boolean prevWasIntentBased = mBubble != null && mPendingIntent != null;
- boolean newIsIntentBased = newBubble.getBubbleIntent() != null;
+ boolean newIsIntentBased = newBubble.getPendingIntent() != null;
return prevWasIntentBased != newIsIntentBased;
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
index 097f3929db42..bf10dc6c4aef 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
@@ -2110,7 +2110,7 @@ public class BubblesTest extends SysuiTestCase {
assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(noteBubbleKey);
assertThat(mBubbleController.isStackExpanded()).isTrue();
assertThat(mBubbleData.getBubbles().size()).isEqualTo(1);
- assertThat(mBubbleData.getBubbles().get(0).getAppBubbleIntent()
+ assertThat(mBubbleData.getBubbles().get(0).getIntent()
.getStringExtra("hello")).isEqualTo("world");
assertThat(mBubbleData.getOverflowBubbleWithKey(noteBubbleKey)).isNull();
}