Loading services/core/java/com/android/server/audio/AudioDeviceBroker.java +2 −1 Original line number Diff line number Diff line Loading @@ -723,7 +723,8 @@ import com.android.internal.annotations.GuardedBy; case MSG_IL_SET_HEARING_AID_CONNECTION_STATE: synchronized (mDeviceStateLock) { mDeviceInventory.onSetHearingAidConnectionState( (BluetoothDevice) msg.obj, msg.arg1); (BluetoothDevice) msg.obj, msg.arg1, mAudioService.getHearingAidStreamType()); } break; case MSG_BT_HEADSET_CNCT_FAILED: Loading services/core/java/com/android/server/audio/AudioDeviceInventory.java +7 −6 Original line number Diff line number Diff line Loading @@ -236,7 +236,7 @@ public final class AudioDeviceInventory { } /*package*/ void onSetHearingAidConnectionState(BluetoothDevice btDevice, @AudioService.BtProfileConnectionState int state) { @AudioService.BtProfileConnectionState int state, int streamType) { String address = btDevice.getAddress(); if (!BluetoothAdapter.checkBluetoothAddress(address)) { address = ""; Loading @@ -253,7 +253,7 @@ public final class AudioDeviceInventory { if (isConnected && state != BluetoothProfile.STATE_CONNECTED) { makeHearingAidDeviceUnavailable(address); } else if (!isConnected && state == BluetoothProfile.STATE_CONNECTED) { makeHearingAidDeviceAvailable(address, BtHelper.getName(btDevice), makeHearingAidDeviceAvailable(address, BtHelper.getName(btDevice), streamType, "onSetHearingAidConnectionState"); } } Loading Loading @@ -719,10 +719,11 @@ public final class AudioDeviceInventory { } @GuardedBy("mConnectedDevices") private void makeHearingAidDeviceAvailable(String address, String name, String eventSource) { final int hearingAidVolIndex = mDeviceBroker.getVssVolumeForDevice(AudioSystem.STREAM_MUSIC, private void makeHearingAidDeviceAvailable( String address, String name, int streamType, String eventSource) { final int hearingAidVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType, AudioSystem.DEVICE_OUT_HEARING_AID); mDeviceBroker.postSetHearingAidVolumeIndex(hearingAidVolIndex, AudioSystem.STREAM_MUSIC); mDeviceBroker.postSetHearingAidVolumeIndex(hearingAidVolIndex, streamType); AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_HEARING_AID, AudioSystem.DEVICE_STATE_AVAILABLE, address, name, Loading @@ -732,7 +733,7 @@ public final class AudioDeviceInventory { new DeviceInfo(AudioSystem.DEVICE_OUT_HEARING_AID, name, address, AudioSystem.AUDIO_FORMAT_DEFAULT)); mDeviceBroker.postAccessoryPlugMediaUnmute(AudioSystem.DEVICE_OUT_HEARING_AID); mDeviceBroker.postApplyVolumeOnDevice(AudioSystem.STREAM_MUSIC, mDeviceBroker.postApplyVolumeOnDevice(streamType, AudioSystem.DEVICE_OUT_HEARING_AID, "makeHearingAidDeviceAvailable"); setCurrentAudioRouteNameIfPossible(name); } Loading services/core/java/com/android/server/audio/AudioService.java +19 −4 Original line number Diff line number Diff line Loading @@ -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, * i.e. the framework sends the full scale signal, and the actual volume for the use case Loading @@ -2087,14 +2103,10 @@ public class AudioService extends IAudioService.Stub if (oldMode == newMode) { return; } int streamType = AudioSystem.STREAM_MUSIC; switch (newMode) { case AudioSystem.MODE_IN_COMMUNICATION: case AudioSystem.MODE_IN_CALL: streamType = AudioSystem.STREAM_VOICE_CALL; break; case AudioSystem.MODE_NORMAL: streamType = AudioSystem.STREAM_MUSIC; break; case AudioSystem.MODE_RINGTONE: // not changing anything for ringtone Loading @@ -2105,6 +2117,9 @@ public class AudioService extends IAudioService.Stub // don't know what to do in this case, better bail return; } int streamType = getHearingAidStreamType(newMode); final int device = AudioSystem.getDevicesForStream(streamType); if ((device & mAbsVolumeMultiModeCaseDevices) == 0) { return; Loading Loading
services/core/java/com/android/server/audio/AudioDeviceBroker.java +2 −1 Original line number Diff line number Diff line Loading @@ -723,7 +723,8 @@ import com.android.internal.annotations.GuardedBy; case MSG_IL_SET_HEARING_AID_CONNECTION_STATE: synchronized (mDeviceStateLock) { mDeviceInventory.onSetHearingAidConnectionState( (BluetoothDevice) msg.obj, msg.arg1); (BluetoothDevice) msg.obj, msg.arg1, mAudioService.getHearingAidStreamType()); } break; case MSG_BT_HEADSET_CNCT_FAILED: Loading
services/core/java/com/android/server/audio/AudioDeviceInventory.java +7 −6 Original line number Diff line number Diff line Loading @@ -236,7 +236,7 @@ public final class AudioDeviceInventory { } /*package*/ void onSetHearingAidConnectionState(BluetoothDevice btDevice, @AudioService.BtProfileConnectionState int state) { @AudioService.BtProfileConnectionState int state, int streamType) { String address = btDevice.getAddress(); if (!BluetoothAdapter.checkBluetoothAddress(address)) { address = ""; Loading @@ -253,7 +253,7 @@ public final class AudioDeviceInventory { if (isConnected && state != BluetoothProfile.STATE_CONNECTED) { makeHearingAidDeviceUnavailable(address); } else if (!isConnected && state == BluetoothProfile.STATE_CONNECTED) { makeHearingAidDeviceAvailable(address, BtHelper.getName(btDevice), makeHearingAidDeviceAvailable(address, BtHelper.getName(btDevice), streamType, "onSetHearingAidConnectionState"); } } Loading Loading @@ -719,10 +719,11 @@ public final class AudioDeviceInventory { } @GuardedBy("mConnectedDevices") private void makeHearingAidDeviceAvailable(String address, String name, String eventSource) { final int hearingAidVolIndex = mDeviceBroker.getVssVolumeForDevice(AudioSystem.STREAM_MUSIC, private void makeHearingAidDeviceAvailable( String address, String name, int streamType, String eventSource) { final int hearingAidVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType, AudioSystem.DEVICE_OUT_HEARING_AID); mDeviceBroker.postSetHearingAidVolumeIndex(hearingAidVolIndex, AudioSystem.STREAM_MUSIC); mDeviceBroker.postSetHearingAidVolumeIndex(hearingAidVolIndex, streamType); AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_HEARING_AID, AudioSystem.DEVICE_STATE_AVAILABLE, address, name, Loading @@ -732,7 +733,7 @@ public final class AudioDeviceInventory { new DeviceInfo(AudioSystem.DEVICE_OUT_HEARING_AID, name, address, AudioSystem.AUDIO_FORMAT_DEFAULT)); mDeviceBroker.postAccessoryPlugMediaUnmute(AudioSystem.DEVICE_OUT_HEARING_AID); mDeviceBroker.postApplyVolumeOnDevice(AudioSystem.STREAM_MUSIC, mDeviceBroker.postApplyVolumeOnDevice(streamType, AudioSystem.DEVICE_OUT_HEARING_AID, "makeHearingAidDeviceAvailable"); setCurrentAudioRouteNameIfPossible(name); } Loading
services/core/java/com/android/server/audio/AudioService.java +19 −4 Original line number Diff line number Diff line Loading @@ -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, * i.e. the framework sends the full scale signal, and the actual volume for the use case Loading @@ -2087,14 +2103,10 @@ public class AudioService extends IAudioService.Stub if (oldMode == newMode) { return; } int streamType = AudioSystem.STREAM_MUSIC; switch (newMode) { case AudioSystem.MODE_IN_COMMUNICATION: case AudioSystem.MODE_IN_CALL: streamType = AudioSystem.STREAM_VOICE_CALL; break; case AudioSystem.MODE_NORMAL: streamType = AudioSystem.STREAM_MUSIC; break; case AudioSystem.MODE_RINGTONE: // not changing anything for ringtone Loading @@ -2105,6 +2117,9 @@ public class AudioService extends IAudioService.Stub // don't know what to do in this case, better bail return; } int streamType = getHearingAidStreamType(newMode); final int device = AudioSystem.getDevicesForStream(streamType); if ((device & mAbsVolumeMultiModeCaseDevices) == 0) { return; Loading