Loading core/java/android/app/INotificationManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ interface INotificationManager boolean onlyHasDefaultChannel(String pkg, int uid); ParceledListSlice getRecentNotifyingAppsForUser(int userId); int getBlockedAppCount(int userId); boolean areChannelsBypassingDnd(); // TODO: Remove this when callers have been migrated to the equivalent // INotificationListener method. Loading core/java/android/app/NotificationManager.java +34 −2 Original line number Diff line number Diff line Loading @@ -1167,6 +1167,23 @@ public class NotificationManager { */ public final int suppressedVisualEffects; /** * @hide */ public static final int STATE_CHANNELS_BYPASSING_DND = 1 << 0; /** * @hide */ public static final int STATE_UNSET = -1; /** * Notification state information that is necessary to determine Do Not Disturb behavior. * Bitmask of STATE_* constants. * @hide */ public final int state; /** * Constructs a policy for Do Not Disturb priority mode behavior. * Loading @@ -1182,7 +1199,7 @@ public class NotificationManager { */ public Policy(int priorityCategories, int priorityCallSenders, int priorityMessageSenders) { this(priorityCategories, priorityCallSenders, priorityMessageSenders, SUPPRESSED_EFFECTS_UNSET); SUPPRESSED_EFFECTS_UNSET, STATE_UNSET); } /** Loading Loading @@ -1220,11 +1237,23 @@ public class NotificationManager { this.priorityCallSenders = priorityCallSenders; this.priorityMessageSenders = priorityMessageSenders; this.suppressedVisualEffects = suppressedVisualEffects; this.state = STATE_UNSET; } /** @hide */ public Policy(int priorityCategories, int priorityCallSenders, int priorityMessageSenders, int suppressedVisualEffects, int state) { this.priorityCategories = priorityCategories; this.priorityCallSenders = priorityCallSenders; this.priorityMessageSenders = priorityMessageSenders; this.suppressedVisualEffects = suppressedVisualEffects; this.state = state; } /** @hide */ public Policy(Parcel source) { this(source.readInt(), source.readInt(), source.readInt(), source.readInt()); this(source.readInt(), source.readInt(), source.readInt(), source.readInt(), source.readInt()); } @Override Loading @@ -1233,6 +1262,7 @@ public class NotificationManager { dest.writeInt(priorityCallSenders); dest.writeInt(priorityMessageSenders); dest.writeInt(suppressedVisualEffects); dest.writeInt(state); } @Override Loading Loading @@ -1265,6 +1295,8 @@ public class NotificationManager { + ",priorityMessageSenders=" + prioritySendersToString(priorityMessageSenders) + ",suppressedVisualEffects=" + suppressedEffectsToString(suppressedVisualEffects) + ",areChannelsBypassingDnd=" + (((state & STATE_CHANNELS_BYPASSING_DND) != 0) ? "true" : "false") + "]"; } Loading core/java/android/service/notification/ZenModeConfig.java +33 −6 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ public class ZenModeConfig implements Parcelable { private static final boolean DEFAULT_ALLOW_REPEAT_CALLERS = false; private static final boolean DEFAULT_ALLOW_SCREEN_OFF = false; private static final boolean DEFAULT_ALLOW_SCREEN_ON = false; private static final boolean DEFAULT_CHANNELS_BYPASSING_DND = false; private static final int DEFAULT_SUPPRESSED_VISUAL_EFFECTS = Policy.getAllSuppressedVisualEffects(); Loading @@ -118,6 +119,8 @@ public class ZenModeConfig implements Parcelable { private static final String ALLOW_ATT_SCREEN_ON = "visualScreenOn"; private static final String DISALLOW_TAG = "disallow"; private static final String DISALLOW_ATT_VISUAL_EFFECTS = "visualEffects"; private static final String STATE_TAG = "state"; private static final String STATE_ATT_CHANNELS_BYPASSING_DND = "areChannelsBypassingDnd"; private static final String CONDITION_ATT_ID = "id"; private static final String CONDITION_ATT_SUMMARY = "summary"; Loading Loading @@ -154,6 +157,7 @@ public class ZenModeConfig implements Parcelable { public int suppressedVisualEffects = DEFAULT_SUPPRESSED_VISUAL_EFFECTS; public boolean allowWhenScreenOff = DEFAULT_ALLOW_SCREEN_OFF; public boolean allowWhenScreenOn = DEFAULT_ALLOW_SCREEN_ON; public boolean areChannelsBypassingDnd = DEFAULT_CHANNELS_BYPASSING_DND; public int version; public ZenRule manualRule; Loading Loading @@ -187,6 +191,7 @@ public class ZenModeConfig implements Parcelable { allowMedia = source.readInt() == 1; allowSystem = source.readInt() == 1; suppressedVisualEffects = source.readInt(); areChannelsBypassingDnd = source.readInt() == 1; } @Override Loading Loading @@ -220,6 +225,7 @@ public class ZenModeConfig implements Parcelable { dest.writeInt(allowMedia ? 1 : 0); dest.writeInt(allowSystem ? 1 : 0); dest.writeInt(suppressedVisualEffects); dest.writeInt(areChannelsBypassingDnd ? 1 : 0); } @Override Loading @@ -239,6 +245,7 @@ public class ZenModeConfig implements Parcelable { .append(",allowWhenScreenOff=").append(allowWhenScreenOff) .append(",allowWhenScreenOn=").append(allowWhenScreenOn) .append(",suppressedVisualEffects=").append(suppressedVisualEffects) .append(",areChannelsBypassingDnd=").append(areChannelsBypassingDnd) .append(",automaticRules=").append(automaticRules) .append(",manualRule=").append(manualRule) .append(']').toString(); Loading Loading @@ -303,6 +310,11 @@ public class ZenModeConfig implements Parcelable { ZenRule.appendDiff(d, "automaticRule[" + rule + "]", fromRule, toRule); } ZenRule.appendDiff(d, "manualRule", manualRule, to.manualRule); if (areChannelsBypassingDnd != to.areChannelsBypassingDnd) { d.addLine("areChannelsBypassingDnd", areChannelsBypassingDnd, to.areChannelsBypassingDnd); } return d; } Loading Loading @@ -397,7 +409,8 @@ public class ZenModeConfig implements Parcelable { && other.user == user && Objects.equals(other.automaticRules, automaticRules) && Objects.equals(other.manualRule, manualRule) && other.suppressedVisualEffects == suppressedVisualEffects; && other.suppressedVisualEffects == suppressedVisualEffects && other.areChannelsBypassingDnd == areChannelsBypassingDnd; } @Override Loading @@ -406,7 +419,7 @@ public class ZenModeConfig implements Parcelable { allowRepeatCallers, allowMessages, allowCallsFrom, allowMessagesFrom, allowReminders, allowEvents, allowWhenScreenOff, allowWhenScreenOn, user, automaticRules, manualRule, suppressedVisualEffects); suppressedVisualEffects, areChannelsBypassingDnd); } private static String toDayList(int[] days) { Loading Loading @@ -511,6 +524,9 @@ public class ZenModeConfig implements Parcelable { automaticRule.id = id; rt.automaticRules.put(id, automaticRule); } } else if (STATE_TAG.equals(tag)) { rt.areChannelsBypassingDnd = safeBoolean(parser, STATE_ATT_CHANNELS_BYPASSING_DND, DEFAULT_CHANNELS_BYPASSING_DND); } } } Loading Loading @@ -561,6 +577,12 @@ public class ZenModeConfig implements Parcelable { writeRuleXml(automaticRule, out); out.endTag(null, AUTOMATIC_TAG); } out.startTag(null, STATE_TAG); out.attribute(null, STATE_ATT_CHANNELS_BYPASSING_DND, Boolean.toString(areChannelsBypassingDnd)); out.endTag(null, STATE_TAG); out.endTag(null, ZEN_TAG); } Loading Loading @@ -743,7 +765,8 @@ public class ZenModeConfig implements Parcelable { priorityCallSenders = sourceToPrioritySenders(allowCallsFrom, priorityCallSenders); priorityMessageSenders = sourceToPrioritySenders(allowMessagesFrom, priorityMessageSenders); return new Policy(priorityCategories, priorityCallSenders, priorityMessageSenders, suppressedVisualEffects); suppressedVisualEffects, areChannelsBypassingDnd ? Policy.STATE_CHANNELS_BYPASSING_DND : 0); } /** Loading Loading @@ -795,6 +818,9 @@ public class ZenModeConfig implements Parcelable { if (policy.suppressedVisualEffects != Policy.SUPPRESSED_EFFECTS_UNSET) { suppressedVisualEffects = policy.suppressedVisualEffects; } if (policy.state != Policy.STATE_UNSET) { areChannelsBypassingDnd = (policy.state & Policy.STATE_CHANNELS_BYPASSING_DND) != 0; } } public static Condition toTimeCondition(Context context, int minutesFromNow, int userHandle) { Loading Loading @@ -1465,15 +1491,15 @@ public class ZenModeConfig implements Parcelable { & NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS) != 0; boolean allowRepeatCallers = (policy.priorityCategories & NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS) != 0; boolean areChannelsBypassingDnd = (policy.state & Policy.STATE_CHANNELS_BYPASSING_DND) != 0; return !allowReminders && !allowCalls && !allowMessages && !allowEvents && !allowRepeatCallers; && !allowRepeatCallers && !areChannelsBypassingDnd; } /** * Determines if DND is currently overriding the ringer */ public static boolean isZenOverridingRinger(int zen, ZenModeConfig zenConfig) { // TODO (beverlyt): check if apps can bypass dnd b/77729075 return zen == Global.ZEN_MODE_NO_INTERRUPTIONS || zen == Global.ZEN_MODE_ALARMS || (zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS Loading @@ -1485,7 +1511,8 @@ public class ZenModeConfig implements Parcelable { */ public static boolean areAllPriorityOnlyNotificationZenSoundsMuted(ZenModeConfig config) { return !config.allowReminders && !config.allowCalls && !config.allowMessages && !config.allowEvents && !config.allowRepeatCallers; && !config.allowEvents && !config.allowRepeatCallers && !config.areChannelsBypassingDnd; } /** Loading core/res/res/xml/default_zen_mode_config.xml +6 −2 Original line number Diff line number Diff line Loading @@ -19,8 +19,12 @@ <!-- Default configuration for zen mode. See android.service.notification.ZenModeConfig. --> <zen version="7"> <allow alarms="true" media="true" system="false" calls="false" messages="false" reminders="false" events="false" /> <allow alarms="true" media="true" system="false" calls="false" messages="false" reminders="false" events="false" /> <!-- all visual effects that exist as of P --> <disallow suppressedVisualEffect="511" /> <!-- whether there are notification channels that can bypass dnd --> <state areChannelsBypassingDnd="false" /> </zen> services/core/java/com/android/server/notification/NotificationManagerService.java +5 −1 Original line number Diff line number Diff line Loading @@ -2399,6 +2399,11 @@ public class NotificationManagerService extends SystemService { return mRankingHelper.getBlockedAppCount(userId); } @Override public boolean areChannelsBypassingDnd() { return mRankingHelper.areChannelsBypassingDnd(); } @Override public void clearData(String packageName, int uid, boolean fromApp) throws RemoteException { checkCallerIsSystem(); Loading Loading @@ -3281,7 +3286,6 @@ public class NotificationManagerService extends SystemService { policy = new Policy(policy.priorityCategories, policy.priorityCallSenders, policy.priorityMessageSenders, newVisualEffects); ZenLog.traceSetNotificationPolicy(pkg, applicationInfo.targetSdkVersion, policy); mZenModeHelper.setNotificationPolicy(policy); } catch (RemoteException e) { Loading Loading
core/java/android/app/INotificationManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ interface INotificationManager boolean onlyHasDefaultChannel(String pkg, int uid); ParceledListSlice getRecentNotifyingAppsForUser(int userId); int getBlockedAppCount(int userId); boolean areChannelsBypassingDnd(); // TODO: Remove this when callers have been migrated to the equivalent // INotificationListener method. Loading
core/java/android/app/NotificationManager.java +34 −2 Original line number Diff line number Diff line Loading @@ -1167,6 +1167,23 @@ public class NotificationManager { */ public final int suppressedVisualEffects; /** * @hide */ public static final int STATE_CHANNELS_BYPASSING_DND = 1 << 0; /** * @hide */ public static final int STATE_UNSET = -1; /** * Notification state information that is necessary to determine Do Not Disturb behavior. * Bitmask of STATE_* constants. * @hide */ public final int state; /** * Constructs a policy for Do Not Disturb priority mode behavior. * Loading @@ -1182,7 +1199,7 @@ public class NotificationManager { */ public Policy(int priorityCategories, int priorityCallSenders, int priorityMessageSenders) { this(priorityCategories, priorityCallSenders, priorityMessageSenders, SUPPRESSED_EFFECTS_UNSET); SUPPRESSED_EFFECTS_UNSET, STATE_UNSET); } /** Loading Loading @@ -1220,11 +1237,23 @@ public class NotificationManager { this.priorityCallSenders = priorityCallSenders; this.priorityMessageSenders = priorityMessageSenders; this.suppressedVisualEffects = suppressedVisualEffects; this.state = STATE_UNSET; } /** @hide */ public Policy(int priorityCategories, int priorityCallSenders, int priorityMessageSenders, int suppressedVisualEffects, int state) { this.priorityCategories = priorityCategories; this.priorityCallSenders = priorityCallSenders; this.priorityMessageSenders = priorityMessageSenders; this.suppressedVisualEffects = suppressedVisualEffects; this.state = state; } /** @hide */ public Policy(Parcel source) { this(source.readInt(), source.readInt(), source.readInt(), source.readInt()); this(source.readInt(), source.readInt(), source.readInt(), source.readInt(), source.readInt()); } @Override Loading @@ -1233,6 +1262,7 @@ public class NotificationManager { dest.writeInt(priorityCallSenders); dest.writeInt(priorityMessageSenders); dest.writeInt(suppressedVisualEffects); dest.writeInt(state); } @Override Loading Loading @@ -1265,6 +1295,8 @@ public class NotificationManager { + ",priorityMessageSenders=" + prioritySendersToString(priorityMessageSenders) + ",suppressedVisualEffects=" + suppressedEffectsToString(suppressedVisualEffects) + ",areChannelsBypassingDnd=" + (((state & STATE_CHANNELS_BYPASSING_DND) != 0) ? "true" : "false") + "]"; } Loading
core/java/android/service/notification/ZenModeConfig.java +33 −6 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ public class ZenModeConfig implements Parcelable { private static final boolean DEFAULT_ALLOW_REPEAT_CALLERS = false; private static final boolean DEFAULT_ALLOW_SCREEN_OFF = false; private static final boolean DEFAULT_ALLOW_SCREEN_ON = false; private static final boolean DEFAULT_CHANNELS_BYPASSING_DND = false; private static final int DEFAULT_SUPPRESSED_VISUAL_EFFECTS = Policy.getAllSuppressedVisualEffects(); Loading @@ -118,6 +119,8 @@ public class ZenModeConfig implements Parcelable { private static final String ALLOW_ATT_SCREEN_ON = "visualScreenOn"; private static final String DISALLOW_TAG = "disallow"; private static final String DISALLOW_ATT_VISUAL_EFFECTS = "visualEffects"; private static final String STATE_TAG = "state"; private static final String STATE_ATT_CHANNELS_BYPASSING_DND = "areChannelsBypassingDnd"; private static final String CONDITION_ATT_ID = "id"; private static final String CONDITION_ATT_SUMMARY = "summary"; Loading Loading @@ -154,6 +157,7 @@ public class ZenModeConfig implements Parcelable { public int suppressedVisualEffects = DEFAULT_SUPPRESSED_VISUAL_EFFECTS; public boolean allowWhenScreenOff = DEFAULT_ALLOW_SCREEN_OFF; public boolean allowWhenScreenOn = DEFAULT_ALLOW_SCREEN_ON; public boolean areChannelsBypassingDnd = DEFAULT_CHANNELS_BYPASSING_DND; public int version; public ZenRule manualRule; Loading Loading @@ -187,6 +191,7 @@ public class ZenModeConfig implements Parcelable { allowMedia = source.readInt() == 1; allowSystem = source.readInt() == 1; suppressedVisualEffects = source.readInt(); areChannelsBypassingDnd = source.readInt() == 1; } @Override Loading Loading @@ -220,6 +225,7 @@ public class ZenModeConfig implements Parcelable { dest.writeInt(allowMedia ? 1 : 0); dest.writeInt(allowSystem ? 1 : 0); dest.writeInt(suppressedVisualEffects); dest.writeInt(areChannelsBypassingDnd ? 1 : 0); } @Override Loading @@ -239,6 +245,7 @@ public class ZenModeConfig implements Parcelable { .append(",allowWhenScreenOff=").append(allowWhenScreenOff) .append(",allowWhenScreenOn=").append(allowWhenScreenOn) .append(",suppressedVisualEffects=").append(suppressedVisualEffects) .append(",areChannelsBypassingDnd=").append(areChannelsBypassingDnd) .append(",automaticRules=").append(automaticRules) .append(",manualRule=").append(manualRule) .append(']').toString(); Loading Loading @@ -303,6 +310,11 @@ public class ZenModeConfig implements Parcelable { ZenRule.appendDiff(d, "automaticRule[" + rule + "]", fromRule, toRule); } ZenRule.appendDiff(d, "manualRule", manualRule, to.manualRule); if (areChannelsBypassingDnd != to.areChannelsBypassingDnd) { d.addLine("areChannelsBypassingDnd", areChannelsBypassingDnd, to.areChannelsBypassingDnd); } return d; } Loading Loading @@ -397,7 +409,8 @@ public class ZenModeConfig implements Parcelable { && other.user == user && Objects.equals(other.automaticRules, automaticRules) && Objects.equals(other.manualRule, manualRule) && other.suppressedVisualEffects == suppressedVisualEffects; && other.suppressedVisualEffects == suppressedVisualEffects && other.areChannelsBypassingDnd == areChannelsBypassingDnd; } @Override Loading @@ -406,7 +419,7 @@ public class ZenModeConfig implements Parcelable { allowRepeatCallers, allowMessages, allowCallsFrom, allowMessagesFrom, allowReminders, allowEvents, allowWhenScreenOff, allowWhenScreenOn, user, automaticRules, manualRule, suppressedVisualEffects); suppressedVisualEffects, areChannelsBypassingDnd); } private static String toDayList(int[] days) { Loading Loading @@ -511,6 +524,9 @@ public class ZenModeConfig implements Parcelable { automaticRule.id = id; rt.automaticRules.put(id, automaticRule); } } else if (STATE_TAG.equals(tag)) { rt.areChannelsBypassingDnd = safeBoolean(parser, STATE_ATT_CHANNELS_BYPASSING_DND, DEFAULT_CHANNELS_BYPASSING_DND); } } } Loading Loading @@ -561,6 +577,12 @@ public class ZenModeConfig implements Parcelable { writeRuleXml(automaticRule, out); out.endTag(null, AUTOMATIC_TAG); } out.startTag(null, STATE_TAG); out.attribute(null, STATE_ATT_CHANNELS_BYPASSING_DND, Boolean.toString(areChannelsBypassingDnd)); out.endTag(null, STATE_TAG); out.endTag(null, ZEN_TAG); } Loading Loading @@ -743,7 +765,8 @@ public class ZenModeConfig implements Parcelable { priorityCallSenders = sourceToPrioritySenders(allowCallsFrom, priorityCallSenders); priorityMessageSenders = sourceToPrioritySenders(allowMessagesFrom, priorityMessageSenders); return new Policy(priorityCategories, priorityCallSenders, priorityMessageSenders, suppressedVisualEffects); suppressedVisualEffects, areChannelsBypassingDnd ? Policy.STATE_CHANNELS_BYPASSING_DND : 0); } /** Loading Loading @@ -795,6 +818,9 @@ public class ZenModeConfig implements Parcelable { if (policy.suppressedVisualEffects != Policy.SUPPRESSED_EFFECTS_UNSET) { suppressedVisualEffects = policy.suppressedVisualEffects; } if (policy.state != Policy.STATE_UNSET) { areChannelsBypassingDnd = (policy.state & Policy.STATE_CHANNELS_BYPASSING_DND) != 0; } } public static Condition toTimeCondition(Context context, int minutesFromNow, int userHandle) { Loading Loading @@ -1465,15 +1491,15 @@ public class ZenModeConfig implements Parcelable { & NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS) != 0; boolean allowRepeatCallers = (policy.priorityCategories & NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS) != 0; boolean areChannelsBypassingDnd = (policy.state & Policy.STATE_CHANNELS_BYPASSING_DND) != 0; return !allowReminders && !allowCalls && !allowMessages && !allowEvents && !allowRepeatCallers; && !allowRepeatCallers && !areChannelsBypassingDnd; } /** * Determines if DND is currently overriding the ringer */ public static boolean isZenOverridingRinger(int zen, ZenModeConfig zenConfig) { // TODO (beverlyt): check if apps can bypass dnd b/77729075 return zen == Global.ZEN_MODE_NO_INTERRUPTIONS || zen == Global.ZEN_MODE_ALARMS || (zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS Loading @@ -1485,7 +1511,8 @@ public class ZenModeConfig implements Parcelable { */ public static boolean areAllPriorityOnlyNotificationZenSoundsMuted(ZenModeConfig config) { return !config.allowReminders && !config.allowCalls && !config.allowMessages && !config.allowEvents && !config.allowRepeatCallers; && !config.allowEvents && !config.allowRepeatCallers && !config.areChannelsBypassingDnd; } /** Loading
core/res/res/xml/default_zen_mode_config.xml +6 −2 Original line number Diff line number Diff line Loading @@ -19,8 +19,12 @@ <!-- Default configuration for zen mode. See android.service.notification.ZenModeConfig. --> <zen version="7"> <allow alarms="true" media="true" system="false" calls="false" messages="false" reminders="false" events="false" /> <allow alarms="true" media="true" system="false" calls="false" messages="false" reminders="false" events="false" /> <!-- all visual effects that exist as of P --> <disallow suppressedVisualEffect="511" /> <!-- whether there are notification channels that can bypass dnd --> <state areChannelsBypassingDnd="false" /> </zen>
services/core/java/com/android/server/notification/NotificationManagerService.java +5 −1 Original line number Diff line number Diff line Loading @@ -2399,6 +2399,11 @@ public class NotificationManagerService extends SystemService { return mRankingHelper.getBlockedAppCount(userId); } @Override public boolean areChannelsBypassingDnd() { return mRankingHelper.areChannelsBypassingDnd(); } @Override public void clearData(String packageName, int uid, boolean fromApp) throws RemoteException { checkCallerIsSystem(); Loading Loading @@ -3281,7 +3286,6 @@ public class NotificationManagerService extends SystemService { policy = new Policy(policy.priorityCategories, policy.priorityCallSenders, policy.priorityMessageSenders, newVisualEffects); ZenLog.traceSetNotificationPolicy(pkg, applicationInfo.targetSdkVersion, policy); mZenModeHelper.setNotificationPolicy(policy); } catch (RemoteException e) { Loading