~singpolyma/cheogram-android

afd02db325efc49f8986c08672bc22cbe12d7395 — Stephen Paul Weber a month ago 470213a + 9f7a949
Merge branch 'audio-routing2'

* audio-routing2:
  Support mute during dialler integration calls
  Use a more familiar ringback for north american users
M src/cheogram/java/com/cheogram/android/ConnectionService.java => src/cheogram/java/com/cheogram/android/ConnectionService.java +21 -1
@@ 197,6 197,7 @@ public class ConnectionService extends android.telecom.ConnectionService {
		protected String sessionId = null;
		protected Stack<String> postDial = new Stack<>();
		protected Icon gatewayIcon;
		protected CallAudioState pendingState = null;
		protected WeakReference<JingleRtpConnection> rtpConnection = null;

		CheogramConnection(Account account, Jid with, String postDialString) {


@@ 222,7 223,8 @@ public class ConnectionService extends android.telecom.ConnectionService {
			);
			setAudioModeIsVoip(true);
			setConnectionCapabilities(
				Connection.CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION
				Connection.CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION |
				Connection.CAPABILITY_MUTE
			);
		}



@@ 271,6 273,8 @@ public class ConnectionService extends android.telecom.ConnectionService {
		public void onAudioDeviceChanged(AppRTCAudioManager.AudioDevice selectedAudioDevice, Set<AppRTCAudioManager.AudioDevice> availableAudioDevices) {
			if (Build.VERSION.SDK_INT < 26) return;

			if (pendingState != null) onCallAudioStateChanged(pendingState);

			switch(selectedAudioDevice) {
				case SPEAKER_PHONE:
					setAudioRoute(CallAudioState.ROUTE_SPEAKER);


@@ 286,6 290,22 @@ public class ConnectionService extends android.telecom.ConnectionService {
		}

		@Override
		public void onCallAudioStateChanged(CallAudioState state) {
			pendingState = null;
			if (rtpConnection == null || rtpConnection.get() == null) {
				pendingState = state;
				return;
			}

			try {
				rtpConnection.get().setMicrophoneEnabled(!state.isMuted());
			} catch (final IllegalStateException e) {
				pendingState = state;
				Log.w("com.cheogram.android.CheogramConnection", "Could not set microphone mute to " + (state.isMuted() ? "true" : "false") + ": " + e.toString());
			}
		}

		@Override
		public void onAnswer() {
			// For incoming calls, a connection update may not have been triggered before answering
			// so we have to acquire the rtp connection object here

M src/main/java/eu/siacs/conversations/xmpp/jingle/ToneManager.java => src/main/java/eu/siacs/conversations/xmpp/jingle/ToneManager.java +1 -1
@@ 131,7 131,7 @@ class ToneManager {

    private void scheduleWaitingTone() {
        this.currentTone = JingleConnectionManager.SCHEDULED_EXECUTOR_SERVICE.scheduleAtFixedRate(() -> {
            startTone(ToneGenerator.TONE_CDMA_DIAL_TONE_LITE, 750);
            startTone(ToneGenerator.TONE_CDMA_NETWORK_USA_RINGBACK, 750);
        }, 0, 3, TimeUnit.SECONDS);
    }