AudioService: setDeviceVolume shouln't change the mute state
Do not allow the codepath for setDeviceVolume to alter the mute state of a stream. Bug: 266211560 Test: adb shell dumpsys audio in silent mode after reboot Change-Id: I4da94d75a1396fc6d1486a0955fb537b7638e9d6
This commit is contained in:
@@ -3757,8 +3757,19 @@ public class AudioService extends IAudioService.Stub
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ void onSetStreamVolume(int streamType, int index, int flags, int device,
|
/**
|
||||||
String caller, boolean hasModifyAudioSettings) {
|
* Update stream volume, ringer mode and mute status after a volume index change
|
||||||
|
* @param streamType
|
||||||
|
* @param index
|
||||||
|
* @param flags
|
||||||
|
* @param device the device for which the volume is changed
|
||||||
|
* @param caller
|
||||||
|
* @param hasModifyAudioSettings
|
||||||
|
* @param canChangeMute true if the origin of this event is one where the mute state should be
|
||||||
|
* updated following the change in volume index
|
||||||
|
*/
|
||||||
|
/*package*/ void onSetStreamVolume(int streamType, int index, int flags, int device,
|
||||||
|
String caller, boolean hasModifyAudioSettings, boolean canChangeMute) {
|
||||||
final int stream = mStreamVolumeAlias[streamType];
|
final int stream = mStreamVolumeAlias[streamType];
|
||||||
setStreamVolumeInt(stream, index, device, false, caller, hasModifyAudioSettings);
|
setStreamVolumeInt(stream, index, device, false, caller, hasModifyAudioSettings);
|
||||||
// setting volume on ui sounds stream type also controls silent mode
|
// setting volume on ui sounds stream type also controls silent mode
|
||||||
@@ -3768,10 +3779,8 @@ public class AudioService extends IAudioService.Stub
|
|||||||
TAG + ".onSetStreamVolume", false /*external*/);
|
TAG + ".onSetStreamVolume", false /*external*/);
|
||||||
}
|
}
|
||||||
// setting non-zero volume for a muted stream unmutes the stream and vice versa
|
// setting non-zero volume for a muted stream unmutes the stream and vice versa
|
||||||
// (only when changing volume for the current device),
|
|
||||||
// except for BT SCO stream where only explicit mute is allowed to comply to BT requirements
|
// except for BT SCO stream where only explicit mute is allowed to comply to BT requirements
|
||||||
if ((streamType != AudioSystem.STREAM_BLUETOOTH_SCO)
|
if ((streamType != AudioSystem.STREAM_BLUETOOTH_SCO) && canChangeMute) {
|
||||||
&& (getDeviceForStream(stream) == device)) {
|
|
||||||
// As adjustStreamVolume with muteAdjust flags mute/unmutes stream and aliased streams.
|
// As adjustStreamVolume with muteAdjust flags mute/unmutes stream and aliased streams.
|
||||||
muteAliasStreams(stream, index == 0);
|
muteAliasStreams(stream, index == 0);
|
||||||
}
|
}
|
||||||
@@ -4494,7 +4503,10 @@ public class AudioService extends IAudioService.Stub
|
|||||||
|
|
||||||
if (!mSoundDoseHelper.willDisplayWarningAfterCheckVolume(streamType, index, device,
|
if (!mSoundDoseHelper.willDisplayWarningAfterCheckVolume(streamType, index, device,
|
||||||
flags)) {
|
flags)) {
|
||||||
onSetStreamVolume(streamType, index, flags, device, caller, hasModifyAudioSettings);
|
onSetStreamVolume(streamType, index, flags, device, caller, hasModifyAudioSettings,
|
||||||
|
// ada is non-null when called from setDeviceVolume,
|
||||||
|
// which shouldn't update the mute state
|
||||||
|
ada == null /*canChangeMute*/);
|
||||||
index = mStreamStates[streamType].getIndex(device);
|
index = mStreamStates[streamType].getIndex(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -404,7 +404,8 @@ public class SoundDoseHelper {
|
|||||||
mPendingVolumeCommand.mIndex,
|
mPendingVolumeCommand.mIndex,
|
||||||
mPendingVolumeCommand.mFlags,
|
mPendingVolumeCommand.mFlags,
|
||||||
mPendingVolumeCommand.mDevice,
|
mPendingVolumeCommand.mDevice,
|
||||||
callingPackage, true /*hasModifyAudioSettings*/);
|
callingPackage, true /*hasModifyAudioSettings*/,
|
||||||
|
true /*canChangeMute*/);
|
||||||
mPendingVolumeCommand = null;
|
mPendingVolumeCommand = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user