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;
}
}
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);
}
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;
}
}
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));
}
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();
}
Aggregations