diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java index e7f15e56a65..fd7a750111f 100644 --- a/src/com/android/settings/notification/AppNotificationSettings.java +++ b/src/com/android/settings/notification/AppNotificationSettings.java @@ -90,7 +90,8 @@ public class AppNotificationSettings extends NotificationSettingsBase { rows.put(mAppRow.pkg, mAppRow); collectConfigActivities(rows); - setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance, mAppRow.banned); + setupImportancePrefs(mAppRow.cantBlock, mAppRow.cantSilence, + mAppRow.appImportance, mAppRow.banned); setupPriorityPref(mAppRow.appBypassDnd); setupVisOverridePref(mAppRow.appVisOverride); updateDependents(mAppRow.appImportance); diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java index 1229b9e3cec..f8c67880ebe 100644 --- a/src/com/android/settings/notification/NotificationBackend.java +++ b/src/com/android/settings/notification/NotificationBackend.java @@ -59,14 +59,14 @@ public class NotificationBackend { public AppRow loadAppRow(Context context, PackageManager pm, PackageInfo app) { final AppRow row = loadAppRow(context, pm, app.applicationInfo); - row.systemApp = Utils.isSystemPackage(context.getResources(), pm, app); + row.cantBlock = Utils.isSystemPackage(context.getResources(), pm, app); final String[] nonBlockablePkgs = context.getResources().getStringArray( com.android.internal.R.array.config_nonBlockableNotificationPackages); if (nonBlockablePkgs != null) { int N = nonBlockablePkgs.length; for (int i = 0; i < N; i++) { if (app.packageName.equals(nonBlockablePkgs[i])) { - row.systemApp = true; + row.cantBlock = row.cantSilence = true; } } } @@ -153,7 +153,8 @@ public class NotificationBackend { public Intent settingsIntent; public boolean banned; public boolean first; // first app in section - public boolean systemApp; + public boolean cantBlock; + public boolean cantSilence; public int appImportance; public boolean appBypassDnd; public int appVisOverride; diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java index 3469cc0a261..0e637a79839 100644 --- a/src/com/android/settings/notification/NotificationSettingsBase.java +++ b/src/com/android/settings/notification/NotificationSettingsBase.java @@ -154,8 +154,9 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen } } - protected void setupImportancePrefs(boolean notBlockable, int importance, boolean banned) { - if (mShowSlider) { + protected void setupImportancePrefs(boolean notBlockable, boolean notSilenceable, + int importance, boolean banned) { + if (mShowSlider && !notSilenceable) { setVisible(mBlock, false); setVisible(mSilent, false); mImportance.setDisabledByAdmin(mSuspendedAppsAdmin); @@ -192,18 +193,22 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen } }); } - mSilent.setChecked(importance == Ranking.IMPORTANCE_LOW); - mSilent.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - final boolean silenced = (Boolean) newValue; - final int importance = - silenced ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_UNSPECIFIED; - mBackend.setImportance(mPkgInfo.packageName, mUid, importance); - updateDependents(importance); - return true; - } - }); + if (notSilenceable) { + setVisible(mSilent, false); + } else { + mSilent.setChecked(importance == Ranking.IMPORTANCE_LOW); + mSilent.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + final boolean silenced = (Boolean) newValue; + final int importance = + silenced ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_UNSPECIFIED; + mBackend.setImportance(mPkgInfo.packageName, mUid, importance); + updateDependents(importance); + return true; + } + }); + } updateDependents(banned ? Ranking.IMPORTANCE_NONE : importance); } }