Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +14 −2 Original line number Diff line number Diff line Loading @@ -140,8 +140,14 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { } protected boolean shouldHeadsUpBecomePinned(@NonNull NotificationEntry entry) { final HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.getKey()); if (headsUpEntry == null) { // This should not happen since shouldHeadsUpBecomePinned is always called after adding // the NotificationEntry into AlertingNotificationManager's mAlertEntries map. return hasFullScreenIntent(entry); } return hasFullScreenIntent(entry) && !headsUpEntry.wasUnpinned; } protected boolean hasFullScreenIntent(@NonNull NotificationEntry entry) { return entry.getSbn().getNotification().fullScreenIntent != null; Loading @@ -151,6 +157,9 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { @NonNull HeadsUpManager.HeadsUpEntry headsUpEntry, boolean isPinned) { mLogger.logSetEntryPinned(headsUpEntry.mEntry, isPinned); NotificationEntry entry = headsUpEntry.mEntry; if (!isPinned) { headsUpEntry.wasUnpinned = true; } if (entry.isRowPinned() != isPinned) { entry.setRowPinned(isPinned); updatePinnedMode(); Loading @@ -177,7 +186,9 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { protected void onAlertEntryAdded(AlertEntry alertEntry) { NotificationEntry entry = alertEntry.mEntry; entry.setHeadsUp(true); setEntryPinned((HeadsUpEntry) alertEntry, shouldHeadsUpBecomePinned(entry)); final boolean shouldPin = shouldHeadsUpBecomePinned(entry); setEntryPinned((HeadsUpEntry) alertEntry, shouldPin); EventLogTags.writeSysuiHeadsUpStatus(entry.getKey(), 1 /* visible */); for (OnHeadsUpChangedListener listener : mListeners) { listener.onHeadsUpStateChanged(entry, true); Loading Loading @@ -411,6 +422,7 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { protected class HeadsUpEntry extends AlertEntry { public boolean remoteInputActive; protected boolean expanded; protected boolean wasUnpinned; @Override public boolean isSticky() { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java +48 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,54 @@ public class HeadsUpManagerTest extends AlertingNotificationManagerTest { verify(mLogger, times(1)).logNotificationActuallyRemoved(eq(mEntry)); } @Test public void testShouldHeadsUpBecomePinned_hasFSI_notUnpinned_true() { // Set up NotifEntry with FSI NotificationEntry notifEntry = new NotificationEntryBuilder() .setSbn(createNewNotification(/* id= */ 0)) .build(); notifEntry.getSbn().getNotification().fullScreenIntent = PendingIntent.getActivity( getContext(), 0, new Intent(getContext(), this.getClass()), PendingIntent.FLAG_MUTABLE_UNAUDITED); // Add notifEntry to ANM mAlertEntries map and make it NOT unpinned mHeadsUpManager.showNotification(notifEntry); HeadsUpManager.HeadsUpEntry headsUpEntry = mHeadsUpManager.getHeadsUpEntry(notifEntry.getKey()); headsUpEntry.wasUnpinned = false; assertTrue(mHeadsUpManager.shouldHeadsUpBecomePinned(notifEntry)); } @Test public void testShouldHeadsUpBecomePinned_wasUnpinned_false() { // Set up NotifEntry with FSI NotificationEntry notifEntry = new NotificationEntryBuilder() .setSbn(createNewNotification(/* id= */ 0)) .build(); notifEntry.getSbn().getNotification().fullScreenIntent = PendingIntent.getActivity( getContext(), 0, new Intent(getContext(), this.getClass()), PendingIntent.FLAG_MUTABLE_UNAUDITED); // Add notifEntry to ANM mAlertEntries map and make it unpinned mHeadsUpManager.showNotification(notifEntry); HeadsUpManager.HeadsUpEntry headsUpEntry = mHeadsUpManager.getHeadsUpEntry(notifEntry.getKey()); headsUpEntry.wasUnpinned = true; assertFalse(mHeadsUpManager.shouldHeadsUpBecomePinned(notifEntry)); } @Test public void testShouldHeadsUpBecomePinned_noFSI_false() { // Set up NotifEntry with no FSI NotificationEntry notifEntry = new NotificationEntryBuilder() .setSbn(createNewNotification(/* id= */ 0)) .build(); assertFalse(mHeadsUpManager.shouldHeadsUpBecomePinned(notifEntry)); } @Test public void testShowNotification_autoDismissesWithAccessibilityTimeout() { doReturn(TEST_A11Y_AUTO_DISMISS_TIME).when(mAccessibilityMgr) Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +14 −2 Original line number Diff line number Diff line Loading @@ -140,8 +140,14 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { } protected boolean shouldHeadsUpBecomePinned(@NonNull NotificationEntry entry) { final HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.getKey()); if (headsUpEntry == null) { // This should not happen since shouldHeadsUpBecomePinned is always called after adding // the NotificationEntry into AlertingNotificationManager's mAlertEntries map. return hasFullScreenIntent(entry); } return hasFullScreenIntent(entry) && !headsUpEntry.wasUnpinned; } protected boolean hasFullScreenIntent(@NonNull NotificationEntry entry) { return entry.getSbn().getNotification().fullScreenIntent != null; Loading @@ -151,6 +157,9 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { @NonNull HeadsUpManager.HeadsUpEntry headsUpEntry, boolean isPinned) { mLogger.logSetEntryPinned(headsUpEntry.mEntry, isPinned); NotificationEntry entry = headsUpEntry.mEntry; if (!isPinned) { headsUpEntry.wasUnpinned = true; } if (entry.isRowPinned() != isPinned) { entry.setRowPinned(isPinned); updatePinnedMode(); Loading @@ -177,7 +186,9 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { protected void onAlertEntryAdded(AlertEntry alertEntry) { NotificationEntry entry = alertEntry.mEntry; entry.setHeadsUp(true); setEntryPinned((HeadsUpEntry) alertEntry, shouldHeadsUpBecomePinned(entry)); final boolean shouldPin = shouldHeadsUpBecomePinned(entry); setEntryPinned((HeadsUpEntry) alertEntry, shouldPin); EventLogTags.writeSysuiHeadsUpStatus(entry.getKey(), 1 /* visible */); for (OnHeadsUpChangedListener listener : mListeners) { listener.onHeadsUpStateChanged(entry, true); Loading Loading @@ -411,6 +422,7 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { protected class HeadsUpEntry extends AlertEntry { public boolean remoteInputActive; protected boolean expanded; protected boolean wasUnpinned; @Override public boolean isSticky() { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java +48 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,54 @@ public class HeadsUpManagerTest extends AlertingNotificationManagerTest { verify(mLogger, times(1)).logNotificationActuallyRemoved(eq(mEntry)); } @Test public void testShouldHeadsUpBecomePinned_hasFSI_notUnpinned_true() { // Set up NotifEntry with FSI NotificationEntry notifEntry = new NotificationEntryBuilder() .setSbn(createNewNotification(/* id= */ 0)) .build(); notifEntry.getSbn().getNotification().fullScreenIntent = PendingIntent.getActivity( getContext(), 0, new Intent(getContext(), this.getClass()), PendingIntent.FLAG_MUTABLE_UNAUDITED); // Add notifEntry to ANM mAlertEntries map and make it NOT unpinned mHeadsUpManager.showNotification(notifEntry); HeadsUpManager.HeadsUpEntry headsUpEntry = mHeadsUpManager.getHeadsUpEntry(notifEntry.getKey()); headsUpEntry.wasUnpinned = false; assertTrue(mHeadsUpManager.shouldHeadsUpBecomePinned(notifEntry)); } @Test public void testShouldHeadsUpBecomePinned_wasUnpinned_false() { // Set up NotifEntry with FSI NotificationEntry notifEntry = new NotificationEntryBuilder() .setSbn(createNewNotification(/* id= */ 0)) .build(); notifEntry.getSbn().getNotification().fullScreenIntent = PendingIntent.getActivity( getContext(), 0, new Intent(getContext(), this.getClass()), PendingIntent.FLAG_MUTABLE_UNAUDITED); // Add notifEntry to ANM mAlertEntries map and make it unpinned mHeadsUpManager.showNotification(notifEntry); HeadsUpManager.HeadsUpEntry headsUpEntry = mHeadsUpManager.getHeadsUpEntry(notifEntry.getKey()); headsUpEntry.wasUnpinned = true; assertFalse(mHeadsUpManager.shouldHeadsUpBecomePinned(notifEntry)); } @Test public void testShouldHeadsUpBecomePinned_noFSI_false() { // Set up NotifEntry with no FSI NotificationEntry notifEntry = new NotificationEntryBuilder() .setSbn(createNewNotification(/* id= */ 0)) .build(); assertFalse(mHeadsUpManager.shouldHeadsUpBecomePinned(notifEntry)); } @Test public void testShowNotification_autoDismissesWithAccessibilityTimeout() { doReturn(TEST_A11Y_AUTO_DISMISS_TIME).when(mAccessibilityMgr) Loading