Fix bug causing call requests to not be handled properly.
parent
cdae919b5e
commit
ef6a5b6599
|
@ -17,7 +17,6 @@ import org.thoughtcrime.securesms.groups.GroupChangeBusyException;
|
||||||
import org.thoughtcrime.securesms.groups.GroupChangeException;
|
import org.thoughtcrime.securesms.groups.GroupChangeException;
|
||||||
import org.thoughtcrime.securesms.groups.GroupChangeFailedException;
|
import org.thoughtcrime.securesms.groups.GroupChangeFailedException;
|
||||||
import org.thoughtcrime.securesms.groups.GroupManager;
|
import org.thoughtcrime.securesms.groups.GroupManager;
|
||||||
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceMessageRequestResponseJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceMessageRequestResponseJob;
|
||||||
import org.thoughtcrime.securesms.jobs.RotateProfileKeyJob;
|
import org.thoughtcrime.securesms.jobs.RotateProfileKeyJob;
|
||||||
|
@ -201,6 +200,20 @@ public class RecipientUtil {
|
||||||
return isMessageRequestAccepted(context, threadId, threadRecipient);
|
return isMessageRequestAccepted(context, threadId, threadRecipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like {@link #isMessageRequestAccepted(Context, long)} but with fewer checks around messages so it
|
||||||
|
* is more likely to return false.
|
||||||
|
*/
|
||||||
|
@WorkerThread
|
||||||
|
public static boolean isCallRequestAccepted(@NonNull Context context, @Nullable Recipient threadRecipient) {
|
||||||
|
if (threadRecipient == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(threadRecipient);
|
||||||
|
return isCallRequestAccepted(context, threadId, threadRecipient);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return True if a conversation existed before we enabled message requests, otherwise false.
|
* @return True if a conversation existed before we enabled message requests, otherwise false.
|
||||||
*/
|
*/
|
||||||
|
@ -244,6 +257,14 @@ public class RecipientUtil {
|
||||||
isPreMessageRequestThread(context, threadId);
|
isPreMessageRequestThread(context, threadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
|
private static boolean isCallRequestAccepted(@NonNull Context context, long threadId, @NonNull Recipient threadRecipient) {
|
||||||
|
return threadRecipient.isProfileSharing() ||
|
||||||
|
threadRecipient.isSystemContact() ||
|
||||||
|
hasSentMessageInThread(context, threadId) ||
|
||||||
|
isPreMessageRequestThread(context, threadId);
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private static boolean hasSentMessageInThread(@NonNull Context context, long threadId) {
|
private static boolean hasSentMessageInThread(@NonNull Context context, long threadId) {
|
||||||
return DatabaseFactory.getMmsSmsDatabase(context).getOutgoingSecureConversationCount(threadId) != 0;
|
return DatabaseFactory.getMmsSmsDatabase(context).getOutgoingSecureConversationCount(threadId) != 0;
|
||||||
|
|
|
@ -17,8 +17,6 @@ import android.util.Pair;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.signal.ringrtc.CallException;
|
import org.signal.ringrtc.CallException;
|
||||||
import org.signal.ringrtc.CallId;
|
import org.signal.ringrtc.CallId;
|
||||||
|
@ -44,7 +42,6 @@ import org.thoughtcrime.securesms.ringrtc.CameraEventListener;
|
||||||
import org.thoughtcrime.securesms.ringrtc.CameraState;
|
import org.thoughtcrime.securesms.ringrtc.CameraState;
|
||||||
import org.thoughtcrime.securesms.ringrtc.IceCandidateParcel;
|
import org.thoughtcrime.securesms.ringrtc.IceCandidateParcel;
|
||||||
import org.thoughtcrime.securesms.ringrtc.RemotePeer;
|
import org.thoughtcrime.securesms.ringrtc.RemotePeer;
|
||||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
|
||||||
import org.thoughtcrime.securesms.util.FutureTaskListener;
|
import org.thoughtcrime.securesms.util.FutureTaskListener;
|
||||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
||||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||||
|
@ -76,7 +73,6 @@ import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserExce
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
@ -410,7 +406,7 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remotePeer.getRecipient() == null || !RecipientUtil.isMessageRequestAccepted(getApplicationContext(), remotePeer.getRecipient())) {
|
if (remotePeer.getRecipient() == null || !RecipientUtil.isCallRequestAccepted(getApplicationContext(), remotePeer.getRecipient())) {
|
||||||
Log.i(TAG, "handleReceivedOffer(): Caller is untrusted.");
|
Log.i(TAG, "handleReceivedOffer(): Caller is untrusted.");
|
||||||
intent.putExtra(EXTRA_BROADCAST, true);
|
intent.putExtra(EXTRA_BROADCAST, true);
|
||||||
intent.putExtra(EXTRA_HANGUP_TYPE, HangupMessage.Type.NEED_PERMISSION.getCode());
|
intent.putExtra(EXTRA_HANGUP_TYPE, HangupMessage.Type.NEED_PERMISSION.getCode());
|
||||||
|
|
Loading…
Reference in New Issue