Search in sources :

Example 66 with AsyncResult

use of android.os.AsyncResult in project android_frameworks_opt_telephony by LineageOS.

the class AdnRecordCache method handleMessage.

// ***** Overridden from Handler
@Override
public void handleMessage(Message msg) {
    AsyncResult ar;
    int efid;
    switch(msg.what) {
        case EVENT_LOAD_ALL_ADN_LIKE_DONE:
            /* arg1 is efid, obj.result is ArrayList<AdnRecord>*/
            ar = (AsyncResult) msg.obj;
            efid = msg.arg1;
            ArrayList<Message> waiters;
            waiters = mAdnLikeWaiters.get(efid);
            mAdnLikeWaiters.delete(efid);
            if (ar.exception == null) {
                mAdnLikeFiles.put(efid, (ArrayList<AdnRecord>) ar.result);
            }
            notifyWaiters(waiters, ar);
            break;
        case EVENT_UPDATE_ADN_DONE:
            ar = (AsyncResult) msg.obj;
            efid = msg.arg1;
            int index = msg.arg2;
            AdnRecord adn = (AdnRecord) (ar.userObj);
            if (ar.exception == null) {
                mAdnLikeFiles.get(efid).set(index - 1, adn);
                mUsimPhoneBookManager.invalidateCache();
            }
            Message response = mUserWriteResponse.get(efid);
            mUserWriteResponse.delete(efid);
            // so we should check if it is null.
            if (response != null) {
                AsyncResult.forMessage(response, null, ar.exception);
                response.sendToTarget();
            }
            break;
    }
}
Also used : Message(android.os.Message) AsyncResult(android.os.AsyncResult)

Example 67 with AsyncResult

use of android.os.AsyncResult in project android_frameworks_opt_telephony by LineageOS.

the class SipPhoneBase method stopRingbackTone.

@Override
public void stopRingbackTone() {
    AsyncResult result = new AsyncResult(null, Boolean.FALSE, null);
    mRingbackRegistrants.notifyRegistrants(result);
}
Also used : AsyncResult(android.os.AsyncResult)

Example 68 with AsyncResult

use of android.os.AsyncResult in project android_frameworks_opt_telephony by LineageOS.

the class AdnRecordLoader method handleMessage.

// ***** Overridden from Handler
@Override
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 || mRecordNumber > 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);
                }
                mFh.updateEFLinearFixed(mEf, getEFPath(mEf), mRecordNumber, data, mPin2, obtainMessage(EVENT_UPDATE_RECORD_DONE));
                mPendingExtLoads = 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);
                }
                mPendingExtLoads = 0;
                mResult = 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 (VDBG) {
                    Rlog.d(LOG_TAG, "ADN EF: 0x" + Integer.toHexString(mEf) + ":" + mRecordNumber + "\n" + IccUtils.bytesToHexString(data));
                }
                adn = new AdnRecord(mEf, mRecordNumber, data);
                mResult = 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
                    mPendingExtLoads = 1;
                    mFh.loadEFLinearFixed(mExtensionEF, adn.mExtRecord, 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) {
                    Rlog.d(LOG_TAG, "ADN extension EF: 0x" + Integer.toHexString(mExtensionEF) + ":" + adn.mExtRecord + "\n" + IccUtils.bytesToHexString(data));
                    adn.appendExtRecord(data);
                } else {
                    // If we can't get the rest of the number from EF_EXT1, rather than
                    // providing the partial number, we clear the number since it's not
                    // dialable anyway. Do not throw exception here otherwise the rest
                    // of the good records will be dropped.
                    Rlog.e(LOG_TAG, "Failed to read ext record. Clear the number now.");
                    adn.setNumber("");
                }
                mPendingExtLoads--;
                // 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);
                }
                mAdns = new ArrayList<AdnRecord>(datas.size());
                mResult = mAdns;
                mPendingExtLoads = 0;
                for (int i = 0, s = datas.size(); i < s; i++) {
                    adn = new AdnRecord(mEf, 1 + i, datas.get(i));
                    mAdns.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
                        mPendingExtLoads++;
                        mFh.loadEFLinearFixed(mExtensionEF, adn.mExtRecord, obtainMessage(EVENT_EXT_RECORD_LOAD_DONE, adn));
                    }
                }
                break;
        }
    } catch (RuntimeException exc) {
        if (mUserResponse != null) {
            AsyncResult.forMessage(mUserResponse).exception = exc;
            mUserResponse.sendToTarget();
            // Loading is all or nothing--either every load succeeds
            // or we fail the whole thing.
            mUserResponse = null;
        }
        return;
    }
    if (mUserResponse != null && mPendingExtLoads == 0) {
        AsyncResult.forMessage(mUserResponse).result = mResult;
        mUserResponse.sendToTarget();
        mUserResponse = null;
    }
}
Also used : ArrayList(java.util.ArrayList) AsyncResult(android.os.AsyncResult)

Example 69 with AsyncResult

use of android.os.AsyncResult in project android_frameworks_opt_telephony by LineageOS.

the class IsimUiccRecords method onAllRecordsLoaded.

@Override
protected void onAllRecordsLoaded() {
    if (DBG)
        log("record load complete");
    mLoaded.set(true);
    mRecordsLoadedRegistrants.notifyRegistrants(new AsyncResult(null, null, null));
}
Also used : AsyncResult(android.os.AsyncResult)

Example 70 with AsyncResult

use of android.os.AsyncResult in project android_frameworks_opt_telephony by LineageOS.

the class LocaleTrackerTest method sendServiceState.

private void sendServiceState(int state) {
    ServiceState ss = new ServiceState();
    ss.setState(state);
    AsyncResult ar = new AsyncResult(null, ss, null);
    mLocaleTracker.sendMessage(mLocaleTracker.obtainMessage(2, /*SERVICE_STATE_CHANGED*/
    ar));
    processAllMessages();
}
Also used : ServiceState(android.telephony.ServiceState) AsyncResult(android.os.AsyncResult)

Aggregations

AsyncResult (android.os.AsyncResult)267 Test (org.junit.Test)60 Message (android.os.Message)57 TelephonyTest (com.android.internal.telephony.TelephonyTest)45 SmallTest (android.test.suitebuilder.annotation.SmallTest)26 ArrayList (java.util.ArrayList)21 Registrant (android.os.Registrant)19 FlakyTest (androidx.test.filters.FlakyTest)17 Intent (android.content.Intent)13 CellInfo (android.telephony.CellInfo)12 MediumTest (android.test.suitebuilder.annotation.MediumTest)12 SmallTest (androidx.test.filters.SmallTest)11 NetworkRegistrationInfo (android.telephony.NetworkRegistrationInfo)9 List (java.util.List)7 Mockito.anyString (org.mockito.Mockito.anyString)6 InvocationOnMock (org.mockito.invocation.InvocationOnMock)6 FlakyTest (android.support.test.filters.FlakyTest)5 MediumTest (android.support.test.filters.MediumTest)5 LteVopsSupportInfo (android.telephony.LteVopsSupportInfo)5 SmsMessage (android.telephony.SmsMessage)5