Loading services/core/java/com/android/server/audio/AudioDeviceBroker.java +9 −1 Original line number Diff line number Diff line Loading @@ -34,10 +34,12 @@ import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET; import static android.media.AudioSystem.DEVICE_OUT_WIRED_HEADSET; import static android.media.AudioSystem.isBluetoothScoOutDevice; import static com.android.media.audio.Flags.equalScoHaVcIndexRange; import static com.android.media.audio.Flags.equalScoLeaVcIndexRange; import static com.android.media.audio.Flags.optimizeBtDeviceSwitch; import static com.android.server.audio.AudioService.BT_COMM_DEVICE_ACTIVE_BLE_HEADSET; import static com.android.server.audio.AudioService.BT_COMM_DEVICE_ACTIVE_BLE_SPEAKER; import static com.android.server.audio.AudioService.BT_COMM_DEVICE_ACTIVE_HA; import static com.android.server.audio.AudioService.BT_COMM_DEVICE_ACTIVE_SCO; import static com.android.server.utils.EventLogger.Event.ALOGW; Loading Loading @@ -923,6 +925,10 @@ public class AudioDeviceBroker { return isDeviceActiveForCommunication(AudioDeviceInfo.TYPE_BLE_SPEAKER); } private boolean isBluetoothHaActive() { return isDeviceActiveForCommunication(AudioDeviceInfo.TYPE_HEARING_AID); } /*package*/ boolean isDeviceConnected(@NonNull AudioDeviceAttributes device) { synchronized (mDeviceStateLock) { return mDeviceInventory.isDeviceConnected(device); Loading Loading @@ -1505,13 +1511,15 @@ public class AudioDeviceBroker { mCurCommunicationPortId = portId; @BtCommDeviceActiveType int btCommDeviceActiveType = 0; if (equalScoLeaVcIndexRange()) { if (equalScoLeaVcIndexRange() || equalScoHaVcIndexRange()) { if (isBluetoothScoActive()) { btCommDeviceActiveType = BT_COMM_DEVICE_ACTIVE_SCO; } else if (isBluetoothBleHeadsetActive()) { btCommDeviceActiveType = BT_COMM_DEVICE_ACTIVE_BLE_HEADSET; } else if (isBluetoothBleSpeakerActive()) { btCommDeviceActiveType = BT_COMM_DEVICE_ACTIVE_BLE_SPEAKER; } else if (equalScoHaVcIndexRange() && isBluetoothHaActive()) { btCommDeviceActiveType = BT_COMM_DEVICE_ACTIVE_HA; } mAudioService.postBtCommDeviceActive(btCommDeviceActiveType); } else { Loading services/core/java/com/android/server/audio/AudioService.java +15 −4 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ import static com.android.media.audio.Flags.asDeviceConnectionFailure; import static com.android.media.audio.Flags.audioserverPermissions; import static com.android.media.audio.Flags.deferWearPermissionUpdates; import static com.android.media.audio.Flags.disablePrescaleAbsoluteVolume; import static com.android.media.audio.Flags.equalScoHaVcIndexRange; import static com.android.media.audio.Flags.equalScoLeaVcIndexRange; import static com.android.media.audio.Flags.optimizeBtDeviceSwitch; import static com.android.media.audio.Flags.replaceStreamBtSco; Loading Loading @@ -826,9 +827,11 @@ public class AudioService extends IAudioService.Stub /*package*/ static final int BT_COMM_DEVICE_ACTIVE_BLE_HEADSET = 1 << 1; /** The active bluetooth device type used for communication is ble speaker. */ /*package*/ static final int BT_COMM_DEVICE_ACTIVE_BLE_SPEAKER = 1 << 2; /** The active bluetooth device type used for communication is hearing aid. */ /*package*/ static final int BT_COMM_DEVICE_ACTIVE_HA = 1 << 3; @IntDef({ BT_COMM_DEVICE_ACTIVE_SCO, BT_COMM_DEVICE_ACTIVE_BLE_HEADSET, BT_COMM_DEVICE_ACTIVE_BLE_SPEAKER BT_COMM_DEVICE_ACTIVE_BLE_SPEAKER, BT_COMM_DEVICE_ACTIVE_HA }) @Retention(RetentionPolicy.SOURCE) public @interface BtCommDeviceActiveType { Loading Loading @@ -5277,6 +5280,8 @@ public class AudioService extends IAudioService.Stub pw.println("\tcom.android.media.audio.vgsVssSyncMuteOrder - EOL"); pw.println("\tcom.android.media.audio.replaceStreamBtSco:" + replaceStreamBtSco()); pw.println("\tcom.android.media.audio.equalScoHaVcIndexRange:" + equalScoHaVcIndexRange()); pw.println("\tcom.android.media.audio.equalScoLeaVcIndexRange:" + equalScoLeaVcIndexRange()); pw.println("\tcom.android.media.audio.ringMyCar:" Loading Loading @@ -9753,7 +9758,7 @@ public class AudioService extends IAudioService.Stub } public void updateIndexFactors() { if (!replaceStreamBtSco() && !equalScoLeaVcIndexRange()) { if (!replaceStreamBtSco() && !equalScoLeaVcIndexRange() && !equalScoHaVcIndexRange()) { return; } Loading @@ -9767,18 +9772,24 @@ public class AudioService extends IAudioService.Stub mIndexMax = MAX_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO] * 10; } if (!equalScoLeaVcIndexRange() && isStreamBluetoothSco(mStreamType)) { if (!equalScoLeaVcIndexRange() && !equalScoHaVcIndexRange() && isStreamBluetoothSco(mStreamType)) { // SCO devices have a different min index mIndexMin = MIN_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO] * 10; indexMinVolCurve = MIN_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO]; indexMaxVolCurve = MAX_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO]; mIndexStepFactor = 1.f; } else if (equalScoLeaVcIndexRange() && isStreamBluetoothComm(mStreamType)) { } else if ((equalScoLeaVcIndexRange() || equalScoHaVcIndexRange()) && isStreamBluetoothComm(mStreamType)) { // For non SCO devices the stream state does not change the min index if (mBtCommDeviceActive.get() == BT_COMM_DEVICE_ACTIVE_SCO) { mIndexMin = MIN_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO] * 10; indexMinVolCurve = MIN_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO]; indexMaxVolCurve = MAX_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO]; } else if (equalScoHaVcIndexRange() && mBtCommDeviceActive.get() == BT_COMM_DEVICE_ACTIVE_HA) { mIndexMin = MIN_STREAM_VOLUME[mStreamType] * 10; indexMaxVolCurve = MAX_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO]; } else { mIndexMin = MIN_STREAM_VOLUME[mStreamType] * 10; } Loading Loading
services/core/java/com/android/server/audio/AudioDeviceBroker.java +9 −1 Original line number Diff line number Diff line Loading @@ -34,10 +34,12 @@ import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET; import static android.media.AudioSystem.DEVICE_OUT_WIRED_HEADSET; import static android.media.AudioSystem.isBluetoothScoOutDevice; import static com.android.media.audio.Flags.equalScoHaVcIndexRange; import static com.android.media.audio.Flags.equalScoLeaVcIndexRange; import static com.android.media.audio.Flags.optimizeBtDeviceSwitch; import static com.android.server.audio.AudioService.BT_COMM_DEVICE_ACTIVE_BLE_HEADSET; import static com.android.server.audio.AudioService.BT_COMM_DEVICE_ACTIVE_BLE_SPEAKER; import static com.android.server.audio.AudioService.BT_COMM_DEVICE_ACTIVE_HA; import static com.android.server.audio.AudioService.BT_COMM_DEVICE_ACTIVE_SCO; import static com.android.server.utils.EventLogger.Event.ALOGW; Loading Loading @@ -923,6 +925,10 @@ public class AudioDeviceBroker { return isDeviceActiveForCommunication(AudioDeviceInfo.TYPE_BLE_SPEAKER); } private boolean isBluetoothHaActive() { return isDeviceActiveForCommunication(AudioDeviceInfo.TYPE_HEARING_AID); } /*package*/ boolean isDeviceConnected(@NonNull AudioDeviceAttributes device) { synchronized (mDeviceStateLock) { return mDeviceInventory.isDeviceConnected(device); Loading Loading @@ -1505,13 +1511,15 @@ public class AudioDeviceBroker { mCurCommunicationPortId = portId; @BtCommDeviceActiveType int btCommDeviceActiveType = 0; if (equalScoLeaVcIndexRange()) { if (equalScoLeaVcIndexRange() || equalScoHaVcIndexRange()) { if (isBluetoothScoActive()) { btCommDeviceActiveType = BT_COMM_DEVICE_ACTIVE_SCO; } else if (isBluetoothBleHeadsetActive()) { btCommDeviceActiveType = BT_COMM_DEVICE_ACTIVE_BLE_HEADSET; } else if (isBluetoothBleSpeakerActive()) { btCommDeviceActiveType = BT_COMM_DEVICE_ACTIVE_BLE_SPEAKER; } else if (equalScoHaVcIndexRange() && isBluetoothHaActive()) { btCommDeviceActiveType = BT_COMM_DEVICE_ACTIVE_HA; } mAudioService.postBtCommDeviceActive(btCommDeviceActiveType); } else { Loading
services/core/java/com/android/server/audio/AudioService.java +15 −4 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ import static com.android.media.audio.Flags.asDeviceConnectionFailure; import static com.android.media.audio.Flags.audioserverPermissions; import static com.android.media.audio.Flags.deferWearPermissionUpdates; import static com.android.media.audio.Flags.disablePrescaleAbsoluteVolume; import static com.android.media.audio.Flags.equalScoHaVcIndexRange; import static com.android.media.audio.Flags.equalScoLeaVcIndexRange; import static com.android.media.audio.Flags.optimizeBtDeviceSwitch; import static com.android.media.audio.Flags.replaceStreamBtSco; Loading Loading @@ -826,9 +827,11 @@ public class AudioService extends IAudioService.Stub /*package*/ static final int BT_COMM_DEVICE_ACTIVE_BLE_HEADSET = 1 << 1; /** The active bluetooth device type used for communication is ble speaker. */ /*package*/ static final int BT_COMM_DEVICE_ACTIVE_BLE_SPEAKER = 1 << 2; /** The active bluetooth device type used for communication is hearing aid. */ /*package*/ static final int BT_COMM_DEVICE_ACTIVE_HA = 1 << 3; @IntDef({ BT_COMM_DEVICE_ACTIVE_SCO, BT_COMM_DEVICE_ACTIVE_BLE_HEADSET, BT_COMM_DEVICE_ACTIVE_BLE_SPEAKER BT_COMM_DEVICE_ACTIVE_BLE_SPEAKER, BT_COMM_DEVICE_ACTIVE_HA }) @Retention(RetentionPolicy.SOURCE) public @interface BtCommDeviceActiveType { Loading Loading @@ -5277,6 +5280,8 @@ public class AudioService extends IAudioService.Stub pw.println("\tcom.android.media.audio.vgsVssSyncMuteOrder - EOL"); pw.println("\tcom.android.media.audio.replaceStreamBtSco:" + replaceStreamBtSco()); pw.println("\tcom.android.media.audio.equalScoHaVcIndexRange:" + equalScoHaVcIndexRange()); pw.println("\tcom.android.media.audio.equalScoLeaVcIndexRange:" + equalScoLeaVcIndexRange()); pw.println("\tcom.android.media.audio.ringMyCar:" Loading Loading @@ -9753,7 +9758,7 @@ public class AudioService extends IAudioService.Stub } public void updateIndexFactors() { if (!replaceStreamBtSco() && !equalScoLeaVcIndexRange()) { if (!replaceStreamBtSco() && !equalScoLeaVcIndexRange() && !equalScoHaVcIndexRange()) { return; } Loading @@ -9767,18 +9772,24 @@ public class AudioService extends IAudioService.Stub mIndexMax = MAX_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO] * 10; } if (!equalScoLeaVcIndexRange() && isStreamBluetoothSco(mStreamType)) { if (!equalScoLeaVcIndexRange() && !equalScoHaVcIndexRange() && isStreamBluetoothSco(mStreamType)) { // SCO devices have a different min index mIndexMin = MIN_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO] * 10; indexMinVolCurve = MIN_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO]; indexMaxVolCurve = MAX_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO]; mIndexStepFactor = 1.f; } else if (equalScoLeaVcIndexRange() && isStreamBluetoothComm(mStreamType)) { } else if ((equalScoLeaVcIndexRange() || equalScoHaVcIndexRange()) && isStreamBluetoothComm(mStreamType)) { // For non SCO devices the stream state does not change the min index if (mBtCommDeviceActive.get() == BT_COMM_DEVICE_ACTIVE_SCO) { mIndexMin = MIN_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO] * 10; indexMinVolCurve = MIN_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO]; indexMaxVolCurve = MAX_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO]; } else if (equalScoHaVcIndexRange() && mBtCommDeviceActive.get() == BT_COMM_DEVICE_ACTIVE_HA) { mIndexMin = MIN_STREAM_VOLUME[mStreamType] * 10; indexMaxVolCurve = MAX_STREAM_VOLUME[AudioSystem.STREAM_BLUETOOTH_SCO]; } else { mIndexMin = MIN_STREAM_VOLUME[mStreamType] * 10; } Loading