summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorBeverly Tai <beverlyt@google.com>2018-11-05 18:58:39 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-11-05 18:58:39 +0000
commitfe0efe6bd2acae99bdd8039ff2fde11308ea85fa (patch)
tree0f8e19f8a03d2ca17382c580bcafa854a83b995a /core/java
parent095d10407055ad86234a721c1575be8b7a7bea9e (diff)
parent49ba9a60190d3ef58a4c30a6fd1ddeff32f83295 (diff)
Merge "Only update zen rule name on locale change"
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/AutomaticZenRule.java33
1 files changed, 28 insertions, 5 deletions
diff --git a/core/java/android/app/AutomaticZenRule.java b/core/java/android/app/AutomaticZenRule.java
index 9d68133c01da..e2f2075f0a32 100644
--- a/core/java/android/app/AutomaticZenRule.java
+++ b/core/java/android/app/AutomaticZenRule.java
@@ -31,7 +31,10 @@ import java.util.Objects;
* Rule instance information for zen mode.
*/
public final class AutomaticZenRule implements Parcelable {
-
+ /* @hide */
+ private static final int ENABLED = 1;
+ /* @hide */
+ private static final int DISABLED = 0;
private boolean enabled = false;
private String name;
private @InterruptionFilter int interruptionFilter;
@@ -39,6 +42,7 @@ public final class AutomaticZenRule implements Parcelable {
private ComponentName owner;
private long creationTime;
private ZenPolicy mZenPolicy;
+ private boolean mModified = false;
/**
* Creates an automatic zen rule.
@@ -101,8 +105,8 @@ public final class AutomaticZenRule implements Parcelable {
}
public AutomaticZenRule(Parcel source) {
- enabled = source.readInt() == 1;
- if (source.readInt() == 1) {
+ enabled = source.readInt() == ENABLED;
+ if (source.readInt() == ENABLED) {
name = source.readString();
}
interruptionFilter = source.readInt();
@@ -110,6 +114,7 @@ public final class AutomaticZenRule implements Parcelable {
owner = source.readParcelable(null);
creationTime = source.readLong();
mZenPolicy = source.readParcelable(null);
+ mModified = source.readInt() == ENABLED;
}
/**
@@ -148,6 +153,14 @@ public final class AutomaticZenRule implements Parcelable {
}
/**
+ * Returns whether this rule's name has been modified by the user.
+ * @hide
+ */
+ public boolean isModified() {
+ return mModified;
+ }
+
+ /**
* Gets the zen policy.
*/
public ZenPolicy getZenPolicy() {
@@ -191,6 +204,14 @@ public final class AutomaticZenRule implements Parcelable {
}
/**
+ * Sets modified state of this rule.
+ * @hide
+ */
+ public void setModified(boolean modified) {
+ this.mModified = modified;
+ }
+
+ /**
* Sets the zen policy.
*/
public void setZenPolicy(ZenPolicy zenPolicy) {
@@ -204,7 +225,7 @@ public final class AutomaticZenRule implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(enabled ? 1 : 0);
+ dest.writeInt(enabled ? ENABLED : DISABLED);
if (name != null) {
dest.writeInt(1);
dest.writeString(name);
@@ -216,6 +237,7 @@ public final class AutomaticZenRule implements Parcelable {
dest.writeParcelable(owner, 0);
dest.writeLong(creationTime);
dest.writeParcelable(mZenPolicy, 0);
+ dest.writeInt(mModified ? ENABLED : DISABLED);
}
@Override
@@ -237,6 +259,7 @@ public final class AutomaticZenRule implements Parcelable {
if (o == this) return true;
final AutomaticZenRule other = (AutomaticZenRule) o;
return other.enabled == enabled
+ && other.mModified == mModified
&& Objects.equals(other.name, name)
&& other.interruptionFilter == interruptionFilter
&& Objects.equals(other.conditionId, conditionId)
@@ -248,7 +271,7 @@ public final class AutomaticZenRule implements Parcelable {
@Override
public int hashCode() {
return Objects.hash(enabled, name, interruptionFilter, conditionId, owner, creationTime,
- mZenPolicy);
+ mZenPolicy, mModified);
}
public static final Parcelable.Creator<AutomaticZenRule> CREATOR