Loading core/java/android/app/AutomaticZenRule.java +1 −1 Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ public final class AutomaticZenRule implements Parcelable { * Gets the zen policy. */ public ZenPolicy getZenPolicy() { return this.mZenPolicy.copy(); return mZenPolicy == null ? null : this.mZenPolicy.copy(); } /** Loading core/java/android/app/INotificationManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,7 @@ interface INotificationManager int getZenMode(); ZenModeConfig getZenModeConfig(); NotificationManager.Policy getConsolidatedNotificationPolicy(); oneway void setZenMode(int mode, in Uri conditionId, String reason); oneway void notifyConditions(String pkg, in IConditionProvider provider, in Condition[] conditions); boolean isNotificationPolicyAccessGranted(String pkg); Loading core/java/android/app/NotificationManager.java +78 −2 Original line number Diff line number Diff line Loading @@ -822,6 +822,18 @@ public class NotificationManager { } } /** * @hide */ public NotificationManager.Policy getConsolidatedNotificationPolicy() { INotificationManager service = getService(); try { return service.getConsolidatedNotificationPolicy(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @hide */ Loading Loading @@ -1062,7 +1074,7 @@ public class NotificationManager { } /** * Gets the current notification policy. * Gets the current user-specified default notification policy. * * <p> */ Loading Loading @@ -1621,6 +1633,71 @@ public class NotificationManager { return new Policy[size]; } }; /** @hide **/ public boolean allowAlarms() { return (priorityCategories & PRIORITY_CATEGORY_ALARMS) != 0; } /** @hide **/ public boolean allowMedia() { return (priorityCategories & PRIORITY_CATEGORY_MEDIA) != 0; } /** @hide **/ public boolean allowSystem() { return (priorityCategories & PRIORITY_CATEGORY_SYSTEM) != 0; } /** @hide **/ public boolean allowRepeatCallers() { return (priorityCategories & PRIORITY_CATEGORY_REPEAT_CALLERS) != 0; } /** @hide **/ public boolean allowCalls() { return (priorityCategories & PRIORITY_CATEGORY_CALLS) != 0; } /** @hide **/ public boolean allowMessages() { return (priorityCategories & PRIORITY_CATEGORY_MESSAGES) != 0; } /** @hide **/ public boolean allowEvents() { return (priorityCategories & PRIORITY_CATEGORY_EVENTS) != 0; } /** @hide **/ public boolean allowReminders() { return (priorityCategories & PRIORITY_CATEGORY_REMINDERS) != 0; } /** @hide **/ public int allowCallsFrom() { return priorityCallSenders; } /** @hide **/ public int allowMessagesFrom() { return priorityMessageSenders; } /** * returns a deep copy of this policy * @hide */ public Policy copy() { final Parcel parcel = Parcel.obtain(); try { writeToParcel(parcel, 0); parcel.setDataPosition(0); return new Policy(parcel); } finally { parcel.recycle(); } } } /** Loading Loading @@ -1708,5 +1785,4 @@ public class NotificationManager { default: return defValue; } } } core/java/android/service/notification/ZenModeConfig.java +19 −24 Original line number Diff line number Diff line Loading @@ -69,9 +69,9 @@ import java.util.UUID; public class ZenModeConfig implements Parcelable { private static String TAG = "ZenModeConfig"; public static final int SOURCE_ANYONE = 0; public static final int SOURCE_CONTACT = 1; public static final int SOURCE_STAR = 2; public static final int SOURCE_ANYONE = Policy.PRIORITY_SENDERS_ANY; public static final int SOURCE_CONTACT = Policy.PRIORITY_SENDERS_CONTACTS; public static final int SOURCE_STAR = Policy.PRIORITY_SENDERS_STARRED; public static final int MAX_SOURCE = SOURCE_STAR; private static final int DEFAULT_SOURCE = SOURCE_CONTACT; private static final int DEFAULT_CALLS_SOURCE = SOURCE_STAR; Loading Loading @@ -776,24 +776,6 @@ 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 Loading Loading @@ -891,7 +873,7 @@ public class ZenModeConfig implements Parcelable { } return new NotificationManager.Policy(priorityCategories, callSenders, messageSenders, suppressedVisualEffects); messageSenders, suppressedVisualEffects, defaultPolicy.state); } private boolean isPriorityCategoryEnabled(int categoryType, Policy policy) { Loading Loading @@ -945,6 +927,7 @@ public class ZenModeConfig implements Parcelable { } priorityCallSenders = sourceToPrioritySenders(allowCallsFrom, priorityCallSenders); priorityMessageSenders = sourceToPrioritySenders(allowMessagesFrom, priorityMessageSenders); return new Policy(priorityCategories, priorityCallSenders, priorityMessageSenders, suppressedVisualEffects, areChannelsBypassingDnd ? Policy.STATE_CHANNELS_BYPASSING_DND : 0); Loading Loading @@ -1731,14 +1714,26 @@ public class ZenModeConfig implements Parcelable { && !allowRepeatCallers && !areChannelsBypassingDnd; } /** * Determines whether dnd behavior should mute all sounds controlled by ringer */ public static boolean areAllZenBehaviorSoundsMuted(NotificationManager.Policy policy) { boolean allowAlarms = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_ALARMS) != 0; boolean allowMedia = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_MEDIA) != 0; boolean allowSystem = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_SYSTEM) != 0; return !allowAlarms && !allowMedia && !allowSystem && areAllPriorityOnlyNotificationZenSoundsMuted(policy); } /** * Determines if DND is currently overriding the ringer */ public static boolean isZenOverridingRinger(int zen, ZenModeConfig zenConfig) { public static boolean isZenOverridingRinger(int zen, Policy consolidatedPolicy) { return zen == Global.ZEN_MODE_NO_INTERRUPTIONS || zen == Global.ZEN_MODE_ALARMS || (zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS && ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(zenConfig)); && ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(consolidatedPolicy)); } /** Loading core/java/android/service/notification/ZenPolicy.java +4 −0 Original line number Diff line number Diff line Loading @@ -818,6 +818,10 @@ public final class ZenPolicy implements Parcelable { * @hide */ public void apply(ZenPolicy policyToApply) { if (policyToApply == null) { return; } // apply priority categories for (int category = 0; category < mPriorityCategories.size(); category++) { if (mPriorityCategories.get(category) == STATE_DISALLOW) { Loading Loading
core/java/android/app/AutomaticZenRule.java +1 −1 Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ public final class AutomaticZenRule implements Parcelable { * Gets the zen policy. */ public ZenPolicy getZenPolicy() { return this.mZenPolicy.copy(); return mZenPolicy == null ? null : this.mZenPolicy.copy(); } /** Loading
core/java/android/app/INotificationManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,7 @@ interface INotificationManager int getZenMode(); ZenModeConfig getZenModeConfig(); NotificationManager.Policy getConsolidatedNotificationPolicy(); oneway void setZenMode(int mode, in Uri conditionId, String reason); oneway void notifyConditions(String pkg, in IConditionProvider provider, in Condition[] conditions); boolean isNotificationPolicyAccessGranted(String pkg); Loading
core/java/android/app/NotificationManager.java +78 −2 Original line number Diff line number Diff line Loading @@ -822,6 +822,18 @@ public class NotificationManager { } } /** * @hide */ public NotificationManager.Policy getConsolidatedNotificationPolicy() { INotificationManager service = getService(); try { return service.getConsolidatedNotificationPolicy(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * @hide */ Loading Loading @@ -1062,7 +1074,7 @@ public class NotificationManager { } /** * Gets the current notification policy. * Gets the current user-specified default notification policy. * * <p> */ Loading Loading @@ -1621,6 +1633,71 @@ public class NotificationManager { return new Policy[size]; } }; /** @hide **/ public boolean allowAlarms() { return (priorityCategories & PRIORITY_CATEGORY_ALARMS) != 0; } /** @hide **/ public boolean allowMedia() { return (priorityCategories & PRIORITY_CATEGORY_MEDIA) != 0; } /** @hide **/ public boolean allowSystem() { return (priorityCategories & PRIORITY_CATEGORY_SYSTEM) != 0; } /** @hide **/ public boolean allowRepeatCallers() { return (priorityCategories & PRIORITY_CATEGORY_REPEAT_CALLERS) != 0; } /** @hide **/ public boolean allowCalls() { return (priorityCategories & PRIORITY_CATEGORY_CALLS) != 0; } /** @hide **/ public boolean allowMessages() { return (priorityCategories & PRIORITY_CATEGORY_MESSAGES) != 0; } /** @hide **/ public boolean allowEvents() { return (priorityCategories & PRIORITY_CATEGORY_EVENTS) != 0; } /** @hide **/ public boolean allowReminders() { return (priorityCategories & PRIORITY_CATEGORY_REMINDERS) != 0; } /** @hide **/ public int allowCallsFrom() { return priorityCallSenders; } /** @hide **/ public int allowMessagesFrom() { return priorityMessageSenders; } /** * returns a deep copy of this policy * @hide */ public Policy copy() { final Parcel parcel = Parcel.obtain(); try { writeToParcel(parcel, 0); parcel.setDataPosition(0); return new Policy(parcel); } finally { parcel.recycle(); } } } /** Loading Loading @@ -1708,5 +1785,4 @@ public class NotificationManager { default: return defValue; } } }
core/java/android/service/notification/ZenModeConfig.java +19 −24 Original line number Diff line number Diff line Loading @@ -69,9 +69,9 @@ import java.util.UUID; public class ZenModeConfig implements Parcelable { private static String TAG = "ZenModeConfig"; public static final int SOURCE_ANYONE = 0; public static final int SOURCE_CONTACT = 1; public static final int SOURCE_STAR = 2; public static final int SOURCE_ANYONE = Policy.PRIORITY_SENDERS_ANY; public static final int SOURCE_CONTACT = Policy.PRIORITY_SENDERS_CONTACTS; public static final int SOURCE_STAR = Policy.PRIORITY_SENDERS_STARRED; public static final int MAX_SOURCE = SOURCE_STAR; private static final int DEFAULT_SOURCE = SOURCE_CONTACT; private static final int DEFAULT_CALLS_SOURCE = SOURCE_STAR; Loading Loading @@ -776,24 +776,6 @@ 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 Loading Loading @@ -891,7 +873,7 @@ public class ZenModeConfig implements Parcelable { } return new NotificationManager.Policy(priorityCategories, callSenders, messageSenders, suppressedVisualEffects); messageSenders, suppressedVisualEffects, defaultPolicy.state); } private boolean isPriorityCategoryEnabled(int categoryType, Policy policy) { Loading Loading @@ -945,6 +927,7 @@ public class ZenModeConfig implements Parcelable { } priorityCallSenders = sourceToPrioritySenders(allowCallsFrom, priorityCallSenders); priorityMessageSenders = sourceToPrioritySenders(allowMessagesFrom, priorityMessageSenders); return new Policy(priorityCategories, priorityCallSenders, priorityMessageSenders, suppressedVisualEffects, areChannelsBypassingDnd ? Policy.STATE_CHANNELS_BYPASSING_DND : 0); Loading Loading @@ -1731,14 +1714,26 @@ public class ZenModeConfig implements Parcelable { && !allowRepeatCallers && !areChannelsBypassingDnd; } /** * Determines whether dnd behavior should mute all sounds controlled by ringer */ public static boolean areAllZenBehaviorSoundsMuted(NotificationManager.Policy policy) { boolean allowAlarms = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_ALARMS) != 0; boolean allowMedia = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_MEDIA) != 0; boolean allowSystem = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_SYSTEM) != 0; return !allowAlarms && !allowMedia && !allowSystem && areAllPriorityOnlyNotificationZenSoundsMuted(policy); } /** * Determines if DND is currently overriding the ringer */ public static boolean isZenOverridingRinger(int zen, ZenModeConfig zenConfig) { public static boolean isZenOverridingRinger(int zen, Policy consolidatedPolicy) { return zen == Global.ZEN_MODE_NO_INTERRUPTIONS || zen == Global.ZEN_MODE_ALARMS || (zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS && ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(zenConfig)); && ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(consolidatedPolicy)); } /** Loading
core/java/android/service/notification/ZenPolicy.java +4 −0 Original line number Diff line number Diff line Loading @@ -818,6 +818,10 @@ public final class ZenPolicy implements Parcelable { * @hide */ public void apply(ZenPolicy policyToApply) { if (policyToApply == null) { return; } // apply priority categories for (int category = 0; category < mPriorityCategories.size(); category++) { if (mPriorityCategories.get(category) == STATE_DISALLOW) { Loading