Search in sources :

Example 26 with CellIdentityCdma

use of android.telephony.CellIdentityCdma in project network-monitor by caarmen.

the class CellLocationDataSource method fillCellLocationV17.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void fillCellLocationV17(ContentValues values) {
    if (PermissionUtil.hasLocationPermission(mContext)) {
        @SuppressLint("MissingPermission") List<CellInfo> cellInfos = mTelephonyManager.getAllCellInfo();
        if (cellInfos == null || cellInfos.isEmpty()) {
            fillCellLocation(values);
        } else {
            StreamSupport.stream(cellInfos).filter(CellInfo::isRegistered).forEach(cellInfo -> {
                if (cellInfo instanceof CellInfoGsm) {
                    CellInfoGsm gsmCellInfo = (CellInfoGsm) cellInfo;
                    CellIdentityGsm cellIdentityGsm = gsmCellInfo.getCellIdentity();
                    setGsmCellInfo(values, cellIdentityGsm.getCid(), cellIdentityGsm.getLac());
                } else if (cellInfo instanceof CellInfoCdma) {
                    CellInfoCdma cellInfoCdma = (CellInfoCdma) cellInfo;
                    CellIdentityCdma cellIdentityCdma = cellInfoCdma.getCellIdentity();
                    setCdmaCellInfo(values, cellIdentityCdma.getBasestationId(), cellIdentityCdma.getLatitude(), cellIdentityCdma.getLongitude(), cellIdentityCdma.getNetworkId(), cellIdentityCdma.getSystemId());
                } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo instanceof CellInfoWcdma) {
                    CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
                    CellIdentityWcdma cellIdentityWcdma = cellInfoWcdma.getCellIdentity();
                    setGsmCellInfo(values, cellIdentityWcdma.getCid(), cellIdentityWcdma.getLac());
                    values.put(NetMonColumns.GSM_CELL_PSC, cellIdentityWcdma.getPsc());
                } else if (cellInfo instanceof CellInfoLte) {
                    CellInfoLte cellInfoLte = (CellInfoLte) cellInfo;
                    CellIdentityLte cellIdentityLte = cellInfoLte.getCellIdentity();
                    values.put(NetMonColumns.LTE_CELL_CI, cellIdentityLte.getCi());
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                        values.put(NetMonColumns.LTE_CELL_EARFCN, cellIdentityLte.getEarfcn());
                    }
                    values.put(NetMonColumns.LTE_CELL_TAC, cellIdentityLte.getTac());
                    values.put(NetMonColumns.LTE_CELL_PCI, cellIdentityLte.getPci());
                }
            });
        }
    }
}
Also used : CellInfoLte(android.telephony.CellInfoLte) CellIdentityCdma(android.telephony.CellIdentityCdma) CellInfo(android.telephony.CellInfo) CellInfoCdma(android.telephony.CellInfoCdma) CellIdentityLte(android.telephony.CellIdentityLte) CellInfoWcdma(android.telephony.CellInfoWcdma) SuppressLint(android.annotation.SuppressLint) CellIdentityGsm(android.telephony.CellIdentityGsm) CellIdentityWcdma(android.telephony.CellIdentityWcdma) CellInfoGsm(android.telephony.CellInfoGsm) TargetApi(android.annotation.TargetApi)

Example 27 with CellIdentityCdma

use of android.telephony.CellIdentityCdma in project VirtualApp by asLody.

the class MethodProxies method createCellInfo.

private static CellInfo createCellInfo(VCell cell) {
    if (cell.type == 2) {
        // CDMA
        CellInfoCdma cdma = mirror.android.telephony.CellInfoCdma.ctor.newInstance();
        CellIdentityCdma identityCdma = mirror.android.telephony.CellInfoCdma.mCellIdentityCdma.get(cdma);
        CellSignalStrengthCdma strengthCdma = mirror.android.telephony.CellInfoCdma.mCellSignalStrengthCdma.get(cdma);
        mirror.android.telephony.CellIdentityCdma.mNetworkId.set(identityCdma, cell.networkId);
        mirror.android.telephony.CellIdentityCdma.mSystemId.set(identityCdma, cell.systemId);
        mirror.android.telephony.CellIdentityCdma.mBasestationId.set(identityCdma, cell.baseStationId);
        mirror.android.telephony.CellSignalStrengthCdma.mCdmaDbm.set(strengthCdma, -74);
        mirror.android.telephony.CellSignalStrengthCdma.mCdmaEcio.set(strengthCdma, -91);
        mirror.android.telephony.CellSignalStrengthCdma.mEvdoDbm.set(strengthCdma, -64);
        mirror.android.telephony.CellSignalStrengthCdma.mEvdoSnr.set(strengthCdma, 7);
        return cdma;
    } else {
        // GSM
        CellInfoGsm gsm = mirror.android.telephony.CellInfoGsm.ctor.newInstance();
        CellIdentityGsm identityGsm = mirror.android.telephony.CellInfoGsm.mCellIdentityGsm.get(gsm);
        CellSignalStrengthGsm strengthGsm = mirror.android.telephony.CellInfoGsm.mCellSignalStrengthGsm.get(gsm);
        mirror.android.telephony.CellIdentityGsm.mMcc.set(identityGsm, cell.mcc);
        mirror.android.telephony.CellIdentityGsm.mMnc.set(identityGsm, cell.mnc);
        mirror.android.telephony.CellIdentityGsm.mLac.set(identityGsm, cell.lac);
        mirror.android.telephony.CellIdentityGsm.mCid.set(identityGsm, cell.cid);
        mirror.android.telephony.CellSignalStrengthGsm.mSignalStrength.set(strengthGsm, 20);
        mirror.android.telephony.CellSignalStrengthGsm.mBitErrorRate.set(strengthGsm, 0);
        return gsm;
    }
}
Also used : CellIdentityCdma(android.telephony.CellIdentityCdma) CellInfoCdma(android.telephony.CellInfoCdma) CellSignalStrengthGsm(android.telephony.CellSignalStrengthGsm) CellIdentityGsm(android.telephony.CellIdentityGsm) CellSignalStrengthCdma(android.telephony.CellSignalStrengthCdma) CellInfoGsm(android.telephony.CellInfoGsm)

Example 28 with CellIdentityCdma

use of android.telephony.CellIdentityCdma in project Android-IMSI-Catcher-Detector by CellularPrivacy.

the class DeviceApi18 method loadCellInfo.

public static void loadCellInfo(TelephonyManager tm, Device pDevice) {
    int lCurrentApiVersion = Build.VERSION.SDK_INT;
    try {
        if (pDevice.cell == null) {
            pDevice.cell = new Cell();
        }
        List<CellInfo> cellInfoList = tm.getAllCellInfo();
        if (cellInfoList != null) {
            for (final CellInfo info : cellInfoList) {
                // Network Type
                pDevice.cell.setNetType(tm.getNetworkType());
                if (info instanceof CellInfoGsm) {
                    final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
                    final CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity();
                    // Signal Strength
                    // [dBm]
                    pDevice.cell.setDbm(gsm.getDbm());
                    // Cell Identity
                    pDevice.cell.setCellId(identityGsm.getCid());
                    pDevice.cell.setMobileCountryCode(identityGsm.getMcc());
                    pDevice.cell.setMobileNetworkCode(identityGsm.getMnc());
                    pDevice.cell.setLocationAreaCode(identityGsm.getLac());
                } else if (info instanceof CellInfoCdma) {
                    final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
                    final CellIdentityCdma identityCdma = ((CellInfoCdma) info).getCellIdentity();
                    // Signal Strength
                    pDevice.cell.setDbm(cdma.getDbm());
                    // Cell Identity
                    pDevice.cell.setCellId(identityCdma.getBasestationId());
                    pDevice.cell.setMobileNetworkCode(identityCdma.getSystemId());
                    pDevice.cell.setLocationAreaCode(identityCdma.getNetworkId());
                    pDevice.cell.setSid(identityCdma.getSystemId());
                } else if (info instanceof CellInfoLte) {
                    final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
                    final CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity();
                    // Signal Strength
                    pDevice.cell.setDbm(lte.getDbm());
                    pDevice.cell.setTimingAdvance(lte.getTimingAdvance());
                    // Cell Identity
                    pDevice.cell.setMobileCountryCode(identityLte.getMcc());
                    pDevice.cell.setMobileNetworkCode(identityLte.getMnc());
                    pDevice.cell.setCellId(identityLte.getCi());
                } else if (lCurrentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2 && info instanceof CellInfoWcdma) {
                    final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info).getCellSignalStrength();
                    final CellIdentityWcdma identityWcdma = ((CellInfoWcdma) info).getCellIdentity();
                    // Signal Strength
                    pDevice.cell.setDbm(wcdma.getDbm());
                    // Cell Identity
                    pDevice.cell.setLocationAreaCode(identityWcdma.getLac());
                    pDevice.cell.setMobileCountryCode(identityWcdma.getMcc());
                    pDevice.cell.setMobileNetworkCode(identityWcdma.getMnc());
                    pDevice.cell.setCellId(identityWcdma.getCid());
                    pDevice.cell.setPrimaryScramblingCode(identityWcdma.getPsc());
                } else {
                    log.info("Unknown type of cell signal!" + "\n ClassName: " + info.getClass().getSimpleName() + "\n ToString: " + info.toString());
                }
                if (pDevice.cell.isValid()) {
                    break;
                }
            }
        }
    } catch (NullPointerException npe) {
        log.error("loadCellInfo: Unable to obtain cell signal information: ", npe);
    }
}
Also used : CellInfoCdma(android.telephony.CellInfoCdma) CellInfoWcdma(android.telephony.CellInfoWcdma) CellIdentityGsm(android.telephony.CellIdentityGsm) CellSignalStrengthWcdma(android.telephony.CellSignalStrengthWcdma) CellInfoGsm(android.telephony.CellInfoGsm) CellSignalStrengthLte(android.telephony.CellSignalStrengthLte) CellInfoLte(android.telephony.CellInfoLte) CellIdentityCdma(android.telephony.CellIdentityCdma) CellInfo(android.telephony.CellInfo) CellSignalStrengthGsm(android.telephony.CellSignalStrengthGsm) CellIdentityLte(android.telephony.CellIdentityLte) CellSignalStrengthCdma(android.telephony.CellSignalStrengthCdma) CellIdentityWcdma(android.telephony.CellIdentityWcdma)

Example 29 with CellIdentityCdma

use of android.telephony.CellIdentityCdma in project Android-IMSI-Catcher-Detector by CellularPrivacy.

the class DeviceApi17 method loadCellInfo.

public static void loadCellInfo(TelephonyManager tm, Device pDevice) {
    int lCurrentApiVersion = Build.VERSION.SDK_INT;
    try {
        if (pDevice.cell == null) {
            pDevice.cell = new Cell();
        }
        List<CellInfo> cellInfoList = tm.getAllCellInfo();
        if (cellInfoList != null) {
            for (final CellInfo info : cellInfoList) {
                // Network Type
                pDevice.cell.setNetType(tm.getNetworkType());
                if (info instanceof CellInfoGsm) {
                    final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
                    final CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity();
                    // Signal Strength
                    // [dBm]
                    pDevice.cell.setDbm(gsm.getDbm());
                    // Cell Identity
                    pDevice.cell.setCellId(identityGsm.getCid());
                    pDevice.cell.setMobileCountryCode(identityGsm.getMcc());
                    pDevice.cell.setMobileNetworkCode(identityGsm.getMnc());
                    pDevice.cell.setLocationAreaCode(identityGsm.getLac());
                } else if (info instanceof CellInfoCdma) {
                    final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
                    final CellIdentityCdma identityCdma = ((CellInfoCdma) info).getCellIdentity();
                    // Signal Strength
                    pDevice.cell.setDbm(cdma.getDbm());
                    // Cell Identity
                    pDevice.cell.setCellId(identityCdma.getBasestationId());
                    pDevice.cell.setMobileNetworkCode(identityCdma.getSystemId());
                    pDevice.cell.setLocationAreaCode(identityCdma.getNetworkId());
                    pDevice.cell.setSid(identityCdma.getSystemId());
                } else if (info instanceof CellInfoLte) {
                    final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
                    final CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity();
                    // Signal Strength
                    pDevice.cell.setDbm(lte.getDbm());
                    pDevice.cell.setTimingAdvance(lte.getTimingAdvance());
                    // Cell Identity
                    pDevice.cell.setMobileCountryCode(identityLte.getMcc());
                    pDevice.cell.setMobileNetworkCode(identityLte.getMnc());
                    pDevice.cell.setCellId(identityLte.getCi());
                } else if (lCurrentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2 && info instanceof CellInfoWcdma) {
                    final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info).getCellSignalStrength();
                    final CellIdentityWcdma identityWcdma = ((CellInfoWcdma) info).getCellIdentity();
                    // Signal Strength
                    pDevice.cell.setDbm(wcdma.getDbm());
                    // Cell Identity
                    pDevice.cell.setLocationAreaCode(identityWcdma.getLac());
                    pDevice.cell.setMobileCountryCode(identityWcdma.getMcc());
                    pDevice.cell.setMobileNetworkCode(identityWcdma.getMnc());
                    pDevice.cell.setCellId(identityWcdma.getCid());
                    pDevice.cell.setPrimaryScramblingCode(identityWcdma.getPsc());
                } else {
                    log.info("Unknown type of cell signal! " + "ClassName: " + info.getClass().getSimpleName() + " ToString: " + info.toString());
                }
                if (pDevice.cell.isValid()) {
                    break;
                }
            }
        }
    } catch (NullPointerException npe) {
        log.error("loadCellInfo: Unable to obtain cell signal information: ", npe);
    }
}
Also used : CellInfoCdma(android.telephony.CellInfoCdma) CellInfoWcdma(android.telephony.CellInfoWcdma) CellIdentityGsm(android.telephony.CellIdentityGsm) CellSignalStrengthWcdma(android.telephony.CellSignalStrengthWcdma) CellInfoGsm(android.telephony.CellInfoGsm) CellSignalStrengthLte(android.telephony.CellSignalStrengthLte) CellInfoLte(android.telephony.CellInfoLte) CellIdentityCdma(android.telephony.CellIdentityCdma) CellInfo(android.telephony.CellInfo) CellSignalStrengthGsm(android.telephony.CellSignalStrengthGsm) CellIdentityLte(android.telephony.CellIdentityLte) CellSignalStrengthCdma(android.telephony.CellSignalStrengthCdma) CellIdentityWcdma(android.telephony.CellIdentityWcdma)

Example 30 with CellIdentityCdma

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

the class RadioInfo method buildCdmaInfoString.

private final String buildCdmaInfoString(CellInfoCdma ci) {
    CellIdentityCdma cidCdma = ci.getCellIdentity();
    CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
    return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s", getConnectionStatusString(ci), getCellInfoDisplayString(cidCdma.getSystemId()), getCellInfoDisplayString(cidCdma.getNetworkId()), getCellInfoDisplayString(cidCdma.getBasestationId()), getCellInfoDisplayString(ssCdma.getCdmaDbm()), getCellInfoDisplayString(ssCdma.getCdmaEcio()), getCellInfoDisplayString(ssCdma.getEvdoDbm()), getCellInfoDisplayString(ssCdma.getEvdoEcio()), getCellInfoDisplayString(ssCdma.getEvdoSnr()));
}
Also used : CellIdentityCdma(android.telephony.CellIdentityCdma) CellSignalStrengthCdma(android.telephony.CellSignalStrengthCdma)

Aggregations

CellIdentityCdma (android.telephony.CellIdentityCdma)37 CellInfoCdma (android.telephony.CellInfoCdma)18 CellIdentityGsm (android.telephony.CellIdentityGsm)16 CellSignalStrengthCdma (android.telephony.CellSignalStrengthCdma)16 CellInfo (android.telephony.CellInfo)14 CellInfoGsm (android.telephony.CellInfoGsm)14 CellIdentityLte (android.telephony.CellIdentityLte)13 CellIdentityWcdma (android.telephony.CellIdentityWcdma)12 CellInfoLte (android.telephony.CellInfoLte)11 CellInfoWcdma (android.telephony.CellInfoWcdma)11 SmallTest (android.test.suitebuilder.annotation.SmallTest)9 CellSignalStrengthGsm (android.telephony.CellSignalStrengthGsm)6 FlakyTest (androidx.test.filters.FlakyTest)6 Test (org.junit.Test)6 PendingIntent (android.app.PendingIntent)5 Intent (android.content.Intent)5 WifiInfo (android.net.wifi.WifiInfo)5 TargetApi (android.annotation.TargetApi)3 CellIdentity (android.telephony.CellIdentity)3 CellSignalStrengthLte (android.telephony.CellSignalStrengthLte)3