Search in sources :

Example 6 with ServiceState

use of android.telephony.ServiceState in project XobotOS by xamarin.

the class DefaultPhoneNotifier method doNotifyDataConnection.

private void doNotifyDataConnection(Phone sender, String reason, String apnType, Phone.DataState state) {
    // TODO
    // use apnType as the key to which connection we're talking about.
    // pass apnType back up to fetch particular for this one.
    TelephonyManager telephony = TelephonyManager.getDefault();
    LinkProperties linkProperties = null;
    LinkCapabilities linkCapabilities = null;
    boolean roaming = false;
    if (state == Phone.DataState.CONNECTED) {
        linkProperties = sender.getLinkProperties(apnType);
        linkCapabilities = sender.getLinkCapabilities(apnType);
    }
    ServiceState ss = sender.getServiceState();
    if (ss != null)
        roaming = ss.getRoaming();
    try {
        mRegistry.notifyDataConnection(convertDataState(state), sender.isDataConnectivityPossible(apnType), reason, sender.getActiveApnHost(apnType), apnType, linkProperties, linkCapabilities, ((telephony != null) ? telephony.getNetworkType() : TelephonyManager.NETWORK_TYPE_UNKNOWN), roaming);
    } catch (RemoteException ex) {
    // system process is dead
    }
}
Also used : ServiceState(android.telephony.ServiceState) TelephonyManager(android.telephony.TelephonyManager) RemoteException(android.os.RemoteException) LinkProperties(android.net.LinkProperties) LinkCapabilities(android.net.LinkCapabilities)

Example 7 with ServiceState

use of android.telephony.ServiceState 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();
    }
}
Also used : ServiceState(android.telephony.ServiceState) GsmDataConnectionTracker(com.android.internal.telephony.gsm.GsmDataConnectionTracker) CdmaCellLocation(android.telephony.cdma.CdmaCellLocation)

Example 8 with ServiceState

use of android.telephony.ServiceState in project XobotOS by xamarin.

the class SipPhoneBase method getServiceState.

public ServiceState getServiceState() {
    // FIXME: we may need to provide this when data connectivity is lost
    // or when server is down
    ServiceState s = new ServiceState();
    s.setState(ServiceState.STATE_IN_SERVICE);
    return s;
}
Also used : ServiceState(android.telephony.ServiceState)

Example 9 with ServiceState

use of android.telephony.ServiceState in project android_frameworks_base by DirtyUnicorns.

the class CarrierText method updateCarrierText.

protected void updateCarrierText() {
    boolean allSimsMissing = true;
    boolean anySimReadyAndInService = false;
    CharSequence displayText = null;
    List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
    final int N = subs.size();
    if (DEBUG)
        Log.d(TAG, "updateCarrierText(): " + N);
    for (int i = 0; i < N; i++) {
        int subId = subs.get(i).getSubscriptionId();
        State simState = mKeyguardUpdateMonitor.getSimState(subId);
        CharSequence carrierName = subs.get(i).getCarrierName();
        CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName);
        if (DEBUG) {
            Log.d(TAG, "Handling (subId=" + subId + "): " + simState + " " + carrierName);
        }
        if (carrierTextForSimState != null) {
            allSimsMissing = false;
            displayText = concatenate(displayText, carrierTextForSimState);
        }
        if (simState == IccCardConstants.State.READY) {
            ServiceState ss = mKeyguardUpdateMonitor.mServiceStates.get(subId);
            if (ss != null && ss.getDataRegState() == ServiceState.STATE_IN_SERVICE) {
                // Wi-Fi is disassociated or disabled
                if (ss.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN || (mWifiManager.isWifiEnabled() && mWifiManager.getConnectionInfo() != null && mWifiManager.getConnectionInfo().getBSSID() != null)) {
                    if (DEBUG) {
                        Log.d(TAG, "SIM ready and in service: subId=" + subId + ", ss=" + ss);
                    }
                    anySimReadyAndInService = true;
                }
            }
        }
    }
    if (allSimsMissing) {
        if (N != 0) {
            // Shows "No SIM card | Emergency calls only" on devices that are voice-capable.
            // This depends on mPlmn containing the text "Emergency calls only" when the radio
            // has some connectivity. Otherwise, it should be null or empty and just show
            // "No SIM card"
            // Grab the first subscripton, because they all should contain the emergency text,
            // described above.
            displayText = null;
        } else {
            // We don't have a SubscriptionInfo to get the emergency calls only from.
            // Grab it from the old sticky broadcast if possible instead. We can use it
            // here because no subscriptions are active, so we don't have
            // to worry about MSIM clashing.
            CharSequence text = getContext().getText(com.android.internal.R.string.emergency_calls_only);
            Intent i = getContext().registerReceiver(null, new IntentFilter(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION));
            if (i != null) {
                String spn = "";
                String plmn = "";
                if (i.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false)) {
                    spn = i.getStringExtra(TelephonyIntents.EXTRA_SPN);
                }
                if (i.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false)) {
                    plmn = i.getStringExtra(TelephonyIntents.EXTRA_PLMN);
                }
                if (DEBUG)
                    Log.d(TAG, "Getting plmn/spn sticky brdcst " + plmn + "/" + spn);
                if (Objects.equals(plmn, spn)) {
                    text = plmn;
                } else {
                    text = concatenate(plmn, spn);
                }
            }
            displayText = null;
        }
    }
    // (e.g. WFC = Wi-Fi calling) which may operate in APM.
    if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) {
        displayText = getContext().getString(R.string.airplane_mode);
    }
    setText(displayText);
}
Also used : IntentFilter(android.content.IntentFilter) ServiceState(android.telephony.ServiceState) ServiceState(android.telephony.ServiceState) State(com.android.internal.telephony.IccCardConstants.State) SubscriptionInfo(android.telephony.SubscriptionInfo) Intent(android.content.Intent)

Example 10 with ServiceState

use of android.telephony.ServiceState in project android_frameworks_base by DirtyUnicorns.

the class NetworkControllerSignalTest method testNoEmengencyNoSubscriptions.

public void testNoEmengencyNoSubscriptions() {
    setupDefaultSignal();
    setSubscriptions();
    mNetworkController.mLastServiceState = new ServiceState();
    mNetworkController.mLastServiceState.setEmergencyOnly(false);
    mNetworkController.recalculateEmergency();
    verifyEmergencyOnly(false);
}
Also used : ServiceState(android.telephony.ServiceState)

Aggregations

ServiceState (android.telephony.ServiceState)55 RemoteException (android.os.RemoteException)19 VoLteServiceState (android.telephony.VoLteServiceState)15 Bundle (android.os.Bundle)11 PhoneStateListener (android.telephony.PhoneStateListener)10 SubscriptionInfo (android.telephony.SubscriptionInfo)7 IBinder (android.os.IBinder)6 SignalStrength (android.telephony.SignalStrength)6 Intent (android.content.Intent)5 IntentFilter (android.content.IntentFilter)5 State (com.android.internal.telephony.IccCardConstants.State)5 TelephonyManager (android.telephony.TelephonyManager)3 Paint (android.graphics.Paint)2 Fingerprint (android.hardware.fingerprint.Fingerprint)2 CdmaCellLocation (android.telephony.cdma.CdmaCellLocation)2 BitSet (java.util.BitSet)2 LinkCapabilities (android.net.LinkCapabilities)1 LinkProperties (android.net.LinkProperties)1 GsmCellLocation (android.telephony.gsm.GsmCellLocation)1 Phone (com.android.internal.telephony.Phone)1