Search in sources :

Example 16 with SmsMessage

use of android.telephony.SmsMessage in project XobotOS by xamarin.

the class SMSDispatcher method handleMessage.

/**
     * Handles events coming from the phone stack. Overridden from handler.
     *
     * @param msg the message to handle
     */
@Override
public void handleMessage(Message msg) {
    AsyncResult ar;
    switch(msg.what) {
        case EVENT_NEW_SMS:
            // A new SMS has been received by the device
            if (false) {
                Log.d(TAG, "New SMS Message Received");
            }
            SmsMessage sms;
            ar = (AsyncResult) msg.obj;
            if (ar.exception != null) {
                Log.e(TAG, "Exception processing incoming SMS. Exception:" + ar.exception);
                return;
            }
            sms = (SmsMessage) ar.result;
            try {
                int result = dispatchMessage(sms.mWrappedSmsMessage);
                if (result != Activity.RESULT_OK) {
                    // RESULT_OK means that message was broadcast for app(s) to handle.
                    // Any other result, we should ack here.
                    boolean handled = (result == Intents.RESULT_SMS_HANDLED);
                    notifyAndAcknowledgeLastIncomingSms(handled, result, null);
                }
            } catch (RuntimeException ex) {
                Log.e(TAG, "Exception dispatching message", ex);
                notifyAndAcknowledgeLastIncomingSms(false, Intents.RESULT_SMS_GENERIC_ERROR, null);
            }
            break;
        case EVENT_SEND_SMS_COMPLETE:
            // An outbound SMS has been successfully transferred, or failed.
            handleSendComplete((AsyncResult) msg.obj);
            break;
        case EVENT_SEND_RETRY:
            sendSms((SmsTracker) msg.obj);
            break;
        case EVENT_POST_ALERT:
            handleReachSentLimit((SmsTracker) (msg.obj));
            break;
        case EVENT_ALERT_TIMEOUT:
            ((AlertDialog) (msg.obj)).dismiss();
            msg.obj = null;
            if (mSTrackers.isEmpty() == false) {
                try {
                    SmsTracker sTracker = mSTrackers.remove(0);
                    sTracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED);
                } catch (CanceledException ex) {
                    Log.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED");
                }
            }
            if (false) {
                Log.d(TAG, "EVENT_ALERT_TIMEOUT, message stop sending");
            }
            break;
        case EVENT_SEND_CONFIRMED_SMS:
            if (mSTrackers.isEmpty() == false) {
                SmsTracker sTracker = mSTrackers.remove(mSTrackers.size() - 1);
                if (sTracker.isMultipart()) {
                    sendMultipartSms(sTracker);
                } else {
                    sendSms(sTracker);
                }
                removeMessages(EVENT_ALERT_TIMEOUT, msg.obj);
            }
            break;
        case EVENT_STOP_SENDING:
            if (mSTrackers.isEmpty() == false) {
                // Remove the latest one.
                try {
                    SmsTracker sTracker = mSTrackers.remove(mSTrackers.size() - 1);
                    sTracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED);
                } catch (CanceledException ex) {
                    Log.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED");
                }
                removeMessages(EVENT_ALERT_TIMEOUT, msg.obj);
            }
            break;
    }
}
Also used : AlertDialog(android.app.AlertDialog) CanceledException(android.app.PendingIntent.CanceledException) SmsMessage(android.telephony.SmsMessage) AsyncResult(android.os.AsyncResult)

Example 17 with SmsMessage

use of android.telephony.SmsMessage in project XobotOS by xamarin.

the class RIL method responseCdmaSms.

private Object responseCdmaSms(Parcel p) {
    SmsMessage sms;
    sms = SmsMessage.newFromParcel(p);
    return sms;
}
Also used : SmsMessage(android.telephony.SmsMessage)

Aggregations

SmsMessage (android.telephony.SmsMessage)17 Bundle (android.os.Bundle)7 ContentValues (android.content.ContentValues)2 Cursor (android.database.Cursor)2 AsyncResult (android.os.AsyncResult)2 AlertDialog (android.app.AlertDialog)1 CanceledException (android.app.PendingIntent.CanceledException)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 SQLException (android.database.SQLException)1 Uri (android.net.Uri)1 PowerManager (android.os.PowerManager)1 CdmaInformationRecords (com.android.internal.telephony.cdma.CdmaInformationRecords)1 Builder (csacre15.ipl.be.myapp.Builder)1 MyModel (csacre15.ipl.be.myapp.model.MyModel)1 DataHandler (fr.neamar.kiss.DataHandler)1 ContactsProvider (fr.neamar.kiss.dataprovider.ContactsProvider)1 ContactsPojo (fr.neamar.kiss.pojo.ContactsPojo)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 NotificationSpec (nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec)1