Skip to content

Commit b63414b

Browse files
committed
android: fix broken forceSpeakerOn
1 parent 3152a4d commit b63414b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

android/src/main/java/com/zxcpoiu/incallmanager/InCallManagerModule.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,15 @@ public void setForceSpeakerphoneOn(final int flag) {
789789
Log.d(TAG, "setForceSpeakerphoneOn() flag: " + flag);
790790
forceSpeakerOn = flag;
791791

792-
selectAudioDevice((flag == 1) ? AudioDevice.SPEAKER_PHONE : AudioDevice.NONE); // --- will call updateAudioDeviceState()
792+
// --- will call updateAudioDeviceState()
793+
// --- Note: in some devices, it may not contains specified route thus will not be effected.
794+
if (flag == 1) {
795+
selectAudioDevice(AudioDevice.SPEAKER_PHONE);
796+
} else if (flag == -1) {
797+
selectAudioDevice(AudioDevice.EARPIECE); // --- use the most common earpiece to force `speaker off`
798+
} else {
799+
selectAudioDevice(AudioDevice.NONE); // --- NONE will follow default route, the default route of `video` call is speaker.
800+
}
793801
}
794802

795803
// --- TODO (zxcpoiu): Implement api to let user choose audio devices

0 commit comments

Comments
 (0)