diff options
45 files changed, 548 insertions, 315 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index e868f96426c9..c6dcfc7356be 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -268,7 +268,7 @@ public class BubbleController { for (BubbleView bv : mBubbles.values()) { NotificationData.Entry entry = bv.getEntry(); if (entry != null) { - if (entry.row.isRemoved() || entry.isBubbleDismissed() || entry.row.isDismissed()) { + if (entry.isRowRemoved() || entry.isBubbleDismissed() || entry.isRowDismissed()) { viewsToRemove.add(bv); } } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java index a79e04736337..6c47aac712f6 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java @@ -120,7 +120,7 @@ public class BubbleView extends LinearLayout implements BubbleTouchHandler.Float * @return the view to display when the bubble is expanded. */ public ExpandableNotificationRow getRowView() { - return mEntry.row; + return mEntry.getRow(); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java index 3da6d2e877ed..bc381699494a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java @@ -112,8 +112,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim return; } - alertEntry.mEntry.row.sendAccessibilityEvent( - AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); + alertEntry.mEntry.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); if (alert) { alertEntry.updateEntry(true /* updatePostTime */); } @@ -186,7 +185,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim alertEntry.setEntry(entry); mAlertEntries.put(entry.key, alertEntry); onAlertEntryAdded(alertEntry); - entry.row.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); + entry.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); } /** @@ -207,7 +206,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim Entry entry = alertEntry.mEntry; mAlertEntries.remove(key); onAlertEntryRemoved(alertEntry); - entry.row.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); + entry.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); alertEntry.reset(); if (mExtendedLifetimeAlertEntries.contains(entry)) { if (mNotificationLifetimeFinishedCallback != null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/AmbientPulseManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/AmbientPulseManager.java index f1c03049202f..a5e7f04be281 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/AmbientPulseManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/AmbientPulseManager.java @@ -79,7 +79,7 @@ public final class AmbientPulseManager extends AlertingNotificationManager { @Override protected void onAlertEntryAdded(AlertEntry alertEntry) { NotificationData.Entry entry = alertEntry.mEntry; - entry.row.setAmbientPulsing(true); + entry.setAmbientPulsing(true); for (OnAmbientChangedListener listener : mListeners) { listener.onAmbientStateChanged(entry, true); } @@ -88,11 +88,11 @@ public final class AmbientPulseManager extends AlertingNotificationManager { @Override protected void onAlertEntryRemoved(AlertEntry alertEntry) { NotificationData.Entry entry = alertEntry.mEntry; - entry.row.setAmbientPulsing(false); + entry.setAmbientPulsing(false); for (OnAmbientChangedListener listener : mListeners) { listener.onAmbientStateChanged(entry, false); } - entry.row.freeContentViewWhenSafe(FLAG_CONTENT_VIEW_AMBIENT); + entry.freeContentViewWhenSafe(FLAG_CONTENT_VIEW_AMBIENT); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java index fc1e94a08478..f0455481b353 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java @@ -199,7 +199,7 @@ public class NotificationMediaManager implements Dumpable { for (int i = 0; i < N; i++) { final NotificationData.Entry entry = activeNotifications.get(i); - if (isMediaNotification(entry)) { + if (entry.isMediaNotification()) { final MediaSession.Token token = entry.notification.getNotification().extras.getParcelable( Notification.EXTRA_MEDIA_SESSION); @@ -336,13 +336,6 @@ public class NotificationMediaManager implements Dumpable { return PlaybackState.STATE_NONE; } - private boolean isMediaNotification(NotificationData.Entry entry) { - // TODO: confirm that there's a valid media key - return entry.row.getExpandedContentView() != null - && entry.row.getExpandedContentView().findViewById( - com.android.internal.R.id.media_actions) != null; - } - private void clearCurrentMediaNotificationSession() { mMediaMetadata = null; if (mMediaController != null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java index 8c53cc2a06a4..2ee5443ab3aa 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java @@ -393,7 +393,7 @@ public class NotificationRemoteInputManager implements Dumpable { } public boolean shouldKeepForRemoteInputHistory(NotificationData.Entry entry) { - if (entry.row == null || entry.row.isDismissed()) { + if (entry.isDismissed()) { return false; } if (!FORCE_REMOTE_INPUT_HISTORY) { @@ -403,7 +403,7 @@ public class NotificationRemoteInputManager implements Dumpable { } public boolean shouldKeepForSmartReplyHistory(NotificationData.Entry entry) { - if (entry.row == null || entry.row.isDismissed()) { + if (entry.isDismissed()) { return false; } if (!FORCE_REMOTE_INPUT_HISTORY) { @@ -532,7 +532,7 @@ public class NotificationRemoteInputManager implements Dumpable { // Ensure the entry hasn't already been removed. This can happen if there is an // inflation exception while updating the remote history - if (entry.row == null || entry.row.isRemoved()) { + if (entry.isRemoved()) { return; } @@ -570,7 +570,7 @@ public class NotificationRemoteInputManager implements Dumpable { mEntryManager.updateNotification(newSbn, null); - if (entry.row == null || entry.row.isRemoved()) { + if (entry.isRemoved()) { return; } @@ -593,7 +593,7 @@ public class NotificationRemoteInputManager implements Dumpable { protected class RemoteInputActiveExtender extends RemoteInputExtender { @Override public boolean shouldExtendLifetime(@NonNull NotificationData.Entry entry) { - if (entry.row == null || entry.row.isDismissed()) { + if (entry.isDismissed()) { return false; } return mRemoteInputController.isRemoteInputActive(entry); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java index ea677363a0ba..daa2fd45b142 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java @@ -51,6 +51,7 @@ import java.util.Stack; public class NotificationViewHierarchyManager { private static final String TAG = "NotificationViewHierarchyManager"; + //TODO: change this top <Entry, List<Entry>>? private final HashMap<ExpandableNotificationRow, List<ExpandableNotificationRow>> mTmpChildOrderMap = new HashMap<>(); @@ -140,6 +141,7 @@ public class NotificationViewHierarchyManager { /** * Updates the visual representation of the notifications. */ + //TODO: Rewrite this to focus on Entries, or some other data object instead of views public void updateNotificationViews() { ArrayList<NotificationData.Entry> activeNotifications = mEntryManager.getNotificationData() .getActiveNotifications(); @@ -148,12 +150,12 @@ public class NotificationViewHierarchyManager { final int N = activeNotifications.size(); for (int i = 0; i < N; i++) { NotificationData.Entry ent = activeNotifications.get(i); - if (ent.row.isDismissed() || ent.row.isRemoved()) { + if (ent.isRowDismissed() || ent.isRowRemoved()) { // we don't want to update removed notifications because they could // temporarily become children if they were isolated before. continue; } - ent.row.setStatusBarState(mStatusBarStateListener.getCurrentState()); + ent.getRow().setStatusBarState(mStatusBarStateListener.getCurrentState()); boolean showAsBubble = ent.isBubble() && !ent.isBubbleDismissed() && mStatusBarStateListener.getCurrentState() == SHADE; if (showAsBubble) { @@ -175,20 +177,19 @@ public class NotificationViewHierarchyManager { boolean deviceSensitive = devicePublic && !mLockscreenUserManager.userAllowsPrivateNotificationsInPublic( mLockscreenUserManager.getCurrentUserId()); - ent.row.setSensitive(sensitive, deviceSensitive); - ent.row.setNeedsRedaction(needsRedaction); - if (mGroupManager.isChildInGroupWithSummary(ent.row.getStatusBarNotification())) { - ExpandableNotificationRow summary = mGroupManager.getGroupSummary( - ent.row.getStatusBarNotification()); + ent.getRow().setSensitive(sensitive, deviceSensitive); + ent.getRow().setNeedsRedaction(needsRedaction); + if (mGroupManager.isChildInGroupWithSummary(ent.notification)) { + NotificationData.Entry summary = mGroupManager.getGroupSummary(ent.notification); List<ExpandableNotificationRow> orderedChildren = - mTmpChildOrderMap.get(summary); + mTmpChildOrderMap.get(summary.getRow()); if (orderedChildren == null) { orderedChildren = new ArrayList<>(); - mTmpChildOrderMap.put(summary, orderedChildren); + mTmpChildOrderMap.put(summary.getRow(), orderedChildren); } - orderedChildren.add(ent.row); + orderedChildren.add(ent.getRow()); } else { - toShow.add(ent.row); + toShow.add(ent.getRow()); } } @@ -391,19 +392,19 @@ public class NotificationViewHierarchyManager { && !row.isLowPriority())); } - entry.row.setOnAmbient(getShadeController().isDozing()); + entry.getRow().setOnAmbient(getShadeController().isDozing()); int userId = entry.notification.getUserId(); boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup( - entry.notification) && !entry.row.isRemoved(); + entry.notification) && !entry.isRowRemoved(); boolean showOnKeyguard = mLockscreenUserManager.shouldShowOnKeyguard(entry .notification); if (!showOnKeyguard) { // min priority notifications should show if their summary is showing if (mGroupManager.isChildInGroupWithSummary(entry.notification)) { - ExpandableNotificationRow summary = mGroupManager.getLogicalGroupSummary( + NotificationData.Entry summary = mGroupManager.getLogicalGroupSummary( entry.notification); if (summary != null && mLockscreenUserManager.shouldShowOnKeyguard( - summary.getStatusBarNotification())) { + summary.notification)) { showOnKeyguard = true; } } @@ -411,16 +412,16 @@ public class NotificationViewHierarchyManager { if (suppressedSummary || mLockscreenUserManager.shouldHideNotifications(userId) || (onKeyguard && !showOnKeyguard)) { - entry.row.setVisibility(View.GONE); + entry.getRow().setVisibility(View.GONE); } else { - boolean wasGone = entry.row.getVisibility() == View.GONE; + boolean wasGone = entry.getRow().getVisibility() == View.GONE; if (wasGone) { - entry.row.setVisibility(View.VISIBLE); + entry.getRow().setVisibility(View.VISIBLE); } - if (!isChildNotification && !entry.row.isRemoved()) { + if (!isChildNotification && !entry.getRow().isRemoved()) { if (wasGone) { // notify the scroller of a child addition - mListContainer.generateAddAnimation(entry.row, + mListContainer.generateAddAnimation(entry.getRow(), !showOnKeyguard /* fromMoreCard */); } visibleNotifications++; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java b/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java index 929f43e01c0f..e8abcc2bd80e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java @@ -250,16 +250,16 @@ public class RemoteInputController { // Make a copy because closing the remote inputs will modify mOpen. ArrayList<NotificationData.Entry> list = new ArrayList<>(mOpen.size()); for (int i = mOpen.size() - 1; i >= 0; i--) { - NotificationData.Entry item = mOpen.get(i).first.get(); - if (item != null && item.row != null) { - list.add(item); + NotificationData.Entry entry = mOpen.get(i).first.get(); + if (entry != null && entry.rowExists()) { + list.add(entry); } } for (int i = list.size() - 1; i >= 0; i--) { - NotificationData.Entry item = list.get(i); - if (item.row != null) { - item.row.closeRemoteInput(); + NotificationData.Entry entry = list.get(i); + if (entry.rowExists()) { + entry.closeRemoteInput(); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationData.java index da6d977f3f5b..d7680b3523ba 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationData.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationData.java @@ -64,6 +64,9 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.StatusBarIconView; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; +import com.android.systemui.statusbar.notification.row.NotificationGuts; +import com.android.systemui.statusbar.notification.row.NotificationInflater.InflationFlag; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; @@ -106,7 +109,6 @@ public class NotificationData { public int importance; public StatusBarIconView icon; public StatusBarIconView expandedIcon; - public ExpandableNotificationRow row; // the outer expanded view private boolean interruption; public boolean autoRedacted; // whether the redacted notification was generated by us public int targetSdk; @@ -119,6 +121,10 @@ public class NotificationData { public List<Notification.Action> systemGeneratedSmartActions = Collections.emptyList(); public CharSequence[] smartReplies = new CharSequence[0]; + private Entry parent; // our parent (if we're in a group) + private ArrayList<Entry> children = new ArrayList<Entry>(); + private ExpandableNotificationRow row; // the outer expanded view + private int mCachedContrastColor = COLOR_INVALID; private int mCachedContrastColorIsFor = COLOR_INVALID; private InflationTask mRunningTask = null; @@ -212,6 +218,24 @@ public class NotificationData { } } + public ExpandableNotificationRow getRow() { + return row; + } + + //TODO: This will go away when we have a way to bind an entry to a row + public void setRow(ExpandableNotificationRow row) { + this.row = row; + } + + @Nullable + public List<Entry> getChildren() { + if (children.size() <= 0) { + return null; + } + + return children; + } + public void notifyFullScreenIntentLaunched() { setInterruption(); lastFullScreenIntentLaunchTime = SystemClock.elapsedRealtime(); @@ -409,6 +433,198 @@ public class NotificationData { initializationTime = time; } } + + public void sendAccessibilityEvent(int eventType) { + if (row != null) { + row.sendAccessibilityEvent(eventType); + } + } + + /** + * Used by NotificationMediaManager to determine... things + * @return {@code true} if we are a media notification + */ + public boolean isMediaNotification() { + if (row == null) return false; + + return row.isMediaRow(); + } + + /** + * We are a top level child if our parent is the list of notifications duh + * @return {@code true} if we're a top level notification + */ + public boolean isTopLevelChild() { + return row != null && row.isTopLevelChild(); + } + + public void resetUserExpansion() { + if (row != null) row.resetUserExpansion(); + } + + public void freeContentViewWhenSafe(@InflationFlag int inflationFlag) { + if (row != null) row.freeContentViewWhenSafe(inflationFlag); + } + + public void setAmbientPulsing(boolean pulsing) { + if (row != null) row.setAmbientPulsing(pulsing); + } + + public boolean rowExists() { + return row != null; + } + + public boolean isRowDismissed() { + return row != null && row.isDismissed(); + } + + public boolean isRowRemoved() { + return row != null && row.isRemoved(); + } + + /** + * @return {@code true} if the row is null or removed + */ + public boolean isRemoved() { + //TODO: recycling invalidates this + return row == null || row.isRemoved(); + } + + /** + * @return {@code true} if the row is null or dismissed + */ + public boolean isDismissed() { + //TODO: recycling + return row == null || row.isDismissed(); + } + + public boolean isRowPinned() { + return row != null && row.isPinned(); + } + + public void setRowPinned(boolean pinned) { + if (row != null) row.setPinned(pinned); + } + + public boolean isRowAnimatingAway() { + return row != null && row.isHeadsUpAnimatingAway(); + } + + public boolean isRowHeadsUp() { + return row != null && row.isHeadsUp(); + } + + public void setHeadsUp(boolean shouldHeadsUp) { + if (row != null) row.setHeadsUp(shouldHeadsUp); + } + + public boolean mustStayOnScreen() { + return row != null && row.mustStayOnScreen(); + } + + public void setHeadsUpIsVisible() { + if (row != null) row.setHeadsUpIsVisible(); + } + + //TODO: i'm imagining a world where this isn't just the row, but I could be rwong + public ExpandableNotificationRow getHeadsUpAnimationView() { + return row; + } + + public void setUserLocked(boolean userLocked) { + if (row != null) row.setUserLocked(userLocked); + } + + public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) { + if (row != null) row.setUserExpanded(userExpanded, allowChildExpansion); + } + + public void setGroupExpansionChanging(boolean changing) { + if (row != null) row.setGroupExpansionChanging(changing); + } + + public void notifyHeightChanged(boolean needsAnimation) { + if (row != null) row.notifyHeightChanged(needsAnimation); + } + + public void closeRemoteInput() { + if (row != null) row.closeRemoteInput(); + } + + public boolean areChildrenExpanded() { + return row != null && row.areChildrenExpanded(); + } + + public boolean keepInParent() { + return row != null && row.keepInParent(); + } + + //TODO: probably less confusing to say "is group fully visible" + public boolean isGroupNotFullyVisible() { + return row == null || row.isGroupNotFullyVisible(); + } + + public NotificationGuts getGuts() { + if (row != null) return row.getGuts(); + return null; + } + + public boolean hasLowPriorityStateUpdated() { + return row != null && row.hasLowPriorityStateUpdated(); + } + + public void removeRow() { + if (row != null) row.setRemoved(); + } + + public boolean isSummaryWithChildren() { + return row != null && row.isSummaryWithChildren(); + } + + public void setKeepInParent(boolean keep) { + if (row != null) row.setKeepInParent(keep); + } + + public void onDensityOrFontScaleChanged() { + if (row != null) row.onDensityOrFontScaleChanged(); + } + + public boolean areGutsExposed() { + return row != null && row.getGuts().isExposed(); + } + + public boolean isChildInGroup() { + return parent == null; + } + + public void setLowPriorityStateUpdated(boolean updated) { + if (row != null) row.setLowPriorityStateUpdated(updated); + } + + /** + * @return Can the underlying notification be cleared? This can be different from whether the + * notification can be dismissed in case notifications are sensitive on the lockscreen. + * @see #canViewBeDismissed() + */ + public boolean isClearable() { + if (notification == null || !notification.isClearable()) { + return false; + } + if (children.size() > 0) { + for (int i = 0; i < children.size(); i++) { + Entry child = children.get(i); + if (!child.isClearable()) { + return false; + } + } + } + return true; + } + + public boolean canViewBeDismissed() { + if (row == null) return true; + return row.canViewBeDismissed(); + } } private final ArrayMap<String, Entry> mEntries = new ArrayMap<>(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index 450d34d4007e..e33372957011 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -385,9 +385,9 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. entry.notification.getUser().getIdentifier()); final StatusBarNotification sbn = entry.notification; - if (entry.row != null) { + if (entry.rowExists()) { entry.reset(); - updateNotification(entry, pmUser, sbn, entry.row); + updateNotification(entry, pmUser, sbn, entry.getRow()); } else { new RowInflaterTask().inflate(mContext, parent, entry, row -> { @@ -543,14 +543,14 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. // Mark as seen immediately setNotificationShown(entry.notification); } else { - entry.row.freeContentViewWhenSafe(FLAG_CONTENT_VIEW_HEADS_UP); + entry.freeContentViewWhenSafe(FLAG_CONTENT_VIEW_HEADS_UP); } } if ((inflatedFlags & FLAG_CONTENT_VIEW_AMBIENT) != 0) { if (shouldPulse(entry)) { mAmbientPulseManager.showNotification(entry); } else { - entry.row.freeContentViewWhenSafe(FLAG_CONTENT_VIEW_AMBIENT); + entry.freeContentViewWhenSafe(FLAG_CONTENT_VIEW_AMBIENT); } } } @@ -561,20 +561,20 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. mPendingNotifications.remove(entry.key); // If there was an async task started after the removal, we don't want to add it back to // the list, otherwise we might get leaks. - if (!entry.row.isRemoved()) { + if (!entry.isRowRemoved()) { boolean isNew = mNotificationData.get(entry.key) == null; if (isNew) { showAlertingView(entry, inflatedFlags); addEntry(entry); } else { - if (entry.row.hasLowPriorityStateUpdated()) { + if (entry.getRow().hasLowPriorityStateUpdated()) { mVisualStabilityManager.onLowPriorityUpdated(entry); mPresenter.updateNotificationViews(); } mGroupAlertTransferHelper.onInflationFinished(entry); } } - entry.row.setLowPriorityStateUpdated(false); + entry.setLowPriorityStateUpdated(false); } @Override @@ -633,9 +633,9 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. getMediaManager().onNotificationRemoved(key); mForegroundServiceController.removeNotification(entry.notification); - if (entry.row != null) { - entry.row.setRemoved(); - mListContainer.cleanUpViewState(entry.row); + if (entry.rowExists()) { + entry.removeRow(); + mListContainer.cleanUpViewStateForEntry(entry); } // Let's remove the children if this was a summary @@ -670,19 +670,19 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. */ private void handleGroupSummaryRemoved(String key) { NotificationData.Entry entry = mNotificationData.get(key); - if (entry != null && entry.row != null - && entry.row.isSummaryWithChildren()) { - if (entry.notification.getOverrideGroupKey() != null && !entry.row.isDismissed()) { + if (entry != null && entry.rowExists() && entry.isSummaryWithChildren()) { + if (entry.notification.getOverrideGroupKey() != null && !entry.isRowDismissed()) { // We don't want to remove children for autobundled notifications as they are not // always cancelled. We only remove them if they were dismissed by the user. return; } - List<ExpandableNotificationRow> notificationChildren = - entry.row.getNotificationChildren(); - for (int i = 0; i < notificationChildren.size(); i++) { - ExpandableNotificationRow row = notificationChildren.get(i); - NotificationData.Entry childEntry = row.getEntry(); - boolean isForeground = (row.getStatusBarNotification().getNotification().flags + List<NotificationData.Entry> childEntries = entry.getChildren(); + if (childEntries == null) { + return; + } + for (int i = 0; i < childEntries.size(); i++) { + NotificationData.Entry childEntry = childEntries.get(i); + boolean isForeground = (entry.notification.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0; boolean keepForReply = getRemoteInputManager().shouldKeepForRemoteInputHistory(childEntry) @@ -692,10 +692,10 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. // a child we're keeping around for reply! continue; } - row.setKeepInParent(true); + entry.setKeepInParent(true); // we need to set this state earlier as otherwise we might generate some weird // animations - row.setRemoved(); + entry.removeRow(); } } } @@ -705,15 +705,15 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. mNotificationData.getNotificationsForCurrentUser(); for (int i = 0; i < userNotifications.size(); i++) { NotificationData.Entry entry = userNotifications.get(i); - boolean exposedGuts = mGutsManager.getExposedGuts() != null - && entry.row.getGuts() == mGutsManager.getExposedGuts(); - entry.row.onDensityOrFontScaleChanged(); + entry.onDensityOrFontScaleChanged(); + boolean exposedGuts = entry.areGutsExposed(); if (exposedGuts) { - mGutsManager.onDensityOrFontScaleChanged(entry.row); + mGutsManager.onDensityOrFontScaleChanged(entry); } } } + //TODO: This method associates a row with an entry, but eventually needs to not do that protected void updateNotification(NotificationData.Entry entry, PackageManager pmUser, StatusBarNotification sbn, ExpandableNotificationRow row) { boolean isLowPriority = mNotificationData.isAmbient(sbn.getKey()); @@ -736,8 +736,8 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. entry.setIconTag(R.id.icon_is_pre_L, entry.targetSdk < Build.VERSION_CODES.LOLLIPOP); entry.autoRedacted = entry.notification.getNotification().publicVersion == null; - entry.row = row; - entry.row.setOnActivatedListener(mPresenter); + entry.setRow(row); + row.setOnActivatedListener(mPresenter); boolean useIncreasedCollapsedHeight = mMessagingUtil.isImportantMessaging(sbn, mNotificationData.getImportance(sbn.getKey())); @@ -910,7 +910,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. if (!notification.isClearable()) { // The user may have performed a dismiss action on the notification, since it's // not clearable we should snap it back. - mListContainer.snapViewIfNeeded(entry.row); + mListContainer.snapViewIfNeeded(entry); } if (DEBUG) { @@ -963,11 +963,11 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. if (NotificationUiAdjustment.needReinflate( oldAdjustments.get(entry.key), newAdjustment)) { - if (entry.row != null) { + if (entry.rowExists()) { entry.reset(); PackageManager pmUser = StatusBar.getPackageManagerForUser(mContext, entry.notification.getUser().getIdentifier()); - updateNotification(entry, pmUser, entry.notification, entry.row); + updateNotification(entry, pmUser, entry.notification, entry.getRow()); } else { // Once the RowInflaterTask is done, it will pick up the updated entry, so // no-op here. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisibilityLocationProvider.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisibilityLocationProvider.java index 53ebe747c2e9..247c1ababc18 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisibilityLocationProvider.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisibilityLocationProvider.java @@ -26,8 +26,8 @@ public interface VisibilityLocationProvider { /** * Returns whether an ExpandableNotificationRow is in a visible location or not. * - * @param row + * @param entry * @return true if row is in a visible location */ - boolean isInVisibleLocation(ExpandableNotificationRow row); + boolean isInVisibleLocation(NotificationData.Entry entry); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java index 75613a42eb5e..fce79800193d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java @@ -120,7 +120,7 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener { return true; } if (mAllowedReorderViews.contains(row) - && !mVisibilityLocationProvider.isInVisibleLocation(row)) { + && !mVisibilityLocationProvider.isInVisibleLocation(row.getEntry())) { return true; } return false; @@ -142,12 +142,12 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener { if (isHeadsUp) { // Heads up notifications should in general be allowed to reorder if they are out of // view and stay at the current location if they aren't. - mAllowedReorderViews.add(entry.row); + mAllowedReorderViews.add(entry.getRow()); } } public void onLowPriorityUpdated(NotificationData.Entry entry) { - mLowPriorityReorderingViews.add(entry.row); + mLowPriorityReorderingViews.add(entry.getRow()); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java index 5dfd5d0da4af..87313b8a0393 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java @@ -115,7 +115,7 @@ public class NotificationLogger implements StateListener { for (int i = 0; i < N; i++) { NotificationData.Entry entry = activeNotifications.get(i); String key = entry.notification.getKey(); - boolean isVisible = mListContainer.isInVisibleLocation(entry.row); + boolean isVisible = mListContainer.isInVisibleLocation(entry); NotificationVisibility visObj = NotificationVisibility.obtain(key, i, N, isVisible); boolean previouslyVisible = mCurrentlyVisibleNotifications.contains(visObj); if (isVisible) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index daec9c9cca33..23bfdad02e7d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -104,6 +104,7 @@ import com.android.systemui.statusbar.notification.stack.AmbientState; import com.android.systemui.statusbar.notification.stack.AnimationProperties; import com.android.systemui.statusbar.notification.stack.ExpandableViewState; import com.android.systemui.statusbar.notification.stack.NotificationChildrenContainer; +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.notification.stack.StackScrollState; import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.StatusBar; @@ -1411,16 +1412,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public void performDismiss(boolean fromAccessibility) { if (isOnlyChildInGroup()) { - ExpandableNotificationRow groupSummary = + NotificationData.Entry groupSummary = mGroupManager.getLogicalGroupSummary(getStatusBarNotification()); if (groupSummary.isClearable()) { // If this is the only child in the group, dismiss the group, but don't try to show // the blocking helper affordance! - groupSummary.performDismiss(fromAccessibility); + groupSummary.getRow().performDismiss(fromAccessibility); } } setDismissed(fromAccessibility); - if (isClearable()) { + if (mEntry.isClearable()) { // TODO: track dismiss sentiment if (mOnDismissRunnable != null) { mOnDismissRunnable.run(); @@ -2244,28 +2245,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView setRippleAllowed(allowed); } - /** - * @return Can the underlying notification be cleared? This can be different from whether the - * notification can be dismissed in case notifications are sensitive on the lockscreen. - * @see #canViewBeDismissed() - */ - public boolean isClearable() { - if (mStatusBarNotification == null || !mStatusBarNotification.isClearable()) { - return false; - } - if (mIsSummaryWithChildren) { - List<ExpandableNotificationRow> notificationChildren = - mChildrenContainer.getNotificationChildren(); - for (int i = 0; i < notificationChildren.size(); i++) { - ExpandableNotificationRow child = notificationChildren.get(i); - if (!child.isClearable()) { - return false; - } - } - } - return true; - } - @Override public int getIntrinsicHeight() { if (isShownAsBubble()) { @@ -2533,10 +2512,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView /** * @return Whether this view is allowed to be dismissed. Only valid for visible notifications as * otherwise some state might not be updated. To request about the general clearability - * see {@link #isClearable()}. + * see {@link NotificationData.Entry#isClearable()}. */ public boolean canViewBeDismissed() { - return isClearable() && (!shouldShowPublic() || !mSensitiveHiddenInGeneral); + return mEntry.isClearable() && (!shouldShowPublic() || !mSensitiveHiddenInGeneral); } private boolean shouldShowPublic() { @@ -3038,6 +3017,21 @@ public class ExpandableNotificationRow extends ActivatableNotificationView return mOnAmbient; } + //TODO: this logic can't depend on layout if we are recycling! + public boolean isMediaRow() { + return getExpandedContentView() != null + && getExpandedContentView().findViewById( + com.android.internal.R.id.media_actions) != null; + } + + public boolean isTopLevelChild() { + return getParent() instanceof NotificationStackScrollLayout; + } + + public boolean isGroupNotFullyVisible() { + return getClipTopAmount() > 0 || getTranslationY() < 0; + } + public void setAboveShelf(boolean aboveShelf) { boolean wasAboveShelf = isAboveShelf(); mAboveShelf = aboveShelf; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index aa5ab71f8eb8..a4fdc08d5579 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -1230,17 +1230,18 @@ public class NotificationContentView extends FrameLayout { mOnContentViewInactiveListeners.clear(); mBeforeN = entry.targetSdk < Build.VERSION_CODES.N; updateAllSingleLineViews(); + ExpandableNotificationRow row = entry.getRow(); if (mContractedChild != null) { - mContractedWrapper.onContentUpdated(entry.row); + mContractedWrapper.onContentUpdated(row); } if (mExpandedChild != null) { - mExpandedWrapper.onContentUpdated(entry.row); + mExpandedWrapper.onContentUpdated(row); } if (mHeadsUpChild != null) { - mHeadsUpWrapper.onContentUpdated(entry.row); + mHeadsUpWrapper.onContentUpdated(row); } if (mAmbientChild != null) { - mAmbientWrapper.onContentUpdated(entry.row); + mAmbientWrapper.onContentUpdated(row); } applyRemoteInputAndSmartReply(entry); updateLegacy(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java index 37bf06edde4f..7895a8e7831f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java @@ -86,7 +86,6 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx private final ActivityStarter mActivityStarter = Dependency.get(ActivityStarter.class); // which notification is currently being longpress-examined by the user - private final IStatusBarService mBarService; private NotificationGuts mNotificationGutsExposed; private NotificationMenuRowPlugin.MenuItem mGutsMenuItem; private NotificationSafeToRemoveCallback mNotificationLifetimeFinishedCallback; @@ -103,8 +102,6 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); - mBarService = IStatusBarService.Stub.asInterface( - ServiceManager.getService(Context.STATUS_BAR_SERVICE)); } public void setUpWithPresenter(NotificationPresenter presenter, @@ -116,9 +113,9 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx mOnSettingsClickListener = onSettingsClick; } - public void onDensityOrFontScaleChanged(ExpandableNotificationRow row) { - setExposedGuts(row.getGuts()); - bindGuts(row); + public void onDensityOrFontScaleChanged(NotificationData.Entry entry) { + setExposedGuts(entry.getGuts()); + bindGuts(entry.getRow()); } /** @@ -441,8 +438,8 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx public boolean shouldExtendLifetime(NotificationData.Entry entry) { return entry != null &&(mNotificationGutsExposed != null - && entry.row.getGuts() != null - && mNotificationGutsExposed == entry.row.getGuts() + && entry.getGuts() != null + && mNotificationGutsExposed == entry.getGuts() && !mNotificationGutsExposed.isLeavebehind()); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationListContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationListContainer.java index 4d100a46c48a..6de4fc80cb4d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationListContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationListContainer.java @@ -118,9 +118,9 @@ public interface NotificationListContainer extends ExpandableView.OnHeightChange /** * Handle snapping a non-dismissable row back if the user tried to dismiss it. * - * @param row row to snap back + * @param entry the entry whose row needs to snap back */ - void snapViewIfNeeded(ExpandableNotificationRow row); + void snapViewIfNeeded(NotificationData.Entry entry); /** * Get the view parent for a notification entry. For example, NotificationStackScrollLayout. @@ -149,9 +149,9 @@ public interface NotificationListContainer extends ExpandableView.OnHeightChange * Called when a notification is removed from the shade. This cleans up the state for a * given view. * - * @param view view to clean up view state for + * @param entry the entry whose view's view state needs to be cleaned up (say that 5 times fast) */ - void cleanUpViewState(View view); + void cleanUpViewStateForEntry(NotificationData.Entry entry); /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java index c867a41e7264..27838a2a6a97 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java @@ -21,6 +21,7 @@ import static com.android.systemui.statusbar.notification.stack.NotificationStac import android.view.View; +import com.android.systemui.statusbar.notification.NotificationData; import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; @@ -50,13 +51,13 @@ class NotificationRoundnessManager implements OnHeadsUpChangedListener { } @Override - public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { - updateView(headsUp, false /* animate */); + public void onHeadsUpPinned(NotificationData.Entry headsUp) { + updateView(headsUp.getRow(), false /* animate */); } @Override - public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { - updateView(headsUp, true /* animate */); + public void onHeadsUpUnPinned(NotificationData.Entry headsUp) { + updateView(headsUp.getRow(), true /* animate */); } public void onHeadsupAnimatingAwayChanged(ExpandableNotificationRow row, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index ecd0d98bdcf4..faccff392af5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -600,12 +600,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd public void setRemoteInputActive(NotificationData.Entry entry, boolean remoteInputActive) { mHeadsUpManager.setRemoteInputActive(entry, remoteInputActive); - entry.row.notifyHeightChanged(true /* needsAnimation */); + entry.notifyHeightChanged(true /* needsAnimation */); updateFooter(); } public void lockScrollTo(NotificationData.Entry entry) { - NotificationStackScrollLayout.this.lockScrollTo(entry.row); + NotificationStackScrollLayout.this.lockScrollTo(entry.getRow()); } public void requestDisallowLongPressAndDismiss() { @@ -897,7 +897,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd @Override @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM) - public boolean isInVisibleLocation(ExpandableNotificationRow row) { + public boolean isInVisibleLocation(NotificationData.Entry entry) { + ExpandableNotificationRow row = entry.getRow(); ExpandableViewState childViewState = mCurrentStackScrollState.getViewStateForView(row); if (childViewState == null) { return false; @@ -1213,12 +1214,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd if (topEntry == null) { return 0; } - ExpandableNotificationRow row = topEntry.row; + ExpandableNotificationRow row = topEntry.getRow(); if (row.isChildInGroup()) { - final ExpandableNotificationRow groupSummary + final NotificationData.Entry groupSummary = mGroupManager.getGroupSummary(row.getStatusBarNotification()); if (groupSummary != null) { - row = groupSummary; + row = groupSummary.getRow(); } } return row.getPinnedHeadsUpHeight(); @@ -1390,11 +1391,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd && touchY >= top && touchY <= bottom && touchX >= left && touchX <= right) { if (slidingChild instanceof ExpandableNotificationRow) { ExpandableNotificationRow row = (ExpandableNotificationRow) slidingChild; + NotificationData.Entry entry = row.getEntry(); if (!mIsExpanded && row.isHeadsUp() && row.isPinned() - && mHeadsUpManager.getTopEntry().row != row + && mHeadsUpManager.getTopEntry().getRow() != row && mGroupManager.getGroupSummary( - mHeadsUpManager.getTopEntry().row.getStatusBarNotification()) - != row) { + mHeadsUpManager.getTopEntry().notification) + != entry) { continue; } return row.getViewAtPosition(touchY - childTop); @@ -1524,7 +1526,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd @Override @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) - public void snapViewIfNeeded(ExpandableNotificationRow child) { + public void snapViewIfNeeded(NotificationData.Entry entry) { + ExpandableNotificationRow child = entry.getRow(); boolean animate = mIsExpanded || isPinnedHeadsUp(child); // If the child is showing the notification menu snap to that float targetLeft = child.getProvider().isMenuVisible() ? child.getTranslation() : 0; @@ -2514,7 +2517,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) @Override - public void cleanUpViewState(View child) { + public void cleanUpViewStateForEntry(NotificationData.Entry entry) { + View child = entry.getRow(); if (child == mSwipeHelper.getTranslatingParentView()) { mSwipeHelper.clearTranslatingParentView(); } @@ -2644,9 +2648,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd private boolean isChildInInvisibleGroup(View child) { if (child instanceof ExpandableNotificationRow) { ExpandableNotificationRow row = (ExpandableNotificationRow) child; - ExpandableNotificationRow groupSummary = + NotificationData.Entry groupSummary = mGroupManager.getGroupSummary(row.getStatusBarNotification()); - if (groupSummary != null && groupSummary != row) { + if (groupSummary != null && groupSummary.getRow() != row) { return row.getVisibility() == View.INVISIBLE; } } @@ -4662,6 +4666,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd mHeadsUpManager.setAnimationStateHandler(this::setHeadsUpGoingAwayAnimationsAllowed); } + public void generateHeadsUpAnimation(NotificationData.Entry entry, boolean isHeadsUp) { + ExpandableNotificationRow row = entry.getHeadsUpAnimationView(); + generateHeadsUpAnimation(row, isHeadsUp); + } + @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) public void generateHeadsUpAnimation(ExpandableNotificationRow row, boolean isHeadsUp) { if (mAnimationsEnabled && (isHeadsUp || mHeadsUpGoingAwayAnimationsAllowed)) { @@ -5692,7 +5701,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd && (parent.areGutsExposed() || mSwipeHelper.getExposedMenuView() == parent || (parent.getNotificationChildren().size() == 1 - && parent.isClearable()))) { + && parent.getEntry().isClearable()))) { // In this case the group is expanded and showing the menu for the // group, further interaction should apply to the group, not any // child notifications so we use the parent of the child. We also do the same diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java index 40f9f45bf8bb..3c8cad7cb60b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java @@ -143,9 +143,9 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, } @Override - public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { + public void onHeadsUpPinned(NotificationData.Entry entry) { updateTopEntry(); - updateHeader(headsUp.getEntry()); + updateHeader(entry); } /** To count the distance from the window right boundary to scroller right boundary. The @@ -298,9 +298,9 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, } @Override - public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { + public void onHeadsUpUnPinned(NotificationData.Entry entry) { updateTopEntry(); - updateHeader(headsUp.getEntry()); + updateHeader(entry); } public void setExpandedHeight(float expandedHeight, float appearFraction) { @@ -339,7 +339,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, } public void updateHeader(NotificationData.Entry entry) { - ExpandableNotificationRow row = entry.row; + ExpandableNotificationRow row = entry.getRow(); float headerVisibleAmount = 1.0f; if (row.isPinned() || row.isHeadsUpAnimatingAway() || row == mTrackedChild) { headerVisibleAmount = mExpandFraction; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java index 00d6b14f50c5..9faada05294b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java @@ -304,18 +304,19 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, return; } if (hasPinnedHeadsUp()) { - ExpandableNotificationRow topEntry = getTopEntry().row; + NotificationData.Entry topEntry = getTopEntry(); if (topEntry.isChildInGroup()) { - final ExpandableNotificationRow groupSummary - = mGroupManager.getGroupSummary(topEntry.getStatusBarNotification()); + final NotificationData.Entry groupSummary + = mGroupManager.getGroupSummary(topEntry.notification); if (groupSummary != null) { topEntry = groupSummary; } } - topEntry.getLocationOnScreen(mTmpTwoArray); + ExpandableNotificationRow topRow = topEntry.getRow(); + topRow.getLocationOnScreen(mTmpTwoArray); int minX = mTmpTwoArray[0]; - int maxX = mTmpTwoArray[0] + topEntry.getWidth(); - int height = topEntry.getIntrinsicHeight(); + int maxX = mTmpTwoArray[0] + topRow.getWidth(); + int height = topRow.getIntrinsicHeight(); info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION); info.touchableRegion.set(minX, 0, maxX, mHeadsUpInset + height); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java index be4df458ecb9..9c1c71a2dec8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java @@ -84,8 +84,8 @@ public class HeadsUpTouchHelper implements Gefingerpoken { // We might touch above the visible heads up child, but then we still would // like to capture it. NotificationData.Entry topEntry = mHeadsUpManager.getTopEntry(); - if (topEntry != null && topEntry.row.isPinned()) { - mPickedChild = topEntry.row; + if (topEntry != null && topEntry.isRowPinned()) { + mPickedChild = topEntry.getRow(); mTouchingHeadsUpView = true; } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java index c74514e05b20..3e31fa06ef27 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java @@ -198,7 +198,7 @@ public class NotificationGroupAlertTransferHelper implements OnGroupChangeListen alertNotificationWhenPossible(entry, getActiveAlertManager()); } else { // The transfer is no longer valid. Free the content. - entry.row.freeContentViewWhenSafe(alertInfo.mAlertManager.getContentFlag()); + entry.getRow().freeContentViewWhenSafe(alertInfo.mAlertManager.getContentFlag()); } } } @@ -299,9 +299,9 @@ public class NotificationGroupAlertTransferHelper implements OnGroupChangeListen Entry child = mGroupManager.getLogicalChildren(summary.notification).iterator().next(); if (child != null) { - if (child.row.keepInParent() - || child.row.isRemoved() - || child.row.isDismissed()) { + if (child.getRow().keepInParent() + || child.isRowRemoved() + || child.isRowDismissed()) { // The notification is actually already removed. No need to alert it. return; } @@ -390,10 +390,10 @@ public class NotificationGroupAlertTransferHelper implements OnGroupChangeListen private void alertNotificationWhenPossible(@NonNull Entry entry, @NonNull AlertingNotificationManager alertManager) { @InflationFlag int contentFlag = alertManager.getContentFlag(); - if (!entry.row.isInflationFlagSet(contentFlag)) { + if (!entry.getRow().isInflationFlagSet(contentFlag)) { mPendingAlerts.put(entry.key, new PendingAlertInfo(entry, alertManager)); - entry.row.updateInflationFlag(contentFlag, true /* shouldInflate */); - entry.row.inflateViews(); + entry.getRow().updateInflationFlag(contentFlag, true /* shouldInflate */); + entry.getRow().inflateViews(); return; } if (alertManager.isAlerting(entry.key)) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java index 8ceabf809df8..448b5c38da51 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java @@ -87,8 +87,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, group.expanded = expanded; if (group.summary != null) { for (OnGroupChangeListener listener : mListeners) { - listener.onGroupExpansionChanged(group.summary.row, - expanded); + listener.onGroupExpansionChanged(group.summary.getRow(), expanded); } } } @@ -133,7 +132,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, } public void onEntryAdded(final NotificationData.Entry added) { - if (added.row.isRemoved()) { + if (added.isRowRemoved()) { added.setDebugThrowable(new Throwable()); } final StatusBarNotification sbn = added.notification; @@ -152,17 +151,17 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, if (existing != null && existing != added) { Throwable existingThrowable = existing.getDebugThrowable(); Log.wtf(TAG, "Inconsistent entries found with the same key " + added.key - + "existing removed: " + existing.row.isRemoved() + + "existing removed: " + existing.isRowRemoved() + (existingThrowable != null ? Log.getStackTraceString(existingThrowable) + "\n": "") - + " added removed" + added.row.isRemoved() + + " added removed" + added.isRowRemoved() , new Throwable()); } group.children.put(added.key, added); updateSuppression(group); } else { group.summary = added; - group.expanded = added.row.areChildrenExpanded(); + group.expanded = added.areChildrenExpanded(); updateSuppression(group); if (!group.children.isEmpty()) { ArrayList<NotificationData.Entry> childrenCopy @@ -263,9 +262,9 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, if (!isOnlyChild(sbn)) { return false; } - ExpandableNotificationRow logicalGroupSummary = getLogicalGroupSummary(sbn); + NotificationData.Entry logicalGroupSummary = getLogicalGroupSummary(sbn); return logicalGroupSummary != null - && !logicalGroupSummary.getStatusBarNotification().equals(sbn); + && !logicalGroupSummary.notification.equals(sbn); } private int getTotalNumberOfChildren(StatusBarNotification sbn) { @@ -339,7 +338,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, * Get the summary of a specified status bar notification. For isolated notification this return * itself. */ - public ExpandableNotificationRow getGroupSummary(StatusBarNotification sbn) { + public NotificationData.Entry getGroupSummary(StatusBarNotification sbn) { return getGroupSummary(getGroupKey(sbn)); } @@ -348,16 +347,17 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, * but the logical summary, i.e when a child is isolated, it still returns the summary as if * it wasn't isolated. */ - public ExpandableNotificationRow getLogicalGroupSummary(StatusBarNotification sbn) { + public NotificationData.Entry getLogicalGroupSummary(StatusBarNotification sbn) { return getGroupSummary(sbn.getGroupKey()); } @Nullable - private ExpandableNotificationRow getGroupSummary(String groupKey) { + private NotificationData.Entry getGroupSummary(String groupKey) { NotificationGroup group = mGroupMap.get(groupKey); + //TODO: see if this can become an Entry return group == null ? null : group.summary == null ? null - : group.summary.row; + : group.summary; } /** @@ -438,11 +438,11 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, } @Override - public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { + public void onHeadsUpPinned(NotificationData.Entry entry) { } @Override - public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { + public void onHeadsUpUnPinned(NotificationData.Entry entry) { } @Override @@ -533,8 +533,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, private boolean isGroupNotFullyVisible(NotificationGroup notificationGroup) { return notificationGroup.summary == null - || notificationGroup.summary.row.getClipTopAmount() > 0 - || notificationGroup.summary.row.getTranslationY() < 0; + || notificationGroup.summary.isGroupNotFullyVisible(); } public void setHeadsUpManager(HeadsUpManager headsUpManager) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java index 184766c6c7a3..2d5d56274640 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java @@ -192,13 +192,13 @@ public class NotificationIconAreaController implements DarkReceiver { && !mEntryManager.getNotificationData().isHighPriority(entry.notification)) { return false; } - if (!StatusBar.isTopLevelChild(entry)) { + if (!entry.isTopLevelChild()) { return false; } - if (entry.row.getVisibility() == View.GONE) { + if (entry.getRow().getVisibility() == View.GONE) { return false; } - if (entry.row.isDismissed() && hideDismissed) { + if (entry.isRowDismissed() && hideDismissed) { return false; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 851e6d0b4dea..33d176a580da 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -2500,25 +2500,26 @@ public class NotificationPanelView extends PanelView implements } @Override - public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { - mNotificationStackScroller.generateHeadsUpAnimation(headsUp, true); + public void onHeadsUpPinned(NotificationData.Entry entry) { + mNotificationStackScroller.generateHeadsUpAnimation(entry.getHeadsUpAnimationView(), true); } @Override - public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { + public void onHeadsUpUnPinned(NotificationData.Entry entry) { // When we're unpinning the notification via active edge they remain heads-upped, // we need to make sure that an animation happens in this case, otherwise the notification // will stick to the top without any interaction. - if (isFullyCollapsed() && headsUp.isHeadsUp()) { - mNotificationStackScroller.generateHeadsUpAnimation(headsUp, false); - headsUp.setHeadsUpIsVisible(); + if (isFullyCollapsed() && entry.isRowHeadsUp()) { + mNotificationStackScroller.generateHeadsUpAnimation( + entry.getHeadsUpAnimationView(), false); + entry.setHeadsUpIsVisible(); } } @Override public void onHeadsUpStateChanged(NotificationData.Entry entry, boolean isHeadsUp) { - mNotificationStackScroller.generateHeadsUpAnimation(entry.row, isHeadsUp); + mNotificationStackScroller.generateHeadsUpAnimation(entry, isHeadsUp); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index bdddf5b9794f..05f8f18effaf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -484,7 +484,7 @@ public class StatusBar extends SystemUI implements DemoMode, private Runnable mLaunchTransitionEndRunnable; protected boolean mLaunchTransitionFadingAway; - private ExpandableNotificationRow mDraggedDownRow; + private NotificationData.Entry mDraggedDownEntry; private boolean mLaunchCameraOnScreenTurningOn; private boolean mLaunchCameraOnFinishedGoingToSleep; private int mLastCameraLaunchSource; @@ -1265,10 +1265,6 @@ public class StatusBar extends SystemUI implements DemoMode, mQSPanel.clickTile(tile); } - public static boolean isTopLevelChild(Entry entry) { - return entry.row.getParent() instanceof NotificationStackScrollLayout; - } - public boolean areNotificationsHidden() { return mZenController.areNotificationsHiddenInShade(); } @@ -1491,12 +1487,12 @@ public class StatusBar extends SystemUI implements DemoMode, } @Override - public void onHeadsUpPinned(ExpandableNotificationRow headsUp) { + public void onHeadsUpPinned(NotificationData.Entry entry) { dismissVolumeDialog(); } @Override - public void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) { + public void onHeadsUpUnPinned(NotificationData.Entry entry) { } @Override @@ -2605,9 +2601,7 @@ public class StatusBar extends SystemUI implements DemoMode, final int notificationCount = activeNotifications.size(); for (int i = 0; i < notificationCount; i++) { NotificationData.Entry entry = activeNotifications.get(i); - if (entry.row != null) { - entry.row.resetUserExpansion(); - } + entry.resetUserExpansion(); } } @@ -3038,10 +3032,10 @@ public class StatusBar extends SystemUI implements DemoMode, mStatusBarStateController.setState(StatusBarState.KEYGUARD); } updatePanelExpansionForKeyguard(); - if (mDraggedDownRow != null) { - mDraggedDownRow.setUserLocked(false); - mDraggedDownRow.notifyHeightChanged(false /* needsAnimation */); - mDraggedDownRow = null; + if (mDraggedDownEntry != null) { + mDraggedDownEntry.setUserLocked(false); + mDraggedDownEntry.notifyHeightChanged(false /* needsAnimation */); + mDraggedDownEntry = null; } } @@ -3181,9 +3175,9 @@ public class StatusBar extends SystemUI implements DemoMode, } long delay = mKeyguardMonitor.calculateGoingToFullShadeDelay(); mNotificationPanel.animateToFullShade(delay); - if (mDraggedDownRow != null) { - mDraggedDownRow.setUserLocked(false); - mDraggedDownRow = null; + if (mDraggedDownEntry != null) { + mDraggedDownEntry.setUserLocked(false); + mDraggedDownEntry = null; } // TODO(115978725): Support animations on external nav bars. @@ -3575,14 +3569,15 @@ public class StatusBar extends SystemUI implements DemoMode, int userId = mLockscreenUserManager.getCurrentUserId(); ExpandableNotificationRow row = null; + NotificationData.Entry entry = null; if (expandView instanceof ExpandableNotificationRow) { - row = (ExpandableNotificationRow) expandView; - row.setUserExpanded(true /* userExpanded */, true /* allowChildExpansion */); + entry = ((ExpandableNotificationRow) expandView).getEntry(); + entry.setUserExpanded(true /* userExpanded */, true /* allowChildExpansion */); // Indicate that the group expansion is changing at this time -- this way the group // and children backgrounds / divider animations will look correct. - row.setGroupExpansionChanging(true); - if (row.getStatusBarNotification() != null) { - userId = row.getStatusBarNotification().getUserId(); + entry.setGroupExpansionChanging(true); + if (entry.notification != null) { + userId = entry.notification.getUserId(); } } boolean fullShadeNeedsBouncer = !mLockscreenUserManager. @@ -3592,7 +3587,7 @@ public class StatusBar extends SystemUI implements DemoMode, if (mLockscreenUserManager.isLockscreenPublicMode(userId) && fullShadeNeedsBouncer) { mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); showBouncerIfKeyguard(); - mDraggedDownRow = row; + mDraggedDownEntry = entry; mPendingRemoteInputView = null; } else { mNotificationPanel.animateToFullShade(0 /* delay */); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java index edfc0496149b..588c3a8a33ea 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java @@ -418,7 +418,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter { StatusBarNotification parentToCancel = null; if (shouldAutoCancel(sbn) && mGroupManager.isOnlyChildInGroup(sbn)) { StatusBarNotification summarySbn = - mGroupManager.getLogicalGroupSummary(sbn).getStatusBarNotification(); + mGroupManager.getLogicalGroupSummary(sbn).notification; if (shouldAutoCancel(summarySbn)) { parentToCancel = summarySbn; } @@ -591,7 +591,7 @@ public class StatusBarNotificationPresenter implements NotificationPresenter { public void onExpandClicked(Entry clickedEntry, boolean nowExpanded) { mHeadsUpManager.setExpanded(clickedEntry, nowExpanded); if (mStatusBarStateController.getState() == StatusBarState.KEYGUARD && nowExpanded) { - mShadeController.goToLockedShade(clickedEntry.row); + mShadeController.goToLockedShade(clickedEntry.getRow()); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java index fdab6168d05a..e72806438f54 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java @@ -123,15 +123,15 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "setEntryPinned: " + isPinned); } - ExpandableNotificationRow row = headsUpEntry.mEntry.row; - if (row.isPinned() != isPinned) { - row.setPinned(isPinned); + NotificationData.Entry entry = headsUpEntry.mEntry; + if (entry.isRowPinned() != isPinned) { + entry.setRowPinned(isPinned); updatePinnedMode(); for (OnHeadsUpChangedListener listener : mListeners) { if (isPinned) { - listener.onHeadsUpPinned(row); + listener.onHeadsUpPinned(entry); } else { - listener.onHeadsUpUnPinned(row); + listener.onHeadsUpUnPinned(entry); } } } @@ -144,7 +144,7 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { @Override protected void onAlertEntryAdded(AlertEntry alertEntry) { NotificationData.Entry entry = alertEntry.mEntry; - entry.row.setHeadsUp(true); + entry.setHeadsUp(true); setEntryPinned((HeadsUpEntry) alertEntry, shouldHeadsUpBecomePinned(entry)); for (OnHeadsUpChangedListener listener : mListeners) { listener.onHeadsUpStateChanged(entry, true); @@ -154,12 +154,12 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { @Override protected void onAlertEntryRemoved(AlertEntry alertEntry) { NotificationData.Entry entry = alertEntry.mEntry; - entry.row.setHeadsUp(false); + entry.setHeadsUp(false); setEntryPinned((HeadsUpEntry) alertEntry, false /* isPinned */); for (OnHeadsUpChangedListener listener : mListeners) { listener.onHeadsUpStateChanged(entry, false); } - entry.row.freeContentViewWhenSafe(FLAG_CONTENT_VIEW_HEADS_UP); + entry.freeContentViewWhenSafe(FLAG_CONTENT_VIEW_HEADS_UP); } protected void updatePinnedMode() { @@ -282,7 +282,7 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { private boolean hasPinnedNotificationInternal() { for (String key : mAlertEntries.keySet()) { AlertEntry entry = getHeadsUpEntry(key); - if (entry.mEntry.row.isPinned()) { + if (entry.mEntry.isRowPinned()) { return true; } } @@ -302,10 +302,9 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { // when the user unpinned all of HUNs by moving one HUN, all of HUNs should not stay // on the screen. - if (userUnPinned && entry.mEntry != null && entry.mEntry.row != null) { - ExpandableNotificationRow row = entry.mEntry.row; - if (row.mustStayOnScreen()) { - row.setHeadsUpIsVisible(); + if (userUnPinned && entry.mEntry != null) { + if (entry.mEntry.mustStayOnScreen()) { + entry.mEntry.setHeadsUpIsVisible(); } } } @@ -341,7 +340,7 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { */ public void setExpanded(@NonNull NotificationData.Entry entry, boolean expanded) { HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.key); - if (headsUpEntry != null && entry.row.isPinned()) { + if (headsUpEntry != null && entry.isRowPinned()) { headsUpEntry.setExpanded(expanded); } } @@ -365,15 +364,15 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { @Override protected boolean isSticky() { - return (mEntry.row.isPinned() && expanded) + return (mEntry.isRowPinned() && expanded) || remoteInputActive || hasFullScreenIntent(mEntry); } @Override public int compareTo(@NonNull AlertEntry alertEntry) { HeadsUpEntry headsUpEntry = (HeadsUpEntry) alertEntry; - boolean isPinned = mEntry.row.isPinned(); - boolean otherPinned = headsUpEntry.mEntry.row.isPinned(); + boolean isPinned = mEntry.isRowPinned(); + boolean otherPinned = headsUpEntry.mEntry.isRowPinned(); if (isPinned && !otherPinned) { return -1; } else if (!isPinned && otherPinned) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/OnHeadsUpChangedListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/OnHeadsUpChangedListener.java index d43476885979..7ad547afdb53 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/OnHeadsUpChangedListener.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/OnHeadsUpChangedListener.java @@ -33,12 +33,12 @@ public interface OnHeadsUpChangedListener { /** * A notification was just pinned to the top. */ - default void onHeadsUpPinned(ExpandableNotificationRow headsUp) {} + default void onHeadsUpPinned(NotificationData.Entry entry) {} /** * A notification was just unpinned from the top. */ - default void onHeadsUpUnPinned(ExpandableNotificationRow headsUp) {} + default void onHeadsUpUnPinned(NotificationData.Entry entry) {} /** * A notification just became a heads up or turned back to its normal state. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index a485fa89ebe8..866015e84af0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -245,7 +245,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - if (mEntry.row.isChangingPosition()) { + if (mEntry.getRow().isChangingPosition()) { if (getVisibility() == VISIBLE && mEditText.isFocusable()) { mEditText.requestFocus(); } @@ -255,7 +255,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - if (mEntry.row.isChangingPosition() || isTemporarilyDetached()) { + if (mEntry.getRow().isChangingPosition() || isTemporarilyDetached()) { return; } mController.removeRemoteInput(mEntry, mToken); @@ -495,7 +495,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene } private void defocusIfNeeded(boolean animate) { - if (mRemoteInputView != null && mRemoteInputView.mEntry.row.isChangingPosition() + if (mRemoteInputView != null && mRemoteInputView.mEntry.getRow().isChangingPosition() || isTemporarilyDetached()) { if (isTemporarilyDetached()) { // We might get reattached but then the other one of HUN / expanded might steal diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java index f49c5b47deda..9d0556f61398 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java @@ -120,7 +120,7 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { mTestHandler = Handler.createAsync(Looper.myLooper()); mSbn = createNewNotification(0 /* id */); mEntry = new NotificationData.Entry(mSbn); - mEntry.row = mRow; + mEntry.setRow(mRow); mAlertingNotificationManager = createAlertingNotificationManager(); } @@ -171,7 +171,7 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { for (int i = 0; i < TEST_NUM_NOTIFICATIONS; i++) { StatusBarNotification sbn = createNewNotification(i); NotificationData.Entry entry = new NotificationData.Entry(sbn); - entry.row = mRow; + entry.setRow(mRow); mAlertingNotificationManager.showNotification(entry); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java index d409e2b254df..b5d305d864e8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationRemoteInputManagerTest.java @@ -78,7 +78,7 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase { mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0, new Notification(), UserHandle.CURRENT, null, 0); mEntry = new NotificationData.Entry(mSbn); - mEntry.row = mRow; + mEntry.setRow(mRow); mRemoteInputManager.setUpWithPresenterForTest(mPresenter, mCallback, mDelegate, mController); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java index aca1f90b5aa8..9bed59b16f6e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java @@ -227,7 +227,7 @@ public class NotificationTestHelper { null /* overrideGroupKey */, System.currentTimeMillis()); NotificationData.Entry entry = new NotificationData.Entry(sbn); - entry.row = row; + entry.setRow(row); entry.createIcons(mContext, sbn); entry.channel = new NotificationChannel( notification.getChannelId(), notification.getChannelId(), IMPORTANCE_DEFAULT); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java index 602e613388fd..f64e84c28218 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationViewHierarchyManagerTest.java @@ -37,6 +37,7 @@ import com.android.systemui.InitController; import com.android.systemui.SysuiTestCase; import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper; import com.android.systemui.statusbar.notification.NotificationData; +import com.android.systemui.statusbar.notification.NotificationData.Entry; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.notification.logging.NotificationLogger; @@ -95,7 +96,7 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { private NotificationData.Entry createEntry() throws Exception { ExpandableNotificationRow row = mHelper.createRow(); NotificationData.Entry entry = new NotificationData.Entry(row.getStatusBarNotification()); - entry.row = row; + entry.setRow(row); return entry; } @@ -108,9 +109,9 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { NotificationData.Entry entry2 = createEntry(); // Set up the prior state to look like three top level notifications. - mListContainer.addContainerView(entry0.row); - mListContainer.addContainerView(entry1.row); - mListContainer.addContainerView(entry2.row); + mListContainer.addContainerView(entry0.getRow()); + mListContainer.addContainerView(entry1.getRow()); + mListContainer.addContainerView(entry2.getRow()); when(mNotificationData.getActiveNotifications()).thenReturn( Lists.newArrayList(entry0, entry1, entry2)); @@ -118,15 +119,15 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { when(mGroupManager.isChildInGroupWithSummary(entry0.notification)).thenReturn(false); when(mGroupManager.isChildInGroupWithSummary(entry1.notification)).thenReturn(true); when(mGroupManager.isChildInGroupWithSummary(entry2.notification)).thenReturn(true); - when(mGroupManager.getGroupSummary(entry1.notification)).thenReturn(entry0.row); - when(mGroupManager.getGroupSummary(entry2.notification)).thenReturn(entry0.row); + when(mGroupManager.getGroupSummary(entry1.notification)).thenReturn(entry0); + when(mGroupManager.getGroupSummary(entry2.notification)).thenReturn(entry0); // Run updateNotifications - the view hierarchy should be reorganized. mViewHierarchyManager.updateNotificationViews(); - verify(mListContainer).notifyGroupChildAdded(entry1.row); - verify(mListContainer).notifyGroupChildAdded(entry2.row); - assertTrue(Lists.newArrayList(entry0.row).equals(mListContainer.mRows)); + verify(mListContainer).notifyGroupChildAdded(entry1.getRow()); + verify(mListContainer).notifyGroupChildAdded(entry2.getRow()); + assertTrue(Lists.newArrayList(entry0.getRow()).equals(mListContainer.mRows)); } @Test @@ -135,11 +136,11 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { NotificationData.Entry entry0 = createEntry(); NotificationData.Entry entry1 = createEntry(); NotificationData.Entry entry2 = createEntry(); - entry0.row.addChildNotification(entry1.row); - entry0.row.addChildNotification(entry2.row); + entry0.getRow().addChildNotification(entry1.getRow()); + entry0.getRow().addChildNotification(entry2.getRow()); // Set up the prior state to look like one top level notification. - mListContainer.addContainerView(entry0.row); + mListContainer.addContainerView(entry0.getRow()); when(mNotificationData.getActiveNotifications()).thenReturn( Lists.newArrayList(entry0, entry1, entry2)); @@ -152,10 +153,12 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { mViewHierarchyManager.updateNotificationViews(); verify(mListContainer).notifyGroupChildRemoved( - entry1.row, entry0.row.getChildrenContainer()); + entry1.getRow(), entry0.getRow().getChildrenContainer()); verify(mListContainer).notifyGroupChildRemoved( - entry2.row, entry0.row.getChildrenContainer()); - assertTrue(Lists.newArrayList(entry0.row, entry1.row, entry2.row).equals(mListContainer.mRows)); + entry2.getRow(), entry0.getRow().getChildrenContainer()); + assertTrue( + Lists.newArrayList(entry0.getRow(), entry1.getRow(), entry2.getRow()) + .equals(mListContainer.mRows)); } @Test @@ -163,10 +166,10 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { // Tests two top level notifications becoming a suppressed summary and a child. NotificationData.Entry entry0 = createEntry(); NotificationData.Entry entry1 = createEntry(); - entry0.row.addChildNotification(entry1.row); + entry0.getRow().addChildNotification(entry1.getRow()); // Set up the prior state to look like a top level notification. - mListContainer.addContainerView(entry0.row); + mListContainer.addContainerView(entry0.getRow()); when(mNotificationData.getActiveNotifications()).thenReturn( Lists.newArrayList(entry0, entry1)); @@ -179,23 +182,23 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { mViewHierarchyManager.updateNotificationViews(); verify(mListContainer).notifyGroupChildRemoved( - entry1.row, entry0.row.getChildrenContainer()); - assertTrue(Lists.newArrayList(entry0.row, entry1.row).equals(mListContainer.mRows)); - assertEquals(View.GONE, entry0.row.getVisibility()); - assertEquals(View.VISIBLE, entry1.row.getVisibility()); + entry1.getRow(), entry0.getRow().getChildrenContainer()); + assertTrue(Lists.newArrayList(entry0.getRow(), entry1.getRow()).equals(mListContainer.mRows)); + assertEquals(View.GONE, entry0.getRow().getVisibility()); + assertEquals(View.VISIBLE, entry1.getRow().getVisibility()); } @Test public void testUpdateNotificationViews_appOps() throws Exception { NotificationData.Entry entry0 = createEntry(); - entry0.row = spy(entry0.row); + entry0.setRow(spy(entry0.getRow())); when(mNotificationData.getActiveNotifications()).thenReturn( Lists.newArrayList(entry0)); - mListContainer.addContainerView(entry0.row); + mListContainer.addContainerView(entry0.getRow()); mViewHierarchyManager.updateNotificationViews(); - verify(entry0.row, times(1)).showAppOpsIcons(any()); + verify(entry0.getRow(), times(1)).showAppOpsIcons(any()); } private class FakeListContainer implements NotificationListContainer { @@ -252,7 +255,7 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { public void setMaxDisplayedNotifications(int maxNotifications) {} @Override - public void snapViewIfNeeded(ExpandableNotificationRow row) {} + public void snapViewIfNeeded(Entry entry) {} @Override public ViewGroup getViewParentForNotification(NotificationData.Entry entry) { @@ -271,10 +274,10 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { } @Override - public void cleanUpViewState(View view) {} + public void cleanUpViewStateForEntry(Entry entry) { } @Override - public boolean isInVisibleLocation(ExpandableNotificationRow row) { + public boolean isInVisibleLocation(Entry entry) { return true; } @@ -286,5 +289,6 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase { public boolean hasPulsingNotifications() { return false; } + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java index d1fe5af406d3..8706e214db8e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java @@ -262,14 +262,14 @@ public class NotificationEntryManagerTest extends SysuiTestCase { NotificationData.Entry.class); verify(mCallback).onBindRow(entryCaptor.capture(), any(), eq(mSbn), any()); NotificationData.Entry entry = entryCaptor.getValue(); - verify(mRemoteInputManager).bindRow(entry.row); + verify(mRemoteInputManager).bindRow(entry.getRow()); // Row content inflation: verify(mCallback).onNotificationAdded(entry); verify(mPresenter).updateNotificationViews(); assertEquals(mEntryManager.getNotificationData().get(mSbn.getKey()), entry); - assertNotNull(entry.row); + assertNotNull(entry.getRow()); assertEquals(mEntry.userSentiment, NotificationListenerService.Ranking.USER_SENTIMENT_NEUTRAL); } @@ -294,7 +294,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { verify(mPresenter).updateNotificationViews(); verify(mForegroundServiceController).updateNotification(eq(mSbn), anyInt()); verify(mCallback).onNotificationUpdated(mSbn); - assertNotNull(mEntry.row); + assertNotNull(mEntry.getRow()); assertEquals(mEntry.userSentiment, NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE); } @@ -303,7 +303,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { public void testRemoveNotification() throws Exception { com.android.systemui.util.Assert.isNotMainThread(); - mEntry.row = mRow; + mEntry.setRow(mRow); mEntryManager.getNotificationData().add(mEntry); mEntryManager.removeNotification(mSbn.getKey(), mRankingMap); @@ -313,7 +313,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { verify(mMediaManager).onNotificationRemoved(mSbn.getKey()); verify(mForegroundServiceController).removeNotification(mSbn); - verify(mListContainer).cleanUpViewState(mRow); + verify(mListContainer).cleanUpViewStateForEntry(mEntry); verify(mPresenter).updateNotificationViews(); verify(mCallback).onNotificationRemoved(mSbn.getKey(), mSbn); verify(mRow).setRemoved(); @@ -332,7 +332,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { extenders.clear(); extenders.add(extender); - mEntry.row = mRow; + mEntry.setRow(mRow); mEntryManager.getNotificationData().add(mEntry); mEntryManager.removeNotification(mSbn.getKey(), mRankingMap); @@ -347,7 +347,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { when(mForegroundServiceController.getStandardLayoutKey(anyInt(), anyString())) .thenReturn(mEntry.key); - mEntry.row = mRow; + mEntry.setRow(mRow); mEntryManager.getNotificationData().add(mEntry); mEntryManager.updateNotificationsForAppOp( @@ -372,7 +372,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { @Test public void testAddNotificationExistingAppOps() { - mEntry.row = mRow; + mEntry.setRow(mRow); mEntryManager.getNotificationData().add(mEntry); ArraySet<Integer> expected = new ArraySet<>(); expected.add(3); @@ -395,7 +395,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { @Test public void testAdd_noExistingAppOps() { - mEntry.row = mRow; + mEntry.setRow(mRow); mEntryManager.getNotificationData().add(mEntry); when(mForegroundServiceController.getStandardLayoutKey( mEntry.notification.getUserId(), @@ -409,7 +409,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { @Test public void testAdd_existingAppOpsNotForegroundNoti() { - mEntry.row = mRow; + mEntry.setRow(mRow); mEntryManager.getNotificationData().add(mEntry); ArraySet<Integer> ops = new ArraySet<>(); ops.add(3); @@ -431,7 +431,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { when(mEnvironment.isDeviceProvisioned()).thenReturn(true); when(mEnvironment.isNotificationForCurrentProfiles(any())).thenReturn(true); - mEntry.row = mRow; + mEntry.setRow(mRow); mEntry.setInflationTask(mAsyncInflationTask); mEntryManager.getNotificationData().add(mEntry); setSmartActions(mEntry.key, new ArrayList<>(Arrays.asList(createAction()))); @@ -447,7 +447,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(true); when(mEnvironment.isNotificationForCurrentProfiles(any())).thenReturn(true); - mEntry.row = mRow; + mEntry.setRow(mRow); mEntryManager.getNotificationData().add(mEntry); setSmartActions(mEntry.key, null); @@ -461,7 +461,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(true); when(mEnvironment.isNotificationForCurrentProfiles(any())).thenReturn(true); - mEntry.row = null; + mEntry.setRow(null); mEntryManager.getNotificationData().add(mEntry); setSmartActions(mEntry.key, new ArrayList<>(Arrays.asList(createAction()))); @@ -476,7 +476,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(true); when(mEnvironment.isNotificationForCurrentProfiles(any())).thenReturn(true); - mEntry.row = null; + mEntry.setRow(null); mEntryManager.mPendingNotifications.put(mEntry.key, mEntry); setSmartActions(mEntry.key, new ArrayList<>(Arrays.asList(createAction()))); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/VisualStabilityManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/VisualStabilityManagerTest.java index ffb1c2d26af2..f19097934fd6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/VisualStabilityManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/VisualStabilityManagerTest.java @@ -47,7 +47,7 @@ public class VisualStabilityManagerTest extends SysuiTestCase { public void setUp() { mVisualStabilityManager.setVisibilityLocationProvider(mLocationProvider); mEntry = new NotificationData.Entry(mock(StatusBarNotification.class)); - mEntry.row = mRow; + mEntry.setRow(mRow); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java index 1c7a8e8185a3..3710fa833d50 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationLoggerTest.java @@ -89,7 +89,7 @@ public class NotificationLoggerTest extends SysuiTestCase { mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0, new Notification(), UserHandle.CURRENT, null, 0); mEntry = new NotificationData.Entry(mSbn); - mEntry.row = mRow; + mEntry.setRow(mRow); mLogger = new TestableNotificationLogger(mBarService); mLogger.setUpWithContainer(mListContainer); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java index 3d2ea708e90e..279796919879 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java @@ -54,6 +54,7 @@ import android.support.test.filters.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.util.ArraySet; +import android.util.Log; import android.view.View; import com.android.systemui.SysuiTestCase; @@ -177,10 +178,17 @@ public class NotificationGutsManagerTest extends SysuiTestCase { NotificationMenuRowPlugin.MenuItem menuItem = createTestMenuItem(realRow); ExpandableNotificationRow row = spy(realRow); + when(row.getWindowToken()).thenReturn(new Binder()); when(row.getGuts()).thenReturn(guts); doNothing().when(row).inflateGuts(); + NotificationData.Entry realEntry = realRow.getEntry(); + NotificationData.Entry entry = spy(realEntry); + + when(entry.getRow()).thenReturn(row); + when(entry.getGuts()).thenReturn(guts); + mGutsManager.openGuts(row, 0, 0, menuItem); mTestableLooper.processAllMessages(); verify(guts).openControls( @@ -190,13 +198,19 @@ public class NotificationGutsManagerTest extends SysuiTestCase { anyBoolean(), any(Runnable.class)); + // called once by mGutsManager.bindGuts() in mGutsManager.openGuts() + verify(row).setGutsView(any()); + row.onDensityOrFontScaleChanged(); - mGutsManager.onDensityOrFontScaleChanged(row); + mGutsManager.onDensityOrFontScaleChanged(entry); + mTestableLooper.processAllMessages(); mGutsManager.closeAndSaveGuts(false, false, false, 0, 0, false); verify(guts).closeControls(anyBoolean(), anyBoolean(), anyInt(), anyInt(), anyBoolean()); + + // called again by mGutsManager.bindGuts(), in mGutsManager.onDensityOrFontScaleChanged() verify(row, times(2)).setGutsView(any()); } @@ -470,7 +484,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase { ExpandableNotificationRow row = spy(createTestNotificationRow()); doReturn(guts).when(row).getGuts(); NotificationData.Entry entry = row.getEntry(); - entry.row = row; + entry.setRow(row); mGutsManager.setExposedGuts(guts); assertTrue(mGutsManager.shouldExtendLifetime(entry)); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 74ce5f63f01a..e65e806da93a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -325,7 +325,9 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { // add notification ExpandableNotificationRow row = mock(ExpandableNotificationRow.class); - when(row.isClearable()).thenReturn(true); + NotificationData.Entry entry = mock(NotificationData.Entry.class); + when(row.getEntry()).thenReturn(entry); + when(entry.isClearable()).thenReturn(true); mStackScroller.addContainerView(row); mStackScroller.onUpdateRowStates(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java index 10b0d834b36b..c99e766ac697 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java @@ -81,12 +81,12 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { mFirst.setPinned(true); when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry()); - mHeadsUpAppearanceController.onHeadsUpPinned(mFirst); + mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry()); Assert.assertEquals(mFirst.getEntry(), mHeadsUpStatusBarView.getShowingEntry()); mFirst.setPinned(false); when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); - mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst); + mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry()); Assert.assertEquals(null, mHeadsUpStatusBarView.getShowingEntry()); } @@ -95,12 +95,12 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { mFirst.setPinned(true); when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry()); - mHeadsUpAppearanceController.onHeadsUpPinned(mFirst); + mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry()); Assert.assertTrue(mHeadsUpAppearanceController.isShown()); mFirst.setPinned(false); when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); - mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst); + mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry()); Assert.assertFalse(mHeadsUpAppearanceController.isShown()); } @@ -109,12 +109,12 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { mFirst.setPinned(true); when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry()); - mHeadsUpAppearanceController.onHeadsUpPinned(mFirst); + mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry()); Assert.assertEquals(mFirst.getHeaderVisibleAmount(), 0.0f, 0.0f); mFirst.setPinned(false); when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); - mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst); + mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry()); Assert.assertEquals(mFirst.getHeaderVisibleAmount(), 1.0f, 0.0f); } @@ -125,12 +125,12 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { mFirst.setPinned(true); when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry()); - mHeadsUpAppearanceController.onHeadsUpPinned(mFirst); + mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry()); Assert.assertEquals(View.INVISIBLE, mOperatorNameView.getVisibility()); mFirst.setPinned(false); when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); - mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst); + mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry()); Assert.assertEquals(View.VISIBLE, mOperatorNameView.getVisibility()); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java index 10707957521e..44deb10941ec 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java @@ -97,7 +97,7 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest { @Test public void testCanRemoveImmediately_notTopEntry() { NotificationData.Entry laterEntry = new NotificationData.Entry(createNewNotification(1)); - laterEntry.row = mRow; + laterEntry.setRow(mRow); mHeadsUpManager.showNotification(mEntry); mHeadsUpManager.showNotification(laterEntry); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java index 96c57f2b7991..c3bc5110febe 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java @@ -149,7 +149,8 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { Entry summaryEntry = mGroupTestHelper.createSummaryNotification(); mHeadsUpManager.showNotification(summaryEntry); Entry childEntry = mGroupTestHelper.createChildNotification(); - when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false); + when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) + .thenReturn(false); mGroupManager.onEntryAdded(summaryEntry); mGroupManager.onEntryAdded(childEntry); @@ -166,12 +167,14 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { Entry summaryEntry = mGroupTestHelper.createSummaryNotification(); mHeadsUpManager.showNotification(summaryEntry); Entry childEntry = mGroupTestHelper.createChildNotification(); - when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false); + when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) + .thenReturn(false); mGroupManager.onEntryAdded(summaryEntry); mGroupManager.onEntryAdded(childEntry); - when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(true); + when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) + .thenReturn(true); mGroupAlertTransferHelper.onInflationFinished(childEntry); // Alert is immediately removed from summary, and we show child as its content is inflated. @@ -185,7 +188,8 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY); NotificationData.Entry childEntry = mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); - when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false); + when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) + .thenReturn(false); NotificationData.Entry childEntry2 = mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); mHeadsUpManager.showNotification(summaryEntry); @@ -199,10 +203,12 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupManager.onEntryAdded(childEntry2); // Child entry finishes its inflation. - when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(true); + when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) + .thenReturn(true); mGroupAlertTransferHelper.onInflationFinished(childEntry); - verify(childEntry.row, times(1)).freeContentViewWhenSafe(mHeadsUpManager.getContentFlag()); + verify(childEntry.getRow(), times(1)).freeContentViewWhenSafe(mHeadsUpManager + .getContentFlag()); assertFalse(mHeadsUpManager.isAlerting(childEntry.key)); } @@ -212,7 +218,8 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY); NotificationData.Entry childEntry = mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); - when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false); + when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) + .thenReturn(false); mHeadsUpManager.showNotification(summaryEntry); // Trigger a transfer of alert state from summary to child. mGroupManager.onEntryAdded(summaryEntry); @@ -229,7 +236,8 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY); NotificationData.Entry childEntry = mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); - when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false); + when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) + .thenReturn(false); mHeadsUpManager.showNotification(summaryEntry); // Trigger a transfer of alert state from summary to child. mGroupManager.onEntryAdded(summaryEntry); @@ -251,7 +259,8 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase { mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY); NotificationData.Entry childEntry = mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY); - when(childEntry.row.isInflationFlagSet(mHeadsUpManager.getContentFlag())).thenReturn(false); + when(childEntry.getRow().isInflationFlagSet(mHeadsUpManager.getContentFlag())) + .thenReturn(false); mHeadsUpManager.showNotification(summaryEntry); // Trigger a transfer of alert state from summary to child. mGroupManager.onEntryAdded(summaryEntry); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java index 1483ae5f2a12..b0bd1fba3760 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java @@ -100,7 +100,7 @@ public class NotificationGroupManagerTest extends SysuiTestCase { mGroupManager.onEntryAdded(mGroupTestHelper.createChildNotification()); assertTrue(mGroupManager.isSummaryOfGroup(summaryEntry.notification)); - assertEquals(summaryEntry.row, mGroupManager.getGroupSummary(childEntry.notification)); + assertEquals(summaryEntry, mGroupManager.getGroupSummary(childEntry.notification)); } @Test @@ -143,9 +143,8 @@ public class NotificationGroupManagerTest extends SysuiTestCase { // Child entries that are heads upped should be considered separate groups visually even if // they are the same group logically - assertEquals(childEntry.row, mGroupManager.getGroupSummary(childEntry.notification)); - assertEquals(summaryEntry.row, - mGroupManager.getLogicalGroupSummary(childEntry.notification)); + assertEquals(childEntry, mGroupManager.getGroupSummary(childEntry.notification)); + assertEquals(summaryEntry, mGroupManager.getLogicalGroupSummary(childEntry.notification)); } @Test @@ -161,8 +160,7 @@ public class NotificationGroupManagerTest extends SysuiTestCase { // Child entries that are heads upped should be considered separate groups visually even if // they are the same group logically - assertEquals(childEntry.row, mGroupManager.getGroupSummary(childEntry.notification)); - assertEquals(summaryEntry.row, - mGroupManager.getLogicalGroupSummary(childEntry.notification)); + assertEquals(childEntry, mGroupManager.getGroupSummary(childEntry.notification)); + assertEquals(summaryEntry, mGroupManager.getLogicalGroupSummary(childEntry.notification)); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java index 01f44fd4d0cc..7ad68eb1c9a3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupTestHelper.java @@ -81,7 +81,7 @@ public final class NotificationGroupTestHelper { 0 /* postTime */); NotificationData.Entry entry = new NotificationData.Entry(sbn); ExpandableNotificationRow row = mock(ExpandableNotificationRow.class); - entry.row = row; + entry.setRow(row); when(row.getEntry()).thenReturn(entry); when(row.getStatusBarNotification()).thenReturn(sbn); when(row.isInflationFlagSet(anyInt())).thenReturn(true); |