From f94db44b4d1610a6c2615ed16e309721db39782f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Mon, 19 Sep 2022 04:27:03 +0200 Subject: [PATCH 1/3] Enforce leaving state when shutting down the activity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the view is shutting down the call is always left, so the status should be accordingly set. Signed-off-by: Daniel Calviño Sánchez --- .../java/com/nextcloud/talk/activities/CallActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index 0f691f353..5bab1e20a 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -396,7 +396,6 @@ public class CallActivity extends CallBaseActivity { binding.cameraButton.setOnClickListener(l -> onCameraClick()); binding.hangupButton.setOnClickListener(l -> { - setCallState(CallStatus.LEAVING); hangup(true); }); @@ -1167,7 +1166,6 @@ public class CallActivity extends CallBaseActivity { @Override public void onDestroy() { if (!currentCallStatus.equals(CallStatus.LEAVING)) { - setCallState(CallStatus.LEAVING); hangup(true); } powerManagerUtils.updatePhoneState(PowerManagerUtils.PhoneState.IDLE); @@ -1660,6 +1658,9 @@ public class CallActivity extends CallBaseActivity { private void hangup(boolean shutDownView) { Log.d(TAG, "hangup! shutDownView=" + shutDownView); + if (shutDownView) { + setCallState(CallStatus.LEAVING); + } stopCallingSound(); dispose(null); From fdbcc3b16daca8b9c2ea9ed7ead967bc4679a34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Mon, 19 Sep 2022 04:29:04 +0200 Subject: [PATCH 2/3] Close the call activity when leaving the call only if remotely triggered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the local participant leaves the call the participant list will be updated with the new call flags. However, that does not necessarily mean that a moderator ended the call; the call could have been left too by the Android app due to a forced reconnection or a time out when starting the call. In those cases the call activity should be kept open, and only when the local participant left the call due to a remote action the call activity should be closed. Signed-off-by: Daniel Calviño Sánchez --- .../main/java/com/nextcloud/talk/activities/CallActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index 5bab1e20a..4755db18a 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -1798,7 +1798,7 @@ public class CallActivity extends CallBaseActivity { } } else { Log.d(TAG, " inCallFlag of currentSessionId: " + inCallFlag); - if (inCallFlag == 0) { + if (inCallFlag == 0 && !CallStatus.LEAVING.equals(currentCallStatus) && ApplicationWideCurrentRoomHolder.getInstance().isInCall()) { Log.d(TAG, "Most probably a moderator ended the call for all."); hangup(true); } From 13a04808d97f2833f465f010d74086f1746a03fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Mon, 19 Sep 2022 04:30:15 +0200 Subject: [PATCH 3/3] Ignore signaling messages when the call activity is closing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The call activity unregisters from the event bus events when stopped. However, when the call activity is being closed the new activity can start before the call activity is stopped; if the new activity causes new signaling messages to be sent those messages were handled by the call activity too. The chat controller joins the conversation again when it is attached, and the call activity automatically joins the call when it receives a "roomJoined" event. Due to all that, when the call activity was closed and the chat controller was opened the call was joined again (and then left once the call activity was finally destroyed). Signed-off-by: Daniel Calviño Sánchez --- .../main/java/com/nextcloud/talk/activities/CallActivity.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index 4755db18a..3dc128ae9 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -1483,6 +1483,10 @@ public class CallActivity extends CallBaseActivity { @Subscribe(threadMode = ThreadMode.BACKGROUND) public void onMessageEvent(WebSocketCommunicationEvent webSocketCommunicationEvent) { + if (CallStatus.LEAVING.equals(currentCallStatus)) { + return; + } + switch (webSocketCommunicationEvent.getType()) { case "hello": Log.d(TAG, "onMessageEvent 'hello'");