Also some apis have changed.
Test: manual, modify settings and check policy xml.
Change-Id: I967cb1fb30d8d400bdc0f3aa92fa07b4c87ddcf5
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;
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;
}
};
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;
List<String> 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));
}
}
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);
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;
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;
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);
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;
}
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;
}
}
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;
}
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;
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);
}
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);
}
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);
}
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;
return sINM.getImportance(pkg, uid);
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
- return NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
+ return NotificationManager.IMPORTANCE_UNSPECIFIED;
}
}
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);
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,
// 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
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,
return true;
}
});
- updateDependents(banned ? Ranking.IMPORTANCE_NONE : importance);
+ updateDependents(banned ? NotificationManager.IMPORTANCE_NONE : importance);
}
}
}
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 {
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,
}
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);
}
if (mChannel != null) {
mChannel.setLockscreenVisibility(sensitive);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_VISIBILITY);
mBackend.updateChannel(mPkg, mUid, mChannel);
} else {
mBackend.setVisibilityOverride(mPkgInfo.packageName, mUid, sensitive);
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) {
}
protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
- if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
+ if (importance == NotificationManager.IMPORTANCE_UNSPECIFIED) {
return true;
}
return importance >= minImportanceVisible;