diff --git a/src/com/android/settings/applications/AppStateNotificationBridge.java b/src/com/android/settings/applications/AppStateNotificationBridge.java index b9363512e56..5fff175be03 100644 --- a/src/com/android/settings/applications/AppStateNotificationBridge.java +++ b/src/com/android/settings/applications/AppStateNotificationBridge.java @@ -16,6 +16,7 @@ package com.android.settings.applications; import android.app.Notification; +import android.app.NotificationManager; import android.content.Context; import android.content.pm.PackageManager; import android.os.UserHandle; @@ -92,8 +93,8 @@ public class AppStateNotificationBridge extends AppStateBaseBridge { return false; } AppRow row = (AppRow) info.extraInfo; - return row.appImportance > NotificationListenerService.Ranking.IMPORTANCE_NONE - && row.appImportance < NotificationListenerService.Ranking.IMPORTANCE_DEFAULT; + return row.appImportance > NotificationManager.IMPORTANCE_NONE + && row.appImportance < NotificationManager.IMPORTANCE_DEFAULT; } }; diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index f23d2146ae7..652b8ecaab0 100755 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -22,6 +22,7 @@ import android.app.ActivityManager; import android.app.AlertDialog; import android.app.LoaderManager.LoaderCallbacks; import android.app.Notification; +import android.app.NotificationManager; import android.app.admin.DevicePolicyManager; import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; @@ -1099,15 +1100,15 @@ public class InstalledAppDetails extends AppInfoBase List summaryAttributes = new ArrayList<>(); StringBuffer summary = new StringBuffer(); if (showSlider) { - if (appRow.appImportance != Ranking.IMPORTANCE_UNSPECIFIED) { + if (appRow.appImportance != NotificationManager.IMPORTANCE_UNSPECIFIED) { summaryAttributes.add(context.getString( R.string.notification_summary_level, appRow.appImportance)); } } else { if (appRow.banned) { summaryAttributes.add(context.getString(R.string.notifications_disabled)); - } else if (appRow.appImportance > Ranking.IMPORTANCE_NONE - && appRow.appImportance < Ranking.IMPORTANCE_DEFAULT) { + } else if (appRow.appImportance > NotificationManager.IMPORTANCE_NONE + && appRow.appImportance < NotificationManager.IMPORTANCE_DEFAULT) { summaryAttributes.add(context.getString(R.string.notifications_silenced)); } } diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java index fb36c54e2a9..8e47af5148c 100644 --- a/src/com/android/settings/notification/AppNotificationSettings.java +++ b/src/com/android/settings/notification/AppNotificationSettings.java @@ -102,7 +102,7 @@ public class AppNotificationSettings extends NotificationSettingsBase { mChannelList = mBackend.getChannels(mPkg, mUid).getList(); setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance, mAppRow.banned, - NotificationManager.IMPORTANCE_MAX); + NotificationManager.IMPORTANCE_HIGH); setupPriorityPref(mAppRow.appBypassDnd); setupVisOverridePref(mAppRow.appVisOverride); diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java index a405de6fcd4..7f384a5fb45 100644 --- a/src/com/android/settings/notification/ChannelNotificationSettings.java +++ b/src/com/android/settings/notification/ChannelNotificationSettings.java @@ -17,6 +17,7 @@ package com.android.settings.notification; import android.app.Activity; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Intent; import android.net.Uri; @@ -24,6 +25,7 @@ import android.os.Bundle; import android.provider.Settings; import android.service.notification.NotificationListenerService.Ranking; import android.support.v7.preference.Preference; +import android.view.View; import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.settings.AppHeader; @@ -94,7 +96,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { setupVibrate(); setupRingtone(); mMaxImportance = mAppRow.appImportance == NotificationManager.IMPORTANCE_UNSPECIFIED - ? NotificationManager.IMPORTANCE_MAX : mAppRow.appImportance; + ? NotificationManager.IMPORTANCE_HIGH : mAppRow.appImportance; setupImportancePrefs(false, mChannel.getImportance(), mChannel.getImportance() == NotificationManager.IMPORTANCE_NONE, mMaxImportance); @@ -141,6 +143,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean lights = (Boolean) newValue; mChannel.setLights(lights); + mChannel.lockFields(NotificationChannel.USER_LOCKED_LIGHTS); mBackend.updateChannel(mPkg, mUid, mChannel); return true; } @@ -155,6 +158,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean vibrate = (Boolean) newValue; mChannel.setVibration(vibrate); + mChannel.lockFields(NotificationChannel.USER_LOCKED_VIBRATION); mBackend.updateChannel(mPkg, mUid, mChannel); return true; } @@ -162,13 +166,14 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { } private void setupRingtone() { - mRingtone.setRingtone(mChannel.getDefaultRingtone()); + mRingtone.setRingtone(mChannel.getRingtone()); mRingtone.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Uri ringtone = Uri.parse((String) newValue); mRingtone.setRingtone(ringtone); - mChannel.setDefaultRingtone(ringtone); + mChannel.setRingtone(ringtone); + mChannel.lockFields(NotificationChannel.USER_LOCKED_RINGTONE); mBackend.updateChannel(mPkg, mUid, mChannel); return false; } diff --git a/src/com/android/settings/notification/ImportanceSeekBarPreference.java b/src/com/android/settings/notification/ImportanceSeekBarPreference.java index 0617df94409..568dc1cdd12 100644 --- a/src/com/android/settings/notification/ImportanceSeekBarPreference.java +++ b/src/com/android/settings/notification/ImportanceSeekBarPreference.java @@ -19,6 +19,7 @@ package com.android.settings.notification; import com.android.settings.R; import com.android.settings.SeekBarPreference; +import android.app.NotificationManager; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; @@ -119,12 +120,10 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements private void applyAuto(ImageView autoButton) { mAutoOn = !mAutoOn; if (!mAutoOn) { - setProgress(NotificationListenerService.Ranking.IMPORTANCE_DEFAULT); - mCallback.onImportanceChanged( - NotificationListenerService.Ranking.IMPORTANCE_DEFAULT, true); + setProgress(NotificationManager.IMPORTANCE_DEFAULT); + mCallback.onImportanceChanged(NotificationManager.IMPORTANCE_DEFAULT, true); } else { - mCallback.onImportanceChanged( - NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED, true); + mCallback.onImportanceChanged(NotificationManager.IMPORTANCE_UNSPECIFIED, true); } applyAutoUi(autoButton); } @@ -140,9 +139,8 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements mSeekBar.setAlpha(alpha); if (mAutoOn) { - setProgress(NotificationListenerService.Ranking.IMPORTANCE_DEFAULT); - mSummary = getProgressSummary( - NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED); + setProgress(NotificationManager.IMPORTANCE_DEFAULT); + mSummary = getProgressSummary(NotificationManager.IMPORTANCE_UNSPECIFIED); } mSummaryTextView.setText(mSummary); } @@ -168,18 +166,17 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements private String getProgressSummary(int progress) { switch (progress) { - case NotificationListenerService.Ranking.IMPORTANCE_NONE: + case NotificationManager.IMPORTANCE_NONE: return getContext().getString(R.string.notification_importance_blocked); - case NotificationListenerService.Ranking.IMPORTANCE_MIN: + case NotificationManager.IMPORTANCE_MIN: return getContext().getString(R.string.notification_importance_min); - case NotificationListenerService.Ranking.IMPORTANCE_LOW: + case NotificationManager.IMPORTANCE_LOW: return getContext().getString(R.string.notification_importance_low); - case NotificationListenerService.Ranking.IMPORTANCE_DEFAULT: + case NotificationManager.IMPORTANCE_DEFAULT: return getContext().getString(R.string.notification_importance_default); - case NotificationListenerService.Ranking.IMPORTANCE_HIGH: + case NotificationManager.IMPORTANCE_HIGH: + case NotificationManager.IMPORTANCE_MAX: return getContext().getString(R.string.notification_importance_high); - case NotificationListenerService.Ranking.IMPORTANCE_MAX: - return getContext().getString(R.string.notification_importance_max); default: return getContext().getString(R.string.notification_importance_unspecified); } diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java index 32eacc6b74e..5d69203def2 100644 --- a/src/com/android/settings/notification/NotificationBackend.java +++ b/src/com/android/settings/notification/NotificationBackend.java @@ -18,6 +18,7 @@ package com.android.settings.notification; import android.app.INotificationManager; import android.app.Notification; import android.app.NotificationChannel; +import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; @@ -139,7 +140,7 @@ public class NotificationBackend { return sINM.getImportance(pkg, uid); } catch (Exception e) { Log.w(TAG, "Error calling NoMan", e); - return NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED; + return NotificationManager.IMPORTANCE_UNSPECIFIED; } } diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java index 0925833a580..5d6f5982a73 100644 --- a/src/com/android/settings/notification/NotificationSettingsBase.java +++ b/src/com/android/settings/notification/NotificationSettingsBase.java @@ -178,16 +178,18 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen setVisible(mSilent, false); mImportance.setDisabledByAdmin(mSuspendedAppsAdmin); mImportance.setMinimumProgress( - notBlockable ? Ranking.IMPORTANCE_MIN : Ranking.IMPORTANCE_NONE); + notBlockable ? NotificationManager.IMPORTANCE_MIN + : NotificationManager.IMPORTANCE_NONE); mImportance.setMax(maxImportance); mImportance.setProgress(Math.min(importance, maxImportance)); - mImportance.setAutoOn(importance == Ranking.IMPORTANCE_UNSPECIFIED); + mImportance.setAutoOn(importance == NotificationManager.IMPORTANCE_UNSPECIFIED); mImportance.setCallback(new ImportanceSeekBarPreference.Callback() { @Override public void onImportanceChanged(int progress, boolean fromUser) { if (fromUser) { if (mChannel != null) { mChannel.setImportance(progress); + mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); mBackend.updateChannel(mPkg, mUid, mChannel); } else { mBackend.setImportance(mPkg, mUid, progress); @@ -209,10 +211,11 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen Object newValue) { final boolean blocked = (Boolean) newValue; final int importance = blocked - ? Ranking.IMPORTANCE_NONE - : Ranking.IMPORTANCE_UNSPECIFIED; + ? NotificationManager.IMPORTANCE_NONE + : NotificationManager.IMPORTANCE_UNSPECIFIED; if (mChannel != null) { mChannel.setImportance(importance); + mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); mBackend.updateChannel(mPkg, mUid, mChannel); } else { mBackend.setImportance(mPkgInfo.packageName, mUid, @@ -226,9 +229,10 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen // app silenced; cannot un-silence a channel if (maxImportance == NotificationManager.IMPORTANCE_LOW) { setVisible(mSilent, false); - updateDependents(banned ? Ranking.IMPORTANCE_NONE : Ranking.IMPORTANCE_LOW); + updateDependents(banned ? NotificationManager.IMPORTANCE_NONE + : NotificationManager.IMPORTANCE_LOW); } else { - mSilent.setChecked(importance == Ranking.IMPORTANCE_LOW); + mSilent.setChecked(importance == NotificationManager.IMPORTANCE_LOW); mSilent.setOnPreferenceChangeListener( new Preference.OnPreferenceChangeListener() { @Override @@ -236,10 +240,11 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen Object newValue) { final boolean silenced = (Boolean) newValue; final int importance = silenced - ? Ranking.IMPORTANCE_LOW - : Ranking.IMPORTANCE_UNSPECIFIED; + ? NotificationManager.IMPORTANCE_LOW + : NotificationManager.IMPORTANCE_UNSPECIFIED; if (mChannel != null) { mChannel.setImportance(importance); + mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); mBackend.updateChannel(mPkg, mUid, mChannel); } else { mBackend.setImportance(mPkgInfo.packageName, mUid, @@ -249,7 +254,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen return true; } }); - updateDependents(banned ? Ranking.IMPORTANCE_NONE : importance); + updateDependents(banned ? NotificationManager.IMPORTANCE_NONE : importance); } } } @@ -263,6 +268,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen final boolean bypassZenMode = (Boolean) newValue; if (mChannel != null) { mChannel.setBypassDnd(bypassZenMode); + mChannel.lockFields(NotificationChannel.USER_LOCKED_PRIORITY); mBackend.updateChannel(mPkg, mUid, mChannel); return true; } else { @@ -280,7 +286,8 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen if (getLockscreenNotificationsEnabled() && getLockscreenAllowPrivateNotifications()) { final String summaryShowEntry = getString(R.string.lock_screen_notifications_summary_show); - final String summaryShowEntryValue = Integer.toString(Ranking.VISIBILITY_NO_OVERRIDE); + final String summaryShowEntryValue = + Integer.toString(NotificationManager.VISIBILITY_NO_OVERRIDE); entries.add(summaryShowEntry); values.add(summaryShowEntryValue); setRestrictedIfNotificationFeaturesDisabled(summaryShowEntry, summaryShowEntryValue, @@ -306,7 +313,8 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen } mVisibilityOverride.setSummary("%s"); - mVisibilityOverride.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + mVisibilityOverride.setOnPreferenceChangeListener( + new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { int sensitive = Integer.parseInt((String) newValue); @@ -315,6 +323,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen } if (mChannel != null) { mChannel.setLockscreenVisibility(sensitive); + mChannel.lockFields(NotificationChannel.USER_LOCKED_VISIBILITY); mBackend.updateChannel(mPkg, mUid, mChannel); } else { mBackend.setVisibilityOverride(mPkgInfo.packageName, mUid, sensitive); @@ -367,14 +376,15 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen protected void updateDependents(int importance) { if (getPreferenceScreen().findPreference(mBlock.getKey()) != null) { - setVisible(mSilent, checkCanBeVisible(Ranking.IMPORTANCE_MIN, importance)); - mSilent.setChecked(importance == Ranking.IMPORTANCE_LOW); + setVisible(mSilent, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN, importance)); + mSilent.setChecked(importance == NotificationManager.IMPORTANCE_LOW); } - setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_DEFAULT, importance) - || (checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance) + setVisible(mPriority, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT, importance) + || (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW, importance) && mDndVisualEffectsSuppressed)); setVisible(mVisibilityOverride, - checkCanBeVisible(Ranking.IMPORTANCE_MIN, importance) && isLockScreenSecure()); + checkCanBeVisible(NotificationManager.IMPORTANCE_MIN, importance) + && isLockScreenSecure()); } protected void setVisible(Preference p, boolean visible) { @@ -388,7 +398,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen } protected boolean checkCanBeVisible(int minImportanceVisible, int importance) { - if (importance == Ranking.IMPORTANCE_UNSPECIFIED) { + if (importance == NotificationManager.IMPORTANCE_UNSPECIFIED) { return true; } return importance >= minImportanceVisible;