Merge "Rename NotificationChannel#setBlockableSystem" into rvc-dev

This commit is contained in:
Hall Liu
2020-03-19 21:06:53 +00:00
committed by Android (Google) Code Review
11 changed files with 36 additions and 33 deletions

View File

@@ -665,7 +665,7 @@ package android.app {
method public int getUserLockedFields();
method public boolean isDeleted();
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 void writeXml(org.xmlpull.v1.XmlSerializer) throws java.io.IOException;
field public static final int USER_LOCKED_SOUND = 32; // 0x20

View File

@@ -426,11 +426,11 @@ package android.app {
public final class NotificationChannel implements android.os.Parcelable {
method public int getOriginalImportance();
method public boolean isBlockableSystem();
method public boolean isBlockable();
method public boolean isImportanceLockedByCriticalDeviceFunction();
method public boolean isImportanceLockedByOEM();
method public void lockFields(int);
method public void setBlockableSystem(boolean);
method public void setBlockable(boolean);
method public void setDeleted(boolean);
method public void setFgServiceShown(boolean);
method public void setImportanceLockedByCriticalDeviceFunction(boolean);

View File

@@ -370,15 +370,18 @@ public final class NotificationChannel implements Parcelable {
/**
* 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
* 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.
* a package that is signed with the system signature.
*
* 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
*/
@SystemApi
@TestApi
public void setBlockableSystem(boolean blockableSystem) {
mBlockableSystem = blockableSystem;
public void setBlockable(boolean blockable) {
mBlockableSystem = blockable;
}
// Modifiable by apps post channel creation
@@ -749,7 +752,7 @@ public final class NotificationChannel implements Parcelable {
* @hide
*/
@TestApi
public boolean isBlockableSystem() {
public boolean isBlockable() {
return mBlockableSystem;
}
@@ -873,7 +876,7 @@ public final class NotificationChannel implements Parcelable {
setGroup(parser.getAttributeValue(null, ATT_GROUP));
lockFields(safeInt(parser, ATT_USER_LOCKED, 0));
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));
setOriginalImportance(safeInt(parser, ATT_ORIG_IMP, DEFAULT_IMPORTANCE));
setConversationId(parser.getAttributeValue(null, ATT_PARENT_CHANNEL),
@@ -995,8 +998,8 @@ public final class NotificationChannel implements Parcelable {
if (getGroup() != null) {
out.attribute(null, ATT_GROUP, getGroup());
}
if (isBlockableSystem()) {
out.attribute(null, ATT_BLOCKABLE_SYSTEM, Boolean.toString(isBlockableSystem()));
if (isBlockable()) {
out.attribute(null, ATT_BLOCKABLE_SYSTEM, Boolean.toString(isBlockable()));
}
if (canBubble() != DEFAULT_ALLOW_BUBBLE) {
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_DELETED, Boolean.toString(isDeleted()));
record.put(ATT_GROUP, getGroup());
record.put(ATT_BLOCKABLE_SYSTEM, isBlockableSystem());
record.put(ATT_BLOCKABLE_SYSTEM, isBlockable());
record.put(ATT_ALLOW_BUBBLE, canBubble());
// TODO: original importance
return record;
@@ -1162,7 +1165,7 @@ public final class NotificationChannel implements Parcelable {
&& mVibrationEnabled == that.mVibrationEnabled
&& mShowBadge == that.mShowBadge
&& isDeleted() == that.isDeleted()
&& isBlockableSystem() == that.isBlockableSystem()
&& isBlockable() == that.isBlockable()
&& mAllowBubbles == that.mAllowBubbles
&& Objects.equals(getId(), that.getId())
&& Objects.equals(getName(), that.getName())
@@ -1186,7 +1189,7 @@ public final class NotificationChannel implements Parcelable {
getLockscreenVisibility(), getSound(), mLights, getLightColor(),
getUserLockedFields(),
isFgServiceShown(), mVibrationEnabled, mShowBadge, isDeleted(), getGroup(),
getAudioAttributes(), isBlockableSystem(), mAllowBubbles,
getAudioAttributes(), isBlockable(), mAllowBubbles,
mImportanceLockedByOEM, mImportanceLockedDefaultApp, mOriginalImportance,
mParentId, mConversationId, mDemoted, mImportantConvo);
result = 31 * result + Arrays.hashCode(mVibration);

View File

@@ -65,7 +65,7 @@ public class SystemNotificationChannels {
VIRTUAL_KEYBOARD,
context.getString(R.string.notification_channel_virtual_keyboard),
NotificationManager.IMPORTANCE_LOW);
keyboard.setBlockableSystem(true);
keyboard.setBlockable(true);
channelsList.add(keyboard);
final NotificationChannel physicalKeyboardChannel = new NotificationChannel(
@@ -74,7 +74,7 @@ public class SystemNotificationChannels {
NotificationManager.IMPORTANCE_DEFAULT);
physicalKeyboardChannel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI,
Notification.AUDIO_ATTRIBUTES_DEFAULT);
physicalKeyboardChannel.setBlockableSystem(true);
physicalKeyboardChannel.setBlockable(true);
channelsList.add(physicalKeyboardChannel);
final NotificationChannel security = new NotificationChannel(
@@ -87,7 +87,7 @@ public class SystemNotificationChannels {
CAR_MODE,
context.getString(R.string.notification_channel_car_mode),
NotificationManager.IMPORTANCE_LOW);
car.setBlockableSystem(true);
car.setBlockable(true);
channelsList.add(car);
channelsList.add(newAccountChannel(context));
@@ -96,14 +96,14 @@ public class SystemNotificationChannels {
DEVELOPER,
context.getString(R.string.notification_channel_developer),
NotificationManager.IMPORTANCE_LOW);
developer.setBlockableSystem(true);
developer.setBlockable(true);
channelsList.add(developer);
final NotificationChannel developerImportant = new NotificationChannel(
DEVELOPER_IMPORTANT,
context.getString(R.string.notification_channel_developer_important),
NotificationManager.IMPORTANCE_HIGH);
developer.setBlockableSystem(true);
developer.setBlockable(true);
channelsList.add(developerImportant);
final NotificationChannel updates = new NotificationChannel(
@@ -116,21 +116,21 @@ public class SystemNotificationChannels {
NETWORK_STATUS,
context.getString(R.string.notification_channel_network_status),
NotificationManager.IMPORTANCE_LOW);
network.setBlockableSystem(true);
network.setBlockable(true);
channelsList.add(network);
final NotificationChannel networkAlertsChannel = new NotificationChannel(
NETWORK_ALERTS,
context.getString(R.string.notification_channel_network_alerts),
NotificationManager.IMPORTANCE_HIGH);
networkAlertsChannel.setBlockableSystem(true);
networkAlertsChannel.setBlockable(true);
channelsList.add(networkAlertsChannel);
final NotificationChannel networkAvailable = new NotificationChannel(
NETWORK_AVAILABLE,
context.getString(R.string.notification_channel_network_available),
NotificationManager.IMPORTANCE_LOW);
networkAvailable.setBlockableSystem(true);
networkAvailable.setBlockable(true);
channelsList.add(networkAvailable);
final NotificationChannel vpn = new NotificationChannel(
@@ -167,7 +167,7 @@ public class SystemNotificationChannels {
FOREGROUND_SERVICE,
context.getString(R.string.notification_channel_foreground_service),
NotificationManager.IMPORTANCE_LOW);
foregroundChannel.setBlockableSystem(true);
foregroundChannel.setBlockable(true);
channelsList.add(foregroundChannel);
NotificationChannel heavyWeightChannel = new NotificationChannel(

View File

@@ -219,7 +219,7 @@ class PackageInstalledNotificationUtils {
channel.enableVibration(false);
channel.setSound(null, null);
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
channel.setBlockableSystem(true);
channel.setBlockable(true);
mNotificationManager.createNotificationChannel(channel);
}

View File

@@ -527,7 +527,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
if (!isNonblockable && mEntry != null && mEntry.mIsSystemNotification != null) {
if (mEntry.mIsSystemNotification) {
if (mEntry.getChannel() != null
&& !mEntry.getChannel().isBlockableSystem()) {
&& !mEntry.getChannel().isBlockable()) {
isNonblockable = true;
}
}

View File

@@ -53,7 +53,7 @@ public class NotificationChannels extends SystemUI {
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
.build());
batteryChannel.setBlockableSystem(true);
batteryChannel.setBlockable(true);
final NotificationChannel alerts = new NotificationChannel(
ALERTS,
@@ -118,7 +118,7 @@ public class NotificationChannels extends SystemUI {
screenshotChannel.setSound(null, // silent
new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).build());
screenshotChannel.setBlockableSystem(true);
screenshotChannel.setBlockable(true);
if (legacySS != null) {
// Respect any user modified fields from the old channel.

View File

@@ -372,7 +372,7 @@ public class NotificationTestHelper {
notification.getChannelId(),
notification.getChannelId(),
importance);
channel.setBlockableSystem(true);
channel.setBlockable(true);
NotificationEntry entry = new NotificationEntryBuilder()
.setPkg(pkg)

View File

@@ -725,8 +725,8 @@ public class PreferencesHelper implements RankingConfig {
existing.setDescription(channel.getDescription());
needsPolicyFileChange = true;
}
if (channel.isBlockableSystem() != existing.isBlockableSystem()) {
existing.setBlockableSystem(channel.isBlockableSystem());
if (channel.isBlockable() != existing.isBlockable()) {
existing.setBlockable(channel.isBlockable());
needsPolicyFileChange = true;
}
if (channel.getGroup() != null && existing.getGroup() == null) {

View File

@@ -828,7 +828,7 @@ public class BatterySaverStateMachine {
NotificationChannel channel = new NotificationChannel(
channelId, mContext.getText(nameId), NotificationManager.IMPORTANCE_DEFAULT);
channel.setSound(null, null);
channel.setBlockableSystem(true);
channel.setBlockable(true);
manager.createNotificationChannel(channel);
}

View File

@@ -160,7 +160,7 @@ class AlertWindowNotification {
channel = new NotificationChannel(mNotificationTag, nameChannel, IMPORTANCE_MIN);
channel.enableLights(false);
channel.enableVibration(false);
channel.setBlockableSystem(true);
channel.setBlockable(true);
channel.setGroup(sChannelGroup.getId());
channel.setBypassDnd(true);
mNotificationManager.createNotificationChannel(channel);