use of android.os.AsyncResult in project XobotOS by xamarin.
the class RuimRecords method handleMessage.
@Override
public void handleMessage(Message msg) {
AsyncResult ar;
byte[] data;
boolean isRecordLoadResponse = false;
try {
switch(msg.what) {
case EVENT_RUIM_READY:
onRuimReady();
break;
case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:
onRadioOffOrNotAvailable();
break;
case EVENT_GET_DEVICE_IDENTITY_DONE:
Log.d(LOG_TAG, "Event EVENT_GET_DEVICE_IDENTITY_DONE Received");
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;
}
mImsi = (String) ar.result;
// than 15 (and usually 15).
if (mImsi != null && (mImsi.length() < 6 || mImsi.length() > 15)) {
Log.e(LOG_TAG, "invalid IMSI " + mImsi);
mImsi = null;
}
Log.d(LOG_TAG, "IMSI: " + mImsi.substring(0, 6) + "xxxxxxxxx");
String operatorNumeric = getRUIMOperatorNumeric();
if (operatorNumeric != null) {
if (operatorNumeric.length() <= 6) {
MccTable.updateMccMncConfiguration(phone, operatorNumeric);
}
}
break;
case EVENT_GET_CDMA_SUBSCRIPTION_DONE:
ar = (AsyncResult) msg.obj;
String[] localTemp = (String[]) ar.result;
if (ar.exception != null) {
break;
}
mMyMobileNumber = localTemp[0];
mMin2Min1 = localTemp[3];
mPrlVersion = localTemp[4];
Log.d(LOG_TAG, "MDN: " + mMyMobileNumber + " MIN: " + mMin2Min1);
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_UPDATE_DONE:
ar = (AsyncResult) msg.obj;
if (ar.exception != null) {
Log.i(LOG_TAG, "RuimRecords update failed", ar.exception);
}
break;
case EVENT_GET_ALL_SMS_DONE:
case EVENT_MARK_SMS_READ_DONE:
case EVENT_SMS_ON_RUIM:
case EVENT_GET_SMS_DONE:
Log.w(LOG_TAG, "Event not supported: " + msg.what);
break;
// TODO: probably EF_CST should be read instead
case EVENT_GET_SST_DONE:
Log.d(LOG_TAG, "Event EVENT_GET_SST_DONE Received");
break;
case EVENT_RUIM_REFRESH:
isRecordLoadResponse = false;
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
handleRuimRefresh((int[]) (ar.result));
}
break;
}
} catch (RuntimeException exc) {
// I don't want these exceptions to be fatal
Log.w(LOG_TAG, "Exception parsing RUIM record", exc);
} finally {
// Count up record load responses even if they are fails
if (isRecordLoadResponse) {
onRecordLoaded();
}
}
}
use of android.os.AsyncResult in project XobotOS by xamarin.
the class CdmaServiceStateTracker method handleMessage.
@Override
public void handleMessage(Message msg) {
AsyncResult ar;
int[] ints;
String[] strings;
switch(msg.what) {
case EVENT_RADIO_AVAILABLE:
if (DBG)
log("handleMessage: EVENT_RADIO_AVAILABLE");
break;
case EVENT_RUIM_READY:
// The RUIM is now ready i.e if it was locked it has been
// unlocked. At this stage, the radio is already powered on.
isSubscriptionFromRuim = true;
if (mNeedToRegForRuimLoaded) {
phone.mIccRecords.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null);
mNeedToRegForRuimLoaded = false;
}
cm.getCDMASubscription(obtainMessage(EVENT_POLL_STATE_CDMA_SUBSCRIPTION));
if (DBG)
log("handleMessage: EVENT_RUIM_READY, Send Request getCDMASubscription.");
// Restore the previous network selection.
pollState();
// Signal strength polling stops when radio is off.
queueNextSignalStrengthPoll();
break;
case EVENT_NV_READY:
isSubscriptionFromRuim = false;
// subscription info.
if (DBG)
log("handleMessage: EVENT_NV_READY, Send Request getCDMASubscription.");
cm.getCDMASubscription(obtainMessage(EVENT_POLL_STATE_CDMA_SUBSCRIPTION));
pollState();
// Signal strength polling stops when radio is off.
queueNextSignalStrengthPoll();
break;
case EVENT_RADIO_STATE_CHANGED:
// This will do nothing in the 'radio not available' case.
setPowerStateToDesired();
pollState();
break;
case EVENT_NETWORK_STATE_CHANGED_CDMA:
pollState();
break;
case EVENT_GET_SIGNAL_STRENGTH:
if (!(cm.getRadioState().isOn()) || (cm.getRadioState().isGsm())) {
// Polling will continue when radio turns back on.
return;
}
ar = (AsyncResult) msg.obj;
onSignalStrengthResult(ar);
queueNextSignalStrengthPoll();
break;
case EVENT_GET_LOC_DONE_CDMA:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
String[] states = (String[]) ar.result;
int baseStationId = -1;
int baseStationLatitude = CdmaCellLocation.INVALID_LAT_LONG;
int baseStationLongitude = CdmaCellLocation.INVALID_LAT_LONG;
int systemId = -1;
int networkId = -1;
if (states.length > 9) {
try {
if (states[4] != null) {
baseStationId = Integer.parseInt(states[4]);
}
if (states[5] != null) {
baseStationLatitude = Integer.parseInt(states[5]);
}
if (states[6] != null) {
baseStationLongitude = Integer.parseInt(states[6]);
}
// Some carriers only return lat-lngs of 0,0
if (baseStationLatitude == 0 && baseStationLongitude == 0) {
baseStationLatitude = CdmaCellLocation.INVALID_LAT_LONG;
baseStationLongitude = CdmaCellLocation.INVALID_LAT_LONG;
}
if (states[8] != null) {
systemId = Integer.parseInt(states[8]);
}
if (states[9] != null) {
networkId = Integer.parseInt(states[9]);
}
} catch (NumberFormatException ex) {
loge("error parsing cell location data: " + ex);
}
}
cellLoc.setCellLocationData(baseStationId, baseStationLatitude, baseStationLongitude, systemId, networkId);
phone.notifyLocationChanged();
}
// Release any temporary cell lock, which could have been
// acquired to allow a single-shot location update.
disableSingleLocationUpdate();
break;
case EVENT_POLL_STATE_REGISTRATION_CDMA:
case EVENT_POLL_STATE_OPERATOR_CDMA:
ar = (AsyncResult) msg.obj;
handlePollStateResult(msg.what, ar);
break;
case // Handle RIL_CDMA_SUBSCRIPTION
EVENT_POLL_STATE_CDMA_SUBSCRIPTION:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
String[] cdmaSubscription = (String[]) ar.result;
if (cdmaSubscription != null && cdmaSubscription.length >= 5) {
mMdn = cdmaSubscription[0];
parseSidNid(cdmaSubscription[1], cdmaSubscription[2]);
mMin = cdmaSubscription[3];
mPrlVersion = cdmaSubscription[4];
if (DBG)
log("GET_CDMA_SUBSCRIPTION: MDN=" + mMdn);
mIsMinInfoReady = true;
updateOtaspState();
phone.getIccCard().broadcastIccStateChangedIntent(IccCard.INTENT_VALUE_ICC_IMSI, null);
} else {
if (DBG) {
log("GET_CDMA_SUBSCRIPTION: error parsing cdmaSubscription params num=" + cdmaSubscription.length);
}
}
}
break;
case EVENT_POLL_SIGNAL_STRENGTH:
// Just poll signal strength...not part of pollState()
cm.getSignalStrength(obtainMessage(EVENT_GET_SIGNAL_STRENGTH));
break;
case EVENT_NITZ_TIME:
ar = (AsyncResult) msg.obj;
String nitzString = (String) ((Object[]) ar.result)[0];
long nitzReceiveTime = ((Long) ((Object[]) ar.result)[1]).longValue();
setTimeFromNITZString(nitzString, nitzReceiveTime);
break;
case EVENT_SIGNAL_STRENGTH_UPDATE:
// This is a notification from CommandsInterface.setOnSignalStrengthUpdate.
ar = (AsyncResult) msg.obj;
// The radio is telling us about signal strength changes,
// so we don't have to ask it.
dontPollSignalStrength = true;
onSignalStrengthResult(ar);
break;
case EVENT_RUIM_RECORDS_LOADED:
updateSpnDisplay();
break;
case EVENT_LOCATION_UPDATES_ENABLED:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
cm.getVoiceRegistrationState(obtainMessage(EVENT_GET_LOC_DONE_CDMA, null));
}
break;
case EVENT_ERI_FILE_LOADED:
// Repoll the state once the ERI file has been loaded.
if (DBG)
log("[CdmaServiceStateTracker] ERI file has been loaded, repolling.");
pollState();
break;
case EVENT_OTA_PROVISION_STATUS_CHANGE:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
ints = (int[]) ar.result;
int otaStatus = ints[0];
if (otaStatus == Phone.CDMA_OTA_PROVISION_STATUS_COMMITTED || otaStatus == Phone.CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED) {
if (DBG)
log("EVENT_OTA_PROVISION_STATUS_CHANGE: Complete, Reload MDN");
cm.getCDMASubscription(obtainMessage(EVENT_POLL_STATE_CDMA_SUBSCRIPTION));
}
}
break;
default:
super.handleMessage(msg);
break;
}
}
use of android.os.AsyncResult in project XobotOS by xamarin.
the class UsimPhoneBookManager method handleMessage.
@Override
public void handleMessage(Message msg) {
AsyncResult ar;
switch(msg.what) {
case EVENT_PBR_LOAD_DONE:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
createPbrFile((ArrayList<byte[]>) ar.result);
}
synchronized (mLock) {
mLock.notify();
}
break;
case EVENT_USIM_ADN_LOAD_DONE:
log("Loading USIM ADN records done");
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
mPhoneBookRecords.addAll((ArrayList<AdnRecord>) ar.result);
}
synchronized (mLock) {
mLock.notify();
}
break;
case EVENT_IAP_LOAD_DONE:
log("Loading USIM IAP records done");
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
mIapFileRecord = ((ArrayList<byte[]>) ar.result);
}
synchronized (mLock) {
mLock.notify();
}
break;
case EVENT_EMAIL_LOAD_DONE:
log("Loading USIM Email records done");
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
mEmailFileRecord = ((ArrayList<byte[]>) ar.result);
}
synchronized (mLock) {
mLock.notify();
}
break;
}
}
use of android.os.AsyncResult in project XobotOS by xamarin.
the class SipPhoneBase method stopRingbackTone.
protected void stopRingbackTone() {
AsyncResult result = new AsyncResult(null, Boolean.FALSE, null);
mRingbackRegistrants.notifyRegistrants(result);
}
use of android.os.AsyncResult in project XobotOS by xamarin.
the class SimulatedCommands method triggerSsn.
public void triggerSsn(int type, int code) {
SuppServiceNotification not = new SuppServiceNotification();
not.notificationType = type;
not.code = code;
mSsnRegistrant.notifyRegistrant(new AsyncResult(null, not, null));
}
Aggregations