summaryrefslogtreecommitdiff
path: root/core/java/android/app/NotificationChannel.java
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2019-01-11 10:38:08 -0500
committerJulia Reynolds <juliacr@google.com>2019-01-14 14:03:55 +0000
commit413ba846b377a1dd094ce94fa6ded78104de8b51 (patch)
tree7355c732139116c21ddf91bb91dae26accd81809 /core/java/android/app/NotificationChannel.java
parent5ca575ae71493aedfbd93da032692ad5a1d50f27 (diff)
Don't allow importance updates for oem locked channels
Test: atest, make sure missed call notifications are no longer demoted by aosp notification assistant Change-Id: I80728bae67501d64359e0dac02dca928c34a7e95 Fixes: 122657004
Diffstat (limited to 'core/java/android/app/NotificationChannel.java')
-rw-r--r--core/java/android/app/NotificationChannel.java64
1 files changed, 44 insertions, 20 deletions
diff --git a/core/java/android/app/NotificationChannel.java b/core/java/android/app/NotificationChannel.java
index 41ceaafa56a9..950e9aa939f8 100644
--- a/core/java/android/app/NotificationChannel.java
+++ b/core/java/android/app/NotificationChannel.java
@@ -19,6 +19,7 @@ import static android.app.NotificationManager.IMPORTANCE_HIGH;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.app.NotificationManager.Importance;
import android.content.ContentResolver;
@@ -168,6 +169,7 @@ public final class NotificationChannel implements Parcelable {
// If this is a blockable system notification channel.
private boolean mBlockableSystem = false;
private boolean mAllowAppOverlay = DEFAULT_ALLOW_APP_OVERLAY;
+ private boolean mImportanceLockedByOEM;
/**
* Creates a notification channel.
@@ -230,6 +232,7 @@ public final class NotificationChannel implements Parcelable {
mLightColor = in.readInt();
mBlockableSystem = in.readBoolean();
mAllowAppOverlay = in.readBoolean();
+ mImportanceLockedByOEM = in.readBoolean();
}
@Override
@@ -283,6 +286,7 @@ public final class NotificationChannel implements Parcelable {
dest.writeInt(mLightColor);
dest.writeBoolean(mBlockableSystem);
dest.writeBoolean(mAllowAppOverlay);
+ dest.writeBoolean(mImportanceLockedByOEM);
}
/**
@@ -649,6 +653,22 @@ public final class NotificationChannel implements Parcelable {
}
/**
+ * @hide
+ */
+ @TestApi
+ public void setImportanceLockedByOEM(boolean locked) {
+ mImportanceLockedByOEM = locked;
+ }
+
+ /**
+ * @hide
+ */
+ @TestApi
+ public boolean isImportanceLockedByOEM() {
+ return mImportanceLockedByOEM;
+ }
+
+ /**
* Returns whether the user has chosen the importance of this channel, either to affirm the
* initial selection from the app, or changed it to be higher or lower.
* @see #getImportance()
@@ -952,25 +972,26 @@ public final class NotificationChannel implements Parcelable {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
NotificationChannel that = (NotificationChannel) o;
- return getImportance() == that.getImportance() &&
- mBypassDnd == that.mBypassDnd &&
- getLockscreenVisibility() == that.getLockscreenVisibility() &&
- mLights == that.mLights &&
- getLightColor() == that.getLightColor() &&
- getUserLockedFields() == that.getUserLockedFields() &&
- isFgServiceShown() == that.isFgServiceShown() &&
- mVibrationEnabled == that.mVibrationEnabled &&
- mShowBadge == that.mShowBadge &&
- isDeleted() == that.isDeleted() &&
- isBlockableSystem() == that.isBlockableSystem() &&
- mAllowAppOverlay == that.mAllowAppOverlay &&
- Objects.equals(getId(), that.getId()) &&
- Objects.equals(getName(), that.getName()) &&
- Objects.equals(mDesc, that.mDesc) &&
- Objects.equals(getSound(), that.getSound()) &&
- Arrays.equals(mVibration, that.mVibration) &&
- Objects.equals(getGroup(), that.getGroup()) &&
- Objects.equals(getAudioAttributes(), that.getAudioAttributes());
+ return getImportance() == that.getImportance()
+ && mBypassDnd == that.mBypassDnd
+ && getLockscreenVisibility() == that.getLockscreenVisibility()
+ && mLights == that.mLights
+ && getLightColor() == that.getLightColor()
+ && getUserLockedFields() == that.getUserLockedFields()
+ && isFgServiceShown() == that.isFgServiceShown()
+ && mVibrationEnabled == that.mVibrationEnabled
+ && mShowBadge == that.mShowBadge
+ && isDeleted() == that.isDeleted()
+ && isBlockableSystem() == that.isBlockableSystem()
+ && mAllowAppOverlay == that.mAllowAppOverlay
+ && Objects.equals(getId(), that.getId())
+ && Objects.equals(getName(), that.getName())
+ && Objects.equals(mDesc, that.mDesc)
+ && Objects.equals(getSound(), that.getSound())
+ && Arrays.equals(mVibration, that.mVibration)
+ && Objects.equals(getGroup(), that.getGroup())
+ && Objects.equals(getAudioAttributes(), that.getAudioAttributes())
+ && mImportanceLockedByOEM == that.mImportanceLockedByOEM;
}
@Override
@@ -979,7 +1000,8 @@ public final class NotificationChannel implements Parcelable {
getLockscreenVisibility(), getSound(), mLights, getLightColor(),
getUserLockedFields(),
isFgServiceShown(), mVibrationEnabled, mShowBadge, isDeleted(), getGroup(),
- getAudioAttributes(), isBlockableSystem(), mAllowAppOverlay);
+ getAudioAttributes(), isBlockableSystem(), mAllowAppOverlay,
+ mImportanceLockedByOEM);
result = 31 * result + Arrays.hashCode(mVibration);
return result;
}
@@ -1007,6 +1029,7 @@ public final class NotificationChannel implements Parcelable {
+ ", mAudioAttributes=" + mAudioAttributes
+ ", mBlockableSystem=" + mBlockableSystem
+ ", mAllowAppOverlay=" + mAllowAppOverlay
+ + ", mImportanceLockedByOEM=" + mImportanceLockedByOEM
+ '}';
pw.println(prefix + output);
}
@@ -1033,6 +1056,7 @@ public final class NotificationChannel implements Parcelable {
+ ", mAudioAttributes=" + mAudioAttributes
+ ", mBlockableSystem=" + mBlockableSystem
+ ", mAllowAppOverlay=" + mAllowAppOverlay
+ + ", mImportanceLockedByOEM=" + mImportanceLockedByOEM
+ '}';
}