audioManager not work in huawei

audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
audioManager.setSpeakerphoneOn(true);
these code work on other device but not in huawei P10 lite android 8.0.0
and how to select the sound device programmablly

how to use

and (for ConnectionService):