Merge "audioservice: special mute behavior for BT SCO volume" into qt-dev
This commit is contained in:
@@ -3238,7 +3238,7 @@ public class SettingsProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final class UpgradeController {
|
private final class UpgradeController {
|
||||||
private static final int SETTINGS_VERSION = 181;
|
private static final int SETTINGS_VERSION = 182;
|
||||||
|
|
||||||
private final int mUserId;
|
private final int mUserId;
|
||||||
|
|
||||||
@@ -4421,6 +4421,37 @@ public class SettingsProvider extends ContentProvider {
|
|||||||
currentVersion = 181;
|
currentVersion = 181;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentVersion == 181) {
|
||||||
|
// Version cd : by default, add STREAM_BLUETOOTH_SCO to list of streams that can
|
||||||
|
// be muted.
|
||||||
|
final SettingsState systemSettings = getSystemSettingsLocked(userId);
|
||||||
|
final Setting currentSetting = systemSettings.getSettingLocked(
|
||||||
|
Settings.System.MUTE_STREAMS_AFFECTED);
|
||||||
|
if (!currentSetting.isNull()) {
|
||||||
|
try {
|
||||||
|
int currentSettingIntegerValue = Integer.parseInt(
|
||||||
|
currentSetting.getValue());
|
||||||
|
if ((currentSettingIntegerValue
|
||||||
|
& (1 << AudioManager.STREAM_BLUETOOTH_SCO)) == 0) {
|
||||||
|
systemSettings.insertSettingLocked(
|
||||||
|
Settings.System.MUTE_STREAMS_AFFECTED,
|
||||||
|
Integer.toString(
|
||||||
|
currentSettingIntegerValue
|
||||||
|
| (1 << AudioManager.STREAM_BLUETOOTH_SCO)),
|
||||||
|
null, true, SettingsState.SYSTEM_PACKAGE_NAME);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// remove the setting in case it is not a valid integer
|
||||||
|
Slog.w("Failed to parse integer value of MUTE_STREAMS_AFFECTED"
|
||||||
|
+ "setting, removing setting", e);
|
||||||
|
systemSettings.deleteSettingLocked(
|
||||||
|
Settings.System.MUTE_STREAMS_AFFECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
currentVersion = 182;
|
||||||
|
}
|
||||||
|
|
||||||
// vXXX: Add new settings above this point.
|
// vXXX: Add new settings above this point.
|
||||||
|
|
||||||
if (currentVersion != newVersion) {
|
if (currentVersion != newVersion) {
|
||||||
|
|||||||
@@ -2052,9 +2052,12 @@ public class AudioService extends IAudioService.Stub
|
|||||||
setRingerMode(getNewRingerMode(stream, index, flags),
|
setRingerMode(getNewRingerMode(stream, index, flags),
|
||||||
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,
|
||||||
|
// except for BT SCO stream where only explicit mute is allowed to comply to BT requirements
|
||||||
|
if (streamType != AudioSystem.STREAM_BLUETOOTH_SCO) {
|
||||||
mStreamStates[stream].mute(index == 0);
|
mStreamStates[stream].mute(index == 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void enforceModifyAudioRoutingPermission() {
|
private void enforceModifyAudioRoutingPermission() {
|
||||||
if (mContext.checkCallingPermission(
|
if (mContext.checkCallingPermission(
|
||||||
@@ -2131,14 +2134,11 @@ public class AudioService extends IAudioService.Stub
|
|||||||
+ " CHANGE_ACCESSIBILITY_VOLUME callingPackage=" + callingPackage);
|
+ " CHANGE_ACCESSIBILITY_VOLUME callingPackage=" + callingPackage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((streamType == AudioManager.STREAM_VOICE_CALL ||
|
if ((streamType == AudioManager.STREAM_VOICE_CALL) && (index == 0)
|
||||||
streamType == AudioManager.STREAM_BLUETOOTH_SCO) &&
|
&& (mContext.checkCallingOrSelfPermission(
|
||||||
(index == 0) &&
|
|
||||||
(mContext.checkCallingOrSelfPermission(
|
|
||||||
android.Manifest.permission.MODIFY_PHONE_STATE)
|
android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||||
!= PackageManager.PERMISSION_GRANTED)) {
|
!= PackageManager.PERMISSION_GRANTED)) {
|
||||||
Log.w(TAG, "Trying to call setStreamVolume() for STREAM_VOICE_CALL or"
|
Log.w(TAG, "Trying to call setStreamVolume() for STREAM_VOICE_CALL and index 0 without"
|
||||||
+ " STREAM_BLUETOOTH_SCO and index 0 without"
|
|
||||||
+ " MODIFY_PHONE_STATE callingPackage=" + callingPackage);
|
+ " MODIFY_PHONE_STATE callingPackage=" + callingPackage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -4641,6 +4641,16 @@ public class AudioService extends IAudioService.Stub
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setStreamVolumeIndex(int index, int device) {
|
||||||
|
// Only set audio policy BT SCO stream volume to 0 when the stream is actually muted.
|
||||||
|
// This allows RX path muting by the audio HAL only when explicitly muted but not when
|
||||||
|
// index is just set to 0 to repect BT requirements
|
||||||
|
if (mStreamType == AudioSystem.STREAM_BLUETOOTH_SCO && index == 0 && !mIsMuted) {
|
||||||
|
index = 1;
|
||||||
|
}
|
||||||
|
AudioSystem.setStreamVolumeIndexAS(mStreamType, index, device);
|
||||||
|
}
|
||||||
|
|
||||||
// must be called while synchronized VolumeStreamState.class
|
// must be called while synchronized VolumeStreamState.class
|
||||||
/*package*/ void applyDeviceVolume_syncVSS(int device, boolean isAvrcpAbsVolSupported) {
|
/*package*/ void applyDeviceVolume_syncVSS(int device, boolean isAvrcpAbsVolSupported) {
|
||||||
int index;
|
int index;
|
||||||
@@ -4655,7 +4665,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
} else {
|
} else {
|
||||||
index = (getIndex(device) + 5)/10;
|
index = (getIndex(device) + 5)/10;
|
||||||
}
|
}
|
||||||
AudioSystem.setStreamVolumeIndexAS(mStreamType, index, device);
|
setStreamVolumeIndex(index, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyAllVolumes() {
|
public void applyAllVolumes() {
|
||||||
@@ -4678,7 +4688,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
} else {
|
} else {
|
||||||
index = (mIndexMap.valueAt(i) + 5)/10;
|
index = (mIndexMap.valueAt(i) + 5)/10;
|
||||||
}
|
}
|
||||||
AudioSystem.setStreamVolumeIndexAS(mStreamType, index, device);
|
setStreamVolumeIndex(index, device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// apply default volume last: by convention , default device volume will be used
|
// apply default volume last: by convention , default device volume will be used
|
||||||
@@ -4688,8 +4698,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
} else {
|
} else {
|
||||||
index = (getIndex(AudioSystem.DEVICE_OUT_DEFAULT) + 5)/10;
|
index = (getIndex(AudioSystem.DEVICE_OUT_DEFAULT) + 5)/10;
|
||||||
}
|
}
|
||||||
AudioSystem.setStreamVolumeIndexAS(
|
setStreamVolumeIndex(index, AudioSystem.DEVICE_OUT_DEFAULT);
|
||||||
mStreamType, index, AudioSystem.DEVICE_OUT_DEFAULT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user