Merge changes from topic "active_device_volume_level" into tm-qpr-dev
* changes: BleAudioVolume: Fix calculation for the activated device AudioService: conditional logging of hearing aid volume
This commit is contained in:
committed by
Android (Google) Code Review
commit
ddf6aa97b9
@@ -1365,7 +1365,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
break;
|
break;
|
||||||
case MSG_II_SET_HEARING_AID_VOLUME:
|
case MSG_II_SET_HEARING_AID_VOLUME:
|
||||||
synchronized (mDeviceStateLock) {
|
synchronized (mDeviceStateLock) {
|
||||||
mBtHelper.setHearingAidVolume(msg.arg1, msg.arg2);
|
mBtHelper.setHearingAidVolume(msg.arg1, msg.arg2,
|
||||||
|
mDeviceInventory.isHearingAidConnected());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MSG_II_SET_LE_AUDIO_OUT_VOLUME: {
|
case MSG_II_SET_LE_AUDIO_OUT_VOLUME: {
|
||||||
|
|||||||
@@ -377,7 +377,8 @@ public class AudioDeviceInventory {
|
|||||||
makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice);
|
makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice);
|
||||||
} else if (switchToAvailable) {
|
} else if (switchToAvailable) {
|
||||||
makeLeAudioDeviceAvailable(address, BtHelper.getName(btInfo.mDevice),
|
makeLeAudioDeviceAvailable(address, BtHelper.getName(btInfo.mDevice),
|
||||||
streamType, btInfo.mVolume, btInfo.mAudioSystemDevice,
|
streamType, btInfo.mVolume == -1 ? -1 : btInfo.mVolume * 10,
|
||||||
|
btInfo.mAudioSystemDevice,
|
||||||
"onSetBtActiveDevice");
|
"onSetBtActiveDevice");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1161,6 +1162,22 @@ public class AudioDeviceInventory {
|
|||||||
.record();
|
.record();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether a device of type DEVICE_OUT_HEARING_AID is connected.
|
||||||
|
* Visibility by APM plays no role
|
||||||
|
* @return true if a DEVICE_OUT_HEARING_AID is connected, false otherwise.
|
||||||
|
*/
|
||||||
|
boolean isHearingAidConnected() {
|
||||||
|
synchronized (mDevicesLock) {
|
||||||
|
for (DeviceInfo di : mConnectedDevices.values()) {
|
||||||
|
if (di.mDeviceType == AudioSystem.DEVICE_OUT_HEARING_AID) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@GuardedBy("mDevicesLock")
|
@GuardedBy("mDevicesLock")
|
||||||
private void makeLeAudioDeviceAvailable(String address, String name, int streamType,
|
private void makeLeAudioDeviceAvailable(String address, String name, int streamType,
|
||||||
int volumeIndex, int device, String eventSource) {
|
int volumeIndex, int device, String eventSource) {
|
||||||
|
|||||||
@@ -4011,7 +4011,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLeAudioVolumeOnModeUpdate(int mode) {
|
private void setLeAudioVolumeOnModeUpdate(int mode, int streamType, int device) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case AudioSystem.MODE_IN_COMMUNICATION:
|
case AudioSystem.MODE_IN_COMMUNICATION:
|
||||||
case AudioSystem.MODE_IN_CALL:
|
case AudioSystem.MODE_IN_CALL:
|
||||||
@@ -4025,8 +4025,6 @@ public class AudioService extends IAudioService.Stub
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int streamType = getBluetoothContextualVolumeStream(mode);
|
|
||||||
|
|
||||||
// Currently, DEVICE_OUT_BLE_HEADSET is the only output type for LE_AUDIO profile.
|
// Currently, DEVICE_OUT_BLE_HEADSET is the only output type for LE_AUDIO profile.
|
||||||
// (See AudioDeviceBroker#createBtDeviceInfo())
|
// (See AudioDeviceBroker#createBtDeviceInfo())
|
||||||
int index = mStreamStates[streamType].getIndex(AudioSystem.DEVICE_OUT_BLE_HEADSET);
|
int index = mStreamStates[streamType].getIndex(AudioSystem.DEVICE_OUT_BLE_HEADSET);
|
||||||
@@ -4037,6 +4035,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
+ index + " maxIndex=" + maxIndex + " streamType=" + streamType);
|
+ index + " maxIndex=" + maxIndex + " streamType=" + streamType);
|
||||||
}
|
}
|
||||||
mDeviceBroker.postSetLeAudioVolumeIndex(index, maxIndex, streamType);
|
mDeviceBroker.postSetLeAudioVolumeIndex(index, maxIndex, streamType);
|
||||||
|
mDeviceBroker.postApplyVolumeOnDevice(streamType, device, "setLeAudioVolumeOnModeUpdate");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setStreamVolume(int streamType, int index, int flags,
|
private void setStreamVolume(int streamType, int index, int flags,
|
||||||
@@ -5417,7 +5416,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
|
|
||||||
// Forcefully set LE audio volume as a workaround, since the value of 'device'
|
// Forcefully set LE audio volume as a workaround, since the value of 'device'
|
||||||
// is not DEVICE_OUT_BLE_* even when BLE is connected.
|
// is not DEVICE_OUT_BLE_* even when BLE is connected.
|
||||||
setLeAudioVolumeOnModeUpdate(mode);
|
setLeAudioVolumeOnModeUpdate(mode, streamType, device);
|
||||||
|
|
||||||
// when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all SCO
|
// when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all SCO
|
||||||
// connections not started by the application changing the mode when pid changes
|
// connections not started by the application changing the mode when pid changes
|
||||||
|
|||||||
@@ -424,7 +424,8 @@ public class BtHelper {
|
|||||||
mLeAudio.setVolume(volume);
|
mLeAudio.setVolume(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ synchronized void setHearingAidVolume(int index, int streamType) {
|
/*package*/ synchronized void setHearingAidVolume(int index, int streamType,
|
||||||
|
boolean isHeadAidConnected) {
|
||||||
if (mHearingAid == null) {
|
if (mHearingAid == null) {
|
||||||
if (AudioService.DEBUG_VOL) {
|
if (AudioService.DEBUG_VOL) {
|
||||||
Log.i(TAG, "setHearingAidVolume: null mHearingAid");
|
Log.i(TAG, "setHearingAidVolume: null mHearingAid");
|
||||||
@@ -441,8 +442,11 @@ public class BtHelper {
|
|||||||
Log.i(TAG, "setHearingAidVolume: calling mHearingAid.setVolume idx="
|
Log.i(TAG, "setHearingAidVolume: calling mHearingAid.setVolume idx="
|
||||||
+ index + " gain=" + gainDB);
|
+ index + " gain=" + gainDB);
|
||||||
}
|
}
|
||||||
AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent(
|
// do not log when hearing aid is not connected to avoid confusion when reading dumpsys
|
||||||
AudioServiceEvents.VolumeEvent.VOL_SET_HEARING_AID_VOL, index, gainDB));
|
if (isHeadAidConnected) {
|
||||||
|
AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent(
|
||||||
|
AudioServiceEvents.VolumeEvent.VOL_SET_HEARING_AID_VOL, index, gainDB));
|
||||||
|
}
|
||||||
mHearingAid.setVolume(gainDB);
|
mHearingAid.setVolume(gainDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user