From 9f36db1f4ceab527a4297b813eba59f91e2a6976 Mon Sep 17 00:00:00 2001 From: Alison Cichowlas Date: Wed, 31 May 2017 17:01:24 -0400 Subject: [PATCH] Disallow buzz/beep/disturb changes for notifications with locked importance. If mAppRow.lockedImportance (which comes from the whitelist config_nonBlockableNotificationPackages), don't allow sound, vibration, or override dnd to be changed. Bug: 38480212 Test: manually verified for now Change-Id: I04aa7f15f2480472ec6ee487472098e81ab3d99f --- .../ChannelNotificationSettings.java | 17 +++++++++++------ .../notification/NotificationSettingsBase.java | 3 +++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java index 8c43a3fd748..15c80d7cb63 100644 --- a/src/com/android/settings/notification/ChannelNotificationSettings.java +++ b/src/com/android/settings/notification/ChannelNotificationSettings.java @@ -175,6 +175,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { private void setupVibrate() { mVibrate = (RestrictedSwitchPreference) findPreference(KEY_VIBRATE); mVibrate.setDisabledByAdmin(mSuspendedAppsAdmin); + mVibrate.setEnabled(!(mAppRow.lockedImportance || mVibrate.isDisabledByAdmin())); mVibrate.setChecked(mChannel.shouldVibrate()); mVibrate.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override @@ -191,6 +192,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { private void setupRingtone() { mRingtone = (NotificationSoundPreference) findPreference(KEY_RINGTONE); mRingtone.setRingtone(mChannel.getSound()); + mRingtone.setEnabled(!(mAppRow.lockedImportance)); mRingtone.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { @@ -246,12 +248,15 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { channelArgs.putBoolean(AppHeader.EXTRA_HIDE_INFO_BUTTON, true); channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg); channelArgs.putString(Settings.EXTRA_CHANNEL_ID, mChannel.getId()); - Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(), - ChannelImportanceSettings.class.getName(), - channelArgs, null, R.string.notification_importance_title, null, - false, getMetricsCategory()); - mImportance.setIntent(channelIntent); - mImportance.setEnabled(mSuspendedAppsAdmin == null); + mImportance.setEnabled(mSuspendedAppsAdmin == null && !mAppRow.lockedImportance); + // Set up intent to show importance selection only if this setting is enabled. + if (mImportance.isEnabled()) { + Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(), + ChannelImportanceSettings.class.getName(), + channelArgs, null, R.string.notification_importance_title, null, + false, getMetricsCategory()); + mImportance.setIntent(channelIntent); + } mImportance.setSummary(getImportanceSummary(mChannel.getImportance())); } diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java index bfa93557a62..4f715ca1f05 100644 --- a/src/com/android/settings/notification/NotificationSettingsBase.java +++ b/src/com/android/settings/notification/NotificationSettingsBase.java @@ -293,6 +293,8 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen private void setupImportanceToggle() { mImportanceToggle = (RestrictedSwitchPreference) findPreference(KEY_ALLOW_SOUND); mImportanceToggle.setDisabledByAdmin(mSuspendedAppsAdmin); + mImportanceToggle.setEnabled(!(mAppRow.lockedImportance + || mImportanceToggle.isDisabledByAdmin())); mImportanceToggle.setChecked(mChannel.getImportance() >= IMPORTANCE_DEFAULT || mChannel.getImportance() == IMPORTANCE_UNSPECIFIED); mImportanceToggle.setOnPreferenceChangeListener( @@ -313,6 +315,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen protected void setupPriorityPref(boolean priority) { mPriority = (RestrictedSwitchPreference) findPreference(KEY_BYPASS_DND); mPriority.setDisabledByAdmin(mSuspendedAppsAdmin); + mPriority.setEnabled(!(mAppRow.lockedImportance || mPriority.isDisabledByAdmin())); mPriority.setChecked(priority); mPriority.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override