Merge "AudioService: fix call volume switching from speaker to hearing aid" into qt-dev
This commit is contained in:
@@ -723,7 +723,8 @@ import com.android.internal.annotations.GuardedBy;
|
|||||||
case MSG_IL_SET_HEARING_AID_CONNECTION_STATE:
|
case MSG_IL_SET_HEARING_AID_CONNECTION_STATE:
|
||||||
synchronized (mDeviceStateLock) {
|
synchronized (mDeviceStateLock) {
|
||||||
mDeviceInventory.onSetHearingAidConnectionState(
|
mDeviceInventory.onSetHearingAidConnectionState(
|
||||||
(BluetoothDevice) msg.obj, msg.arg1);
|
(BluetoothDevice) msg.obj, msg.arg1,
|
||||||
|
mAudioService.getHearingAidStreamType());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MSG_BT_HEADSET_CNCT_FAILED:
|
case MSG_BT_HEADSET_CNCT_FAILED:
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ public final class AudioDeviceInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ void onSetHearingAidConnectionState(BluetoothDevice btDevice,
|
/*package*/ void onSetHearingAidConnectionState(BluetoothDevice btDevice,
|
||||||
@AudioService.BtProfileConnectionState int state) {
|
@AudioService.BtProfileConnectionState int state, int streamType) {
|
||||||
String address = btDevice.getAddress();
|
String address = btDevice.getAddress();
|
||||||
if (!BluetoothAdapter.checkBluetoothAddress(address)) {
|
if (!BluetoothAdapter.checkBluetoothAddress(address)) {
|
||||||
address = "";
|
address = "";
|
||||||
@@ -253,7 +253,7 @@ public final class AudioDeviceInventory {
|
|||||||
if (isConnected && state != BluetoothProfile.STATE_CONNECTED) {
|
if (isConnected && state != BluetoothProfile.STATE_CONNECTED) {
|
||||||
makeHearingAidDeviceUnavailable(address);
|
makeHearingAidDeviceUnavailable(address);
|
||||||
} else if (!isConnected && state == BluetoothProfile.STATE_CONNECTED) {
|
} else if (!isConnected && state == BluetoothProfile.STATE_CONNECTED) {
|
||||||
makeHearingAidDeviceAvailable(address, BtHelper.getName(btDevice),
|
makeHearingAidDeviceAvailable(address, BtHelper.getName(btDevice), streamType,
|
||||||
"onSetHearingAidConnectionState");
|
"onSetHearingAidConnectionState");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -719,10 +719,11 @@ public final class AudioDeviceInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GuardedBy("mConnectedDevices")
|
@GuardedBy("mConnectedDevices")
|
||||||
private void makeHearingAidDeviceAvailable(String address, String name, String eventSource) {
|
private void makeHearingAidDeviceAvailable(
|
||||||
final int hearingAidVolIndex = mDeviceBroker.getVssVolumeForDevice(AudioSystem.STREAM_MUSIC,
|
String address, String name, int streamType, String eventSource) {
|
||||||
|
final int hearingAidVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType,
|
||||||
AudioSystem.DEVICE_OUT_HEARING_AID);
|
AudioSystem.DEVICE_OUT_HEARING_AID);
|
||||||
mDeviceBroker.postSetHearingAidVolumeIndex(hearingAidVolIndex, AudioSystem.STREAM_MUSIC);
|
mDeviceBroker.postSetHearingAidVolumeIndex(hearingAidVolIndex, streamType);
|
||||||
|
|
||||||
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_HEARING_AID,
|
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_HEARING_AID,
|
||||||
AudioSystem.DEVICE_STATE_AVAILABLE, address, name,
|
AudioSystem.DEVICE_STATE_AVAILABLE, address, name,
|
||||||
@@ -732,7 +733,7 @@ public final class AudioDeviceInventory {
|
|||||||
new DeviceInfo(AudioSystem.DEVICE_OUT_HEARING_AID, name,
|
new DeviceInfo(AudioSystem.DEVICE_OUT_HEARING_AID, name,
|
||||||
address, AudioSystem.AUDIO_FORMAT_DEFAULT));
|
address, AudioSystem.AUDIO_FORMAT_DEFAULT));
|
||||||
mDeviceBroker.postAccessoryPlugMediaUnmute(AudioSystem.DEVICE_OUT_HEARING_AID);
|
mDeviceBroker.postAccessoryPlugMediaUnmute(AudioSystem.DEVICE_OUT_HEARING_AID);
|
||||||
mDeviceBroker.postApplyVolumeOnDevice(AudioSystem.STREAM_MUSIC,
|
mDeviceBroker.postApplyVolumeOnDevice(streamType,
|
||||||
AudioSystem.DEVICE_OUT_HEARING_AID, "makeHearingAidDeviceAvailable");
|
AudioSystem.DEVICE_OUT_HEARING_AID, "makeHearingAidDeviceAvailable");
|
||||||
setCurrentAudioRouteNameIfPossible(name);
|
setCurrentAudioRouteNameIfPossible(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2078,6 +2078,22 @@ public class AudioService extends IAudioService.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*package*/ int getHearingAidStreamType() {
|
||||||
|
return getHearingAidStreamType(mMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getHearingAidStreamType(int mode) {
|
||||||
|
switch (mode) {
|
||||||
|
case AudioSystem.MODE_IN_COMMUNICATION:
|
||||||
|
case AudioSystem.MODE_IN_CALL:
|
||||||
|
return AudioSystem.STREAM_VOICE_CALL;
|
||||||
|
case AudioSystem.MODE_NORMAL:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return AudioSystem.STREAM_MUSIC;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage an audio mode change for audio devices that use an "absolute volume" model,
|
* Manage an audio mode change for audio devices that use an "absolute volume" model,
|
||||||
* i.e. the framework sends the full scale signal, and the actual volume for the use case
|
* i.e. the framework sends the full scale signal, and the actual volume for the use case
|
||||||
@@ -2087,14 +2103,10 @@ public class AudioService extends IAudioService.Stub
|
|||||||
if (oldMode == newMode) {
|
if (oldMode == newMode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int streamType = AudioSystem.STREAM_MUSIC;
|
|
||||||
switch (newMode) {
|
switch (newMode) {
|
||||||
case AudioSystem.MODE_IN_COMMUNICATION:
|
case AudioSystem.MODE_IN_COMMUNICATION:
|
||||||
case AudioSystem.MODE_IN_CALL:
|
case AudioSystem.MODE_IN_CALL:
|
||||||
streamType = AudioSystem.STREAM_VOICE_CALL;
|
|
||||||
break;
|
|
||||||
case AudioSystem.MODE_NORMAL:
|
case AudioSystem.MODE_NORMAL:
|
||||||
streamType = AudioSystem.STREAM_MUSIC;
|
|
||||||
break;
|
break;
|
||||||
case AudioSystem.MODE_RINGTONE:
|
case AudioSystem.MODE_RINGTONE:
|
||||||
// not changing anything for ringtone
|
// not changing anything for ringtone
|
||||||
@@ -2105,6 +2117,9 @@ public class AudioService extends IAudioService.Stub
|
|||||||
// don't know what to do in this case, better bail
|
// don't know what to do in this case, better bail
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int streamType = getHearingAidStreamType(newMode);
|
||||||
|
|
||||||
final int device = AudioSystem.getDevicesForStream(streamType);
|
final int device = AudioSystem.getDevicesForStream(streamType);
|
||||||
if ((device & mAbsVolumeMultiModeCaseDevices) == 0) {
|
if ((device & mAbsVolumeMultiModeCaseDevices) == 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user