Search in sources :

Example 1 with SmsSentJob

use of org.thoughtcrime.securesms.jobs.SmsSentJob in project Signal-Android by WhisperSystems.

the class SmsDeliveryListener method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
    long messageId = intent.getLongExtra("message_id", -1);
    switch(intent.getAction()) {
        case SENT_SMS_ACTION:
            int result = getResultCode();
            jobManager.add(new SmsSentJob(context, messageId, SENT_SMS_ACTION, result));
            break;
        case DELIVERED_SMS_ACTION:
            byte[] pdu = intent.getByteArrayExtra("pdu");
            if (pdu == null) {
                Log.w(TAG, "No PDU in delivery receipt!");
                break;
            }
            SmsMessage message = SmsMessage.createFromPdu(pdu);
            if (message == null) {
                Log.w(TAG, "Delivery receipt failed to parse!");
                break;
            }
            jobManager.add(new SmsSentJob(context, messageId, DELIVERED_SMS_ACTION, message.getStatus()));
            break;
        default:
            Log.w(TAG, "Unknown action: " + intent.getAction());
    }
}
Also used : SmsSentJob(org.thoughtcrime.securesms.jobs.SmsSentJob) SmsMessage(android.telephony.SmsMessage) JobManager(org.whispersystems.jobqueue.JobManager)

Aggregations

SmsMessage (android.telephony.SmsMessage)1 SmsSentJob (org.thoughtcrime.securesms.jobs.SmsSentJob)1 JobManager (org.whispersystems.jobqueue.JobManager)1