Search in sources :

Example 26 with CellInfoWcdma

use of android.telephony.CellInfoWcdma 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 27 with CellInfoWcdma

use of android.telephony.CellInfoWcdma 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 28 with CellInfoWcdma

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

the class RILTest method testConvertHalCellInfoListForWcdma.

@Test
public void testConvertHalCellInfoListForWcdma() {
    android.hardware.radio.V1_0.CellInfoWcdma cellinfo = new android.hardware.radio.V1_0.CellInfoWcdma();
    cellinfo.cellIdentityWcdma.lac = LAC;
    cellinfo.cellIdentityWcdma.cid = CID;
    cellinfo.cellIdentityWcdma.psc = PSC;
    cellinfo.cellIdentityWcdma.uarfcn = UARFCN;
    cellinfo.cellIdentityWcdma.mcc = MCC_STR;
    cellinfo.cellIdentityWcdma.mnc = MNC_STR;
    cellinfo.signalStrengthWcdma.signalStrength = RSSI_ASU;
    cellinfo.signalStrengthWcdma.bitErrorRate = BIT_ERROR_RATE;
    android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo();
    record.cellInfoType = TYPE_WCDMA;
    record.registered = false;
    record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL;
    record.timeStamp = TIMESTAMP;
    record.wcdma.add(cellinfo);
    ArrayList<android.hardware.radio.V1_0.CellInfo> records = new ArrayList<android.hardware.radio.V1_0.CellInfo>();
    records.add(record);
    ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records);
    assertEquals(1, ret.size());
    CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) ret.get(0);
    CellInfoWcdma expected = new CellInfoWcdma();
    expected.setRegistered(false);
    expected.setTimeStamp(TIMESTAMP);
    CellIdentityWcdma ci = new CellIdentityWcdma(LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT, Collections.emptyList(), null);
    CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(RSSI, BIT_ERROR_RATE, Integer.MAX_VALUE, Integer.MAX_VALUE);
    expected.setCellIdentity(ci);
    expected.setCellSignalStrength(cs);
    expected.setCellConnectionStatus(CellInfo.CONNECTION_UNKNOWN);
    // override the timestamp
    cellInfoWcdma.setTimeStamp(TIMESTAMP);
    assertEquals(expected, cellInfoWcdma);
}
Also used : CellInfoWcdma(android.telephony.CellInfoWcdma) ArrayList(java.util.ArrayList) CellSignalStrengthWcdma(android.telephony.CellSignalStrengthWcdma) CellInfo(android.telephony.CellInfo) CellIdentityWcdma(android.telephony.CellIdentityWcdma) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Example 29 with CellInfoWcdma

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

the class RILTest method getRadioAccessSpecifier.

private RadioAccessSpecifier getRadioAccessSpecifier(CellInfo cellInfo) {
    RadioAccessSpecifier ras;
    if (cellInfo instanceof CellInfoLte) {
        int ranLte = AccessNetworkConstants.AccessNetworkType.EUTRAN;
        int[] lteChannels = { ((CellInfoLte) cellInfo).getCellIdentity().getEarfcn() };
        ras = new RadioAccessSpecifier(ranLte, null, /* bands */
        lteChannels);
    } else if (cellInfo instanceof CellInfoWcdma) {
        int ranLte = AccessNetworkConstants.AccessNetworkType.UTRAN;
        int[] wcdmaChannels = { ((CellInfoWcdma) cellInfo).getCellIdentity().getUarfcn() };
        ras = new RadioAccessSpecifier(ranLte, null, /* bands */
        wcdmaChannels);
    } else if (cellInfo instanceof CellInfoGsm) {
        int ranGsm = AccessNetworkConstants.AccessNetworkType.GERAN;
        int[] gsmChannels = { ((CellInfoGsm) cellInfo).getCellIdentity().getArfcn() };
        ras = new RadioAccessSpecifier(ranGsm, null, /* bands */
        gsmChannels);
    } else {
        ras = null;
    }
    return ras;
}
Also used : CellInfoLte(android.telephony.CellInfoLte) CellInfoWcdma(android.telephony.CellInfoWcdma) RadioAccessSpecifier(android.telephony.RadioAccessSpecifier) CellInfoGsm(android.telephony.CellInfoGsm)

Example 30 with CellInfoWcdma

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

the class RILTest method testConvertHalCellInfoList_1_2ForWcdma.

@Test
public void testConvertHalCellInfoList_1_2ForWcdma() {
    ArrayList<CellInfo> ret = getCellInfoListForWcdma(MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT);
    assertEquals(1, ret.size());
    CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) ret.get(0);
    CellInfoWcdma expected = new CellInfoWcdma();
    expected.setRegistered(false);
    expected.setTimeStamp(TIMESTAMP);
    CellIdentityWcdma ci = new CellIdentityWcdma(LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(RSSI, BIT_ERROR_RATE, RSCP, ECNO);
    expected.setCellIdentity(ci);
    expected.setCellSignalStrength(cs);
    expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
    // override the timestamp
    cellInfoWcdma.setTimeStamp(TIMESTAMP);
    assertEquals(expected, cellInfoWcdma);
}
Also used : CellInfo(android.telephony.CellInfo) CellInfoWcdma(android.telephony.CellInfoWcdma) CellSignalStrengthWcdma(android.telephony.CellSignalStrengthWcdma) CellIdentityWcdma(android.telephony.CellIdentityWcdma) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Aggregations

CellInfoWcdma (android.telephony.CellInfoWcdma)30 CellInfo (android.telephony.CellInfo)27 CellInfoGsm (android.telephony.CellInfoGsm)26 CellInfoLte (android.telephony.CellInfoLte)26 CellInfoCdma (android.telephony.CellInfoCdma)19 CellIdentityWcdma (android.telephony.CellIdentityWcdma)16 CellIdentityGsm (android.telephony.CellIdentityGsm)12 CellIdentityLte (android.telephony.CellIdentityLte)12 CellIdentityCdma (android.telephony.CellIdentityCdma)11 CellSignalStrengthWcdma (android.telephony.CellSignalStrengthWcdma)7 NeighboringCellInfo (android.telephony.NeighboringCellInfo)6 PendingIntent (android.app.PendingIntent)5 Intent (android.content.Intent)5 WifiInfo (android.net.wifi.WifiInfo)5 FlakyTest (androidx.test.filters.FlakyTest)4 Test (org.junit.Test)4 CellSignalStrengthCdma (android.telephony.CellSignalStrengthCdma)3 CellSignalStrengthGsm (android.telephony.CellSignalStrengthGsm)3 CellSignalStrengthLte (android.telephony.CellSignalStrengthLte)3 TargetApi (android.annotation.TargetApi)2