diff options
author | Hall Liu <hallliu@google.com> | 2020-03-12 12:55:50 -0700 |
---|---|---|
committer | Hall Liu <hallliu@google.com> | 2020-03-13 13:50:48 -0700 |
commit | 9866aa8b70fa83907d5a89b8a88e4b19200b259b (patch) | |
tree | 9d363765e98a856f7b5f64f70107a957b22323fd | |
parent | 28ab493385d3b3875bfe0fd4b24633b633f85bb8 (diff) |
Rename NotificationChannel#setBlockableSystem
Rename the method to setBlockable. Also rename isBlockableSystem in the
same way.
Fixes: 151311073
Test: atest NotificationChannelTest
Change-Id: Ie25f8aed3c22b74d9ad2329863c4ffebbace03f7
11 files changed, 36 insertions, 33 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index c102e661d400..792c045e17ed 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -668,7 +668,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 diff --git a/api/test-current.txt b/api/test-current.txt index a5f1f68b82ac..faadb1f20f65 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -425,11 +425,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); diff --git a/core/java/android/app/NotificationChannel.java b/core/java/android/app/NotificationChannel.java index 94b237cd1f5b..d1d67f0d81d8 100644 --- a/core/java/android/app/NotificationChannel.java +++ b/core/java/android/app/NotificationChannel.java @@ -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); diff --git a/core/java/com/android/internal/notification/SystemNotificationChannels.java b/core/java/com/android/internal/notification/SystemNotificationChannels.java index 1296ddc01c35..41be5c493d95 100644 --- a/core/java/com/android/internal/notification/SystemNotificationChannels.java +++ b/core/java/com/android/internal/notification/SystemNotificationChannels.java @@ -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( diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstalledNotificationUtils.java b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstalledNotificationUtils.java index 2ebbefaef85b..caf971800ad2 100644 --- a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstalledNotificationUtils.java +++ b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstalledNotificationUtils.java @@ -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); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 9a4e789a2e03..0f1f1827ce69 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -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; } } diff --git a/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java b/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java index 8c60747dffc7..90b95ea9562e 100644 --- a/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java +++ b/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java @@ -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. diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java index 5a89fc44f970..0a8540f0806f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java @@ -362,7 +362,7 @@ public class NotificationTestHelper { notification.getChannelId(), notification.getChannelId(), importance); - channel.setBlockableSystem(true); + channel.setBlockable(true); NotificationEntry entry = new NotificationEntryBuilder() .setPkg(pkg) diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java index 6fd09bb2fa8c..32cfaf614ab9 100644 --- a/services/core/java/com/android/server/notification/PreferencesHelper.java +++ b/services/core/java/com/android/server/notification/PreferencesHelper.java @@ -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) { diff --git a/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java b/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java index 42aaec9ce23a..2256b623fce0 100644 --- a/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java +++ b/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java @@ -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); } diff --git a/services/core/java/com/android/server/wm/AlertWindowNotification.java b/services/core/java/com/android/server/wm/AlertWindowNotification.java index 0de94d936f24..7b511ec20541 100644 --- a/services/core/java/com/android/server/wm/AlertWindowNotification.java +++ b/services/core/java/com/android/server/wm/AlertWindowNotification.java @@ -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); |