Merge "audioservice: special mute behavior for BT SCO volume" into qt-dev am: 98edda5b5e
am: 39749b093e
Change-Id: If763c3604ce6df755510db66db9e9426cd147805
This commit is contained in:
@@ -3241,7 +3241,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private final class UpgradeController {
|
||||
private static final int SETTINGS_VERSION = 181;
|
||||
private static final int SETTINGS_VERSION = 182;
|
||||
|
||||
private final int mUserId;
|
||||
|
||||
@@ -4424,6 +4424,37 @@ public class SettingsProvider extends ContentProvider {
|
||||
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.
|
||||
|
||||
if (currentVersion != newVersion) {
|
||||
|
||||
@@ -2052,8 +2052,11 @@ public class AudioService extends IAudioService.Stub
|
||||
setRingerMode(getNewRingerMode(stream, index, flags),
|
||||
TAG + ".onSetStreamVolume", false /*external*/);
|
||||
}
|
||||
// setting non-zero volume for a muted stream unmutes the stream and vice versa
|
||||
mStreamStates[stream].mute(index == 0);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
private void enforceModifyAudioRoutingPermission() {
|
||||
@@ -2131,14 +2134,11 @@ public class AudioService extends IAudioService.Stub
|
||||
+ " CHANGE_ACCESSIBILITY_VOLUME callingPackage=" + callingPackage);
|
||||
return;
|
||||
}
|
||||
if ((streamType == AudioManager.STREAM_VOICE_CALL ||
|
||||
streamType == AudioManager.STREAM_BLUETOOTH_SCO) &&
|
||||
(index == 0) &&
|
||||
(mContext.checkCallingOrSelfPermission(
|
||||
android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
if ((streamType == AudioManager.STREAM_VOICE_CALL) && (index == 0)
|
||||
&& (mContext.checkCallingOrSelfPermission(
|
||||
android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
!= PackageManager.PERMISSION_GRANTED)) {
|
||||
Log.w(TAG, "Trying to call setStreamVolume() for STREAM_VOICE_CALL or"
|
||||
+ " STREAM_BLUETOOTH_SCO and index 0 without"
|
||||
Log.w(TAG, "Trying to call setStreamVolume() for STREAM_VOICE_CALL and index 0 without"
|
||||
+ " MODIFY_PHONE_STATE callingPackage=" + callingPackage);
|
||||
return;
|
||||
}
|
||||
@@ -4642,6 +4642,16 @@ public class AudioService extends IAudioService.Stub
|
||||
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
|
||||
/*package*/ void applyDeviceVolume_syncVSS(int device, boolean isAvrcpAbsVolSupported) {
|
||||
int index;
|
||||
@@ -4656,7 +4666,7 @@ public class AudioService extends IAudioService.Stub
|
||||
} else {
|
||||
index = (getIndex(device) + 5)/10;
|
||||
}
|
||||
AudioSystem.setStreamVolumeIndexAS(mStreamType, index, device);
|
||||
setStreamVolumeIndex(index, device);
|
||||
}
|
||||
|
||||
public void applyAllVolumes() {
|
||||
@@ -4679,7 +4689,7 @@ public class AudioService extends IAudioService.Stub
|
||||
} else {
|
||||
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
|
||||
@@ -4689,8 +4699,7 @@ public class AudioService extends IAudioService.Stub
|
||||
} else {
|
||||
index = (getIndex(AudioSystem.DEVICE_OUT_DEFAULT) + 5)/10;
|
||||
}
|
||||
AudioSystem.setStreamVolumeIndexAS(
|
||||
mStreamType, index, AudioSystem.DEVICE_OUT_DEFAULT);
|
||||
setStreamVolumeIndex(index, AudioSystem.DEVICE_OUT_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user