use of com.android.internal.telephony.gsm.GsmDataConnectionTracker in project XobotOS by xamarin.
the class CdmaLteServiceStateTracker method pollStateDone.
@Override
protected void pollStateDone() {
// determine data NetworkType from both LET and CDMA SS
if (mLteSS.getState() == ServiceState.STATE_IN_SERVICE) {
//in LTE service
newNetworkType = mLteSS.getRadioTechnology();
mNewDataConnectionState = mLteSS.getState();
newSS.setRadioTechnology(newNetworkType);
log("pollStateDone LTE/eHRPD STATE_IN_SERVICE newNetworkType = " + newNetworkType);
} else {
// LTE out of service, get CDMA Service State
newNetworkType = newSS.getRadioTechnology();
mNewDataConnectionState = radioTechnologyToDataServiceState(newNetworkType);
log("pollStateDone CDMA STATE_IN_SERVICE newNetworkType = " + newNetworkType + " mNewDataConnectionState = " + mNewDataConnectionState);
}
// databases/settings.db "update secure set value='11' where name='preferred_network_mode'"
if (newSS.getState() == ServiceState.STATE_OUT_OF_SERVICE) {
int networkMode = android.provider.Settings.Secure.getInt(phone.getContext().getContentResolver(), android.provider.Settings.Secure.PREFERRED_NETWORK_MODE, RILConstants.PREFERRED_NETWORK_MODE);
if (networkMode == RILConstants.NETWORK_MODE_LTE_ONLY) {
if (DBG)
log("pollState: LTE Only mode");
newSS.setState(mLteSS.getState());
}
}
if (DBG)
log("pollStateDone: oldSS=[" + ss + "] newSS=[" + newSS + "]");
boolean hasRegistered = ss.getState() != ServiceState.STATE_IN_SERVICE && newSS.getState() == ServiceState.STATE_IN_SERVICE;
boolean hasDeregistered = ss.getState() == ServiceState.STATE_IN_SERVICE && newSS.getState() != ServiceState.STATE_IN_SERVICE;
boolean hasCdmaDataConnectionAttached = mDataConnectionState != ServiceState.STATE_IN_SERVICE && mNewDataConnectionState == ServiceState.STATE_IN_SERVICE;
boolean hasCdmaDataConnectionDetached = mDataConnectionState == ServiceState.STATE_IN_SERVICE && mNewDataConnectionState != ServiceState.STATE_IN_SERVICE;
boolean hasCdmaDataConnectionChanged = mDataConnectionState != mNewDataConnectionState;
boolean hasNetworkTypeChanged = networkType != newNetworkType;
boolean hasChanged = !newSS.equals(ss);
boolean hasRoamingOn = !ss.getRoaming() && newSS.getRoaming();
boolean hasRoamingOff = ss.getRoaming() && !newSS.getRoaming();
boolean hasLocationChanged = !newCellLoc.equals(cellLoc);
boolean has4gHandoff = mNewDataConnectionState == ServiceState.STATE_IN_SERVICE && (((networkType == ServiceState.RADIO_TECHNOLOGY_LTE) && (newNetworkType == ServiceState.RADIO_TECHNOLOGY_EHRPD)) || ((networkType == ServiceState.RADIO_TECHNOLOGY_EHRPD) && (newNetworkType == ServiceState.RADIO_TECHNOLOGY_LTE)));
boolean hasMultiApnSupport = (((newNetworkType == ServiceState.RADIO_TECHNOLOGY_LTE) || (newNetworkType == ServiceState.RADIO_TECHNOLOGY_EHRPD)) && ((networkType != ServiceState.RADIO_TECHNOLOGY_LTE) && (networkType != ServiceState.RADIO_TECHNOLOGY_EHRPD)));
boolean hasLostMultiApnSupport = ((newNetworkType >= ServiceState.RADIO_TECHNOLOGY_IS95A) && (newNetworkType <= ServiceState.RADIO_TECHNOLOGY_EVDO_A));
if (DBG) {
log("pollStateDone:" + " hasRegistered=" + hasRegistered + " hasDeegistered=" + hasDeregistered + " hasCdmaDataConnectionAttached=" + hasCdmaDataConnectionAttached + " hasCdmaDataConnectionDetached=" + hasCdmaDataConnectionDetached + " hasCdmaDataConnectionChanged=" + hasCdmaDataConnectionChanged + " hasNetworkTypeChanged = " + hasNetworkTypeChanged + " hasChanged=" + hasChanged + " hasRoamingOn=" + hasRoamingOn + " hasRoamingOff=" + hasRoamingOff + " hasLocationChanged=" + hasLocationChanged + " has4gHandoff = " + has4gHandoff + " hasMultiApnSupport=" + hasMultiApnSupport + " hasLostMultiApnSupport=" + hasLostMultiApnSupport);
}
// Add an event log when connection state changes
if (ss.getState() != newSS.getState() || mDataConnectionState != mNewDataConnectionState) {
EventLog.writeEvent(EventLogTags.CDMA_SERVICE_STATE_CHANGE, ss.getState(), mDataConnectionState, newSS.getState(), mNewDataConnectionState);
}
ServiceState tss;
tss = ss;
ss = newSS;
newSS = tss;
// clean slate for next time
newSS.setStateOutOfService();
mLteSS.setStateOutOfService();
if ((hasMultiApnSupport) && (phone.mDataConnectionTracker instanceof CdmaDataConnectionTracker)) {
if (DBG)
log("GsmDataConnectionTracker Created");
phone.mDataConnectionTracker.dispose();
phone.mDataConnectionTracker = new GsmDataConnectionTracker(mCdmaLtePhone);
}
if ((hasLostMultiApnSupport) && (phone.mDataConnectionTracker instanceof GsmDataConnectionTracker)) {
if (DBG)
log("GsmDataConnectionTracker disposed");
phone.mDataConnectionTracker.dispose();
phone.mDataConnectionTracker = new CdmaDataConnectionTracker(phone);
}
CdmaCellLocation tcl = cellLoc;
cellLoc = newCellLoc;
newCellLoc = tcl;
mDataConnectionState = mNewDataConnectionState;
networkType = newNetworkType;
// clean slate for next time
newSS.setStateOutOfService();
if (hasNetworkTypeChanged) {
phone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, ServiceState.radioTechnologyToString(networkType));
}
if (hasRegistered) {
mNetworkAttachedRegistrants.notifyRegistrants();
}
if (hasChanged) {
if (phone.isEriFileLoaded()) {
String eriText;
// new ERI text
if (ss.getState() == ServiceState.STATE_IN_SERVICE) {
eriText = phone.getCdmaEriText();
} else {
// Note that ServiceState.STATE_OUT_OF_SERVICE is valid used
// for
// mRegistrationState 0,2,3 and 4
eriText = phone.getContext().getText(com.android.internal.R.string.roamingTextSearching).toString();
}
ss.setOperatorAlphaLong(eriText);
}
if (cm.getSimState().isSIMReady()) {
// SIM is found on the device. If ERI roaming is OFF and SID/NID matches
// one configfured in SIM, use operator name from CSIM record.
boolean showSpn = ((CdmaLteUiccRecords) phone.mIccRecords).getCsimSpnDisplayCondition();
int iconIndex = ss.getCdmaEriIconIndex();
if (showSpn && (iconIndex == EriInfo.ROAMING_INDICATOR_OFF) && isInHomeSidNid(ss.getSystemId(), ss.getNetworkId())) {
ss.setOperatorAlphaLong(phone.mIccRecords.getServiceProviderName());
}
}
String operatorNumeric;
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ALPHA, ss.getOperatorAlphaLong());
operatorNumeric = ss.getOperatorNumeric();
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, operatorNumeric);
if (operatorNumeric == null) {
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, "");
mGotCountryCode = false;
} else {
String isoCountryCode = "";
try {
isoCountryCode = MccTable.countryCodeForMcc(Integer.parseInt(operatorNumeric.substring(0, 3)));
} catch (NumberFormatException ex) {
loge("countryCodeForMcc error" + ex);
} catch (StringIndexOutOfBoundsException ex) {
loge("countryCodeForMcc error" + ex);
}
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, isoCountryCode);
mGotCountryCode = true;
if (mNeedFixZone) {
fixTimeZone(isoCountryCode);
}
}
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, ss.getRoaming() ? "true" : "false");
updateSpnDisplay();
phone.notifyServiceStateChanged(ss);
}
if (hasCdmaDataConnectionAttached || has4gHandoff) {
mAttachedRegistrants.notifyRegistrants();
}
if (hasCdmaDataConnectionDetached) {
mDetachedRegistrants.notifyRegistrants();
}
if ((hasCdmaDataConnectionChanged || hasNetworkTypeChanged)) {
phone.notifyDataConnection(null);
}
if (hasRoamingOn) {
mRoamingOnRegistrants.notifyRegistrants();
}
if (hasRoamingOff) {
mRoamingOffRegistrants.notifyRegistrants();
}
if (hasLocationChanged) {
phone.notifyLocationChanged();
}
}
Aggregations