summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Lyn Han <lynhan@google.com> 2020-04-27 15:11:18 -0700
committer Lyn Han <lynhan@google.com> 2020-04-29 16:19:05 -0700
commit6cb4e5f68574282c93bcc57a55e97e73047b35c9 (patch)
tree098047893a449ef354f3bc2fd07024c47acbc666
parent5093c5816b7ff7228cd28fa056811368d3d4086f (diff)
Handle PendingIntent cancellation v2
On cancel: - Remove unopened bubble - Mark opened bubble as canceled to skip overflowing later Fixes: 152889099 Test: manual 1) Expand bubble with FLAG_ONE_SHOT PendingIntent => bubble NOT removed 2) Overflow bubble => bubble removed Test: manual 1) Overflow bubble with FLAG_ONE_SHOT PendingIntent without expanding it 2) Promote bubble from overflow 3) Expand bubble => bubble NOT removed 4) Overflow bubble => bubble removed Change-Id: I1657e84985ff1535205f8e32d1ace9dd3a3cc7ef
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java20
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java3
3 files changed, 37 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
index 38bfffbb75d9..0dbee663c1c9 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
@@ -78,6 +78,7 @@ class Bubble implements BubbleViewProvider {
private BubbleViewInfoTask mInflationTask;
private boolean mInflateSynchronously;
+ private boolean mPendingIntentCanceled;
/**
* Presentational info about the flyout.
@@ -182,6 +183,14 @@ class Bubble implements BubbleViewProvider {
mIconView = null;
}
+ void setPendingIntentCanceled() {
+ mPendingIntentCanceled = true;
+ }
+
+ boolean getPendingIntentCanceled() {
+ return mPendingIntentCanceled;
+ }
+
/**
* Sets whether to perform inflation on the same thread as the caller. This method should only
* be used in tests, not in production.
@@ -295,6 +304,13 @@ class Bubble implements BubbleViewProvider {
}
/**
+ * @return if the bubble was ever expanded
+ */
+ boolean getWasAccessed() {
+ return mLastAccessed != 0L;
+ }
+
+ /**
* @return the display id of the virtual display on which bubble contents is drawn.
*/
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index 5239a37797a9..013f22203fbc 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -54,6 +54,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Rect;
+import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.service.notification.NotificationListenerService;
@@ -176,6 +177,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
private IStatusBarService mBarService;
private SysUiState mSysUiState;
+ // Used to post to main UI thread
+ private Handler mHandler = new Handler();
+
// Used for determining view rect for touch interaction
private Rect mTempRect = new Rect();
@@ -808,7 +812,21 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
Bubble bubble = mBubbleData.getOrCreateBubble(notif);
bubble.setInflateSynchronously(mInflateSynchronously);
bubble.inflate(
- b -> mBubbleData.notificationEntryUpdated(b, suppressFlyout, showInShade),
+ b -> {
+ mBubbleData.notificationEntryUpdated(b, suppressFlyout, showInShade);
+ if (bubble.getBubbleIntent() == null) {
+ return;
+ }
+ bubble.getBubbleIntent().registerCancelListener(pendingIntent -> {
+ if (bubble.getWasAccessed()) {
+ bubble.setPendingIntentCanceled();
+ return;
+ }
+ mHandler.post(
+ () -> removeBubble(bubble.getEntry(),
+ BubbleController.DISMISS_INVALID_INTENT));
+ });
+ },
mContext, mStackView, mBubbleIconFactory);
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
index 2ac60f206273..f2b1c031dcd5 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
@@ -480,7 +480,8 @@ public class BubbleData {
}
void overflowBubble(@DismissReason int reason, Bubble bubble) {
- if (!(reason == BubbleController.DISMISS_AGED
+ if (bubble.getPendingIntentCanceled()
+ || !(reason == BubbleController.DISMISS_AGED
|| reason == BubbleController.DISMISS_USER_GESTURE)) {
return;
}