Merge "Fixed AudioMixingRule usage of AudioAttribute#getUsage" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-05-07 20:06:35 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 10 deletions

View File

@@ -267,14 +267,18 @@ public final class AudioPlaybackConfiguration implements Parcelable {
final AudioPlaybackConfiguration anonymCopy = new AudioPlaybackConfiguration(in.mPlayerIId);
anonymCopy.mPlayerState = in.mPlayerState;
// do not reuse the full attributes: only usage, content type and public flags are allowed
anonymCopy.mPlayerAttr = new AudioAttributes.Builder()
.setUsage(in.mPlayerAttr.getUsage())
AudioAttributes.Builder builder = new AudioAttributes.Builder()
.setContentType(in.mPlayerAttr.getContentType())
.setFlags(in.mPlayerAttr.getFlags())
.setAllowedCapturePolicy(
in.mPlayerAttr.getAllowedCapturePolicy() == ALLOW_CAPTURE_BY_ALL
? ALLOW_CAPTURE_BY_ALL : ALLOW_CAPTURE_BY_NONE)
.build();
? ALLOW_CAPTURE_BY_ALL : ALLOW_CAPTURE_BY_NONE);
if (AudioAttributes.isSystemUsage(in.mPlayerAttr.getSystemUsage())) {
builder.setSystemUsage(in.mPlayerAttr.getSystemUsage());
} else {
builder.setUsage(in.mPlayerAttr.getUsage());
}
anonymCopy.mPlayerAttr = builder.build();
anonymCopy.mDeviceId = in.mDeviceId;
// anonymized data
anonymCopy.mPlayerType = PLAYER_TYPE_UNKNOWN;

View File

@@ -140,7 +140,7 @@ public class AudioMixingRule {
final int match_rule = mRule & ~RULE_EXCLUSION_MASK;
switch (match_rule) {
case RULE_MATCH_ATTRIBUTE_USAGE:
dest.writeInt(mAttr.getUsage());
dest.writeInt(mAttr.getSystemUsage());
break;
case RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET:
dest.writeInt(mAttr.getCapturePreset());
@@ -165,7 +165,7 @@ public class AudioMixingRule {
for (AudioMixMatchCriterion criterion : mCriteria) {
if ((criterion.mRule & RULE_MATCH_ATTRIBUTE_USAGE) != 0
&& criterion.mAttr != null
&& criterion.mAttr.getUsage() == usage) {
&& criterion.mAttr.getSystemUsage() == usage) {
return true;
}
}
@@ -182,7 +182,7 @@ public class AudioMixingRule {
for (AudioMixMatchCriterion criterion : mCriteria) {
if (criterion.mRule == RULE_MATCH_ATTRIBUTE_USAGE
&& criterion.mAttr != null
&& criterion.mAttr.getUsage() == usage) {
&& criterion.mAttr.getSystemUsage() == usage) {
return true;
}
}
@@ -565,7 +565,7 @@ public class AudioMixingRule {
switch (match_rule) {
case RULE_MATCH_ATTRIBUTE_USAGE:
// "usage"-based rule
if (criterion.mAttr.getUsage() == attrToMatch.getUsage()) {
if (criterion.mAttr.getSystemUsage() == attrToMatch.getSystemUsage()) {
if (criterion.mRule == rule) {
// rule already exists, we're done
return this;
@@ -646,8 +646,13 @@ public class AudioMixingRule {
switch (match_rule) {
case RULE_MATCH_ATTRIBUTE_USAGE:
int usage = in.readInt();
attr = new AudioAttributes.Builder()
.setUsage(usage).build();
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();