Search in sources :

Example 1 with NetworkRegistrationInfo

use of android.telephony.NetworkRegistrationInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NetworkSelectSettings method forceUpdateConnectedPreferenceCategory.

/**
 * Config the connected network operator preference when the page was created. When user get
 * into this page, the device might or might not have data connection.
 * - If the device has data:
 * 1. use {@code ServiceState#getNetworkRegistrationInfoList()} to get the currently
 * registered cellIdentity, wrap it into a CellInfo;
 * 2. set the signal strength level as strong;
 * 3. get the title of the previously connected network operator, since the CellIdentity
 * got from step 1 only has PLMN.
 * - If the device has no data, we will remove the connected network operators list from the
 * screen.
 */
private void forceUpdateConnectedPreferenceCategory() {
    if (mTelephonyManager.getDataState() == mTelephonyManager.DATA_CONNECTED) {
        // Try to get the network registration states
        ServiceState ss = mTelephonyManager.getServiceState();
        List<NetworkRegistrationInfo> networkList = ss.getNetworkRegistrationInfoListForTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        if (networkList == null || networkList.size() == 0) {
            // Remove the connected network operators category
            mConnectedPreferenceCategory.setVisible(false);
            return;
        }
        CellIdentity cellIdentity = networkList.get(0).getCellIdentity();
        CellInfo cellInfo = CellInfoUtil.wrapCellInfoWithCellIdentity(cellIdentity);
        if (cellInfo != null) {
            NetworkOperatorPreference pref = new NetworkOperatorPreference(cellInfo, getPrefContext(), mForbiddenPlmns, mShow4GForLTE);
            pref.setTitle(MobileNetworkUtils.getCurrentCarrierNameForDisplay(getPrefContext(), mSubId));
            pref.setSummary(R.string.network_connected);
            // Update the signal strength icon, since the default signalStrength value would be
            // zero (it would be quite confusing why the connected network has no signal)
            pref.setIcon(SignalStrength.NUM_SIGNAL_STRENGTH_BINS - 1);
            mConnectedPreferenceCategory.addPreference(pref);
        } else {
            // Remove the connected network operators category
            mConnectedPreferenceCategory.setVisible(false);
        }
    } else {
        // Remove the connected network operators category
        mConnectedPreferenceCategory.setVisible(false);
    }
}
Also used : NetworkRegistrationInfo(android.telephony.NetworkRegistrationInfo) ServiceState(android.telephony.ServiceState) CellInfo(android.telephony.CellInfo) CellIdentity(android.telephony.CellIdentity)

Aggregations

CellIdentity (android.telephony.CellIdentity)1 CellInfo (android.telephony.CellInfo)1 NetworkRegistrationInfo (android.telephony.NetworkRegistrationInfo)1 ServiceState (android.telephony.ServiceState)1