Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.bubbles; |
| 18 | |
Mady Mellor | 3a0a1b4 | 2019-05-23 06:40:21 -0700 | [diff] [blame] | 19 | import static android.app.Notification.FLAG_BUBBLE; |
Mady Mellor | c2ff011 | 2019-03-28 14:18:06 -0700 | [diff] [blame] | 20 | import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL; |
| 21 | import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL_ALL; |
| 22 | import static android.service.notification.NotificationListenerService.REASON_CANCEL; |
| 23 | import static android.service.notification.NotificationListenerService.REASON_CANCEL_ALL; |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 24 | import static android.service.notification.NotificationListenerService.REASON_CLICK; |
| 25 | import static android.service.notification.NotificationListenerService.REASON_GROUP_SUMMARY_CANCELED; |
Mady Mellor | 390bff4 | 2019-04-05 15:09:01 -0700 | [diff] [blame] | 26 | import static android.view.Display.DEFAULT_DISPLAY; |
| 27 | import static android.view.Display.INVALID_DISPLAY; |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 28 | import static android.view.View.INVISIBLE; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 29 | import static android.view.View.VISIBLE; |
Joshua Tsuji | b1a796b | 2019-01-16 15:43:12 -0800 | [diff] [blame] | 30 | import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 31 | |
Issei Suzuki | a8d0731 | 2019-06-07 12:56:19 +0200 | [diff] [blame] | 32 | import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_CONTROLLER; |
Mady Mellor | ff076eb | 2019-11-13 10:12:06 -0800 | [diff] [blame] | 33 | import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_EXPERIMENTS; |
Issei Suzuki | a8d0731 | 2019-06-07 12:56:19 +0200 | [diff] [blame] | 34 | import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES; |
| 35 | import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME; |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 36 | import static com.android.systemui.statusbar.StatusBarState.SHADE; |
Mady Mellor | 1a4e86f | 2019-05-03 16:07:23 -0700 | [diff] [blame] | 37 | import static com.android.systemui.statusbar.notification.NotificationEntryManager.UNDEFINED_DISMISS_REASON; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 38 | |
Mark Renouf | ba5ab51 | 2019-05-02 15:21:01 -0400 | [diff] [blame] | 39 | import static java.lang.annotation.ElementType.FIELD; |
| 40 | import static java.lang.annotation.ElementType.LOCAL_VARIABLE; |
| 41 | import static java.lang.annotation.ElementType.PARAMETER; |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 42 | import static java.lang.annotation.RetentionPolicy.SOURCE; |
| 43 | |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 44 | import android.annotation.UserIdInt; |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 45 | import android.app.ActivityManager.RunningTaskInfo; |
Mady Mellor | 66efd5e | 2019-05-15 13:38:11 -0700 | [diff] [blame] | 46 | import android.app.NotificationManager; |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 47 | import android.app.PendingIntent; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 48 | import android.content.Context; |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 49 | import android.content.pm.ActivityInfo; |
Mady Mellor | f3b9fab | 2019-11-13 17:27:32 -0800 | [diff] [blame] | 50 | import android.content.pm.PackageManager; |
Joshua Tsuji | f418f9e | 2019-04-04 17:09:53 -0400 | [diff] [blame] | 51 | import android.content.res.Configuration; |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 52 | import android.graphics.Rect; |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 53 | import android.os.RemoteException; |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 54 | import android.os.ServiceManager; |
Mady Mellor | 56515c4 | 2020-02-18 17:58:36 -0800 | [diff] [blame] | 55 | import android.service.notification.NotificationListenerService; |
Mark Renouf | bbcf07f | 2019-05-09 10:42:43 -0400 | [diff] [blame] | 56 | import android.service.notification.NotificationListenerService.RankingMap; |
Joshua Tsuji | dd4d9f9 | 2019-05-13 13:57:38 -0400 | [diff] [blame] | 57 | import android.service.notification.ZenModeConfig; |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 58 | import android.util.ArraySet; |
Mark Renouf | 9ba6cea | 2019-04-17 11:53:50 -0400 | [diff] [blame] | 59 | import android.util.Log; |
Mark Renouf | 82a40e6 | 2019-05-23 16:16:24 -0400 | [diff] [blame] | 60 | import android.util.Pair; |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 61 | import android.util.SparseSetArray; |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 62 | import android.view.Display; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 63 | import android.view.ViewGroup; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 64 | import android.widget.FrameLayout; |
| 65 | |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 66 | import androidx.annotation.IntDef; |
Mark Renouf | 658c6bc | 2019-01-30 10:26:54 -0500 | [diff] [blame] | 67 | import androidx.annotation.MainThread; |
Joshua Tsuji | c650a14 | 2019-05-22 11:31:19 -0400 | [diff] [blame] | 68 | import androidx.annotation.Nullable; |
Mark Renouf | 658c6bc | 2019-01-30 10:26:54 -0500 | [diff] [blame] | 69 | |
Mady Mellor | ebdbbb9 | 2018-11-15 14:36:48 -0800 | [diff] [blame] | 70 | import com.android.internal.annotations.VisibleForTesting; |
Mady Mellor | a54e9fa | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 71 | import com.android.internal.statusbar.IStatusBarService; |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 72 | import com.android.internal.statusbar.NotificationVisibility; |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 73 | import com.android.systemui.Dumpable; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 74 | import com.android.systemui.R; |
Sergey Nikolaienkov | 5cb6e52 | 2020-02-10 17:33:00 +0100 | [diff] [blame] | 75 | import com.android.systemui.bubbles.dagger.BubbleModule; |
Ned Burns | aaeb44b | 2020-02-12 23:48:26 -0500 | [diff] [blame] | 76 | import com.android.systemui.dump.DumpManager; |
Joshua Tsuji | be60a58 | 2020-03-23 17:17:26 -0400 | [diff] [blame] | 77 | import com.android.systemui.model.SysUiState; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 78 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 79 | import com.android.systemui.shared.system.ActivityManagerWrapper; |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 80 | import com.android.systemui.shared.system.PinnedStackListenerForwarder; |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 81 | import com.android.systemui.shared.system.TaskStackChangeListener; |
Joshua Tsuji | a19515f | 2019-02-13 18:02:29 -0500 | [diff] [blame] | 82 | import com.android.systemui.shared.system.WindowManagerWrapper; |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 83 | import com.android.systemui.statusbar.FeatureFlags; |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 84 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
Mady Mellor | c2ff011 | 2019-03-28 14:18:06 -0700 | [diff] [blame] | 85 | import com.android.systemui.statusbar.NotificationRemoveInterceptor; |
Ned Burns | 01e3821 | 2019-01-03 16:32:52 -0500 | [diff] [blame] | 86 | import com.android.systemui.statusbar.notification.NotificationEntryListener; |
| 87 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 88 | import com.android.systemui.statusbar.notification.collection.NotifCollection; |
| 89 | import com.android.systemui.statusbar.notification.collection.NotifPipeline; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 90 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 91 | import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 92 | import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider; |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 93 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 94 | import com.android.systemui.statusbar.phone.NotificationShadeWindowController; |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 95 | import com.android.systemui.statusbar.phone.ShadeController; |
Mady Mellor | f3b9fab | 2019-11-13 17:27:32 -0800 | [diff] [blame] | 96 | import com.android.systemui.statusbar.phone.StatusBar; |
Lyn Han | f1c9b8b | 2019-03-14 16:49:48 -0700 | [diff] [blame] | 97 | import com.android.systemui.statusbar.policy.ConfigurationController; |
Joshua Tsuji | dd4d9f9 | 2019-05-13 13:57:38 -0400 | [diff] [blame] | 98 | import com.android.systemui.statusbar.policy.ZenModeController; |
Joshua Tsuji | 7155bf1 | 2020-02-13 16:14:29 -0500 | [diff] [blame] | 99 | import com.android.systemui.util.FloatingContentCoordinator; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 100 | |
Mady Mellor | 70cba7bb | 2019-07-02 15:06:07 -0700 | [diff] [blame] | 101 | import java.io.FileDescriptor; |
| 102 | import java.io.PrintWriter; |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 103 | import java.lang.annotation.Retention; |
Mark Renouf | ba5ab51 | 2019-05-02 15:21:01 -0400 | [diff] [blame] | 104 | import java.lang.annotation.Target; |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 105 | import java.util.ArrayList; |
Mady Mellor | ff076eb | 2019-11-13 10:12:06 -0800 | [diff] [blame] | 106 | import java.util.HashSet; |
Lyn Han | b58c756 | 2020-01-07 14:29:20 -0800 | [diff] [blame] | 107 | import java.util.List; |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 108 | |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 109 | /** |
| 110 | * Bubbles are a special type of content that can "float" on top of other apps or System UI. |
| 111 | * Bubbles can be expanded to show more content. |
| 112 | * |
| 113 | * The controller manages addition, removal, and visible state of bubbles on screen. |
| 114 | */ |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 115 | public class BubbleController implements ConfigurationController.ConfigurationListener, Dumpable { |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 116 | |
Issei Suzuki | a8d0731 | 2019-06-07 12:56:19 +0200 | [diff] [blame] | 117 | private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleController" : TAG_BUBBLES; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 118 | |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 119 | @Retention(SOURCE) |
| 120 | @IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED, |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 121 | DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION, DISMISS_NO_LONGER_BUBBLE, |
Mady Mellor | 8454ddf | 2019-08-15 11:16:23 -0700 | [diff] [blame] | 122 | DISMISS_USER_CHANGED, DISMISS_GROUP_CANCELLED, DISMISS_INVALID_INTENT}) |
Mark Renouf | ba5ab51 | 2019-05-02 15:21:01 -0400 | [diff] [blame] | 123 | @Target({FIELD, LOCAL_VARIABLE, PARAMETER}) |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 124 | @interface DismissReason {} |
Lyn Han | f1c9b8b | 2019-03-14 16:49:48 -0700 | [diff] [blame] | 125 | |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 126 | static final int DISMISS_USER_GESTURE = 1; |
| 127 | static final int DISMISS_AGED = 2; |
| 128 | static final int DISMISS_TASK_FINISHED = 3; |
| 129 | static final int DISMISS_BLOCKED = 4; |
| 130 | static final int DISMISS_NOTIF_CANCEL = 5; |
| 131 | static final int DISMISS_ACCESSIBILITY_ACTION = 6; |
Mady Mellor | aa8fef2 | 2019-04-11 13:36:40 -0700 | [diff] [blame] | 132 | static final int DISMISS_NO_LONGER_BUBBLE = 7; |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 133 | static final int DISMISS_USER_CHANGED = 8; |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 134 | static final int DISMISS_GROUP_CANCELLED = 9; |
Mady Mellor | 8454ddf | 2019-08-15 11:16:23 -0700 | [diff] [blame] | 135 | static final int DISMISS_INVALID_INTENT = 10; |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 136 | |
Ned Burns | 01e3821 | 2019-01-03 16:32:52 -0500 | [diff] [blame] | 137 | private final Context mContext; |
| 138 | private final NotificationEntryManager mNotificationEntryManager; |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 139 | private final NotifPipeline mNotifPipeline; |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 140 | private final BubbleTaskStackListener mTaskStackListener; |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 141 | private BubbleStateChangeListener mStateChangeListener; |
Mady Mellor | cd9b130 | 2018-11-06 18:08:04 -0800 | [diff] [blame] | 142 | private BubbleExpandListener mExpandListener; |
Issei Suzuki | c038754 | 2019-03-08 17:31:14 +0100 | [diff] [blame] | 143 | @Nullable private BubbleStackView.SurfaceSynchronizer mSurfaceSynchronizer; |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 144 | private final NotificationGroupManager mNotificationGroupManager; |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 145 | private final ShadeController mShadeController; |
Joshua Tsuji | 7155bf1 | 2020-02-13 16:14:29 -0500 | [diff] [blame] | 146 | private final FloatingContentCoordinator mFloatingContentCoordinator; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 147 | |
Mady Mellor | 3dff9e6 | 2019-02-05 18:12:53 -0800 | [diff] [blame] | 148 | private BubbleData mBubbleData; |
Joshua Tsuji | c650a14 | 2019-05-22 11:31:19 -0400 | [diff] [blame] | 149 | @Nullable private BubbleStackView mStackView; |
Mady Mellor | 247ca2c | 2019-12-02 16:18:59 -0800 | [diff] [blame] | 150 | private BubbleIconFactory mBubbleIconFactory; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 151 | |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 152 | // Tracks the id of the current (foreground) user. |
| 153 | private int mCurrentUserId; |
| 154 | // Saves notification keys of active bubbles when users are switched. |
| 155 | private final SparseSetArray<String> mSavedBubbleKeysPerUser; |
| 156 | |
Mady Mellor | 56515c4 | 2020-02-18 17:58:36 -0800 | [diff] [blame] | 157 | // Used when ranking updates occur and we check if things should bubble / unbubble |
| 158 | private NotificationListenerService.Ranking mTmpRanking; |
| 159 | |
Mady Mellor | ff076eb | 2019-11-13 10:12:06 -0800 | [diff] [blame] | 160 | // Saves notification keys of user created "fake" bubbles so that we can allow notifications |
| 161 | // like these to bubble by default. Doesn't persist across reboots, not a long-term solution. |
| 162 | private final HashSet<String> mUserCreatedBubbles; |
Mady Mellor | 3b86a4f | 2019-12-11 13:15:41 -0800 | [diff] [blame] | 163 | // If we're auto-bubbling bubbles via a whitelist, we need to track which notifs from that app |
| 164 | // have been "demoted" back to a notification so that we don't auto-bubbles those again. |
| 165 | // Doesn't persist across reboots, not a long-term solution. |
| 166 | private final HashSet<String> mUserBlockedBubbles; |
Mady Mellor | ff076eb | 2019-11-13 10:12:06 -0800 | [diff] [blame] | 167 | |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 168 | // Bubbles get added to the status bar view |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 169 | private final NotificationShadeWindowController mNotificationShadeWindowController; |
Joshua Tsuji | dd4d9f9 | 2019-05-13 13:57:38 -0400 | [diff] [blame] | 170 | private final ZenModeController mZenModeController; |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 171 | private StatusBarStateListener mStatusBarStateListener; |
Aran Ink | aa4dfa7 | 2019-11-18 16:49:07 -0500 | [diff] [blame] | 172 | |
Lyn Han | b58c756 | 2020-01-07 14:29:20 -0800 | [diff] [blame] | 173 | // Callback that updates BubbleOverflowActivity on data change. |
| 174 | @Nullable private Runnable mOverflowCallback = null; |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 175 | |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 176 | private final NotificationInterruptStateProvider mNotificationInterruptStateProvider; |
Mady Mellor | a54e9fa | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 177 | private IStatusBarService mBarService; |
Joshua Tsuji | be60a58 | 2020-03-23 17:17:26 -0400 | [diff] [blame] | 178 | private SysUiState mSysUiState; |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 179 | |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 180 | // Used for determining view rect for touch interaction |
| 181 | private Rect mTempRect = new Rect(); |
| 182 | |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 183 | // Listens to user switch so bubbles can be saved and restored. |
| 184 | private final NotificationLockscreenUserManager mNotifUserManager; |
| 185 | |
Joshua Tsuji | f418f9e | 2019-04-04 17:09:53 -0400 | [diff] [blame] | 186 | /** Last known orientation, used to detect orientation changes in {@link #onConfigChanged}. */ |
| 187 | private int mOrientation = Configuration.ORIENTATION_UNDEFINED; |
| 188 | |
Mady Mellor | 3df7ab0 | 2019-12-09 15:07:10 -0800 | [diff] [blame] | 189 | private boolean mInflateSynchronously; |
| 190 | |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 191 | // TODO (b/145659174): allow for multiple callbacks to support the "shadow" new notif pipeline |
| 192 | private final List<NotifCallback> mCallbacks = new ArrayList<>(); |
| 193 | |
Mady Mellor | 5549dd2 | 2018-11-06 18:07:34 -0800 | [diff] [blame] | 194 | /** |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 195 | * Listener to be notified when some states of the bubbles change. |
| 196 | */ |
| 197 | public interface BubbleStateChangeListener { |
| 198 | /** |
| 199 | * Called when the stack has bubbles or no longer has bubbles. |
| 200 | */ |
| 201 | void onHasBubblesChanged(boolean hasBubbles); |
| 202 | } |
| 203 | |
Mady Mellor | cd9b130 | 2018-11-06 18:08:04 -0800 | [diff] [blame] | 204 | /** |
| 205 | * Listener to find out about stack expansion / collapse events. |
| 206 | */ |
| 207 | public interface BubbleExpandListener { |
| 208 | /** |
| 209 | * Called when the expansion state of the bubble stack changes. |
Lyn Han | f1c9b8b | 2019-03-14 16:49:48 -0700 | [diff] [blame] | 210 | * |
Mady Mellor | cd9b130 | 2018-11-06 18:08:04 -0800 | [diff] [blame] | 211 | * @param isExpanding whether it's expanding or collapsing |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 212 | * @param key the notification key associated with bubble being expanded |
Mady Mellor | cd9b130 | 2018-11-06 18:08:04 -0800 | [diff] [blame] | 213 | */ |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 214 | void onBubbleExpandChanged(boolean isExpanding, String key); |
| 215 | } |
| 216 | |
| 217 | /** |
Mady Mellor | f44b683 | 2020-01-14 13:26:14 -0800 | [diff] [blame] | 218 | * Listener to be notified when a bubbles' notification suppression state changes. |
| 219 | */ |
| 220 | public interface NotificationSuppressionChangedListener { |
| 221 | /** |
| 222 | * Called when the notification suppression state of a bubble changes. |
| 223 | */ |
| 224 | void onBubbleNotificationSuppressionChange(Bubble bubble); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 225 | } |
Mady Mellor | f44b683 | 2020-01-14 13:26:14 -0800 | [diff] [blame] | 226 | |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 227 | /** |
| 228 | * Callback for when the BubbleController wants to interact with the notification pipeline to: |
| 229 | * - Remove a previously bubbled notification |
| 230 | * - Update the notification shade since bubbled notification should/shouldn't be showing |
| 231 | */ |
| 232 | public interface NotifCallback { |
| 233 | /** |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 234 | * Called when a bubbled notification that was hidden from the shade is now being removed |
| 235 | * This can happen when an app cancels a bubbled notification or when the user dismisses a |
| 236 | * bubble. |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 237 | */ |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 238 | void removeNotification(NotificationEntry entry, int reason); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 239 | |
| 240 | /** |
| 241 | * Called when a bubbled notification has changed whether it should be |
| 242 | * filtered from the shade. |
| 243 | */ |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 244 | void invalidateNotifications(String reason); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 245 | |
| 246 | /** |
| 247 | * Called on a bubbled entry that has been removed when there are no longer |
| 248 | * bubbled entries in its group. |
| 249 | * |
| 250 | * Checks whether its group has any other (non-bubbled) children. If it doesn't, |
| 251 | * removes all remnants of the group's summary from the notification pipeline. |
| 252 | * TODO: (b/145659174) Only old pipeline needs this - delete post-migration. |
| 253 | */ |
| 254 | void maybeCancelSummary(NotificationEntry entry); |
Mady Mellor | f44b683 | 2020-01-14 13:26:14 -0800 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | /** |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 258 | * Listens for the current state of the status bar and updates the visibility state |
| 259 | * of bubbles as needed. |
| 260 | */ |
| 261 | private class StatusBarStateListener implements StatusBarStateController.StateListener { |
| 262 | private int mState; |
| 263 | /** |
| 264 | * Returns the current status bar state. |
| 265 | */ |
| 266 | public int getCurrentState() { |
| 267 | return mState; |
| 268 | } |
| 269 | |
| 270 | @Override |
| 271 | public void onStateChanged(int newState) { |
| 272 | mState = newState; |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 273 | boolean shouldCollapse = (mState != SHADE); |
| 274 | if (shouldCollapse) { |
| 275 | collapseStack(); |
| 276 | } |
Lyn Han | 6c40fe7 | 2019-05-08 14:06:33 -0700 | [diff] [blame] | 277 | updateStack(); |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 278 | } |
Mady Mellor | cd9b130 | 2018-11-06 18:08:04 -0800 | [diff] [blame] | 279 | } |
| 280 | |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 281 | public BubbleController(Context context, |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 282 | NotificationShadeWindowController notificationShadeWindowController, |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 283 | StatusBarStateController statusBarStateController, |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 284 | ShadeController shadeController, |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 285 | BubbleData data, |
Mady Mellor | aa8fef2 | 2019-04-11 13:36:40 -0700 | [diff] [blame] | 286 | ConfigurationController configurationController, |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 287 | NotificationInterruptStateProvider interruptionStateProvider, |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 288 | ZenModeController zenModeController, |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 289 | NotificationLockscreenUserManager notifUserManager, |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 290 | NotificationGroupManager groupManager, |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 291 | NotificationEntryManager entryManager, |
| 292 | NotifPipeline notifPipeline, |
| 293 | FeatureFlags featureFlags, |
Ned Burns | aaeb44b | 2020-02-12 23:48:26 -0500 | [diff] [blame] | 294 | DumpManager dumpManager, |
Joshua Tsuji | be60a58 | 2020-03-23 17:17:26 -0400 | [diff] [blame] | 295 | FloatingContentCoordinator floatingContentCoordinator, |
| 296 | SysUiState sysUiState) { |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 297 | this(context, notificationShadeWindowController, statusBarStateController, shadeController, |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 298 | data, null /* synchronizer */, configurationController, interruptionStateProvider, |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 299 | zenModeController, notifUserManager, groupManager, entryManager, |
Joshua Tsuji | be60a58 | 2020-03-23 17:17:26 -0400 | [diff] [blame] | 300 | notifPipeline, featureFlags, dumpManager, floatingContentCoordinator, sysUiState); |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 301 | } |
| 302 | |
Sergey Nikolaienkov | 5cb6e52 | 2020-02-10 17:33:00 +0100 | [diff] [blame] | 303 | /** |
| 304 | * Injected constructor. See {@link BubbleModule}. |
| 305 | */ |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 306 | public BubbleController(Context context, |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 307 | NotificationShadeWindowController notificationShadeWindowController, |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 308 | StatusBarStateController statusBarStateController, |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 309 | ShadeController shadeController, |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 310 | BubbleData data, |
| 311 | @Nullable BubbleStackView.SurfaceSynchronizer synchronizer, |
| 312 | ConfigurationController configurationController, |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 313 | NotificationInterruptStateProvider interruptionStateProvider, |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 314 | ZenModeController zenModeController, |
| 315 | NotificationLockscreenUserManager notifUserManager, |
| 316 | NotificationGroupManager groupManager, |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 317 | NotificationEntryManager entryManager, |
| 318 | NotifPipeline notifPipeline, |
| 319 | FeatureFlags featureFlags, |
Ned Burns | aaeb44b | 2020-02-12 23:48:26 -0500 | [diff] [blame] | 320 | DumpManager dumpManager, |
Joshua Tsuji | be60a58 | 2020-03-23 17:17:26 -0400 | [diff] [blame] | 321 | FloatingContentCoordinator floatingContentCoordinator, |
| 322 | SysUiState sysUiState) { |
Ned Burns | aaeb44b | 2020-02-12 23:48:26 -0500 | [diff] [blame] | 323 | dumpManager.registerDumpable(TAG, this); |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 324 | mContext = context; |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 325 | mShadeController = shadeController; |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 326 | mNotificationInterruptStateProvider = interruptionStateProvider; |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 327 | mNotifUserManager = notifUserManager; |
Joshua Tsuji | dd4d9f9 | 2019-05-13 13:57:38 -0400 | [diff] [blame] | 328 | mZenModeController = zenModeController; |
Joshua Tsuji | 7155bf1 | 2020-02-13 16:14:29 -0500 | [diff] [blame] | 329 | mFloatingContentCoordinator = floatingContentCoordinator; |
Joshua Tsuji | dd4d9f9 | 2019-05-13 13:57:38 -0400 | [diff] [blame] | 330 | mZenModeController.addCallback(new ZenModeController.Callback() { |
| 331 | @Override |
| 332 | public void onZenChanged(int zen) { |
Mady Mellor | b8aaf97 | 2019-11-26 10:28:00 -0800 | [diff] [blame] | 333 | for (Bubble b : mBubbleData.getBubbles()) { |
Joshua Tsuji | 2ed260e | 2020-03-26 14:26:01 -0400 | [diff] [blame^] | 334 | b.setShowDot(b.showInShade()); |
Mady Mellor | df48d0a | 2019-06-25 18:26:46 -0700 | [diff] [blame] | 335 | } |
Joshua Tsuji | dd4d9f9 | 2019-05-13 13:57:38 -0400 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | @Override |
| 339 | public void onConfigChanged(ZenModeConfig config) { |
Mady Mellor | b8aaf97 | 2019-11-26 10:28:00 -0800 | [diff] [blame] | 340 | for (Bubble b : mBubbleData.getBubbles()) { |
Joshua Tsuji | 2ed260e | 2020-03-26 14:26:01 -0400 | [diff] [blame^] | 341 | b.setShowDot(b.showInShade()); |
Mady Mellor | df48d0a | 2019-06-25 18:26:46 -0700 | [diff] [blame] | 342 | } |
Joshua Tsuji | dd4d9f9 | 2019-05-13 13:57:38 -0400 | [diff] [blame] | 343 | } |
| 344 | }); |
Mady Mellor | aa8fef2 | 2019-04-11 13:36:40 -0700 | [diff] [blame] | 345 | |
Lyn Han | f1c9b8b | 2019-03-14 16:49:48 -0700 | [diff] [blame] | 346 | configurationController.addCallback(this /* configurationListener */); |
Joshua Tsuji | be60a58 | 2020-03-23 17:17:26 -0400 | [diff] [blame] | 347 | mSysUiState = sysUiState; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 348 | |
Mark Renouf | 9ba6cea | 2019-04-17 11:53:50 -0400 | [diff] [blame] | 349 | mBubbleData = data; |
| 350 | mBubbleData.setListener(mBubbleDataListener); |
Mady Mellor | f44b683 | 2020-01-14 13:26:14 -0800 | [diff] [blame] | 351 | mBubbleData.setSuppressionChangedListener(new NotificationSuppressionChangedListener() { |
| 352 | @Override |
| 353 | public void onBubbleNotificationSuppressionChange(Bubble bubble) { |
| 354 | // Make sure NoMan knows it's not showing in the shade anymore so anyone querying it |
| 355 | // can tell. |
| 356 | try { |
| 357 | mBarService.onBubbleNotificationSuppressionChanged(bubble.getKey(), |
| 358 | !bubble.showInShade()); |
| 359 | } catch (RemoteException e) { |
| 360 | // Bad things have happened |
| 361 | } |
| 362 | } |
| 363 | }); |
Mark Renouf | 9ba6cea | 2019-04-17 11:53:50 -0400 | [diff] [blame] | 364 | |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 365 | mNotificationEntryManager = entryManager; |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 366 | mNotificationGroupManager = groupManager; |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 367 | mNotifPipeline = notifPipeline; |
| 368 | |
| 369 | if (!featureFlags.isNewNotifPipelineRenderingEnabled()) { |
| 370 | setupNEM(); |
| 371 | } else { |
| 372 | setupNotifPipeline(); |
| 373 | } |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 374 | |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 375 | mNotificationShadeWindowController = notificationShadeWindowController; |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 376 | mStatusBarStateListener = new StatusBarStateListener(); |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 377 | statusBarStateController.addCallback(mStatusBarStateListener); |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 378 | |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 379 | mTaskStackListener = new BubbleTaskStackListener(); |
| 380 | ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener); |
Mady Mellor | 3dff9e6 | 2019-02-05 18:12:53 -0800 | [diff] [blame] | 381 | |
Joshua Tsuji | a19515f | 2019-02-13 18:02:29 -0500 | [diff] [blame] | 382 | try { |
| 383 | WindowManagerWrapper.getInstance().addPinnedStackListener(new BubblesImeListener()); |
| 384 | } catch (RemoteException e) { |
| 385 | e.printStackTrace(); |
| 386 | } |
Issei Suzuki | c038754 | 2019-03-08 17:31:14 +0100 | [diff] [blame] | 387 | mSurfaceSynchronizer = synchronizer; |
Mady Mellor | a54e9fa | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 388 | |
| 389 | mBarService = IStatusBarService.Stub.asInterface( |
| 390 | ServiceManager.getService(Context.STATUS_BAR_SERVICE)); |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 391 | |
| 392 | mSavedBubbleKeysPerUser = new SparseSetArray<>(); |
| 393 | mCurrentUserId = mNotifUserManager.getCurrentUserId(); |
| 394 | mNotifUserManager.addUserChangedListener( |
Steve Elliott | b47f1c7 | 2019-12-19 12:39:26 -0500 | [diff] [blame] | 395 | new NotificationLockscreenUserManager.UserChangedListener() { |
| 396 | @Override |
| 397 | public void onUserChanged(int newUserId) { |
| 398 | BubbleController.this.saveBubbles(mCurrentUserId); |
| 399 | mBubbleData.dismissAll(DISMISS_USER_CHANGED); |
| 400 | BubbleController.this.restoreBubbles(newUserId); |
| 401 | mCurrentUserId = newUserId; |
| 402 | } |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 403 | }); |
Mady Mellor | ff076eb | 2019-11-13 10:12:06 -0800 | [diff] [blame] | 404 | |
| 405 | mUserCreatedBubbles = new HashSet<>(); |
Mady Mellor | 3b86a4f | 2019-12-11 13:15:41 -0800 | [diff] [blame] | 406 | mUserBlockedBubbles = new HashSet<>(); |
Aran Ink | aa4dfa7 | 2019-11-18 16:49:07 -0500 | [diff] [blame] | 407 | |
Mady Mellor | 247ca2c | 2019-12-02 16:18:59 -0800 | [diff] [blame] | 408 | mBubbleIconFactory = new BubbleIconFactory(context); |
Mady Mellor | 5549dd2 | 2018-11-06 18:07:34 -0800 | [diff] [blame] | 409 | } |
| 410 | |
Mark Renouf | 8b6a3c6 | 2019-04-09 10:17:40 -0400 | [diff] [blame] | 411 | /** |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 412 | * See {@link NotifCallback}. |
| 413 | */ |
| 414 | public void addNotifCallback(NotifCallback callback) { |
| 415 | mCallbacks.add(callback); |
| 416 | } |
| 417 | |
| 418 | private void setupNEM() { |
| 419 | mNotificationEntryManager.addNotificationEntryListener( |
| 420 | new NotificationEntryListener() { |
| 421 | @Override |
Mady Mellor | f9439ab | 2020-01-30 16:06:53 -0800 | [diff] [blame] | 422 | public void onPendingEntryAdded(NotificationEntry entry) { |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 423 | onEntryAdded(entry); |
| 424 | } |
| 425 | |
| 426 | @Override |
| 427 | public void onPreEntryUpdated(NotificationEntry entry) { |
| 428 | onEntryUpdated(entry); |
| 429 | } |
| 430 | |
| 431 | @Override |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 432 | public void onEntryRemoved( |
| 433 | NotificationEntry entry, |
| 434 | @android.annotation.Nullable NotificationVisibility visibility, |
Julia Reynolds | 138111f | 2020-02-26 11:17:39 -0500 | [diff] [blame] | 435 | boolean removedByUser, |
| 436 | int reason) { |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 437 | BubbleController.this.onEntryRemoved(entry); |
| 438 | } |
| 439 | |
| 440 | @Override |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 441 | public void onNotificationRankingUpdated(RankingMap rankingMap) { |
| 442 | onRankingUpdated(rankingMap); |
| 443 | } |
| 444 | }); |
| 445 | |
Evan Laird | 0437366 | 2020-01-24 17:37:39 -0500 | [diff] [blame] | 446 | mNotificationEntryManager.addNotificationRemoveInterceptor( |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 447 | new NotificationRemoveInterceptor() { |
| 448 | @Override |
Evan Laird | 0437366 | 2020-01-24 17:37:39 -0500 | [diff] [blame] | 449 | public boolean onNotificationRemoveRequested( |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 450 | String key, |
| 451 | NotificationEntry entry, |
| 452 | int dismissReason) { |
| 453 | final boolean isClearAll = dismissReason == REASON_CANCEL_ALL; |
| 454 | final boolean isUserDimiss = dismissReason == REASON_CANCEL |
| 455 | || dismissReason == REASON_CLICK; |
| 456 | final boolean isAppCancel = dismissReason == REASON_APP_CANCEL |
| 457 | || dismissReason == REASON_APP_CANCEL_ALL; |
| 458 | final boolean isSummaryCancel = |
| 459 | dismissReason == REASON_GROUP_SUMMARY_CANCELED; |
| 460 | |
| 461 | // Need to check for !appCancel here because the notification may have |
| 462 | // previously been dismissed & entry.isRowDismissed would still be true |
| 463 | boolean userRemovedNotif = |
| 464 | (entry != null && entry.isRowDismissed() && !isAppCancel) |
| 465 | || isClearAll || isUserDimiss || isSummaryCancel; |
| 466 | |
| 467 | if (userRemovedNotif || isUserCreatedBubble(key) |
| 468 | || isSummaryOfUserCreatedBubble(entry)) { |
| 469 | return handleDismissalInterception(entry); |
| 470 | } |
| 471 | |
| 472 | return false; |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 473 | } |
| 474 | }); |
| 475 | |
| 476 | mNotificationGroupManager.addOnGroupChangeListener( |
| 477 | new NotificationGroupManager.OnGroupChangeListener() { |
| 478 | @Override |
| 479 | public void onGroupSuppressionChanged( |
| 480 | NotificationGroupManager.NotificationGroup group, |
| 481 | boolean suppressed) { |
| 482 | // More notifications could be added causing summary to no longer |
| 483 | // be suppressed -- in this case need to remove the key. |
| 484 | final String groupKey = group.summary != null |
| 485 | ? group.summary.getSbn().getGroupKey() |
| 486 | : null; |
| 487 | if (!suppressed && groupKey != null |
| 488 | && mBubbleData.isSummarySuppressed(groupKey)) { |
| 489 | mBubbleData.removeSuppressedSummary(groupKey); |
| 490 | } |
| 491 | } |
| 492 | }); |
| 493 | |
| 494 | addNotifCallback(new NotifCallback() { |
| 495 | @Override |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 496 | public void removeNotification(NotificationEntry entry, int reason) { |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 497 | mNotificationEntryManager.performRemoveNotification(entry.getSbn(), |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 498 | reason); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | @Override |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 502 | public void invalidateNotifications(String reason) { |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 503 | mNotificationEntryManager.updateNotifications(reason); |
| 504 | } |
| 505 | |
| 506 | @Override |
| 507 | public void maybeCancelSummary(NotificationEntry entry) { |
| 508 | // Check if removed bubble has an associated suppressed group summary that needs |
| 509 | // to be removed now. |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 510 | final String groupKey = entry.getSbn().getGroupKey(); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 511 | if (mBubbleData.isSummarySuppressed(groupKey)) { |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 512 | mBubbleData.removeSuppressedSummary(groupKey); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 513 | |
| 514 | final NotificationEntry summary = |
| 515 | mNotificationEntryManager.getActiveNotificationUnfiltered( |
| 516 | mBubbleData.getSummaryKey(groupKey)); |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 517 | if (summary != null) { |
| 518 | mNotificationEntryManager.performRemoveNotification(summary.getSbn(), |
| 519 | UNDEFINED_DISMISS_REASON); |
| 520 | } |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 521 | } |
| 522 | |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 523 | // Check if we still need to remove the summary from NoManGroup because the summary |
| 524 | // may not be in the mBubbleData.mSuppressedGroupKeys list and removed above. |
| 525 | // For example: |
| 526 | // 1. Bubbled notifications (group) is posted to shade and are visible bubbles |
| 527 | // 2. User expands bubbles so now their respective notifications in the shade are |
| 528 | // hidden, including the group summary |
| 529 | // 3. User removes all bubbles |
| 530 | // 4. We expect all the removed bubbles AND the summary (note: the summary was |
| 531 | // never added to the suppressedSummary list in BubbleData, so we add this check) |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 532 | NotificationEntry summary = |
| 533 | mNotificationGroupManager.getLogicalGroupSummary(entry.getSbn()); |
| 534 | if (summary != null) { |
| 535 | ArrayList<NotificationEntry> summaryChildren = |
| 536 | mNotificationGroupManager.getLogicalChildren(summary.getSbn()); |
| 537 | boolean isSummaryThisNotif = summary.getKey().equals(entry.getKey()); |
| 538 | if (!isSummaryThisNotif && (summaryChildren == null |
| 539 | || summaryChildren.isEmpty())) { |
| 540 | mNotificationEntryManager.performRemoveNotification(summary.getSbn(), |
| 541 | UNDEFINED_DISMISS_REASON); |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | }); |
| 546 | } |
| 547 | |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 548 | private void setupNotifPipeline() { |
| 549 | mNotifPipeline.addCollectionListener(new NotifCollectionListener() { |
| 550 | @Override |
| 551 | public void onEntryAdded(NotificationEntry entry) { |
| 552 | BubbleController.this.onEntryAdded(entry); |
| 553 | } |
| 554 | |
| 555 | @Override |
| 556 | public void onEntryUpdated(NotificationEntry entry) { |
| 557 | BubbleController.this.onEntryUpdated(entry); |
| 558 | } |
| 559 | |
| 560 | @Override |
| 561 | public void onRankingUpdate(RankingMap rankingMap) { |
| 562 | onRankingUpdated(rankingMap); |
| 563 | } |
| 564 | |
| 565 | @Override |
| 566 | public void onEntryRemoved(NotificationEntry entry, |
| 567 | @NotifCollection.CancellationReason int reason) { |
| 568 | BubbleController.this.onEntryRemoved(entry); |
| 569 | } |
| 570 | }); |
| 571 | } |
| 572 | |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 573 | /** |
Mady Mellor | 3df7ab0 | 2019-12-09 15:07:10 -0800 | [diff] [blame] | 574 | * Sets whether to perform inflation on the same thread as the caller. This method should only |
| 575 | * be used in tests, not in production. |
| 576 | */ |
| 577 | @VisibleForTesting |
| 578 | void setInflateSynchronously(boolean inflateSynchronously) { |
| 579 | mInflateSynchronously = inflateSynchronously; |
Mady Mellor | 5549dd2 | 2018-11-06 18:07:34 -0800 | [diff] [blame] | 580 | } |
| 581 | |
Lyn Han | b58c756 | 2020-01-07 14:29:20 -0800 | [diff] [blame] | 582 | void setOverflowCallback(Runnable updateOverflow) { |
| 583 | mOverflowCallback = updateOverflow; |
| 584 | } |
| 585 | |
| 586 | /** |
| 587 | * @return Bubbles for updating overflow. |
| 588 | */ |
| 589 | List<Bubble> getOverflowBubbles() { |
| 590 | return mBubbleData.getOverflowBubbles(); |
| 591 | } |
| 592 | |
| 593 | |
Mark Renouf | 8b6a3c6 | 2019-04-09 10:17:40 -0400 | [diff] [blame] | 594 | /** |
| 595 | * BubbleStackView is lazily created by this method the first time a Bubble is added. This |
| 596 | * method initializes the stack view and adds it to the StatusBar just above the scrim. |
| 597 | */ |
| 598 | private void ensureStackViewCreated() { |
| 599 | if (mStackView == null) { |
Joshua Tsuji | 7155bf1 | 2020-02-13 16:14:29 -0500 | [diff] [blame] | 600 | mStackView = new BubbleStackView( |
Joshua Tsuji | be60a58 | 2020-03-23 17:17:26 -0400 | [diff] [blame] | 601 | mContext, mBubbleData, mSurfaceSynchronizer, mFloatingContentCoordinator, |
| 602 | mSysUiState); |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 603 | ViewGroup nsv = mNotificationShadeWindowController.getNotificationShadeView(); |
| 604 | int bubbleScrimIndex = nsv.indexOfChild(nsv.findViewById(R.id.scrim_for_bubble)); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame] | 605 | int stackIndex = bubbleScrimIndex + 1; // Show stack above bubble scrim. |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 606 | nsv.addView(mStackView, stackIndex, |
Mark Renouf | 8b6a3c6 | 2019-04-09 10:17:40 -0400 | [diff] [blame] | 607 | new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); |
| 608 | if (mExpandListener != null) { |
| 609 | mStackView.setExpandListener(mExpandListener); |
| 610 | } |
Mark Renouf | 8b6a3c6 | 2019-04-09 10:17:40 -0400 | [diff] [blame] | 611 | } |
| 612 | } |
| 613 | |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 614 | /** |
| 615 | * Records the notification key for any active bubbles. These are used to restore active |
| 616 | * bubbles when the user returns to the foreground. |
| 617 | * |
| 618 | * @param userId the id of the user |
| 619 | */ |
| 620 | private void saveBubbles(@UserIdInt int userId) { |
| 621 | // First clear any existing keys that might be stored. |
| 622 | mSavedBubbleKeysPerUser.remove(userId); |
| 623 | // Add in all active bubbles for the current user. |
| 624 | for (Bubble bubble: mBubbleData.getBubbles()) { |
| 625 | mSavedBubbleKeysPerUser.add(userId, bubble.getKey()); |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | /** |
| 630 | * Promotes existing notifications to Bubbles if they were previously bubbles. |
| 631 | * |
| 632 | * @param userId the id of the user |
| 633 | */ |
| 634 | private void restoreBubbles(@UserIdInt int userId) { |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 635 | ArraySet<String> savedBubbleKeys = mSavedBubbleKeysPerUser.get(userId); |
| 636 | if (savedBubbleKeys == null) { |
| 637 | // There were no bubbles saved for this used. |
| 638 | return; |
| 639 | } |
Evan Laird | 181de62 | 2019-10-24 09:53:02 -0400 | [diff] [blame] | 640 | for (NotificationEntry e : |
| 641 | mNotificationEntryManager.getActiveNotificationsForCurrentUser()) { |
Ned Burns | 00b4b2d | 2019-10-17 22:09:27 -0400 | [diff] [blame] | 642 | if (savedBubbleKeys.contains(e.getKey()) |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 643 | && mNotificationInterruptStateProvider.shouldBubbleUp(e) |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 644 | && canLaunchInActivityView(mContext, e)) { |
| 645 | updateBubble(e, /* suppressFlyout= */ true); |
| 646 | } |
| 647 | } |
| 648 | // Finally, remove the entries for this user now that bubbles are restored. |
| 649 | mSavedBubbleKeysPerUser.remove(mCurrentUserId); |
| 650 | } |
| 651 | |
Lyn Han | f1c9b8b | 2019-03-14 16:49:48 -0700 | [diff] [blame] | 652 | @Override |
| 653 | public void onUiModeChanged() { |
Mady Mellor | 247ca2c | 2019-12-02 16:18:59 -0800 | [diff] [blame] | 654 | updateForThemeChanges(); |
Lyn Han | f1c9b8b | 2019-03-14 16:49:48 -0700 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | @Override |
| 658 | public void onOverlayChanged() { |
Mady Mellor | 247ca2c | 2019-12-02 16:18:59 -0800 | [diff] [blame] | 659 | updateForThemeChanges(); |
| 660 | } |
| 661 | |
| 662 | private void updateForThemeChanges() { |
Lyn Han | f1c9b8b | 2019-03-14 16:49:48 -0700 | [diff] [blame] | 663 | if (mStackView != null) { |
Lyn Han | 02cca81 | 2019-04-02 16:27:32 -0700 | [diff] [blame] | 664 | mStackView.onThemeChanged(); |
Lyn Han | f1c9b8b | 2019-03-14 16:49:48 -0700 | [diff] [blame] | 665 | } |
Mady Mellor | 3df7ab0 | 2019-12-09 15:07:10 -0800 | [diff] [blame] | 666 | mBubbleIconFactory = new BubbleIconFactory(mContext); |
| 667 | for (Bubble b: mBubbleData.getBubbles()) { |
| 668 | // Reload each bubble |
| 669 | b.inflate(null /* callback */, mContext, mStackView, mBubbleIconFactory); |
| 670 | } |
Lyn Han | f1c9b8b | 2019-03-14 16:49:48 -0700 | [diff] [blame] | 671 | } |
| 672 | |
Joshua Tsuji | f418f9e | 2019-04-04 17:09:53 -0400 | [diff] [blame] | 673 | @Override |
| 674 | public void onConfigChanged(Configuration newConfig) { |
| 675 | if (mStackView != null && newConfig != null && newConfig.orientation != mOrientation) { |
Joshua Tsuji | f418f9e | 2019-04-04 17:09:53 -0400 | [diff] [blame] | 676 | mOrientation = newConfig.orientation; |
Lyn Han | f473031 | 2019-06-18 11:18:58 -0700 | [diff] [blame] | 677 | mStackView.onOrientationChanged(newConfig.orientation); |
Joshua Tsuji | f418f9e | 2019-04-04 17:09:53 -0400 | [diff] [blame] | 678 | } |
| 679 | } |
| 680 | |
Mady Mellor | 5549dd2 | 2018-11-06 18:07:34 -0800 | [diff] [blame] | 681 | /** |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 682 | * Set a listener to be notified when some states of the bubbles change. |
| 683 | */ |
| 684 | public void setBubbleStateChangeListener(BubbleStateChangeListener listener) { |
| 685 | mStateChangeListener = listener; |
| 686 | } |
| 687 | |
| 688 | /** |
Mady Mellor | cd9b130 | 2018-11-06 18:08:04 -0800 | [diff] [blame] | 689 | * Set a listener to be notified of bubble expand events. |
| 690 | */ |
| 691 | public void setExpandListener(BubbleExpandListener listener) { |
Issei Suzuki | ac9fcb7 | 2019-02-04 17:45:57 +0100 | [diff] [blame] | 692 | mExpandListener = ((isExpanding, key) -> { |
| 693 | if (listener != null) { |
| 694 | listener.onBubbleExpandChanged(isExpanding, key); |
| 695 | } |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 696 | mNotificationShadeWindowController.setBubbleExpanded(isExpanding); |
Issei Suzuki | ac9fcb7 | 2019-02-04 17:45:57 +0100 | [diff] [blame] | 697 | }); |
Mady Mellor | cd9b130 | 2018-11-06 18:08:04 -0800 | [diff] [blame] | 698 | if (mStackView != null) { |
| 699 | mStackView.setExpandListener(mExpandListener); |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | /** |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 704 | * Whether or not there are bubbles present, regardless of them being visible on the |
| 705 | * screen (e.g. if on AOD). |
| 706 | */ |
| 707 | public boolean hasBubbles() { |
Mady Mellor | 3dff9e6 | 2019-02-05 18:12:53 -0800 | [diff] [blame] | 708 | if (mStackView == null) { |
| 709 | return false; |
| 710 | } |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 711 | return mBubbleData.hasBubbles(); |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | /** |
| 715 | * Whether the stack of bubbles is expanded or not. |
| 716 | */ |
| 717 | public boolean isStackExpanded() { |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 718 | return mBubbleData.isExpanded(); |
| 719 | } |
| 720 | |
| 721 | /** |
| 722 | * Tell the stack of bubbles to expand. |
| 723 | */ |
| 724 | public void expandStack() { |
| 725 | mBubbleData.setExpanded(true); |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | /** |
| 729 | * Tell the stack of bubbles to collapse. |
| 730 | */ |
| 731 | public void collapseStack() { |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 732 | mBubbleData.setExpanded(false /* expanded */); |
| 733 | } |
| 734 | |
Mady Mellor | ce23c46 | 2019-06-17 17:30:07 -0700 | [diff] [blame] | 735 | /** |
Mady Mellor | e28fe10 | 2019-07-09 15:33:32 -0700 | [diff] [blame] | 736 | * True if either: |
| 737 | * (1) There is a bubble associated with the provided key and if its notification is hidden |
| 738 | * from the shade. |
| 739 | * (2) There is a group summary associated with the provided key that is hidden from the shade |
| 740 | * because it has been dismissed but still has child bubbles active. |
Mady Mellor | ce23c46 | 2019-06-17 17:30:07 -0700 | [diff] [blame] | 741 | * |
Mady Mellor | e28fe10 | 2019-07-09 15:33:32 -0700 | [diff] [blame] | 742 | * False otherwise. |
Mady Mellor | ce23c46 | 2019-06-17 17:30:07 -0700 | [diff] [blame] | 743 | */ |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 744 | public boolean isBubbleNotificationSuppressedFromShade(NotificationEntry entry) { |
| 745 | String key = entry.getKey(); |
Mady Mellor | e28fe10 | 2019-07-09 15:33:32 -0700 | [diff] [blame] | 746 | boolean isBubbleAndSuppressed = mBubbleData.hasBubbleWithKey(key) |
Mady Mellor | b8aaf97 | 2019-11-26 10:28:00 -0800 | [diff] [blame] | 747 | && !mBubbleData.getBubbleWithKey(key).showInShade(); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 748 | |
| 749 | String groupKey = entry.getSbn().getGroupKey(); |
Mady Mellor | e28fe10 | 2019-07-09 15:33:32 -0700 | [diff] [blame] | 750 | boolean isSuppressedSummary = mBubbleData.isSummarySuppressed(groupKey); |
Mady Mellor | e434827 | 2019-07-29 17:43:36 -0700 | [diff] [blame] | 751 | boolean isSummary = key.equals(mBubbleData.getSummaryKey(groupKey)); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 752 | |
Mady Mellor | e434827 | 2019-07-29 17:43:36 -0700 | [diff] [blame] | 753 | return (isSummary && isSuppressedSummary) || isBubbleAndSuppressed; |
Mady Mellor | ce23c46 | 2019-06-17 17:30:07 -0700 | [diff] [blame] | 754 | } |
| 755 | |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 756 | @VisibleForTesting |
| 757 | void selectBubble(String key) { |
| 758 | Bubble bubble = mBubbleData.getBubbleWithKey(key); |
Mady Mellor | 247ca2c | 2019-12-02 16:18:59 -0800 | [diff] [blame] | 759 | mBubbleData.setSelectedBubble(bubble); |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 760 | } |
| 761 | |
Lyn Han | b58c756 | 2020-01-07 14:29:20 -0800 | [diff] [blame] | 762 | void promoteBubbleFromOverflow(Bubble bubble) { |
Lyn Han | 1e19d7f | 2020-02-05 19:10:58 -0800 | [diff] [blame] | 763 | bubble.setInflateSynchronously(mInflateSynchronously); |
| 764 | mBubbleData.promoteBubbleFromOverflow(bubble, mStackView, mBubbleIconFactory); |
Lyn Han | b58c756 | 2020-01-07 14:29:20 -0800 | [diff] [blame] | 765 | } |
| 766 | |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 767 | /** |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 768 | * Request the stack expand if needed, then select the specified Bubble as current. |
| 769 | * |
| 770 | * @param notificationKey the notification key for the bubble to be selected |
| 771 | */ |
| 772 | public void expandStackAndSelectBubble(String notificationKey) { |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 773 | Bubble bubble = mBubbleData.getBubbleWithKey(notificationKey); |
| 774 | if (bubble != null) { |
| 775 | mBubbleData.setSelectedBubble(bubble); |
| 776 | mBubbleData.setExpanded(true); |
Mark Renouf | fec45da | 2019-03-13 13:24:27 -0400 | [diff] [blame] | 777 | } |
| 778 | } |
| 779 | |
| 780 | /** |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 781 | * Tell the stack of bubbles to be dismissed, this will remove all of the bubbles in the stack. |
| 782 | */ |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 783 | void dismissStack(@DismissReason int reason) { |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 784 | mBubbleData.dismissAll(reason); |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | /** |
Mark Renouf | 041d726 | 2019-02-06 12:09:41 -0500 | [diff] [blame] | 788 | * Directs a back gesture at the bubble stack. When opened, the current expanded bubble |
| 789 | * is forwarded a back key down/up pair. |
| 790 | */ |
| 791 | public void performBackPressIfNeeded() { |
| 792 | if (mStackView != null) { |
| 793 | mStackView.performBackPressIfNeeded(); |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | /** |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 798 | * Adds or updates a bubble associated with the provided notification entry. |
| 799 | * |
Mark Renouf | 8b6a3c6 | 2019-04-09 10:17:40 -0400 | [diff] [blame] | 800 | * @param notif the notification associated with this bubble. |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 801 | */ |
Mark Renouf | f97ed46 | 2019-04-05 13:46:24 -0400 | [diff] [blame] | 802 | void updateBubble(NotificationEntry notif) { |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 803 | updateBubble(notif, false /* suppressFlyout */); |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | void updateBubble(NotificationEntry notif, boolean suppressFlyout) { |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 807 | updateBubble(notif, suppressFlyout, true /* showInShade */); |
| 808 | } |
| 809 | |
| 810 | void updateBubble(NotificationEntry notif, boolean suppressFlyout, boolean showInShade) { |
Mady Mellor | 3df7ab0 | 2019-12-09 15:07:10 -0800 | [diff] [blame] | 811 | if (mStackView == null) { |
| 812 | // Lazy init stack view when a bubble is created |
| 813 | ensureStackViewCreated(); |
| 814 | } |
Mady Mellor | 66efd5e | 2019-05-15 13:38:11 -0700 | [diff] [blame] | 815 | // If this is an interruptive notif, mark that it's interrupted |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 816 | if (notif.getImportance() >= NotificationManager.IMPORTANCE_HIGH) { |
Mady Mellor | 66efd5e | 2019-05-15 13:38:11 -0700 | [diff] [blame] | 817 | notif.setInterruption(); |
| 818 | } |
Mady Mellor | 3df7ab0 | 2019-12-09 15:07:10 -0800 | [diff] [blame] | 819 | Bubble bubble = mBubbleData.getOrCreateBubble(notif); |
| 820 | bubble.setInflateSynchronously(mInflateSynchronously); |
| 821 | bubble.inflate( |
| 822 | b -> mBubbleData.notificationEntryUpdated(b, suppressFlyout, showInShade), |
| 823 | mContext, mStackView, mBubbleIconFactory); |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | /** |
| 827 | * Called when a user has indicated that an active notification should be shown as a bubble. |
| 828 | * <p> |
| 829 | * This method will collapse the shade, create the bubble without a flyout or dot, and suppress |
| 830 | * the notification from appearing in the shade. |
| 831 | * |
| 832 | * @param entry the notification to show as a bubble. |
| 833 | */ |
| 834 | public void onUserCreatedBubbleFromNotification(NotificationEntry entry) { |
Mady Mellor | ff076eb | 2019-11-13 10:12:06 -0800 | [diff] [blame] | 835 | if (DEBUG_EXPERIMENTS || DEBUG_BUBBLE_CONTROLLER) { |
| 836 | Log.d(TAG, "onUserCreatedBubble: " + entry.getKey()); |
| 837 | } |
Heemin Seog | ba6337f | 2019-12-10 15:34:37 -0800 | [diff] [blame] | 838 | mShadeController.collapsePanel(true); |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 839 | entry.setFlagBubble(true); |
| 840 | updateBubble(entry, true /* suppressFlyout */, false /* showInShade */); |
Mady Mellor | ff076eb | 2019-11-13 10:12:06 -0800 | [diff] [blame] | 841 | mUserCreatedBubbles.add(entry.getKey()); |
Mady Mellor | 3b86a4f | 2019-12-11 13:15:41 -0800 | [diff] [blame] | 842 | mUserBlockedBubbles.remove(entry.getKey()); |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | /** |
| 846 | * Called when a user has indicated that an active notification appearing as a bubble should |
| 847 | * no longer be shown as a bubble. |
| 848 | * |
| 849 | * @param entry the notification to no longer show as a bubble. |
| 850 | */ |
| 851 | public void onUserDemotedBubbleFromNotification(NotificationEntry entry) { |
Mady Mellor | ff076eb | 2019-11-13 10:12:06 -0800 | [diff] [blame] | 852 | if (DEBUG_EXPERIMENTS || DEBUG_BUBBLE_CONTROLLER) { |
| 853 | Log.d(TAG, "onUserDemotedBubble: " + entry.getKey()); |
| 854 | } |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 855 | entry.setFlagBubble(false); |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 856 | removeBubble(entry, DISMISS_BLOCKED); |
Mady Mellor | ff076eb | 2019-11-13 10:12:06 -0800 | [diff] [blame] | 857 | mUserCreatedBubbles.remove(entry.getKey()); |
Mady Mellor | 3b86a4f | 2019-12-11 13:15:41 -0800 | [diff] [blame] | 858 | if (BubbleExperimentConfig.isPackageWhitelistedToAutoBubble( |
| 859 | mContext, entry.getSbn().getPackageName())) { |
| 860 | // This package is whitelist but user demoted the bubble, let's save it so we don't |
| 861 | // auto-bubble for the whitelist again. |
| 862 | mUserBlockedBubbles.add(entry.getKey()); |
| 863 | } |
Mady Mellor | ff076eb | 2019-11-13 10:12:06 -0800 | [diff] [blame] | 864 | } |
| 865 | |
| 866 | /** |
| 867 | * Whether this bubble was explicitly created by the user via a SysUI affordance. |
| 868 | */ |
| 869 | boolean isUserCreatedBubble(String key) { |
| 870 | return mUserCreatedBubbles.contains(key); |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 871 | } |
| 872 | |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 873 | boolean isSummaryOfUserCreatedBubble(NotificationEntry entry) { |
| 874 | if (isSummaryOfBubbles(entry)) { |
| 875 | List<Bubble> bubbleChildren = |
| 876 | mBubbleData.getBubblesInGroup(entry.getSbn().getGroupKey()); |
| 877 | for (int i = 0; i < bubbleChildren.size(); i++) { |
| 878 | // Check if any are user-created (i.e. experimental bubbles) |
| 879 | if (isUserCreatedBubble(bubbleChildren.get(i).getKey())) { |
| 880 | return true; |
| 881 | } |
| 882 | } |
| 883 | } |
| 884 | return false; |
| 885 | } |
| 886 | |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 887 | /** |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 888 | * Removes the bubble with the given NotificationEntry. |
Mark Renouf | 658c6bc | 2019-01-30 10:26:54 -0500 | [diff] [blame] | 889 | * <p> |
| 890 | * Must be called from the main thread. |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 891 | */ |
Mark Renouf | 658c6bc | 2019-01-30 10:26:54 -0500 | [diff] [blame] | 892 | @MainThread |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 893 | void removeBubble(NotificationEntry entry, int reason) { |
| 894 | if (mBubbleData.hasBubbleWithKey(entry.getKey())) { |
| 895 | mBubbleData.notificationEntryRemoved(entry, reason); |
Mady Mellor | e8e0771 | 2019-01-23 12:45:33 -0800 | [diff] [blame] | 896 | } |
| 897 | } |
| 898 | |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 899 | private void onEntryAdded(NotificationEntry entry) { |
| 900 | boolean previouslyUserCreated = mUserCreatedBubbles.contains(entry.getKey()); |
| 901 | boolean userBlocked = mUserBlockedBubbles.contains(entry.getKey()); |
| 902 | boolean wasAdjusted = BubbleExperimentConfig.adjustForExperiments( |
| 903 | mContext, entry, previouslyUserCreated, userBlocked); |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 904 | |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 905 | if (mNotificationInterruptStateProvider.shouldBubbleUp(entry) |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 906 | && (canLaunchInActivityView(mContext, entry) || wasAdjusted)) { |
| 907 | if (wasAdjusted && !previouslyUserCreated) { |
| 908 | // Gotta treat the auto-bubbled / whitelisted packaged bubbles as usercreated |
| 909 | mUserCreatedBubbles.add(entry.getKey()); |
Mady Mellor | c2ff011 | 2019-03-28 14:18:06 -0700 | [diff] [blame] | 910 | } |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 911 | updateBubble(entry); |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 912 | } |
| 913 | } |
| 914 | |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 915 | private void onEntryUpdated(NotificationEntry entry) { |
| 916 | boolean previouslyUserCreated = mUserCreatedBubbles.contains(entry.getKey()); |
| 917 | boolean userBlocked = mUserBlockedBubbles.contains(entry.getKey()); |
| 918 | boolean wasAdjusted = BubbleExperimentConfig.adjustForExperiments( |
| 919 | mContext, entry, previouslyUserCreated, userBlocked); |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 920 | |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 921 | boolean shouldBubble = mNotificationInterruptStateProvider.shouldBubbleUp(entry) |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 922 | && (canLaunchInActivityView(mContext, entry) || wasAdjusted); |
| 923 | if (!shouldBubble && mBubbleData.hasBubbleWithKey(entry.getKey())) { |
| 924 | // It was previously a bubble but no longer a bubble -- lets remove it |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 925 | removeBubble(entry, DISMISS_NO_LONGER_BUBBLE); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 926 | } else if (shouldBubble) { |
| 927 | if (wasAdjusted && !previouslyUserCreated) { |
| 928 | // Gotta treat the auto-bubbled / whitelisted packaged bubbles as usercreated |
| 929 | mUserCreatedBubbles.add(entry.getKey()); |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 930 | } |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 931 | updateBubble(entry); |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 932 | } |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 933 | } |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 934 | |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 935 | private void onEntryRemoved(NotificationEntry entry) { |
| 936 | if (isSummaryOfBubbles(entry)) { |
| 937 | final String groupKey = entry.getSbn().getGroupKey(); |
| 938 | mBubbleData.removeSuppressedSummary(groupKey); |
| 939 | |
| 940 | // Remove any associated bubble children with the summary |
| 941 | final List<Bubble> bubbleChildren = mBubbleData.getBubblesInGroup(groupKey); |
| 942 | for (int i = 0; i < bubbleChildren.size(); i++) { |
| 943 | removeBubble(bubbleChildren.get(i).getEntry(), DISMISS_GROUP_CANCELLED); |
| 944 | } |
| 945 | } else { |
| 946 | removeBubble(entry, DISMISS_NOTIF_CANCEL); |
| 947 | } |
| 948 | } |
| 949 | |
Mady Mellor | 56515c4 | 2020-02-18 17:58:36 -0800 | [diff] [blame] | 950 | /** |
| 951 | * Called when NotificationListener has received adjusted notification rank and reapplied |
| 952 | * filtering and sorting. This is used to dismiss or create bubbles based on changes in |
| 953 | * permissions on the notification channel or the global setting. |
| 954 | * |
| 955 | * @param rankingMap the updated ranking map from NotificationListenerService |
| 956 | */ |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 957 | private void onRankingUpdated(RankingMap rankingMap) { |
Mady Mellor | 56515c4 | 2020-02-18 17:58:36 -0800 | [diff] [blame] | 958 | if (mTmpRanking == null) { |
| 959 | mTmpRanking = new NotificationListenerService.Ranking(); |
| 960 | } |
| 961 | String[] orderedKeys = rankingMap.getOrderedKeys(); |
| 962 | for (int i = 0; i < orderedKeys.length; i++) { |
| 963 | String key = orderedKeys[i]; |
| 964 | NotificationEntry entry = mNotificationEntryManager.getPendingOrActiveNotif(key); |
| 965 | rankingMap.getRanking(key, mTmpRanking); |
Mady Mellor | e45ff86 | 2020-03-24 15:54:50 -0700 | [diff] [blame] | 966 | boolean isActiveBubble = mBubbleData.hasBubbleWithKey(key); |
| 967 | if (isActiveBubble && !mTmpRanking.canBubble()) { |
Mady Mellor | 56515c4 | 2020-02-18 17:58:36 -0800 | [diff] [blame] | 968 | mBubbleData.notificationEntryRemoved(entry, BubbleController.DISMISS_BLOCKED); |
Mady Mellor | e45ff86 | 2020-03-24 15:54:50 -0700 | [diff] [blame] | 969 | } else if (entry != null && mTmpRanking.isBubble() && !isActiveBubble) { |
Mady Mellor | 56515c4 | 2020-02-18 17:58:36 -0800 | [diff] [blame] | 970 | entry.setFlagBubble(true); |
| 971 | onEntryUpdated(entry); |
| 972 | } |
| 973 | } |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 974 | } |
Ned Burns | 01e3821 | 2019-01-03 16:32:52 -0500 | [diff] [blame] | 975 | |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 976 | @SuppressWarnings("FieldCanBeLocal") |
Mark Renouf | 3bc5b36 | 2019-04-05 14:37:59 -0400 | [diff] [blame] | 977 | private final BubbleData.Listener mBubbleDataListener = new BubbleData.Listener() { |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 978 | |
Mark Renouf | 3bc5b36 | 2019-04-05 14:37:59 -0400 | [diff] [blame] | 979 | @Override |
Mark Renouf | 82a40e6 | 2019-05-23 16:16:24 -0400 | [diff] [blame] | 980 | public void applyUpdate(BubbleData.Update update) { |
Lyn Han | b58c756 | 2020-01-07 14:29:20 -0800 | [diff] [blame] | 981 | // Update bubbles in overflow. |
| 982 | if (mOverflowCallback != null) { |
| 983 | mOverflowCallback.run(); |
| 984 | } |
| 985 | |
Mark Renouf | 82a40e6 | 2019-05-23 16:16:24 -0400 | [diff] [blame] | 986 | // Collapsing? Do this first before remaining steps. |
| 987 | if (update.expandedChanged && !update.expanded) { |
| 988 | mStackView.setExpanded(false); |
| 989 | } |
| 990 | |
| 991 | // Do removals, if any. |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 992 | ArrayList<Pair<Bubble, Integer>> removedBubbles = |
| 993 | new ArrayList<>(update.removedBubbles); |
| 994 | for (Pair<Bubble, Integer> removed : removedBubbles) { |
Mark Renouf | 82a40e6 | 2019-05-23 16:16:24 -0400 | [diff] [blame] | 995 | final Bubble bubble = removed.first; |
| 996 | @DismissReason final int reason = removed.second; |
| 997 | mStackView.removeBubble(bubble); |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 998 | // If the bubble is removed for user switching, leave the notification in place. |
| 999 | if (reason != DISMISS_USER_CHANGED) { |
| 1000 | if (!mBubbleData.hasBubbleWithKey(bubble.getKey()) |
Mady Mellor | b8aaf97 | 2019-11-26 10:28:00 -0800 | [diff] [blame] | 1001 | && !bubble.showInShade()) { |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1002 | // The bubble is now gone & the notification is hidden from the shade, so |
| 1003 | // time to actually remove it |
| 1004 | for (NotifCallback cb : mCallbacks) { |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1005 | cb.removeNotification(bubble.getEntry(), REASON_CANCEL); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1006 | } |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 1007 | } else { |
| 1008 | // Update the flag for SysUI |
Ned Burns | 00b4b2d | 2019-10-17 22:09:27 -0400 | [diff] [blame] | 1009 | bubble.getEntry().getSbn().getNotification().flags &= ~FLAG_BUBBLE; |
Mady Mellor | 3a0a1b4 | 2019-05-23 06:40:21 -0700 | [diff] [blame] | 1010 | |
Mark Renouf | c19b473 | 2019-06-26 12:08:33 -0400 | [diff] [blame] | 1011 | // Make sure NoMan knows it's not a bubble anymore so anyone querying it |
| 1012 | // will get right result back |
| 1013 | try { |
| 1014 | mBarService.onNotificationBubbleChanged(bubble.getKey(), |
| 1015 | false /* isBubble */); |
| 1016 | } catch (RemoteException e) { |
| 1017 | // Bad things have happened |
| 1018 | } |
Mark Renouf | 82a40e6 | 2019-05-23 16:16:24 -0400 | [diff] [blame] | 1019 | } |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 1020 | |
Ned Burns | 00b4b2d | 2019-10-17 22:09:27 -0400 | [diff] [blame] | 1021 | final String groupKey = bubble.getEntry().getSbn().getGroupKey(); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1022 | if (mBubbleData.getBubblesInGroup(groupKey).isEmpty()) { |
| 1023 | // Time to potentially remove the summary |
| 1024 | for (NotifCallback cb : mCallbacks) { |
| 1025 | cb.maybeCancelSummary(bubble.getEntry()); |
Mady Mellor | 22f2f07 | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 1026 | } |
| 1027 | } |
Mady Mellor | a54e9fa | 2019-04-18 13:26:18 -0700 | [diff] [blame] | 1028 | } |
| 1029 | } |
Mark Renouf | 3bc5b36 | 2019-04-05 14:37:59 -0400 | [diff] [blame] | 1030 | |
Lyn Han | c47e171 | 2020-01-28 21:43:34 -0800 | [diff] [blame] | 1031 | if (update.addedBubble != null) { |
| 1032 | mStackView.addBubble(update.addedBubble); |
| 1033 | } |
| 1034 | |
Mark Renouf | 82a40e6 | 2019-05-23 16:16:24 -0400 | [diff] [blame] | 1035 | if (update.updatedBubble != null) { |
| 1036 | mStackView.updateBubble(update.updatedBubble); |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 1037 | } |
Mark Renouf | 3bc5b36 | 2019-04-05 14:37:59 -0400 | [diff] [blame] | 1038 | |
Lyn Han | b58c756 | 2020-01-07 14:29:20 -0800 | [diff] [blame] | 1039 | // At this point, the correct bubbles are inflated in the stack. |
| 1040 | // Make sure the order in bubble data is reflected in bubble row. |
Mark Renouf | 82a40e6 | 2019-05-23 16:16:24 -0400 | [diff] [blame] | 1041 | if (update.orderChanged) { |
| 1042 | mStackView.updateBubbleOrder(update.bubbles); |
Mark Renouf | ba5ab51 | 2019-05-02 15:21:01 -0400 | [diff] [blame] | 1043 | } |
Mark Renouf | 3bc5b36 | 2019-04-05 14:37:59 -0400 | [diff] [blame] | 1044 | |
Mark Renouf | 82a40e6 | 2019-05-23 16:16:24 -0400 | [diff] [blame] | 1045 | if (update.selectionChanged) { |
| 1046 | mStackView.setSelectedBubble(update.selectedBubble); |
Mady Mellor | 740d85d | 2019-07-09 15:26:47 -0700 | [diff] [blame] | 1047 | if (update.selectedBubble != null) { |
| 1048 | mNotificationGroupManager.updateSuppression( |
| 1049 | update.selectedBubble.getEntry()); |
| 1050 | } |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 1051 | } |
Mark Renouf | 3bc5b36 | 2019-04-05 14:37:59 -0400 | [diff] [blame] | 1052 | |
Mark Renouf | 82a40e6 | 2019-05-23 16:16:24 -0400 | [diff] [blame] | 1053 | // Expanding? Apply this last. |
| 1054 | if (update.expandedChanged && update.expanded) { |
| 1055 | mStackView.setExpanded(true); |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 1056 | } |
Mark Renouf | 3bc5b36 | 2019-04-05 14:37:59 -0400 | [diff] [blame] | 1057 | |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1058 | for (NotifCallback cb : mCallbacks) { |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1059 | cb.invalidateNotifications("BubbleData.Listener.applyUpdate"); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1060 | } |
Lyn Han | 6c40fe7 | 2019-05-08 14:06:33 -0700 | [diff] [blame] | 1061 | updateStack(); |
Mark Renouf | 9ba6cea | 2019-04-17 11:53:50 -0400 | [diff] [blame] | 1062 | |
Issei Suzuki | a8d0731 | 2019-06-07 12:56:19 +0200 | [diff] [blame] | 1063 | if (DEBUG_BUBBLE_CONTROLLER) { |
Lyn Han | b58c756 | 2020-01-07 14:29:20 -0800 | [diff] [blame] | 1064 | Log.d(TAG, "\n[BubbleData] bubbles:"); |
Lyn Han | 767d70e | 2019-12-10 18:02:23 -0800 | [diff] [blame] | 1065 | Log.d(TAG, BubbleDebugConfig.formatBubblesString(mBubbleData.getBubbles(), |
Mark Renouf | 9ba6cea | 2019-04-17 11:53:50 -0400 | [diff] [blame] | 1066 | mBubbleData.getSelectedBubble())); |
| 1067 | |
| 1068 | if (mStackView != null) { |
Lyn Han | b58c756 | 2020-01-07 14:29:20 -0800 | [diff] [blame] | 1069 | Log.d(TAG, "\n[BubbleStackView]"); |
Lyn Han | 767d70e | 2019-12-10 18:02:23 -0800 | [diff] [blame] | 1070 | Log.d(TAG, BubbleDebugConfig.formatBubblesString(mStackView.getBubblesOnScreen(), |
Mark Renouf | 9ba6cea | 2019-04-17 11:53:50 -0400 | [diff] [blame] | 1071 | mStackView.getExpandedBubble())); |
| 1072 | } |
Lyn Han | b58c756 | 2020-01-07 14:29:20 -0800 | [diff] [blame] | 1073 | Log.d(TAG, "\n[BubbleData] overflow:"); |
| 1074 | Log.d(TAG, BubbleDebugConfig.formatBubblesString(mBubbleData.getOverflowBubbles(), |
| 1075 | null)); |
Mark Renouf | 9ba6cea | 2019-04-17 11:53:50 -0400 | [diff] [blame] | 1076 | } |
Mark Renouf | 3bc5b36 | 2019-04-05 14:37:59 -0400 | [diff] [blame] | 1077 | } |
| 1078 | }; |
| 1079 | |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 1080 | /** |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1081 | * We intercept notification entries (including group summaries) dismissed by the user when |
| 1082 | * there is an active bubble associated with it. We do this so that developers can still |
| 1083 | * cancel it (and hence the bubbles associated with it). However, these intercepted |
| 1084 | * notifications should then be hidden from the shade since the user has cancelled them, so we |
| 1085 | * {@link Bubble#setSuppressNotification}. For the case of suppressed summaries, we also add |
| 1086 | * {@link BubbleData#addSummaryToSuppress}. |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1087 | * |
Mady Mellor | 91b31e6 | 2020-01-30 17:40:48 -0800 | [diff] [blame] | 1088 | * @return true if we want to intercept the dismissal of the entry, else false. |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1089 | */ |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1090 | public boolean handleDismissalInterception(NotificationEntry entry) { |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1091 | if (entry == null) { |
| 1092 | return false; |
| 1093 | } |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1094 | |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1095 | final boolean interceptBubbleDismissal = mBubbleData.hasBubbleWithKey(entry.getKey()) |
| 1096 | && entry.isBubble(); |
| 1097 | final boolean interceptSummaryDismissal = isSummaryOfBubbles(entry); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1098 | |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1099 | if (interceptSummaryDismissal) { |
| 1100 | handleSummaryDismissalInterception(entry); |
| 1101 | } else if (interceptBubbleDismissal) { |
| 1102 | Bubble bubble = mBubbleData.getBubbleWithKey(entry.getKey()); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1103 | bubble.setSuppressNotification(true); |
Joshua Tsuji | 2ed260e | 2020-03-26 14:26:01 -0400 | [diff] [blame^] | 1104 | bubble.setShowDot(false /* show */); |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1105 | } else { |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1106 | return false; |
| 1107 | } |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1108 | |
| 1109 | // Update the shade |
| 1110 | for (NotifCallback cb : mCallbacks) { |
| 1111 | cb.invalidateNotifications("BubbleController.handleDismissalInterception"); |
| 1112 | } |
| 1113 | return true; |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1114 | } |
| 1115 | |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1116 | private boolean isSummaryOfBubbles(NotificationEntry entry) { |
| 1117 | if (entry == null) { |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1118 | return false; |
| 1119 | } |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1120 | |
| 1121 | String groupKey = entry.getSbn().getGroupKey(); |
| 1122 | ArrayList<Bubble> bubbleChildren = mBubbleData.getBubblesInGroup(groupKey); |
| 1123 | boolean isSuppressedSummary = (mBubbleData.isSummarySuppressed(groupKey) |
| 1124 | && mBubbleData.getSummaryKey(groupKey).equals(entry.getKey())); |
| 1125 | boolean isSummary = entry.getSbn().getNotification().isGroupSummary(); |
| 1126 | return (isSuppressedSummary || isSummary) |
| 1127 | && bubbleChildren != null |
| 1128 | && !bubbleChildren.isEmpty(); |
| 1129 | } |
| 1130 | |
| 1131 | private void handleSummaryDismissalInterception(NotificationEntry summary) { |
| 1132 | // current children in the row: |
| 1133 | final List<NotificationEntry> children = summary.getChildren(); |
| 1134 | if (children != null) { |
| 1135 | for (int i = 0; i < children.size(); i++) { |
| 1136 | NotificationEntry child = children.get(i); |
| 1137 | if (mBubbleData.hasBubbleWithKey(child.getKey())) { |
| 1138 | // Suppress the bubbled child |
| 1139 | // As far as group manager is concerned, once a child is no longer shown |
| 1140 | // in the shade, it is essentially removed. |
| 1141 | Bubble bubbleChild = mBubbleData.getBubbleWithKey(child.getKey()); |
| 1142 | mNotificationGroupManager.onEntryRemoved(bubbleChild.getEntry()); |
| 1143 | bubbleChild.setSuppressNotification(true); |
Joshua Tsuji | 2ed260e | 2020-03-26 14:26:01 -0400 | [diff] [blame^] | 1144 | bubbleChild.setShowDot(false /* show */); |
Beverly | a53fb0d | 2020-01-29 15:26:13 -0500 | [diff] [blame] | 1145 | } else { |
| 1146 | // non-bubbled children can be removed |
| 1147 | for (NotifCallback cb : mCallbacks) { |
| 1148 | cb.removeNotification(child, REASON_GROUP_SUMMARY_CANCELED); |
| 1149 | } |
| 1150 | } |
| 1151 | } |
| 1152 | } |
| 1153 | |
| 1154 | // And since all children are removed, remove the summary. |
| 1155 | mNotificationGroupManager.onEntryRemoved(summary); |
| 1156 | |
| 1157 | // TODO: (b/145659174) remove references to mSuppressedGroupKeys once fully migrated |
| 1158 | mBubbleData.addSummaryToSuppress(summary.getSbn().getGroupKey(), |
| 1159 | summary.getKey()); |
Beverly | ed8aea2 | 2020-01-22 16:52:47 -0500 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | /** |
Joshua Tsuji | dd4d9f9 | 2019-05-13 13:57:38 -0400 | [diff] [blame] | 1163 | * Lets any listeners know if bubble state has changed. |
Lyn Han | 6c40fe7 | 2019-05-08 14:06:33 -0700 | [diff] [blame] | 1164 | * Updates the visibility of the bubbles based on current state. |
| 1165 | * Does not un-bubble, just hides or un-hides. Notifies any |
| 1166 | * {@link BubbleStateChangeListener}s of visibility changes. |
| 1167 | * Updates stack description for TalkBack focus. |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 1168 | */ |
Lyn Han | 6c40fe7 | 2019-05-08 14:06:33 -0700 | [diff] [blame] | 1169 | public void updateStack() { |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 1170 | if (mStackView == null) { |
| 1171 | return; |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 1172 | } |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 1173 | if (mStatusBarStateListener.getCurrentState() == SHADE && hasBubbles()) { |
| 1174 | // Bubbles only appear in unlocked shade |
| 1175 | mStackView.setVisibility(hasBubbles() ? VISIBLE : INVISIBLE); |
Mady Mellor | 698d9e8 | 2019-08-01 23:11:53 +0000 | [diff] [blame] | 1176 | } else if (mStackView != null) { |
Mady Mellor | 3f2efdb | 2018-11-21 11:30:45 -0800 | [diff] [blame] | 1177 | mStackView.setVisibility(INVISIBLE); |
Mady Mellor | 5549dd2 | 2018-11-06 18:07:34 -0800 | [diff] [blame] | 1178 | } |
Lyn Han | 6c40fe7 | 2019-05-08 14:06:33 -0700 | [diff] [blame] | 1179 | |
Mady Mellor | 698d9e8 | 2019-08-01 23:11:53 +0000 | [diff] [blame] | 1180 | // Let listeners know if bubble state changed. |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 1181 | boolean hadBubbles = mNotificationShadeWindowController.getBubblesShowing(); |
Mady Mellor | 698d9e8 | 2019-08-01 23:11:53 +0000 | [diff] [blame] | 1182 | boolean hasBubblesShowing = hasBubbles() && mStackView.getVisibility() == VISIBLE; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 1183 | mNotificationShadeWindowController.setBubblesShowing(hasBubblesShowing); |
Lyn Han | 6c40fe7 | 2019-05-08 14:06:33 -0700 | [diff] [blame] | 1184 | if (mStateChangeListener != null && hadBubbles != hasBubblesShowing) { |
| 1185 | mStateChangeListener.onHasBubblesChanged(hasBubblesShowing); |
| 1186 | } |
| 1187 | |
| 1188 | mStackView.updateContentDescription(); |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 1189 | } |
| 1190 | |
| 1191 | /** |
| 1192 | * Rect indicating the touchable region for the bubble stack / expanded stack. |
| 1193 | */ |
| 1194 | public Rect getTouchableRegion() { |
| 1195 | if (mStackView == null || mStackView.getVisibility() != VISIBLE) { |
| 1196 | return null; |
| 1197 | } |
| 1198 | mStackView.getBoundsOnScreen(mTempRect); |
| 1199 | return mTempRect; |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 1200 | } |
| 1201 | |
Mady Mellor | 390bff4 | 2019-04-05 15:09:01 -0700 | [diff] [blame] | 1202 | /** |
| 1203 | * The display id of the expanded view, if the stack is expanded and not occluded by the |
| 1204 | * status bar, otherwise returns {@link Display#INVALID_DISPLAY}. |
| 1205 | */ |
| 1206 | public int getExpandedDisplayId(Context context) { |
Joel Galenson | 4071ddb | 2019-04-18 13:30:45 -0700 | [diff] [blame] | 1207 | if (mStackView == null) { |
Lyn Han | 9f66c3b | 2020-03-05 23:59:29 -0800 | [diff] [blame] | 1208 | return INVALID_DISPLAY; |
Joel Galenson | 4071ddb | 2019-04-18 13:30:45 -0700 | [diff] [blame] | 1209 | } |
Issei Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 1210 | final boolean defaultDisplay = context.getDisplay() != null |
Mady Mellor | 390bff4 | 2019-04-05 15:09:01 -0700 | [diff] [blame] | 1211 | && context.getDisplay().getDisplayId() == DEFAULT_DISPLAY; |
Lyn Han | 9f66c3b | 2020-03-05 23:59:29 -0800 | [diff] [blame] | 1212 | final BubbleViewProvider expandedViewProvider = mStackView.getExpandedBubble(); |
| 1213 | if (defaultDisplay && expandedViewProvider != null && isStackExpanded() |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 1214 | && !mNotificationShadeWindowController.getPanelExpanded()) { |
Lyn Han | 9f66c3b | 2020-03-05 23:59:29 -0800 | [diff] [blame] | 1215 | return expandedViewProvider.getDisplayId(); |
Mady Mellor | 390bff4 | 2019-04-05 15:09:01 -0700 | [diff] [blame] | 1216 | } |
Lyn Han | 9f66c3b | 2020-03-05 23:59:29 -0800 | [diff] [blame] | 1217 | return INVALID_DISPLAY; |
Mady Mellor | 390bff4 | 2019-04-05 15:09:01 -0700 | [diff] [blame] | 1218 | } |
| 1219 | |
Mady Mellor | f6e3ac0 | 2019-01-29 10:37:52 -0800 | [diff] [blame] | 1220 | @VisibleForTesting |
| 1221 | BubbleStackView getStackView() { |
| 1222 | return mStackView; |
| 1223 | } |
| 1224 | |
Mady Mellor | 70cba7bb | 2019-07-02 15:06:07 -0700 | [diff] [blame] | 1225 | /** |
| 1226 | * Description of current bubble state. |
| 1227 | */ |
| 1228 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 1229 | pw.println("BubbleController state:"); |
| 1230 | mBubbleData.dump(fd, pw, args); |
| 1231 | pw.println(); |
Joshua Tsuji | 395bcfe | 2019-07-02 19:23:23 -0400 | [diff] [blame] | 1232 | if (mStackView != null) { |
| 1233 | mStackView.dump(fd, pw, args); |
| 1234 | } |
| 1235 | pw.println(); |
Mady Mellor | 70cba7bb | 2019-07-02 15:06:07 -0700 | [diff] [blame] | 1236 | } |
| 1237 | |
Mady Mellor | e80930e | 2019-03-21 16:00:45 -0700 | [diff] [blame] | 1238 | /** |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 1239 | * This task stack listener is responsible for responding to tasks moved to the front |
| 1240 | * which are on the default (main) display. When this happens, expanded bubbles must be |
| 1241 | * collapsed so the user may interact with the app which was just moved to the front. |
| 1242 | * <p> |
| 1243 | * This listener is registered with SystemUI's ActivityManagerWrapper which dispatches |
| 1244 | * these calls via a main thread Handler. |
| 1245 | */ |
| 1246 | @MainThread |
| 1247 | private class BubbleTaskStackListener extends TaskStackChangeListener { |
| 1248 | |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 1249 | @Override |
Mark Renouf | c808f06 | 2019-02-07 15:20:37 -0500 | [diff] [blame] | 1250 | public void onTaskMovedToFront(RunningTaskInfo taskInfo) { |
| 1251 | if (mStackView != null && taskInfo.displayId == Display.DEFAULT_DISPLAY) { |
Mady Mellor | 047e24e | 2019-08-05 11:35:40 -0700 | [diff] [blame] | 1252 | if (!mStackView.isExpansionAnimating()) { |
| 1253 | mBubbleData.setExpanded(false); |
| 1254 | } |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 1255 | } |
| 1256 | } |
| 1257 | |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 1258 | @Override |
Winson Chung | e789ff6 | 2020-02-24 14:40:23 -0800 | [diff] [blame] | 1259 | public void onActivityRestartAttempt(RunningTaskInfo task, boolean homeTaskVisible, |
| 1260 | boolean clearedTask) { |
| 1261 | for (Bubble b : mBubbleData.getBubbles()) { |
| 1262 | if (b.getDisplayId() == task.displayId) { |
| 1263 | expandStackAndSelectBubble(b.getKey()); |
| 1264 | return; |
| 1265 | } |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | @Override |
Mark Renouf | a12e876 | 2019-03-07 15:43:01 -0500 | [diff] [blame] | 1270 | public void onActivityLaunchOnSecondaryDisplayRerouted() { |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 1271 | if (mStackView != null) { |
Mark Renouf | 71a3af6 | 2019-04-08 15:02:54 -0400 | [diff] [blame] | 1272 | mBubbleData.setExpanded(false); |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 1273 | } |
| 1274 | } |
Mark Renouf | 446251d | 2019-04-26 10:22:41 -0400 | [diff] [blame] | 1275 | |
| 1276 | @Override |
| 1277 | public void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo) { |
| 1278 | if (mStackView != null && taskInfo.displayId == getExpandedDisplayId(mContext)) { |
| 1279 | mBubbleData.setExpanded(false); |
| 1280 | } |
| 1281 | } |
Issei Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 1282 | |
| 1283 | @Override |
| 1284 | public void onSingleTaskDisplayDrawn(int displayId) { |
Lyn Han | a0bb02e | 2020-01-28 17:57:27 -0800 | [diff] [blame] | 1285 | if (mStackView == null) { |
| 1286 | return; |
Issei Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 1287 | } |
Lyn Han | a0bb02e | 2020-01-28 17:57:27 -0800 | [diff] [blame] | 1288 | mStackView.showExpandedViewContents(displayId); |
Issei Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 1289 | } |
Issei Suzuki | 734bc94 | 2019-06-05 13:59:52 +0200 | [diff] [blame] | 1290 | |
| 1291 | @Override |
| 1292 | public void onSingleTaskDisplayEmpty(int displayId) { |
Lyn Han | 9f66c3b | 2020-03-05 23:59:29 -0800 | [diff] [blame] | 1293 | final BubbleViewProvider expandedBubble = mStackView != null |
Mady Mellor | 5186b13 | 2019-09-16 17:55:48 -0700 | [diff] [blame] | 1294 | ? mStackView.getExpandedBubble() |
| 1295 | : null; |
Mady Mellor | ca184aae | 2019-09-17 16:07:12 -0700 | [diff] [blame] | 1296 | int expandedId = expandedBubble != null ? expandedBubble.getDisplayId() : -1; |
| 1297 | if (mStackView != null && mStackView.isExpanded() && expandedId == displayId) { |
Issei Suzuki | 734bc94 | 2019-06-05 13:59:52 +0200 | [diff] [blame] | 1298 | mBubbleData.setExpanded(false); |
Issei Suzuki | 734bc94 | 2019-06-05 13:59:52 +0200 | [diff] [blame] | 1299 | } |
Mady Mellor | ca184aae | 2019-09-17 16:07:12 -0700 | [diff] [blame] | 1300 | mBubbleData.notifyDisplayEmpty(displayId); |
Issei Suzuki | 734bc94 | 2019-06-05 13:59:52 +0200 | [diff] [blame] | 1301 | } |
Mark Renouf | cecc77b | 2019-01-30 16:32:24 -0500 | [diff] [blame] | 1302 | } |
| 1303 | |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 1304 | /** |
| 1305 | * Whether an intent is properly configured to display in an {@link android.app.ActivityView}. |
| 1306 | * |
| 1307 | * Keep checks in sync with NotificationManagerService#canLaunchInActivityView. Typically |
| 1308 | * that should filter out any invalid bubbles, but should protect SysUI side just in case. |
| 1309 | * |
| 1310 | * @param context the context to use. |
| 1311 | * @param entry the entry to bubble. |
| 1312 | */ |
| 1313 | static boolean canLaunchInActivityView(Context context, NotificationEntry entry) { |
| 1314 | PendingIntent intent = entry.getBubbleMetadata() != null |
Mady Mellor | aa9ce17 | 2020-03-17 10:34:20 -0700 | [diff] [blame] | 1315 | ? entry.getBubbleMetadata().getIntent() |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 1316 | : null; |
Mady Mellor | 2ac2d3a | 2020-01-08 17:18:54 -0800 | [diff] [blame] | 1317 | if (entry.getBubbleMetadata() != null |
| 1318 | && entry.getBubbleMetadata().getShortcutId() != null) { |
| 1319 | return true; |
| 1320 | } |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 1321 | if (intent == null) { |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 1322 | Log.w(TAG, "Unable to create bubble -- no intent: " + entry.getKey()); |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 1323 | return false; |
| 1324 | } |
Mady Mellor | f3b9fab | 2019-11-13 17:27:32 -0800 | [diff] [blame] | 1325 | PackageManager packageManager = StatusBar.getPackageManagerForUser( |
| 1326 | context, entry.getSbn().getUser().getIdentifier()); |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 1327 | ActivityInfo info = |
Mady Mellor | f3b9fab | 2019-11-13 17:27:32 -0800 | [diff] [blame] | 1328 | intent.getIntent().resolveActivityInfo(packageManager, 0); |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 1329 | if (info == null) { |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 1330 | Log.w(TAG, "Unable to send as bubble, " |
| 1331 | + entry.getKey() + " couldn't find activity info for intent: " |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 1332 | + intent); |
| 1333 | return false; |
| 1334 | } |
| 1335 | if (!ActivityInfo.isResizeableMode(info.resizeMode)) { |
Mady Mellor | 7f23490 | 2019-10-20 12:06:29 -0700 | [diff] [blame] | 1336 | Log.w(TAG, "Unable to send as bubble, " |
| 1337 | + entry.getKey() + " activity is not resizable for intent: " |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 1338 | + intent); |
| 1339 | return false; |
| 1340 | } |
Mady Mellor | ca0c24c | 2019-05-16 16:14:32 -0700 | [diff] [blame] | 1341 | return true; |
| 1342 | } |
| 1343 | |
Joshua Tsuji | a19515f | 2019-02-13 18:02:29 -0500 | [diff] [blame] | 1344 | /** PinnedStackListener that dispatches IME visibility updates to the stack. */ |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 1345 | private class BubblesImeListener extends PinnedStackListenerForwarder.PinnedStackListener { |
Joshua Tsuji | a19515f | 2019-02-13 18:02:29 -0500 | [diff] [blame] | 1346 | @Override |
Joshua Tsuji | d942283 | 2019-03-05 13:32:37 -0500 | [diff] [blame] | 1347 | public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) { |
Joshua Tsuji | ff6b0f2 | 2020-03-09 14:55:19 -0400 | [diff] [blame] | 1348 | if (mStackView != null) { |
Joshua Tsuji | d942283 | 2019-03-05 13:32:37 -0500 | [diff] [blame] | 1349 | mStackView.post(() -> mStackView.onImeVisibilityChanged(imeVisible, imeHeight)); |
Joshua Tsuji | a19515f | 2019-02-13 18:02:29 -0500 | [diff] [blame] | 1350 | } |
| 1351 | } |
Joshua Tsuji | a19515f | 2019-02-13 18:02:29 -0500 | [diff] [blame] | 1352 | } |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 1353 | } |