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