Remove "don't show" option from work notifications settings
Option to not show notifications is still available for device-wide locks screen notification settings. Also s/On lock screen/When work profile is locked/ for work notifications since it applies not only to lock screen but to notification shade as well. Bug: 64829587 Test: make RunSettingsRoboTests Change-Id: Ie3ec461f4c8887a5a49cd92b5350ea683f701027
This commit is contained in:
@@ -7170,6 +7170,9 @@
|
|||||||
<!-- 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 lock screen</string>
|
<string name="lock_screen_notifications_title">On lock screen</string>
|
||||||
|
|
||||||
|
<!-- Configure Notifications: Title for the option controlling notifications for work profile. [CHAR LIMIT=30] -->
|
||||||
|
<string name="locked_work_profile_notification_title">When work profile is locked</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
|
||||||
[CHAR LIMIT=50] -->
|
[CHAR LIMIT=50] -->
|
||||||
@@ -7200,10 +7203,6 @@
|
|||||||
[CHAR LIMIT=50] -->
|
[CHAR LIMIT=50] -->
|
||||||
<string name="lock_screen_notifications_summary_hide_profile">Hide sensitive work 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
|
|
||||||
[CHAR LIMIT=50] -->
|
|
||||||
<string name="lock_screen_notifications_summary_disable_profile">Don\u2019t show work notifications at all</string>
|
|
||||||
|
|
||||||
<!-- 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>
|
||||||
|
|
||||||
|
@@ -89,10 +89,9 @@
|
|||||||
|
|
||||||
<com.android.settings.RestrictedListPreference
|
<com.android.settings.RestrictedListPreference
|
||||||
android:key="lock_screen_notifications_profile"
|
android:key="lock_screen_notifications_profile"
|
||||||
android:title="@string/lock_screen_notifications_title"
|
android:title="@string/locked_work_profile_notification_title"
|
||||||
android:summary="@string/summary_placeholder"
|
android:summary="@string/summary_placeholder"
|
||||||
android:order="24"/>
|
android:order="24"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
<com.android.settings.RestrictedListPreference
|
<com.android.settings.RestrictedListPreference
|
||||||
android:key="security_setting_lock_screen_notif_work"
|
android:key="security_setting_lock_screen_notif_work"
|
||||||
android:title="@string/lock_screen_notifications_title"
|
android:title="@string/locked_work_profile_notification_title"
|
||||||
android:summary="@string/summary_placeholder" />
|
android:summary="@string/summary_placeholder" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings.notification;
|
|||||||
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
|
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
|
||||||
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
|
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
@@ -59,7 +60,7 @@ public class LockScreenNotificationPreferenceController extends AbstractPreferen
|
|||||||
private RestrictedListPreference mLockscreen;
|
private RestrictedListPreference mLockscreen;
|
||||||
private RestrictedListPreference mLockscreenProfile;
|
private RestrictedListPreference mLockscreenProfile;
|
||||||
|
|
||||||
private final int mProfileChallengeUserId;
|
private final int mProfileUserId;
|
||||||
private final boolean mSecure;
|
private final boolean mSecure;
|
||||||
private final boolean mSecureProfile;
|
private final boolean mSecureProfile;
|
||||||
|
|
||||||
@@ -78,29 +79,24 @@ public class LockScreenNotificationPreferenceController extends AbstractPreferen
|
|||||||
mWorkSettingCategoryKey = workSettingCategoryKey;
|
mWorkSettingCategoryKey = workSettingCategoryKey;
|
||||||
mWorkSettingKey = workSettingKey;
|
mWorkSettingKey = workSettingKey;
|
||||||
|
|
||||||
mProfileChallengeUserId = Utils.getManagedProfileId(
|
mProfileUserId = Utils.getManagedProfileId(UserManager.get(context), UserHandle.myUserId());
|
||||||
UserManager.get(context), UserHandle.myUserId());
|
|
||||||
final LockPatternUtils utils = FeatureFactory.getFactory(context)
|
final LockPatternUtils utils = FeatureFactory.getFactory(context)
|
||||||
.getSecurityFeatureProvider()
|
.getSecurityFeatureProvider()
|
||||||
.getLockPatternUtils(context);
|
.getLockPatternUtils(context);
|
||||||
mSecure = utils.isSecure(UserHandle.myUserId());
|
mSecure = utils.isSecure(UserHandle.myUserId());
|
||||||
mSecureProfile = (mProfileChallengeUserId != UserHandle.USER_NULL)
|
mSecureProfile = (mProfileUserId != UserHandle.USER_NULL) && utils.isSecure(mProfileUserId);
|
||||||
&& (utils.isSecure(mProfileChallengeUserId)
|
|
||||||
|| (!utils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId) && mSecure));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mLockscreen =
|
mLockscreen = (RestrictedListPreference) screen.findPreference(mSettingKey);
|
||||||
(RestrictedListPreference) screen.findPreference(mSettingKey);
|
|
||||||
if (mLockscreen == null) {
|
if (mLockscreen == null) {
|
||||||
Log.i(TAG, "Preference not found: " + mSettingKey);
|
Log.i(TAG, "Preference not found: " + mSettingKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mProfileChallengeUserId != UserHandle.USER_NULL) {
|
if (mProfileUserId != UserHandle.USER_NULL) {
|
||||||
mLockscreenProfile = (RestrictedListPreference) screen.findPreference(
|
mLockscreenProfile = (RestrictedListPreference) screen.findPreference(mWorkSettingKey);
|
||||||
mWorkSettingKey);
|
|
||||||
} else {
|
} else {
|
||||||
setVisible(screen, mWorkSettingKey, false /* visible */);
|
setVisible(screen, mWorkSettingKey, false /* visible */);
|
||||||
setVisible(screen, mWorkSettingCategoryKey, false /* visible */);
|
setVisible(screen, mWorkSettingCategoryKey, false /* visible */);
|
||||||
@@ -178,9 +174,6 @@ public class LockScreenNotificationPreferenceController extends AbstractPreferen
|
|||||||
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.add(mContext.getString(R.string.lock_screen_notifications_summary_disable_profile));
|
|
||||||
values.add(Integer.toString(R.string.lock_screen_notifications_summary_disable_profile));
|
|
||||||
|
|
||||||
mLockscreenProfile.setEntries(entries.toArray(new CharSequence[entries.size()]));
|
mLockscreenProfile.setEntries(entries.toArray(new CharSequence[entries.size()]));
|
||||||
mLockscreenProfile.setEntryValues(values.toArray(new CharSequence[values.size()]));
|
mLockscreenProfile.setEntryValues(values.toArray(new CharSequence[values.size()]));
|
||||||
updateLockscreenNotificationsForProfile();
|
updateLockscreenNotificationsForProfile();
|
||||||
@@ -221,23 +214,17 @@ public class LockScreenNotificationPreferenceController extends AbstractPreferen
|
|||||||
final String key = preference.getKey();
|
final String key = preference.getKey();
|
||||||
if (TextUtils.equals(mWorkSettingKey, key)) {
|
if (TextUtils.equals(mWorkSettingKey, key)) {
|
||||||
if (Utils.startQuietModeDialogIfNecessary(mContext, UserManager.get(mContext),
|
if (Utils.startQuietModeDialogIfNecessary(mContext, UserManager.get(mContext),
|
||||||
mProfileChallengeUserId)) {
|
mProfileUserId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int val = Integer.parseInt((String) newValue);
|
final int val = Integer.parseInt((String) newValue);
|
||||||
if (val == mLockscreenSelectedValueProfile) {
|
if (val == mLockscreenSelectedValueProfile) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final boolean enabled =
|
final boolean show = val == R.string.lock_screen_notifications_summary_show_profile;
|
||||||
val != R.string.lock_screen_notifications_summary_disable_profile;
|
|
||||||
final boolean show =
|
|
||||||
val == R.string.lock_screen_notifications_summary_show_profile;
|
|
||||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||||
show ? 1 : 0, mProfileChallengeUserId);
|
show ? 1 : 0, mProfileUserId);
|
||||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
|
||||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
|
||||||
enabled ? 1 : 0, mProfileChallengeUserId);
|
|
||||||
mLockscreenSelectedValueProfile = val;
|
mLockscreenSelectedValueProfile = val;
|
||||||
return true;
|
return true;
|
||||||
} else if (TextUtils.equals(mSettingKey, key)) {
|
} else if (TextUtils.equals(mSettingKey, key)) {
|
||||||
@@ -245,8 +232,7 @@ public class LockScreenNotificationPreferenceController extends AbstractPreferen
|
|||||||
if (val == mLockscreenSelectedValue) {
|
if (val == mLockscreenSelectedValue) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final boolean enabled =
|
final boolean enabled = val != R.string.lock_screen_notifications_summary_disable;
|
||||||
val != R.string.lock_screen_notifications_summary_disable;
|
|
||||||
final boolean show = val == R.string.lock_screen_notifications_summary_show;
|
final boolean show = val == R.string.lock_screen_notifications_summary_show;
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0);
|
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0);
|
||||||
@@ -268,10 +254,10 @@ public class LockScreenNotificationPreferenceController extends AbstractPreferen
|
|||||||
new RestrictedListPreference.RestrictedItem(entry, entryValue, admin);
|
new RestrictedListPreference.RestrictedItem(entry, entryValue, admin);
|
||||||
mLockscreen.addRestrictedItem(item);
|
mLockscreen.addRestrictedItem(item);
|
||||||
}
|
}
|
||||||
if (mProfileChallengeUserId != UserHandle.USER_NULL) {
|
if (mProfileUserId != UserHandle.USER_NULL) {
|
||||||
RestrictedLockUtils.EnforcedAdmin profileAdmin =
|
RestrictedLockUtils.EnforcedAdmin profileAdmin =
|
||||||
RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
|
RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
|
||||||
mContext, keyguardNotificationFeatures, mProfileChallengeUserId);
|
mContext, keyguardNotificationFeatures, mProfileUserId);
|
||||||
if (profileAdmin != null && mLockscreenProfile != null) {
|
if (profileAdmin != null && mLockscreenProfile != null) {
|
||||||
RestrictedListPreference.RestrictedItem item =
|
RestrictedListPreference.RestrictedItem item =
|
||||||
new RestrictedListPreference.RestrictedItem(
|
new RestrictedListPreference.RestrictedItem(
|
||||||
@@ -282,13 +268,13 @@ public class LockScreenNotificationPreferenceController extends AbstractPreferen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getSummaryResource(Context context) {
|
public static int getSummaryResource(Context context) {
|
||||||
final boolean enabled = getLockscreenNotificationsEnabled(context, UserHandle.myUserId());
|
final boolean enabled = getLockscreenNotificationsEnabled(context);
|
||||||
final boolean secure = FeatureFactory.getFactory(context)
|
final boolean secure = FeatureFactory.getFactory(context)
|
||||||
.getSecurityFeatureProvider()
|
.getSecurityFeatureProvider()
|
||||||
.getLockPatternUtils(context)
|
.getLockPatternUtils(context)
|
||||||
.isSecure(UserHandle.myUserId());
|
.isSecure(UserHandle.myUserId());
|
||||||
final boolean allowPrivate = !secure
|
final boolean allowPrivate = !secure
|
||||||
|| getLockscreenAllowPrivateNotifications(context, UserHandle.myUserId());
|
|| getAllowPrivateNotifications(context, UserHandle.myUserId());
|
||||||
return !enabled ? R.string.lock_screen_notifications_summary_disable :
|
return !enabled ? R.string.lock_screen_notifications_summary_disable :
|
||||||
allowPrivate ? R.string.lock_screen_notifications_summary_show :
|
allowPrivate ? R.string.lock_screen_notifications_summary_show :
|
||||||
R.string.lock_screen_notifications_summary_hide;
|
R.string.lock_screen_notifications_summary_hide;
|
||||||
@@ -303,30 +289,34 @@ public class LockScreenNotificationPreferenceController extends AbstractPreferen
|
|||||||
mLockscreen.setValue(Integer.toString(mLockscreenSelectedValue));
|
mLockscreen.setValue(Integer.toString(mLockscreenSelectedValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean adminAllowsUnredactedNotifications(int userId) {
|
||||||
|
final int dpmFlags = mContext.getSystemService(DevicePolicyManager.class)
|
||||||
|
.getKeyguardDisabledFeatures(null/* admin */, userId);
|
||||||
|
return (dpmFlags & KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateLockscreenNotificationsForProfile() {
|
private void updateLockscreenNotificationsForProfile() {
|
||||||
if (mProfileChallengeUserId == UserHandle.USER_NULL) {
|
if (mProfileUserId == UserHandle.USER_NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mLockscreenProfile == null) {
|
if (mLockscreenProfile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean enabled = getLockscreenNotificationsEnabled(mContext,mProfileChallengeUserId);
|
final boolean allowPrivate = adminAllowsUnredactedNotifications(mProfileUserId) &&
|
||||||
final boolean allowPrivate = !mSecureProfile
|
(!mSecureProfile || getAllowPrivateNotifications(mContext, mProfileUserId));
|
||||||
|| getLockscreenAllowPrivateNotifications(mContext, mProfileChallengeUserId);
|
|
||||||
mLockscreenProfile.setSummary("%s");
|
mLockscreenProfile.setSummary("%s");
|
||||||
mLockscreenSelectedValueProfile = !enabled
|
mLockscreenSelectedValueProfile = allowPrivate
|
||||||
? R.string.lock_screen_notifications_summary_disable_profile
|
? R.string.lock_screen_notifications_summary_show_profile
|
||||||
: (allowPrivate ? R.string.lock_screen_notifications_summary_show_profile
|
: R.string.lock_screen_notifications_summary_hide_profile;
|
||||||
: R.string.lock_screen_notifications_summary_hide_profile);
|
|
||||||
mLockscreenProfile.setValue(Integer.toString(mLockscreenSelectedValueProfile));
|
mLockscreenProfile.setValue(Integer.toString(mLockscreenSelectedValueProfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean getLockscreenNotificationsEnabled(Context context, int userId) {
|
private static boolean getLockscreenNotificationsEnabled(Context context) {
|
||||||
return Settings.Secure.getIntForUser(context.getContentResolver(),
|
return Settings.Secure.getInt(context.getContentResolver(),
|
||||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, userId) != 0;
|
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean getLockscreenAllowPrivateNotifications(Context context, int userId) {
|
private static boolean getAllowPrivateNotifications(Context context, int userId) {
|
||||||
return Settings.Secure.getIntForUser(context.getContentResolver(),
|
return Settings.Secure.getIntForUser(context.getContentResolver(),
|
||||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, userId) != 0;
|
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, userId) != 0;
|
||||||
}
|
}
|
||||||
@@ -356,7 +346,7 @@ public class LockScreenNotificationPreferenceController extends AbstractPreferen
|
|||||||
super.onChange(selfChange, uri);
|
super.onChange(selfChange, uri);
|
||||||
if (LOCK_SCREEN_PRIVATE_URI.equals(uri) || LOCK_SCREEN_SHOW_URI.equals(uri)) {
|
if (LOCK_SCREEN_PRIVATE_URI.equals(uri) || LOCK_SCREEN_SHOW_URI.equals(uri)) {
|
||||||
updateLockscreenNotifications();
|
updateLockscreenNotifications();
|
||||||
if (mProfileChallengeUserId != UserHandle.USER_NULL) {
|
if (mProfileUserId != UserHandle.USER_NULL) {
|
||||||
updateLockscreenNotificationsForProfile();
|
updateLockscreenNotificationsForProfile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -119,12 +119,12 @@ public class RedactionInterstitial extends SettingsActivity {
|
|||||||
getContext(), getActivity().getIntent().getExtras());
|
getContext(), getActivity().getIntent().getExtras());
|
||||||
if (UserManager.get(getContext()).isManagedProfile(mUserId)) {
|
if (UserManager.get(getContext()).isManagedProfile(mUserId)) {
|
||||||
((TextView) view.findViewById(R.id.message))
|
((TextView) view.findViewById(R.id.message))
|
||||||
.setText(R.string.lock_screen_notifications_interstitial_message_profile);
|
.setText(R.string.lock_screen_notifications_interstitial_message_profile);
|
||||||
mShowAllButton.setText(R.string.lock_screen_notifications_summary_show_profile);
|
mShowAllButton.setText(R.string.lock_screen_notifications_summary_show_profile);
|
||||||
mRedactSensitiveButton
|
mRedactSensitiveButton
|
||||||
.setText(R.string.lock_screen_notifications_summary_hide_profile);
|
.setText(R.string.lock_screen_notifications_summary_hide_profile);
|
||||||
((RadioButton) view.findViewById(R.id.hide_all))
|
|
||||||
.setText(R.string.lock_screen_notifications_summary_disable_profile);
|
((RadioButton) view.findViewById(R.id.hide_all)).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Button button = (Button) view.findViewById(R.id.redaction_done_button);
|
final Button button = (Button) view.findViewById(R.id.redaction_done_button);
|
||||||
@@ -164,10 +164,11 @@ public class RedactionInterstitial extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadFromSettings() {
|
private void loadFromSettings() {
|
||||||
final boolean enabled = Settings.Secure.getIntForUser(getContentResolver(),
|
final boolean managed = UserManager.get(getContext()).isManagedProfile(mUserId);
|
||||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, mUserId) != 0;
|
final boolean enabled = !managed || Settings.Secure.getIntForUser(getContentResolver(),
|
||||||
|
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, mUserId) != 0;
|
||||||
final boolean show = Settings.Secure.getIntForUser(getContentResolver(),
|
final boolean show = Settings.Secure.getIntForUser(getContentResolver(),
|
||||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mUserId) != 0;
|
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mUserId) != 0;
|
||||||
|
|
||||||
int checkedButtonId = R.id.hide_all;
|
int checkedButtonId = R.id.hide_all;
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
Reference in New Issue
Block a user