Loading media/java/android/media/AudioSystem.java +8 −0 Original line number Diff line number Diff line Loading @@ -2385,6 +2385,14 @@ public class AudioSystem return types.size() == 1 && types.contains(type); } /** * @hide * Return true if the audio device type is a Bluetooth LE Audio device. */ public static boolean isLeAudioDeviceType(int type) { return DEVICE_OUT_ALL_BLE_SET.contains(type); } /** @hide */ public static final int DEFAULT_MUTE_STREAMS_AFFECTED = (1 << STREAM_MUSIC) | Loading services/core/java/com/android/server/audio/AudioService.java +11 −8 Original line number Diff line number Diff line Loading @@ -3355,8 +3355,7 @@ public class AudioService extends IAudioService.Stub dispatchAbsoluteVolumeChanged(streamType, info, newIndex); } if ((device == AudioSystem.DEVICE_OUT_BLE_HEADSET || device == AudioSystem.DEVICE_OUT_BLE_BROADCAST) if (AudioSystem.isLeAudioDeviceType(device) && streamType == getBluetoothContextualVolumeStream() && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) { if (DEBUG_VOL) { Loading Loading @@ -4112,8 +4111,7 @@ public class AudioService extends IAudioService.Stub dispatchAbsoluteVolumeChanged(streamType, info, index); } if ((device == AudioSystem.DEVICE_OUT_BLE_HEADSET || device == AudioSystem.DEVICE_OUT_BLE_BROADCAST) if (AudioSystem.isLeAudioDeviceType(device) && streamType == getBluetoothContextualVolumeStream() && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) { if (DEBUG_VOL) { Loading Loading @@ -6952,7 +6950,8 @@ public class AudioService extends IAudioService.Stub return AudioManager.DEVICE_VOLUME_BEHAVIOR_ABSOLUTE_MULTI_MODE; } if (isAbsoluteVolumeDevice(audioSystemDeviceOut) || isA2dpAbsoluteVolumeDevice(audioSystemDeviceOut)) { || isA2dpAbsoluteVolumeDevice(audioSystemDeviceOut) || AudioSystem.isLeAudioDeviceType(audioSystemDeviceOut)) { return AudioManager.DEVICE_VOLUME_BEHAVIOR_ABSOLUTE; } return AudioManager.DEVICE_VOLUME_BEHAVIOR_VARIABLE; Loading Loading @@ -7719,7 +7718,9 @@ public class AudioService extends IAudioService.Stub int index; if (isFullyMuted()) { index = 0; } else if (isAbsoluteVolumeDevice(device) || isA2dpAbsoluteVolumeDevice(device)) { } else if (isAbsoluteVolumeDevice(device) || isA2dpAbsoluteVolumeDevice(device) || AudioSystem.isLeAudioDeviceType(device)) { index = getAbsoluteVolumeIndex((getIndex(device) + 5)/10); } else if (isFullVolumeDevice(device)) { index = (mIndexMax + 5)/10; Loading @@ -7741,7 +7742,8 @@ public class AudioService extends IAudioService.Stub if (isFullyMuted()) { index = 0; } else if (isAbsoluteVolumeDevice(device) || isA2dpAbsoluteVolumeDevice(device)) { || isA2dpAbsoluteVolumeDevice(device) || AudioSystem.isLeAudioDeviceType(device)) { index = getAbsoluteVolumeIndex((getIndex(device) + 5)/10); } else if (isFullVolumeDevice(device)) { index = (mIndexMax + 5)/10; Loading Loading @@ -8162,7 +8164,8 @@ public class AudioService extends IAudioService.Stub int streamDevice = getDeviceForStream(streamType); if ((device != streamDevice) && (isAbsoluteVolumeDevice(device) || isA2dpAbsoluteVolumeDevice(device))) { || isA2dpAbsoluteVolumeDevice(device) || AudioSystem.isLeAudioDeviceType(device))) { mStreamStates[streamType].applyDeviceVolume_syncVSS(device); } mStreamStates[streamType].applyDeviceVolume_syncVSS(streamDevice); Loading services/core/java/com/android/server/audio/AudioServiceEvents.java +1 −1 Original line number Diff line number Diff line Loading @@ -433,7 +433,7 @@ public class AudioServiceEvents { case VOL_SET_LE_AUDIO_VOL: return new StringBuilder("setLeAudioVolume:") .append(" index:").append(mVal1) .append(" gain dB:").append(mVal2) .append(" maxIndex:").append(mVal2) .toString(); case VOL_SET_AVRCP_VOL: return new StringBuilder("setAvrcpVolume:") Loading services/core/java/com/android/server/audio/BtHelper.java +2 −3 Original line number Diff line number Diff line Loading @@ -412,9 +412,8 @@ public class BtHelper { } return; } /* leaudio expect volume value in range 0 to 255 */ int volume = (index * (BT_LE_AUDIO_MAX_VOL - BT_LE_AUDIO_MIN_VOL)) / maxIndex ; /* leaudio expect volume value in range 0 to 255 */ int volume = (int) Math.round((double) index * BT_LE_AUDIO_MAX_VOL / maxIndex); if (AudioService.DEBUG_VOL) { Log.i(TAG, "setLeAudioVolume: calling mLeAudio.setVolume idx=" Loading Loading
media/java/android/media/AudioSystem.java +8 −0 Original line number Diff line number Diff line Loading @@ -2385,6 +2385,14 @@ public class AudioSystem return types.size() == 1 && types.contains(type); } /** * @hide * Return true if the audio device type is a Bluetooth LE Audio device. */ public static boolean isLeAudioDeviceType(int type) { return DEVICE_OUT_ALL_BLE_SET.contains(type); } /** @hide */ public static final int DEFAULT_MUTE_STREAMS_AFFECTED = (1 << STREAM_MUSIC) | Loading
services/core/java/com/android/server/audio/AudioService.java +11 −8 Original line number Diff line number Diff line Loading @@ -3355,8 +3355,7 @@ public class AudioService extends IAudioService.Stub dispatchAbsoluteVolumeChanged(streamType, info, newIndex); } if ((device == AudioSystem.DEVICE_OUT_BLE_HEADSET || device == AudioSystem.DEVICE_OUT_BLE_BROADCAST) if (AudioSystem.isLeAudioDeviceType(device) && streamType == getBluetoothContextualVolumeStream() && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) { if (DEBUG_VOL) { Loading Loading @@ -4112,8 +4111,7 @@ public class AudioService extends IAudioService.Stub dispatchAbsoluteVolumeChanged(streamType, info, index); } if ((device == AudioSystem.DEVICE_OUT_BLE_HEADSET || device == AudioSystem.DEVICE_OUT_BLE_BROADCAST) if (AudioSystem.isLeAudioDeviceType(device) && streamType == getBluetoothContextualVolumeStream() && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) { if (DEBUG_VOL) { Loading Loading @@ -6952,7 +6950,8 @@ public class AudioService extends IAudioService.Stub return AudioManager.DEVICE_VOLUME_BEHAVIOR_ABSOLUTE_MULTI_MODE; } if (isAbsoluteVolumeDevice(audioSystemDeviceOut) || isA2dpAbsoluteVolumeDevice(audioSystemDeviceOut)) { || isA2dpAbsoluteVolumeDevice(audioSystemDeviceOut) || AudioSystem.isLeAudioDeviceType(audioSystemDeviceOut)) { return AudioManager.DEVICE_VOLUME_BEHAVIOR_ABSOLUTE; } return AudioManager.DEVICE_VOLUME_BEHAVIOR_VARIABLE; Loading Loading @@ -7719,7 +7718,9 @@ public class AudioService extends IAudioService.Stub int index; if (isFullyMuted()) { index = 0; } else if (isAbsoluteVolumeDevice(device) || isA2dpAbsoluteVolumeDevice(device)) { } else if (isAbsoluteVolumeDevice(device) || isA2dpAbsoluteVolumeDevice(device) || AudioSystem.isLeAudioDeviceType(device)) { index = getAbsoluteVolumeIndex((getIndex(device) + 5)/10); } else if (isFullVolumeDevice(device)) { index = (mIndexMax + 5)/10; Loading @@ -7741,7 +7742,8 @@ public class AudioService extends IAudioService.Stub if (isFullyMuted()) { index = 0; } else if (isAbsoluteVolumeDevice(device) || isA2dpAbsoluteVolumeDevice(device)) { || isA2dpAbsoluteVolumeDevice(device) || AudioSystem.isLeAudioDeviceType(device)) { index = getAbsoluteVolumeIndex((getIndex(device) + 5)/10); } else if (isFullVolumeDevice(device)) { index = (mIndexMax + 5)/10; Loading Loading @@ -8162,7 +8164,8 @@ public class AudioService extends IAudioService.Stub int streamDevice = getDeviceForStream(streamType); if ((device != streamDevice) && (isAbsoluteVolumeDevice(device) || isA2dpAbsoluteVolumeDevice(device))) { || isA2dpAbsoluteVolumeDevice(device) || AudioSystem.isLeAudioDeviceType(device))) { mStreamStates[streamType].applyDeviceVolume_syncVSS(device); } mStreamStates[streamType].applyDeviceVolume_syncVSS(streamDevice); Loading
services/core/java/com/android/server/audio/AudioServiceEvents.java +1 −1 Original line number Diff line number Diff line Loading @@ -433,7 +433,7 @@ public class AudioServiceEvents { case VOL_SET_LE_AUDIO_VOL: return new StringBuilder("setLeAudioVolume:") .append(" index:").append(mVal1) .append(" gain dB:").append(mVal2) .append(" maxIndex:").append(mVal2) .toString(); case VOL_SET_AVRCP_VOL: return new StringBuilder("setAvrcpVolume:") Loading
services/core/java/com/android/server/audio/BtHelper.java +2 −3 Original line number Diff line number Diff line Loading @@ -412,9 +412,8 @@ public class BtHelper { } return; } /* leaudio expect volume value in range 0 to 255 */ int volume = (index * (BT_LE_AUDIO_MAX_VOL - BT_LE_AUDIO_MIN_VOL)) / maxIndex ; /* leaudio expect volume value in range 0 to 255 */ int volume = (int) Math.round((double) index * BT_LE_AUDIO_MAX_VOL / maxIndex); if (AudioService.DEBUG_VOL) { Log.i(TAG, "setLeAudioVolume: calling mLeAudio.setVolume idx=" Loading