Search in sources :

Example 1 with AsyncResult

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

the class AdnRecordCache method clearWaiters.

private void clearWaiters() {
    int size = adnLikeWaiters.size();
    for (int i = 0; i < size; i++) {
        ArrayList<Message> waiters = adnLikeWaiters.valueAt(i);
        AsyncResult ar = new AsyncResult(null, null, new RuntimeException("AdnCache reset"));
        notifyWaiters(waiters, ar);
    }
    adnLikeWaiters.clear();
}
Also used : Message(android.os.Message) AsyncResult(android.os.AsyncResult)

Example 2 with AsyncResult

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

the class AdnRecordLoader method handleMessage.

//***** Overridden from Handler
public void handleMessage(Message msg) {
    AsyncResult ar;
    byte[] data;
    AdnRecord adn;
    try {
        switch(msg.what) {
            case EVENT_EF_LINEAR_RECORD_SIZE_DONE:
                ar = (AsyncResult) (msg.obj);
                adn = (AdnRecord) (ar.userObj);
                if (ar.exception != null) {
                    throw new RuntimeException("get EF record size failed", ar.exception);
                }
                int[] recordSize = (int[]) ar.result;
                // So int[0] * int[2] = int[1]
                if (recordSize.length != 3 || recordNumber > recordSize[2]) {
                    throw new RuntimeException("get wrong EF record size format", ar.exception);
                }
                data = adn.buildAdnString(recordSize[0]);
                if (data == null) {
                    throw new RuntimeException("wrong ADN format", ar.exception);
                }
                phone.mIccFileHandler.updateEFLinearFixed(ef, recordNumber, data, pin2, obtainMessage(EVENT_UPDATE_RECORD_DONE));
                pendingExtLoads = 1;
                break;
            case EVENT_UPDATE_RECORD_DONE:
                ar = (AsyncResult) (msg.obj);
                if (ar.exception != null) {
                    throw new RuntimeException("update EF adn record failed", ar.exception);
                }
                pendingExtLoads = 0;
                result = null;
                break;
            case EVENT_ADN_LOAD_DONE:
                ar = (AsyncResult) (msg.obj);
                data = (byte[]) (ar.result);
                if (ar.exception != null) {
                    throw new RuntimeException("load failed", ar.exception);
                }
                if (false) {
                    Log.d(LOG_TAG, "ADN EF: 0x" + Integer.toHexString(ef) + ":" + recordNumber + "\n" + IccUtils.bytesToHexString(data));
                }
                adn = new AdnRecord(ef, recordNumber, data);
                result = adn;
                if (adn.hasExtendedRecord()) {
                    // If we have a valid value in the ext record field,
                    // we're not done yet: we need to read the corresponding
                    // ext record and append it
                    pendingExtLoads = 1;
                    phone.mIccFileHandler.loadEFLinearFixed(extensionEF, adn.extRecord, obtainMessage(EVENT_EXT_RECORD_LOAD_DONE, adn));
                }
                break;
            case EVENT_EXT_RECORD_LOAD_DONE:
                ar = (AsyncResult) (msg.obj);
                data = (byte[]) (ar.result);
                adn = (AdnRecord) (ar.userObj);
                if (ar.exception != null) {
                    throw new RuntimeException("load failed", ar.exception);
                }
                Log.d(LOG_TAG, "ADN extension EF: 0x" + Integer.toHexString(extensionEF) + ":" + adn.extRecord + "\n" + IccUtils.bytesToHexString(data));
                adn.appendExtRecord(data);
                pendingExtLoads--;
                // EVENT_ADN_LOAD_DONE or EVENT_ADN_LOAD_ALL_DONE
                break;
            case EVENT_ADN_LOAD_ALL_DONE:
                ar = (AsyncResult) (msg.obj);
                ArrayList<byte[]> datas = (ArrayList<byte[]>) (ar.result);
                if (ar.exception != null) {
                    throw new RuntimeException("load failed", ar.exception);
                }
                adns = new ArrayList<AdnRecord>(datas.size());
                result = adns;
                pendingExtLoads = 0;
                for (int i = 0, s = datas.size(); i < s; i++) {
                    adn = new AdnRecord(ef, 1 + i, datas.get(i));
                    adns.add(adn);
                    if (adn.hasExtendedRecord()) {
                        // If we have a valid value in the ext record field,
                        // we're not done yet: we need to read the corresponding
                        // ext record and append it
                        pendingExtLoads++;
                        phone.mIccFileHandler.loadEFLinearFixed(extensionEF, adn.extRecord, obtainMessage(EVENT_EXT_RECORD_LOAD_DONE, adn));
                    }
                }
                break;
        }
    } catch (RuntimeException exc) {
        if (userResponse != null) {
            AsyncResult.forMessage(userResponse).exception = exc;
            userResponse.sendToTarget();
            // Loading is all or nothing--either every load succeeds
            // or we fail the whole thing.
            userResponse = null;
        }
        return;
    }
    if (userResponse != null && pendingExtLoads == 0) {
        AsyncResult.forMessage(userResponse).result = result;
        userResponse.sendToTarget();
        userResponse = null;
    }
}
Also used : ArrayList(java.util.ArrayList) AsyncResult(android.os.AsyncResult)

Example 3 with AsyncResult

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

the class DataConnection method tearDownData.

/**
     * TearDown the data connection.
     *
     * @param o will be returned in AsyncResult.userObj
     *          and is either a DisconnectParams or ConnectionParams.
     */
private void tearDownData(Object o) {
    int discReason = RILConstants.DEACTIVATE_REASON_NONE;
    if ((o != null) && (o instanceof DisconnectParams)) {
        DisconnectParams dp = (DisconnectParams) o;
        Message m = dp.onCompletedMsg;
        if (TextUtils.equals(dp.reason, Phone.REASON_RADIO_TURNED_OFF)) {
            discReason = RILConstants.DEACTIVATE_REASON_RADIO_OFF;
        } else if (TextUtils.equals(dp.reason, Phone.REASON_PDP_RESET)) {
            discReason = RILConstants.DEACTIVATE_REASON_PDP_RESET;
        }
    }
    if (phone.mCM.getRadioState().isOn()) {
        if (DBG)
            log("tearDownData radio is on, call deactivateDataCall");
        phone.mCM.deactivateDataCall(cid, discReason, obtainMessage(EVENT_DEACTIVATE_DONE, o));
    } else {
        if (DBG)
            log("tearDownData radio is off sendMessage EVENT_DEACTIVATE_DONE immediately");
        AsyncResult ar = new AsyncResult(o, null, null);
        sendMessage(obtainMessage(EVENT_DEACTIVATE_DONE, ar));
    }
}
Also used : Message(android.os.Message) AsyncResult(android.os.AsyncResult)

Example 4 with AsyncResult

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

the class SIMRecords method onAllRecordsLoaded.

protected void onAllRecordsLoaded() {
    Log.d(LOG_TAG, "SIMRecords: record load complete");
    String operator = getOperatorNumeric();
    // Some fields require more than one SIM record to set
    phone.setSystemProperty(PROPERTY_ICC_OPERATOR_NUMERIC, operator);
    if (imsi != null) {
        phone.setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, MccTable.countryCodeForMcc(Integer.parseInt(imsi.substring(0, 3))));
    } else {
        Log.e("SIM", "[SIMRecords] onAllRecordsLoaded: imsi is NULL!");
    }
    setVoiceMailByCountry(operator);
    setSpnFromConfig(operator);
    recordsLoadedRegistrants.notifyRegistrants(new AsyncResult(null, null, null));
    phone.mIccCard.broadcastIccStateChangedIntent(SimCard.INTENT_VALUE_ICC_LOADED, null);
}
Also used : AsyncResult(android.os.AsyncResult)

Example 5 with AsyncResult

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

the class SIMRecords method handleMessage.

// ***** Overridden from Handler
public void handleMessage(Message msg) {
    AsyncResult ar;
    AdnRecord adn;
    byte[] data;
    boolean isRecordLoadResponse = false;
    try {
        switch(msg.what) {
            case EVENT_SIM_READY:
                onSimReady();
                break;
            case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:
                onRadioOffOrNotAvailable();
                break;
            /* IO events */
            case EVENT_GET_IMSI_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                if (ar.exception != null) {
                    Log.e(LOG_TAG, "Exception querying IMSI, Exception:" + ar.exception);
                    break;
                }
                imsi = (String) ar.result;
                // than 15 (and usually 15).
                if (imsi != null && (imsi.length() < 6 || imsi.length() > 15)) {
                    Log.e(LOG_TAG, "invalid IMSI " + imsi);
                    imsi = null;
                }
                Log.d(LOG_TAG, "IMSI: " + /* imsi.substring(0, 6) +*/
                "xxxxxxx");
                if (((mncLength == UNKNOWN) || (mncLength == 2)) && ((imsi != null) && (imsi.length() >= 6))) {
                    String mccmncCode = imsi.substring(0, 6);
                    for (String mccmnc : MCCMNC_CODES_HAVING_3DIGITS_MNC) {
                        if (mccmnc.equals(mccmncCode)) {
                            mncLength = 3;
                            break;
                        }
                    }
                }
                if (mncLength == UNKNOWN) {
                    // guess using the mcc
                    try {
                        int mcc = Integer.parseInt(imsi.substring(0, 3));
                        mncLength = MccTable.smallestDigitsMccForMnc(mcc);
                    } catch (NumberFormatException e) {
                        mncLength = UNKNOWN;
                        Log.e(LOG_TAG, "SIMRecords: Corrupt IMSI!");
                    }
                }
                if (mncLength != UNKNOWN && mncLength != UNINITIALIZED) {
                    // finally have both the imsi and the mncLength and can parse the imsi properly
                    MccTable.updateMccMncConfiguration(phone, imsi.substring(0, 3 + mncLength));
                }
                phone.mIccCard.broadcastIccStateChangedIntent(SimCard.INTENT_VALUE_ICC_IMSI, null);
                break;
            case EVENT_GET_MBI_DONE:
                boolean isValidMbdn;
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                data = (byte[]) ar.result;
                isValidMbdn = false;
                if (ar.exception == null) {
                    // Refer TS 51.011 Section 10.3.44 for content details
                    Log.d(LOG_TAG, "EF_MBI: " + IccUtils.bytesToHexString(data));
                    // Voice mail record number stored first
                    mailboxIndex = (int) data[0] & 0xff;
                    // check if dailing numbe id valid
                    if (mailboxIndex != 0 && mailboxIndex != 0xff) {
                        Log.d(LOG_TAG, "Got valid mailbox number for MBDN");
                        isValidMbdn = true;
                    }
                }
                // one more record to load
                recordsToLoad += 1;
                if (isValidMbdn) {
                    // Note: MBDN was not included in NUM_OF_SIM_RECORDS_LOADED
                    new AdnRecordLoader(phone).loadFromEF(EF_MBDN, EF_EXT6, mailboxIndex, obtainMessage(EVENT_GET_MBDN_DONE));
                } else {
                    // If this EF not present, try mailbox as in CPHS standard
                    // CPHS (CPHS4_2.WW6) is a european standard.
                    new AdnRecordLoader(phone).loadFromEF(EF_MAILBOX_CPHS, EF_EXT1, 1, obtainMessage(EVENT_GET_CPHS_MAILBOX_DONE));
                }
                break;
            case EVENT_GET_CPHS_MAILBOX_DONE:
            case EVENT_GET_MBDN_DONE:
                //Resetting the voice mail number and voice mail tag to null
                //as these should be updated from the data read from EF_MBDN.
                //If they are not reset, incase of invalid data/exception these
                //variables are retaining their previous values and are
                //causing invalid voice mailbox info display to user.
                voiceMailNum = null;
                voiceMailTag = null;
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                if (ar.exception != null) {
                    Log.d(LOG_TAG, "Invalid or missing EF" + ((msg.what == EVENT_GET_CPHS_MAILBOX_DONE) ? "[MAILBOX]" : "[MBDN]"));
                    if (msg.what == EVENT_GET_MBDN_DONE) {
                        //load CPHS on fail...
                        // FIXME right now, only load line1's CPHS voice mail entry
                        recordsToLoad += 1;
                        new AdnRecordLoader(phone).loadFromEF(EF_MAILBOX_CPHS, EF_EXT1, 1, obtainMessage(EVENT_GET_CPHS_MAILBOX_DONE));
                    }
                    break;
                }
                adn = (AdnRecord) ar.result;
                Log.d(LOG_TAG, "VM: " + adn + ((msg.what == EVENT_GET_CPHS_MAILBOX_DONE) ? " EF[MAILBOX]" : " EF[MBDN]"));
                if (adn.isEmpty() && msg.what == EVENT_GET_MBDN_DONE) {
                    // Bug #645770 fall back to CPHS
                    // FIXME should use SST to decide
                    // FIXME right now, only load line1's CPHS voice mail entry
                    recordsToLoad += 1;
                    new AdnRecordLoader(phone).loadFromEF(EF_MAILBOX_CPHS, EF_EXT1, 1, obtainMessage(EVENT_GET_CPHS_MAILBOX_DONE));
                    break;
                }
                voiceMailNum = adn.getNumber();
                voiceMailTag = adn.getAlphaTag();
                break;
            case EVENT_GET_MSISDN_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                if (ar.exception != null) {
                    Log.d(LOG_TAG, "Invalid or missing EF[MSISDN]");
                    break;
                }
                adn = (AdnRecord) ar.result;
                msisdn = adn.getNumber();
                msisdnTag = adn.getAlphaTag();
                Log.d(LOG_TAG, "MSISDN: " + /*msisdn*/
                "xxxxxxx");
                break;
            case EVENT_SET_MSISDN_DONE:
                isRecordLoadResponse = false;
                ar = (AsyncResult) msg.obj;
                if (ar.userObj != null) {
                    AsyncResult.forMessage(((Message) ar.userObj)).exception = ar.exception;
                    ((Message) ar.userObj).sendToTarget();
                }
                break;
            case EVENT_GET_MWIS_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                data = (byte[]) ar.result;
                if (ar.exception != null) {
                    break;
                }
                Log.d(LOG_TAG, "EF_MWIS: " + IccUtils.bytesToHexString(data));
                efMWIS = data;
                if ((data[0] & 0xff) == 0xff) {
                    Log.d(LOG_TAG, "SIMRecords: Uninitialized record MWIS");
                    break;
                }
                // Refer TS 51.011 Section 10.3.45 for the content description
                boolean voiceMailWaiting = ((data[0] & 0x01) != 0);
                countVoiceMessages = data[1] & 0xff;
                if (voiceMailWaiting && countVoiceMessages == 0) {
                    // Unknown count = -1
                    countVoiceMessages = -1;
                }
                phone.notifyMessageWaitingIndicator();
                break;
            case EVENT_GET_VOICE_MAIL_INDICATOR_CPHS_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                data = (byte[]) ar.result;
                if (ar.exception != null) {
                    break;
                }
                efCPHS_MWI = data;
                if (efMWIS == null) {
                    int indicator = (int) (data[0] & 0xf);
                    // Refer CPHS4_2.WW6 B4.2.3
                    if (indicator == 0xA) {
                        // Unknown count = -1
                        countVoiceMessages = -1;
                    } else if (indicator == 0x5) {
                        countVoiceMessages = 0;
                    }
                    phone.notifyMessageWaitingIndicator();
                }
                break;
            case EVENT_GET_ICCID_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                data = (byte[]) ar.result;
                if (ar.exception != null) {
                    break;
                }
                iccid = IccUtils.bcdToString(data, 0, data.length);
                Log.d(LOG_TAG, "iccid: " + iccid);
                break;
            case EVENT_GET_AD_DONE:
                try {
                    isRecordLoadResponse = true;
                    ar = (AsyncResult) msg.obj;
                    data = (byte[]) ar.result;
                    if (ar.exception != null) {
                        break;
                    }
                    Log.d(LOG_TAG, "EF_AD: " + IccUtils.bytesToHexString(data));
                    if (data.length < 3) {
                        Log.d(LOG_TAG, "SIMRecords: Corrupt AD data on SIM");
                        break;
                    }
                    if (data.length == 3) {
                        Log.d(LOG_TAG, "SIMRecords: MNC length not present in EF_AD");
                        break;
                    }
                    mncLength = (int) data[3] & 0xf;
                    if (mncLength == 0xf) {
                        mncLength = UNKNOWN;
                    }
                } finally {
                    if (((mncLength == UNINITIALIZED) || (mncLength == UNKNOWN) || (mncLength == 2)) && ((imsi != null) && (imsi.length() >= 6))) {
                        String mccmncCode = imsi.substring(0, 6);
                        for (String mccmnc : MCCMNC_CODES_HAVING_3DIGITS_MNC) {
                            if (mccmnc.equals(mccmncCode)) {
                                mncLength = 3;
                                break;
                            }
                        }
                    }
                    if (mncLength == UNKNOWN || mncLength == UNINITIALIZED) {
                        if (imsi != null) {
                            try {
                                int mcc = Integer.parseInt(imsi.substring(0, 3));
                                mncLength = MccTable.smallestDigitsMccForMnc(mcc);
                            } catch (NumberFormatException e) {
                                mncLength = UNKNOWN;
                                Log.e(LOG_TAG, "SIMRecords: Corrupt IMSI!");
                            }
                        } else {
                            // Indicate we got this info, but it didn't contain the length.
                            mncLength = UNKNOWN;
                            Log.d(LOG_TAG, "SIMRecords: MNC length not present in EF_AD");
                        }
                    }
                    if (imsi != null && mncLength != UNKNOWN) {
                        // finally have both imsi and the length of the mnc and can parse
                        // the imsi properly
                        MccTable.updateMccMncConfiguration(phone, imsi.substring(0, 3 + mncLength));
                    }
                }
                break;
            case EVENT_GET_SPN_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                getSpnFsm(false, ar);
                break;
            case EVENT_GET_CFF_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                data = (byte[]) ar.result;
                if (ar.exception != null) {
                    break;
                }
                Log.d(LOG_TAG, "EF_CFF_CPHS: " + IccUtils.bytesToHexString(data));
                mEfCff = data;
                if (mEfCfis == null) {
                    callForwardingEnabled = ((data[0] & CFF_LINE1_MASK) == CFF_UNCONDITIONAL_ACTIVE);
                    phone.notifyCallForwardingIndicator();
                }
                break;
            case EVENT_GET_SPDI_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                data = (byte[]) ar.result;
                if (ar.exception != null) {
                    break;
                }
                parseEfSpdi(data);
                break;
            case EVENT_UPDATE_DONE:
                ar = (AsyncResult) msg.obj;
                if (ar.exception != null) {
                    Log.i(LOG_TAG, "SIMRecords update failed", ar.exception);
                }
                break;
            case EVENT_GET_PNN_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                data = (byte[]) ar.result;
                if (ar.exception != null) {
                    break;
                }
                SimTlv tlv = new SimTlv(data, 0, data.length);
                for (; tlv.isValidObject(); tlv.nextObject()) {
                    if (tlv.getTag() == TAG_FULL_NETWORK_NAME) {
                        pnnHomeName = IccUtils.networkNameToString(tlv.getData(), 0, tlv.getData().length);
                        break;
                    }
                }
                break;
            case EVENT_GET_ALL_SMS_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                if (ar.exception != null)
                    break;
                handleSmses((ArrayList) ar.result);
                break;
            case EVENT_MARK_SMS_READ_DONE:
                Log.i("ENF", "marked read: sms " + msg.arg1);
                break;
            case EVENT_SMS_ON_SIM:
                isRecordLoadResponse = false;
                ar = (AsyncResult) msg.obj;
                int[] index = (int[]) ar.result;
                if (ar.exception != null || index.length != 1) {
                    Log.e(LOG_TAG, "[SIMRecords] Error on SMS_ON_SIM with exp " + ar.exception + " length " + index.length);
                } else {
                    Log.d(LOG_TAG, "READ EF_SMS RECORD index=" + index[0]);
                    phone.getIccFileHandler().loadEFLinearFixed(EF_SMS, index[0], obtainMessage(EVENT_GET_SMS_DONE));
                }
                break;
            case EVENT_GET_SMS_DONE:
                isRecordLoadResponse = false;
                ar = (AsyncResult) msg.obj;
                if (ar.exception == null) {
                    handleSms((byte[]) ar.result);
                } else {
                    Log.e(LOG_TAG, "[SIMRecords] Error on GET_SMS with exp " + ar.exception);
                }
                break;
            case EVENT_GET_SST_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                data = (byte[]) ar.result;
                if (ar.exception != null) {
                    break;
                }
                //Log.d(LOG_TAG, "SST: " + IccUtils.bytesToHexString(data));
                break;
            case EVENT_GET_INFO_CPHS_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                if (ar.exception != null) {
                    break;
                }
                mCphsInfo = (byte[]) ar.result;
                if (DBG)
                    log("iCPHS: " + IccUtils.bytesToHexString(mCphsInfo));
                break;
            case EVENT_SET_MBDN_DONE:
                isRecordLoadResponse = false;
                ar = (AsyncResult) msg.obj;
                if (ar.exception == null) {
                    voiceMailNum = newVoiceMailNum;
                    voiceMailTag = newVoiceMailTag;
                }
                if (isCphsMailboxEnabled()) {
                    adn = new AdnRecord(voiceMailTag, voiceMailNum);
                    Message onCphsCompleted = (Message) ar.userObj;
                    /* write to cphs mailbox whenever it is available but
                    * we only need notify caller once if both updating are
                    * successful.
                    *
                    * so if set_mbdn successful, notify caller here and set
                    * onCphsCompleted to null
                    */
                    if (ar.exception == null && ar.userObj != null) {
                        AsyncResult.forMessage(((Message) ar.userObj)).exception = null;
                        ((Message) ar.userObj).sendToTarget();
                        if (DBG)
                            log("Callback with MBDN successful.");
                        onCphsCompleted = null;
                    }
                    new AdnRecordLoader(phone).updateEF(adn, EF_MAILBOX_CPHS, EF_EXT1, 1, null, obtainMessage(EVENT_SET_CPHS_MAILBOX_DONE, onCphsCompleted));
                } else {
                    if (ar.userObj != null) {
                        AsyncResult.forMessage(((Message) ar.userObj)).exception = ar.exception;
                        ((Message) ar.userObj).sendToTarget();
                    }
                }
                break;
            case EVENT_SET_CPHS_MAILBOX_DONE:
                isRecordLoadResponse = false;
                ar = (AsyncResult) msg.obj;
                if (ar.exception == null) {
                    voiceMailNum = newVoiceMailNum;
                    voiceMailTag = newVoiceMailTag;
                } else {
                    if (DBG)
                        log("Set CPHS MailBox with exception: " + ar.exception);
                }
                if (ar.userObj != null) {
                    if (DBG)
                        log("Callback with CPHS MB successful.");
                    AsyncResult.forMessage(((Message) ar.userObj)).exception = ar.exception;
                    ((Message) ar.userObj).sendToTarget();
                }
                break;
            case EVENT_SIM_REFRESH:
                isRecordLoadResponse = false;
                ar = (AsyncResult) msg.obj;
                if (DBG)
                    log("Sim REFRESH with exception: " + ar.exception);
                if (ar.exception == null) {
                    handleSimRefresh((int[]) (ar.result));
                }
                break;
            case EVENT_GET_CFIS_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                data = (byte[]) ar.result;
                if (ar.exception != null) {
                    break;
                }
                Log.d(LOG_TAG, "EF_CFIS: " + IccUtils.bytesToHexString(data));
                mEfCfis = data;
                // Refer TS 51.011 Section 10.3.46 for the content description
                callForwardingEnabled = ((data[1] & 0x01) != 0);
                phone.notifyCallForwardingIndicator();
                break;
            case EVENT_GET_CSP_CPHS_DONE:
                isRecordLoadResponse = true;
                ar = (AsyncResult) msg.obj;
                if (ar.exception != null) {
                    Log.e(LOG_TAG, "Exception in fetching EF_CSP data " + ar.exception);
                    break;
                }
                data = (byte[]) ar.result;
                Log.i(LOG_TAG, "EF_CSP: " + IccUtils.bytesToHexString(data));
                handleEfCspData(data);
                break;
            default:
                // IccRecords handles generic record load responses
                super.handleMessage(msg);
        }
    } catch (RuntimeException exc) {
        // I don't want these exceptions to be fatal
        Log.w(LOG_TAG, "Exception parsing SIM record", exc);
    } finally {
        // Count up record load responses even if they are fails
        if (isRecordLoadResponse) {
            onRecordLoaded();
        }
    }
}
Also used : AdnRecord(com.android.internal.telephony.AdnRecord) Message(android.os.Message) AdnRecordLoader(com.android.internal.telephony.AdnRecordLoader) AsyncResult(android.os.AsyncResult)

Aggregations

AsyncResult (android.os.AsyncResult)170 Message (android.os.Message)20 Test (org.junit.Test)17 TelephonyTest (com.android.internal.telephony.TelephonyTest)15 Intent (android.content.Intent)14 FlakyTest (android.support.test.filters.FlakyTest)13 Registrant (android.os.Registrant)12 MediumTest (android.support.test.filters.MediumTest)9 ArrayList (java.util.ArrayList)8 SmallTest (android.test.suitebuilder.annotation.SmallTest)6 SmsMessage (android.telephony.SmsMessage)5 GsmCellLocation (android.telephony.gsm.GsmCellLocation)5 SmsHeader (com.android.internal.telephony.SmsHeader)5 MediumTest (android.test.suitebuilder.annotation.MediumTest)4 GsmMmiCode (com.android.internal.telephony.gsm.GsmMmiCode)4 SuppServiceNotification (com.android.internal.telephony.gsm.SuppServiceNotification)4 Ignore (org.junit.Ignore)4 CellInfo (android.telephony.CellInfo)3 Pair (android.util.Pair)3 CanceledException (android.app.PendingIntent.CanceledException)2