Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

fix: android prompt "Failed to stop voice call" on conn ended (#8434)

fufesou74cc5abd09f5
diff --git a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/AudioRecordHandle.kt b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/AudioRecordHandle.kt
index 122a5a92b..bb8cbffb2 100644
--- a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/AudioRecordHandle.kt
+++ b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/AudioRecordHandle.kt
@@ -119,21 +119,17 @@ class AudioRecordHandle(private var context: Context, private var isVideoStart:
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
return false
}
- if (isVideoStart() || isAudioStart()) {
- if (!switchToVoiceCall(mediaProjection)) {
- return false
- }
- } else {
- if (!switchToVoiceCall(mediaProjection)) {
- return false
- }
+ // No need to check if video or audio is started here.
+ if (!switchToVoiceCall(mediaProjection)) {
+ return false
}
return true
}
fun onVoiceCallClosed(mediaProjection: MediaProjection?): Boolean {
+ // Return true if `Build.VERSION.SDK_INT < Build.VERSION_CODES.R`, because is was not started.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
- return false
+ return true
}
if (isVideoStart()) {
switchOutVoiceCall(mediaProjection)
diff --git a/flutter/lib/mobile/pages/remote_page.dart b/flutter/lib/mobile/pages/remote_page.dart
index 3d89cd85f..d74dc4839 100644
--- a/flutter/lib/mobile/pages/remote_page.dart
+++ b/flutter/lib/mobile/pages/remote_page.dart
@@ -105,11 +105,10 @@ class _RemotePageState extends State<RemotePage> {
}
await keyboardSubscription.cancel();
removeSharedStates(widget.id);
- if (isAndroid) {
- // Only one client is considered here for now.
- // TODO: take into account the case where there are multiple clients
- gFFI.invokeMethod("on_voice_call_closed");
- }
+ // `on_voice_call_closed` should be called when the connection is ended.
+ // The inner logic of `on_voice_call_closed` will check if the voice call is active.
+ // Only one client is considered here for now.
+ gFFI.chatModel.onVoiceCallClosed("End connetion");
}
// to-do: It should be better to use transparent color instead of the bgColor.
diff --git a/flutter/lib/models/chat_model.dart b/flutter/lib/models/chat_model.dart
index 289124104..778c94357 100644
--- a/flutter/lib/models/chat_model.dart
+++ b/flutter/lib/models/chat_model.dart
@@ -535,6 +535,8 @@ class ChatModel with ChangeNotifier {
void onVoiceCallClosed(String reason) {
_voiceCallStatus.value = VoiceCallStatus.notStarted;
if (isAndroid) {
+ // We can always invoke "on_voice_call_closed"
+ // no matter if the `_voiceCallStatus` was `VoiceCallStatus.notStarted` or not.
parent.target?.invokeMethod("on_voice_call_closed");
}
}