Merge "Exclude silent notifications from lockscreen" into tm-dev am: 009c9389ee
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18090439 Change-Id: I756ab9a87575cb673c4b44f155812c2584655d4d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -164,12 +164,23 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
|
|||||||
!lockscreenUserManager.shouldShowLockscreenNotifications() -> true
|
!lockscreenUserManager.shouldShowLockscreenNotifications() -> true
|
||||||
// User settings do not allow this notification on the lockscreen, so hide it.
|
// User settings do not allow this notification on the lockscreen, so hide it.
|
||||||
userSettingsDisallowNotification(entry) -> true
|
userSettingsDisallowNotification(entry) -> true
|
||||||
|
// if entry is silent, apply custom logic to see if should hide
|
||||||
|
shouldHideIfEntrySilent(entry) -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun shouldHideIfEntrySilent(entry: ListEntry): Boolean = when {
|
||||||
|
// Show if high priority (not hidden)
|
||||||
|
highPriorityProvider.isHighPriority(entry) -> false
|
||||||
|
// Ambient notifications are hidden always from lock screen
|
||||||
|
entry.representativeEntry?.isAmbient == true -> true
|
||||||
|
// [Now notification is silent]
|
||||||
|
// Hide regardless of parent priority if user wants silent notifs hidden
|
||||||
|
hideSilentNotificationsOnLockscreen -> true
|
||||||
// Parent priority is high enough to be shown on the lockscreen, do not hide.
|
// Parent priority is high enough to be shown on the lockscreen, do not hide.
|
||||||
entry.parent?.let(::priorityExceedsLockscreenShowingThreshold) == true -> false
|
entry.parent?.let(::shouldHideIfEntrySilent) == false -> false
|
||||||
// Entry priority is high enough to be shown on the lockscreen, do not hide.
|
// Show when silent notifications are allowed on lockscreen
|
||||||
priorityExceedsLockscreenShowingThreshold(entry) -> false
|
else -> false
|
||||||
// Priority is too low, hide.
|
|
||||||
else -> true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun userSettingsDisallowNotification(entry: NotificationEntry): Boolean {
|
private fun userSettingsDisallowNotification(entry: NotificationEntry): Boolean {
|
||||||
@@ -193,11 +204,6 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun priorityExceedsLockscreenShowingThreshold(entry: ListEntry): Boolean = when {
|
|
||||||
hideSilentNotificationsOnLockscreen -> highPriorityProvider.isHighPriority(entry)
|
|
||||||
else -> entry.representativeEntry?.ranking?.isAmbient == false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun readShowSilentNotificationSetting() {
|
private fun readShowSilentNotificationSetting() {
|
||||||
val showSilentNotifs =
|
val showSilentNotifs =
|
||||||
secureSettings.getBoolForUser(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
|
secureSettings.getBoolForUser(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import static com.android.systemui.util.mockito.KotlinMockitoHelpersKt.argThat;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.ArgumentMatchers.isNull;
|
import static org.mockito.ArgumentMatchers.isNull;
|
||||||
@@ -227,6 +228,41 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
|
|||||||
verify(listener).accept(anyString());
|
verify(listener).accept(anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void hideSilentNotificationsPerUserSettingWithHighPriorityParent() {
|
||||||
|
when(mKeyguardStateController.isShowing()).thenReturn(true);
|
||||||
|
mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, true);
|
||||||
|
mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, false);
|
||||||
|
GroupEntry parent = new GroupEntryBuilder()
|
||||||
|
.setKey("parent")
|
||||||
|
.addChild(mEntry)
|
||||||
|
.setSummary(new NotificationEntryBuilder()
|
||||||
|
.setUser(new UserHandle(NOTIF_USER_ID))
|
||||||
|
.setImportance(IMPORTANCE_LOW)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
mEntry = new NotificationEntryBuilder()
|
||||||
|
.setUser(new UserHandle(NOTIF_USER_ID))
|
||||||
|
.setImportance(IMPORTANCE_LOW)
|
||||||
|
.setParent(parent)
|
||||||
|
.build();
|
||||||
|
when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false);
|
||||||
|
assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void hideSilentNotificationsPerUserSetting() {
|
||||||
|
when(mKeyguardStateController.isShowing()).thenReturn(true);
|
||||||
|
mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, true);
|
||||||
|
mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, false);
|
||||||
|
mEntry = new NotificationEntryBuilder()
|
||||||
|
.setUser(new UserHandle(NOTIF_USER_ID))
|
||||||
|
.setImportance(IMPORTANCE_LOW)
|
||||||
|
.build();
|
||||||
|
when(mHighPriorityProvider.isHighPriority(any())).thenReturn(false);
|
||||||
|
assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void notifyListeners_onSettingChange_zenMode() {
|
public void notifyListeners_onSettingChange_zenMode() {
|
||||||
when(mKeyguardStateController.isShowing()).thenReturn(true);
|
when(mKeyguardStateController.isShowing()).thenReturn(true);
|
||||||
@@ -384,8 +420,8 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
|
|||||||
mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, false);
|
mFakeSettings.putBool(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, false);
|
||||||
when(mHighPriorityProvider.isHighPriority(parent)).thenReturn(true);
|
when(mHighPriorityProvider.isHighPriority(parent)).thenReturn(true);
|
||||||
|
|
||||||
// THEN don't filter out the entry
|
// THEN filter out the entry regardless of parent
|
||||||
assertFalse(
|
assertTrue(
|
||||||
mKeyguardNotificationVisibilityProvider.shouldHideNotification(entryWithParent));
|
mKeyguardNotificationVisibilityProvider.shouldHideNotification(entryWithParent));
|
||||||
|
|
||||||
// WHEN its parent doesn't exceed threshold to show on lockscreen
|
// WHEN its parent doesn't exceed threshold to show on lockscreen
|
||||||
|
|||||||
Reference in New Issue
Block a user