Merge pull request #4288 from deltachat/wch423/offline-outgoing-state

Make outgoing call start with `CONNECTING` then switch to `RINGING`
This commit is contained in:
adb
2026-03-18 17:10:31 +01:00
committed by GitHub
2 changed files with 23 additions and 2 deletions
@@ -94,6 +94,7 @@ public class CallCoordinator implements DcEventCenter.DcEventDelegate {
private final MutableLiveData<String> errorMessage = new MutableLiveData<>();
private final MutableLiveData<String> displayName = new MutableLiveData<>();
private final MutableLiveData<Icon> displayIcon = new MutableLiveData<>();
private final MutableLiveData<Boolean> outgoingCallPlaced = new MutableLiveData<>(false);
// Audio Routing Support
private final MediatorLiveData<CallEndpointCompat> currentAudioEndpoint =
@@ -312,6 +313,10 @@ public class CallCoordinator implements DcEventCenter.DcEventDelegate {
return displayIcon;
}
public LiveData<Boolean> getOutgoingCallPlaced() {
return outgoingCallPlaced;
}
public LiveData<CallEndpointCompat> getCurrentAudioEndpoint() {
return currentAudioEndpoint;
}
@@ -1132,6 +1137,7 @@ public class CallCoordinator implements DcEventCenter.DcEventDelegate {
remoteVideoEnabled.postValue(true);
isRelayUsed.postValue(false);
errorMessage.postValue(null);
outgoingCallPlaced.postValue(false);
currentAudioEndpoint.postValue(null);
availableAudioEndpoints.postValue(null);
}
@@ -1203,6 +1209,7 @@ public class CallCoordinator implements DcEventCenter.DcEventDelegate {
}
this.activeCallId = callId;
outgoingCallPlaced.postValue(true);
// Get callee info
String calleeName = displayName.getValue();
@@ -35,6 +35,7 @@ public class CallViewModel extends AndroidViewModel {
private final LiveData<String> errorMessage;
private final LiveData<String> displayName;
private final LiveData<Icon> displayIcon;
private final LiveData<Boolean> outgoingCallPlaced;
private final LiveData<CallEndpointCompat> currentAudioEndpoint;
private final LiveData<List<CallEndpointCompat>> availableAudioEndpoints;
@@ -75,6 +76,7 @@ public class CallViewModel extends AndroidViewModel {
this.errorMessage = callCoordinator.getErrorMessage();
this.displayName = callCoordinator.getDisplayName();
this.displayIcon = callCoordinator.getDisplayIcon();
this.outgoingCallPlaced = callCoordinator.getOutgoingCallPlaced();
this.currentAudioEndpoint = callCoordinator.getCurrentAudioEndpoint();
this.availableAudioEndpoints = callCoordinator.getAvailableAudioEndpoints();
@@ -93,7 +95,7 @@ public class CallViewModel extends AndroidViewModel {
if (callCoordinator.isIncomingCall()) {
callState.setValue(CallState.PROMPTING_USER_ACCEPT);
} else {
callState.setValue(CallState.RINGING);
callState.setValue(CallState.CONNECTING);
}
Log.d(TAG, "CallViewModel initialized");
@@ -116,6 +118,16 @@ public class CallViewModel extends AndroidViewModel {
}
}
});
callState.addSource(
outgoingCallPlaced,
placed -> {
if (Boolean.TRUE.equals(placed) && !callCoordinator.isIncomingCall()) {
if (callState.getValue() == CallState.CONNECTING) {
callState.setValue(CallState.RINGING);
}
}
});
}
private CallState translateConnectionState(PeerConnection.PeerConnectionState state) {
@@ -131,7 +143,9 @@ public class CallViewModel extends AndroidViewModel {
if (callCoordinator.isIncomingCall()) {
return CallState.CONNECTING;
} else {
return CallState.RINGING; // Mirror TypeScript
return Boolean.TRUE.equals(outgoingCallPlaced.getValue())
? CallState.RINGING
: CallState.CONNECTING;
}
case CONNECTED: