summaryrefslogtreecommitdiff
path: root/libs/WindowManager/Shell
diff options
context:
space:
mode:
author Mady Mellor <madym@google.com> 2022-02-24 01:30:11 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-02-24 01:30:11 +0000
commitcdc7d70d4f1852086221c6bd80d8a2751cf4baf6 (patch)
tree337b4b03b94d4348a705f9d52777d4bded9b84f9 /libs/WindowManager/Shell
parent431a79bb116271663dd23b138a3d6615d3a86015 (diff)
parentf274b012d3a1d1fee7cf62a89e61f6273d065b80 (diff)
Merge "Only collapse bubbles when its from gesture nav" into tm-dev
Diffstat (limited to 'libs/WindowManager/Shell')
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java34
1 files changed, 33 insertions, 1 deletions
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 241f1a7d4d1c..d0138a488295 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
@@ -47,7 +47,10 @@ import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
@@ -131,6 +134,10 @@ public class BubbleController {
public static final String RIGHT_POSITION = "Right";
public static final String BOTTOM_POSITION = "Bottom";
+ // Should match with PhoneWindowManager
+ private static final String SYSTEM_DIALOG_REASON_KEY = "reason";
+ private static final String SYSTEM_DIALOG_REASON_GESTURE_NAV = "gestureNav";
+
private final Context mContext;
private final BubblesImpl mImpl = new BubblesImpl();
private Bubbles.BubbleExpandListener mExpandListener;
@@ -675,6 +682,7 @@ public class BubbleController {
try {
mAddedToWindowManager = true;
+ registerBroadcastReceiver();
mBubbleData.getOverflow().initialize(this);
mWindowManager.addView(mStackView, mWmLayoutParams);
mStackView.setOnApplyWindowInsetsListener((view, windowInsets) -> {
@@ -717,6 +725,7 @@ public class BubbleController {
try {
mAddedToWindowManager = false;
+ mContext.unregisterReceiver(mBroadcastReceiver);
if (mStackView != null) {
mWindowManager.removeView(mStackView);
mBubbleData.getOverflow().cleanUpExpandedState();
@@ -730,11 +739,34 @@ public class BubbleController {
}
}
+ private void registerBroadcastReceiver() {
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+ filter.addAction(Intent.ACTION_SCREEN_OFF);
+ mContext.registerReceiver(mBroadcastReceiver, filter);
+ }
+
+ private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (!isStackExpanded()) return; // Nothing to do
+
+ String action = intent.getAction();
+ String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
+ if ((Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
+ && SYSTEM_DIALOG_REASON_GESTURE_NAV.equals(reason))
+ || Intent.ACTION_SCREEN_OFF.equals(action)) {
+ mMainExecutor.execute(() -> collapseStack());
+ }
+ }
+ };
+
/**
* Called by the BubbleStackView and whenever all bubbles have animated out, and none have been
* added in the meantime.
*/
- void onAllBubblesAnimatedOut() {
+ @VisibleForTesting
+ public void onAllBubblesAnimatedOut() {
if (mStackView != null) {
mStackView.setVisibility(INVISIBLE);
removeFromWindowManagerMaybe();