Search in sources :

Example 16 with AsyncResult

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

the class GSMPhone 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.getIMEI(obtainMessage(EVENT_GET_IMEI_DONE));
                mCM.getIMEISV(obtainMessage(EVENT_GET_IMEISV_DONE));
            }
            break;
        case EVENT_RADIO_ON:
            break;
        case EVENT_REGISTERED_TO_NETWORK:
            syncClirSetting();
            break;
        case EVENT_SIM_RECORDS_LOADED:
            updateCurrentCarrierInProvider();
            // Check if this is a different SIM than the previous one. If so unset the
            // voice mail number.
            String imsi = getVmSimImsi();
            String imsiFromSIM = getSubscriberId();
            if (imsi != null && imsiFromSIM != null && !imsiFromSIM.equals(imsi)) {
                storeVoiceMailNumber(null);
                setVmSimImsi(null);
            }
            break;
        case EVENT_GET_BASEBAND_VERSION_DONE:
            ar = (AsyncResult) msg.obj;
            if (ar.exception != null) {
                break;
            }
            if (LOCAL_DEBUG)
                Log.d(LOG_TAG, "Baseband version: " + ar.result);
            setSystemProperty(PROPERTY_BASEBAND_VERSION, (String) ar.result);
            break;
        case EVENT_GET_IMEI_DONE:
            ar = (AsyncResult) msg.obj;
            if (ar.exception != null) {
                break;
            }
            mImei = (String) ar.result;
            break;
        case EVENT_GET_IMEISV_DONE:
            ar = (AsyncResult) msg.obj;
            if (ar.exception != null) {
                break;
            }
            mImeiSv = (String) ar.result;
            break;
        case EVENT_USSD:
            ar = (AsyncResult) msg.obj;
            String[] ussdResult = (String[]) ar.result;
            if (ussdResult.length > 1) {
                try {
                    onIncomingUSSD(Integer.parseInt(ussdResult[0]), ussdResult[1]);
                } catch (NumberFormatException e) {
                    Log.w(LOG_TAG, "error parsing USSD");
                }
            }
            break;
        case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:
            for (int i = 0, s = mPendingMMIs.size(); i < s; i++) {
                if (mPendingMMIs.get(i).isPendingUSSD()) {
                    mPendingMMIs.get(i).onUssdFinishedError();
                }
            }
            break;
        case EVENT_SSN:
            ar = (AsyncResult) msg.obj;
            SuppServiceNotification not = (SuppServiceNotification) ar.result;
            mSsnRegistrants.notifyRegistrants(ar);
            break;
        case EVENT_SET_CALL_FORWARD_DONE:
            ar = (AsyncResult) msg.obj;
            if (ar.exception == null) {
                mIccRecords.setVoiceCallForwardingFlag(1, msg.arg1 == 1);
            }
            onComplete = (Message) ar.userObj;
            if (onComplete != null) {
                AsyncResult.forMessage(onComplete, ar.result, ar.exception);
                onComplete.sendToTarget();
            }
            break;
        case EVENT_SET_VM_NUMBER_DONE:
            ar = (AsyncResult) msg.obj;
            if (IccVmNotSupportedException.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;
        case EVENT_GET_CALL_FORWARD_DONE:
            ar = (AsyncResult) msg.obj;
            if (ar.exception == null) {
                handleCfuQueryResult((CallForwardInfo[]) ar.result);
            }
            onComplete = (Message) ar.userObj;
            if (onComplete != null) {
                AsyncResult.forMessage(onComplete, ar.result, ar.exception);
                onComplete.sendToTarget();
            }
            break;
        // handle the select network completion callbacks.
        case EVENT_SET_NETWORK_MANUAL_COMPLETE:
        case EVENT_SET_NETWORK_AUTOMATIC_COMPLETE:
            handleSetSelectNetwork((AsyncResult) msg.obj);
            break;
        case EVENT_SET_CLIR_COMPLETE:
            ar = (AsyncResult) msg.obj;
            if (ar.exception == null) {
                saveClirSetting(msg.arg1);
            }
            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) CallForwardInfo(com.android.internal.telephony.CallForwardInfo) AsyncResult(android.os.AsyncResult)

Example 17 with AsyncResult

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

the class RuimRecords method onAllRecordsLoaded.

@Override
protected void onAllRecordsLoaded() {
    Log.d(LOG_TAG, "RuimRecords: record load complete");
    // Further records that can be inserted are Operator/OEM dependent
    String operator = getRUIMOperatorNumeric();
    SystemProperties.set(PROPERTY_ICC_OPERATOR_NUMERIC, operator);
    if (mImsi != null) {
        SystemProperties.set(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, MccTable.countryCodeForMcc(Integer.parseInt(mImsi.substring(0, 3))));
    }
    recordsLoadedRegistrants.notifyRegistrants(new AsyncResult(null, null, null));
    phone.mIccCard.broadcastIccStateChangedIntent(RuimCard.INTENT_VALUE_ICC_LOADED, null);
}
Also used : AsyncResult(android.os.AsyncResult)

Example 18 with AsyncResult

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

the class GsmCallTracker method handleMessage.

//****** Overridden from Handler
public void handleMessage(Message msg) {
    AsyncResult ar;
    switch(msg.what) {
        case EVENT_POLL_CALLS_RESULT:
            ar = (AsyncResult) msg.obj;
            if (msg == lastRelevantPoll) {
                if (DBG_POLL)
                    log("handle EVENT_POLL_CALL_RESULT: set needsPoll=F");
                needsPoll = false;
                lastRelevantPoll = null;
                handlePollCalls((AsyncResult) msg.obj);
            }
            break;
        case EVENT_OPERATION_COMPLETE:
            ar = (AsyncResult) msg.obj;
            operationComplete();
            break;
        case EVENT_SWITCH_RESULT:
        case EVENT_CONFERENCE_RESULT:
        case EVENT_SEPARATE_RESULT:
        case EVENT_ECT_RESULT:
            ar = (AsyncResult) msg.obj;
            if (ar.exception != null) {
                phone.notifySuppServiceFailed(getFailedService(msg.what));
            }
            operationComplete();
            break;
        case EVENT_GET_LAST_CALL_FAIL_CAUSE:
            int causeCode;
            ar = (AsyncResult) msg.obj;
            operationComplete();
            if (ar.exception != null) {
                // An exception occurred...just treat the disconnect
                // cause as "normal"
                causeCode = CallFailCause.NORMAL_CLEARING;
                Log.i(LOG_TAG, "Exception during getLastCallFailCause, assuming normal disconnect");
            } else {
                causeCode = ((int[]) ar.result)[0];
            }
            // Log the causeCode if its not normal
            if (causeCode == CallFailCause.NO_CIRCUIT_AVAIL || causeCode == CallFailCause.TEMPORARY_FAILURE || causeCode == CallFailCause.SWITCHING_CONGESTION || causeCode == CallFailCause.CHANNEL_NOT_AVAIL || causeCode == CallFailCause.QOS_NOT_AVAIL || causeCode == CallFailCause.BEARER_NOT_AVAIL || causeCode == CallFailCause.ERROR_UNSPECIFIED) {
                GsmCellLocation loc = ((GsmCellLocation) phone.getCellLocation());
                EventLog.writeEvent(EventLogTags.CALL_DROP, causeCode, loc != null ? loc.getCid() : -1, TelephonyManager.getDefault().getNetworkType());
            }
            for (int i = 0, s = droppedDuringPoll.size(); i < s; i++) {
                GsmConnection conn = droppedDuringPoll.get(i);
                conn.onRemoteDisconnect(causeCode);
            }
            updatePhoneState();
            phone.notifyPreciseCallStateChanged();
            droppedDuringPoll.clear();
            break;
        case EVENT_REPOLL_AFTER_DELAY:
        case EVENT_CALL_STATE_CHANGE:
            pollCallsWhenSafe();
            break;
        case EVENT_RADIO_AVAILABLE:
            handleRadioAvailable();
            break;
        case EVENT_RADIO_NOT_AVAILABLE:
            handleRadioNotAvailable();
            break;
    }
}
Also used : GsmConnection(com.android.internal.telephony.gsm.GsmConnection) GsmCellLocation(android.telephony.gsm.GsmCellLocation) AsyncResult(android.os.AsyncResult)

Example 19 with AsyncResult

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

the class GsmConnection method processNextPostDialChar.

private void processNextPostDialChar() {
    char c = 0;
    Registrant postDialHandler;
    if (postDialState == PostDialState.CANCELLED) {
        //Log.v("GSM", "##### processNextPostDialChar: postDialState == CANCELLED, bail");
        return;
    }
    if (postDialString == null || postDialString.length() <= nextPostDialChar) {
        setPostDialState(PostDialState.COMPLETE);
        // notifyMessage.arg1 is 0 on complete
        c = 0;
    } else {
        boolean isValid;
        setPostDialState(PostDialState.STARTED);
        c = postDialString.charAt(nextPostDialChar++);
        isValid = processPostDialChar(c);
        if (!isValid) {
            // Will call processNextPostDialChar
            h.obtainMessage(EVENT_NEXT_POST_DIAL).sendToTarget();
            // Don't notify application
            Log.e("GSM", "processNextPostDialChar: c=" + c + " isn't valid!");
            return;
        }
    }
    postDialHandler = owner.phone.mPostDialHandler;
    Message notifyMessage;
    if (postDialHandler != null && (notifyMessage = postDialHandler.messageForRegistrant()) != null) {
        // The AsyncResult.result is the Connection object
        PostDialState state = postDialState;
        AsyncResult ar = AsyncResult.forMessage(notifyMessage);
        ar.result = this;
        ar.userObj = state;
        // arg1 is the character that was/is being processed
        notifyMessage.arg1 = c;
        //Log.v("GSM", "##### processNextPostDialChar: send msg to postDialHandler, arg1=" + c);
        notifyMessage.sendToTarget();
    }
}
Also used : Message(android.os.Message) Registrant(android.os.Registrant) AsyncResult(android.os.AsyncResult)

Example 20 with AsyncResult

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

the class SipPhoneBase method startRingbackTone.

protected void startRingbackTone() {
    AsyncResult result = new AsyncResult(null, Boolean.TRUE, null);
    mRingbackRegistrants.notifyRegistrants(result);
}
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