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); final AudioPlaybackConfiguration anonymCopy = new AudioPlaybackConfiguration(in.mPlayerIId);
anonymCopy.mPlayerState = in.mPlayerState; anonymCopy.mPlayerState = in.mPlayerState;
// do not reuse the full attributes: only usage, content type and public flags are allowed // do not reuse the full attributes: only usage, content type and public flags are allowed
anonymCopy.mPlayerAttr = new AudioAttributes.Builder() AudioAttributes.Builder builder = new AudioAttributes.Builder()
.setUsage(in.mPlayerAttr.getUsage())
.setContentType(in.mPlayerAttr.getContentType()) .setContentType(in.mPlayerAttr.getContentType())
.setFlags(in.mPlayerAttr.getFlags()) .setFlags(in.mPlayerAttr.getFlags())
.setAllowedCapturePolicy( .setAllowedCapturePolicy(
in.mPlayerAttr.getAllowedCapturePolicy() == ALLOW_CAPTURE_BY_ALL in.mPlayerAttr.getAllowedCapturePolicy() == ALLOW_CAPTURE_BY_ALL
? ALLOW_CAPTURE_BY_ALL : ALLOW_CAPTURE_BY_NONE) ? ALLOW_CAPTURE_BY_ALL : ALLOW_CAPTURE_BY_NONE);
.build(); 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; anonymCopy.mDeviceId = in.mDeviceId;
// anonymized data // anonymized data
anonymCopy.mPlayerType = PLAYER_TYPE_UNKNOWN; anonymCopy.mPlayerType = PLAYER_TYPE_UNKNOWN;

View File

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