Add Calling Requests.

master
Cody Henthorne 2020-07-06 16:27:03 -04:00 committed by Greyson Parrelli
parent 5a12eedc2c
commit 1e250ee95c
16 changed files with 192 additions and 182 deletions

View File

@ -304,7 +304,7 @@ dependencies {
implementation 'org.signal:argon2:13.1@aar'
implementation 'org.signal:ringrtc-android:2.2.0'
implementation 'org.signal:ringrtc-android:2.3.1'
implementation "me.leolin:ShortcutBadger:1.1.16"
implementation 'se.emilsjolander:stickylistheaders:2.7.0'

View File

@ -122,6 +122,12 @@
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:launchMode="singleTask"/>
<activity android:name=".messagerequests.CalleeMustAcceptMessageRequestActivity"
android:theme="@style/TextSecure.DarkNoActionBar"
android:screenOrientation="portrait"
android:noHistory="true"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".InviteActivity"
android:theme="@style/Signal.Light.NoActionBar.Invite"
android:windowSoftInputMode="stateHidden"

View File

@ -51,6 +51,7 @@ import org.thoughtcrime.securesms.components.webrtc.WebRtcCallViewModel;
import org.thoughtcrime.securesms.crypto.storage.TextSecureIdentityKeyStore;
import org.thoughtcrime.securesms.events.WebRtcViewModel;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.messagerequests.CalleeMustAcceptMessageRequestActivity;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.ringrtc.RemotePeer;
@ -391,6 +392,9 @@ public class WebRtcCallActivity extends AppCompatActivity {
EventBus.getDefault().removeStickyEvent(WebRtcViewModel.class);
if (hangupType == HangupMessage.Type.NEED_PERMISSION) {
startActivity(CalleeMustAcceptMessageRequestActivity.createIntent(this, recipient.getId()));
}
delayedFinish();
}
@ -510,19 +514,20 @@ public class WebRtcCallActivity extends AppCompatActivity {
viewModel.setRecipient(event.getRecipient());
switch (event.getState()) {
case CALL_CONNECTED: handleCallConnected(event); break;
case NETWORK_FAILURE: handleServerFailure(event); break;
case CALL_RINGING: handleCallRinging(event); break;
case CALL_DISCONNECTED: handleTerminate(event.getRecipient(), HangupMessage.Type.NORMAL); break;
case CALL_ACCEPTED_ELSEWHERE: handleTerminate(event.getRecipient(), HangupMessage.Type.ACCEPTED); break;
case CALL_DECLINED_ELSEWHERE: handleTerminate(event.getRecipient(), HangupMessage.Type.DECLINED); break;
case CALL_ONGOING_ELSEWHERE: handleTerminate(event.getRecipient(), HangupMessage.Type.BUSY); break;
case NO_SUCH_USER: handleNoSuchUser(event); break;
case RECIPIENT_UNAVAILABLE: handleRecipientUnavailable(event); break;
case CALL_INCOMING: handleIncomingCall(event); break;
case CALL_OUTGOING: handleOutgoingCall(event); break;
case CALL_BUSY: handleCallBusy(event); break;
case UNTRUSTED_IDENTITY: handleUntrustedIdentity(event); break;
case CALL_CONNECTED: handleCallConnected(event); break;
case NETWORK_FAILURE: handleServerFailure(event); break;
case CALL_RINGING: handleCallRinging(event); break;
case CALL_DISCONNECTED: handleTerminate(event.getRecipient(), HangupMessage.Type.NORMAL); break;
case CALL_ACCEPTED_ELSEWHERE: handleTerminate(event.getRecipient(), HangupMessage.Type.ACCEPTED); break;
case CALL_DECLINED_ELSEWHERE: handleTerminate(event.getRecipient(), HangupMessage.Type.DECLINED); break;
case CALL_ONGOING_ELSEWHERE: handleTerminate(event.getRecipient(), HangupMessage.Type.BUSY); break;
case CALL_NEEDS_PERMISSION: handleTerminate(event.getRecipient(), HangupMessage.Type.NEED_PERMISSION); break;
case NO_SUCH_USER: handleNoSuchUser(event); break;
case RECIPIENT_UNAVAILABLE: handleRecipientUnavailable(event); break;
case CALL_INCOMING: handleIncomingCall(event); break;
case CALL_OUTGOING: handleOutgoingCall(event); break;
case CALL_BUSY: handleCallBusy(event); break;
case UNTRUSTED_IDENTITY: handleUntrustedIdentity(event); break;
}
callScreen.setLocalRenderer(event.getLocalRenderer());

View File

@ -286,6 +286,7 @@ public class WebRtcCallView extends FrameLayout {
public void setStatusFromHangupType(@NonNull HangupMessage.Type hangupType) {
switch (hangupType) {
case NORMAL:
case NEED_PERMISSION:
status.setText(R.string.RedPhone_ending_call);
break;
case ACCEPTED:

View File

@ -621,13 +621,13 @@ public class SmsDatabase extends MessagingDatabase {
long messageId = db.insert(TABLE_NAME, null, values);
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
notifyConversationListeners(threadId);
ApplicationDependencies.getJobManager().add(new TrimThreadJob(threadId));
if (unread) {
DatabaseFactory.getThreadDatabase(context).incrementUnread(threadId, 1);
}
notifyConversationListeners(threadId);
ApplicationDependencies.getJobManager().add(new TrimThreadJob(threadId));
return new Pair<>(messageId, threadId);
}

View File

@ -311,7 +311,11 @@ public class ThreadDatabase extends Database {
}
public boolean hasCalledSince(@NonNull Recipient recipient, long timestamp) {
return DatabaseFactory.getMmsSmsDatabase(context).hasReceivedAnyCallsSince(getThreadIdFor(recipient), timestamp);
return hasReceivedAnyCallsSince(getThreadIdFor(recipient), timestamp);
}
public boolean hasReceivedAnyCallsSince(long threadId, long timestamp) {
return DatabaseFactory.getMmsSmsDatabase(context).hasReceivedAnyCallsSince(threadId, timestamp);
}
public List<MarkedMessageInfo> setEntireThreadRead(long threadId) {

View File

@ -19,6 +19,7 @@ public class WebRtcViewModel {
CALL_RINGING,
CALL_BUSY,
CALL_DISCONNECTED,
CALL_NEEDS_PERMISSION,
// Error states
NETWORK_FAILURE,

View File

@ -1,20 +1,18 @@
package org.thoughtcrime.securesms.messagerequests;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.lifecycle.ViewModelProviders;
import org.thoughtcrime.securesms.BaseActivity;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.AvatarImageView;
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
@ -25,56 +23,45 @@ import org.thoughtcrime.securesms.recipients.RecipientId;
import java.util.concurrent.TimeUnit;
public class CalleeMustAcceptMessageRequestDialogFragment extends DialogFragment {
import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION;
private static final long TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10);
private static final String ARG_RECIPIENT_ID = "arg.recipient.id";
public class CalleeMustAcceptMessageRequestActivity extends BaseActivity {
private static final long TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10);
private static final String RECIPIENT_ID_EXTRA = "extra.recipient.id";
private TextView description;
private AvatarImageView avatar;
private View okay;
private final Handler handler = new Handler(Looper.getMainLooper());
private final Runnable dismisser = this::dismiss;
private final Runnable finisher = this::finish;
public static DialogFragment create(@NonNull RecipientId recipientId) {
DialogFragment fragment = new CalleeMustAcceptMessageRequestDialogFragment();
Bundle args = new Bundle();
args.putParcelable(ARG_RECIPIENT_ID, recipientId);
fragment.setArguments(args);
return fragment;
public static Intent createIntent(@NonNull Context context, @NonNull RecipientId recipientId) {
Intent intent = new Intent(context, CalleeMustAcceptMessageRequestActivity.class);
intent.setFlags(FLAG_ACTIVITY_NO_ANIMATION);
intent.putExtra(RECIPIENT_ID_EXTRA, recipientId);
return intent;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.callee_must_accept_message_request_dialog_fragment);
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.TextSecure_DarkNoActionBar);
}
@Override
public @Nullable View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.callee_must_accept_message_request_dialog_fragment, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
description = view.findViewById(R.id.description);
avatar = view.findViewById(R.id.avatar);
okay = view.findViewById(R.id.okay);
description = findViewById(R.id.description);
avatar = findViewById(R.id.avatar);
okay = findViewById(R.id.okay);
avatar.setFallbackPhotoProvider(new FallbackPhotoProvider());
okay.setOnClickListener(v -> dismiss());
okay.setOnClickListener(v -> finish());
RecipientId recipientId = requireArguments().getParcelable(ARG_RECIPIENT_ID);
RecipientId recipientId = getIntent().getParcelableExtra(RECIPIENT_ID_EXTRA);
CalleeMustAcceptMessageRequestViewModel.Factory factory = new CalleeMustAcceptMessageRequestViewModel.Factory(recipientId);
CalleeMustAcceptMessageRequestViewModel viewModel = ViewModelProviders.of(this, factory).get(CalleeMustAcceptMessageRequestViewModel.class);
viewModel.getRecipient().observe(getViewLifecycleOwner(), recipient -> {
description.setText(getString(R.string.CalleeMustAcceptMessageRequestDialogFragment__s_will_get_a_message_request_from_you, recipient.getDisplayName(requireContext())));
viewModel.getRecipient().observe(this, recipient -> {
description.setText(getString(R.string.CalleeMustAcceptMessageRequestDialogFragment__s_will_get_a_message_request_from_you, recipient.getDisplayName(this)));
avatar.setAvatar(GlideApp.with(this), recipient, false);
});
}
@ -83,14 +70,14 @@ public class CalleeMustAcceptMessageRequestDialogFragment extends DialogFragment
public void onResume() {
super.onResume();
handler.postDelayed(dismisser, TIMEOUT_MS);
handler.postDelayed(finisher, TIMEOUT_MS);
}
@Override
public void onPause() {
super.onPause();
handler.removeCallbacks(dismisser);
handler.removeCallbacks(finisher);
}
private static class FallbackPhotoProvider extends Recipient.FallbackPhotoProvider {

View File

@ -184,13 +184,13 @@ public class RecipientUtil {
@WorkerThread
private static boolean isMessageRequestAccepted(@NonNull Context context, long threadId, @NonNull Recipient threadRecipient) {
return threadRecipient.isLocalNumber() ||
threadRecipient.isProfileSharing() ||
threadRecipient.isSystemContact() ||
threadRecipient.isForceSmsSelection() ||
!threadRecipient.isRegistered() ||
hasSentMessageInThread(context, threadId) ||
noSecureMessagesInThread(context, threadId) ||
return threadRecipient.isLocalNumber() ||
threadRecipient.isProfileSharing() ||
threadRecipient.isSystemContact() ||
threadRecipient.isForceSmsSelection() ||
!threadRecipient.isRegistered() ||
hasSentMessageInThread(context, threadId) ||
noSecureMessagesAndNoCallsInThread(context, threadId) ||
isPreMessageRequestThread(context, threadId);
}
@ -200,8 +200,9 @@ public class RecipientUtil {
}
@WorkerThread
private static boolean noSecureMessagesInThread(@NonNull Context context, long threadId) {
return DatabaseFactory.getMmsSmsDatabase(context).getSecureConversationCount(threadId) == 0;
private static boolean noSecureMessagesAndNoCallsInThread(@NonNull Context context, long threadId) {
return DatabaseFactory.getMmsSmsDatabase(context).getSecureConversationCount(threadId) == 0 &&
!DatabaseFactory.getThreadDatabase(context).hasReceivedAnyCallsSince(threadId, 0);
}
@WorkerThread

View File

@ -117,48 +117,49 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
public static final String EXTRA_BROADCAST = "broadcast";
public static final String EXTRA_ANSWER_WITH_VIDEO = "enable_video";
public static final String ACTION_OUTGOING_CALL = "CALL_OUTGOING";
public static final String ACTION_DENY_CALL = "DENY_CALL";
public static final String ACTION_LOCAL_HANGUP = "LOCAL_HANGUP";
public static final String ACTION_SET_MUTE_AUDIO = "SET_MUTE_AUDIO";
public static final String ACTION_FLIP_CAMERA = "FLIP_CAMERA";
public static final String ACTION_BLUETOOTH_CHANGE = "BLUETOOTH_CHANGE";
public static final String ACTION_WIRED_HEADSET_CHANGE = "WIRED_HEADSET_CHANGE";
public static final String ACTION_SCREEN_OFF = "SCREEN_OFF";
public static final String ACTION_IS_IN_CALL_QUERY = "IS_IN_CALL";
public static final String ACTION_SET_AUDIO_SPEAKER = "SET_AUDIO_SPEAKER";
public static final String ACTION_SET_AUDIO_BLUETOOTH = "SET_AUDIO_BLUETOOTH";
public static final String ACTION_CALL_CONNECTED = "CALL_CONNECTED";
public static final String ACTION_START_OUTGOING_CALL = "START_OUTGOING_CALL";
public static final String ACTION_START_INCOMING_CALL = "START_INCOMING_CALL";
public static final String ACTION_LOCAL_RINGING = "LOCAL_RINGING";
public static final String ACTION_REMOTE_RINGING = "REMOTE_RINGING";
public static final String ACTION_ACCEPT_CALL = "ACCEPT_CALL";
public static final String ACTION_SEND_OFFER = "SEND_OFFER";
public static final String ACTION_SEND_ANSWER = "SEND_ANSWER";
public static final String ACTION_SEND_ICE_CANDIDATES = "SEND_ICE_CANDIDATES";
public static final String ACTION_SEND_HANGUP = "SEND_HANGUP";
public static final String ACTION_SEND_BUSY = "SEND_BUSY";
public static final String ACTION_RECEIVE_OFFER = "RECEIVE_OFFER";
public static final String ACTION_RECEIVE_ANSWER = "RECEIVE_ANSWER";
public static final String ACTION_RECEIVE_ICE_CANDIDATES = "RECEIVE_ICE_CANDIDATES";
public static final String ACTION_RECEIVE_HANGUP = "RECEIVE_HANGUP";
public static final String ACTION_RECEIVE_BUSY = "RECEIVE_BUSY";
public static final String ACTION_REMOTE_VIDEO_ENABLE = "REMOTE_VIDEO_ENABLE";
public static final String ACTION_SET_ENABLE_VIDEO = "SET_ENABLE_VIDEO";
public static final String ACTION_ENDED_REMOTE_HANGUP = "ENDED_REMOTE_HANGUP";
public static final String ACTION_ENDED_REMOTE_HANGUP_ACCEPTED = "ENDED_REMOTE_HANGUP_ACCEPTED";
public static final String ACTION_ENDED_REMOTE_HANGUP_DECLINED = "ENDED_REMOTE_HANGUP_DECLINED";
public static final String ACTION_ENDED_REMOTE_HANGUP_BUSY = "ENDED_REMOTE_HANGUP_BUSY";
public static final String ACTION_ENDED_REMOTE_BUSY = "ENDED_REMOTE_BUSY";
public static final String ACTION_ENDED_REMOTE_GLARE = "ENDED_REMOTE_GLARE";
public static final String ACTION_ENDED_TIMEOUT = "ENDED_TIMEOUT";
public static final String ACTION_ENDED_INTERNAL_FAILURE = "ENDED_INTERNAL_FAILURE";
public static final String ACTION_ENDED_SIGNALING_FAILURE = "ENDED_SIGNALING_FAILURE";
public static final String ACTION_ENDED_CONNECTION_FAILURE = "ENDED_CONNECTION_FAILURE";
public static final String ACTION_ENDED_RX_OFFER_EXPIRED = "ENDED_RX_OFFER_EXPIRED";
public static final String ACTION_ENDED_RX_OFFER_WHILE_ACTIVE = "ENDED_RX_OFFER_WHILE_ACTIVE";
public static final String ACTION_CALL_CONCLUDED = "CALL_CONCLUDED";
public static final String ACTION_OUTGOING_CALL = "CALL_OUTGOING";
public static final String ACTION_DENY_CALL = "DENY_CALL";
public static final String ACTION_LOCAL_HANGUP = "LOCAL_HANGUP";
public static final String ACTION_SET_MUTE_AUDIO = "SET_MUTE_AUDIO";
public static final String ACTION_FLIP_CAMERA = "FLIP_CAMERA";
public static final String ACTION_BLUETOOTH_CHANGE = "BLUETOOTH_CHANGE";
public static final String ACTION_WIRED_HEADSET_CHANGE = "WIRED_HEADSET_CHANGE";
public static final String ACTION_SCREEN_OFF = "SCREEN_OFF";
public static final String ACTION_IS_IN_CALL_QUERY = "IS_IN_CALL";
public static final String ACTION_SET_AUDIO_SPEAKER = "SET_AUDIO_SPEAKER";
public static final String ACTION_SET_AUDIO_BLUETOOTH = "SET_AUDIO_BLUETOOTH";
public static final String ACTION_CALL_CONNECTED = "CALL_CONNECTED";
public static final String ACTION_START_OUTGOING_CALL = "START_OUTGOING_CALL";
public static final String ACTION_START_INCOMING_CALL = "START_INCOMING_CALL";
public static final String ACTION_LOCAL_RINGING = "LOCAL_RINGING";
public static final String ACTION_REMOTE_RINGING = "REMOTE_RINGING";
public static final String ACTION_ACCEPT_CALL = "ACCEPT_CALL";
public static final String ACTION_SEND_OFFER = "SEND_OFFER";
public static final String ACTION_SEND_ANSWER = "SEND_ANSWER";
public static final String ACTION_SEND_ICE_CANDIDATES = "SEND_ICE_CANDIDATES";
public static final String ACTION_SEND_HANGUP = "SEND_HANGUP";
public static final String ACTION_SEND_BUSY = "SEND_BUSY";
public static final String ACTION_RECEIVE_OFFER = "RECEIVE_OFFER";
public static final String ACTION_RECEIVE_ANSWER = "RECEIVE_ANSWER";
public static final String ACTION_RECEIVE_ICE_CANDIDATES = "RECEIVE_ICE_CANDIDATES";
public static final String ACTION_RECEIVE_HANGUP = "RECEIVE_HANGUP";
public static final String ACTION_RECEIVE_BUSY = "RECEIVE_BUSY";
public static final String ACTION_REMOTE_VIDEO_ENABLE = "REMOTE_VIDEO_ENABLE";
public static final String ACTION_SET_ENABLE_VIDEO = "SET_ENABLE_VIDEO";
public static final String ACTION_ENDED_REMOTE_HANGUP = "ENDED_REMOTE_HANGUP";
public static final String ACTION_ENDED_REMOTE_HANGUP_ACCEPTED = "ENDED_REMOTE_HANGUP_ACCEPTED";
public static final String ACTION_ENDED_REMOTE_HANGUP_DECLINED = "ENDED_REMOTE_HANGUP_DECLINED";
public static final String ACTION_ENDED_REMOTE_HANGUP_BUSY = "ENDED_REMOTE_HANGUP_BUSY";
public static final String ACTION_ENDED_REMOTE_HANGUP_NEED_PERMISSION = "ENDED_REMOTE_HANGUP_NEED_PERMISSION";
public static final String ACTION_ENDED_REMOTE_BUSY = "ENDED_REMOTE_BUSY";
public static final String ACTION_ENDED_REMOTE_GLARE = "ENDED_REMOTE_GLARE";
public static final String ACTION_ENDED_TIMEOUT = "ENDED_TIMEOUT";
public static final String ACTION_ENDED_INTERNAL_FAILURE = "ENDED_INTERNAL_FAILURE";
public static final String ACTION_ENDED_SIGNALING_FAILURE = "ENDED_SIGNALING_FAILURE";
public static final String ACTION_ENDED_CONNECTION_FAILURE = "ENDED_CONNECTION_FAILURE";
public static final String ACTION_ENDED_RX_OFFER_EXPIRED = "ENDED_RX_OFFER_EXPIRED";
public static final String ACTION_ENDED_RX_OFFER_WHILE_ACTIVE = "ENDED_RX_OFFER_WHILE_ACTIVE";
public static final String ACTION_CALL_CONCLUDED = "CALL_CONCLUDED";
private CameraState localCameraState = CameraState.UNKNOWN;
private boolean microphoneEnabled = true;
@ -213,48 +214,49 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
if (intent == null || intent.getAction() == null) return START_NOT_STICKY;
serviceExecutor.execute(() -> {
if (intent.getAction().equals(ACTION_RECEIVE_OFFER)) handleReceivedOffer(intent);
else if (intent.getAction().equals(ACTION_RECEIVE_BUSY)) handleReceivedBusy(intent);
else if (intent.getAction().equals(ACTION_OUTGOING_CALL) && isIdle()) handleOutgoingCall(intent);
else if (intent.getAction().equals(ACTION_DENY_CALL)) handleDenyCall(intent);
else if (intent.getAction().equals(ACTION_LOCAL_HANGUP)) handleLocalHangup(intent);
else if (intent.getAction().equals(ACTION_SET_MUTE_AUDIO)) handleSetMuteAudio(intent);
else if (intent.getAction().equals(ACTION_FLIP_CAMERA)) handleSetCameraFlip(intent);
else if (intent.getAction().equals(ACTION_BLUETOOTH_CHANGE)) handleBluetoothChange(intent);
else if (intent.getAction().equals(ACTION_WIRED_HEADSET_CHANGE)) handleWiredHeadsetChange(intent);
else if (intent.getAction().equals(ACTION_SCREEN_OFF)) handleScreenOffChange(intent);
else if (intent.getAction().equals(ACTION_CALL_CONNECTED)) handleCallConnected(intent);
else if (intent.getAction().equals(ACTION_IS_IN_CALL_QUERY)) handleIsInCallQuery(intent);
else if (intent.getAction().equals(ACTION_SET_AUDIO_SPEAKER)) handleSetSpeakerAudio(intent);
else if (intent.getAction().equals(ACTION_SET_AUDIO_BLUETOOTH)) handleSetBluetoothAudio(intent);
else if (intent.getAction().equals(ACTION_START_OUTGOING_CALL)) handleStartOutgoingCall(intent);
else if (intent.getAction().equals(ACTION_START_INCOMING_CALL)) handleStartIncomingCall(intent);
else if (intent.getAction().equals(ACTION_ACCEPT_CALL)) handleAcceptCall(intent);
else if (intent.getAction().equals(ACTION_LOCAL_RINGING)) handleLocalRinging(intent);
else if (intent.getAction().equals(ACTION_REMOTE_RINGING)) handleRemoteRinging(intent);
else if (intent.getAction().equals(ACTION_SEND_OFFER)) handleSendOffer(intent);
else if (intent.getAction().equals(ACTION_SEND_ANSWER)) handleSendAnswer(intent);
else if (intent.getAction().equals(ACTION_SEND_ICE_CANDIDATES)) handleSendIceCandidates(intent);
else if (intent.getAction().equals(ACTION_SEND_HANGUP)) handleSendHangup(intent);
else if (intent.getAction().equals(ACTION_SEND_BUSY)) handleSendBusy(intent);
else if (intent.getAction().equals(ACTION_RECEIVE_ANSWER)) handleReceivedAnswer(intent);
else if (intent.getAction().equals(ACTION_RECEIVE_ICE_CANDIDATES)) handleReceivedIceCandidates(intent);
else if (intent.getAction().equals(ACTION_RECEIVE_HANGUP)) handleReceivedHangup(intent);
else if (intent.getAction().equals(ACTION_REMOTE_VIDEO_ENABLE)) handleRemoteVideoEnable(intent);
else if (intent.getAction().equals(ACTION_SET_ENABLE_VIDEO)) handleSetEnableVideo(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_HANGUP)) handleEndedRemoteHangup(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_HANGUP_ACCEPTED)) handleEndedRemoteHangupAccepted(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_HANGUP_BUSY)) handleEndedRemoteHangupBusy(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_HANGUP_DECLINED)) handleEndedRemoteHangupDeclined(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_BUSY)) handleEndedRemoteBusy(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_GLARE)) handleEndedRemoteGlare(intent);
else if (intent.getAction().equals(ACTION_ENDED_TIMEOUT)) handleEndedTimeout(intent);
else if (intent.getAction().equals(ACTION_ENDED_INTERNAL_FAILURE)) handleEndedInternalFailure(intent);
else if (intent.getAction().equals(ACTION_ENDED_SIGNALING_FAILURE)) handleEndedSignalingFailure(intent);
else if (intent.getAction().equals(ACTION_ENDED_CONNECTION_FAILURE)) handleEndedConnectionFailure(intent);
else if (intent.getAction().equals(ACTION_ENDED_RX_OFFER_EXPIRED)) handleEndedReceivedOfferExpired(intent);
else if (intent.getAction().equals(ACTION_ENDED_RX_OFFER_WHILE_ACTIVE)) handleEndedReceivedOfferWhileActive(intent);
else if (intent.getAction().equals(ACTION_CALL_CONCLUDED)) handleCallConcluded(intent);
if (intent.getAction().equals(ACTION_RECEIVE_OFFER)) handleReceivedOffer(intent);
else if (intent.getAction().equals(ACTION_RECEIVE_BUSY)) handleReceivedBusy(intent);
else if (intent.getAction().equals(ACTION_OUTGOING_CALL) && isIdle()) handleOutgoingCall(intent);
else if (intent.getAction().equals(ACTION_DENY_CALL)) handleDenyCall(intent);
else if (intent.getAction().equals(ACTION_LOCAL_HANGUP)) handleLocalHangup(intent);
else if (intent.getAction().equals(ACTION_SET_MUTE_AUDIO)) handleSetMuteAudio(intent);
else if (intent.getAction().equals(ACTION_FLIP_CAMERA)) handleSetCameraFlip(intent);
else if (intent.getAction().equals(ACTION_BLUETOOTH_CHANGE)) handleBluetoothChange(intent);
else if (intent.getAction().equals(ACTION_WIRED_HEADSET_CHANGE)) handleWiredHeadsetChange(intent);
else if (intent.getAction().equals(ACTION_SCREEN_OFF)) handleScreenOffChange(intent);
else if (intent.getAction().equals(ACTION_CALL_CONNECTED)) handleCallConnected(intent);
else if (intent.getAction().equals(ACTION_IS_IN_CALL_QUERY)) handleIsInCallQuery(intent);
else if (intent.getAction().equals(ACTION_SET_AUDIO_SPEAKER)) handleSetSpeakerAudio(intent);
else if (intent.getAction().equals(ACTION_SET_AUDIO_BLUETOOTH)) handleSetBluetoothAudio(intent);
else if (intent.getAction().equals(ACTION_START_OUTGOING_CALL)) handleStartOutgoingCall(intent);
else if (intent.getAction().equals(ACTION_START_INCOMING_CALL)) handleStartIncomingCall(intent);
else if (intent.getAction().equals(ACTION_ACCEPT_CALL)) handleAcceptCall(intent);
else if (intent.getAction().equals(ACTION_LOCAL_RINGING)) handleLocalRinging(intent);
else if (intent.getAction().equals(ACTION_REMOTE_RINGING)) handleRemoteRinging(intent);
else if (intent.getAction().equals(ACTION_SEND_OFFER)) handleSendOffer(intent);
else if (intent.getAction().equals(ACTION_SEND_ANSWER)) handleSendAnswer(intent);
else if (intent.getAction().equals(ACTION_SEND_ICE_CANDIDATES)) handleSendIceCandidates(intent);
else if (intent.getAction().equals(ACTION_SEND_HANGUP)) handleSendHangup(intent);
else if (intent.getAction().equals(ACTION_SEND_BUSY)) handleSendBusy(intent);
else if (intent.getAction().equals(ACTION_RECEIVE_ANSWER)) handleReceivedAnswer(intent);
else if (intent.getAction().equals(ACTION_RECEIVE_ICE_CANDIDATES)) handleReceivedIceCandidates(intent);
else if (intent.getAction().equals(ACTION_RECEIVE_HANGUP)) handleReceivedHangup(intent);
else if (intent.getAction().equals(ACTION_REMOTE_VIDEO_ENABLE)) handleRemoteVideoEnable(intent);
else if (intent.getAction().equals(ACTION_SET_ENABLE_VIDEO)) handleSetEnableVideo(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_HANGUP)) handleEndedRemoteHangup(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_HANGUP_ACCEPTED)) handleEndedRemoteHangupAccepted(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_HANGUP_BUSY)) handleEndedRemoteHangupBusy(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_HANGUP_DECLINED)) handleEndedRemoteHangupDeclined(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_BUSY)) handleEndedRemoteBusy(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_HANGUP_NEED_PERMISSION)) handleEndedRemoteNeedPermission(intent);
else if (intent.getAction().equals(ACTION_ENDED_REMOTE_GLARE)) handleEndedRemoteGlare(intent);
else if (intent.getAction().equals(ACTION_ENDED_TIMEOUT)) handleEndedTimeout(intent);
else if (intent.getAction().equals(ACTION_ENDED_INTERNAL_FAILURE)) handleEndedInternalFailure(intent);
else if (intent.getAction().equals(ACTION_ENDED_SIGNALING_FAILURE)) handleEndedSignalingFailure(intent);
else if (intent.getAction().equals(ACTION_ENDED_CONNECTION_FAILURE)) handleEndedConnectionFailure(intent);
else if (intent.getAction().equals(ACTION_ENDED_RX_OFFER_EXPIRED)) handleEndedReceivedOfferExpired(intent);
else if (intent.getAction().equals(ACTION_ENDED_RX_OFFER_WHILE_ACTIVE)) handleEndedReceivedOfferWhileActive(intent);
else if (intent.getAction().equals(ACTION_CALL_CONCLUDED)) handleCallConcluded(intent);
});
@ -403,9 +405,10 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
return;
}
if (offerType == OfferMessage.Type.NEED_PERMISSION || FeatureFlags.profileForCalling() && !remotePeer.getRecipient().resolve().isProfileSharing()) {
if (FeatureFlags.profileForCalling() && (remotePeer.getRecipient() == null || !RecipientUtil.isMessageRequestAccepted(getApplicationContext(), remotePeer.getRecipient()))) {
Log.i(TAG, "handleReceivedOffer(): Caller is untrusted.");
intent.putExtra(EXTRA_BROADCAST, true);
intent.putExtra(EXTRA_HANGUP_TYPE, HangupMessage.Type.NEED_PERMISSION.getCode());
handleSendHangup(intent);
insertMissedCall(remotePeer, true);
return;
@ -706,11 +709,6 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
Log.i(TAG, "handleSendOffer: id: " + callId.format(remoteDevice));
if (FeatureFlags.profileForCalling() && remotePeer.getRecipient().resolve().getProfileKey() == null) {
offer = "";
offerType = OfferMessage.Type.NEED_PERMISSION;
}
OfferMessage offerMessage = new OfferMessage(callId.longValue(), offer, offerType);
Integer destinationDeviceId = broadcast ? null : remoteDevice;
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOffer(offerMessage, true, destinationDeviceId);
@ -1137,6 +1135,16 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
}, WebRtcCallActivity.BUSY_SIGNAL_DELAY_FINISH);
}
private void handleEndedRemoteNeedPermission(Intent intent) {
RemotePeer remotePeer = getRemotePeer(intent);
Log.i(TAG, "handleEndedRemoteNeedPermission(): call_id: " + remotePeer.getCallId());
if (remotePeer.callIdEquals(activePeer)) {
sendMessage(WebRtcViewModel.State.CALL_NEEDS_PERMISSION, remotePeer, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled, isRemoteVideoOffer);
}
}
private void handleEndedRemoteGlare(Intent intent) {
RemotePeer remotePeer = getRemotePeer(intent);
@ -1386,6 +1394,8 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
return CallManager.HangupType.NORMAL;
case DECLINED:
return CallManager.HangupType.DECLINED;
case NEED_PERMISSION:
return CallManager.HangupType.NEED_PERMISSION;
default:
throw new IllegalArgumentException("Unexpected hangup type: " + hangupType);
}
@ -1401,6 +1411,8 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
return HangupMessage.Type.NORMAL;
case DECLINED:
return HangupMessage.Type.DECLINED;
case NEED_PERMISSION:
return HangupMessage.Type.NEED_PERMISSION;
default:
throw new IllegalArgumentException("Unexpected hangup type: " + hangupType);
}
@ -1723,6 +1735,9 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
case ENDED_REMOTE_HANGUP:
intent.setAction(ACTION_ENDED_REMOTE_HANGUP);
break;
case ENDED_REMOTE_HANGUP_NEED_PERMISSION:
intent.setAction(ACTION_ENDED_REMOTE_HANGUP_NEED_PERMISSION);
break;
case ENDED_REMOTE_HANGUP_ACCEPTED:
intent.setAction(ACTION_ENDED_REMOTE_HANGUP_ACCEPTED);
break;

View File

@ -25,7 +25,6 @@ import org.thoughtcrime.securesms.WebRtcCallActivity;
import org.thoughtcrime.securesms.conversation.ConversationActivity;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.messagerequests.CalleeMustAcceptMessageRequestDialogFragment;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.ringrtc.RemotePeer;
@ -197,16 +196,11 @@ public class CommunicationActions {
MessageSender.onMessageSent();
if (FeatureFlags.profileForCalling() && recipient.resolve().getProfileKey() == null) {
CalleeMustAcceptMessageRequestDialogFragment.create(recipient.getId())
.show(activity.getSupportFragmentManager(), null);
} else {
Intent activityIntent = new Intent(activity, WebRtcCallActivity.class);
Intent activityIntent = new Intent(activity, WebRtcCallActivity.class);
activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(activityIntent);
}
activity.startActivity(activityIntent);
})
.execute();
}
@ -228,17 +222,12 @@ public class CommunicationActions {
MessageSender.onMessageSent();
if (FeatureFlags.profileForCalling() && recipient.resolve().getProfileKey() == null) {
CalleeMustAcceptMessageRequestDialogFragment.create(recipient.getId())
.show(activity.getSupportFragmentManager(), null);
} else {
Intent activityIntent = new Intent(activity, WebRtcCallActivity.class);
Intent activityIntent = new Intent(activity, WebRtcCallActivity.class);
activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(WebRtcCallActivity.EXTRA_ENABLE_VIDEO_IF_AVAILABLE, true);
activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(WebRtcCallActivity.EXTRA_ENABLE_VIDEO_IF_AVAILABLE, true);
activity.startActivity(activityIntent);
}
activity.startActivity(activityIntent);
})
.execute();
}

View File

@ -55,7 +55,7 @@ public final class FeatureFlags {
private static final String PINS_MEGAPHONE_KILL_SWITCH = "android.pinsMegaphoneKillSwitch";
private static final String ATTACHMENTS_V3 = "android.attachmentsV3";
private static final String REMOTE_DELETE = "android.remoteDelete";
private static final String PROFILE_FOR_CALLING = "android.profileForCalling";
private static final String PROFILE_FOR_CALLING = "android.profileForCalling.2";
private static final String CALLING_PIP = "android.callingPip";
private static final String VERSIONED_PROFILES_1 = "android.versionedProfiles";
private static final String VERSIONED_PROFILES_2 = "android.versionedProfiles.2";

View File

@ -432,8 +432,8 @@ dependencyVerification {
['org.signal:argon2:13.1',
'0f686ccff0d4842bfcc74d92e8dc780a5f159b9376e37a1189fabbcdac458bef'],
['org.signal:ringrtc-android:2.2.0',
'10da52bd63cb6c0ba45927928b0da3fd59621e3e698ef17f2dbbb1d3b293e80e'],
['org.signal:ringrtc-android:2.3.1',
'2860e38b3e01c25ff23abdb848bd3fd772ffddb4387ea7838b71e2400da1648d'],
['org.signal:signal-metadata-java:0.1.2',
'6aaeb6a33bf3161a3e6ac9db7678277f7a4cf5a2c96b84342e4007ee49bab1bd'],

View File

@ -37,7 +37,8 @@ public class HangupMessage {
NORMAL("normal", SignalServiceProtos.CallMessage.Hangup.Type.HANGUP_NORMAL),
ACCEPTED("accepted", SignalServiceProtos.CallMessage.Hangup.Type.HANGUP_ACCEPTED),
DECLINED("declined", SignalServiceProtos.CallMessage.Hangup.Type.HANGUP_DECLINED),
BUSY("busy", SignalServiceProtos.CallMessage.Hangup.Type.HANGUP_BUSY);
BUSY("busy", SignalServiceProtos.CallMessage.Hangup.Type.HANGUP_BUSY),
NEED_PERMISSION("need_permission", SignalServiceProtos.CallMessage.Hangup.Type.HANGUP_NEED_PERMISSION);
private final String code;
private final SignalServiceProtos.CallMessage.Hangup.Type protoType;

View File

@ -29,8 +29,7 @@ public class OfferMessage {
public enum Type {
AUDIO_CALL("audio_call", SignalServiceProtos.CallMessage.Offer.Type.OFFER_AUDIO_CALL),
VIDEO_CALL("video_call", SignalServiceProtos.CallMessage.Offer.Type.OFFER_VIDEO_CALL),
NEED_PERMISSION("need_permission", SignalServiceProtos.CallMessage.Offer.Type.OFFER_NEED_PERMISSION);
VIDEO_CALL("video_call", SignalServiceProtos.CallMessage.Offer.Type.OFFER_VIDEO_CALL);
private final String code;
private final SignalServiceProtos.CallMessage.Offer.Type protoType;

View File

@ -46,7 +46,7 @@ message CallMessage {
enum Type {
OFFER_AUDIO_CALL = 0;
OFFER_VIDEO_CALL = 1;
OFFER_NEED_PERMISSION = 2;
// 2 is reserved, removed OFFER_NEED_PERMISSION
}
optional uint64 id = 1;
@ -72,10 +72,11 @@ message CallMessage {
message Hangup {
enum Type {
HANGUP_NORMAL = 0;
HANGUP_ACCEPTED = 1;
HANGUP_DECLINED = 2;
HANGUP_BUSY = 3;
HANGUP_NORMAL = 0;
HANGUP_ACCEPTED = 1;
HANGUP_DECLINED = 2;
HANGUP_BUSY = 3;
HANGUP_NEED_PERMISSION = 4;
}
optional uint64 id = 1;