Merge "Notification lock screen setting updates"
This commit is contained in:
committed by
Android (Google) Code Review
commit
1ea9eeb9c6
@@ -7086,7 +7086,7 @@
|
|||||||
<string name="notification_pulse_title">Blink light</string>
|
<string name="notification_pulse_title">Blink light</string>
|
||||||
|
|
||||||
<!-- Configure Notifications: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
|
<!-- Configure Notifications: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
|
||||||
<string name="lock_screen_notifications_title">On the lock screen</string>
|
<string name="lock_screen_notifications_title">On lock screen</string>
|
||||||
|
|
||||||
<!-- Configure Notifications: Value for lockscreen notifications: all information will be
|
<!-- Configure Notifications: Value for lockscreen notifications: all information will be
|
||||||
shown in notifications shown on a secure lock screen
|
shown in notifications shown on a secure lock screen
|
||||||
@@ -7096,7 +7096,7 @@
|
|||||||
<!-- Configure Notifications: Value for lockscreen notifications: sensitive information will be
|
<!-- Configure Notifications: Value for lockscreen notifications: sensitive information will be
|
||||||
hidden or redacted from notifications shown on a secure lock screen
|
hidden or redacted from notifications shown on a secure lock screen
|
||||||
[CHAR LIMIT=50] -->
|
[CHAR LIMIT=50] -->
|
||||||
<string name="lock_screen_notifications_summary_hide">Hide sensitive notification content</string>
|
<string name="lock_screen_notifications_summary_hide">Hide sensitive content</string>
|
||||||
|
|
||||||
<!-- Configure Notifications: Value for lockscreen notifications: notifications will not appear on a secure lock screen
|
<!-- Configure Notifications: Value for lockscreen notifications: notifications will not appear on a secure lock screen
|
||||||
[CHAR LIMIT=50] -->
|
[CHAR LIMIT=50] -->
|
||||||
@@ -7116,7 +7116,7 @@
|
|||||||
<!-- Configure Notifications: Value for lockscreen notifications: sensitive information will be
|
<!-- Configure Notifications: Value for lockscreen notifications: sensitive information will be
|
||||||
hidden or redacted from work notifications shown on a secure lock screen
|
hidden or redacted from work notifications shown on a secure lock screen
|
||||||
[CHAR LIMIT=50] -->
|
[CHAR LIMIT=50] -->
|
||||||
<string name="lock_screen_notifications_summary_hide_profile">Hide sensitive work notification content</string>
|
<string name="lock_screen_notifications_summary_hide_profile">Hide sensitive work content</string>
|
||||||
|
|
||||||
<!-- Configure Notifications: Value for lockscreen notifications: work notifications will not appear on a secure lock screen
|
<!-- Configure Notifications: Value for lockscreen notifications: work notifications will not appear on a secure lock screen
|
||||||
[CHAR LIMIT=50] -->
|
[CHAR LIMIT=50] -->
|
||||||
@@ -7376,7 +7376,7 @@
|
|||||||
<string name="app_notification_override_dnd_summary">Let these notifications continue to interrupt when Do Not Disturb is set to Priority Only</string>
|
<string name="app_notification_override_dnd_summary">Let these notifications continue to interrupt when Do Not Disturb is set to Priority Only</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] App notification settings: Visibility override option title -->
|
<!-- [CHAR LIMIT=NONE] App notification settings: Visibility override option title -->
|
||||||
<string name="app_notification_visibility_override_title">On the lock screen</string>
|
<string name="app_notification_visibility_override_title">On lock screen</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=20] Notification settings: App notifications row summary when allowed -->
|
<!-- [CHAR LIMIT=20] Notification settings: App notifications row summary when allowed -->
|
||||||
<string name="app_notification_row_banned">Blocked</string>
|
<string name="app_notification_row_banned">Blocked</string>
|
||||||
|
@@ -84,14 +84,17 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro
|
|||||||
| DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
|
| DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getLockscreenNotificationsEnabled()) {
|
||||||
final String summaryHideEntry =
|
final String summaryHideEntry =
|
||||||
mContext.getString(R.string.lock_screen_notifications_summary_hide);
|
mContext.getString(R.string.lock_screen_notifications_summary_hide);
|
||||||
final String summaryHideEntryValue = Integer.toString(Notification.VISIBILITY_PRIVATE);
|
final String summaryHideEntryValue = Integer.toString(
|
||||||
|
Notification.VISIBILITY_PRIVATE);
|
||||||
entries.add(summaryHideEntry);
|
entries.add(summaryHideEntry);
|
||||||
values.add(summaryHideEntryValue);
|
values.add(summaryHideEntryValue);
|
||||||
setRestrictedIfNotificationFeaturesDisabled(pref,
|
setRestrictedIfNotificationFeaturesDisabled(pref,
|
||||||
summaryHideEntry, summaryHideEntryValue,
|
summaryHideEntry, summaryHideEntryValue,
|
||||||
DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||||
|
}
|
||||||
entries.add(mContext.getString(R.string.lock_screen_notifications_summary_disable));
|
entries.add(mContext.getString(R.string.lock_screen_notifications_summary_disable));
|
||||||
values.add(Integer.toString(Notification.VISIBILITY_SECRET));
|
values.add(Integer.toString(Notification.VISIBILITY_SECRET));
|
||||||
pref.setEntries(entries.toArray(new CharSequence[entries.size()]));
|
pref.setEntries(entries.toArray(new CharSequence[entries.size()]));
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
|
import static android.app.Notification.VISIBILITY_PRIVATE;
|
||||||
import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
|
import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
|
||||||
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
||||||
import static android.app.NotificationManager.IMPORTANCE_MIN;
|
import static android.app.NotificationManager.IMPORTANCE_MIN;
|
||||||
@@ -114,14 +115,14 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoCrashIfNoOnResume() throws Exception {
|
public void testNoCrashIfNoOnResume() {
|
||||||
mController.isAvailable();
|
mController.isAvailable();
|
||||||
mController.updateState(mock(RestrictedListPreference.class));
|
mController.updateState(mock(RestrictedListPreference.class));
|
||||||
mController.onPreferenceChange(mock(RestrictedListPreference.class), true);
|
mController.onPreferenceChange(mock(RestrictedListPreference.class), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAvailable_notSecure() throws Exception {
|
public void testIsAvailable_notSecure() {
|
||||||
when(mLockUtils.isSecure(anyInt())).thenReturn(false);
|
when(mLockUtils.isSecure(anyInt())).thenReturn(false);
|
||||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
|
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
|
||||||
@@ -130,7 +131,7 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAvailable_notIfNotImportant() throws Exception {
|
public void testIsAvailable_notIfNotImportant() {
|
||||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_MIN);
|
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_MIN);
|
||||||
mController.onResume(appRow, channel, null, null);
|
mController.onResume(appRow, channel, null, null);
|
||||||
@@ -138,7 +139,7 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAvailable() throws Exception {
|
public void testIsAvailable() {
|
||||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
NotificationChannel channel =
|
NotificationChannel channel =
|
||||||
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
|
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
|
||||||
@@ -151,7 +152,7 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateState_disabledByAdmin_disableSecure() throws Exception {
|
public void testUpdateState_disabledByAdmin_disableSecure() {
|
||||||
ShadowRestrictionUtils.setRestricted(true);
|
ShadowRestrictionUtils.setRestricted(true);
|
||||||
UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
|
UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
|
||||||
when(mUm.getUserInfo(anyInt())).thenReturn(userInfo);
|
when(mUm.getUserInfo(anyInt())).thenReturn(userInfo);
|
||||||
@@ -173,7 +174,7 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateState_disabledByAdmin_disableUnredacted() throws Exception {
|
public void testUpdateState_disabledByAdmin_disableUnredacted() {
|
||||||
ShadowRestrictionUtils.setRestricted(true);
|
ShadowRestrictionUtils.setRestricted(true);
|
||||||
UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
|
UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
|
||||||
when(mUm.getUserInfo(anyInt())).thenReturn(userInfo);
|
when(mUm.getUserInfo(anyInt())).thenReturn(userInfo);
|
||||||
@@ -195,7 +196,7 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateState_noLockScreenNotificationsGlobally() throws Exception {
|
public void testUpdateState_noLockScreenNotificationsGlobally() {
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
|
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
|
||||||
|
|
||||||
@@ -211,10 +212,14 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
|
verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
|
||||||
assertFalse(toStringList(argumentCaptor.getValue())
|
assertFalse(toStringList(argumentCaptor.getValue())
|
||||||
.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
|
.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
|
||||||
|
assertFalse(toStringList(argumentCaptor.getValue())
|
||||||
|
.contains(String.valueOf(VISIBILITY_PRIVATE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateState_noPrivateLockScreenNotificationsGlobally() throws Exception {
|
public void testUpdateState_noPrivateLockScreenNotificationsGlobally() {
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
|
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
|
||||||
|
|
||||||
@@ -228,12 +233,13 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
ArgumentCaptor<CharSequence[]> argumentCaptor =
|
ArgumentCaptor<CharSequence[]> argumentCaptor =
|
||||||
ArgumentCaptor.forClass(CharSequence[].class);
|
ArgumentCaptor.forClass(CharSequence[].class);
|
||||||
verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
|
verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
|
||||||
|
assertEquals(2, toStringList(argumentCaptor.getValue()).size());
|
||||||
assertFalse(toStringList(argumentCaptor.getValue())
|
assertFalse(toStringList(argumentCaptor.getValue())
|
||||||
.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
|
.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateState_noGlobalRestriction() throws Exception {
|
public void testUpdateState_noGlobalRestriction() {
|
||||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
NotificationChannel channel = mock(NotificationChannel.class);
|
NotificationChannel channel = mock(NotificationChannel.class);
|
||||||
mController.onResume(appRow, channel, null, null);
|
mController.onResume(appRow, channel, null, null);
|
||||||
@@ -247,7 +253,7 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
List<String> values = toStringList(argumentCaptor.getValue());
|
List<String> values = toStringList(argumentCaptor.getValue());
|
||||||
assertEquals(3, values.size());
|
assertEquals(3, values.size());
|
||||||
assertTrue(values.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
|
assertTrue(values.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
|
||||||
assertTrue(values.contains(String.valueOf(Notification.VISIBILITY_PRIVATE)));
|
assertTrue(values.contains(String.valueOf(VISIBILITY_PRIVATE)));
|
||||||
assertTrue(values.contains(String.valueOf(Notification.VISIBILITY_SECRET)));
|
assertTrue(values.contains(String.valueOf(Notification.VISIBILITY_SECRET)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +266,7 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateState_noChannelOverride() throws Exception {
|
public void testUpdateState_noChannelOverride() {
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
|
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
|
||||||
|
|
||||||
@@ -275,11 +281,11 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
|
ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
|
||||||
verify(pref, times(1)).setValue(argumentCaptor.capture());
|
verify(pref, times(1)).setValue(argumentCaptor.capture());
|
||||||
|
|
||||||
assertEquals(String.valueOf(Notification.VISIBILITY_PRIVATE), argumentCaptor.getValue());
|
assertEquals(String.valueOf(VISIBILITY_PRIVATE), argumentCaptor.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateState_channelOverride() throws Exception {
|
public void testUpdateState_channelOverride() {
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
|
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
|
||||||
|
|
||||||
@@ -310,7 +316,7 @@ public class VisibilityPreferenceControllerTest {
|
|||||||
RestrictedListPreference pref = mock(RestrictedListPreference.class);
|
RestrictedListPreference pref = mock(RestrictedListPreference.class);
|
||||||
mController.updateState(pref);
|
mController.updateState(pref);
|
||||||
|
|
||||||
mController.onPreferenceChange(pref, String.valueOf(Notification.VISIBILITY_PRIVATE));
|
mController.onPreferenceChange(pref, String.valueOf(VISIBILITY_PRIVATE));
|
||||||
|
|
||||||
assertEquals(VISIBILITY_NO_OVERRIDE, channel.getLockscreenVisibility());
|
assertEquals(VISIBILITY_NO_OVERRIDE, channel.getLockscreenVisibility());
|
||||||
verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
|
verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
|
||||||
|
Reference in New Issue
Block a user