Loading api/current.txt +58 −0 Original line number Diff line number Diff line Loading @@ -4385,6 +4385,7 @@ package android.app { public final class AutomaticZenRule implements android.os.Parcelable { ctor public AutomaticZenRule(java.lang.String, android.content.ComponentName, android.net.Uri, int, boolean); ctor public AutomaticZenRule(java.lang.String, android.content.ComponentName, android.net.Uri, android.service.notification.ZenPolicy, boolean); ctor public AutomaticZenRule(android.os.Parcel); method public int describeContents(); method public android.net.Uri getConditionId(); Loading @@ -4392,11 +4393,13 @@ package android.app { method public int getInterruptionFilter(); method public java.lang.String getName(); method public android.content.ComponentName getOwner(); method public android.service.notification.ZenPolicy getZenPolicy(); method public boolean isEnabled(); method public void setConditionId(android.net.Uri); method public void setEnabled(boolean); method public void setInterruptionFilter(int); method public void setName(java.lang.String); method public void setZenPolicy(android.service.notification.ZenPolicy); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.app.AutomaticZenRule> CREATOR; } Loading Loading @@ -39682,6 +39685,61 @@ package android.service.notification { field public static final android.os.Parcelable.Creator<android.service.notification.StatusBarNotification> CREATOR; } public final class ZenPolicy implements android.os.Parcelable { method public int describeContents(); method public int getPriorityCallSenders(); method public int getPriorityCategoryAlarms(); method public int getPriorityCategoryCalls(); method public int getPriorityCategoryEvents(); method public int getPriorityCategoryMedia(); method public int getPriorityCategoryMessages(); method public int getPriorityCategoryReminders(); method public int getPriorityCategoryRepeatCallers(); method public int getPriorityCategorySystem(); method public int getPriorityMessageSenders(); method public int getVisualEffectAmbient(); method public int getVisualEffectBadge(); method public int getVisualEffectFullScreenIntent(); method public int getVisualEffectLights(); method public int getVisualEffectNotificationList(); method public int getVisualEffectPeek(); method public int getVisualEffectStatusBar(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.service.notification.ZenPolicy> CREATOR; field public static final int PEOPLE_TYPE_ANYONE = 1; // 0x1 field public static final int PEOPLE_TYPE_CONTACTS = 2; // 0x2 field public static final int PEOPLE_TYPE_NONE = 4; // 0x4 field public static final int PEOPLE_TYPE_STARRED = 3; // 0x3 field public static final int PEOPLE_TYPE_UNSET = 0; // 0x0 field public static final int STATE_ALLOW = 1; // 0x1 field public static final int STATE_DISALLOW = 2; // 0x2 field public static final int STATE_UNSET = 0; // 0x0 } public static class ZenPolicy.Builder { ctor public ZenPolicy.Builder(); method public android.service.notification.ZenPolicy.Builder allowAlarms(boolean); method public android.service.notification.ZenPolicy.Builder allowAllSounds(); method public android.service.notification.ZenPolicy.Builder allowCalls(int); method public android.service.notification.ZenPolicy.Builder allowEvents(boolean); method public android.service.notification.ZenPolicy.Builder allowMedia(boolean); method public android.service.notification.ZenPolicy.Builder allowMessages(int); method public android.service.notification.ZenPolicy.Builder allowReminders(boolean); method public android.service.notification.ZenPolicy.Builder allowRepeatCallers(boolean); method public android.service.notification.ZenPolicy.Builder allowSystem(boolean); method public android.service.notification.ZenPolicy build(); method public android.service.notification.ZenPolicy.Builder disallowAllSounds(); method public android.service.notification.ZenPolicy.Builder hideAllVisualEffects(); method public android.service.notification.ZenPolicy.Builder showAllVisualEffects(); method public android.service.notification.ZenPolicy.Builder showBadges(boolean); method public android.service.notification.ZenPolicy.Builder showFullScreenIntent(boolean); method public android.service.notification.ZenPolicy.Builder showInAmbientDisplay(boolean); method public android.service.notification.ZenPolicy.Builder showInNotificationList(boolean); method public android.service.notification.ZenPolicy.Builder showLights(boolean); method public android.service.notification.ZenPolicy.Builder showPeeking(boolean); method public android.service.notification.ZenPolicy.Builder showStatusBarIcons(boolean); } } package android.service.quicksettings { api/system-current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -355,6 +355,11 @@ package android.app { field public static final android.os.Parcelable.Creator<android.app.AppOpsManager.PackageOps> CREATOR; } public final class AutomaticZenRule implements android.os.Parcelable { ctor public AutomaticZenRule(java.lang.String, android.content.ComponentName, android.net.Uri, int, boolean, long); ctor public AutomaticZenRule(java.lang.String, android.content.ComponentName, android.net.Uri, int, boolean, long, android.service.notification.ZenPolicy); } public class BroadcastOptions { method public static android.app.BroadcastOptions makeBasic(); method public void setDontSendToRestrictedApps(boolean); Loading core/java/android/app/AutomaticZenRule.java +55 −3 Original line number Diff line number Diff line Loading @@ -16,11 +16,14 @@ package android.app; import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY; import android.app.NotificationManager.InterruptionFilter; import android.content.ComponentName; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.service.notification.ZenPolicy; import java.util.Objects; Loading @@ -35,6 +38,7 @@ public final class AutomaticZenRule implements Parcelable { private Uri conditionId; private ComponentName owner; private long creationTime; private ZenPolicy mZenPolicy; /** * Creates an automatic zen rule. Loading @@ -58,7 +62,27 @@ public final class AutomaticZenRule implements Parcelable { } /** * @SystemApi * Creates an automatic zen rule. * * @param name The name of the rule. * @param owner The Condition Provider service that owns this rule. * @param conditionId A representation of the state that should cause the Condition Provider * service to apply the given interruption filter. * @param policy The policy defines which notifications are allowed to interrupt the user * while this rule is active * @param enabled Whether the rule is enabled. */ public AutomaticZenRule(String name, ComponentName owner, Uri conditionId, ZenPolicy policy, boolean enabled) { this.name = name; this.owner = owner; this.conditionId = conditionId; this.interruptionFilter = INTERRUPTION_FILTER_PRIORITY; this.enabled = enabled; this.mZenPolicy = policy; } /** * @hide */ public AutomaticZenRule(String name, ComponentName owner, Uri conditionId, Loading @@ -67,6 +91,15 @@ public final class AutomaticZenRule implements Parcelable { this.creationTime = creationTime; } /** * @hide */ public AutomaticZenRule(String name, ComponentName owner, Uri conditionId, ZenPolicy policy, boolean enabled, long creationTime) { this(name, owner, conditionId, policy, enabled); this.creationTime = creationTime; } public AutomaticZenRule(Parcel source) { enabled = source.readInt() == 1; if (source.readInt() == 1) { Loading @@ -76,6 +109,7 @@ public final class AutomaticZenRule implements Parcelable { conditionId = source.readParcelable(null); owner = source.readParcelable(null); creationTime = source.readLong(); mZenPolicy = source.readParcelable(null); } /** Loading Loading @@ -113,6 +147,13 @@ public final class AutomaticZenRule implements Parcelable { return enabled; } /** * Gets the zen policy. */ public ZenPolicy getZenPolicy() { return this.mZenPolicy.copy(); } /** * Returns the time this rule was created, represented as milliseconds since the epoch. */ Loading Loading @@ -149,6 +190,13 @@ public final class AutomaticZenRule implements Parcelable { this.enabled = enabled; } /** * Sets the zen policy. */ public void setZenPolicy(ZenPolicy zenPolicy) { this.mZenPolicy = zenPolicy; } @Override public int describeContents() { return 0; Loading @@ -167,6 +215,7 @@ public final class AutomaticZenRule implements Parcelable { dest.writeParcelable(conditionId, 0); dest.writeParcelable(owner, 0); dest.writeLong(creationTime); dest.writeParcelable(mZenPolicy, 0); } @Override Loading @@ -178,6 +227,7 @@ public final class AutomaticZenRule implements Parcelable { .append(",conditionId=").append(conditionId) .append(",owner=").append(owner) .append(",creationTime=").append(creationTime) .append(",mZenPolicy=").append(mZenPolicy) .append(']').toString(); } Loading @@ -191,12 +241,14 @@ public final class AutomaticZenRule implements Parcelable { && other.interruptionFilter == interruptionFilter && Objects.equals(other.conditionId, conditionId) && Objects.equals(other.owner, owner) && other.creationTime == creationTime; && other.creationTime == creationTime && Objects.equals(other.mZenPolicy, mZenPolicy); } @Override public int hashCode() { return Objects.hash(enabled, name, interruptionFilter, conditionId, owner, creationTime); return Objects.hash(enabled, name, interruptionFilter, conditionId, owner, creationTime, mZenPolicy); } public static final Parcelable.Creator<AutomaticZenRule> CREATOR Loading core/java/android/app/NotificationManager.java +8 −3 Original line number Diff line number Diff line Loading @@ -841,9 +841,14 @@ public class NotificationManager { List<ZenModeConfig.ZenRule> rules = service.getZenRules(); Map<String, AutomaticZenRule> ruleMap = new HashMap<>(); for (ZenModeConfig.ZenRule rule : rules) { if (rule.zenPolicy == null) { ruleMap.put(rule.id, new AutomaticZenRule(rule.name, rule.component, rule.conditionId, zenModeToInterruptionFilter(rule.zenMode), rule.enabled, rule.creationTime)); rule.conditionId, zenModeToInterruptionFilter(rule.zenMode), rule.enabled, rule.creationTime)); } else { ruleMap.put(rule.id, new AutomaticZenRule(rule.name, rule.component, rule.conditionId, rule.zenPolicy, rule.enabled, rule.creationTime)); } } return ruleMap; } catch (RemoteException e) { Loading core/java/android/service/notification/ZenModeConfig.java +152 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.service.notification; import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; Loading Loading @@ -763,6 +764,145 @@ public class ZenModeConfig implements Parcelable { } }; /** * @return notification policy based on manual and automatic rules */ public Policy getConsolidatedNotificationPolicy() { ZenPolicy policy = new ZenPolicy(); // assumption: manual rule always uses the default policy for (ZenRule rule : automaticRules.values()) { if (rule.isAutomaticActive()) { if (rule.zenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) { policy.apply(rule.zenPolicy); } } } return toNotificationPolicy(policy); } /** * Converts a zenPolicy to a notificationPolicy using this ZenModeConfig's values as its * defaults for all unset values in zenPolicy */ public Policy toNotificationPolicy(ZenPolicy zenPolicy) { NotificationManager.Policy defaultPolicy = toNotificationPolicy(); int priorityCategories = 0; int suppressedVisualEffects = 0; int callSenders = defaultPolicy.priorityCallSenders; int messageSenders = defaultPolicy.priorityMessageSenders; if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_REMINDERS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_REMINDERS, defaultPolicy))) { priorityCategories |= PRIORITY_CATEGORY_REMINDERS; } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_EVENTS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_EVENTS, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_EVENTS; } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_MESSAGES, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_MESSAGES, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_MESSAGES; messageSenders = getNotificationPolicySenders(zenPolicy.getPriorityMessageSenders()); } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_CALLS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_CALLS, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_CALLS; messageSenders = getNotificationPolicySenders(zenPolicy.getPriorityCallSenders()); } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_REPEAT_CALLERS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_REPEAT_CALLERS; } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_ALARMS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_ALARMS, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_ALARMS; } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_MEDIA, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_MEDIA, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_MEDIA; } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_SYSTEM, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_SYSTEM, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_SYSTEM; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_FULL_SCREEN_INTENT, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_LIGHTS, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_LIGHTS, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_LIGHTS; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_PEEK, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_PEEK, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_PEEK; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_STATUS_BAR, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_STATUS_BAR, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_STATUS_BAR; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_BADGE, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_BADGE, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_BADGE; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_AMBIENT, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_AMBIENT, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_AMBIENT; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_NOTIFICATION_LIST, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST; } return new NotificationManager.Policy(priorityCategories, callSenders, messageSenders, suppressedVisualEffects); } private boolean isPriorityCategoryEnabled(int categoryType, Policy policy) { return (policy.priorityCategories & categoryType) != 0; } private boolean isVisualEffectAllowed(int visualEffect, Policy policy) { return (policy.suppressedVisualEffects & visualEffect) == 0; } private int getNotificationPolicySenders(@ZenPolicy.PeopleType int senders) { switch (senders) { case ZenPolicy.PEOPLE_TYPE_ANYONE: return Policy.PRIORITY_SENDERS_ANY; case ZenPolicy.PEOPLE_TYPE_CONTACTS: return Policy.PRIORITY_SENDERS_CONTACTS; case ZenPolicy.PEOPLE_TYPE_STARRED: default: return Policy.PRIORITY_SENDERS_STARRED; } } public Policy toNotificationPolicy() { int priorityCategories = 0; int priorityCallSenders = Policy.PRIORITY_SENDERS_CONTACTS; Loading Loading @@ -1315,6 +1455,7 @@ public class ZenModeConfig implements Parcelable { @UnsupportedAppUsage public long creationTime; // required for automatic public String enabler; // package name, only used for manual rules. public ZenPolicy zenPolicy; public ZenRule() { } Loading @@ -1335,6 +1476,7 @@ public class ZenModeConfig implements Parcelable { if (source.readInt() == 1) { enabler = source.readString(); } zenPolicy = source.readParcelable(null); } @Override Loading Loading @@ -1369,6 +1511,7 @@ public class ZenModeConfig implements Parcelable { } else { dest.writeInt(0); } dest.writeParcelable(zenPolicy, 0); } @Override Loading @@ -1384,6 +1527,7 @@ public class ZenModeConfig implements Parcelable { .append(",component=").append(component) .append(",creationTime=").append(creationTime) .append(",enabler=").append(enabler) .append(",zenPolicy=").append(zenPolicy) .append(']').toString(); } Loading @@ -1407,7 +1551,7 @@ public class ZenModeConfig implements Parcelable { if (component != null) { component.writeToProto(proto, ZenRuleProto.COMPONENT); } // TODO: write zenPolicy to proto (b/115370281) proto.end(token); } Loading Loading @@ -1454,9 +1598,12 @@ public class ZenModeConfig implements Parcelable { if (creationTime != to.creationTime) { d.addLine(item, "creationTime", creationTime, to.creationTime); } if (enabler != to.enabler) { if (!Objects.equals(enabler, to.enabler)) { d.addLine(item, "enabler", enabler, to.enabler); } if (!Objects.equals(zenPolicy, to.zenPolicy)) { d.addLine(item, "zenPolicy", zenPolicy, to.zenPolicy); } } @Override Loading @@ -1472,13 +1619,14 @@ public class ZenModeConfig implements Parcelable { && Objects.equals(other.condition, condition) && Objects.equals(other.component, component) && Objects.equals(other.id, id) && Objects.equals(other.enabler, enabler); && Objects.equals(other.enabler, enabler) && Objects.equals(other.zenPolicy, zenPolicy); } @Override public int hashCode() { return Objects.hash(enabled, snoozing, name, zenMode, conditionId, condition, component, id, enabler); component, id, enabler, zenPolicy); } public boolean isAutomaticActive() { Loading Loading
api/current.txt +58 −0 Original line number Diff line number Diff line Loading @@ -4385,6 +4385,7 @@ package android.app { public final class AutomaticZenRule implements android.os.Parcelable { ctor public AutomaticZenRule(java.lang.String, android.content.ComponentName, android.net.Uri, int, boolean); ctor public AutomaticZenRule(java.lang.String, android.content.ComponentName, android.net.Uri, android.service.notification.ZenPolicy, boolean); ctor public AutomaticZenRule(android.os.Parcel); method public int describeContents(); method public android.net.Uri getConditionId(); Loading @@ -4392,11 +4393,13 @@ package android.app { method public int getInterruptionFilter(); method public java.lang.String getName(); method public android.content.ComponentName getOwner(); method public android.service.notification.ZenPolicy getZenPolicy(); method public boolean isEnabled(); method public void setConditionId(android.net.Uri); method public void setEnabled(boolean); method public void setInterruptionFilter(int); method public void setName(java.lang.String); method public void setZenPolicy(android.service.notification.ZenPolicy); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.app.AutomaticZenRule> CREATOR; } Loading Loading @@ -39682,6 +39685,61 @@ package android.service.notification { field public static final android.os.Parcelable.Creator<android.service.notification.StatusBarNotification> CREATOR; } public final class ZenPolicy implements android.os.Parcelable { method public int describeContents(); method public int getPriorityCallSenders(); method public int getPriorityCategoryAlarms(); method public int getPriorityCategoryCalls(); method public int getPriorityCategoryEvents(); method public int getPriorityCategoryMedia(); method public int getPriorityCategoryMessages(); method public int getPriorityCategoryReminders(); method public int getPriorityCategoryRepeatCallers(); method public int getPriorityCategorySystem(); method public int getPriorityMessageSenders(); method public int getVisualEffectAmbient(); method public int getVisualEffectBadge(); method public int getVisualEffectFullScreenIntent(); method public int getVisualEffectLights(); method public int getVisualEffectNotificationList(); method public int getVisualEffectPeek(); method public int getVisualEffectStatusBar(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.service.notification.ZenPolicy> CREATOR; field public static final int PEOPLE_TYPE_ANYONE = 1; // 0x1 field public static final int PEOPLE_TYPE_CONTACTS = 2; // 0x2 field public static final int PEOPLE_TYPE_NONE = 4; // 0x4 field public static final int PEOPLE_TYPE_STARRED = 3; // 0x3 field public static final int PEOPLE_TYPE_UNSET = 0; // 0x0 field public static final int STATE_ALLOW = 1; // 0x1 field public static final int STATE_DISALLOW = 2; // 0x2 field public static final int STATE_UNSET = 0; // 0x0 } public static class ZenPolicy.Builder { ctor public ZenPolicy.Builder(); method public android.service.notification.ZenPolicy.Builder allowAlarms(boolean); method public android.service.notification.ZenPolicy.Builder allowAllSounds(); method public android.service.notification.ZenPolicy.Builder allowCalls(int); method public android.service.notification.ZenPolicy.Builder allowEvents(boolean); method public android.service.notification.ZenPolicy.Builder allowMedia(boolean); method public android.service.notification.ZenPolicy.Builder allowMessages(int); method public android.service.notification.ZenPolicy.Builder allowReminders(boolean); method public android.service.notification.ZenPolicy.Builder allowRepeatCallers(boolean); method public android.service.notification.ZenPolicy.Builder allowSystem(boolean); method public android.service.notification.ZenPolicy build(); method public android.service.notification.ZenPolicy.Builder disallowAllSounds(); method public android.service.notification.ZenPolicy.Builder hideAllVisualEffects(); method public android.service.notification.ZenPolicy.Builder showAllVisualEffects(); method public android.service.notification.ZenPolicy.Builder showBadges(boolean); method public android.service.notification.ZenPolicy.Builder showFullScreenIntent(boolean); method public android.service.notification.ZenPolicy.Builder showInAmbientDisplay(boolean); method public android.service.notification.ZenPolicy.Builder showInNotificationList(boolean); method public android.service.notification.ZenPolicy.Builder showLights(boolean); method public android.service.notification.ZenPolicy.Builder showPeeking(boolean); method public android.service.notification.ZenPolicy.Builder showStatusBarIcons(boolean); } } package android.service.quicksettings {
api/system-current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -355,6 +355,11 @@ package android.app { field public static final android.os.Parcelable.Creator<android.app.AppOpsManager.PackageOps> CREATOR; } public final class AutomaticZenRule implements android.os.Parcelable { ctor public AutomaticZenRule(java.lang.String, android.content.ComponentName, android.net.Uri, int, boolean, long); ctor public AutomaticZenRule(java.lang.String, android.content.ComponentName, android.net.Uri, int, boolean, long, android.service.notification.ZenPolicy); } public class BroadcastOptions { method public static android.app.BroadcastOptions makeBasic(); method public void setDontSendToRestrictedApps(boolean); Loading
core/java/android/app/AutomaticZenRule.java +55 −3 Original line number Diff line number Diff line Loading @@ -16,11 +16,14 @@ package android.app; import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY; import android.app.NotificationManager.InterruptionFilter; import android.content.ComponentName; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.service.notification.ZenPolicy; import java.util.Objects; Loading @@ -35,6 +38,7 @@ public final class AutomaticZenRule implements Parcelable { private Uri conditionId; private ComponentName owner; private long creationTime; private ZenPolicy mZenPolicy; /** * Creates an automatic zen rule. Loading @@ -58,7 +62,27 @@ public final class AutomaticZenRule implements Parcelable { } /** * @SystemApi * Creates an automatic zen rule. * * @param name The name of the rule. * @param owner The Condition Provider service that owns this rule. * @param conditionId A representation of the state that should cause the Condition Provider * service to apply the given interruption filter. * @param policy The policy defines which notifications are allowed to interrupt the user * while this rule is active * @param enabled Whether the rule is enabled. */ public AutomaticZenRule(String name, ComponentName owner, Uri conditionId, ZenPolicy policy, boolean enabled) { this.name = name; this.owner = owner; this.conditionId = conditionId; this.interruptionFilter = INTERRUPTION_FILTER_PRIORITY; this.enabled = enabled; this.mZenPolicy = policy; } /** * @hide */ public AutomaticZenRule(String name, ComponentName owner, Uri conditionId, Loading @@ -67,6 +91,15 @@ public final class AutomaticZenRule implements Parcelable { this.creationTime = creationTime; } /** * @hide */ public AutomaticZenRule(String name, ComponentName owner, Uri conditionId, ZenPolicy policy, boolean enabled, long creationTime) { this(name, owner, conditionId, policy, enabled); this.creationTime = creationTime; } public AutomaticZenRule(Parcel source) { enabled = source.readInt() == 1; if (source.readInt() == 1) { Loading @@ -76,6 +109,7 @@ public final class AutomaticZenRule implements Parcelable { conditionId = source.readParcelable(null); owner = source.readParcelable(null); creationTime = source.readLong(); mZenPolicy = source.readParcelable(null); } /** Loading Loading @@ -113,6 +147,13 @@ public final class AutomaticZenRule implements Parcelable { return enabled; } /** * Gets the zen policy. */ public ZenPolicy getZenPolicy() { return this.mZenPolicy.copy(); } /** * Returns the time this rule was created, represented as milliseconds since the epoch. */ Loading Loading @@ -149,6 +190,13 @@ public final class AutomaticZenRule implements Parcelable { this.enabled = enabled; } /** * Sets the zen policy. */ public void setZenPolicy(ZenPolicy zenPolicy) { this.mZenPolicy = zenPolicy; } @Override public int describeContents() { return 0; Loading @@ -167,6 +215,7 @@ public final class AutomaticZenRule implements Parcelable { dest.writeParcelable(conditionId, 0); dest.writeParcelable(owner, 0); dest.writeLong(creationTime); dest.writeParcelable(mZenPolicy, 0); } @Override Loading @@ -178,6 +227,7 @@ public final class AutomaticZenRule implements Parcelable { .append(",conditionId=").append(conditionId) .append(",owner=").append(owner) .append(",creationTime=").append(creationTime) .append(",mZenPolicy=").append(mZenPolicy) .append(']').toString(); } Loading @@ -191,12 +241,14 @@ public final class AutomaticZenRule implements Parcelable { && other.interruptionFilter == interruptionFilter && Objects.equals(other.conditionId, conditionId) && Objects.equals(other.owner, owner) && other.creationTime == creationTime; && other.creationTime == creationTime && Objects.equals(other.mZenPolicy, mZenPolicy); } @Override public int hashCode() { return Objects.hash(enabled, name, interruptionFilter, conditionId, owner, creationTime); return Objects.hash(enabled, name, interruptionFilter, conditionId, owner, creationTime, mZenPolicy); } public static final Parcelable.Creator<AutomaticZenRule> CREATOR Loading
core/java/android/app/NotificationManager.java +8 −3 Original line number Diff line number Diff line Loading @@ -841,9 +841,14 @@ public class NotificationManager { List<ZenModeConfig.ZenRule> rules = service.getZenRules(); Map<String, AutomaticZenRule> ruleMap = new HashMap<>(); for (ZenModeConfig.ZenRule rule : rules) { if (rule.zenPolicy == null) { ruleMap.put(rule.id, new AutomaticZenRule(rule.name, rule.component, rule.conditionId, zenModeToInterruptionFilter(rule.zenMode), rule.enabled, rule.creationTime)); rule.conditionId, zenModeToInterruptionFilter(rule.zenMode), rule.enabled, rule.creationTime)); } else { ruleMap.put(rule.id, new AutomaticZenRule(rule.name, rule.component, rule.conditionId, rule.zenPolicy, rule.enabled, rule.creationTime)); } } return ruleMap; } catch (RemoteException e) { Loading
core/java/android/service/notification/ZenModeConfig.java +152 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.service.notification; import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; Loading Loading @@ -763,6 +764,145 @@ public class ZenModeConfig implements Parcelable { } }; /** * @return notification policy based on manual and automatic rules */ public Policy getConsolidatedNotificationPolicy() { ZenPolicy policy = new ZenPolicy(); // assumption: manual rule always uses the default policy for (ZenRule rule : automaticRules.values()) { if (rule.isAutomaticActive()) { if (rule.zenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) { policy.apply(rule.zenPolicy); } } } return toNotificationPolicy(policy); } /** * Converts a zenPolicy to a notificationPolicy using this ZenModeConfig's values as its * defaults for all unset values in zenPolicy */ public Policy toNotificationPolicy(ZenPolicy zenPolicy) { NotificationManager.Policy defaultPolicy = toNotificationPolicy(); int priorityCategories = 0; int suppressedVisualEffects = 0; int callSenders = defaultPolicy.priorityCallSenders; int messageSenders = defaultPolicy.priorityMessageSenders; if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_REMINDERS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_REMINDERS, defaultPolicy))) { priorityCategories |= PRIORITY_CATEGORY_REMINDERS; } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_EVENTS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_EVENTS, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_EVENTS; } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_MESSAGES, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_MESSAGES, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_MESSAGES; messageSenders = getNotificationPolicySenders(zenPolicy.getPriorityMessageSenders()); } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_CALLS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_CALLS, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_CALLS; messageSenders = getNotificationPolicySenders(zenPolicy.getPriorityCallSenders()); } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_REPEAT_CALLERS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_REPEAT_CALLERS; } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_ALARMS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_ALARMS, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_ALARMS; } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_MEDIA, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_MEDIA, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_MEDIA; } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_SYSTEM, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_SYSTEM, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_SYSTEM; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_FULL_SCREEN_INTENT, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_LIGHTS, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_LIGHTS, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_LIGHTS; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_PEEK, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_PEEK, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_PEEK; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_STATUS_BAR, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_STATUS_BAR, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_STATUS_BAR; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_BADGE, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_BADGE, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_BADGE; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_AMBIENT, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_AMBIENT, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_AMBIENT; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_NOTIFICATION_LIST, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST, defaultPolicy))) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST; } return new NotificationManager.Policy(priorityCategories, callSenders, messageSenders, suppressedVisualEffects); } private boolean isPriorityCategoryEnabled(int categoryType, Policy policy) { return (policy.priorityCategories & categoryType) != 0; } private boolean isVisualEffectAllowed(int visualEffect, Policy policy) { return (policy.suppressedVisualEffects & visualEffect) == 0; } private int getNotificationPolicySenders(@ZenPolicy.PeopleType int senders) { switch (senders) { case ZenPolicy.PEOPLE_TYPE_ANYONE: return Policy.PRIORITY_SENDERS_ANY; case ZenPolicy.PEOPLE_TYPE_CONTACTS: return Policy.PRIORITY_SENDERS_CONTACTS; case ZenPolicy.PEOPLE_TYPE_STARRED: default: return Policy.PRIORITY_SENDERS_STARRED; } } public Policy toNotificationPolicy() { int priorityCategories = 0; int priorityCallSenders = Policy.PRIORITY_SENDERS_CONTACTS; Loading Loading @@ -1315,6 +1455,7 @@ public class ZenModeConfig implements Parcelable { @UnsupportedAppUsage public long creationTime; // required for automatic public String enabler; // package name, only used for manual rules. public ZenPolicy zenPolicy; public ZenRule() { } Loading @@ -1335,6 +1476,7 @@ public class ZenModeConfig implements Parcelable { if (source.readInt() == 1) { enabler = source.readString(); } zenPolicy = source.readParcelable(null); } @Override Loading Loading @@ -1369,6 +1511,7 @@ public class ZenModeConfig implements Parcelable { } else { dest.writeInt(0); } dest.writeParcelable(zenPolicy, 0); } @Override Loading @@ -1384,6 +1527,7 @@ public class ZenModeConfig implements Parcelable { .append(",component=").append(component) .append(",creationTime=").append(creationTime) .append(",enabler=").append(enabler) .append(",zenPolicy=").append(zenPolicy) .append(']').toString(); } Loading @@ -1407,7 +1551,7 @@ public class ZenModeConfig implements Parcelable { if (component != null) { component.writeToProto(proto, ZenRuleProto.COMPONENT); } // TODO: write zenPolicy to proto (b/115370281) proto.end(token); } Loading Loading @@ -1454,9 +1598,12 @@ public class ZenModeConfig implements Parcelable { if (creationTime != to.creationTime) { d.addLine(item, "creationTime", creationTime, to.creationTime); } if (enabler != to.enabler) { if (!Objects.equals(enabler, to.enabler)) { d.addLine(item, "enabler", enabler, to.enabler); } if (!Objects.equals(zenPolicy, to.zenPolicy)) { d.addLine(item, "zenPolicy", zenPolicy, to.zenPolicy); } } @Override Loading @@ -1472,13 +1619,14 @@ public class ZenModeConfig implements Parcelable { && Objects.equals(other.condition, condition) && Objects.equals(other.component, component) && Objects.equals(other.id, id) && Objects.equals(other.enabler, enabler); && Objects.equals(other.enabler, enabler) && Objects.equals(other.zenPolicy, zenPolicy); } @Override public int hashCode() { return Objects.hash(enabled, snoozing, name, zenMode, conditionId, condition, component, id, enabler); component, id, enabler, zenPolicy); } public boolean isAutomaticActive() { Loading