Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -4021,6 +4021,8 @@ package android.app { ctor public AutomaticZenRule(android.os.Parcel); method public int describeContents(); method public android.net.Uri getConditionId(); method public long getCreationTime(); method public java.lang.String getId(); method public int getInterruptionFilter(); method public java.lang.String getName(); method public android.content.ComponentName getOwner(); api/system-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -4132,6 +4132,8 @@ package android.app { ctor public AutomaticZenRule(android.os.Parcel); method public int describeContents(); method public android.net.Uri getConditionId(); method public long getCreationTime(); method public java.lang.String getId(); method public int getInterruptionFilter(); method public java.lang.String getName(); method public android.content.ComponentName getOwner(); core/java/android/app/AutomaticZenRule.java +45 −3 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ public class AutomaticZenRule implements Parcelable { private int interruptionFilter; private Uri conditionId; private ComponentName owner; private String id; private long creationTime; /** * Creates an automatic zen rule. Loading @@ -55,6 +57,17 @@ public class AutomaticZenRule implements Parcelable { this.enabled = enabled; } /** * @SystemApi * @hide */ public AutomaticZenRule(String name, ComponentName owner, Uri conditionId, int interruptionFilter, boolean enabled, String id, long creationTime) { this(name, owner, conditionId, interruptionFilter, enabled); this.id = id; this.creationTime = creationTime; } public AutomaticZenRule(Parcel source) { enabled = source.readInt() == 1; if (source.readInt() == 1) { Loading @@ -63,6 +76,10 @@ public class AutomaticZenRule implements Parcelable { interruptionFilter = source.readInt(); conditionId = source.readParcelable(null); owner = source.readParcelable(null); if (source.readInt() == 1) { id = source.readString(); } creationTime = source.readLong(); } /** Loading Loading @@ -100,6 +117,20 @@ public class AutomaticZenRule implements Parcelable { return enabled; } /** * Returns the wall time in milliseconds when this rule was created, if known. */ public long getCreationTime() { return creationTime; } /** * Returns the unique identifier for this rule. */ public String getId() { return id; } /** * Sets the representation of the state that causes this rule to become active. */ Loading Loading @@ -146,6 +177,13 @@ public class AutomaticZenRule implements Parcelable { dest.writeInt(interruptionFilter); dest.writeParcelable(conditionId, 0); dest.writeParcelable(owner, 0); if (id != null) { dest.writeInt(1); dest.writeString(id); } else { dest.writeInt(0); } dest.writeLong(creationTime); } @Override Loading @@ -156,6 +194,8 @@ public class AutomaticZenRule implements Parcelable { .append(",interruptionFilter=").append(interruptionFilter) .append(",conditionId=").append(conditionId) .append(",owner=").append(owner) .append(",id=").append(id) .append(",creationTime=").append(creationTime) .append(']').toString(); } Loading @@ -168,12 +208,14 @@ public class AutomaticZenRule implements Parcelable { && Objects.equals(other.name, name) && other.interruptionFilter == interruptionFilter && Objects.equals(other.conditionId, conditionId) && Objects.equals(other.owner, owner); && Objects.equals(other.owner, owner) && Objects.equals(other.id, id) && other.creationTime == creationTime; } @Override public int hashCode() { return Objects.hash(enabled, name, interruptionFilter, conditionId, owner); return Objects.hash(enabled, name, interruptionFilter, conditionId, owner, id, creationTime); } public static final Parcelable.Creator<AutomaticZenRule> CREATOR Loading core/java/android/service/notification/ZenModeConfig.java +34 −2 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ public class ZenModeConfig implements Parcelable { private static final String RULE_ATT_COMPONENT = "component"; private static final String RULE_ATT_ZEN = "zen"; private static final String RULE_ATT_CONDITION_ID = "conditionId"; private static final String RULE_ATT_CREATION_TIME = "creationTime"; public boolean allowCalls = DEFAULT_ALLOW_CALLS; public boolean allowRepeatCallers = DEFAULT_ALLOW_REPEAT_CALLERS; Loading Loading @@ -415,6 +416,7 @@ public class ZenModeConfig implements Parcelable { final String id = parser.getAttributeValue(null, RULE_ATT_ID); final ZenRule automaticRule = readRuleXml(parser); if (id != null && automaticRule != null) { automaticRule.id = id; rt.automaticRules.put(id, automaticRule); } } Loading Loading @@ -468,6 +470,7 @@ public class ZenModeConfig implements Parcelable { } rt.conditionId = safeUri(parser, RULE_ATT_CONDITION_ID); rt.component = safeComponentName(parser, RULE_ATT_COMPONENT); rt.creationTime = safeLong(parser, RULE_ATT_CREATION_TIME, 0); rt.condition = readConditionXml(parser); return rt; } Loading @@ -485,6 +488,7 @@ public class ZenModeConfig implements Parcelable { if (rule.conditionId != null) { out.attribute(null, RULE_ATT_CONDITION_ID, rule.conditionId.toString()); } out.attribute(null, RULE_ATT_CREATION_TIME, Long.toString(rule.creationTime)); if (rule.condition != null) { writeConditionXml(rule.condition, out); } Loading Loading @@ -552,6 +556,11 @@ public class ZenModeConfig implements Parcelable { return Uri.parse(val); } private static long safeLong(XmlPullParser parser, String att, long defValue) { final String val = parser.getAttributeValue(null, att); return tryParseLong(val, defValue); } public ArraySet<String> getAutomaticRuleNames() { final ArraySet<String> rt = new ArraySet<String>(); for (int i = 0; i < automaticRules.size(); i++) { Loading Loading @@ -943,6 +952,8 @@ public class ZenModeConfig implements Parcelable { public Uri conditionId; // required for automatic public Condition condition; // optional public ComponentName component; // optional public String id; // required for automatic (unique) public long creationTime; // required for automatic public ZenRule() { } Loading @@ -956,6 +967,10 @@ public class ZenModeConfig implements Parcelable { conditionId = source.readParcelable(null); condition = source.readParcelable(null); component = source.readParcelable(null); if (source.readInt() == 1) { id = source.readString(); } creationTime = source.readLong(); } @Override Loading @@ -977,6 +992,13 @@ public class ZenModeConfig implements Parcelable { dest.writeParcelable(conditionId, 0); dest.writeParcelable(condition, 0); dest.writeParcelable(component, 0); if (id != null) { dest.writeInt(1); dest.writeString(id); } else { dest.writeInt(0); } dest.writeLong(creationTime); } @Override Loading @@ -989,6 +1011,8 @@ public class ZenModeConfig implements Parcelable { .append(",conditionId=").append(conditionId) .append(",condition=").append(condition) .append(",component=").append(component) .append(",id=").append(id) .append(",creationTime=").append(creationTime) .append(']').toString(); } Loading Loading @@ -1029,6 +1053,12 @@ public class ZenModeConfig implements Parcelable { if (!Objects.equals(component, to.component)) { d.addLine(item, "component", component, to.component); } if (!Objects.equals(id, to.id)) { d.addLine(item, "id", id, to.id); } if (creationTime == to.creationTime) { d.addLine(item, "creationTime", creationTime, to.creationTime); } } @Override Loading @@ -1042,13 +1072,15 @@ public class ZenModeConfig implements Parcelable { && other.zenMode == zenMode && Objects.equals(other.conditionId, conditionId) && Objects.equals(other.condition, condition) && Objects.equals(other.component, component); && Objects.equals(other.component, component) && Objects.equals(other.id, id) && other.creationTime == creationTime; } @Override public int hashCode() { return Objects.hash(enabled, snoozing, name, zenMode, conditionId, condition, component); component, id, creationTime); } public boolean isAutomaticActive() { Loading services/core/java/com/android/server/notification/ZenModeHelper.java +13 −4 Original line number Diff line number Diff line Loading @@ -232,6 +232,8 @@ public class ZenModeHelper { ZenModeConfig.ZenRule rule = new ZenModeConfig.ZenRule(); if (ruleId == null) { ruleId = newConfig.newRuleId(); rule.id = ruleId; rule.creationTime = System.currentTimeMillis(); rule.name = automaticZenRule.getName(); rule.component = automaticZenRule.getOwner(); } else { Loading Loading @@ -312,7 +314,8 @@ public class ZenModeHelper { private AutomaticZenRule createAutomaticZenRule(ZenRule rule) { return new AutomaticZenRule(rule.name, rule.component, rule.conditionId, NotificationManager.zenModeToInterruptionFilter(rule.zenMode), rule.enabled); NotificationManager.zenModeToInterruptionFilter(rule.zenMode), rule.enabled, rule.id, rule.creationTime); } public void setManualZenMode(int zenMode, Uri conditionId, String reason) { Loading Loading @@ -640,7 +643,9 @@ public class ZenModeHelper { rule1.conditionId = ZenModeConfig.toScheduleConditionId(weeknights); rule1.zenMode = Global.ZEN_MODE_ALARMS; rule1.component = ScheduleConditionProvider.COMPONENT; config.automaticRules.put(config.newRuleId(), rule1); rule1.id = config.newRuleId(); rule1.creationTime = System.currentTimeMillis(); config.automaticRules.put(rule1.id, rule1); final ScheduleInfo weekends = new ScheduleInfo(); weekends.days = ZenModeConfig.WEEKEND_DAYS; Loading @@ -654,7 +659,9 @@ public class ZenModeHelper { rule2.conditionId = ZenModeConfig.toScheduleConditionId(weekends); rule2.zenMode = Global.ZEN_MODE_ALARMS; rule2.component = ScheduleConditionProvider.COMPONENT; config.automaticRules.put(config.newRuleId(), rule2); rule2.id = config.newRuleId(); rule2.creationTime = System.currentTimeMillis(); config.automaticRules.put(rule2.id, rule2); } private void appendDefaultEventRules(ZenModeConfig config) { Loading @@ -669,7 +676,9 @@ public class ZenModeHelper { rule.conditionId = ZenModeConfig.toEventConditionId(events); rule.zenMode = Global.ZEN_MODE_ALARMS; rule.component = EventConditionProvider.COMPONENT; config.automaticRules.put(config.newRuleId(), rule); rule.id = config.newRuleId(); rule.creationTime = System.currentTimeMillis(); config.automaticRules.put(rule.id, rule); } private static int zenSeverity(int zen) { Loading Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -4021,6 +4021,8 @@ package android.app { ctor public AutomaticZenRule(android.os.Parcel); method public int describeContents(); method public android.net.Uri getConditionId(); method public long getCreationTime(); method public java.lang.String getId(); method public int getInterruptionFilter(); method public java.lang.String getName(); method public android.content.ComponentName getOwner();
api/system-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -4132,6 +4132,8 @@ package android.app { ctor public AutomaticZenRule(android.os.Parcel); method public int describeContents(); method public android.net.Uri getConditionId(); method public long getCreationTime(); method public java.lang.String getId(); method public int getInterruptionFilter(); method public java.lang.String getName(); method public android.content.ComponentName getOwner();
core/java/android/app/AutomaticZenRule.java +45 −3 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ public class AutomaticZenRule implements Parcelable { private int interruptionFilter; private Uri conditionId; private ComponentName owner; private String id; private long creationTime; /** * Creates an automatic zen rule. Loading @@ -55,6 +57,17 @@ public class AutomaticZenRule implements Parcelable { this.enabled = enabled; } /** * @SystemApi * @hide */ public AutomaticZenRule(String name, ComponentName owner, Uri conditionId, int interruptionFilter, boolean enabled, String id, long creationTime) { this(name, owner, conditionId, interruptionFilter, enabled); this.id = id; this.creationTime = creationTime; } public AutomaticZenRule(Parcel source) { enabled = source.readInt() == 1; if (source.readInt() == 1) { Loading @@ -63,6 +76,10 @@ public class AutomaticZenRule implements Parcelable { interruptionFilter = source.readInt(); conditionId = source.readParcelable(null); owner = source.readParcelable(null); if (source.readInt() == 1) { id = source.readString(); } creationTime = source.readLong(); } /** Loading Loading @@ -100,6 +117,20 @@ public class AutomaticZenRule implements Parcelable { return enabled; } /** * Returns the wall time in milliseconds when this rule was created, if known. */ public long getCreationTime() { return creationTime; } /** * Returns the unique identifier for this rule. */ public String getId() { return id; } /** * Sets the representation of the state that causes this rule to become active. */ Loading Loading @@ -146,6 +177,13 @@ public class AutomaticZenRule implements Parcelable { dest.writeInt(interruptionFilter); dest.writeParcelable(conditionId, 0); dest.writeParcelable(owner, 0); if (id != null) { dest.writeInt(1); dest.writeString(id); } else { dest.writeInt(0); } dest.writeLong(creationTime); } @Override Loading @@ -156,6 +194,8 @@ public class AutomaticZenRule implements Parcelable { .append(",interruptionFilter=").append(interruptionFilter) .append(",conditionId=").append(conditionId) .append(",owner=").append(owner) .append(",id=").append(id) .append(",creationTime=").append(creationTime) .append(']').toString(); } Loading @@ -168,12 +208,14 @@ public class AutomaticZenRule implements Parcelable { && Objects.equals(other.name, name) && other.interruptionFilter == interruptionFilter && Objects.equals(other.conditionId, conditionId) && Objects.equals(other.owner, owner); && Objects.equals(other.owner, owner) && Objects.equals(other.id, id) && other.creationTime == creationTime; } @Override public int hashCode() { return Objects.hash(enabled, name, interruptionFilter, conditionId, owner); return Objects.hash(enabled, name, interruptionFilter, conditionId, owner, id, creationTime); } public static final Parcelable.Creator<AutomaticZenRule> CREATOR Loading
core/java/android/service/notification/ZenModeConfig.java +34 −2 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ public class ZenModeConfig implements Parcelable { private static final String RULE_ATT_COMPONENT = "component"; private static final String RULE_ATT_ZEN = "zen"; private static final String RULE_ATT_CONDITION_ID = "conditionId"; private static final String RULE_ATT_CREATION_TIME = "creationTime"; public boolean allowCalls = DEFAULT_ALLOW_CALLS; public boolean allowRepeatCallers = DEFAULT_ALLOW_REPEAT_CALLERS; Loading Loading @@ -415,6 +416,7 @@ public class ZenModeConfig implements Parcelable { final String id = parser.getAttributeValue(null, RULE_ATT_ID); final ZenRule automaticRule = readRuleXml(parser); if (id != null && automaticRule != null) { automaticRule.id = id; rt.automaticRules.put(id, automaticRule); } } Loading Loading @@ -468,6 +470,7 @@ public class ZenModeConfig implements Parcelable { } rt.conditionId = safeUri(parser, RULE_ATT_CONDITION_ID); rt.component = safeComponentName(parser, RULE_ATT_COMPONENT); rt.creationTime = safeLong(parser, RULE_ATT_CREATION_TIME, 0); rt.condition = readConditionXml(parser); return rt; } Loading @@ -485,6 +488,7 @@ public class ZenModeConfig implements Parcelable { if (rule.conditionId != null) { out.attribute(null, RULE_ATT_CONDITION_ID, rule.conditionId.toString()); } out.attribute(null, RULE_ATT_CREATION_TIME, Long.toString(rule.creationTime)); if (rule.condition != null) { writeConditionXml(rule.condition, out); } Loading Loading @@ -552,6 +556,11 @@ public class ZenModeConfig implements Parcelable { return Uri.parse(val); } private static long safeLong(XmlPullParser parser, String att, long defValue) { final String val = parser.getAttributeValue(null, att); return tryParseLong(val, defValue); } public ArraySet<String> getAutomaticRuleNames() { final ArraySet<String> rt = new ArraySet<String>(); for (int i = 0; i < automaticRules.size(); i++) { Loading Loading @@ -943,6 +952,8 @@ public class ZenModeConfig implements Parcelable { public Uri conditionId; // required for automatic public Condition condition; // optional public ComponentName component; // optional public String id; // required for automatic (unique) public long creationTime; // required for automatic public ZenRule() { } Loading @@ -956,6 +967,10 @@ public class ZenModeConfig implements Parcelable { conditionId = source.readParcelable(null); condition = source.readParcelable(null); component = source.readParcelable(null); if (source.readInt() == 1) { id = source.readString(); } creationTime = source.readLong(); } @Override Loading @@ -977,6 +992,13 @@ public class ZenModeConfig implements Parcelable { dest.writeParcelable(conditionId, 0); dest.writeParcelable(condition, 0); dest.writeParcelable(component, 0); if (id != null) { dest.writeInt(1); dest.writeString(id); } else { dest.writeInt(0); } dest.writeLong(creationTime); } @Override Loading @@ -989,6 +1011,8 @@ public class ZenModeConfig implements Parcelable { .append(",conditionId=").append(conditionId) .append(",condition=").append(condition) .append(",component=").append(component) .append(",id=").append(id) .append(",creationTime=").append(creationTime) .append(']').toString(); } Loading Loading @@ -1029,6 +1053,12 @@ public class ZenModeConfig implements Parcelable { if (!Objects.equals(component, to.component)) { d.addLine(item, "component", component, to.component); } if (!Objects.equals(id, to.id)) { d.addLine(item, "id", id, to.id); } if (creationTime == to.creationTime) { d.addLine(item, "creationTime", creationTime, to.creationTime); } } @Override Loading @@ -1042,13 +1072,15 @@ public class ZenModeConfig implements Parcelable { && other.zenMode == zenMode && Objects.equals(other.conditionId, conditionId) && Objects.equals(other.condition, condition) && Objects.equals(other.component, component); && Objects.equals(other.component, component) && Objects.equals(other.id, id) && other.creationTime == creationTime; } @Override public int hashCode() { return Objects.hash(enabled, snoozing, name, zenMode, conditionId, condition, component); component, id, creationTime); } public boolean isAutomaticActive() { Loading
services/core/java/com/android/server/notification/ZenModeHelper.java +13 −4 Original line number Diff line number Diff line Loading @@ -232,6 +232,8 @@ public class ZenModeHelper { ZenModeConfig.ZenRule rule = new ZenModeConfig.ZenRule(); if (ruleId == null) { ruleId = newConfig.newRuleId(); rule.id = ruleId; rule.creationTime = System.currentTimeMillis(); rule.name = automaticZenRule.getName(); rule.component = automaticZenRule.getOwner(); } else { Loading Loading @@ -312,7 +314,8 @@ public class ZenModeHelper { private AutomaticZenRule createAutomaticZenRule(ZenRule rule) { return new AutomaticZenRule(rule.name, rule.component, rule.conditionId, NotificationManager.zenModeToInterruptionFilter(rule.zenMode), rule.enabled); NotificationManager.zenModeToInterruptionFilter(rule.zenMode), rule.enabled, rule.id, rule.creationTime); } public void setManualZenMode(int zenMode, Uri conditionId, String reason) { Loading Loading @@ -640,7 +643,9 @@ public class ZenModeHelper { rule1.conditionId = ZenModeConfig.toScheduleConditionId(weeknights); rule1.zenMode = Global.ZEN_MODE_ALARMS; rule1.component = ScheduleConditionProvider.COMPONENT; config.automaticRules.put(config.newRuleId(), rule1); rule1.id = config.newRuleId(); rule1.creationTime = System.currentTimeMillis(); config.automaticRules.put(rule1.id, rule1); final ScheduleInfo weekends = new ScheduleInfo(); weekends.days = ZenModeConfig.WEEKEND_DAYS; Loading @@ -654,7 +659,9 @@ public class ZenModeHelper { rule2.conditionId = ZenModeConfig.toScheduleConditionId(weekends); rule2.zenMode = Global.ZEN_MODE_ALARMS; rule2.component = ScheduleConditionProvider.COMPONENT; config.automaticRules.put(config.newRuleId(), rule2); rule2.id = config.newRuleId(); rule2.creationTime = System.currentTimeMillis(); config.automaticRules.put(rule2.id, rule2); } private void appendDefaultEventRules(ZenModeConfig config) { Loading @@ -669,7 +676,9 @@ public class ZenModeHelper { rule.conditionId = ZenModeConfig.toEventConditionId(events); rule.zenMode = Global.ZEN_MODE_ALARMS; rule.component = EventConditionProvider.COMPONENT; config.automaticRules.put(config.newRuleId(), rule); rule.id = config.newRuleId(); rule.creationTime = System.currentTimeMillis(); config.automaticRules.put(rule.id, rule); } private static int zenSeverity(int zen) { Loading