Rename NotificationChannel#setBlockableSystem
Rename the method to setBlockable. Also rename isBlockableSystem in the same way. Fixes: 151311073 Test: atest NotificationChannelTest Change-Id: Ie25f8aed3c22b74d9ad2329863c4ffebbace03f7
This commit is contained in:
@@ -668,7 +668,7 @@ package android.app {
|
|||||||
method public int getUserLockedFields();
|
method public int getUserLockedFields();
|
||||||
method public boolean isDeleted();
|
method public boolean isDeleted();
|
||||||
method public void populateFromXml(org.xmlpull.v1.XmlPullParser);
|
method public void populateFromXml(org.xmlpull.v1.XmlPullParser);
|
||||||
method public void setBlockableSystem(boolean);
|
method public void setBlockable(boolean);
|
||||||
method public org.json.JSONObject toJson() throws org.json.JSONException;
|
method public org.json.JSONObject toJson() throws org.json.JSONException;
|
||||||
method public void writeXml(org.xmlpull.v1.XmlSerializer) throws java.io.IOException;
|
method public void writeXml(org.xmlpull.v1.XmlSerializer) throws java.io.IOException;
|
||||||
field public static final int USER_LOCKED_SOUND = 32; // 0x20
|
field public static final int USER_LOCKED_SOUND = 32; // 0x20
|
||||||
|
|||||||
@@ -425,11 +425,11 @@ package android.app {
|
|||||||
|
|
||||||
public final class NotificationChannel implements android.os.Parcelable {
|
public final class NotificationChannel implements android.os.Parcelable {
|
||||||
method public int getOriginalImportance();
|
method public int getOriginalImportance();
|
||||||
method public boolean isBlockableSystem();
|
method public boolean isBlockable();
|
||||||
method public boolean isImportanceLockedByCriticalDeviceFunction();
|
method public boolean isImportanceLockedByCriticalDeviceFunction();
|
||||||
method public boolean isImportanceLockedByOEM();
|
method public boolean isImportanceLockedByOEM();
|
||||||
method public void lockFields(int);
|
method public void lockFields(int);
|
||||||
method public void setBlockableSystem(boolean);
|
method public void setBlockable(boolean);
|
||||||
method public void setDeleted(boolean);
|
method public void setDeleted(boolean);
|
||||||
method public void setFgServiceShown(boolean);
|
method public void setFgServiceShown(boolean);
|
||||||
method public void setImportanceLockedByCriticalDeviceFunction(boolean);
|
method public void setImportanceLockedByCriticalDeviceFunction(boolean);
|
||||||
|
|||||||
@@ -370,15 +370,18 @@ public final class NotificationChannel implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows users to block notifications sent through this channel, if this channel belongs to
|
* Allows users to block notifications sent through this channel, if this channel belongs to
|
||||||
* a package that is signed with the system signature. If the channel does not belong to a
|
* a package that is signed with the system signature.
|
||||||
* package that is signed with the system signature, this method does nothing.
|
*
|
||||||
* @param blockableSystem if {@code true}, allows users to block notifications on this channel.
|
* If the channel does not belong to a package that is signed with the system signature, this
|
||||||
|
* method does nothing, since such channels are blockable by default and cannot be set to be
|
||||||
|
* unblockable.
|
||||||
|
* @param blockable if {@code true}, allows users to block notifications on this channel.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@TestApi
|
@TestApi
|
||||||
public void setBlockableSystem(boolean blockableSystem) {
|
public void setBlockable(boolean blockable) {
|
||||||
mBlockableSystem = blockableSystem;
|
mBlockableSystem = blockable;
|
||||||
}
|
}
|
||||||
// Modifiable by apps post channel creation
|
// Modifiable by apps post channel creation
|
||||||
|
|
||||||
@@ -749,7 +752,7 @@ public final class NotificationChannel implements Parcelable {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@TestApi
|
@TestApi
|
||||||
public boolean isBlockableSystem() {
|
public boolean isBlockable() {
|
||||||
return mBlockableSystem;
|
return mBlockableSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,7 +876,7 @@ public final class NotificationChannel implements Parcelable {
|
|||||||
setGroup(parser.getAttributeValue(null, ATT_GROUP));
|
setGroup(parser.getAttributeValue(null, ATT_GROUP));
|
||||||
lockFields(safeInt(parser, ATT_USER_LOCKED, 0));
|
lockFields(safeInt(parser, ATT_USER_LOCKED, 0));
|
||||||
setFgServiceShown(safeBool(parser, ATT_FG_SERVICE_SHOWN, false));
|
setFgServiceShown(safeBool(parser, ATT_FG_SERVICE_SHOWN, false));
|
||||||
setBlockableSystem(safeBool(parser, ATT_BLOCKABLE_SYSTEM, false));
|
setBlockable(safeBool(parser, ATT_BLOCKABLE_SYSTEM, false));
|
||||||
setAllowBubbles(safeBool(parser, ATT_ALLOW_BUBBLE, DEFAULT_ALLOW_BUBBLE));
|
setAllowBubbles(safeBool(parser, ATT_ALLOW_BUBBLE, DEFAULT_ALLOW_BUBBLE));
|
||||||
setOriginalImportance(safeInt(parser, ATT_ORIG_IMP, DEFAULT_IMPORTANCE));
|
setOriginalImportance(safeInt(parser, ATT_ORIG_IMP, DEFAULT_IMPORTANCE));
|
||||||
setConversationId(parser.getAttributeValue(null, ATT_PARENT_CHANNEL),
|
setConversationId(parser.getAttributeValue(null, ATT_PARENT_CHANNEL),
|
||||||
@@ -995,8 +998,8 @@ public final class NotificationChannel implements Parcelable {
|
|||||||
if (getGroup() != null) {
|
if (getGroup() != null) {
|
||||||
out.attribute(null, ATT_GROUP, getGroup());
|
out.attribute(null, ATT_GROUP, getGroup());
|
||||||
}
|
}
|
||||||
if (isBlockableSystem()) {
|
if (isBlockable()) {
|
||||||
out.attribute(null, ATT_BLOCKABLE_SYSTEM, Boolean.toString(isBlockableSystem()));
|
out.attribute(null, ATT_BLOCKABLE_SYSTEM, Boolean.toString(isBlockable()));
|
||||||
}
|
}
|
||||||
if (canBubble() != DEFAULT_ALLOW_BUBBLE) {
|
if (canBubble() != DEFAULT_ALLOW_BUBBLE) {
|
||||||
out.attribute(null, ATT_ALLOW_BUBBLE, Boolean.toString(canBubble()));
|
out.attribute(null, ATT_ALLOW_BUBBLE, Boolean.toString(canBubble()));
|
||||||
@@ -1060,7 +1063,7 @@ public final class NotificationChannel implements Parcelable {
|
|||||||
record.put(ATT_SHOW_BADGE, Boolean.toString(canShowBadge()));
|
record.put(ATT_SHOW_BADGE, Boolean.toString(canShowBadge()));
|
||||||
record.put(ATT_DELETED, Boolean.toString(isDeleted()));
|
record.put(ATT_DELETED, Boolean.toString(isDeleted()));
|
||||||
record.put(ATT_GROUP, getGroup());
|
record.put(ATT_GROUP, getGroup());
|
||||||
record.put(ATT_BLOCKABLE_SYSTEM, isBlockableSystem());
|
record.put(ATT_BLOCKABLE_SYSTEM, isBlockable());
|
||||||
record.put(ATT_ALLOW_BUBBLE, canBubble());
|
record.put(ATT_ALLOW_BUBBLE, canBubble());
|
||||||
// TODO: original importance
|
// TODO: original importance
|
||||||
return record;
|
return record;
|
||||||
@@ -1162,7 +1165,7 @@ public final class NotificationChannel implements Parcelable {
|
|||||||
&& mVibrationEnabled == that.mVibrationEnabled
|
&& mVibrationEnabled == that.mVibrationEnabled
|
||||||
&& mShowBadge == that.mShowBadge
|
&& mShowBadge == that.mShowBadge
|
||||||
&& isDeleted() == that.isDeleted()
|
&& isDeleted() == that.isDeleted()
|
||||||
&& isBlockableSystem() == that.isBlockableSystem()
|
&& isBlockable() == that.isBlockable()
|
||||||
&& mAllowBubbles == that.mAllowBubbles
|
&& mAllowBubbles == that.mAllowBubbles
|
||||||
&& Objects.equals(getId(), that.getId())
|
&& Objects.equals(getId(), that.getId())
|
||||||
&& Objects.equals(getName(), that.getName())
|
&& Objects.equals(getName(), that.getName())
|
||||||
@@ -1186,7 +1189,7 @@ public final class NotificationChannel implements Parcelable {
|
|||||||
getLockscreenVisibility(), getSound(), mLights, getLightColor(),
|
getLockscreenVisibility(), getSound(), mLights, getLightColor(),
|
||||||
getUserLockedFields(),
|
getUserLockedFields(),
|
||||||
isFgServiceShown(), mVibrationEnabled, mShowBadge, isDeleted(), getGroup(),
|
isFgServiceShown(), mVibrationEnabled, mShowBadge, isDeleted(), getGroup(),
|
||||||
getAudioAttributes(), isBlockableSystem(), mAllowBubbles,
|
getAudioAttributes(), isBlockable(), mAllowBubbles,
|
||||||
mImportanceLockedByOEM, mImportanceLockedDefaultApp, mOriginalImportance,
|
mImportanceLockedByOEM, mImportanceLockedDefaultApp, mOriginalImportance,
|
||||||
mParentId, mConversationId, mDemoted, mImportantConvo);
|
mParentId, mConversationId, mDemoted, mImportantConvo);
|
||||||
result = 31 * result + Arrays.hashCode(mVibration);
|
result = 31 * result + Arrays.hashCode(mVibration);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class SystemNotificationChannels {
|
|||||||
VIRTUAL_KEYBOARD,
|
VIRTUAL_KEYBOARD,
|
||||||
context.getString(R.string.notification_channel_virtual_keyboard),
|
context.getString(R.string.notification_channel_virtual_keyboard),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
keyboard.setBlockableSystem(true);
|
keyboard.setBlockable(true);
|
||||||
channelsList.add(keyboard);
|
channelsList.add(keyboard);
|
||||||
|
|
||||||
final NotificationChannel physicalKeyboardChannel = new NotificationChannel(
|
final NotificationChannel physicalKeyboardChannel = new NotificationChannel(
|
||||||
@@ -74,7 +74,7 @@ public class SystemNotificationChannels {
|
|||||||
NotificationManager.IMPORTANCE_DEFAULT);
|
NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
physicalKeyboardChannel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI,
|
physicalKeyboardChannel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI,
|
||||||
Notification.AUDIO_ATTRIBUTES_DEFAULT);
|
Notification.AUDIO_ATTRIBUTES_DEFAULT);
|
||||||
physicalKeyboardChannel.setBlockableSystem(true);
|
physicalKeyboardChannel.setBlockable(true);
|
||||||
channelsList.add(physicalKeyboardChannel);
|
channelsList.add(physicalKeyboardChannel);
|
||||||
|
|
||||||
final NotificationChannel security = new NotificationChannel(
|
final NotificationChannel security = new NotificationChannel(
|
||||||
@@ -87,7 +87,7 @@ public class SystemNotificationChannels {
|
|||||||
CAR_MODE,
|
CAR_MODE,
|
||||||
context.getString(R.string.notification_channel_car_mode),
|
context.getString(R.string.notification_channel_car_mode),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
car.setBlockableSystem(true);
|
car.setBlockable(true);
|
||||||
channelsList.add(car);
|
channelsList.add(car);
|
||||||
|
|
||||||
channelsList.add(newAccountChannel(context));
|
channelsList.add(newAccountChannel(context));
|
||||||
@@ -96,14 +96,14 @@ public class SystemNotificationChannels {
|
|||||||
DEVELOPER,
|
DEVELOPER,
|
||||||
context.getString(R.string.notification_channel_developer),
|
context.getString(R.string.notification_channel_developer),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
developer.setBlockableSystem(true);
|
developer.setBlockable(true);
|
||||||
channelsList.add(developer);
|
channelsList.add(developer);
|
||||||
|
|
||||||
final NotificationChannel developerImportant = new NotificationChannel(
|
final NotificationChannel developerImportant = new NotificationChannel(
|
||||||
DEVELOPER_IMPORTANT,
|
DEVELOPER_IMPORTANT,
|
||||||
context.getString(R.string.notification_channel_developer_important),
|
context.getString(R.string.notification_channel_developer_important),
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
developer.setBlockableSystem(true);
|
developer.setBlockable(true);
|
||||||
channelsList.add(developerImportant);
|
channelsList.add(developerImportant);
|
||||||
|
|
||||||
final NotificationChannel updates = new NotificationChannel(
|
final NotificationChannel updates = new NotificationChannel(
|
||||||
@@ -116,21 +116,21 @@ public class SystemNotificationChannels {
|
|||||||
NETWORK_STATUS,
|
NETWORK_STATUS,
|
||||||
context.getString(R.string.notification_channel_network_status),
|
context.getString(R.string.notification_channel_network_status),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
network.setBlockableSystem(true);
|
network.setBlockable(true);
|
||||||
channelsList.add(network);
|
channelsList.add(network);
|
||||||
|
|
||||||
final NotificationChannel networkAlertsChannel = new NotificationChannel(
|
final NotificationChannel networkAlertsChannel = new NotificationChannel(
|
||||||
NETWORK_ALERTS,
|
NETWORK_ALERTS,
|
||||||
context.getString(R.string.notification_channel_network_alerts),
|
context.getString(R.string.notification_channel_network_alerts),
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
networkAlertsChannel.setBlockableSystem(true);
|
networkAlertsChannel.setBlockable(true);
|
||||||
channelsList.add(networkAlertsChannel);
|
channelsList.add(networkAlertsChannel);
|
||||||
|
|
||||||
final NotificationChannel networkAvailable = new NotificationChannel(
|
final NotificationChannel networkAvailable = new NotificationChannel(
|
||||||
NETWORK_AVAILABLE,
|
NETWORK_AVAILABLE,
|
||||||
context.getString(R.string.notification_channel_network_available),
|
context.getString(R.string.notification_channel_network_available),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
networkAvailable.setBlockableSystem(true);
|
networkAvailable.setBlockable(true);
|
||||||
channelsList.add(networkAvailable);
|
channelsList.add(networkAvailable);
|
||||||
|
|
||||||
final NotificationChannel vpn = new NotificationChannel(
|
final NotificationChannel vpn = new NotificationChannel(
|
||||||
@@ -167,7 +167,7 @@ public class SystemNotificationChannels {
|
|||||||
FOREGROUND_SERVICE,
|
FOREGROUND_SERVICE,
|
||||||
context.getString(R.string.notification_channel_foreground_service),
|
context.getString(R.string.notification_channel_foreground_service),
|
||||||
NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
foregroundChannel.setBlockableSystem(true);
|
foregroundChannel.setBlockable(true);
|
||||||
channelsList.add(foregroundChannel);
|
channelsList.add(foregroundChannel);
|
||||||
|
|
||||||
NotificationChannel heavyWeightChannel = new NotificationChannel(
|
NotificationChannel heavyWeightChannel = new NotificationChannel(
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ class PackageInstalledNotificationUtils {
|
|||||||
channel.enableVibration(false);
|
channel.enableVibration(false);
|
||||||
channel.setSound(null, null);
|
channel.setSound(null, null);
|
||||||
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||||
channel.setBlockableSystem(true);
|
channel.setBlockable(true);
|
||||||
|
|
||||||
mNotificationManager.createNotificationChannel(channel);
|
mNotificationManager.createNotificationChannel(channel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -527,7 +527,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
if (!isNonblockable && mEntry != null && mEntry.mIsSystemNotification != null) {
|
if (!isNonblockable && mEntry != null && mEntry.mIsSystemNotification != null) {
|
||||||
if (mEntry.mIsSystemNotification) {
|
if (mEntry.mIsSystemNotification) {
|
||||||
if (mEntry.getChannel() != null
|
if (mEntry.getChannel() != null
|
||||||
&& !mEntry.getChannel().isBlockableSystem()) {
|
&& !mEntry.getChannel().isBlockable()) {
|
||||||
isNonblockable = true;
|
isNonblockable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class NotificationChannels extends SystemUI {
|
|||||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||||
.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
|
.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
|
||||||
.build());
|
.build());
|
||||||
batteryChannel.setBlockableSystem(true);
|
batteryChannel.setBlockable(true);
|
||||||
|
|
||||||
final NotificationChannel alerts = new NotificationChannel(
|
final NotificationChannel alerts = new NotificationChannel(
|
||||||
ALERTS,
|
ALERTS,
|
||||||
@@ -118,7 +118,7 @@ public class NotificationChannels extends SystemUI {
|
|||||||
|
|
||||||
screenshotChannel.setSound(null, // silent
|
screenshotChannel.setSound(null, // silent
|
||||||
new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).build());
|
new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).build());
|
||||||
screenshotChannel.setBlockableSystem(true);
|
screenshotChannel.setBlockable(true);
|
||||||
|
|
||||||
if (legacySS != null) {
|
if (legacySS != null) {
|
||||||
// Respect any user modified fields from the old channel.
|
// Respect any user modified fields from the old channel.
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ public class NotificationTestHelper {
|
|||||||
notification.getChannelId(),
|
notification.getChannelId(),
|
||||||
notification.getChannelId(),
|
notification.getChannelId(),
|
||||||
importance);
|
importance);
|
||||||
channel.setBlockableSystem(true);
|
channel.setBlockable(true);
|
||||||
|
|
||||||
NotificationEntry entry = new NotificationEntryBuilder()
|
NotificationEntry entry = new NotificationEntryBuilder()
|
||||||
.setPkg(pkg)
|
.setPkg(pkg)
|
||||||
|
|||||||
@@ -725,8 +725,8 @@ public class PreferencesHelper implements RankingConfig {
|
|||||||
existing.setDescription(channel.getDescription());
|
existing.setDescription(channel.getDescription());
|
||||||
needsPolicyFileChange = true;
|
needsPolicyFileChange = true;
|
||||||
}
|
}
|
||||||
if (channel.isBlockableSystem() != existing.isBlockableSystem()) {
|
if (channel.isBlockable() != existing.isBlockable()) {
|
||||||
existing.setBlockableSystem(channel.isBlockableSystem());
|
existing.setBlockable(channel.isBlockable());
|
||||||
needsPolicyFileChange = true;
|
needsPolicyFileChange = true;
|
||||||
}
|
}
|
||||||
if (channel.getGroup() != null && existing.getGroup() == null) {
|
if (channel.getGroup() != null && existing.getGroup() == null) {
|
||||||
|
|||||||
@@ -828,7 +828,7 @@ public class BatterySaverStateMachine {
|
|||||||
NotificationChannel channel = new NotificationChannel(
|
NotificationChannel channel = new NotificationChannel(
|
||||||
channelId, mContext.getText(nameId), NotificationManager.IMPORTANCE_DEFAULT);
|
channelId, mContext.getText(nameId), NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
channel.setSound(null, null);
|
channel.setSound(null, null);
|
||||||
channel.setBlockableSystem(true);
|
channel.setBlockable(true);
|
||||||
manager.createNotificationChannel(channel);
|
manager.createNotificationChannel(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ class AlertWindowNotification {
|
|||||||
channel = new NotificationChannel(mNotificationTag, nameChannel, IMPORTANCE_MIN);
|
channel = new NotificationChannel(mNotificationTag, nameChannel, IMPORTANCE_MIN);
|
||||||
channel.enableLights(false);
|
channel.enableLights(false);
|
||||||
channel.enableVibration(false);
|
channel.enableVibration(false);
|
||||||
channel.setBlockableSystem(true);
|
channel.setBlockable(true);
|
||||||
channel.setGroup(sChannelGroup.getId());
|
channel.setGroup(sChannelGroup.getId());
|
||||||
channel.setBypassDnd(true);
|
channel.setBypassDnd(true);
|
||||||
mNotificationManager.createNotificationChannel(channel);
|
mNotificationManager.createNotificationChannel(channel);
|
||||||
|
|||||||
Reference in New Issue
Block a user