Merge "Handle PendingIntent cancellation v2" into rvc-dev am: 9cdbc7f66b
Change-Id: Ie47923912d535e671e0a4573f3ff8f2abf86f8f1
This commit is contained in:
@@ -78,6 +78,7 @@ class Bubble implements BubbleViewProvider {
|
|||||||
|
|
||||||
private BubbleViewInfoTask mInflationTask;
|
private BubbleViewInfoTask mInflationTask;
|
||||||
private boolean mInflateSynchronously;
|
private boolean mInflateSynchronously;
|
||||||
|
private boolean mPendingIntentCanceled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Presentational info about the flyout.
|
* Presentational info about the flyout.
|
||||||
@@ -182,6 +183,14 @@ class Bubble implements BubbleViewProvider {
|
|||||||
mIconView = null;
|
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
|
* Sets whether to perform inflation on the same thread as the caller. This method should only
|
||||||
* be used in tests, not in production.
|
* be used in tests, not in production.
|
||||||
@@ -294,6 +303,13 @@ class Bubble implements BubbleViewProvider {
|
|||||||
return mLastUpdated;
|
return mLastUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.
|
* @return the display id of the virtual display on which bubble contents is drawn.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import android.content.pm.ActivityInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.service.notification.NotificationListenerService;
|
import android.service.notification.NotificationListenerService;
|
||||||
@@ -176,6 +177,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
|
|||||||
private IStatusBarService mBarService;
|
private IStatusBarService mBarService;
|
||||||
private SysUiState mSysUiState;
|
private SysUiState mSysUiState;
|
||||||
|
|
||||||
|
// Used to post to main UI thread
|
||||||
|
private Handler mHandler = new Handler();
|
||||||
|
|
||||||
// Used for determining view rect for touch interaction
|
// Used for determining view rect for touch interaction
|
||||||
private Rect mTempRect = new Rect();
|
private Rect mTempRect = new Rect();
|
||||||
|
|
||||||
@@ -808,7 +812,21 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
|
|||||||
Bubble bubble = mBubbleData.getOrCreateBubble(notif);
|
Bubble bubble = mBubbleData.getOrCreateBubble(notif);
|
||||||
bubble.setInflateSynchronously(mInflateSynchronously);
|
bubble.setInflateSynchronously(mInflateSynchronously);
|
||||||
bubble.inflate(
|
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);
|
mContext, mStackView, mBubbleIconFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -480,7 +480,8 @@ public class BubbleData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void overflowBubble(@DismissReason int reason, Bubble bubble) {
|
void overflowBubble(@DismissReason int reason, Bubble bubble) {
|
||||||
if (!(reason == BubbleController.DISMISS_AGED
|
if (bubble.getPendingIntentCanceled()
|
||||||
|
|| !(reason == BubbleController.DISMISS_AGED
|
||||||
|| reason == BubbleController.DISMISS_USER_GESTURE)) {
|
|| reason == BubbleController.DISMISS_USER_GESTURE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user