diff --git a/CHANGELOG.md b/CHANGELOG.md index d4c34ecd4..603346a55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Group changes to describe their impact on the project, as follows: - Android 10 compatibility - New plugin loader to be compatible with app bundle distribution mode - Restart service if foreground service setting is on when app is updated +- Change bluetooth volume while in call if BT device connected and used ## Changed - Improved performances to reduce startup time diff --git a/app/src/main/java/org/linphone/utils/AndroidAudioManager.java b/app/src/main/java/org/linphone/utils/AndroidAudioManager.java index dc60a0367..643b5b561 100644 --- a/app/src/main/java/org/linphone/utils/AndroidAudioManager.java +++ b/app/src/main/java/org/linphone/utils/AndroidAudioManager.java @@ -54,8 +54,6 @@ import org.linphone.receivers.HeadsetReceiver; import org.linphone.settings.LinphonePreferences; public class AndroidAudioManager { - private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL; - private Context mContext; private AudioManager mAudioManager; private Call mRingingCall; @@ -415,10 +413,22 @@ public class AndroidAudioManager { } private void adjustVolume(int i) { - // starting from ICS, volume must be adjusted by the application, at least for - // STREAM_VOICE_CALL volume stream + if (mAudioManager.isVolumeFixed()) { + Log.e("[Audio Manager] Can't adjust volume, device has it fixed..."); + // Keep going just in case... + } + + int stream = STREAM_VOICE_CALL; + if (mIsBluetoothHeadsetScoConnected) { + Log.i( + "[Audio Manager] Bluetooth is connected, try to change the volume on STREAM_BLUETOOTH_SCO"); + stream = 6; // STREAM_BLUETOOTH_SCO, it's hidden... + } + + // starting from ICS, volume must be adjusted by the application, + // at least for STREAM_VOICE_CALL volume stream mAudioManager.adjustStreamVolume( - LINPHONE_VOLUME_STREAM, + stream, i < 0 ? AudioManager.ADJUST_LOWER : AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI); }