Search in sources :

Example 26 with AsyncResult

use of android.os.AsyncResult 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 27 with AsyncResult

use of android.os.AsyncResult in project XobotOS by xamarin.

the class SmsStorageMonitor 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_ICC_FULL:
            handleIccFull();
            break;
        case EVENT_REPORT_MEMORY_STATUS_DONE:
            ar = (AsyncResult) msg.obj;
            if (ar.exception != null) {
                mReportMemoryStatusPending = true;
                Log.v(TAG, "Memory status report to modem pending : mStorageAvailable = " + mStorageAvailable);
            } else {
                mReportMemoryStatusPending = false;
            }
            break;
        case EVENT_RADIO_ON:
            if (mReportMemoryStatusPending) {
                Log.v(TAG, "Sending pending memory status report : mStorageAvailable = " + mStorageAvailable);
                mCm.reportSmsMemoryStatus(mStorageAvailable, obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE));
            }
            break;
    }
}
Also used : AsyncResult(android.os.AsyncResult)

Example 28 with AsyncResult

use of android.os.AsyncResult in project XobotOS by xamarin.

the class CDMAPhone method handleMessage.

@Override
public void handleMessage(Message msg) {
    AsyncResult ar;
    Message onComplete;
    switch(msg.what) {
        case EVENT_RADIO_AVAILABLE:
            {
                mCM.getBasebandVersion(obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE));
                mCM.getDeviceIdentity(obtainMessage(EVENT_GET_DEVICE_IDENTITY_DONE));
            }
            break;
        case EVENT_GET_BASEBAND_VERSION_DONE:
            {
                ar = (AsyncResult) msg.obj;
                if (ar.exception != null) {
                    break;
                }
                if (DBG)
                    Log.d(LOG_TAG, "Baseband version: " + ar.result);
                setSystemProperty(TelephonyProperties.PROPERTY_BASEBAND_VERSION, (String) ar.result);
            }
            break;
        case EVENT_GET_DEVICE_IDENTITY_DONE:
            {
                ar = (AsyncResult) msg.obj;
                if (ar.exception != null) {
                    break;
                }
                String[] respId = (String[]) ar.result;
                mImei = respId[0];
                mImeiSv = respId[1];
                mEsn = respId[2];
                mMeid = respId[3];
            }
            break;
        case EVENT_EMERGENCY_CALLBACK_MODE_ENTER:
            {
                handleEnterEmergencyCallbackMode(msg);
            }
            break;
        case EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE:
            {
                handleExitEmergencyCallbackMode(msg);
            }
            break;
        case EVENT_RUIM_RECORDS_LOADED:
            {
                Log.d(LOG_TAG, "Event EVENT_RUIM_RECORDS_LOADED Received");
                updateCurrentCarrierInProvider();
            }
            break;
        case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:
            {
                Log.d(LOG_TAG, "Event EVENT_RADIO_OFF_OR_NOT_AVAILABLE Received");
            }
            break;
        case EVENT_RADIO_ON:
            {
                Log.d(LOG_TAG, "Event EVENT_RADIO_ON Received");
            }
            break;
        case EVENT_SSN:
            {
                Log.d(LOG_TAG, "Event EVENT_SSN Received");
            }
            break;
        case EVENT_REGISTERED_TO_NETWORK:
            {
                Log.d(LOG_TAG, "Event EVENT_REGISTERED_TO_NETWORK Received");
            }
            break;
        case EVENT_NV_READY:
            {
                Log.d(LOG_TAG, "Event EVENT_NV_READY Received");
                //Inform the Service State Tracker
                mNvLoadedRegistrants.notifyRegistrants();
                prepareEri();
            }
            break;
        case EVENT_SET_VM_NUMBER_DONE:
            {
                ar = (AsyncResult) msg.obj;
                if (IccException.class.isInstance(ar.exception)) {
                    storeVoiceMailNumber(mVmNumber);
                    ar.exception = null;
                }
                onComplete = (Message) ar.userObj;
                if (onComplete != null) {
                    AsyncResult.forMessage(onComplete, ar.result, ar.exception);
                    onComplete.sendToTarget();
                }
            }
            break;
        default:
            {
                super.handleMessage(msg);
            }
    }
}
Also used : Message(android.os.Message) IccException(com.android.internal.telephony.IccException) AsyncResult(android.os.AsyncResult)

Example 29 with AsyncResult

use of android.os.AsyncResult in project XobotOS by xamarin.

the class PhoneBase method notifyServiceStateChangedP.

/**
     * Subclasses of Phone probably want to replace this with a
     * version scoped to their packages
     */
protected void notifyServiceStateChangedP(ServiceState ss) {
    AsyncResult ar = new AsyncResult(null, ss, null);
    mServiceStateRegistrants.notifyRegistrants(ar);
    mNotifier.notifyServiceState(this);
}
Also used : AsyncResult(android.os.AsyncResult)

Example 30 with AsyncResult

use of android.os.AsyncResult in project XobotOS by xamarin.

the class PhoneBase method notifyIncomingRing.

/**
     * Notify registrants of a RING event.
     */
private void notifyIncomingRing() {
    if (!mIsVoiceCapable)
        return;
    AsyncResult ar = new AsyncResult(null, this, null);
    mIncomingRingRegistrants.notifyRegistrants(ar);
}
Also used : AsyncResult(android.os.AsyncResult)

Aggregations

AsyncResult (android.os.AsyncResult)42 Message (android.os.Message)10 Registrant (android.os.Registrant)5 SmsMessage (android.telephony.SmsMessage)2 GsmCellLocation (android.telephony.gsm.GsmCellLocation)2 AdnRecord (com.android.internal.telephony.AdnRecord)2 ArrayList (java.util.ArrayList)2 AlertDialog (android.app.AlertDialog)1 CanceledException (android.app.PendingIntent.CanceledException)1 AdnRecordLoader (com.android.internal.telephony.AdnRecordLoader)1 CallForwardInfo (com.android.internal.telephony.CallForwardInfo)1 IccException (com.android.internal.telephony.IccException)1 CdmaInformationRecords (com.android.internal.telephony.cdma.CdmaInformationRecords)1 GsmConnection (com.android.internal.telephony.gsm.GsmConnection)1 SuppServiceNotification (com.android.internal.telephony.gsm.SuppServiceNotification)1