Search in sources :

Example 16 with CellInfo

use of android.telephony.CellInfo in project android_frameworks_opt_telephony by LineageOS.

the class ServiceStateTracker method dumpCellInfoList.

private void dumpCellInfoList(PrintWriter pw) {
    pw.print(" mLastCellInfoList={");
    if (mLastCellInfoList != null) {
        boolean first = true;
        for (CellInfo info : mLastCellInfoList) {
            if (first == false) {
                pw.print(",");
            }
            first = false;
            pw.print(info.toString());
        }
    }
    pw.println("}");
}
Also used : CellInfo(android.telephony.CellInfo)

Example 17 with CellInfo

use of android.telephony.CellInfo in project robolectric by robolectric.

the class ShadowTelephonyManagerTest method shouldGiveAllCellInfo.

@Test
@Config(minSdk = JELLY_BEAN_MR1)
public void shouldGiveAllCellInfo() {
    PhoneStateListener listener = mock(PhoneStateListener.class);
    telephonyManager.listen(listener, LISTEN_CELL_INFO);
    List<CellInfo> allCellInfo = Collections.singletonList(mock(CellInfo.class));
    shadowOf(telephonyManager).setAllCellInfo(allCellInfo);
    assertEquals(allCellInfo, telephonyManager.getAllCellInfo());
    verify(listener).onCellInfoChanged(allCellInfo);
}
Also used : CellInfo(android.telephony.CellInfo) PhoneStateListener(android.telephony.PhoneStateListener) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 18 with CellInfo

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

the class RadioInfo method buildCellInfoString.

private final String buildCellInfoString(List<CellInfo> arrayCi) {
    String value = new String();
    StringBuilder cdmaCells = new StringBuilder(), gsmCells = new StringBuilder(), lteCells = new StringBuilder(), wcdmaCells = new StringBuilder();
    if (arrayCi != null) {
        for (CellInfo ci : arrayCi) {
            if (ci instanceof CellInfoLte) {
                lteCells.append(buildLteInfoString((CellInfoLte) ci));
            } else if (ci instanceof CellInfoWcdma) {
                wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
            } else if (ci instanceof CellInfoGsm) {
                gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
            } else if (ci instanceof CellInfoCdma) {
                cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
            }
        }
        if (lteCells.length() != 0) {
            value += String.format("LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s" + " %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n", "SRV", "MCC", "MNC", "TAC", "CID", "PCI", "EARFCN", "BW", "RSRP", "RSRQ", "TA");
            value += lteCells.toString();
        }
        if (wcdmaCells.length() != 0) {
            value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n", "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
            value += wcdmaCells.toString();
        }
        if (gsmCells.length() != 0) {
            value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
            value += gsmCells.toString();
        }
        if (cdmaCells.length() != 0) {
            value += String.format("CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n", "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
            value += cdmaCells.toString();
        }
    } else {
        value = "unknown";
    }
    return value.toString();
}
Also used : CellInfoLte(android.telephony.CellInfoLte) CellInfo(android.telephony.CellInfo) CellInfoCdma(android.telephony.CellInfoCdma) CellInfoWcdma(android.telephony.CellInfoWcdma) CellInfoGsm(android.telephony.CellInfoGsm)

Example 19 with CellInfo

use of android.telephony.CellInfo 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)

Example 20 with CellInfo

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

the class NetworkSelectSettings method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(Preference preference) {
    if (preference != mSelectedPreference) {
        stopNetworkQuery();
        // Refresh the last selected item in case users reselect network.
        if (mSelectedPreference != null) {
            mSelectedPreference.setSummary(null);
        }
        mSelectedPreference = (NetworkOperatorPreference) preference;
        CellInfo cellInfo = mSelectedPreference.getCellInfo();
        mSelectedPreference.setSummary(R.string.network_connecting);
        mMetricsFeatureProvider.action(getContext(), SettingsEnums.ACTION_MOBILE_NETWORK_MANUAL_SELECT_NETWORK);
        // Set summary as "Disconnected" to the previously connected network
        if (mConnectedPreferenceCategory.getPreferenceCount() > 0) {
            NetworkOperatorPreference connectedNetworkOperator = (NetworkOperatorPreference) (mConnectedPreferenceCategory.getPreference(0));
            if (!CellInfoUtil.getNetworkTitle(cellInfo).equals(CellInfoUtil.getNetworkTitle(connectedNetworkOperator.getCellInfo()))) {
                connectedNetworkOperator.setSummary(R.string.network_disconnected);
            }
        }
        setProgressBarVisible(true);
        // Disable the screen until network is manually set
        getPreferenceScreen().setEnabled(false);
        final OperatorInfo operatorInfo = CellInfoUtil.getOperatorInfoFromCellInfo(cellInfo);
        ThreadUtils.postOnBackgroundThread(() -> {
            Message msg = mHandler.obtainMessage(EVENT_SET_NETWORK_SELECTION_MANUALLY_DONE);
            msg.obj = mTelephonyManager.setNetworkSelectionModeManual(operatorInfo, true);
            msg.sendToTarget();
        });
    }
    return true;
}
Also used : CellInfo(android.telephony.CellInfo) Message(android.os.Message) OperatorInfo(com.android.internal.telephony.OperatorInfo)

Aggregations

CellInfo (android.telephony.CellInfo)40 CellInfoGsm (android.telephony.CellInfoGsm)26 CellInfoLte (android.telephony.CellInfoLte)25 CellInfoWcdma (android.telephony.CellInfoWcdma)23 CellInfoCdma (android.telephony.CellInfoCdma)18 CellIdentityGsm (android.telephony.CellIdentityGsm)12 CellIdentityLte (android.telephony.CellIdentityLte)12 CellIdentityCdma (android.telephony.CellIdentityCdma)11 CellIdentityWcdma (android.telephony.CellIdentityWcdma)11 NeighboringCellInfo (android.telephony.NeighboringCellInfo)8 ArrayList (java.util.ArrayList)6 PendingIntent (android.app.PendingIntent)5 Intent (android.content.Intent)5 WifiInfo (android.net.wifi.WifiInfo)5 CellSignalStrengthLte (android.telephony.CellSignalStrengthLte)5 Parcel (android.os.Parcel)4 CellSignalStrengthGsm (android.telephony.CellSignalStrengthGsm)4 Test (org.junit.Test)4 SuppressLint (android.annotation.SuppressLint)3 TargetApi (android.annotation.TargetApi)3