Search in sources :

Example 11 with CellIdentityGsm

use of android.telephony.CellIdentityGsm in project platform_packages_apps_Settings by BlissRoms.

the class RadioInfo method buildGsmInfoString.

private final String buildGsmInfoString(CellInfoGsm ci) {
    CellIdentityGsm cidGsm = ci.getCellIdentity();
    CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
    return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", ci.isRegistered() ? "S  " : "   ", getCellInfoDisplayString(cidGsm.getMcc()), getCellInfoDisplayString(cidGsm.getMnc()), getCellInfoDisplayString(cidGsm.getLac()), getCellInfoDisplayString(cidGsm.getCid()), getCellInfoDisplayString(cidGsm.getArfcn()), getCellInfoDisplayString(cidGsm.getBsic()), getCellInfoDisplayString(ssGsm.getDbm()));
}
Also used : CellSignalStrengthGsm(android.telephony.CellSignalStrengthGsm) CellIdentityGsm(android.telephony.CellIdentityGsm)

Example 12 with CellIdentityGsm

use of android.telephony.CellIdentityGsm in project assertj-android by square.

the class CellInfoGsmAssert method hasCellIdentity.

public CellInfoGsmAssert hasCellIdentity(CellIdentityGsm cellIdentity) {
    isNotNull();
    CellIdentityGsm actualCellIdentity = actual.getCellIdentity();
    // 
    assertThat(actualCellIdentity).overridingErrorMessage("Expected cell identity <%s> but was <%s>.", cellIdentity, // 
    actualCellIdentity).isEqualTo(cellIdentity);
    return this;
}
Also used : CellIdentityGsm(android.telephony.CellIdentityGsm)

Example 13 with CellIdentityGsm

use of android.telephony.CellIdentityGsm 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 14 with CellIdentityGsm

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

the class CellInfoUtil method convertOperatorInfoToCellInfo.

/**
 * Creates a CellInfo object from OperatorInfo. GsmCellInfo is used here only because
 * operatorInfo does not contain technology type while CellInfo is an abstract object that
 * requires to specify technology type. It doesn't matter which CellInfo type to use here, since
 * we only want to wrap the operator info and PLMN to a CellInfo object.
 */
public static CellInfo convertOperatorInfoToCellInfo(OperatorInfo operatorInfo) {
    String operatorNumeric = operatorInfo.getOperatorNumeric();
    String mcc = null;
    String mnc = null;
    if (operatorNumeric != null && operatorNumeric.matches("^[0-9]{5,6}$")) {
        mcc = operatorNumeric.substring(0, 3);
        mnc = operatorNumeric.substring(3);
    }
    CellIdentityGsm cig = new CellIdentityGsm(Integer.MAX_VALUE, /* lac */
    Integer.MAX_VALUE, /* cid */
    Integer.MAX_VALUE, /* arfcn */
    Integer.MAX_VALUE, /* bsic */
    mcc, mnc, operatorInfo.getOperatorAlphaLong(), operatorInfo.getOperatorAlphaShort());
    CellInfoGsm ci = new CellInfoGsm();
    ci.setCellIdentity(cig);
    return ci;
}
Also used : CellIdentityGsm(android.telephony.CellIdentityGsm) CellInfoGsm(android.telephony.CellInfoGsm)

Example 15 with CellIdentityGsm

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

Aggregations

CellIdentityGsm (android.telephony.CellIdentityGsm)53 CellInfoGsm (android.telephony.CellInfoGsm)25 CellSignalStrengthGsm (android.telephony.CellSignalStrengthGsm)20 SmallTest (android.test.suitebuilder.annotation.SmallTest)19 CellIdentityCdma (android.telephony.CellIdentityCdma)16 CellIdentityLte (android.telephony.CellIdentityLte)16 CellInfo (android.telephony.CellInfo)16 CellIdentityWcdma (android.telephony.CellIdentityWcdma)14 CellInfoCdma (android.telephony.CellInfoCdma)14 CellInfoLte (android.telephony.CellInfoLte)13 Test (org.junit.Test)13 CellInfoWcdma (android.telephony.CellInfoWcdma)12 FlakyTest (androidx.test.filters.FlakyTest)11 CellSignalStrengthCdma (android.telephony.CellSignalStrengthCdma)6 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 PendingIntent (android.app.PendingIntent)5 Intent (android.content.Intent)5 WifiInfo (android.net.wifi.WifiInfo)5 Parcel (android.os.Parcel)4 CellIdentity (android.telephony.CellIdentity)4