Add shared calling intent system.

This commit is contained in:
Alex Hart
2024-09-03 15:22:44 -03:00
committed by Cody Henthorne
parent e5b482c7ad
commit 4d23f11f6e
12 changed files with 277 additions and 90 deletions

View File

@@ -6,7 +6,7 @@ import android.telecom.CallAudioState
import android.telecom.Connection
import androidx.annotation.RequiresApi
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.WebRtcCallActivity
import org.thoughtcrime.securesms.components.webrtc.v2.CallIntent
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.permissions.Permissions
import org.thoughtcrime.securesms.recipients.RecipientId
@@ -66,9 +66,10 @@ class AndroidCallConnection(
if (Permissions.hasAll(context, android.Manifest.permission.RECORD_AUDIO)) {
AppDependencies.signalCallManager.acceptCall(false)
} else {
val intent = Intent(context, WebRtcCallActivity::class.java)
intent.action = if (isVideoCall) WebRtcCallActivity.ANSWER_VIDEO_ACTION else WebRtcCallActivity.ANSWER_ACTION
intent.flags = intent.flags or Intent.FLAG_ACTIVITY_NEW_TASK
val intent = CallIntent.Builder(context)
.withAddedIntentFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.withAction(if (isVideoCall) CallIntent.Action.ANSWER_VIDEO else CallIntent.Action.ANSWER_AUDIO)
.build()
context.startActivity(intent)
}
}

View File

@@ -36,6 +36,7 @@ import org.signal.ringrtc.PeekInfo;
import org.signal.ringrtc.Remote;
import org.signal.storageservice.protos.groups.GroupExternalCredential;
import org.thoughtcrime.securesms.WebRtcCallActivity;
import org.thoughtcrime.securesms.components.webrtc.v2.CallIntent;
import org.thoughtcrime.securesms.crypto.SealedSenderAccessUtil;
import org.thoughtcrime.securesms.database.CallLinkTable;
import org.thoughtcrime.securesms.database.CallTable;
@@ -1253,10 +1254,12 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
WebRtcViewModel.State callState = s.getCallInfoState().getCallState();
if (callState.getInOngoingCall()) {
Intent intent = new Intent(context, WebRtcCallActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(WebRtcCallActivity.EXTRA_LAUNCH_IN_PIP, true);
context.startActivity(intent);
context.startActivity(
new CallIntent.Builder(context)
.withIntentFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.withLaunchInPip(true)
.build()
);
}
return s;