fixup '[IMPR] AudioManager: add adjustAttributesVolume API'
Bug: 237409207 Bug: 260298113 Test: atest AudioManagerTest#testAdjustVolumeGroupVolume Change-Id: I0a2b90d1ecc2d14b484e12e5da5edf2bf5aefbe2 Merged-In: I0a2b90d1ecc2d14b484e12e5da5edf2bf5aefbe2
This commit is contained in:
committed by
Eric Laurent
parent
31bb5135cc
commit
adc81000e3
@@ -3759,7 +3759,9 @@ public class AudioService extends IAudioService.Stub
|
|||||||
throw new IllegalArgumentException("No volume group for id " + groupId);
|
throw new IllegalArgumentException("No volume group for id " + groupId);
|
||||||
}
|
}
|
||||||
VolumeGroupState vgs = sVolumeGroupStates.get(groupId);
|
VolumeGroupState vgs = sVolumeGroupStates.get(groupId);
|
||||||
return vgs.isMuted() ? vgs.getMinIndex() : vgs.getVolumeIndex();
|
// Return 0 when muted, not min index since for e.g. Voice Call, it has a non zero
|
||||||
|
// min but it mutable on permission condition.
|
||||||
|
return vgs.isMuted() ? 0 : vgs.getVolumeIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3871,6 +3873,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
}
|
}
|
||||||
VolumeGroupState vgs = sVolumeGroupStates.get(groupId);
|
VolumeGroupState vgs = sVolumeGroupStates.get(groupId);
|
||||||
// For compatibility reason, use stream API if group linked to a valid stream
|
// For compatibility reason, use stream API if group linked to a valid stream
|
||||||
|
boolean fallbackOnStream = false;
|
||||||
for (int stream : vgs.getLegacyStreamTypes()) {
|
for (int stream : vgs.getLegacyStreamTypes()) {
|
||||||
try {
|
try {
|
||||||
ensureValidStreamType(stream);
|
ensureValidStreamType(stream);
|
||||||
@@ -3879,14 +3882,21 @@ public class AudioService extends IAudioService.Stub
|
|||||||
+ "), do not change associated stream volume");
|
+ "), do not change associated stream volume");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Call only for the first valid stream, legacy API will propagate to aliased streams.
|
|
||||||
// Note: Group and Stream does not share same convention, 0 is mute for stream,
|
// Note: Group and Stream does not share same convention, 0 is mute for stream,
|
||||||
// min index is acting as mute for Groups
|
// min index is acting as mute for Groups
|
||||||
if (vgs.isVssMuteBijective(stream)) {
|
if (vgs.isVssMuteBijective(stream)) {
|
||||||
adjustStreamVolume(stream, direction, flags, callingPackage);
|
adjustStreamVolume(stream, direction, flags, callingPackage);
|
||||||
return;
|
if (isMuteAdjust(direction)) {
|
||||||
|
// will be propagated to all aliased streams
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fallbackOnStream = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fallbackOnStream) {
|
||||||
|
// Handled by at least one stream, will be propagated to group, bailing out.
|
||||||
|
return;
|
||||||
|
}
|
||||||
sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_ADJUST_GROUP_VOL, vgs.name(),
|
sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_ADJUST_GROUP_VOL, vgs.name(),
|
||||||
direction, flags, callingPackage));
|
direction, flags, callingPackage));
|
||||||
vgs.adjustVolume(direction, flags);
|
vgs.adjustVolume(direction, flags);
|
||||||
@@ -5096,7 +5106,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setRingerMode(int ringerMode, String caller, boolean external) {
|
private void setRingerMode(int ringerMode, String caller, boolean external) {
|
||||||
if (mUseFixedVolume || mIsSingleVolume) {
|
if (mUseFixedVolume || mIsSingleVolume || mUseVolumeGroupAliases) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (caller == null || caller.length() == 0) {
|
if (caller == null || caller.length() == 0) {
|
||||||
@@ -7587,7 +7597,13 @@ public class AudioService extends IAudioService.Stub
|
|||||||
synchronized (VolumeStreamState.class) {
|
synchronized (VolumeStreamState.class) {
|
||||||
int device = getDeviceForVolume();
|
int device = getDeviceForVolume();
|
||||||
int previousIndex = getIndex(device);
|
int previousIndex = getIndex(device);
|
||||||
|
if (isMuteAdjust(direction) && !isMutable()) {
|
||||||
|
// Non mutable volume group
|
||||||
|
if (DEBUG_VOL) {
|
||||||
|
Log.d(TAG, "invalid mute on unmutable volume group " + name());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case AudioManager.ADJUST_TOGGLE_MUTE: {
|
case AudioManager.ADJUST_TOGGLE_MUTE: {
|
||||||
// Note: If muted by volume 0, unmute will restore volume 0.
|
// Note: If muted by volume 0, unmute will restore volume 0.
|
||||||
|
|||||||
Reference in New Issue
Block a user