mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 16:33:39 +00:00
Don't ring on incoming calls from blocked numbers
// FREEBIE
This commit is contained in:
parent
3bec127020
commit
e46caa024d
@ -16,6 +16,8 @@ import org.thoughtcrime.redphone.signaling.signals.CompressedInitiateSignalProto
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.jobs.PushContentReceiveJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -65,15 +67,20 @@ public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
|
||||
String signalingKey = TextSecurePreferences.getSignalingKey(context);
|
||||
EncryptedSignalMessage encryptedSignalMessage = new EncryptedSignalMessage(data, signalingKey);
|
||||
CompressedInitiateSignal signal = CompressedInitiateSignal.parseFrom(encryptedSignalMessage.getPlaintext());
|
||||
Recipients recipients = RecipientFactory.getRecipientsFromString(context, signal.getInitiator(), false);
|
||||
|
||||
Intent intent = new Intent(context, RedPhoneService.class);
|
||||
intent.setAction(RedPhoneService.ACTION_INCOMING_CALL);
|
||||
intent.putExtra(RedPhoneService.EXTRA_REMOTE_NUMBER, signal.getInitiator());
|
||||
intent.putExtra(RedPhoneService.EXTRA_SESSION_DESCRIPTOR, new SessionDescriptor(signal.getServerName(),
|
||||
signal.getPort(),
|
||||
signal.getSessionId(),
|
||||
signal.getVersion()));
|
||||
context.startService(intent);
|
||||
if (!recipients.isBlocked()) {
|
||||
Intent intent = new Intent(context, RedPhoneService.class);
|
||||
intent.setAction(RedPhoneService.ACTION_INCOMING_CALL);
|
||||
intent.putExtra(RedPhoneService.EXTRA_REMOTE_NUMBER, signal.getInitiator());
|
||||
intent.putExtra(RedPhoneService.EXTRA_SESSION_DESCRIPTOR, new SessionDescriptor(signal.getServerName(),
|
||||
signal.getPort(),
|
||||
signal.getSessionId(),
|
||||
signal.getVersion()));
|
||||
context.startService(intent);
|
||||
} else {
|
||||
Log.w(TAG, "*** Received incoming call from blocked number, ignoring...");
|
||||
}
|
||||
} catch (InvalidEncryptedSignalException | IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user