From f48249a3b8bd5f26a80208570bbecb7b564c269f Mon Sep 17 00:00:00 2001 From: Chris Wren Date: Thu, 28 Aug 2014 17:52:39 -0400 Subject: [PATCH] Don't allow users to set redaction on an insecure device. Bug: 17106788 Change-Id: I05f8f4d920158fe99186fb8b879278d6780b8722 --- .../notification/AppNotificationSettings.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java index 60757482120..efa43cd033c 100644 --- a/src/com/android/settings/notification/AppNotificationSettings.java +++ b/src/com/android/settings/notification/AppNotificationSettings.java @@ -36,6 +36,7 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import com.android.internal.widget.LockPatternUtils; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.notification.NotificationAppList.AppRow; @@ -134,6 +135,11 @@ public class AppNotificationSettings extends SettingsPreferenceFragment { mPriority = (SwitchPreference) findPreference(KEY_PRIORITY); mSensitive = (SwitchPreference) findPreference(KEY_SENSITIVE); + final boolean secure = new LockPatternUtils(getActivity()).isSecure(); + if (!secure) { + getPreferenceScreen().removePreference(mSensitive); + } + mAppRow = NotificationAppList.loadAppRow(pm, info, mBackend); if (intent.hasExtra(EXTRA_HAS_SETTINGS_INTENT)) { // use settings intent from extra @@ -149,7 +155,9 @@ public class AppNotificationSettings extends SettingsPreferenceFragment { mBlock.setChecked(mAppRow.banned); mPriority.setChecked(mAppRow.priority); - mSensitive.setChecked(mAppRow.sensitive); + if (mSensitive != null) { + mSensitive.setChecked(mAppRow.sensitive); + } mBlock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override @@ -167,13 +175,15 @@ public class AppNotificationSettings extends SettingsPreferenceFragment { } }); - mSensitive.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - final boolean sensitive = (Boolean) newValue; - return mBackend.setSensitive(pkg, uid, sensitive); - } - }); + if (mSensitive != null) { + mSensitive.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + final boolean sensitive = (Boolean) newValue; + return mBackend.setSensitive(pkg, uid, sensitive); + } + }); + } } private void toastAndFinish() {