Merge "AudioPolicy: fix AudioMixingRule parceling"
diff --git a/media/java/android/media/audiopolicy/AudioMixingRule.java b/media/java/android/media/audiopolicy/AudioMixingRule.java
index c912759..1f89f99 100644
--- a/media/java/android/media/audiopolicy/AudioMixingRule.java
+++ b/media/java/android/media/audiopolicy/AudioMixingRule.java
@@ -145,10 +145,8 @@
final int match_rule = mRule & ~RULE_EXCLUSION_MASK;
switch (match_rule) {
case RULE_MATCH_ATTRIBUTE_USAGE:
- dest.writeInt(mAttr.getSystemUsage());
- break;
case RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET:
- dest.writeInt(mAttr.getCapturePreset());
+ mAttr.writeToParcel(dest, AudioAttributes.FLATTEN_TAGS/*flags*/);
break;
case RULE_MATCH_UID:
case RULE_MATCH_USERID:
@@ -266,12 +264,14 @@
public boolean isForCallRedirection() {
for (AudioMixMatchCriterion criterion : mCriteria) {
if (criterion.mAttr != null
- && (criterion.mRule == RULE_MATCH_ATTRIBUTE_USAGE
- && criterion.mAttr.getUsage() == AudioAttributes.USAGE_VOICE_COMMUNICATION)
+ && criterion.mAttr.isForCallRedirection()
+ && ((criterion.mRule == RULE_MATCH_ATTRIBUTE_USAGE
+ && (criterion.mAttr.getUsage() == AudioAttributes.USAGE_VOICE_COMMUNICATION
+ || criterion.mAttr.getUsage()
+ == AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING))
|| (criterion.mRule == RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET
- && criterion.mAttr.getCapturePreset()
- == MediaRecorder.AudioSource.VOICE_COMMUNICATION)
- && criterion.mAttr.isForCallRedirection()) {
+ && (criterion.mAttr.getCapturePreset()
+ == MediaRecorder.AudioSource.VOICE_COMMUNICATION)))) {
return true;
}
}
@@ -713,19 +713,8 @@
Integer intProp = null;
switch (match_rule) {
case RULE_MATCH_ATTRIBUTE_USAGE:
- int usage = in.readInt();
- if (AudioAttributes.isSystemUsage(usage)) {
- attr = new AudioAttributes.Builder()
- .setSystemUsage(usage).build();
- } else {
- attr = new AudioAttributes.Builder()
- .setUsage(usage).build();
- }
- break;
case RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET:
- int preset = in.readInt();
- attr = new AudioAttributes.Builder()
- .setInternalCapturePreset(preset).build();
+ attr = AudioAttributes.CREATOR.createFromParcel(in);
break;
case RULE_MATCH_UID:
case RULE_MATCH_USERID:
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 8615393..902cdb9 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -9771,7 +9771,7 @@
projection)) {
Slog.w(TAG, "Permission denied to register audio policy for pid "
+ Binder.getCallingPid() + " / uid " + Binder.getCallingUid()
- + ", need MODIFY_AUDIO_ROUTING or MediaProjection that can project audio");
+ + ", need system permission or a MediaProjection that can project audio");
return null;
}