Merge changes I1dffab01,I6e34ef9b,Ia8d472ea,Icf4e7003 into main

* changes:
  Notification on lockscreen settings: adapt text view for large font
  Inverse toggles on the notifications on locks screen settings page
  Update appearance of notifications on locks screen settings page
  Remove description from notifications on locks screen settings page
This commit is contained in:
Yining Liu
2025-01-02 16:11:51 -08:00
committed by Android (Google) Code Review
8 changed files with 82 additions and 111 deletions

View File

@@ -19,22 +19,10 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="@dimen/settingslib_illustration_padding"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView
android:id="@+id/notif_ls_style_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="@dimen/settingslib_illustration_padding"
android:paddingEnd="48dp"
android:paddingStart="48dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:focusable="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -66,12 +54,11 @@
</FrameLayout> </FrameLayout>
<TextView <TextView
android:layout_width="match_parent" android:layout_width="@dimen/contrast_button_total_size"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/contrast_button_text_spacing" android:layout_marginTop="@dimen/contrast_button_text_spacing"
android:gravity="center_horizontal|top" android:gravity="center_horizontal|top"
android:ellipsize="end" android:singleLine="false"
android:singleLine="true"
android:textSize="@dimen/contrast_button_text_size" android:textSize="@dimen/contrast_button_text_size"
android:text="@string/lock_screen_notifs_show_compact" android:text="@string/lock_screen_notifs_show_compact"
android:textColor="@androidprv:color/materialColorOnSurface"/> android:textColor="@androidprv:color/materialColorOnSurface"/>
@@ -101,12 +88,11 @@
</FrameLayout> </FrameLayout>
<TextView <TextView
android:layout_width="match_parent" android:layout_width="@dimen/contrast_button_total_size"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/contrast_button_text_spacing" android:layout_marginTop="@dimen/contrast_button_text_spacing"
android:gravity="center_horizontal|top" android:gravity="center_horizontal|top"
android:ellipsize="end" android:singleLine="false"
android:singleLine="true"
android:textSize="@dimen/contrast_button_text_size" android:textSize="@dimen/contrast_button_text_size"
android:text="@string/lock_screen_notifs_show_full_list" android:text="@string/lock_screen_notifs_show_full_list"
android:textColor="@androidprv:color/materialColorOnSurface"/> android:textColor="@androidprv:color/materialColorOnSurface"/>

View File

@@ -8892,14 +8892,8 @@
<!-- Configure notifications: Value for lockscreen notifications: show all notifications [CHAR LIMIT=60] --> <!-- Configure notifications: Value for lockscreen notifications: show all notifications [CHAR LIMIT=60] -->
<string name="lock_screen_notifs_show_full_list">Full list</string> <string name="lock_screen_notifs_show_full_list">Full list</string>
<!-- Configure notifications: Summary for lockscreen notifications: show all notifications [CHAR LIMIT=NONE] --> <!-- Configure notifications: Value for lockscreen notifications: show compact notifications (minimalism on) [CHAR LIMIT=30] -->
<string name="lock_screen_notifs_full_list_desc">The current default placement is a full shelf and notification stack.</string> <string name="lock_screen_notifs_show_compact">Compact View</string>
<!-- Configure notifications: Value for lockscreen notifications: show compact notifications (minimalism on) [CHAR LIMIT=60] -->
<string name="lock_screen_notifs_show_compact">Compact</string>
<!-- Configure notifications: Summary for lockscreen notifications: show compact notifications (minimalism on) [CHAR LIMIT=NONE] -->
<string name="lock_screen_notifs_compact_desc">New notifications are collapsed into a shelf on your lockscreen.</string>
<!-- Configure notifications: Title for determining which notifications appear on the lock screen [CHAR LIMIT=60] --> <!-- Configure notifications: Title for determining which notifications appear on the lock screen [CHAR LIMIT=60] -->
<string name="lock_screen_notifs_title">Notifications on lock screen</string> <string name="lock_screen_notifs_title">Notifications on lock screen</string>
@@ -8963,17 +8957,20 @@
<!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Message asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=NONE] --> <!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Message asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=NONE] -->
<string name="lock_screen_notifications_interstitial_message_profile">When your device is locked, how do you want profile notifications to show?</string> <string name="lock_screen_notifications_interstitial_message_profile">When your device is locked, how do you want profile notifications to show?</string>
<!-- Notification Settings > Notifications on lock screen > Title for hiding seen notifications toggle. [CHAR LIMIT=60] --> <!-- Notification Settings > Notifications on lock screen > Title for showing notifications on the lock screen. [CHAR LIMIT=100] -->
<string name="lock_screen_notification_hide_seen_title">Hide seen notifications</string> <string name="lockscreen_notification_what_to_show_title">What to show on lock screen</string>
<!-- Notification Settings > Notifications on lock screen > Summary for hiding seen notifications toggle. [CHAR LIMIT=100] --> <!-- Notification Settings > Notifications on lock screen > Title for showing seen notifications toggle. [CHAR LIMIT=60] -->
<string name="lock_screen_notification_hide_seen_summary">Seen notifications are removed from the lock screen.</string> <string name="lock_screen_notification_show_seen_title">Show seen notifications</string>
<!-- Notification Settings > Notifications on lock screen > Title for hiding silent notifications toggle. [CHAR LIMIT=60] --> <!-- Notification Settings > Notifications on lock screen > Title for hiding silent notifications toggle. [CHAR LIMIT=60] -->
<string name="lock_screen_notification_hide_silent_title">Hide silent notifications</string> <string name="lock_screen_notification_show_silent_title">Show silent notifications</string>
<!-- Notification Settings > Notifications on lock screen > Summary for hiding silent notifications toggle. [CHAR LIMIT=100] --> <!-- Notification Settings > Notifications on lock screen > Title for hiding sensitive notification content on lock screen. [CHAR LIMIT=60] -->
<string name="lock_screen_notification_hide_silent_summary">Silent notifications and conversations are removed from the lock screen.</string> <string name="lock_screen_notification_show_sensitive_content_title">Show sensitive content</string>
<!-- Notification Settings > Notifications on lock screen > Title for hiding sensitive work profile notification content on lock screen. [CHAR LIMIT=100] -->
<string name="lock_screen_notification_show_sensitive_work_content_title">Show sensitive work profile content</string>
<!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Title for the screen asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=30] --> <!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Title for the screen asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=30] -->
<string name="lock_screen_notifications_interstitial_title_profile">Profile notifications</string> <string name="lock_screen_notifications_interstitial_title_profile">Profile notifications</string>

View File

@@ -44,26 +44,30 @@
android:layout="@layout/notification_ls_minimalism_selector" android:layout="@layout/notification_ls_minimalism_selector"
settings:controller="com.android.settings.notification.lockscreen.MinimalismPreferenceController" /> settings:controller="com.android.settings.notification.lockscreen.MinimalismPreferenceController" />
<PreferenceCategory
android:key="lockscreen_notification_what_to_show"
android:title="@string/lockscreen_notification_what_to_show_title">
<SwitchPreferenceCompat
android:key="lock_screen_notification_show_seen_toggle"
android:title="@string/lock_screen_notification_show_seen_title"
settings:controller="com.android.settings.notification.LockScreenNotificationShowSeenController" />
<SwitchPreferenceCompat
android:key="lock_screen_notification_show_silent_toggle"
android:title="@string/lock_screen_notification_show_silent_title"
settings:controller="com.android.settings.notification.LockScreenNotificationShowSilentController" />
<com.android.settingslib.RestrictedSwitchPreference <com.android.settingslib.RestrictedSwitchPreference
android:key="lock_screen_notification_show_sensitive_toggle" android:key="lock_screen_notification_show_sensitive_toggle"
android:title="@string/lock_screen_notifications_summary_hide" android:title="@string/lock_screen_notification_show_sensitive_content_title"
settings:controller="com.android.settings.notification.LockScreenNotificationShowSensitiveToggleController" /> settings:controller="com.android.settings.notification.LockScreenNotificationShowSensitiveController" />
<com.android.settingslib.RestrictedSwitchPreference <com.android.settingslib.RestrictedSwitchPreference
android:key="work_profile_show_sensitive_notif_toggle" android:key="work_profile_show_sensitive_notif_toggle"
android:title="@string/lock_screen_notifications_summary_hide_profile" android:title="@string/lock_screen_notification_show_sensitive_work_content_title"
settings:controller="com.android.settings.notification.LockScreenNotificationShowSensitiveToggleController" /> settings:controller="com.android.settings.notification.LockScreenNotificationShowSensitiveController" />
<SwitchPreferenceCompat </PreferenceCategory>
android:key="lock_screen_notification_hide_seen_toggle"
android:title="@string/lock_screen_notification_hide_seen_title"
android:summary="@string/lock_screen_notification_hide_seen_summary"
settings:controller="com.android.settings.notification.LockScreenNotificationHideSeenToggleController" />
<SwitchPreferenceCompat
android:key="lock_screen_notification_hide_silent_toggle"
android:title="@string/lock_screen_notification_hide_silent_title"
android:summary="@string/lock_screen_notification_hide_silent_summary"
settings:controller="com.android.settings.notification.LockScreenNotificationHideSilentToggleController" />
</PreferenceScreen> </PreferenceScreen>

View File

@@ -39,7 +39,7 @@ import com.android.settings.core.TogglePreferenceController;
* Controls the toggle that determines whether to hide seen notifications from the lock screen. * Controls the toggle that determines whether to hide seen notifications from the lock screen.
* Toggle for setting: Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS * Toggle for setting: Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS
*/ */
public class LockScreenNotificationHideSeenToggleController extends TogglePreferenceController public class LockScreenNotificationShowSeenController extends TogglePreferenceController
implements LifecycleEventObserver { implements LifecycleEventObserver {
private static final int UNSET = 0; private static final int UNSET = 0;
@@ -57,7 +57,7 @@ public class LockScreenNotificationHideSeenToggleController extends TogglePrefer
} }
}; };
public LockScreenNotificationHideSeenToggleController(@NonNull Context context, public LockScreenNotificationShowSeenController(@NonNull Context context,
@NonNull String preferenceKey) { @NonNull String preferenceKey) {
super(context, preferenceKey); super(context, preferenceKey);
mContentResolver = context.getContentResolver(); mContentResolver = context.getContentResolver();
@@ -90,7 +90,7 @@ public class LockScreenNotificationHideSeenToggleController extends TogglePrefer
@Override @Override
public void updateState(@NonNull Preference preference) { public void updateState(@NonNull Preference preference) {
super.updateState(preference); super.updateState(preference);
setChecked(lockScreenShowOnlyUnseenNotifications()); setChecked(lockScreenShowSeenNotifications());
preference.setVisible(isAvailable()); preference.setVisible(isAvailable());
} }
@@ -115,18 +115,18 @@ public class LockScreenNotificationHideSeenToggleController extends TogglePrefer
@Override @Override
public boolean isChecked() { public boolean isChecked() {
return lockScreenShowOnlyUnseenNotifications(); return lockScreenShowSeenNotifications();
} }
private boolean lockScreenShowOnlyUnseenNotifications() { private boolean lockScreenShowSeenNotifications() {
return Settings.Secure.getInt(mContext.getContentResolver(), return Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, UNSET) == ON; Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, UNSET) == OFF;
} }
@Override @Override
public boolean setChecked(boolean isChecked) { public boolean setChecked(boolean isChecked) {
return Settings.Secure.putInt(mContext.getContentResolver(), return Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, (isChecked ? ON : OFF)); Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, (isChecked ? OFF : ON));
} }
@Override @Override

View File

@@ -53,7 +53,7 @@ import java.util.List;
* when locked. * when locked.
* Toggle for: Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS * Toggle for: Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS
*/ */
public class LockScreenNotificationShowSensitiveToggleController public class LockScreenNotificationShowSensitiveController
extends TogglePreferenceController implements LifecycleEventObserver { extends TogglePreferenceController implements LifecycleEventObserver {
private static final int ON = 1; private static final int ON = 1;
@@ -78,7 +78,7 @@ public class LockScreenNotificationShowSensitiveToggleController
} }
}; };
public LockScreenNotificationShowSensitiveToggleController(@NonNull Context context, public LockScreenNotificationShowSensitiveController(@NonNull Context context,
@NonNull String preferenceKey) { @NonNull String preferenceKey) {
super(context, preferenceKey); super(context, preferenceKey);
mContentResolver = context.getContentResolver(); mContentResolver = context.getContentResolver();
@@ -145,7 +145,7 @@ public class LockScreenNotificationShowSensitiveToggleController
@Override @Override
public void updateState(@Nullable Preference preference) { public void updateState(@Nullable Preference preference) {
if (preference == null) return; if (preference == null) return;
setChecked(showSensitiveContentOnlyWhenUnlocked()); setChecked(showSensitiveContentWhenLocked());
preference.setVisible(isAvailable()); preference.setVisible(isAvailable());
} }
@@ -187,15 +187,15 @@ public class LockScreenNotificationShowSensitiveToggleController
@Override @Override
public boolean isChecked() { public boolean isChecked() {
return showSensitiveContentOnlyWhenUnlocked(); return showSensitiveContentWhenLocked();
} }
private boolean showSensitiveContentOnlyWhenUnlocked() { private boolean showSensitiveContentWhenLocked() {
int userId = getUserId(); int userId = getUserId();
if (!isLockScreenSecure()) return false; if (!isLockScreenSecure()) return true;
if (getEnforcedAdmin(userId) != null) return true; if (getEnforcedAdmin(userId) != null) return false;
return Settings.Secure.getIntForUser(mContext.getContentResolver(), return Settings.Secure.getIntForUser(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, ON, userId) == OFF; Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, ON, userId) == ON;
} }
@Override @Override
@@ -203,7 +203,7 @@ public class LockScreenNotificationShowSensitiveToggleController
return Settings.Secure.putIntForUser( return Settings.Secure.putIntForUser(
mContext.getContentResolver(), mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
(isChecked ? OFF : ON), getUserId() (isChecked ? ON : OFF), getUserId()
); );
} }

View File

@@ -38,7 +38,7 @@ import com.android.settings.core.TogglePreferenceController;
* Controls the toggle that determines whether to show silent notifications when screen locked. * Controls the toggle that determines whether to show silent notifications when screen locked.
* Toggle for: Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS * Toggle for: Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS
*/ */
public class LockScreenNotificationHideSilentToggleController extends TogglePreferenceController public class LockScreenNotificationShowSilentController extends TogglePreferenceController
implements LifecycleEventObserver { implements LifecycleEventObserver {
private static final int ON = 1; private static final int ON = 1;
@@ -56,7 +56,7 @@ public class LockScreenNotificationHideSilentToggleController extends TogglePref
} }
}; };
public LockScreenNotificationHideSilentToggleController(@NonNull Context context, public LockScreenNotificationShowSilentController(@NonNull Context context,
@NonNull String preferenceKey) { @NonNull String preferenceKey) {
super(context, preferenceKey); super(context, preferenceKey);
mContentResolver = context.getContentResolver(); mContentResolver = context.getContentResolver();
@@ -89,13 +89,13 @@ public class LockScreenNotificationHideSilentToggleController extends TogglePref
@Override @Override
public void updateState(@NonNull Preference preference) { public void updateState(@NonNull Preference preference) {
super.updateState(preference); super.updateState(preference);
setChecked(hideSilentNotificationsWhenLocked()); setChecked(showSilentNotificationsWhenLocked());
preference.setVisible(isAvailable()); preference.setVisible(isAvailable());
} }
private boolean hideSilentNotificationsWhenLocked() { private boolean showSilentNotificationsWhenLocked() {
return Settings.Secure.getInt(mContext.getContentResolver(), return Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, OFF) == OFF; Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, OFF) == ON;
} }
@Override @Override
@@ -116,13 +116,13 @@ public class LockScreenNotificationHideSilentToggleController extends TogglePref
@Override @Override
public boolean isChecked() { public boolean isChecked() {
return hideSilentNotificationsWhenLocked(); return showSilentNotificationsWhenLocked();
} }
@Override @Override
public boolean setChecked(boolean isChecked) { public boolean setChecked(boolean isChecked) {
return Settings.Secure.putInt(mContext.getContentResolver(), return Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, (isChecked ? OFF : ON)); Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, (isChecked ? ON : OFF));
} }
@Override @Override

View File

@@ -27,7 +27,6 @@ import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.provider.Settings; import android.provider.Settings;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -62,13 +61,8 @@ public class MinimalismPreferenceController
Settings.Secure.getUriFor(LOCK_SCREEN_SHOW_NOTIFICATIONS); Settings.Secure.getUriFor(LOCK_SCREEN_SHOW_NOTIFICATIONS);
@Nullable private LayoutPreference mPreference; @Nullable private LayoutPreference mPreference;
@Nullable private TextView mDescView;
private Map<Integer, LinearLayout> mButtons = new HashMap<>(); private Map<Integer, LinearLayout> mButtons = new HashMap<>();
private Map<Integer, IllustrationPreference> mIllustrations = new HashMap<>(); private Map<Integer, IllustrationPreference> mIllustrations = new HashMap<>();
private final Map<Integer, Integer> mDescriptionTexts = Map.ofEntries(
Map.entry(LS_MINIMALISM_OFF, R.string.lock_screen_notifs_full_list_desc),
Map.entry(LS_MINIMALISM_ON, R.string.lock_screen_notifs_compact_desc)
);
private final ContentResolver mContentResolver; private final ContentResolver mContentResolver;
@@ -130,7 +124,6 @@ public class MinimalismPreferenceController
public void displayPreference(@NonNull PreferenceScreen screen) { public void displayPreference(@NonNull PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
mPreference = screen.findPreference(KEY_MINIMALISM_PREFERENCE); mPreference = screen.findPreference(KEY_MINIMALISM_PREFERENCE);
mDescView = mPreference.findViewById(R.id.notif_ls_style_desc);
mButtons = Map.ofEntries( mButtons = Map.ofEntries(
Map.entry(LS_MINIMALISM_OFF, Map.entry(LS_MINIMALISM_OFF,
@@ -165,14 +158,6 @@ public class MinimalismPreferenceController
-> preference.setVisible(currentValue == value)); -> preference.setVisible(currentValue == value));
} }
private void highlightDescription(int value) {
if (mDescView == null) return;
Integer descStringId = mDescriptionTexts.get(value);
if (descStringId != null) {
mDescView.setText(descStringId);
}
}
private int getCurrentMinimalismValue() { private int getCurrentMinimalismValue() {
return Settings.Secure.getInt(mContext.getContentResolver(), return Settings.Secure.getInt(mContext.getContentResolver(),
LOCK_SCREEN_NOTIFICATION_MINIMALISM, LS_MINIMALISM_ON); LOCK_SCREEN_NOTIFICATION_MINIMALISM, LS_MINIMALISM_ON);
@@ -190,7 +175,6 @@ public class MinimalismPreferenceController
int currentValue = getCurrentMinimalismValue(); int currentValue = getCurrentMinimalismValue();
highlightButton(currentValue); highlightButton(currentValue);
highlightIllustration(currentValue); highlightIllustration(currentValue);
highlightDescription(currentValue);
} }
} }
} }

View File

@@ -63,7 +63,7 @@ import java.util.Arrays;
ShadowUtils.class, ShadowUtils.class,
ShadowRestrictedLockUtilsInternal.class, ShadowRestrictedLockUtilsInternal.class,
}) })
public class LockScreenNotificationShowSensitiveToggleControllerTest { public class LockScreenNotificationShowSensitiveControllerTest {
@Mock @Mock
private DevicePolicyManager mDpm; private DevicePolicyManager mDpm;
@@ -79,8 +79,8 @@ public class LockScreenNotificationShowSensitiveToggleControllerTest {
private Context mMockContext; private Context mMockContext;
private Context mContext; private Context mContext;
private LockScreenNotificationShowSensitiveToggleController mController; private LockScreenNotificationShowSensitiveController mController;
private LockScreenNotificationShowSensitiveToggleController mWorkController; private LockScreenNotificationShowSensitiveController mWorkController;
private RestrictedSwitchPreference mPreference; private RestrictedSwitchPreference mPreference;
private RestrictedSwitchPreference mWorkPreference; private RestrictedSwitchPreference mWorkPreference;
@@ -98,9 +98,9 @@ public class LockScreenNotificationShowSensitiveToggleControllerTest {
when(mMockContext.getSystemService(KeyguardManager.class)).thenReturn(mKm); when(mMockContext.getSystemService(KeyguardManager.class)).thenReturn(mKm);
when(mUm.getProfiles(anyInt())).thenReturn(Arrays.asList(new UserInfo(0, "", 0))); when(mUm.getProfiles(anyInt())).thenReturn(Arrays.asList(new UserInfo(0, "", 0)));
mController = new LockScreenNotificationShowSensitiveToggleController( mController = new LockScreenNotificationShowSensitiveController(
mMockContext, mMockContext,
LockScreenNotificationShowSensitiveToggleController.KEY_SHOW_SENSITIVE LockScreenNotificationShowSensitiveController.KEY_SHOW_SENSITIVE
); );
mPreference = new RestrictedSwitchPreference(mContext); mPreference = new RestrictedSwitchPreference(mContext);
mPreference.setKey(mController.getPreferenceKey()); mPreference.setKey(mController.getPreferenceKey());
@@ -110,9 +110,9 @@ public class LockScreenNotificationShowSensitiveToggleControllerTest {
when(mUm.getProfiles(anyInt())).thenReturn(Arrays.asList( when(mUm.getProfiles(anyInt())).thenReturn(Arrays.asList(
new UserInfo(5, "", 0), new UserInfo(5, "", 0),
new UserInfo(10, "", UserInfo.FLAG_MANAGED_PROFILE | UserInfo.FLAG_PROFILE))); new UserInfo(10, "", UserInfo.FLAG_MANAGED_PROFILE | UserInfo.FLAG_PROFILE)));
mWorkController = new LockScreenNotificationShowSensitiveToggleController( mWorkController = new LockScreenNotificationShowSensitiveController(
mMockContext, mMockContext,
LockScreenNotificationShowSensitiveToggleController.KEY_SHOW_SENSITIVE_WORK_PROFILE LockScreenNotificationShowSensitiveController.KEY_SHOW_SENSITIVE_WORK_PROFILE
); );
mWorkPreference = new RestrictedSwitchPreference(mContext); mWorkPreference = new RestrictedSwitchPreference(mContext);
mWorkPreference.setKey(mWorkController.getPreferenceKey()); mWorkPreference.setKey(mWorkController.getPreferenceKey());
@@ -150,12 +150,12 @@ public class LockScreenNotificationShowSensitiveToggleControllerTest {
// reset controllers with no work profile // reset controllers with no work profile
when(mUm.getProfiles(anyInt())).thenReturn(Arrays.asList( when(mUm.getProfiles(anyInt())).thenReturn(Arrays.asList(
new UserInfo(UserHandle.myUserId(), "", 0))); new UserInfo(UserHandle.myUserId(), "", 0)));
mWorkController = new LockScreenNotificationShowSensitiveToggleController( mWorkController = new LockScreenNotificationShowSensitiveController(
mMockContext, mMockContext,
LockScreenNotificationShowSensitiveToggleController.KEY_SHOW_SENSITIVE_WORK_PROFILE LockScreenNotificationShowSensitiveController.KEY_SHOW_SENSITIVE_WORK_PROFILE
); );
mController = new LockScreenNotificationShowSensitiveToggleController(mMockContext, mController = new LockScreenNotificationShowSensitiveController(mMockContext,
LockScreenNotificationShowSensitiveToggleController.KEY_SHOW_SENSITIVE); LockScreenNotificationShowSensitiveController.KEY_SHOW_SENSITIVE);
// should otherwise show // should otherwise show
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true); when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
@@ -271,13 +271,13 @@ public class LockScreenNotificationShowSensitiveToggleControllerTest {
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
0, 0); 0, 0);
assertThat(mController.isChecked()).isTrue(); assertThat(mController.isChecked()).isFalse();
Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.putIntForUser(mContext.getContentResolver(),
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
1, 0); 1, 0);
assertThat(mController.isChecked()).isFalse(); assertThat(mController.isChecked()).isTrue();
} }
@Test @Test
@@ -287,13 +287,13 @@ public class LockScreenNotificationShowSensitiveToggleControllerTest {
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
0, 10); 0, 10);
assertThat(mWorkController.isChecked()).isTrue(); assertThat(mWorkController.isChecked()).isFalse();
Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.putIntForUser(mContext.getContentResolver(),
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
1, 10); 1, 10);
assertThat(mWorkController.isChecked()).isFalse(); assertThat(mWorkController.isChecked()).isTrue();
} }
@Test @Test
@@ -305,7 +305,7 @@ public class LockScreenNotificationShowSensitiveToggleControllerTest {
ShadowRestrictedLockUtilsInternal.setKeyguardDisabledFeatures( ShadowRestrictedLockUtilsInternal.setKeyguardDisabledFeatures(
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS); KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
assertThat(mController.isChecked()).isFalse(); assertThat(mController.isChecked()).isTrue();
} }
@Test @Test
@@ -317,7 +317,7 @@ public class LockScreenNotificationShowSensitiveToggleControllerTest {
mController.setChecked(false); mController.setChecked(false);
assertThat(Settings.Secure.getIntForUser( assertThat(Settings.Secure.getIntForUser(
mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0)) mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0))
.isEqualTo(1); .isEqualTo(0);
} }
@Test @Test
@@ -329,7 +329,7 @@ public class LockScreenNotificationShowSensitiveToggleControllerTest {
mWorkController.setChecked(true); mWorkController.setChecked(true);
assertThat(Settings.Secure.getIntForUser( assertThat(Settings.Secure.getIntForUser(
mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 10)) mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 10))
.isEqualTo(0); .isEqualTo(1);
} }
@Test @Test
@@ -345,10 +345,10 @@ public class LockScreenNotificationShowSensitiveToggleControllerTest {
mWorkController.setChecked(true); mWorkController.setChecked(true);
assertThat(Settings.Secure.getIntForUser( assertThat(Settings.Secure.getIntForUser(
mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 10)) mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 10))
.isEqualTo(0); .isEqualTo(1);
assertThat(Settings.Secure.getIntForUser( assertThat(Settings.Secure.getIntForUser(
mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0)) mContext.getContentResolver(), LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0))
.isEqualTo(0); .isEqualTo(1);
} }
} }