Search in sources :

Example 11 with CellIdentityCdma

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

the class Phone method privatizeCellInfoList.

/**
 * Clear CDMA base station lat/long values if location setting is disabled.
 * @param cellInfoList the original cell info list from the RIL
 * @return the original list with CDMA lat/long cleared if necessary
 */
private List<CellInfo> privatizeCellInfoList(List<CellInfo> cellInfoList) {
    if (cellInfoList == null)
        return null;
    int mode = Settings.Secure.getInt(getContext().getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
    if (mode == Settings.Secure.LOCATION_MODE_OFF) {
        ArrayList<CellInfo> privateCellInfoList = new ArrayList<CellInfo>(cellInfoList.size());
        // clear lat/lon values for location privacy
        for (CellInfo c : cellInfoList) {
            if (c instanceof CellInfoCdma) {
                CellInfoCdma cellInfoCdma = (CellInfoCdma) c;
                CellIdentityCdma cellIdentity = cellInfoCdma.getCellIdentity();
                CellIdentityCdma maskedCellIdentity = new CellIdentityCdma(cellIdentity.getNetworkId(), cellIdentity.getSystemId(), cellIdentity.getBasestationId(), Integer.MAX_VALUE, Integer.MAX_VALUE);
                CellInfoCdma privateCellInfoCdma = new CellInfoCdma(cellInfoCdma);
                privateCellInfoCdma.setCellIdentity(maskedCellIdentity);
                privateCellInfoList.add(privateCellInfoCdma);
            } else {
                privateCellInfoList.add(c);
            }
        }
        cellInfoList = privateCellInfoList;
    }
    return cellInfoList;
}
Also used : CellIdentityCdma(android.telephony.CellIdentityCdma) CellInfo(android.telephony.CellInfo) CellInfoCdma(android.telephony.CellInfoCdma) ArrayList(java.util.ArrayList)

Example 12 with CellIdentityCdma

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

the class CellInfoUtil method wrapCellInfoWithCellIdentity.

/**
 * Wrap a CellIdentity into a CellInfo.
 */
public static CellInfo wrapCellInfoWithCellIdentity(CellIdentity cellIdentity) {
    if (cellIdentity instanceof CellIdentityLte) {
        CellInfoLte cellInfo = new CellInfoLte();
        cellInfo.setCellIdentity((CellIdentityLte) cellIdentity);
        return cellInfo;
    } else if (cellIdentity instanceof CellIdentityCdma) {
        CellInfoCdma cellInfo = new CellInfoCdma();
        cellInfo.setCellIdentity((CellIdentityCdma) cellIdentity);
        return cellInfo;
    } else if (cellIdentity instanceof CellIdentityWcdma) {
        CellInfoWcdma cellInfo = new CellInfoWcdma();
        cellInfo.setCellIdentity((CellIdentityWcdma) cellIdentity);
        return cellInfo;
    } else if (cellIdentity instanceof CellIdentityGsm) {
        CellInfoGsm cellInfo = new CellInfoGsm();
        cellInfo.setCellIdentity((CellIdentityGsm) cellIdentity);
        return cellInfo;
    } else {
        Log.e(TAG, "Invalid CellInfo type");
        return null;
    }
}
Also used : CellInfoLte(android.telephony.CellInfoLte) CellIdentityCdma(android.telephony.CellIdentityCdma) CellInfoCdma(android.telephony.CellInfoCdma) CellIdentityLte(android.telephony.CellIdentityLte) CellInfoWcdma(android.telephony.CellInfoWcdma) CellIdentityGsm(android.telephony.CellIdentityGsm) CellIdentityWcdma(android.telephony.CellIdentityWcdma) CellInfoGsm(android.telephony.CellInfoGsm)

Example 13 with CellIdentityCdma

use of android.telephony.CellIdentityCdma in project DataLogger by sussexwearlab.

the class CellsInfoDataCollector method getCellInfoString.

private String getCellInfoString(List<CellInfo> cellsInfo) {
    // Timestamp in system nanoseconds since boot, including time spent in sleep.
    long nanoTime = SystemClock.elapsedRealtimeNanos() + mNanosOffset;
    // System local time in millis
    long currentMillis = (new Date()).getTime();
    String message = String.format("%s", currentMillis) + ";" + String.format("%s", nanoTime) + ";" + String.format("%s", mNanosOffset) + ";" + Integer.toString(cellsInfo.size());
    // The list can include one or more CellInfoGsm, CellInfoCdma, CellInfoLte, and CellInfoWcdma objects, in any combination.
    for (final CellInfo cellInfo : cellsInfo) {
        if (cellInfo instanceof CellInfoGsm) {
            // True if this cell is registered to the mobile network.
            // 0, 1 or more CellInfo objects may return isRegistered() true.
            int isRegistered = (cellInfo.isRegistered()) ? 1 : 0;
            final CellSignalStrengthGsm gsmStrength = ((CellInfoGsm) cellInfo).getCellSignalStrength();
            // Get the signal level as an asu value between 0..31, 99 is unknown Asu is calculated based on 3GPP RSRP.
            int asuLevel = gsmStrength.getAsuLevel();
            // Get the signal strength as dBm
            int dBm = gsmStrength.getDbm();
            // Get signal level as an int from 0..4
            int level = gsmStrength.getLevel();
            final CellIdentityGsm gsmId = ((CellInfoGsm) cellInfo).getCellIdentity();
            // CID Either 16-bit GSM Cell Identity described in TS 27.007, 0..65535, Integer.MAX_VALUE if unknown
            int cid = gsmId.getCid();
            // 16-bit Location Area Code, 0..65535, Integer.MAX_VALUE if unknown
            int lac = gsmId.getLac();
            // 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown
            int mcc = gsmId.getMcc();
            // 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown
            int mnc = gsmId.getMnc();
            message += ";GSM;" + isRegistered + ";" + cid + ";" + lac + ";" + mcc + ";" + mnc + ";" + asuLevel + ";" + dBm + ";" + level;
        } else if (cellInfo instanceof CellInfoCdma) {
            // True if this cell is registered to the mobile network.
            // 0, 1 or more CellInfo objects may return isRegistered() true.
            int isRegistered = (cellInfo.isRegistered()) ? 1 : 0;
            final CellSignalStrengthCdma cdmaStength = ((CellInfoCdma) cellInfo).getCellSignalStrength();
            // Get the signal level as an asu value between 0..97, 99 is unknown
            int asuLevel = cdmaStength.getAsuLevel();
            // Get the CDMA RSSI value in dBm
            int cdmaDbm = cdmaStength.getCdmaDbm();
            // Get the CDMA Ec/Io value in dB*10
            int cdmaEcio = cdmaStength.getCdmaEcio();
            // Get cdma as level 0..4
            int cdmaLevel = cdmaStength.getCdmaLevel();
            // Get the signal strength as dBm
            int dBm = cdmaStength.getDbm();
            // Get the EVDO RSSI value in dBm
            int evdoDbm = cdmaStength.getEvdoDbm();
            // Get the EVDO Ec/Io value in dB*10
            int evdoEcio = cdmaStength.getEvdoEcio();
            // Get Evdo as level 0..4
            int evdoLevel = cdmaStength.getEvdoLevel();
            // Get the signal to noise ratio.
            int evdoSnr = cdmaStength.getEvdoSnr();
            // Get signal level as an int from 0..4
            int level = cdmaStength.getLevel();
            final CellIdentityCdma cdmaId = ((CellInfoCdma) cellInfo).getCellIdentity();
            // Base Station Id 0..65535, Integer.MAX_VALUE if unknown
            int basestationId = cdmaId.getBasestationId();
            // Base station latitude, which is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
            // It is represented in units of 0.25 seconds and ranges from -1296000 to 1296000, both
            // values inclusive (corresponding to a range of -90 to +90 degrees). Integer.MAX_VALUE if unknown.
            int latitude = cdmaId.getLatitude();
            // Base station longitude, which is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
            // It is represented in units of 0.25 seconds and ranges from -2592000 to 2592000, both
            // values inclusive (corresponding to a range of -180 to +180 degrees). Integer.MAX_VALUE if unknown.
            int longitude = cdmaId.getLongitude();
            // Network Id 0..65535, Integer.MAX_VALUE if unknown
            int networkId = cdmaId.getNetworkId();
            // System Id 0..32767, Integer.MAX_VALUE if unknown
            int systemId = cdmaId.getSystemId();
            message += ";CDMA;" + isRegistered + ";" + basestationId + ";" + latitude + ";" + longitude + ";" + networkId + ";" + systemId + ";" + asuLevel + ";" + cdmaDbm + ";" + cdmaEcio + ";" + cdmaLevel + ";" + dBm + ";" + evdoDbm + ";" + evdoEcio + ";" + evdoLevel + ";" + evdoSnr + ";" + level;
        } else if (cellInfo instanceof CellInfoLte) {
            // True if this cell is registered to the mobile network.
            // 0, 1 or more CellInfo objects may return isRegistered() true.
            int isRegistered = (cellInfo.isRegistered()) ? 1 : 0;
            final CellSignalStrengthLte lteStrength = ((CellInfoLte) cellInfo).getCellSignalStrength();
            // Get the LTE signal level as an asu value between 0..97, 99 is unknown Asu is calculated based on 3GPP RSRP.
            // Represents a normalized version of the signal strength as dBm
            int asuLevel = lteStrength.getAsuLevel();
            // Get the signal strength as dBm
            // Returns RSRP – Reference Signal Received Power
            int dBm = lteStrength.getDbm();
            // Get signal level as an int from 0..4
            int level = lteStrength.getLevel();
            final CellIdentityLte lteId = ((CellInfoLte) cellInfo).getCellIdentity();
            // 28-bit Cell Identity, Integer.MAX_VALUE if unknown
            int ci = lteId.getCi();
            // 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown
            int mcc = lteId.getMcc();
            // 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown
            int mnc = lteId.getMnc();
            // Physical Cell Id 0..503, Integer.MAX_VALUE if unknown
            int pci = lteId.getPci();
            // 16-bit Tracking Area Code, Integer.MAX_VALUE if unknown
            int tac = lteId.getTac();
            message += ";LTE;" + isRegistered + ";" + ci + ";" + mcc + ";" + mnc + ";" + pci + ";" + tac + ";" + asuLevel + ";" + dBm + ";" + level;
        // 13 129108338 114 -1
        // LTE;129108338;234;10;384;144;39;-101;3
        } else if (cellInfo instanceof CellInfoWcdma) {
            // True if this cell is registered to the mobile network.
            // 0, 1 or more CellInfo objects may return isRegistered() true.
            int isRegistered = (cellInfo.isRegistered()) ? 1 : 0;
            final CellSignalStrengthWcdma wcdmaStrength = ((CellInfoWcdma) cellInfo).getCellSignalStrength();
            // Get the signal level as an asu value between 0..31, 99 is unknown Asu is calculated based on 3GPP RSRP.
            int asuLevel = wcdmaStrength.getAsuLevel();
            // Get the signal strength as dBm
            int dBm = wcdmaStrength.getDbm();
            // Get signal level as an int from 0..4
            int level = wcdmaStrength.getLevel();
            final CellIdentityWcdma wcdmaId = ((CellInfoWcdma) cellInfo).getCellIdentity();
            // CID 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, Integer.MAX_VALUE if unknown
            int cid = wcdmaId.getCid();
            // 16-bit Location Area Code, 0..65535, Integer.MAX_VALUE if unknown
            int lac = wcdmaId.getLac();
            // 3-digit Mobile Country Code, 0..999, Integer.MAX_VALUE if unknown
            int mcc = wcdmaId.getMcc();
            // 2 or 3-digit Mobile Network Code, 0..999, Integer.MAX_VALUE if unknown
            int mnc = wcdmaId.getMnc();
            // 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511, Integer.MAX_VALUE if unknown
            int psc = wcdmaId.getPsc();
            message += ";WCDMA;" + isRegistered + ";" + cid + ";" + lac + ";" + mcc + ";" + mnc + ";" + psc + ";" + asuLevel + ";" + dBm + ";" + level;
        } else {
            Log.e(TAG, "Unknown type of cell signal");
        }
    }
    return message;
}
Also used : CellInfoCdma(android.telephony.CellInfoCdma) CellInfoWcdma(android.telephony.CellInfoWcdma) CellIdentityGsm(android.telephony.CellIdentityGsm) CellSignalStrengthWcdma(android.telephony.CellSignalStrengthWcdma) Date(java.util.Date) 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 14 with CellIdentityCdma

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

the class CellIdentityTest method testGetMccMncString.

@SmallTest
public void testGetMccMncString() {
    List<CellIdentity> identities = new ArrayList<>(5);
    CellIdentityGsm gsm = new CellIdentityGsm(MAX_LAC, MAX_CID, MAX_ARFCN, MAX_BSIC, MCC_STR, MNC_STR, null, null, Collections.emptyList());
    identities.add(gsm);
    CellIdentityCdma cdma = new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE, ALPHA_LONG, ALPHA_SHORT);
    identities.add(cdma);
    CellIdentity lte = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDS, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    identities.add(lte);
    CellIdentityWcdma wcdma = new CellIdentityWcdma(MAX_LAC, MAX_CID, PSC, UARFCN, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    identities.add(wcdma);
    CellIdentityTdscdma tdscdma = new CellIdentityTdscdma(MCC_STR, MNC_STR, MAX_LAC, MAX_CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList(), null);
    identities.add(tdscdma);
    CellIdentityNr nr = new CellIdentityNr(PCI, TAC, EARFCN, BANDS, MCC_STR, MNC_STR, CI, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList());
    identities.add(nr);
    for (CellIdentity identity : identities) {
        final String mccStr = identity.getMccString();
        final String mncStr = identity.getMncString();
        if (identity instanceof CellIdentityCdma) {
            assertNull(mccStr);
            assertNull(mncStr);
        } else {
            assertEquals(MCC_STR, mccStr);
            assertEquals(MNC_STR, mncStr);
        }
    }
}
Also used : CellIdentityCdma(android.telephony.CellIdentityCdma) CellIdentityLte(android.telephony.CellIdentityLte) CellIdentity(android.telephony.CellIdentity) ArrayList(java.util.ArrayList) CellIdentityGsm(android.telephony.CellIdentityGsm) CellIdentityWcdma(android.telephony.CellIdentityWcdma) CellIdentityTdscdma(android.telephony.CellIdentityTdscdma) CellIdentityNr(android.telephony.CellIdentityNr) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 15 with CellIdentityCdma

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

the class CellIdentityCdmaTest method testConstructor.

@SmallTest
public void testConstructor() {
    CellIdentityCdma ci = new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE, ALPHA_LONG, ALPHA_SHORT);
    assertEquals(NETWORK_ID, ci.getNetworkId());
    assertEquals(LATITUDE, ci.getLatitude());
    assertEquals(LONGITUDE, ci.getLongitude());
    assertEquals(ALPHA_LONG, ci.getOperatorAlphaLong());
    assertEquals(ALPHA_SHORT, ci.getOperatorAlphaShort());
    String globalCi = Integer.toString(SYSTEM_ID, 16) + Integer.toString(NETWORK_ID, 16) + Integer.toString(BASESTATION_ID, 16);
    assertEquals(globalCi, ci.getGlobalCellId());
}
Also used : CellIdentityCdma(android.telephony.CellIdentityCdma) SmallTest(android.test.suitebuilder.annotation.SmallTest)

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