Handle voice GCM intents in AsyncTask.
// FREEBIE
This commit is contained in:
parent
c041495834
commit
ccbe856ffb
1 changed files with 28 additions and 20 deletions
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.gcm;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.support.v4.content.WakefulBroadcastReceiver;
|
import android.support.v4.content.WakefulBroadcastReceiver;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -62,27 +63,34 @@ public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
|
||||||
.add(new PushNotificationReceiveJob(context));
|
.add(new PushNotificationReceiveJob(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleReceivedCall(Context context, String data) {
|
private void handleReceivedCall(final Context context, final String data) {
|
||||||
try {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
String signalingKey = TextSecurePreferences.getSignalingKey(context);
|
@Override
|
||||||
EncryptedSignalMessage encryptedSignalMessage = new EncryptedSignalMessage(data, signalingKey);
|
protected Void doInBackground(Void... params) {
|
||||||
CompressedInitiateSignal signal = CompressedInitiateSignal.parseFrom(encryptedSignalMessage.getPlaintext());
|
try {
|
||||||
Recipients recipients = RecipientFactory.getRecipientsFromString(context, signal.getInitiator(), false);
|
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);
|
||||||
|
|
||||||
if (!recipients.isBlocked()) {
|
if (!recipients.isBlocked()) {
|
||||||
Intent intent = new Intent(context, RedPhoneService.class);
|
Intent intent = new Intent(context, RedPhoneService.class);
|
||||||
intent.setAction(RedPhoneService.ACTION_INCOMING_CALL);
|
intent.setAction(RedPhoneService.ACTION_INCOMING_CALL);
|
||||||
intent.putExtra(RedPhoneService.EXTRA_REMOTE_NUMBER, signal.getInitiator());
|
intent.putExtra(RedPhoneService.EXTRA_REMOTE_NUMBER, signal.getInitiator());
|
||||||
intent.putExtra(RedPhoneService.EXTRA_SESSION_DESCRIPTOR, new SessionDescriptor(signal.getServerName(),
|
intent.putExtra(RedPhoneService.EXTRA_SESSION_DESCRIPTOR, new SessionDescriptor(signal.getServerName(),
|
||||||
signal.getPort(),
|
signal.getPort(),
|
||||||
signal.getSessionId(),
|
signal.getSessionId(),
|
||||||
signal.getVersion()));
|
signal.getVersion()));
|
||||||
context.startService(intent);
|
context.startService(intent);
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "*** Received incoming call from blocked number, ignoring...");
|
Log.w(TAG, "*** Received incoming call from blocked number, ignoring...");
|
||||||
|
}
|
||||||
|
} catch (InvalidEncryptedSignalException | IOException e) {
|
||||||
|
Log.w(TAG, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
} catch (InvalidEncryptedSignalException | IOException e) {
|
}.execute();
|
||||||
Log.w(TAG, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue