Merge "System sounds get its own dnd toggle" into pi-dev
am: 5a169cf2f6
Change-Id: Ie4b15e59d2f9ab16842af48ef07fc85191330a1a
This commit is contained in:
@@ -5745,10 +5745,11 @@ package android.app {
|
|||||||
field public static final int PRIORITY_CATEGORY_ALARMS = 32; // 0x20
|
field public static final int PRIORITY_CATEGORY_ALARMS = 32; // 0x20
|
||||||
field public static final int PRIORITY_CATEGORY_CALLS = 8; // 0x8
|
field public static final int PRIORITY_CATEGORY_CALLS = 8; // 0x8
|
||||||
field public static final int PRIORITY_CATEGORY_EVENTS = 2; // 0x2
|
field public static final int PRIORITY_CATEGORY_EVENTS = 2; // 0x2
|
||||||
field public static final int PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER = 64; // 0x40
|
field public static final int PRIORITY_CATEGORY_MEDIA = 64; // 0x40
|
||||||
field public static final int PRIORITY_CATEGORY_MESSAGES = 4; // 0x4
|
field public static final int PRIORITY_CATEGORY_MESSAGES = 4; // 0x4
|
||||||
field public static final int PRIORITY_CATEGORY_REMINDERS = 1; // 0x1
|
field public static final int PRIORITY_CATEGORY_REMINDERS = 1; // 0x1
|
||||||
field public static final int PRIORITY_CATEGORY_REPEAT_CALLERS = 16; // 0x10
|
field public static final int PRIORITY_CATEGORY_REPEAT_CALLERS = 16; // 0x10
|
||||||
|
field public static final int PRIORITY_CATEGORY_SYSTEM = 128; // 0x80
|
||||||
field public static final int PRIORITY_SENDERS_ANY = 0; // 0x0
|
field public static final int PRIORITY_SENDERS_ANY = 0; // 0x0
|
||||||
field public static final int PRIORITY_SENDERS_CONTACTS = 1; // 0x1
|
field public static final int PRIORITY_SENDERS_CONTACTS = 1; // 0x1
|
||||||
field public static final int PRIORITY_SENDERS_STARRED = 2; // 0x2
|
field public static final int PRIORITY_SENDERS_STARRED = 2; // 0x2
|
||||||
|
|||||||
@@ -1031,12 +1031,18 @@ public class NotificationManager {
|
|||||||
public static final int PRIORITY_CATEGORY_REPEAT_CALLERS = 1 << 4;
|
public static final int PRIORITY_CATEGORY_REPEAT_CALLERS = 1 << 4;
|
||||||
/** Alarms are prioritized */
|
/** Alarms are prioritized */
|
||||||
public static final int PRIORITY_CATEGORY_ALARMS = 1 << 5;
|
public static final int PRIORITY_CATEGORY_ALARMS = 1 << 5;
|
||||||
/** Media, system, game (catch-all for non-never suppressible sounds) are prioritized */
|
/** Media, game, voice navigation are prioritized */
|
||||||
public static final int PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER = 1 << 6;
|
public static final int PRIORITY_CATEGORY_MEDIA = 1 << 6;
|
||||||
|
/**System (catch-all for non-never suppressible sounds) are prioritized */
|
||||||
|
public static final int PRIORITY_CATEGORY_SYSTEM = 1 << 7;
|
||||||
|
|
||||||
private static final int[] ALL_PRIORITY_CATEGORIES = {
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final int[] ALL_PRIORITY_CATEGORIES = {
|
||||||
PRIORITY_CATEGORY_ALARMS,
|
PRIORITY_CATEGORY_ALARMS,
|
||||||
PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER,
|
PRIORITY_CATEGORY_MEDIA,
|
||||||
|
PRIORITY_CATEGORY_SYSTEM,
|
||||||
PRIORITY_CATEGORY_REMINDERS,
|
PRIORITY_CATEGORY_REMINDERS,
|
||||||
PRIORITY_CATEGORY_EVENTS,
|
PRIORITY_CATEGORY_EVENTS,
|
||||||
PRIORITY_CATEGORY_MESSAGES,
|
PRIORITY_CATEGORY_MESSAGES,
|
||||||
@@ -1237,8 +1243,8 @@ public class NotificationManager {
|
|||||||
case PRIORITY_CATEGORY_CALLS: return "PRIORITY_CATEGORY_CALLS";
|
case PRIORITY_CATEGORY_CALLS: return "PRIORITY_CATEGORY_CALLS";
|
||||||
case PRIORITY_CATEGORY_REPEAT_CALLERS: return "PRIORITY_CATEGORY_REPEAT_CALLERS";
|
case PRIORITY_CATEGORY_REPEAT_CALLERS: return "PRIORITY_CATEGORY_REPEAT_CALLERS";
|
||||||
case PRIORITY_CATEGORY_ALARMS: return "PRIORITY_CATEGORY_ALARMS";
|
case PRIORITY_CATEGORY_ALARMS: return "PRIORITY_CATEGORY_ALARMS";
|
||||||
case PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER:
|
case PRIORITY_CATEGORY_MEDIA: return "PRIORITY_CATEGORY_MEDIA";
|
||||||
return "PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER";
|
case PRIORITY_CATEGORY_SYSTEM: return "PRIORITY_CATEGORY_SYSTEM";
|
||||||
default: return "PRIORITY_CATEGORY_UNKNOWN_" + priorityCategory;
|
default: return "PRIORITY_CATEGORY_UNKNOWN_" + priorityCategory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
|
|
||||||
private NotificationManager.Policy mNotificationPolicy;
|
private NotificationManager.Policy mNotificationPolicy;
|
||||||
private boolean mAllowAlarms;
|
private boolean mAllowAlarms;
|
||||||
private boolean mAllowMediaSystem;
|
private boolean mAllowMedia;
|
||||||
private boolean mAllowRinger;
|
private boolean mAllowRinger;
|
||||||
|
|
||||||
public SeekBarVolumizer(Context context, int streamType, Uri defaultUri, Callback callback) {
|
public SeekBarVolumizer(Context context, int streamType, Uri defaultUri, Callback callback) {
|
||||||
@@ -100,8 +100,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
mNotificationPolicy = mNotificationManager.getNotificationPolicy();
|
mNotificationPolicy = mNotificationManager.getNotificationPolicy();
|
||||||
mAllowAlarms = (mNotificationPolicy.priorityCategories & NotificationManager.Policy
|
mAllowAlarms = (mNotificationPolicy.priorityCategories & NotificationManager.Policy
|
||||||
.PRIORITY_CATEGORY_ALARMS) != 0;
|
.PRIORITY_CATEGORY_ALARMS) != 0;
|
||||||
mAllowMediaSystem = (mNotificationPolicy.priorityCategories & NotificationManager.Policy
|
mAllowMedia = (mNotificationPolicy.priorityCategories & NotificationManager.Policy
|
||||||
.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) != 0;
|
.PRIORITY_CATEGORY_MEDIA) != 0;
|
||||||
mAllowRinger = !ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(
|
mAllowRinger = !ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(
|
||||||
mNotificationPolicy);
|
mNotificationPolicy);
|
||||||
mStreamType = streamType;
|
mStreamType = streamType;
|
||||||
@@ -139,8 +139,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
return stream == AudioManager.STREAM_ALARM;
|
return stream == AudioManager.STREAM_ALARM;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isMediaOrSystemStream(int stream) {
|
private static boolean isMediaStream(int stream) {
|
||||||
return stream == AudioManager.STREAM_MUSIC || stream == AudioManager.STREAM_SYSTEM;
|
return stream == AudioManager.STREAM_MUSIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSeekBar(SeekBar seekBar) {
|
public void setSeekBar(SeekBar seekBar) {
|
||||||
@@ -159,7 +159,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
|| mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS
|
|| mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS
|
||||||
|| (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
|
|| (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
|
||||||
&& ((!mAllowAlarms && isAlarmsStream(mStreamType))
|
&& ((!mAllowAlarms && isAlarmsStream(mStreamType))
|
||||||
|| (!mAllowMediaSystem && isMediaOrSystemStream(mStreamType))
|
|| (!mAllowMedia && isMediaStream(mStreamType))
|
||||||
|| (!mAllowRinger && isNotificationOrRing(mStreamType))));
|
|| (!mAllowRinger && isNotificationOrRing(mStreamType))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,8 +454,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
mNotificationPolicy = mNotificationManager.getNotificationPolicy();
|
mNotificationPolicy = mNotificationManager.getNotificationPolicy();
|
||||||
mAllowAlarms = (mNotificationPolicy.priorityCategories & NotificationManager.Policy
|
mAllowAlarms = (mNotificationPolicy.priorityCategories & NotificationManager.Policy
|
||||||
.PRIORITY_CATEGORY_ALARMS) != 0;
|
.PRIORITY_CATEGORY_ALARMS) != 0;
|
||||||
mAllowMediaSystem = (mNotificationPolicy.priorityCategories
|
mAllowMedia = (mNotificationPolicy.priorityCategories
|
||||||
& NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) != 0;
|
& NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA) != 0;
|
||||||
mAllowRinger = !ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(
|
mAllowRinger = !ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(
|
||||||
mNotificationPolicy);
|
mNotificationPolicy);
|
||||||
updateSlider();
|
updateSlider();
|
||||||
|
|||||||
@@ -3132,7 +3132,7 @@ public final class Settings {
|
|||||||
public static final String ALWAYS_FINISH_ACTIVITIES = Global.ALWAYS_FINISH_ACTIVITIES;
|
public static final String ALWAYS_FINISH_ACTIVITIES = Global.ALWAYS_FINISH_ACTIVITIES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines which streams are affected by ringer mode changes. The
|
* Determines which streams are affected by ringer and zen mode changes. The
|
||||||
* stream type's bit should be set to 1 if it should be muted when going
|
* stream type's bit should be set to 1 if it should be muted when going
|
||||||
* into an inaudible ringer mode.
|
* into an inaudible ringer mode.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
|
|
||||||
// Default allow categories set in readXml() from default_zen_mode_config.xml, fallback values:
|
// Default allow categories set in readXml() from default_zen_mode_config.xml, fallback values:
|
||||||
private static final boolean DEFAULT_ALLOW_ALARMS = true;
|
private static final boolean DEFAULT_ALLOW_ALARMS = true;
|
||||||
private static final boolean DEFAULT_ALLOW_MEDIA_SYSTEM_OTHER = true;
|
private static final boolean DEFAULT_ALLOW_MEDIA = true;
|
||||||
|
private static final boolean DEFAULT_ALLOW_SYSTEM = false;
|
||||||
private static final boolean DEFAULT_ALLOW_CALLS = false;
|
private static final boolean DEFAULT_ALLOW_CALLS = false;
|
||||||
private static final boolean DEFAULT_ALLOW_MESSAGES = false;
|
private static final boolean DEFAULT_ALLOW_MESSAGES = false;
|
||||||
private static final boolean DEFAULT_ALLOW_REMINDERS = false;
|
private static final boolean DEFAULT_ALLOW_REMINDERS = false;
|
||||||
@@ -94,13 +95,14 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
private static final boolean DEFAULT_ALLOW_SCREEN_OFF = true;
|
private static final boolean DEFAULT_ALLOW_SCREEN_OFF = true;
|
||||||
private static final boolean DEFAULT_ALLOW_SCREEN_ON = true;
|
private static final boolean DEFAULT_ALLOW_SCREEN_ON = true;
|
||||||
|
|
||||||
public static final int XML_VERSION = 3;
|
public static final int XML_VERSION = 4;
|
||||||
public static final String ZEN_TAG = "zen";
|
public static final String ZEN_TAG = "zen";
|
||||||
private static final String ZEN_ATT_VERSION = "version";
|
private static final String ZEN_ATT_VERSION = "version";
|
||||||
private static final String ZEN_ATT_USER = "user";
|
private static final String ZEN_ATT_USER = "user";
|
||||||
private static final String ALLOW_TAG = "allow";
|
private static final String ALLOW_TAG = "allow";
|
||||||
private static final String ALLOW_ATT_ALARMS = "alarms";
|
private static final String ALLOW_ATT_ALARMS = "alarms";
|
||||||
private static final String ALLOW_ATT_MEDIA_SYSTEM_OTHER = "media_system_other";
|
private static final String ALLOW_ATT_MEDIA = "media";
|
||||||
|
private static final String ALLOW_ATT_SYSTEM = "system";
|
||||||
private static final String ALLOW_ATT_CALLS = "calls";
|
private static final String ALLOW_ATT_CALLS = "calls";
|
||||||
private static final String ALLOW_ATT_REPEAT_CALLERS = "repeatCallers";
|
private static final String ALLOW_ATT_REPEAT_CALLERS = "repeatCallers";
|
||||||
private static final String ALLOW_ATT_MESSAGES = "messages";
|
private static final String ALLOW_ATT_MESSAGES = "messages";
|
||||||
@@ -134,7 +136,8 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
private static final String RULE_ATT_ENABLER = "enabler";
|
private static final String RULE_ATT_ENABLER = "enabler";
|
||||||
|
|
||||||
public boolean allowAlarms = DEFAULT_ALLOW_ALARMS;
|
public boolean allowAlarms = DEFAULT_ALLOW_ALARMS;
|
||||||
public boolean allowMediaSystemOther = DEFAULT_ALLOW_MEDIA_SYSTEM_OTHER;
|
public boolean allowMedia = DEFAULT_ALLOW_MEDIA;
|
||||||
|
public boolean allowSystem = DEFAULT_ALLOW_SYSTEM;
|
||||||
public boolean allowCalls = DEFAULT_ALLOW_CALLS;
|
public boolean allowCalls = DEFAULT_ALLOW_CALLS;
|
||||||
public boolean allowRepeatCallers = DEFAULT_ALLOW_REPEAT_CALLERS;
|
public boolean allowRepeatCallers = DEFAULT_ALLOW_REPEAT_CALLERS;
|
||||||
public boolean allowMessages = DEFAULT_ALLOW_MESSAGES;
|
public boolean allowMessages = DEFAULT_ALLOW_MESSAGES;
|
||||||
@@ -175,7 +178,8 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
allowWhenScreenOff = source.readInt() == 1;
|
allowWhenScreenOff = source.readInt() == 1;
|
||||||
allowWhenScreenOn = source.readInt() == 1;
|
allowWhenScreenOn = source.readInt() == 1;
|
||||||
allowAlarms = source.readInt() == 1;
|
allowAlarms = source.readInt() == 1;
|
||||||
allowMediaSystemOther = source.readInt() == 1;
|
allowMedia = source.readInt() == 1;
|
||||||
|
allowSystem = source.readInt() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -206,7 +210,8 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
dest.writeInt(allowWhenScreenOff ? 1 : 0);
|
dest.writeInt(allowWhenScreenOff ? 1 : 0);
|
||||||
dest.writeInt(allowWhenScreenOn ? 1 : 0);
|
dest.writeInt(allowWhenScreenOn ? 1 : 0);
|
||||||
dest.writeInt(allowAlarms ? 1 : 0);
|
dest.writeInt(allowAlarms ? 1 : 0);
|
||||||
dest.writeInt(allowMediaSystemOther ? 1 : 0);
|
dest.writeInt(allowMedia ? 1 : 0);
|
||||||
|
dest.writeInt(allowSystem ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -214,7 +219,8 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
return new StringBuilder(ZenModeConfig.class.getSimpleName()).append('[')
|
return new StringBuilder(ZenModeConfig.class.getSimpleName()).append('[')
|
||||||
.append("user=").append(user)
|
.append("user=").append(user)
|
||||||
.append(",allowAlarms=").append(allowAlarms)
|
.append(",allowAlarms=").append(allowAlarms)
|
||||||
.append(",allowMediaSystemOther=").append(allowMediaSystemOther)
|
.append(",allowMedia=").append(allowMedia)
|
||||||
|
.append(",allowSystem=").append(allowSystem)
|
||||||
.append(",allowReminders=").append(allowReminders)
|
.append(",allowReminders=").append(allowReminders)
|
||||||
.append(",allowEvents=").append(allowEvents)
|
.append(",allowEvents=").append(allowEvents)
|
||||||
.append(",allowCalls=").append(allowCalls)
|
.append(",allowCalls=").append(allowCalls)
|
||||||
@@ -240,8 +246,11 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
if (allowAlarms != to.allowAlarms) {
|
if (allowAlarms != to.allowAlarms) {
|
||||||
d.addLine("allowAlarms", allowAlarms, to.allowAlarms);
|
d.addLine("allowAlarms", allowAlarms, to.allowAlarms);
|
||||||
}
|
}
|
||||||
if (allowMediaSystemOther != to.allowMediaSystemOther) {
|
if (allowMedia != to.allowMedia) {
|
||||||
d.addLine("allowMediaSystemOther", allowMediaSystemOther, to.allowMediaSystemOther);
|
d.addLine("allowMedia", allowMedia, to.allowMedia);
|
||||||
|
}
|
||||||
|
if (allowSystem != to.allowSystem) {
|
||||||
|
d.addLine("allowSystem", allowSystem, to.allowSystem);
|
||||||
}
|
}
|
||||||
if (allowCalls != to.allowCalls) {
|
if (allowCalls != to.allowCalls) {
|
||||||
d.addLine("allowCalls", allowCalls, to.allowCalls);
|
d.addLine("allowCalls", allowCalls, to.allowCalls);
|
||||||
@@ -361,7 +370,8 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
final ZenModeConfig other = (ZenModeConfig) o;
|
final ZenModeConfig other = (ZenModeConfig) o;
|
||||||
return other.allowAlarms == allowAlarms
|
return other.allowAlarms == allowAlarms
|
||||||
&& other.allowMediaSystemOther == allowMediaSystemOther
|
&& other.allowMedia == allowMedia
|
||||||
|
&& other.allowSystem == allowSystem
|
||||||
&& other.allowCalls == allowCalls
|
&& other.allowCalls == allowCalls
|
||||||
&& other.allowRepeatCallers == allowRepeatCallers
|
&& other.allowRepeatCallers == allowRepeatCallers
|
||||||
&& other.allowMessages == allowMessages
|
&& other.allowMessages == allowMessages
|
||||||
@@ -378,7 +388,7 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(allowAlarms, allowMediaSystemOther, allowCalls,
|
return Objects.hash(allowAlarms, allowMedia, allowSystem, allowCalls,
|
||||||
allowRepeatCallers, allowMessages,
|
allowRepeatCallers, allowMessages,
|
||||||
allowCallsFrom, allowMessagesFrom, allowReminders, allowEvents,
|
allowCallsFrom, allowMessagesFrom, allowReminders, allowEvents,
|
||||||
allowWhenScreenOff, allowWhenScreenOn, user, automaticRules, manualRule);
|
allowWhenScreenOff, allowWhenScreenOn, user, automaticRules, manualRule);
|
||||||
@@ -469,8 +479,9 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
rt.allowWhenScreenOn =
|
rt.allowWhenScreenOn =
|
||||||
safeBoolean(parser, ALLOW_ATT_SCREEN_ON, DEFAULT_ALLOW_SCREEN_ON);
|
safeBoolean(parser, ALLOW_ATT_SCREEN_ON, DEFAULT_ALLOW_SCREEN_ON);
|
||||||
rt.allowAlarms = safeBoolean(parser, ALLOW_ATT_ALARMS, DEFAULT_ALLOW_ALARMS);
|
rt.allowAlarms = safeBoolean(parser, ALLOW_ATT_ALARMS, DEFAULT_ALLOW_ALARMS);
|
||||||
rt.allowMediaSystemOther = safeBoolean(parser, ALLOW_ATT_MEDIA_SYSTEM_OTHER,
|
rt.allowMedia = safeBoolean(parser, ALLOW_ATT_MEDIA,
|
||||||
DEFAULT_ALLOW_MEDIA_SYSTEM_OTHER);
|
DEFAULT_ALLOW_MEDIA);
|
||||||
|
rt.allowSystem = safeBoolean(parser, ALLOW_ATT_SYSTEM, DEFAULT_ALLOW_SYSTEM);
|
||||||
} else if (MANUAL_TAG.equals(tag)) {
|
} else if (MANUAL_TAG.equals(tag)) {
|
||||||
rt.manualRule = readRuleXml(parser);
|
rt.manualRule = readRuleXml(parser);
|
||||||
} else if (AUTOMATIC_TAG.equals(tag)) {
|
} else if (AUTOMATIC_TAG.equals(tag)) {
|
||||||
@@ -502,7 +513,8 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
out.attribute(null, ALLOW_ATT_SCREEN_OFF, Boolean.toString(allowWhenScreenOff));
|
out.attribute(null, ALLOW_ATT_SCREEN_OFF, Boolean.toString(allowWhenScreenOff));
|
||||||
out.attribute(null, ALLOW_ATT_SCREEN_ON, Boolean.toString(allowWhenScreenOn));
|
out.attribute(null, ALLOW_ATT_SCREEN_ON, Boolean.toString(allowWhenScreenOn));
|
||||||
out.attribute(null, ALLOW_ATT_ALARMS, Boolean.toString(allowAlarms));
|
out.attribute(null, ALLOW_ATT_ALARMS, Boolean.toString(allowAlarms));
|
||||||
out.attribute(null, ALLOW_ATT_MEDIA_SYSTEM_OTHER, Boolean.toString(allowMediaSystemOther));
|
out.attribute(null, ALLOW_ATT_MEDIA, Boolean.toString(allowMedia));
|
||||||
|
out.attribute(null, ALLOW_ATT_SYSTEM, Boolean.toString(allowSystem));
|
||||||
out.endTag(null, ALLOW_TAG);
|
out.endTag(null, ALLOW_TAG);
|
||||||
|
|
||||||
if (manualRule != null) {
|
if (manualRule != null) {
|
||||||
@@ -699,8 +711,11 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
if (allowAlarms) {
|
if (allowAlarms) {
|
||||||
priorityCategories |= Policy.PRIORITY_CATEGORY_ALARMS;
|
priorityCategories |= Policy.PRIORITY_CATEGORY_ALARMS;
|
||||||
}
|
}
|
||||||
if (allowMediaSystemOther) {
|
if (allowMedia) {
|
||||||
priorityCategories |= Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER;
|
priorityCategories |= Policy.PRIORITY_CATEGORY_MEDIA;
|
||||||
|
}
|
||||||
|
if (allowSystem) {
|
||||||
|
priorityCategories |= Policy.PRIORITY_CATEGORY_SYSTEM;
|
||||||
}
|
}
|
||||||
priorityCallSenders = sourceToPrioritySenders(allowCallsFrom, priorityCallSenders);
|
priorityCallSenders = sourceToPrioritySenders(allowCallsFrom, priorityCallSenders);
|
||||||
priorityMessageSenders = sourceToPrioritySenders(allowMessagesFrom, priorityMessageSenders);
|
priorityMessageSenders = sourceToPrioritySenders(allowMessagesFrom, priorityMessageSenders);
|
||||||
@@ -743,8 +758,8 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
public void applyNotificationPolicy(Policy policy) {
|
public void applyNotificationPolicy(Policy policy) {
|
||||||
if (policy == null) return;
|
if (policy == null) return;
|
||||||
allowAlarms = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_ALARMS) != 0;
|
allowAlarms = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_ALARMS) != 0;
|
||||||
allowMediaSystemOther = (policy.priorityCategories
|
allowMedia = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_MEDIA) != 0;
|
||||||
& Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) != 0;
|
allowSystem = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_SYSTEM) != 0;
|
||||||
allowEvents = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_EVENTS) != 0;
|
allowEvents = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_EVENTS) != 0;
|
||||||
allowReminders = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_REMINDERS) != 0;
|
allowReminders = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_REMINDERS) != 0;
|
||||||
allowCalls = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_CALLS) != 0;
|
allowCalls = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_CALLS) != 0;
|
||||||
@@ -1415,7 +1430,8 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether dnd behavior should mute all notification sounds
|
* Determines whether dnd behavior should mute all notification/ringer sounds
|
||||||
|
* (sounds associated with ringer volume discluding system)
|
||||||
*/
|
*/
|
||||||
public static boolean areAllPriorityOnlyNotificationZenSoundsMuted(NotificationManager.Policy
|
public static boolean areAllPriorityOnlyNotificationZenSoundsMuted(NotificationManager.Policy
|
||||||
policy) {
|
policy) {
|
||||||
@@ -1434,7 +1450,7 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether dnd behavior should mute all notification sounds
|
* Determines whether dnd behavior should mute all sounds controlled by ringer
|
||||||
*/
|
*/
|
||||||
public static boolean areAllPriorityOnlyNotificationZenSoundsMuted(ZenModeConfig config) {
|
public static boolean areAllPriorityOnlyNotificationZenSoundsMuted(ZenModeConfig config) {
|
||||||
return !config.allowReminders && !config.allowCalls && !config.allowMessages
|
return !config.allowReminders && !config.allowCalls && !config.allowMessages
|
||||||
@@ -1445,7 +1461,7 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
* Determines whether all dnd mutes all sounds
|
* Determines whether all dnd mutes all sounds
|
||||||
*/
|
*/
|
||||||
public static boolean areAllZenBehaviorSoundsMuted(ZenModeConfig config) {
|
public static boolean areAllZenBehaviorSoundsMuted(ZenModeConfig config) {
|
||||||
return !config.allowAlarms && !config.allowMediaSystemOther
|
return !config.allowAlarms && !config.allowMedia && !config.allowSystem
|
||||||
&& areAllPriorityOnlyNotificationZenSoundsMuted(config);
|
&& areAllPriorityOnlyNotificationZenSoundsMuted(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- Default configuration for zen mode. See android.service.notification.ZenModeConfig. -->
|
<!-- Default configuration for zen mode. See android.service.notification.ZenModeConfig. -->
|
||||||
<zen version="3">
|
<zen version="4">
|
||||||
<allow alarms="true" media_system_other="true" calls="false" messages="false" reminders="false"
|
<allow alarms="true" media="true" system="false" calls="false" messages="false" reminders="false"
|
||||||
events="false" />
|
events="false" />
|
||||||
</zen>
|
</zen>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package android.media;
|
|||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.media.AudioAttributesProto;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@@ -206,19 +205,26 @@ public final class AudioAttributes implements Parcelable {
|
|||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
* Denotes a usage for alarms,
|
* Denotes a usage for alarms,
|
||||||
* will be muted when the Zen mode doesn't allow alarms
|
* will be muted when the Zen mode priority doesn't allow alarms or in Alarms Only Mode
|
||||||
* @see #SUPPRESSIBLE_USAGES
|
* @see #SUPPRESSIBLE_USAGES
|
||||||
*/
|
*/
|
||||||
public final static int SUPPRESSIBLE_ALARM = 4;
|
public final static int SUPPRESSIBLE_ALARM = 4;
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
* Denotes a usage for all other sounds not caught in SUPPRESSIBLE_NOTIFICATION,
|
* Denotes a usage for media, game, assistant, and navigation
|
||||||
* SUPPRESSIBLE_CALL,SUPPRESSIBLE_NEVER or SUPPRESSIBLE_ALARM.
|
* will be muted when the Zen priority mode doesn't allow media
|
||||||
* This includes media, system, game, navigation, the assistant, and more.
|
|
||||||
* These will be muted when the Zen mode doesn't allow media/system/other.
|
|
||||||
* @see #SUPPRESSIBLE_USAGES
|
* @see #SUPPRESSIBLE_USAGES
|
||||||
*/
|
*/
|
||||||
public final static int SUPPRESSIBLE_MEDIA_SYSTEM_OTHER = 5;
|
public final static int SUPPRESSIBLE_MEDIA = 5;
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
* Denotes a usage for all other sounds not caught in SUPPRESSIBLE_NOTIFICATION,
|
||||||
|
* SUPPRESSIBLE_CALL,SUPPRESSIBLE_NEVER, SUPPRESSIBLE_ALARM or SUPPRESSIBLE_MEDIA.
|
||||||
|
* This includes system, sonification and unknown sounds.
|
||||||
|
* These will be muted when the Zen priority mode doesn't allow sytem sounds
|
||||||
|
* @see #SUPPRESSIBLE_USAGES
|
||||||
|
*/
|
||||||
|
public final static int SUPPRESSIBLE_SYSTEM = 6;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
@@ -239,13 +245,13 @@ public final class AudioAttributes implements Parcelable {
|
|||||||
SUPPRESSIBLE_USAGES.put(USAGE_ASSISTANCE_ACCESSIBILITY, SUPPRESSIBLE_NEVER);
|
SUPPRESSIBLE_USAGES.put(USAGE_ASSISTANCE_ACCESSIBILITY, SUPPRESSIBLE_NEVER);
|
||||||
SUPPRESSIBLE_USAGES.put(USAGE_VOICE_COMMUNICATION, SUPPRESSIBLE_NEVER);
|
SUPPRESSIBLE_USAGES.put(USAGE_VOICE_COMMUNICATION, SUPPRESSIBLE_NEVER);
|
||||||
SUPPRESSIBLE_USAGES.put(USAGE_ALARM, SUPPRESSIBLE_ALARM);
|
SUPPRESSIBLE_USAGES.put(USAGE_ALARM, SUPPRESSIBLE_ALARM);
|
||||||
SUPPRESSIBLE_USAGES.put(USAGE_MEDIA, SUPPRESSIBLE_MEDIA_SYSTEM_OTHER);
|
SUPPRESSIBLE_USAGES.put(USAGE_MEDIA, SUPPRESSIBLE_MEDIA);
|
||||||
SUPPRESSIBLE_USAGES.put(USAGE_ASSISTANCE_SONIFICATION, SUPPRESSIBLE_MEDIA_SYSTEM_OTHER);
|
SUPPRESSIBLE_USAGES.put(USAGE_ASSISTANCE_NAVIGATION_GUIDANCE, SUPPRESSIBLE_MEDIA);
|
||||||
SUPPRESSIBLE_USAGES.put(USAGE_ASSISTANCE_NAVIGATION_GUIDANCE, SUPPRESSIBLE_MEDIA_SYSTEM_OTHER);
|
SUPPRESSIBLE_USAGES.put(USAGE_GAME, SUPPRESSIBLE_MEDIA);
|
||||||
SUPPRESSIBLE_USAGES.put(USAGE_GAME, SUPPRESSIBLE_MEDIA_SYSTEM_OTHER);
|
SUPPRESSIBLE_USAGES.put(USAGE_ASSISTANT, SUPPRESSIBLE_MEDIA);
|
||||||
SUPPRESSIBLE_USAGES.put(USAGE_VOICE_COMMUNICATION_SIGNALLING, SUPPRESSIBLE_MEDIA_SYSTEM_OTHER);
|
SUPPRESSIBLE_USAGES.put(USAGE_VOICE_COMMUNICATION_SIGNALLING, SUPPRESSIBLE_SYSTEM);
|
||||||
SUPPRESSIBLE_USAGES.put(USAGE_ASSISTANT, SUPPRESSIBLE_MEDIA_SYSTEM_OTHER);
|
SUPPRESSIBLE_USAGES.put(USAGE_ASSISTANCE_SONIFICATION, SUPPRESSIBLE_SYSTEM);
|
||||||
SUPPRESSIBLE_USAGES.put(USAGE_UNKNOWN, SUPPRESSIBLE_MEDIA_SYSTEM_OTHER);
|
SUPPRESSIBLE_USAGES.put(USAGE_UNKNOWN, SUPPRESSIBLE_SYSTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package android.media;
|
package android.media;
|
||||||
|
|
||||||
import android.annotation.CallbackExecutor;
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
@@ -2099,27 +2098,7 @@ public class AudioManager {
|
|||||||
*/
|
*/
|
||||||
private boolean querySoundEffectsEnabled(int user) {
|
private boolean querySoundEffectsEnabled(int user) {
|
||||||
return Settings.System.getIntForUser(getContext().getContentResolver(),
|
return Settings.System.getIntForUser(getContext().getContentResolver(),
|
||||||
Settings.System.SOUND_EFFECTS_ENABLED, 0, user) != 0
|
Settings.System.SOUND_EFFECTS_ENABLED, 0, user) != 0;
|
||||||
&& !areSystemSoundsZenModeBlocked(getContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean areSystemSoundsZenModeBlocked(Context context) {
|
|
||||||
int zenMode = Settings.Global.getInt(context.getContentResolver(),
|
|
||||||
Settings.Global.ZEN_MODE, 0);
|
|
||||||
|
|
||||||
switch (zenMode) {
|
|
||||||
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
|
|
||||||
case Settings.Global.ZEN_MODE_ALARMS:
|
|
||||||
return true;
|
|
||||||
case Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
|
|
||||||
final NotificationManager noMan = (NotificationManager) context
|
|
||||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
return (noMan.getNotificationPolicy().priorityCategories
|
|
||||||
& NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) == 0;
|
|
||||||
case Settings.Global.ZEN_MODE_OFF:
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ public interface VolumeDialogController {
|
|||||||
public int activeStream = NO_ACTIVE_STREAM;
|
public int activeStream = NO_ACTIVE_STREAM;
|
||||||
public boolean disallowAlarms;
|
public boolean disallowAlarms;
|
||||||
public boolean disallowMedia;
|
public boolean disallowMedia;
|
||||||
|
public boolean disallowSystem;
|
||||||
public boolean disallowRinger;
|
public boolean disallowRinger;
|
||||||
|
|
||||||
public State copy() {
|
public State copy() {
|
||||||
@@ -118,6 +119,7 @@ public interface VolumeDialogController {
|
|||||||
rt.activeStream = activeStream;
|
rt.activeStream = activeStream;
|
||||||
rt.disallowAlarms = disallowAlarms;
|
rt.disallowAlarms = disallowAlarms;
|
||||||
rt.disallowMedia = disallowMedia;
|
rt.disallowMedia = disallowMedia;
|
||||||
|
rt.disallowSystem = disallowSystem;
|
||||||
rt.disallowRinger = disallowRinger;
|
rt.disallowRinger = disallowRinger;
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
@@ -150,6 +152,7 @@ public interface VolumeDialogController {
|
|||||||
sep(sb, indent); sb.append("activeStream:").append(activeStream);
|
sep(sb, indent); sb.append("activeStream:").append(activeStream);
|
||||||
sep(sb, indent); sb.append("disallowAlarms:").append(disallowAlarms);
|
sep(sb, indent); sb.append("disallowAlarms:").append(disallowAlarms);
|
||||||
sep(sb, indent); sb.append("disallowMedia:").append(disallowMedia);
|
sep(sb, indent); sb.append("disallowMedia:").append(disallowMedia);
|
||||||
|
sep(sb, indent); sb.append("disallowSystem:").append(disallowSystem);
|
||||||
sep(sb, indent); sb.append("disallowRinger:").append(disallowRinger);
|
sep(sb, indent); sb.append("disallowRinger:").append(disallowRinger);
|
||||||
if (indent > 0) sep(sb, indent);
|
if (indent > 0) sep(sb, indent);
|
||||||
return sb.append('}').toString();
|
return sb.append('}').toString();
|
||||||
|
|||||||
@@ -1697,8 +1697,6 @@ public class KeyguardViewMediator extends SystemUI {
|
|||||||
mUiOffloadThread.submit(() -> {
|
mUiOffloadThread.submit(() -> {
|
||||||
// If the stream is muted, don't play the sound
|
// If the stream is muted, don't play the sound
|
||||||
if (mAudioManager.isStreamMute(mUiSoundsStreamType)) return;
|
if (mAudioManager.isStreamMute(mUiSoundsStreamType)) return;
|
||||||
// If DND blocks the sound, don't play the sound
|
|
||||||
if (areSystemSoundsZenModeBlocked(mContext)) return;
|
|
||||||
|
|
||||||
int id = mLockSounds.play(soundId,
|
int id = mLockSounds.play(soundId,
|
||||||
mLockSoundVolume, mLockSoundVolume, 1/*priortiy*/, 0/*loop*/, 1.0f/*rate*/);
|
mLockSoundVolume, mLockSoundVolume, 1/*priortiy*/, 0/*loop*/, 1.0f/*rate*/);
|
||||||
@@ -1710,25 +1708,6 @@ public class KeyguardViewMediator extends SystemUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean areSystemSoundsZenModeBlocked(Context context) {
|
|
||||||
int zenMode = Settings.Global.getInt(context.getContentResolver(),
|
|
||||||
Settings.Global.ZEN_MODE, 0);
|
|
||||||
|
|
||||||
switch (zenMode) {
|
|
||||||
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
|
|
||||||
case Settings.Global.ZEN_MODE_ALARMS:
|
|
||||||
return true;
|
|
||||||
case Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
|
|
||||||
final NotificationManager noMan = (NotificationManager) context
|
|
||||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
return (noMan.getNotificationPolicy().priorityCategories
|
|
||||||
& NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) == 0;
|
|
||||||
case Settings.Global.ZEN_MODE_OFF:
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void playTrustedSound() {
|
private void playTrustedSound() {
|
||||||
playSound(mTrustedSoundId);
|
playSound(mTrustedSoundId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -521,18 +521,23 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
boolean disallowAlarms = (policy.priorityCategories & NotificationManager.Policy
|
boolean disallowAlarms = (policy.priorityCategories & NotificationManager.Policy
|
||||||
.PRIORITY_CATEGORY_ALARMS) == 0;
|
.PRIORITY_CATEGORY_ALARMS) == 0;
|
||||||
boolean disallowMedia = (policy.priorityCategories & NotificationManager.Policy
|
boolean disallowMedia = (policy.priorityCategories & NotificationManager.Policy
|
||||||
.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) == 0;
|
.PRIORITY_CATEGORY_MEDIA) == 0;
|
||||||
|
boolean disallowSystem = (policy.priorityCategories & NotificationManager.Policy
|
||||||
|
.PRIORITY_CATEGORY_SYSTEM) == 0;
|
||||||
boolean disallowRinger = ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(policy);
|
boolean disallowRinger = ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(policy);
|
||||||
if (mState.disallowAlarms == disallowAlarms && mState.disallowMedia == disallowMedia
|
if (mState.disallowAlarms == disallowAlarms
|
||||||
&& mState.disallowRinger == disallowRinger) {
|
&& mState.disallowMedia == disallowMedia
|
||||||
|
&& mState.disallowRinger == disallowRinger
|
||||||
|
&& mState.disallowSystem == disallowSystem) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mState.disallowAlarms = disallowAlarms;
|
mState.disallowAlarms = disallowAlarms;
|
||||||
mState.disallowMedia = disallowMedia;
|
mState.disallowMedia = disallowMedia;
|
||||||
|
mState.disallowSystem = disallowSystem;
|
||||||
mState.disallowRinger = disallowRinger;
|
mState.disallowRinger = disallowRinger;
|
||||||
Events.writeEvent(mContext, Events.EVENT_ZEN_CONFIG_CHANGED, "disallowAlarms=" +
|
Events.writeEvent(mContext, Events.EVENT_ZEN_CONFIG_CHANGED, "disallowAlarms=" +
|
||||||
disallowAlarms + " disallowMedia=" + disallowMedia + " disallowRinger=" +
|
disallowAlarms + " disallowMedia=" + disallowMedia + " disallowSystem=" +
|
||||||
disallowRinger);
|
disallowSystem + " disallowRinger=" + disallowRinger);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -691,7 +691,8 @@ public class VolumeDialogImpl implements VolumeDialog {
|
|||||||
: isZenNone ? (isRingStream || isSystemStream || isAlarmStream || isMusicStream)
|
: isZenNone ? (isRingStream || isSystemStream || isAlarmStream || isMusicStream)
|
||||||
: isZenPriorityOnly ? ((isAlarmStream && mState.disallowAlarms) ||
|
: isZenPriorityOnly ? ((isAlarmStream && mState.disallowAlarms) ||
|
||||||
(isMusicStream && mState.disallowMedia) ||
|
(isMusicStream && mState.disallowMedia) ||
|
||||||
(isRingStream && mState.disallowRinger))
|
(isRingStream && mState.disallowRinger) ||
|
||||||
|
(isSystemStream && mState.disallowSystem))
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
// update slider max
|
// update slider max
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ import static android.Manifest.permission.REMOTE_AUDIO_PLAYBACK;
|
|||||||
import static android.media.AudioManager.RINGER_MODE_NORMAL;
|
import static android.media.AudioManager.RINGER_MODE_NORMAL;
|
||||||
import static android.media.AudioManager.RINGER_MODE_SILENT;
|
import static android.media.AudioManager.RINGER_MODE_SILENT;
|
||||||
import static android.media.AudioManager.RINGER_MODE_VIBRATE;
|
import static android.media.AudioManager.RINGER_MODE_VIBRATE;
|
||||||
|
import static android.media.AudioManager.STREAM_ALARM;
|
||||||
|
import static android.media.AudioManager.STREAM_MUSIC;
|
||||||
|
import static android.media.AudioManager.STREAM_SYSTEM;
|
||||||
import static android.os.Process.FIRST_APPLICATION_UID;
|
import static android.os.Process.FIRST_APPLICATION_UID;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
@@ -414,8 +417,10 @@ public class AudioService extends IAudioService.Stub
|
|||||||
/** @see System#MODE_RINGER_STREAMS_AFFECTED */
|
/** @see System#MODE_RINGER_STREAMS_AFFECTED */
|
||||||
private int mRingerModeAffectedStreams = 0;
|
private int mRingerModeAffectedStreams = 0;
|
||||||
|
|
||||||
// Streams currently muted by ringer mode
|
private int mZenModeAffectedStreams = 0;
|
||||||
private int mRingerModeMutedStreams;
|
|
||||||
|
// Streams currently muted by ringer mode and dnd
|
||||||
|
private int mRingerAndZenModeMutedStreams;
|
||||||
|
|
||||||
/** Streams that can be muted. Do not resolve to aliases when checking.
|
/** Streams that can be muted. Do not resolve to aliases when checking.
|
||||||
* @see System#MUTE_STREAMS_AFFECTED */
|
* @see System#MUTE_STREAMS_AFFECTED */
|
||||||
@@ -767,7 +772,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
|
|
||||||
// Call setRingerModeInt() to apply correct mute
|
// Call setRingerModeInt() to apply correct mute
|
||||||
// state on streams affected by ringer mode.
|
// state on streams affected by ringer mode.
|
||||||
mRingerModeMutedStreams = 0;
|
mRingerAndZenModeMutedStreams = 0;
|
||||||
setRingerModeInt(getRingerModeInternal(), false);
|
setRingerModeInt(getRingerModeInternal(), false);
|
||||||
|
|
||||||
// Register for device connection intent broadcasts.
|
// Register for device connection intent broadcasts.
|
||||||
@@ -1278,7 +1283,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
mHasVibrator ? AudioManager.VIBRATE_SETTING_ONLY_SILENT
|
mHasVibrator ? AudioManager.VIBRATE_SETTING_ONLY_SILENT
|
||||||
: AudioManager.VIBRATE_SETTING_OFF);
|
: AudioManager.VIBRATE_SETTING_OFF);
|
||||||
|
|
||||||
updateRingerModeAffectedStreams();
|
updateRingerAndZenModeAffectedStreams();
|
||||||
readDockAudioSettings(cr);
|
readDockAudioSettings(cr);
|
||||||
sendEncodedSurroundMode(cr, "readPersistedSettings");
|
sendEncodedSurroundMode(cr, "readPersistedSettings");
|
||||||
}
|
}
|
||||||
@@ -1529,7 +1534,9 @@ public class AudioService extends IAudioService.Stub
|
|||||||
flags |= AudioManager.FLAG_SHOW_VIBRATE_HINT;
|
flags |= AudioManager.FLAG_SHOW_VIBRATE_HINT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the ringermode is suppressing media, prevent changes
|
|
||||||
|
// If the ringer mode or zen is muting the stream, do not change stream unless
|
||||||
|
// it'll cause us to exit dnd
|
||||||
if (!volumeAdjustmentAllowedByDnd(streamTypeAlias, flags)) {
|
if (!volumeAdjustmentAllowedByDnd(streamTypeAlias, flags)) {
|
||||||
adjustVolume = false;
|
adjustVolume = false;
|
||||||
}
|
}
|
||||||
@@ -1876,18 +1883,19 @@ public class AudioService extends IAudioService.Stub
|
|||||||
sendVolumeUpdate(streamType, oldIndex, index, flags);
|
sendVolumeUpdate(streamType, oldIndex, index, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No ringer affected streams can be changed in total silence mode or priority-only
|
// No ringer or zen muted stream volumes can be changed unless it'll exit dnd
|
||||||
// (with alarms/media toggled off) except those that will cause the device to exit
|
|
||||||
// the mode.
|
|
||||||
private boolean volumeAdjustmentAllowedByDnd(int streamTypeAlias, int flags) {
|
private boolean volumeAdjustmentAllowedByDnd(int streamTypeAlias, int flags) {
|
||||||
if ((mNm.getZenMode() == Settings.Global.ZEN_MODE_NO_INTERRUPTIONS
|
switch (mNm.getZenMode()) {
|
||||||
|| mNm.getZenMode() == Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS)
|
case Settings.Global.ZEN_MODE_OFF:
|
||||||
&& isStreamMutedByRingerMode(streamTypeAlias)) {
|
return true;
|
||||||
if (!(((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||
|
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
|
||||||
(streamTypeAlias == getUiSoundsStreamType()))) {
|
case Settings.Global.ZEN_MODE_ALARMS:
|
||||||
return false;
|
case Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
|
||||||
}
|
return !isStreamMutedByRingerOrZenMode(streamTypeAlias)
|
||||||
|
|| streamTypeAlias == getUiSoundsStreamType()
|
||||||
|
|| (flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2403,9 +2411,9 @@ public class AudioService extends IAudioService.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void muteRingerModeStreams() {
|
private void muteRingerModeStreams() {
|
||||||
// Mute stream if not previously muted by ringer mode and ringer mode
|
// Mute stream if not previously muted by ringer mode and (ringer mode
|
||||||
// is not RINGER_MODE_NORMAL and stream is affected by ringer mode.
|
// is not RINGER_MODE_NORMAL OR stream is zen muted) and stream is affected by ringer mode.
|
||||||
// Unmute stream if previously muted by ringer mode and ringer mode
|
// Unmute stream if previously muted by ringer/zen mode and ringer mode
|
||||||
// is RINGER_MODE_NORMAL or stream is not affected by ringer mode.
|
// is RINGER_MODE_NORMAL or stream is not affected by ringer mode.
|
||||||
int numStreamTypes = AudioSystem.getNumStreamTypes();
|
int numStreamTypes = AudioSystem.getNumStreamTypes();
|
||||||
|
|
||||||
@@ -2413,25 +2421,14 @@ public class AudioService extends IAudioService.Stub
|
|||||||
mNm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
mNm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// in priority only dnd, alarms and media streams can be muted when ringer is not muted
|
|
||||||
boolean isZenPriorityMode = mNm.getZenMode() ==
|
|
||||||
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
|
|
||||||
NotificationManager.Policy zenPolicy = mNm.getNotificationPolicy();
|
|
||||||
boolean muteAlarms = isZenPriorityMode && ((zenPolicy.priorityCategories
|
|
||||||
& NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS) == 0);
|
|
||||||
boolean muteMedia = isZenPriorityMode && ((zenPolicy.priorityCategories
|
|
||||||
& NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) == 0);
|
|
||||||
|
|
||||||
final boolean ringerModeMute = mRingerMode == AudioManager.RINGER_MODE_VIBRATE
|
final boolean ringerModeMute = mRingerMode == AudioManager.RINGER_MODE_VIBRATE
|
||||||
|| mRingerMode == AudioManager.RINGER_MODE_SILENT;
|
|| mRingerMode == AudioManager.RINGER_MODE_SILENT;
|
||||||
|
|
||||||
for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
|
for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
|
||||||
final boolean isMuted = isStreamMutedByRingerMode(streamType);
|
final boolean isMuted = isStreamMutedByRingerOrZenMode(streamType);
|
||||||
|
final boolean shouldZenMute = shouldZenMuteStream(streamType);
|
||||||
final boolean shouldZenMute = (isAlarm(streamType) && muteAlarms)
|
final boolean shouldMute = shouldZenMute || (ringerModeMute
|
||||||
|| (isMedia(streamType) && muteMedia);
|
&& isStreamAffectedByRingerMode(streamType));
|
||||||
final boolean shouldMute = (shouldZenMute || ringerModeMute)
|
|
||||||
&& isStreamAffectedByRingerMode(streamType);
|
|
||||||
if (isMuted == shouldMute) continue;
|
if (isMuted == shouldMute) continue;
|
||||||
if (!shouldMute) {
|
if (!shouldMute) {
|
||||||
// unmute
|
// unmute
|
||||||
@@ -2458,11 +2455,11 @@ public class AudioService extends IAudioService.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mStreamStates[streamType].mute(false);
|
mStreamStates[streamType].mute(false);
|
||||||
mRingerModeMutedStreams &= ~(1 << streamType);
|
mRingerAndZenModeMutedStreams &= ~(1 << streamType);
|
||||||
} else {
|
} else {
|
||||||
// mute
|
// mute
|
||||||
mStreamStates[streamType].mute(true);
|
mStreamStates[streamType].mute(true);
|
||||||
mRingerModeMutedStreams |= (1 << streamType);
|
mRingerAndZenModeMutedStreams |= (1 << streamType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2477,7 +2474,12 @@ public class AudioService extends IAudioService.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMedia(int streamType) {
|
private boolean isMedia(int streamType) {
|
||||||
return streamType == AudioSystem.STREAM_SYSTEM || streamType == AudioSystem.STREAM_MUSIC;
|
return streamType == AudioSystem.STREAM_MUSIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isSystem(int streamType) {
|
||||||
|
return streamType == AudioSystem.STREAM_SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRingerModeInt(int ringerMode, boolean persist) {
|
private void setRingerModeInt(int ringerMode, boolean persist) {
|
||||||
@@ -2836,6 +2838,11 @@ public class AudioService extends IAudioService.Stub
|
|||||||
|
|
||||||
/** @see AudioManager#playSoundEffect(int, float) */
|
/** @see AudioManager#playSoundEffect(int, float) */
|
||||||
public void playSoundEffectVolume(int effectType, float volume) {
|
public void playSoundEffectVolume(int effectType, float volume) {
|
||||||
|
// do not try to play the sound effect if the system stream is muted
|
||||||
|
if (isStreamMutedByRingerOrZenMode(STREAM_SYSTEM)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (effectType >= AudioManager.NUM_SOUND_EFFECTS || effectType < 0) {
|
if (effectType >= AudioManager.NUM_SOUND_EFFECTS || effectType < 0) {
|
||||||
Log.w(TAG, "AudioService effectType value " + effectType + " out of range");
|
Log.w(TAG, "AudioService effectType value " + effectType + " out of range");
|
||||||
return;
|
return;
|
||||||
@@ -2953,7 +2960,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
synchronized (VolumeStreamState.class) {
|
synchronized (VolumeStreamState.class) {
|
||||||
// unmute stream that was muted but is not affect by mute anymore
|
// unmute stream that was muted but is not affect by mute anymore
|
||||||
if (streamState.mIsMuted && ((!isStreamAffectedByMute(streamType) &&
|
if (streamState.mIsMuted && ((!isStreamAffectedByMute(streamType) &&
|
||||||
!isStreamMutedByRingerMode(streamType)) || mUseFixedVolume)) {
|
!isStreamMutedByRingerOrZenMode(streamType)) || mUseFixedVolume)) {
|
||||||
streamState.mIsMuted = false;
|
streamState.mIsMuted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3899,12 +3906,69 @@ public class AudioService extends IAudioService.Stub
|
|||||||
return (mRingerModeAffectedStreams & (1 << streamType)) != 0;
|
return (mRingerModeAffectedStreams & (1 << streamType)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStreamMutedByRingerMode(int streamType) {
|
private boolean shouldZenMuteStream(int streamType) {
|
||||||
return (mRingerModeMutedStreams & (1 << streamType)) != 0;
|
if (mNm.getZenMode() != Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
NotificationManager.Policy zenPolicy = mNm.getNotificationPolicy();
|
||||||
|
final boolean muteAlarms = (zenPolicy.priorityCategories
|
||||||
|
& NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS) == 0;
|
||||||
|
final boolean muteMedia = (zenPolicy.priorityCategories
|
||||||
|
& NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA) == 0;
|
||||||
|
final boolean muteSystem = (zenPolicy.priorityCategories
|
||||||
|
& NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM) == 0;
|
||||||
|
final boolean muteNotificationAndRing = ZenModeConfig
|
||||||
|
.areAllPriorityOnlyNotificationZenSoundsMuted(mNm.getNotificationPolicy());
|
||||||
|
return muteAlarms && isAlarm(streamType)
|
||||||
|
|| muteMedia && isMedia(streamType)
|
||||||
|
|| muteSystem && isSystem(streamType)
|
||||||
|
|| muteNotificationAndRing && isNotificationOrRinger(streamType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isStreamMutedByRingerOrZenMode(int streamType) {
|
||||||
|
return (mRingerAndZenModeMutedStreams & (1 << streamType)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DND total silence: media and alarms streams are tied to the muted ringer
|
||||||
|
* {@link ZenModeHelper.RingerModeDelegate#getRingerModeAffectedStreams(int)}
|
||||||
|
* DND alarms only: notification, ringer + system muted (by default tied to muted ringer mode)
|
||||||
|
* DND priority only: alarms, media, system streams can be muted separate from ringer based on
|
||||||
|
* zenPolicy (this method determines which streams)
|
||||||
|
* @return true if changed, else false
|
||||||
|
*/
|
||||||
|
private boolean updateZenModeAffectedStreams() {
|
||||||
|
int zenModeAffectedStreams = 0;
|
||||||
|
if (mSystemReady && mNm.getZenMode() == Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) {
|
||||||
|
NotificationManager.Policy zenPolicy = mNm.getNotificationPolicy();
|
||||||
|
if ((zenPolicy.priorityCategories
|
||||||
|
& NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS) == 0) {
|
||||||
|
zenModeAffectedStreams |= 1 << AudioManager.STREAM_ALARM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zenPolicy.priorityCategories
|
||||||
|
& NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA) == 0) {
|
||||||
|
zenModeAffectedStreams |= 1 << AudioManager.STREAM_MUSIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zenPolicy.priorityCategories
|
||||||
|
& NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM) == 0) {
|
||||||
|
zenModeAffectedStreams |= 1 << AudioManager.STREAM_SYSTEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mZenModeAffectedStreams != zenModeAffectedStreams) {
|
||||||
|
mZenModeAffectedStreams = zenModeAffectedStreams;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GuardedBy("mSettingsLock")
|
@GuardedBy("mSettingsLock")
|
||||||
private boolean updateRingerModeAffectedStreams() {
|
private boolean updateRingerAndZenModeAffectedStreams() {
|
||||||
|
boolean updatedZenModeAffectedStreams = updateZenModeAffectedStreams();
|
||||||
int ringerModeAffectedStreams = Settings.System.getIntForUser(mContentResolver,
|
int ringerModeAffectedStreams = Settings.System.getIntForUser(mContentResolver,
|
||||||
Settings.System.MODE_RINGER_STREAMS_AFFECTED,
|
Settings.System.MODE_RINGER_STREAMS_AFFECTED,
|
||||||
((1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_NOTIFICATION)|
|
((1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_NOTIFICATION)|
|
||||||
@@ -3936,7 +4000,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
mRingerModeAffectedStreams = ringerModeAffectedStreams;
|
mRingerModeAffectedStreams = ringerModeAffectedStreams;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return updatedZenModeAffectedStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -5259,6 +5323,10 @@ public class AudioService extends IAudioService.Stub
|
|||||||
|
|
||||||
SettingsObserver() {
|
SettingsObserver() {
|
||||||
super(new Handler());
|
super(new Handler());
|
||||||
|
mContentResolver.registerContentObserver(Settings.Global.getUriFor(
|
||||||
|
Settings.Global.ZEN_MODE), false, this);
|
||||||
|
mContentResolver.registerContentObserver(Settings.Global.getUriFor(
|
||||||
|
Settings.Global.ZEN_MODE_CONFIG_ETAG), false, this);
|
||||||
mContentResolver.registerContentObserver(Settings.System.getUriFor(
|
mContentResolver.registerContentObserver(Settings.System.getUriFor(
|
||||||
Settings.System.MODE_RINGER_STREAMS_AFFECTED), false, this);
|
Settings.System.MODE_RINGER_STREAMS_AFFECTED), false, this);
|
||||||
mContentResolver.registerContentObserver(Settings.Global.getUriFor(
|
mContentResolver.registerContentObserver(Settings.Global.getUriFor(
|
||||||
@@ -5277,11 +5345,11 @@ public class AudioService extends IAudioService.Stub
|
|||||||
public void onChange(boolean selfChange) {
|
public void onChange(boolean selfChange) {
|
||||||
super.onChange(selfChange);
|
super.onChange(selfChange);
|
||||||
// FIXME This synchronized is not necessary if mSettingsLock only protects mRingerMode.
|
// FIXME This synchronized is not necessary if mSettingsLock only protects mRingerMode.
|
||||||
// However there appear to be some missing locks around mRingerModeMutedStreams
|
// However there appear to be some missing locks around mRingerAndZenModeMutedStreams
|
||||||
// and mRingerModeAffectedStreams, so will leave this synchronized for now.
|
// and mRingerModeAffectedStreams, so will leave this synchronized for now.
|
||||||
// mRingerModeMutedStreams and mMuteAffectedStreams are safe (only accessed once).
|
// mRingerAndZenModeMutedStreams and mMuteAffectedStreams are safe (only accessed once).
|
||||||
synchronized (mSettingsLock) {
|
synchronized (mSettingsLock) {
|
||||||
if (updateRingerModeAffectedStreams()) {
|
if (updateRingerAndZenModeAffectedStreams()) {
|
||||||
/*
|
/*
|
||||||
* Ensure all stream types that should be affected by ringer mode
|
* Ensure all stream types that should be affected by ringer mode
|
||||||
* are in the proper state.
|
* are in the proper state.
|
||||||
@@ -6614,7 +6682,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
pw.println("- mode (internal) = " + RINGER_MODE_NAMES[mRingerMode]);
|
pw.println("- mode (internal) = " + RINGER_MODE_NAMES[mRingerMode]);
|
||||||
pw.println("- mode (external) = " + RINGER_MODE_NAMES[mRingerModeExternal]);
|
pw.println("- mode (external) = " + RINGER_MODE_NAMES[mRingerModeExternal]);
|
||||||
dumpRingerModeStreams(pw, "affected", mRingerModeAffectedStreams);
|
dumpRingerModeStreams(pw, "affected", mRingerModeAffectedStreams);
|
||||||
dumpRingerModeStreams(pw, "muted", mRingerModeMutedStreams);
|
dumpRingerModeStreams(pw, "muted", mRingerAndZenModeMutedStreams);
|
||||||
pw.print("- delegate = "); pw.println(mRingerModeDelegate);
|
pw.print("- delegate = "); pw.println(mRingerModeDelegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6911,7 +6979,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
mRingerModeDelegate = delegate;
|
mRingerModeDelegate = delegate;
|
||||||
if (mRingerModeDelegate != null) {
|
if (mRingerModeDelegate != null) {
|
||||||
synchronized (mSettingsLock) {
|
synchronized (mSettingsLock) {
|
||||||
updateRingerModeAffectedStreams();
|
updateRingerAndZenModeAffectedStreams();
|
||||||
}
|
}
|
||||||
setRingerModeInternal(getRingerModeInternal(), TAG + ".setRingerModeDelegate");
|
setRingerModeInternal(getRingerModeInternal(), TAG + ".setRingerModeDelegate");
|
||||||
}
|
}
|
||||||
@@ -6952,7 +7020,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
@Override
|
@Override
|
||||||
public void updateRingerModeAffectedStreamsInternal() {
|
public void updateRingerModeAffectedStreamsInternal() {
|
||||||
synchronized (mSettingsLock) {
|
synchronized (mSettingsLock) {
|
||||||
if (updateRingerModeAffectedStreams()) {
|
if (updateRingerAndZenModeAffectedStreams()) {
|
||||||
setRingerModeInt(getRingerModeInternal(), false);
|
setRingerModeInt(getRingerModeInternal(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ import android.os.IDeviceIdleController;
|
|||||||
import android.os.IInterface;
|
import android.os.IInterface;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ResultReceiver;
|
import android.os.ResultReceiver;
|
||||||
@@ -3053,8 +3052,9 @@ public class NotificationManagerService extends SystemService {
|
|||||||
/**
|
/**
|
||||||
* Sets the notification policy. Apps that target API levels below
|
* Sets the notification policy. Apps that target API levels below
|
||||||
* {@link android.os.Build.VERSION_CODES#P} cannot change user-designated values to
|
* {@link android.os.Build.VERSION_CODES#P} cannot change user-designated values to
|
||||||
* allow or disallow {@link Policy#PRIORITY_CATEGORY_ALARMS} and
|
* allow or disallow {@link Policy#PRIORITY_CATEGORY_ALARMS},
|
||||||
* {@link Policy#PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER} from bypassing dnd
|
* {@link Policy#PRIORITY_CATEGORY_SYSTEM} and
|
||||||
|
* {@link Policy#PRIORITY_CATEGORY_MEDIA} from bypassing dnd
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setNotificationPolicy(String pkg, Policy policy) {
|
public void setNotificationPolicy(String pkg, Policy policy) {
|
||||||
@@ -3070,16 +3070,25 @@ public class NotificationManagerService extends SystemService {
|
|||||||
int priorityCategories = policy.priorityCategories;
|
int priorityCategories = policy.priorityCategories;
|
||||||
// ignore alarm and media values from new policy
|
// ignore alarm and media values from new policy
|
||||||
priorityCategories &= ~Policy.PRIORITY_CATEGORY_ALARMS;
|
priorityCategories &= ~Policy.PRIORITY_CATEGORY_ALARMS;
|
||||||
priorityCategories &= ~Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER;
|
priorityCategories &= ~Policy.PRIORITY_CATEGORY_MEDIA;
|
||||||
|
priorityCategories &= ~Policy.PRIORITY_CATEGORY_SYSTEM;
|
||||||
// use user-designated values
|
// use user-designated values
|
||||||
priorityCategories |= currPolicy.PRIORITY_CATEGORY_ALARMS;
|
priorityCategories |= currPolicy.priorityCategories
|
||||||
priorityCategories |= currPolicy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER;
|
& Policy.PRIORITY_CATEGORY_ALARMS;
|
||||||
|
priorityCategories |= currPolicy.priorityCategories
|
||||||
|
& Policy.PRIORITY_CATEGORY_MEDIA;
|
||||||
|
priorityCategories |= currPolicy.priorityCategories
|
||||||
|
& Policy.PRIORITY_CATEGORY_SYSTEM;
|
||||||
|
|
||||||
policy = new Policy(priorityCategories,
|
policy = new Policy(priorityCategories,
|
||||||
policy.priorityCallSenders, policy.priorityMessageSenders,
|
policy.priorityCallSenders, policy.priorityMessageSenders,
|
||||||
policy.suppressedVisualEffects);
|
policy.suppressedVisualEffects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Slog.i(TAG, "setNotificationPolicy pkg=" + pkg
|
||||||
|
+ " targetSdk=" + applicationInfo.targetSdkVersion
|
||||||
|
+ " policy="
|
||||||
|
+ Policy.priorityCategoriesToString(policy.priorityCategories));
|
||||||
mZenModeHelper.setNotificationPolicy(policy);
|
mZenModeHelper.setNotificationPolicy(policy);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -163,11 +163,16 @@ public class ZenModeFiltering {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AudioAttributes aa = record.getAudioAttributes();
|
if (isMedia(record)) {
|
||||||
if (aa != null && AudioAttributes.SUPPRESSIBLE_USAGES.get(aa.getUsage()) ==
|
if (!config.allowMedia) {
|
||||||
AudioAttributes.SUPPRESSIBLE_MEDIA_SYSTEM_OTHER) {
|
ZenLog.traceIntercepted(record, "!allowMedia");
|
||||||
if (!config.allowMediaSystemOther) {
|
return true;
|
||||||
ZenLog.traceIntercepted(record, "!allowMediaSystemOther");
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isSystem(record)) {
|
||||||
|
if (!config.allowSystem) {
|
||||||
|
ZenLog.traceIntercepted(record, "!allowSystem");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -206,6 +211,18 @@ public class ZenModeFiltering {
|
|||||||
|| record.isCategory(Notification.CATEGORY_CALL));
|
|| record.isCategory(Notification.CATEGORY_CALL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMedia(NotificationRecord record) {
|
||||||
|
AudioAttributes aa = record.getAudioAttributes();
|
||||||
|
return aa != null && AudioAttributes.SUPPRESSIBLE_USAGES.get(aa.getUsage()) ==
|
||||||
|
AudioAttributes.SUPPRESSIBLE_MEDIA;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSystem(NotificationRecord record) {
|
||||||
|
AudioAttributes aa = record.getAudioAttributes();
|
||||||
|
return aa != null && AudioAttributes.SUPPRESSIBLE_USAGES.get(aa.getUsage()) ==
|
||||||
|
AudioAttributes.SUPPRESSIBLE_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isDefaultPhoneApp(String pkg) {
|
private boolean isDefaultPhoneApp(String pkg) {
|
||||||
if (mDefaultPhoneApp == null) {
|
if (mDefaultPhoneApp == null) {
|
||||||
final TelecomManager telecomm =
|
final TelecomManager telecomm =
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ public class ZenModeHelper {
|
|||||||
protected ZenModeConfig mDefaultConfig;
|
protected ZenModeConfig mDefaultConfig;
|
||||||
private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>();
|
private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>();
|
||||||
private final ZenModeFiltering mFiltering;
|
private final ZenModeFiltering mFiltering;
|
||||||
private final RingerModeDelegate mRingerModeDelegate = new RingerModeDelegate();
|
protected final RingerModeDelegate mRingerModeDelegate = new
|
||||||
|
RingerModeDelegate();
|
||||||
private final ZenModeConditions mConditions;
|
private final ZenModeConditions mConditions;
|
||||||
private final SparseArray<ZenModeConfig> mConfigs = new SparseArray<>();
|
private final SparseArray<ZenModeConfig> mConfigs = new SparseArray<>();
|
||||||
private final Metrics mMetrics = new Metrics();
|
private final Metrics mMetrics = new Metrics();
|
||||||
@@ -601,9 +602,9 @@ public class ZenModeHelper {
|
|||||||
pw.println(config);
|
pw.println(config);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pw.printf("allow(alarms=%b,media=%bcalls=%b,callsFrom=%s,repeatCallers=%b,messages=%b,messagesFrom=%s,"
|
pw.printf("allow(alarms=%b,media=%b,system=%b,calls=%b,callsFrom=%s,repeatCallers=%b,messages=%b,messagesFrom=%s,"
|
||||||
+ "events=%b,reminders=%b,whenScreenOff=%b,whenScreenOn=%b)\n",
|
+ "events=%b,reminders=%b,whenScreenOff=%b,whenScreenOn=%b)\n",
|
||||||
config.allowAlarms, config.allowMediaSystemOther,
|
config.allowAlarms, config.allowMedia, config.allowSystem,
|
||||||
config.allowCalls, ZenModeConfig.sourceToString(config.allowCallsFrom),
|
config.allowCalls, ZenModeConfig.sourceToString(config.allowCallsFrom),
|
||||||
config.allowRepeatCallers, config.allowMessages,
|
config.allowRepeatCallers, config.allowMessages,
|
||||||
ZenModeConfig.sourceToString(config.allowMessagesFrom),
|
ZenModeConfig.sourceToString(config.allowMessagesFrom),
|
||||||
@@ -781,6 +782,7 @@ public class ZenModeHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setPreviousRingerModeSetting(Integer previousRingerLevel) {
|
private void setPreviousRingerModeSetting(Integer previousRingerLevel) {
|
||||||
|
Slog.d("beverlyt", "setPreviousRingerMode=" + previousRingerLevel);
|
||||||
Global.putString(
|
Global.putString(
|
||||||
mContext.getContentResolver(), Global.ZEN_MODE_RINGER_LEVEL,
|
mContext.getContentResolver(), Global.ZEN_MODE_RINGER_LEVEL,
|
||||||
previousRingerLevel == null ? null : Integer.toString(previousRingerLevel));
|
previousRingerLevel == null ? null : Integer.toString(previousRingerLevel));
|
||||||
@@ -792,8 +794,8 @@ public class ZenModeHelper {
|
|||||||
final int zen = computeZenMode();
|
final int zen = computeZenMode();
|
||||||
ZenLog.traceSetZenMode(zen, reason);
|
ZenLog.traceSetZenMode(zen, reason);
|
||||||
mZenMode = zen;
|
mZenMode = zen;
|
||||||
updateRingerModeAffectedStreams();
|
|
||||||
setZenModeSetting(mZenMode);
|
setZenModeSetting(mZenMode);
|
||||||
|
updateRingerModeAffectedStreams();
|
||||||
if (setRingerMode) {
|
if (setRingerMode) {
|
||||||
applyZenToRingerMode();
|
applyZenToRingerMode();
|
||||||
}
|
}
|
||||||
@@ -849,8 +851,10 @@ public class ZenModeHelper {
|
|||||||
|| (mSuppressedEffects & SUPPRESSED_EFFECT_CALLS) != 0;
|
|| (mSuppressedEffects & SUPPRESSED_EFFECT_CALLS) != 0;
|
||||||
// alarm restrictions
|
// alarm restrictions
|
||||||
final boolean muteAlarms = zenPriorityOnly && !mConfig.allowAlarms;
|
final boolean muteAlarms = zenPriorityOnly && !mConfig.allowAlarms;
|
||||||
// alarm restrictions
|
// media restrictions
|
||||||
final boolean muteMediaAndSystemSounds = zenPriorityOnly && !mConfig.allowMediaSystemOther;
|
final boolean muteMedia = zenPriorityOnly && !mConfig.allowMedia;
|
||||||
|
// system restrictions
|
||||||
|
final boolean muteSystem = zenAlarmsOnly || (zenPriorityOnly && !mConfig.allowSystem);
|
||||||
// total silence restrictions
|
// total silence restrictions
|
||||||
final boolean muteEverything = zenSilence
|
final boolean muteEverything = zenSilence
|
||||||
|| (zenPriorityOnly && ZenModeConfig.areAllZenBehaviorSoundsMuted(mConfig));
|
|| (zenPriorityOnly && ZenModeConfig.areAllZenBehaviorSoundsMuted(mConfig));
|
||||||
@@ -865,8 +869,10 @@ public class ZenModeHelper {
|
|||||||
applyRestrictions(muteCalls || muteEverything, usage);
|
applyRestrictions(muteCalls || muteEverything, usage);
|
||||||
} else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_ALARM) {
|
} else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_ALARM) {
|
||||||
applyRestrictions(muteAlarms || muteEverything, usage);
|
applyRestrictions(muteAlarms || muteEverything, usage);
|
||||||
} else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_MEDIA_SYSTEM_OTHER) {
|
} else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_MEDIA) {
|
||||||
applyRestrictions(muteMediaAndSystemSounds || muteEverything, usage);
|
applyRestrictions(muteMedia || muteEverything, usage);
|
||||||
|
} else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_SYSTEM) {
|
||||||
|
applyRestrictions(muteSystem || muteEverything, usage);
|
||||||
} else {
|
} else {
|
||||||
applyRestrictions(muteEverything, usage);
|
applyRestrictions(muteEverything, usage);
|
||||||
}
|
}
|
||||||
@@ -901,7 +907,8 @@ public class ZenModeHelper {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
|
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
|
||||||
if (ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(mConfig)) {
|
if (ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(mConfig)
|
||||||
|
&& ringerModeInternal != AudioManager.RINGER_MODE_SILENT) {
|
||||||
setPreviousRingerModeSetting(ringerModeInternal);
|
setPreviousRingerModeSetting(ringerModeInternal);
|
||||||
newRingerModeInternal = AudioManager.RINGER_MODE_SILENT;
|
newRingerModeInternal = AudioManager.RINGER_MODE_SILENT;
|
||||||
}
|
}
|
||||||
@@ -1028,7 +1035,7 @@ public class ZenModeHelper {
|
|||||||
|| mZenMode == Global.ZEN_MODE_ALARMS
|
|| mZenMode == Global.ZEN_MODE_ALARMS
|
||||||
|| (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
|
|| (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
|
||||||
&& ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(
|
&& ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(
|
||||||
mConfig)))) {
|
mConfig)))) {
|
||||||
newZen = Global.ZEN_MODE_OFF;
|
newZen = Global.ZEN_MODE_OFF;
|
||||||
} else if (mZenMode != Global.ZEN_MODE_OFF) {
|
} else if (mZenMode != Global.ZEN_MODE_OFF) {
|
||||||
ringerModeExternalOut = AudioManager.RINGER_MODE_SILENT;
|
ringerModeExternalOut = AudioManager.RINGER_MODE_SILENT;
|
||||||
@@ -1096,32 +1103,28 @@ public class ZenModeHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRingerModeAffectedStreams(int streams) {
|
public int getRingerModeAffectedStreams(int streams) {
|
||||||
// ringtone, notification and system streams are always affected by ringer mode
|
// ringtone and notification streams are always affected by ringer mode
|
||||||
|
// system stream is affected by ringer mode when not in priority-only
|
||||||
streams |= (1 << AudioSystem.STREAM_RING) |
|
streams |= (1 << AudioSystem.STREAM_RING) |
|
||||||
(1 << AudioSystem.STREAM_NOTIFICATION) |
|
(1 << AudioSystem.STREAM_NOTIFICATION) |
|
||||||
(1 << AudioSystem.STREAM_SYSTEM);
|
(1 << AudioSystem.STREAM_SYSTEM);
|
||||||
|
|
||||||
if (mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS) {
|
if (mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS) {
|
||||||
// alarm and music streams affected by ringer mode when in total silence
|
// alarm and music streams affected by ringer mode when in total silence
|
||||||
streams |= (1 << AudioSystem.STREAM_ALARM) |
|
streams |= (1 << AudioSystem.STREAM_ALARM) |
|
||||||
(1 << AudioSystem.STREAM_MUSIC);
|
(1 << AudioSystem.STREAM_MUSIC);
|
||||||
} else if (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) {
|
|
||||||
// alarm and music streams affected by ringer mode when in priority only with
|
|
||||||
// media and alarms not allowed to bypass dnd
|
|
||||||
if (!mConfig.allowMediaSystemOther) {
|
|
||||||
streams |= (1 << AudioSystem.STREAM_MUSIC);
|
|
||||||
} else {
|
|
||||||
streams &= ~(1 << AudioSystem.STREAM_MUSIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mConfig.allowAlarms) {
|
|
||||||
streams |= (1 << AudioSystem.STREAM_ALARM);
|
|
||||||
} else {
|
|
||||||
streams &= ~(1 << AudioSystem.STREAM_ALARM);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
streams &= ~((1 << AudioSystem.STREAM_ALARM) |
|
streams &= ~((1 << AudioSystem.STREAM_ALARM) |
|
||||||
(1 << AudioSystem.STREAM_MUSIC));
|
(1 << AudioSystem.STREAM_MUSIC));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
|
||||||
|
&& ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(mConfig)) {
|
||||||
|
// system stream is not affected by ringer mode in priority only when the ringer
|
||||||
|
// is zen muted (all other notification categories are muted)
|
||||||
|
streams &= ~(1 << AudioSystem.STREAM_SYSTEM);
|
||||||
|
} else {
|
||||||
|
streams |= (1 << AudioSystem.STREAM_SYSTEM);
|
||||||
}
|
}
|
||||||
return streams;
|
return streams;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import android.media.AudioAttributes;
|
|||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.AudioManagerInternal;
|
import android.media.AudioManagerInternal;
|
||||||
import android.media.VolumePolicy;
|
import android.media.VolumePolicy;
|
||||||
|
import android.media.AudioSystem;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.Settings.Global;
|
import android.provider.Settings.Global;
|
||||||
import android.service.notification.ZenModeConfig;
|
import android.service.notification.ZenModeConfig;
|
||||||
@@ -50,6 +51,7 @@ import android.testing.TestableLooper;
|
|||||||
|
|
||||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||||
import com.android.server.UiServiceTestCase;
|
import com.android.server.UiServiceTestCase;
|
||||||
|
import android.util.Slog;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -101,7 +103,7 @@ public class ZenModeHelperTest extends UiServiceTestCase {
|
|||||||
public void testZenOn_AllowAlarmsMedia_NoAlarmMediaMuteApplied() {
|
public void testZenOn_AllowAlarmsMedia_NoAlarmMediaMuteApplied() {
|
||||||
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
|
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
|
||||||
assertTrue(mZenModeHelperSpy.mConfig.allowAlarms);
|
assertTrue(mZenModeHelperSpy.mConfig.allowAlarms);
|
||||||
assertTrue(mZenModeHelperSpy.mConfig.allowMediaSystemOther);
|
assertTrue(mZenModeHelperSpy.mConfig.allowMedia);
|
||||||
mZenModeHelperSpy.applyRestrictions();
|
mZenModeHelperSpy.applyRestrictions();
|
||||||
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(false,
|
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(false,
|
||||||
AudioAttributes.USAGE_ALARM);
|
AudioAttributes.USAGE_ALARM);
|
||||||
@@ -111,34 +113,32 @@ public class ZenModeHelperTest extends UiServiceTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZenOn_DisallowAlarmsMedia_AlarmMediaMuteApplied() {
|
public void testZenOn_DisallowAlarmsMedia_AlarmMediaMuteApplied() {
|
||||||
|
|
||||||
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
|
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
|
||||||
mZenModeHelperSpy.mConfig.allowAlarms = false;
|
mZenModeHelperSpy.mConfig.allowAlarms = false;
|
||||||
mZenModeHelperSpy.mConfig.allowMediaSystemOther = false;
|
mZenModeHelperSpy.mConfig.allowMedia = false;
|
||||||
|
mZenModeHelperSpy.mConfig.allowSystem = false;
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowAlarms);
|
assertFalse(mZenModeHelperSpy.mConfig.allowAlarms);
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowMediaSystemOther);
|
assertFalse(mZenModeHelperSpy.mConfig.allowMedia);
|
||||||
|
assertFalse(mZenModeHelperSpy.mConfig.allowSystem);
|
||||||
mZenModeHelperSpy.applyRestrictions();
|
mZenModeHelperSpy.applyRestrictions();
|
||||||
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
|
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
|
||||||
AudioAttributes.USAGE_ALARM);
|
AudioAttributes.USAGE_ALARM);
|
||||||
|
|
||||||
// Media is a catch-all that includes games and system sounds
|
// Media is a catch-all that includes games
|
||||||
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
|
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
|
||||||
AudioAttributes.USAGE_MEDIA);
|
AudioAttributes.USAGE_MEDIA);
|
||||||
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
|
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
|
||||||
AudioAttributes.USAGE_GAME);
|
AudioAttributes.USAGE_GAME);
|
||||||
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
|
|
||||||
AudioAttributes.USAGE_ASSISTANCE_SONIFICATION);
|
|
||||||
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
|
|
||||||
AudioAttributes.USAGE_UNKNOWN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAlarmsOnly_alarmMediaMuteNotApplied() {
|
public void testAlarmsOnly_alarmMediaMuteNotApplied() {
|
||||||
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_ALARMS;
|
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_ALARMS;
|
||||||
mZenModeHelperSpy.mConfig.allowAlarms = false;
|
mZenModeHelperSpy.mConfig.allowAlarms = false;
|
||||||
mZenModeHelperSpy.mConfig.allowMediaSystemOther = false;
|
mZenModeHelperSpy.mConfig.allowSystem = false;
|
||||||
|
mZenModeHelperSpy.mConfig.allowMedia = false;
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowAlarms);
|
assertFalse(mZenModeHelperSpy.mConfig.allowAlarms);
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowMediaSystemOther);
|
assertFalse(mZenModeHelperSpy.mConfig.allowMedia);
|
||||||
mZenModeHelperSpy.applyRestrictions();
|
mZenModeHelperSpy.applyRestrictions();
|
||||||
|
|
||||||
// Alarms only mode will not silence alarms
|
// Alarms only mode will not silence alarms
|
||||||
@@ -150,9 +150,11 @@ public class ZenModeHelperTest extends UiServiceTestCase {
|
|||||||
AudioAttributes.USAGE_MEDIA);
|
AudioAttributes.USAGE_MEDIA);
|
||||||
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(false,
|
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(false,
|
||||||
AudioAttributes.USAGE_GAME);
|
AudioAttributes.USAGE_GAME);
|
||||||
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(false,
|
|
||||||
|
// Alarms only will silence system noises
|
||||||
|
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
|
||||||
AudioAttributes.USAGE_ASSISTANCE_SONIFICATION);
|
AudioAttributes.USAGE_ASSISTANCE_SONIFICATION);
|
||||||
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(false,
|
verify(mZenModeHelperSpy, atLeastOnce()).applyRestrictions(true,
|
||||||
AudioAttributes.USAGE_UNKNOWN);
|
AudioAttributes.USAGE_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,14 +177,15 @@ public class ZenModeHelperTest extends UiServiceTestCase {
|
|||||||
// Only audio attributes with SUPPRESIBLE_NEVER can bypass
|
// Only audio attributes with SUPPRESIBLE_NEVER can bypass
|
||||||
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_ALARMS;
|
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_ALARMS;
|
||||||
mZenModeHelperSpy.mConfig.allowAlarms = false;
|
mZenModeHelperSpy.mConfig.allowAlarms = false;
|
||||||
mZenModeHelperSpy.mConfig.allowMediaSystemOther = false;
|
mZenModeHelperSpy.mConfig.allowMedia = false;
|
||||||
|
mZenModeHelperSpy.mConfig.allowSystem = false;
|
||||||
mZenModeHelperSpy.mConfig.allowReminders = false;
|
mZenModeHelperSpy.mConfig.allowReminders = false;
|
||||||
mZenModeHelperSpy.mConfig.allowCalls = false;
|
mZenModeHelperSpy.mConfig.allowCalls = false;
|
||||||
mZenModeHelperSpy.mConfig.allowMessages = false;
|
mZenModeHelperSpy.mConfig.allowMessages = false;
|
||||||
mZenModeHelperSpy.mConfig.allowEvents = false;
|
mZenModeHelperSpy.mConfig.allowEvents = false;
|
||||||
mZenModeHelperSpy.mConfig.allowRepeatCallers= false;
|
mZenModeHelperSpy.mConfig.allowRepeatCallers= false;
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowAlarms);
|
assertFalse(mZenModeHelperSpy.mConfig.allowAlarms);
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowMediaSystemOther);
|
assertFalse(mZenModeHelperSpy.mConfig.allowMedia);
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowReminders);
|
assertFalse(mZenModeHelperSpy.mConfig.allowReminders);
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowCalls);
|
assertFalse(mZenModeHelperSpy.mConfig.allowCalls);
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowMessages);
|
assertFalse(mZenModeHelperSpy.mConfig.allowMessages);
|
||||||
@@ -199,14 +202,15 @@ public class ZenModeHelperTest extends UiServiceTestCase {
|
|||||||
// Only audio attributes with SUPPRESIBLE_NEVER can bypass
|
// Only audio attributes with SUPPRESIBLE_NEVER can bypass
|
||||||
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
|
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
|
||||||
mZenModeHelperSpy.mConfig.allowAlarms = false;
|
mZenModeHelperSpy.mConfig.allowAlarms = false;
|
||||||
mZenModeHelperSpy.mConfig.allowMediaSystemOther = false;
|
mZenModeHelperSpy.mConfig.allowMedia = false;
|
||||||
|
mZenModeHelperSpy.mConfig.allowSystem = false;
|
||||||
mZenModeHelperSpy.mConfig.allowReminders = false;
|
mZenModeHelperSpy.mConfig.allowReminders = false;
|
||||||
mZenModeHelperSpy.mConfig.allowCalls = false;
|
mZenModeHelperSpy.mConfig.allowCalls = false;
|
||||||
mZenModeHelperSpy.mConfig.allowMessages = false;
|
mZenModeHelperSpy.mConfig.allowMessages = false;
|
||||||
mZenModeHelperSpy.mConfig.allowEvents = false;
|
mZenModeHelperSpy.mConfig.allowEvents = false;
|
||||||
mZenModeHelperSpy.mConfig.allowRepeatCallers= false;
|
mZenModeHelperSpy.mConfig.allowRepeatCallers= false;
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowAlarms);
|
assertFalse(mZenModeHelperSpy.mConfig.allowAlarms);
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowMediaSystemOther);
|
assertFalse(mZenModeHelperSpy.mConfig.allowMedia);
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowReminders);
|
assertFalse(mZenModeHelperSpy.mConfig.allowReminders);
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowCalls);
|
assertFalse(mZenModeHelperSpy.mConfig.allowCalls);
|
||||||
assertFalse(mZenModeHelperSpy.mConfig.allowMessages);
|
assertFalse(mZenModeHelperSpy.mConfig.allowMessages);
|
||||||
@@ -278,6 +282,63 @@ public class ZenModeHelperTest extends UiServiceTestCase {
|
|||||||
mZenModeHelperSpy.TAG);
|
mZenModeHelperSpy.TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRingerAffectedStreamsTotalSilence() {
|
||||||
|
// in total silence:
|
||||||
|
// ringtone, notification, system, alarm, streams, music are affected by ringer mode
|
||||||
|
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
|
||||||
|
ZenModeHelper.RingerModeDelegate ringerModeDelegate =
|
||||||
|
mZenModeHelperSpy.new RingerModeDelegate();
|
||||||
|
int ringerModeAffectedStreams = ringerModeDelegate.getRingerModeAffectedStreams(0);
|
||||||
|
assertTrue((ringerModeAffectedStreams & (1 << AudioSystem.STREAM_RING)) != 0);
|
||||||
|
assertTrue((ringerModeAffectedStreams & (1 << AudioSystem.STREAM_NOTIFICATION))
|
||||||
|
!= 0);
|
||||||
|
assertTrue((ringerModeAffectedStreams & (1 << AudioSystem.STREAM_SYSTEM)) != 0);
|
||||||
|
assertTrue((ringerModeAffectedStreams & (1 << AudioSystem.STREAM_ALARM)) != 0);
|
||||||
|
assertTrue((ringerModeAffectedStreams & (1 << AudioSystem.STREAM_MUSIC)) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRingerAffectedStreamsPriorityOnly() {
|
||||||
|
// in priority only mode:
|
||||||
|
// ringtone, notification and system streams are affected by ringer mode
|
||||||
|
// UNLESS ringer is muted due to all the other priority only dnd sounds being muted
|
||||||
|
mZenModeHelperSpy.mConfig.allowAlarms = true;
|
||||||
|
mZenModeHelperSpy.mConfig.allowReminders = true;
|
||||||
|
mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
|
||||||
|
ZenModeHelper.RingerModeDelegate ringerModeDelegateRingerMuted =
|
||||||
|
mZenModeHelperSpy.new RingerModeDelegate();
|
||||||
|
|
||||||
|
int ringerModeAffectedStreams =
|
||||||
|
ringerModeDelegateRingerMuted.getRingerModeAffectedStreams(0);
|
||||||
|
assertTrue((ringerModeAffectedStreams & (1 << AudioSystem.STREAM_RING)) != 0);
|
||||||
|
assertTrue((ringerModeAffectedStreams & (1 << AudioSystem.STREAM_NOTIFICATION))
|
||||||
|
!= 0);
|
||||||
|
assertTrue((ringerModeAffectedStreams & (1 << AudioSystem.STREAM_SYSTEM)) != 0);
|
||||||
|
assertTrue((ringerModeAffectedStreams & (1 << AudioSystem.STREAM_ALARM)) == 0);
|
||||||
|
assertTrue((ringerModeAffectedStreams & (1 << AudioSystem.STREAM_MUSIC)) == 0);
|
||||||
|
|
||||||
|
// special case: if ringer is muted (since all notification sounds cannot bypass)
|
||||||
|
// then system stream is not affected by ringer mode
|
||||||
|
mZenModeHelperSpy.mConfig.allowReminders = false;
|
||||||
|
mZenModeHelperSpy.mConfig.allowCalls = false;
|
||||||
|
mZenModeHelperSpy.mConfig.allowMessages = false;
|
||||||
|
mZenModeHelperSpy.mConfig.allowEvents = false;
|
||||||
|
mZenModeHelperSpy.mConfig.allowRepeatCallers= false;
|
||||||
|
ZenModeHelper.RingerModeDelegate ringerModeDelegateRingerNotMuted =
|
||||||
|
mZenModeHelperSpy.new RingerModeDelegate();
|
||||||
|
|
||||||
|
int ringerMutedRingerModeAffectedStreams =
|
||||||
|
ringerModeDelegateRingerNotMuted.getRingerModeAffectedStreams(0);
|
||||||
|
assertTrue((ringerMutedRingerModeAffectedStreams & (1 << AudioSystem.STREAM_RING)) != 0);
|
||||||
|
assertTrue((ringerMutedRingerModeAffectedStreams & (1 << AudioSystem.STREAM_NOTIFICATION))
|
||||||
|
!= 0);
|
||||||
|
assertTrue((ringerMutedRingerModeAffectedStreams & (1 << AudioSystem.STREAM_SYSTEM))
|
||||||
|
== 0);
|
||||||
|
assertTrue((ringerMutedRingerModeAffectedStreams & (1 << AudioSystem.STREAM_ALARM)) == 0);
|
||||||
|
assertTrue((ringerMutedRingerModeAffectedStreams & (1 << AudioSystem.STREAM_MUSIC)) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZenSetInternalRinger_NotAllPriorityNotificationSoundsMuted_StartNormal() {
|
public void testZenSetInternalRinger_NotAllPriorityNotificationSoundsMuted_StartNormal() {
|
||||||
AudioManagerInternal mAudioManager = mock(AudioManagerInternal.class);
|
AudioManagerInternal mAudioManager = mock(AudioManagerInternal.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user