Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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.statusbar; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.content.res.Resources; |
Lucas Dupin | 1601382 | 2018-05-17 18:00:16 -0700 | [diff] [blame] | 21 | import android.os.Trace; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 22 | import android.util.Log; |
| 23 | import android.view.View; |
| 24 | import android.view.ViewGroup; |
| 25 | |
| 26 | import com.android.systemui.R; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 27 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 28 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 29 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 30 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
| 31 | import com.android.systemui.statusbar.notification.stack.NotificationListContainer; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 32 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 33 | import com.android.systemui.statusbar.phone.ShadeController; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 34 | |
| 35 | import java.util.ArrayList; |
| 36 | import java.util.HashMap; |
| 37 | import java.util.List; |
| 38 | import java.util.Stack; |
| 39 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 40 | import javax.inject.Inject; |
| 41 | import javax.inject.Singleton; |
| 42 | |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 43 | import dagger.Lazy; |
| 44 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 45 | /** |
| 46 | * NotificationViewHierarchyManager manages updating the view hierarchy of notification views based |
| 47 | * on their group structure. For example, if a notification becomes bundled with another, |
| 48 | * NotificationViewHierarchyManager will update the view hierarchy to reflect that. It also will |
| 49 | * tell NotificationListContainer which notifications to display, and inform it of changes to those |
| 50 | * notifications that might affect their display. |
| 51 | */ |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 52 | @Singleton |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 53 | public class NotificationViewHierarchyManager { |
| 54 | private static final String TAG = "NotificationViewHierarchyManager"; |
| 55 | |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 56 | //TODO: change this top <Entry, List<Entry>>? |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 57 | private final HashMap<ExpandableNotificationRow, List<ExpandableNotificationRow>> |
| 58 | mTmpChildOrderMap = new HashMap<>(); |
Eliot Courtney | 6c313d3 | 2017-12-14 19:57:51 +0900 | [diff] [blame] | 59 | |
| 60 | // Dependencies: |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 61 | protected final NotificationLockscreenUserManager mLockscreenUserManager; |
| 62 | protected final NotificationGroupManager mGroupManager; |
| 63 | protected final VisualStabilityManager mVisualStabilityManager; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 64 | private final StatusBarStateControllerImpl mStatusBarStateController; |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 65 | private final NotificationEntryManager mEntryManager; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 66 | |
| 67 | // Lazy |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 68 | private final Lazy<ShadeController> mShadeController; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * {@code true} if notifications not part of a group should by default be rendered in their |
| 72 | * expanded state. If {@code false}, then only the first notification will be expanded if |
| 73 | * possible. |
| 74 | */ |
| 75 | private final boolean mAlwaysExpandNonGroupedNotification; |
| 76 | |
| 77 | private NotificationPresenter mPresenter; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 78 | private NotificationListContainer mListContainer; |
| 79 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 80 | @Inject |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 81 | public NotificationViewHierarchyManager(Context context, |
| 82 | NotificationLockscreenUserManager notificationLockscreenUserManager, |
| 83 | NotificationGroupManager groupManager, |
| 84 | VisualStabilityManager visualStabilityManager, |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 85 | StatusBarStateControllerImpl statusBarStateController, |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 86 | NotificationEntryManager notificationEntryManager, |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 87 | Lazy<ShadeController> shadeController) { |
| 88 | mLockscreenUserManager = notificationLockscreenUserManager; |
| 89 | mGroupManager = groupManager; |
| 90 | mVisualStabilityManager = visualStabilityManager; |
| 91 | mStatusBarStateController = statusBarStateController; |
| 92 | mEntryManager = notificationEntryManager; |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 93 | mShadeController = shadeController; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 94 | Resources res = context.getResources(); |
| 95 | mAlwaysExpandNonGroupedNotification = |
| 96 | res.getBoolean(R.bool.config_alwaysExpandNonGroupedNotifications); |
| 97 | } |
| 98 | |
| 99 | public void setUpWithPresenter(NotificationPresenter presenter, |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 100 | NotificationListContainer listContainer) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 101 | mPresenter = presenter; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 102 | mListContainer = listContainer; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Updates the visual representation of the notifications. |
| 107 | */ |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 108 | //TODO: Rewrite this to focus on Entries, or some other data object instead of views |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 109 | public void updateNotificationViews() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 110 | ArrayList<NotificationEntry> activeNotifications = mEntryManager.getNotificationData() |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 111 | .getActiveNotifications(); |
| 112 | ArrayList<ExpandableNotificationRow> toShow = new ArrayList<>(activeNotifications.size()); |
| 113 | final int N = activeNotifications.size(); |
| 114 | for (int i = 0; i < N; i++) { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 115 | NotificationEntry ent = activeNotifications.get(i); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 116 | if (ent.isRowDismissed() || ent.isRowRemoved()) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 117 | // we don't want to update removed notifications because they could |
| 118 | // temporarily become children if they were isolated before. |
| 119 | continue; |
| 120 | } |
Mady Mellor | 5549dd2 | 2018-11-06 18:07:34 -0800 | [diff] [blame] | 121 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 122 | int userId = ent.notification.getUserId(); |
| 123 | |
| 124 | // Display public version of the notification if we need to redact. |
| 125 | // TODO: This area uses a lot of calls into NotificationLockscreenUserManager. |
| 126 | // We can probably move some of this code there. |
| 127 | boolean devicePublic = mLockscreenUserManager.isLockscreenPublicMode( |
| 128 | mLockscreenUserManager.getCurrentUserId()); |
| 129 | boolean userPublic = devicePublic |
| 130 | || mLockscreenUserManager.isLockscreenPublicMode(userId); |
| 131 | boolean needsRedaction = mLockscreenUserManager.needsRedaction(ent); |
| 132 | boolean sensitive = userPublic && needsRedaction; |
| 133 | boolean deviceSensitive = devicePublic |
| 134 | && !mLockscreenUserManager.userAllowsPrivateNotificationsInPublic( |
| 135 | mLockscreenUserManager.getCurrentUserId()); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 136 | ent.getRow().setSensitive(sensitive, deviceSensitive); |
| 137 | ent.getRow().setNeedsRedaction(needsRedaction); |
| 138 | if (mGroupManager.isChildInGroupWithSummary(ent.notification)) { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 139 | NotificationEntry summary = mGroupManager.getGroupSummary(ent.notification); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 140 | List<ExpandableNotificationRow> orderedChildren = |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 141 | mTmpChildOrderMap.get(summary.getRow()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 142 | if (orderedChildren == null) { |
| 143 | orderedChildren = new ArrayList<>(); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 144 | mTmpChildOrderMap.put(summary.getRow(), orderedChildren); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 145 | } |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 146 | orderedChildren.add(ent.getRow()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 147 | } else { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 148 | toShow.add(ent.getRow()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | } |
| 152 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 153 | ArrayList<ExpandableNotificationRow> viewsToRemove = new ArrayList<>(); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 154 | for (int i=0; i< mListContainer.getContainerChildCount(); i++) { |
| 155 | View child = mListContainer.getContainerChildAt(i); |
| 156 | if (!toShow.contains(child) && child instanceof ExpandableNotificationRow) { |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 157 | ExpandableNotificationRow row = (ExpandableNotificationRow) child; |
| 158 | |
| 159 | // Blocking helper is effectively a detached view. Don't bother removing it from the |
| 160 | // layout. |
| 161 | if (!row.isBlockingHelperShowing()) { |
| 162 | viewsToRemove.add((ExpandableNotificationRow) child); |
| 163 | } |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 167 | for (ExpandableNotificationRow viewToRemove : viewsToRemove) { |
| 168 | if (mGroupManager.isChildInGroupWithSummary(viewToRemove.getStatusBarNotification())) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 169 | // we are only transferring this notification to its parent, don't generate an |
| 170 | // animation |
| 171 | mListContainer.setChildTransferInProgress(true); |
| 172 | } |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 173 | if (viewToRemove.isSummaryWithChildren()) { |
| 174 | viewToRemove.removeAllChildren(); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 175 | } |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 176 | mListContainer.removeContainerView(viewToRemove); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 177 | mListContainer.setChildTransferInProgress(false); |
| 178 | } |
| 179 | |
| 180 | removeNotificationChildren(); |
| 181 | |
| 182 | for (int i = 0; i < toShow.size(); i++) { |
| 183 | View v = toShow.get(i); |
| 184 | if (v.getParent() == null) { |
| 185 | mVisualStabilityManager.notifyViewAddition(v); |
| 186 | mListContainer.addContainerView(v); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | addNotificationChildrenAndSort(); |
| 191 | |
| 192 | // So after all this work notifications still aren't sorted correctly. |
| 193 | // Let's do that now by advancing through toShow and mListContainer in |
| 194 | // lock-step, making sure mListContainer matches what we see in toShow. |
| 195 | int j = 0; |
| 196 | for (int i = 0; i < mListContainer.getContainerChildCount(); i++) { |
| 197 | View child = mListContainer.getContainerChildAt(i); |
| 198 | if (!(child instanceof ExpandableNotificationRow)) { |
| 199 | // We don't care about non-notification views. |
| 200 | continue; |
| 201 | } |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 202 | if (((ExpandableNotificationRow) child).isBlockingHelperShowing()) { |
| 203 | // Don't count/reorder notifications that are showing the blocking helper! |
| 204 | continue; |
| 205 | } |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 206 | |
| 207 | ExpandableNotificationRow targetChild = toShow.get(j); |
| 208 | if (child != targetChild) { |
| 209 | // Oops, wrong notification at this position. Put the right one |
| 210 | // here and advance both lists. |
| 211 | if (mVisualStabilityManager.canReorderNotification(targetChild)) { |
| 212 | mListContainer.changeViewPosition(targetChild, i); |
| 213 | } else { |
| 214 | mVisualStabilityManager.addReorderingAllowedCallback(mEntryManager); |
| 215 | } |
| 216 | } |
| 217 | j++; |
| 218 | |
| 219 | } |
| 220 | |
| 221 | mVisualStabilityManager.onReorderingFinished(); |
| 222 | // clear the map again for the next usage |
| 223 | mTmpChildOrderMap.clear(); |
| 224 | |
| 225 | updateRowStates(); |
| 226 | |
| 227 | mListContainer.onNotificationViewUpdateFinished(); |
| 228 | } |
| 229 | |
| 230 | private void addNotificationChildrenAndSort() { |
| 231 | // Let's now add all notification children which are missing |
| 232 | boolean orderChanged = false; |
| 233 | for (int i = 0; i < mListContainer.getContainerChildCount(); i++) { |
| 234 | View view = mListContainer.getContainerChildAt(i); |
| 235 | if (!(view instanceof ExpandableNotificationRow)) { |
| 236 | // We don't care about non-notification views. |
| 237 | continue; |
| 238 | } |
| 239 | |
| 240 | ExpandableNotificationRow parent = (ExpandableNotificationRow) view; |
| 241 | List<ExpandableNotificationRow> children = parent.getNotificationChildren(); |
| 242 | List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent); |
| 243 | |
| 244 | for (int childIndex = 0; orderedChildren != null && childIndex < orderedChildren.size(); |
| 245 | childIndex++) { |
| 246 | ExpandableNotificationRow childView = orderedChildren.get(childIndex); |
| 247 | if (children == null || !children.contains(childView)) { |
| 248 | if (childView.getParent() != null) { |
| 249 | Log.wtf(TAG, "trying to add a notification child that already has " + |
| 250 | "a parent. class:" + childView.getParent().getClass() + |
| 251 | "\n child: " + childView); |
| 252 | // This shouldn't happen. We can recover by removing it though. |
| 253 | ((ViewGroup) childView.getParent()).removeView(childView); |
| 254 | } |
| 255 | mVisualStabilityManager.notifyViewAddition(childView); |
| 256 | parent.addChildNotification(childView, childIndex); |
| 257 | mListContainer.notifyGroupChildAdded(childView); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | // Finally after removing and adding has been performed we can apply the order. |
| 262 | orderChanged |= parent.applyChildOrder(orderedChildren, mVisualStabilityManager, |
| 263 | mEntryManager); |
| 264 | } |
| 265 | if (orderChanged) { |
| 266 | mListContainer.generateChildOrderChangedEvent(); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | private void removeNotificationChildren() { |
| 271 | // First let's remove all children which don't belong in the parents |
| 272 | ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(); |
| 273 | for (int i = 0; i < mListContainer.getContainerChildCount(); i++) { |
| 274 | View view = mListContainer.getContainerChildAt(i); |
| 275 | if (!(view instanceof ExpandableNotificationRow)) { |
| 276 | // We don't care about non-notification views. |
| 277 | continue; |
| 278 | } |
| 279 | |
| 280 | ExpandableNotificationRow parent = (ExpandableNotificationRow) view; |
| 281 | List<ExpandableNotificationRow> children = parent.getNotificationChildren(); |
| 282 | List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent); |
| 283 | |
| 284 | if (children != null) { |
| 285 | toRemove.clear(); |
| 286 | for (ExpandableNotificationRow childRow : children) { |
| 287 | if ((orderedChildren == null |
| 288 | || !orderedChildren.contains(childRow)) |
| 289 | && !childRow.keepInParent()) { |
| 290 | toRemove.add(childRow); |
| 291 | } |
| 292 | } |
| 293 | for (ExpandableNotificationRow remove : toRemove) { |
| 294 | parent.removeChildNotification(remove); |
| 295 | if (mEntryManager.getNotificationData().get( |
| 296 | remove.getStatusBarNotification().getKey()) == null) { |
| 297 | // We only want to add an animation if the view is completely removed |
| 298 | // otherwise it's just a transfer |
| 299 | mListContainer.notifyGroupChildRemoved(remove, |
| 300 | parent.getChildrenContainer()); |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Updates expanded, dimmed and locked states of notification rows. |
| 309 | */ |
| 310 | public void updateRowStates() { |
Lucas Dupin | 1601382 | 2018-05-17 18:00:16 -0700 | [diff] [blame] | 311 | Trace.beginSection("NotificationViewHierarchyManager#updateRowStates"); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 312 | final int N = mListContainer.getContainerChildCount(); |
| 313 | |
| 314 | int visibleNotifications = 0; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 315 | boolean onKeyguard = mStatusBarStateController.getState() == StatusBarState.KEYGUARD; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 316 | int maxNotifications = -1; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 317 | if (onKeyguard) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 318 | maxNotifications = mPresenter.getMaxNotificationsWhileLocked(true /* recompute */); |
| 319 | } |
| 320 | mListContainer.setMaxDisplayedNotifications(maxNotifications); |
| 321 | Stack<ExpandableNotificationRow> stack = new Stack<>(); |
| 322 | for (int i = N - 1; i >= 0; i--) { |
| 323 | View child = mListContainer.getContainerChildAt(i); |
| 324 | if (!(child instanceof ExpandableNotificationRow)) { |
| 325 | continue; |
| 326 | } |
| 327 | stack.push((ExpandableNotificationRow) child); |
| 328 | } |
| 329 | while(!stack.isEmpty()) { |
| 330 | ExpandableNotificationRow row = stack.pop(); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 331 | NotificationEntry entry = row.getEntry(); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 332 | boolean isChildNotification = |
| 333 | mGroupManager.isChildInGroupWithSummary(entry.notification); |
| 334 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 335 | row.setOnKeyguard(onKeyguard); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 336 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 337 | if (!onKeyguard) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 338 | // If mAlwaysExpandNonGroupedNotification is false, then only expand the |
| 339 | // very first notification and if it's not a child of grouped notifications. |
| 340 | row.setSystemExpanded(mAlwaysExpandNonGroupedNotification |
| 341 | || (visibleNotifications == 0 && !isChildNotification |
| 342 | && !row.isLowPriority())); |
| 343 | } |
| 344 | |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 345 | entry.getRow().setOnAmbient(mShadeController.get().isDozing()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 346 | int userId = entry.notification.getUserId(); |
| 347 | boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup( |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 348 | entry.notification) && !entry.isRowRemoved(); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 349 | boolean showOnKeyguard = mLockscreenUserManager.shouldShowOnKeyguard(entry |
| 350 | .notification); |
Selim Cinek | 3bf2d20 | 2018-10-16 17:30:05 -0700 | [diff] [blame] | 351 | if (!showOnKeyguard) { |
| 352 | // min priority notifications should show if their summary is showing |
| 353 | if (mGroupManager.isChildInGroupWithSummary(entry.notification)) { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 354 | NotificationEntry summary = mGroupManager.getLogicalGroupSummary( |
Selim Cinek | 3bf2d20 | 2018-10-16 17:30:05 -0700 | [diff] [blame] | 355 | entry.notification); |
| 356 | if (summary != null && mLockscreenUserManager.shouldShowOnKeyguard( |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 357 | summary.notification)) { |
Selim Cinek | 3bf2d20 | 2018-10-16 17:30:05 -0700 | [diff] [blame] | 358 | showOnKeyguard = true; |
| 359 | } |
| 360 | } |
| 361 | } |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 362 | if (suppressedSummary |
Pavel Grafov | 6515263 | 2018-03-26 15:14:45 +0100 | [diff] [blame] | 363 | || mLockscreenUserManager.shouldHideNotifications(userId) |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 364 | || (onKeyguard && !showOnKeyguard)) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 365 | entry.getRow().setVisibility(View.GONE); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 366 | } else { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 367 | boolean wasGone = entry.getRow().getVisibility() == View.GONE; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 368 | if (wasGone) { |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 369 | entry.getRow().setVisibility(View.VISIBLE); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 370 | } |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 371 | if (!isChildNotification && !entry.getRow().isRemoved()) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 372 | if (wasGone) { |
| 373 | // notify the scroller of a child addition |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 374 | mListContainer.generateAddAnimation(entry.getRow(), |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 375 | !showOnKeyguard /* fromMoreCard */); |
| 376 | } |
| 377 | visibleNotifications++; |
| 378 | } |
| 379 | } |
| 380 | if (row.isSummaryWithChildren()) { |
| 381 | List<ExpandableNotificationRow> notificationChildren = |
| 382 | row.getNotificationChildren(); |
| 383 | int size = notificationChildren.size(); |
| 384 | for (int i = size - 1; i >= 0; i--) { |
| 385 | stack.push(notificationChildren.get(i)); |
| 386 | } |
| 387 | } |
Dan Sandler | 83b70a0 | 2018-01-24 23:20:18 -0500 | [diff] [blame] | 388 | |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 389 | row.showAppOpsIcons(entry.mActiveAppOps); |
Gus Prevas | 7306b90 | 2018-12-11 10:57:06 -0500 | [diff] [blame] | 390 | row.setLastAudiblyAlertedMs(entry.lastAudiblyAlertedMs); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 391 | } |
| 392 | |
Lucas Dupin | 1601382 | 2018-05-17 18:00:16 -0700 | [diff] [blame] | 393 | Trace.beginSection("NotificationPresenter#onUpdateRowStates"); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 394 | mPresenter.onUpdateRowStates(); |
Lucas Dupin | 1601382 | 2018-05-17 18:00:16 -0700 | [diff] [blame] | 395 | Trace.endSection(); |
| 396 | Trace.endSection(); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 397 | } |
| 398 | } |