~singpolyma/cheogram-android

fc522ca38b3e7c47c4e50d9d5181d6bb532a6d3f — Stephen Paul Weber 10 months ago 3dc9db3
Set default audio device based on dialler selected route
1 files changed, 21 insertions(+), 0 deletions(-)

M src/cheogram/java/com/cheogram/android/ConnectionService.java
M src/cheogram/java/com/cheogram/android/ConnectionService.java => src/cheogram/java/com/cheogram/android/ConnectionService.java +21 -0
@@ 282,12 282,16 @@ public class ConnectionService extends android.telecom.ConnectionService {
			switch(selectedAudioDevice) {
				case SPEAKER_PHONE:
					setAudioRoute(CallAudioState.ROUTE_SPEAKER);
					break;
				case WIRED_HEADSET:
					setAudioRoute(CallAudioState.ROUTE_WIRED_HEADSET);
					break;
				case EARPIECE:
					setAudioRoute(CallAudioState.ROUTE_EARPIECE);
					break;
				case BLUETOOTH:
					setAudioRoute(CallAudioState.ROUTE_BLUETOOTH);
					break;
				default:
					setAudioRoute(CallAudioState.ROUTE_WIRED_OR_EARPIECE);
			}


@@ 301,6 305,23 @@ public class ConnectionService extends android.telecom.ConnectionService {
				return;
			}

			switch(state.getRoute()) {
				case CallAudioState.ROUTE_SPEAKER:
					rtpConnection.get().getAudioManager().setDefaultAudioDevice(AppRTCAudioManager.AudioDevice.SPEAKER_PHONE);
					break;
				case CallAudioState.ROUTE_WIRED_HEADSET:
					rtpConnection.get().getAudioManager().setDefaultAudioDevice(AppRTCAudioManager.AudioDevice.WIRED_HEADSET);
					break;
				case CallAudioState.ROUTE_EARPIECE:
					rtpConnection.get().getAudioManager().setDefaultAudioDevice(AppRTCAudioManager.AudioDevice.EARPIECE);
					break;
				case CallAudioState.ROUTE_BLUETOOTH:
					rtpConnection.get().getAudioManager().setDefaultAudioDevice(AppRTCAudioManager.AudioDevice.BLUETOOTH);
					break;
				default:
					rtpConnection.get().getAudioManager().setDefaultAudioDevice(AppRTCAudioManager.AudioDevice.NONE);
			}

			try {
				rtpConnection.get().setMicrophoneEnabled(!state.isMuted());
			} catch (final IllegalStateException e) {