diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index b15c5debc17d7..41bc1b29075c9 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -28,6 +28,9 @@ import static com.android.systemui.statusbar.StatusBarState.SHADE; import static com.android.systemui.statusbar.notification.NotificationAlertingManager.alertAgain; import android.annotation.Nullable; +import android.app.ActivityManager; +import android.app.ActivityTaskManager; +import android.app.IActivityTaskManager; import android.app.INotificationManager; import android.app.Notification; import android.app.PendingIntent; @@ -35,11 +38,13 @@ import android.content.Context; import android.content.pm.ActivityInfo; import android.graphics.Point; import android.graphics.Rect; +import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.service.notification.StatusBarNotification; import android.util.Log; import android.util.StatsLog; +import android.view.Display; import android.view.LayoutInflater; import android.view.ViewGroup; import android.view.WindowManager; @@ -52,6 +57,8 @@ import com.android.internal.statusbar.NotificationVisibility; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.shared.system.ActivityManagerWrapper; +import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.statusbar.notification.NotificationEntryListener; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider; @@ -60,6 +67,7 @@ import com.android.systemui.statusbar.notification.row.NotificationInflater; import com.android.systemui.statusbar.phone.StatusBarWindowController; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; @@ -93,6 +101,8 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe private final Context mContext; private final NotificationEntryManager mNotificationEntryManager; + private final IActivityTaskManager mActivityTaskManager; + private final BubbleTaskStackListener mTaskStackListener; private BubbleStateChangeListener mStateChangeListener; private BubbleExpandListener mExpandListener; private LayoutInflater mInflater; @@ -176,6 +186,10 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe mStatusBarWindowController = statusBarWindowController; mStatusBarStateListener = new StatusBarStateListener(); Dependency.get(StatusBarStateController.class).addCallback(mStatusBarStateListener); + + mActivityTaskManager = ActivityTaskManager.getService(); + mTaskStackListener = new BubbleTaskStackListener(); + ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener); } /** @@ -533,6 +547,64 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe || autoBubbleAll; } + /** + * This task stack listener is responsible for responding to tasks moved to the front + * which are on the default (main) display. When this happens, expanded bubbles must be + * collapsed so the user may interact with the app which was just moved to the front. + *
+ * This listener is registered with SystemUI's ActivityManagerWrapper which dispatches
+ * these calls via a main thread Handler.
+ */
+ @MainThread
+ private class BubbleTaskStackListener extends TaskStackChangeListener {
+
+ @Nullable
+ private ActivityManager.StackInfo findStackInfo(int taskId) throws RemoteException {
+ final List
+ * Must be called from the main thread.
*/
+ @MainThread
public void collapseStack() {
if (mIsExpanded) {
// TODO: Save opened bubble & move it to top of stack
@@ -402,7 +406,10 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
/**
* Expands the stack fo bubbles.
+ *
+ * Must be called from the main thread.
*/
+ @MainThread
public void expandStack() {
if (!mIsExpanded) {
mExpandedBubble = getTopBubble();