use of com.android.internal.telephony.gsm.GsmMmiCode in project android_frameworks_opt_telephony by LineageOS.
the class GsmCdmaPhone method dialInternal.
protected Connection dialInternal(String dialString, UUSInfo uusInfo, int videoState, Bundle intentExtras, ResultReceiver wrappedCallback) throws CallStateException {
// Need to make sure dialString gets parsed properly
String newDialString = PhoneNumberUtils.stripSeparators(dialString);
if (isPhoneTypeGsm()) {
// handle in-call MMI first if applicable
if (handleInCallMmiCommands(newDialString)) {
return null;
}
// Only look at the Network portion for mmi
String networkPortion = PhoneNumberUtils.extractNetworkPortionAlt(newDialString);
GsmMmiCode mmi = GsmMmiCode.newFromDialString(networkPortion, this, mUiccApplication.get(), wrappedCallback);
if (DBG)
logd("dialInternal: dialing w/ mmi '" + mmi + "'...");
if (mmi == null) {
return mCT.dial(newDialString, uusInfo, intentExtras);
} else if (mmi.isTemporaryModeCLIR()) {
return mCT.dial(mmi.mDialingNumber, mmi.getCLIRMode(), uusInfo, intentExtras);
} else {
mPendingMMIs.add(mmi);
mMmiRegistrants.notifyRegistrants(new AsyncResult(null, mmi, null));
mmi.processCode();
return null;
}
} else {
return mCT.dial(newDialString);
}
}
use of com.android.internal.telephony.gsm.GsmMmiCode in project android_frameworks_opt_telephony by LineageOS.
the class GsmCdmaPhone method onIncomingUSSD.
/**
* ussdMode is one of CommandsInterface.USSD_MODE_*
*/
private void onIncomingUSSD(int ussdMode, String ussdMessage) {
if (!isPhoneTypeGsm()) {
loge("onIncomingUSSD: not expected on GSM");
}
boolean isUssdError;
boolean isUssdRequest;
boolean isUssdRelease;
isUssdRequest = (ussdMode == CommandsInterface.USSD_MODE_REQUEST);
isUssdError = (ussdMode != CommandsInterface.USSD_MODE_NOTIFY && ussdMode != CommandsInterface.USSD_MODE_REQUEST);
isUssdRelease = (ussdMode == CommandsInterface.USSD_MODE_NW_RELEASE);
// See comments in GsmMmiCode.java
// USSD requests aren't finished until one
// of these two events happen
GsmMmiCode found = null;
for (int i = 0, s = mPendingMMIs.size(); i < s; i++) {
if (((GsmMmiCode) mPendingMMIs.get(i)).isPendingUSSD()) {
found = (GsmMmiCode) mPendingMMIs.get(i);
break;
}
}
if (found != null) {
if (isUssdRelease) {
found.onUssdRelease();
} else if (isUssdError) {
found.onUssdFinishedError();
} else {
found.onUssdFinished(ussdMessage, isUssdRequest);
}
} else if (!isUssdError && ussdMessage != null) {
// pending USSD not found
// The network may initiate its own USSD request
// ignore everything that isnt a Notify or a Request
// also, discard if there is no message to present
GsmMmiCode mmi;
mmi = GsmMmiCode.newNetworkInitiatedUssd(ussdMessage, isUssdRequest, GsmCdmaPhone.this, mUiccApplication.get());
onNetworkInitiatedUssd(mmi);
}
}
use of com.android.internal.telephony.gsm.GsmMmiCode in project android_frameworks_opt_telephony by LineageOS.
the class GsmCdmaPhone method sendUssdResponse.
@Override
public void sendUssdResponse(String ussdMessge) {
if (isPhoneTypeGsm()) {
GsmMmiCode mmi = GsmMmiCode.newFromUssdUserInput(ussdMessge, this, mUiccApplication.get());
mPendingMMIs.add(mmi);
mMmiRegistrants.notifyRegistrants(new AsyncResult(null, mmi, null));
mmi.sendUssd(ussdMessge);
} else {
loge("sendUssdResponse: not possible in CDMA");
}
}
use of com.android.internal.telephony.gsm.GsmMmiCode in project android_frameworks_opt_telephony by LineageOS.
the class GsmCdmaPhone method handleMessage.
@Override
public void handleMessage(Message msg) {
AsyncResult ar;
Message onComplete;
switch(msg.what) {
case EVENT_RADIO_AVAILABLE:
{
handleRadioAvailable();
}
break;
case EVENT_GET_DEVICE_IDENTITY_DONE:
{
ar = (AsyncResult) msg.obj;
if (ar.exception != null) {
break;
}
String[] respId = (String[]) ar.result;
mImei = respId[0];
mImeiSv = respId[1];
mEsn = respId[2];
mMeid = respId[3];
}
break;
case EVENT_EMERGENCY_CALLBACK_MODE_ENTER:
{
handleEnterEmergencyCallbackMode(msg);
}
break;
case EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE:
{
handleExitEmergencyCallbackMode(msg);
}
break;
case EVENT_MODEM_RESET:
{
logd("Event EVENT_MODEM_RESET Received" + " isInEcm = " + isInEcm() + " isPhoneTypeGsm = " + isPhoneTypeGsm() + " mImsPhone = " + mImsPhone);
if (isInEcm()) {
if (isPhoneTypeGsm()) {
if (mImsPhone != null) {
mImsPhone.handleExitEmergencyCallbackMode();
}
} else {
handleExitEmergencyCallbackMode(msg);
}
}
}
break;
case EVENT_RUIM_RECORDS_LOADED:
logd("Event EVENT_RUIM_RECORDS_LOADED Received");
updateCurrentCarrierInProvider();
break;
case EVENT_RADIO_ON:
logd("Event EVENT_RADIO_ON Received");
handleRadioOn();
break;
case EVENT_RIL_CONNECTED:
ar = (AsyncResult) msg.obj;
if (ar.exception == null && ar.result != null) {
mRilVersion = (Integer) ar.result;
} else {
logd("Unexpected exception on EVENT_RIL_CONNECTED");
mRilVersion = -1;
}
break;
case EVENT_VOICE_RADIO_TECH_CHANGED:
case EVENT_REQUEST_VOICE_RADIO_TECH_DONE:
String what = (msg.what == EVENT_VOICE_RADIO_TECH_CHANGED) ? "EVENT_VOICE_RADIO_TECH_CHANGED" : "EVENT_REQUEST_VOICE_RADIO_TECH_DONE";
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
if ((ar.result != null) && (((int[]) ar.result).length != 0)) {
int newVoiceTech = ((int[]) ar.result)[0];
logd(what + ": newVoiceTech=" + newVoiceTech);
phoneObjectUpdater(newVoiceTech);
} else {
loge(what + ": has no tech!");
}
} else {
loge(what + ": exception=" + ar.exception);
}
break;
case EVENT_UPDATE_PHONE_OBJECT:
phoneObjectUpdater(msg.arg1);
break;
case EVENT_CARRIER_CONFIG_CHANGED:
// registration changes.
if (!mContext.getResources().getBoolean(com.android.internal.R.bool.config_switch_phone_on_voice_reg_state_change)) {
mCi.getVoiceRadioTechnology(obtainMessage(EVENT_REQUEST_VOICE_RADIO_TECH_DONE));
}
// Force update IMS service
ImsManager.getInstance(mContext, mPhoneId).updateImsServiceConfigForSlot(true);
// Update broadcastEmergencyCallStateChanges
CarrierConfigManager configMgr = (CarrierConfigManager) getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
PersistableBundle b = configMgr.getConfigForSubId(getSubId());
if (b != null) {
boolean broadcastEmergencyCallStateChanges = b.getBoolean(CarrierConfigManager.KEY_BROADCAST_EMERGENCY_CALL_STATE_CHANGES_BOOL);
logd("broadcastEmergencyCallStateChanges = " + broadcastEmergencyCallStateChanges);
setBroadcastEmergencyCallStateChanges(broadcastEmergencyCallStateChanges);
} else {
loge("didn't get broadcastEmergencyCallStateChanges from carrier config");
}
// Changing the cdma roaming settings based carrier config.
if (b != null) {
int config_cdma_roaming_mode = b.getInt(CarrierConfigManager.KEY_CDMA_ROAMING_MODE_INT);
int current_cdma_roaming_mode = Settings.Global.getInt(getContext().getContentResolver(), Settings.Global.CDMA_ROAMING_MODE, CarrierConfigManager.CDMA_ROAMING_MODE_RADIO_DEFAULT);
switch(config_cdma_roaming_mode) {
// when carrier's setting is turn off.
case CarrierConfigManager.CDMA_ROAMING_MODE_HOME:
case CarrierConfigManager.CDMA_ROAMING_MODE_AFFILIATED:
case CarrierConfigManager.CDMA_ROAMING_MODE_ANY:
logd("cdma_roaming_mode is going to changed to " + config_cdma_roaming_mode);
setCdmaRoamingPreference(config_cdma_roaming_mode, obtainMessage(EVENT_SET_ROAMING_PREFERENCE_DONE));
break;
// previous user's setting
case CarrierConfigManager.CDMA_ROAMING_MODE_RADIO_DEFAULT:
if (current_cdma_roaming_mode != config_cdma_roaming_mode) {
logd("cdma_roaming_mode is going to changed to " + current_cdma_roaming_mode);
setCdmaRoamingPreference(current_cdma_roaming_mode, obtainMessage(EVENT_SET_ROAMING_PREFERENCE_DONE));
}
default:
loge("Invalid cdma_roaming_mode settings: " + config_cdma_roaming_mode);
}
} else {
loge("didn't get the cdma_roaming_mode changes from the carrier config.");
}
// Load the ERI based on carrier config. Carrier might have their specific ERI.
prepareEri();
if (!isPhoneTypeGsm()) {
mSST.pollState();
}
break;
case EVENT_SET_ROAMING_PREFERENCE_DONE:
logd("cdma_roaming_mode change is done");
break;
case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
logd("EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED");
mCdmaSubscriptionSource = mCdmaSSM.getCdmaSubscriptionSource();
break;
case EVENT_REGISTERED_TO_NETWORK:
logd("Event EVENT_REGISTERED_TO_NETWORK Received");
if (isPhoneTypeGsm()) {
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 ((!isPhoneTypeGsm() || imsi != null) && imsiFromSIM != null && !imsiFromSIM.equals(imsi)) {
storeVoiceMailNumber(null);
setVmSimImsi(null);
}
mSimRecordsLoadedRegistrants.notifyRegistrants();
break;
case EVENT_GET_BASEBAND_VERSION_DONE:
ar = (AsyncResult) msg.obj;
if (ar.exception != null) {
break;
}
if (DBG)
logd("Baseband version: " + ar.result);
TelephonyManager.from(mContext).setBasebandVersionForPhone(getPhoneId(), (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) {
Rlog.w(LOG_TAG, "error parsing USSD");
}
}
break;
case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:
{
logd("Event EVENT_RADIO_OFF_OR_NOT_AVAILABLE Received");
handleRadioOffOrNotAvailable();
break;
}
case EVENT_SSN:
logd("Event EVENT_SSN Received");
if (isPhoneTypeGsm()) {
ar = (AsyncResult) msg.obj;
SuppServiceNotification not = (SuppServiceNotification) ar.result;
mSsnRegistrants.notifyRegistrants(ar);
}
break;
case EVENT_SET_CALL_FORWARD_DONE:
ar = (AsyncResult) msg.obj;
IccRecords r = mIccRecords.get();
Cfu cfu = (Cfu) ar.userObj;
if (ar.exception == null && r != null) {
setVoiceCallForwardingFlag(1, msg.arg1 == 1, cfu.mSetCfNumber);
}
if (cfu.mOnComplete != null) {
AsyncResult.forMessage(cfu.mOnComplete, ar.result, ar.exception);
cfu.mOnComplete.sendToTarget();
}
break;
case EVENT_SET_VM_NUMBER_DONE:
ar = (AsyncResult) msg.obj;
if ((isPhoneTypeGsm() && IccVmNotSupportedException.class.isInstance(ar.exception)) || (!isPhoneTypeGsm() && IccException.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;
case EVENT_SET_NETWORK_AUTOMATIC:
// Automatic network selection from EF_CSP SIM record
ar = (AsyncResult) msg.obj;
if (mSST.mSS.getIsManualSelection()) {
setNetworkSelectionModeAutomatic((Message) ar.result);
logd("SET_NETWORK_SELECTION_AUTOMATIC: set to automatic");
} else {
// prevent duplicate request which will push current PLMN to low priority
logd("SET_NETWORK_SELECTION_AUTOMATIC: already automatic, ignore");
}
break;
case EVENT_ICC_RECORD_EVENTS:
ar = (AsyncResult) msg.obj;
processIccRecordEvents((Integer) ar.result);
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;
case EVENT_SS:
ar = (AsyncResult) msg.obj;
logd("Event EVENT_SS received");
if (isPhoneTypeGsm()) {
// SS data is already being handled through MMI codes.
// So, this result if processed as MMI response would help
// in re-using the existing functionality.
GsmMmiCode mmi = new GsmMmiCode(this, mUiccApplication.get());
mmi.processSsData(ar);
}
break;
case EVENT_GET_RADIO_CAPABILITY:
ar = (AsyncResult) msg.obj;
RadioCapability rc = (RadioCapability) ar.result;
if (ar.exception != null) {
Rlog.d(LOG_TAG, "get phone radio capability fail, no need to change " + "mRadioCapability");
} else {
radioCapabilityUpdated(rc);
}
Rlog.d(LOG_TAG, "EVENT_GET_RADIO_CAPABILITY: phone rc: " + rc);
break;
default:
super.handleMessage(msg);
}
}
Aggregations