Search in sources :

Example 21 with CellIdentityGsm

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

the class CellIdentityGsmTest method testDefaultConstructor.

@SmallTest
public void testDefaultConstructor() {
    CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList());
    assertEquals(LAC, ci.getLac());
    assertEquals(CID, ci.getCid());
    assertEquals(ARFCN, ci.getArfcn());
    assertEquals(ARFCN, ci.getChannelNumber());
    assertEquals(BSIC, ci.getBsic());
    assertEquals(MCC, ci.getMcc());
    assertEquals(MNC, ci.getMnc());
    assertEquals(MCC_STR, ci.getMccString());
    assertEquals(MNC_STR, ci.getMncString());
    assertEquals(MCC_STR + MNC_STR, ci.getMobileNetworkOperator());
    assertEquals(ALPHA_LONG, ci.getOperatorAlphaLong());
    assertEquals(ALPHA_SHORT, ci.getOperatorAlphaShort());
    String globalCi = MCC_STR + MNC_STR + Integer.toString(LAC, 16) + Integer.toString(CID, 16);
    assertTrue(globalCi.equals(ci.getGlobalCellId()));
}
Also used : CellIdentityGsm(android.telephony.CellIdentityGsm) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 22 with CellIdentityGsm

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

the class CellIdentityTest method testConstructCellIdentityGsm.

@SmallTest
public void testConstructCellIdentityGsm() {
    // Test values below zero (these must all be non-negative)
    CellIdentityGsm gsm = new CellIdentityGsm(-1, -1, -1, -1, null, null, null, null, Collections.emptyList());
    assertEquals(CellInfo.UNAVAILABLE, gsm.getLac());
    assertEquals(CellInfo.UNAVAILABLE, gsm.getCid());
    assertEquals(CellInfo.UNAVAILABLE, gsm.getArfcn());
    assertEquals(CellInfo.UNAVAILABLE, gsm.getBsic());
    // Test max values of LAC, CID, ARFCN, and BSIC
    gsm = new CellIdentityGsm(MAX_LAC, MAX_CID, MAX_ARFCN, MAX_BSIC, null, null, null, null, Collections.emptyList());
    assertEquals(MAX_LAC, gsm.getLac());
    assertEquals(MAX_CID, gsm.getCid());
    assertEquals(MAX_ARFCN, gsm.getArfcn());
    assertEquals(MAX_BSIC, gsm.getBsic());
    // Test max values + 1 of LAC, CID, ARFCN, and BSIC
    gsm = new CellIdentityGsm(MAX_LAC + 1, MAX_CID + 1, MAX_ARFCN + 1, MAX_BSIC + 1, null, null, null, null, Collections.emptyList());
    assertEquals(CellInfo.UNAVAILABLE, gsm.getLac());
    assertEquals(CellInfo.UNAVAILABLE, gsm.getCid());
    assertEquals(CellInfo.UNAVAILABLE, gsm.getArfcn());
    assertEquals(CellInfo.UNAVAILABLE, gsm.getBsic());
}
Also used : CellIdentityGsm(android.telephony.CellIdentityGsm) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 23 with CellIdentityGsm

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

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

the class ServiceStateTrackerTest method testCellIdentitySort.

@Test
public void testCellIdentitySort() {
    final CellIdentityLte cellIdentityLte = new CellIdentityLte(1, 1, 5, 1, new int[] { 1, 2 }, 5000, "001", "01", "test", "tst", Collections.emptyList(), null);
    final CellIdentityGsm cellIdentityGsm = new CellIdentityGsm(2, 3, 900, 5, "001", "01", "test", "tst", Collections.emptyList());
    ServiceState ss = new ServiceState();
    List<CellIdentity> cids;
    // Test that PS WWAN is reported if available
    ss.addNetworkRegistrationInfo(makeNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, cellIdentityLte, false));
    cids = ServiceStateTracker.getPrioritizedCellIdentities(ss);
    assertEquals(cids.size(), 1);
    assertEquals(cids.get(0), cellIdentityLte);
    // Test that CS is prioritized over PS
    ss.addNetworkRegistrationInfo(makeNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, cellIdentityGsm, false));
    cids = ServiceStateTracker.getPrioritizedCellIdentities(ss);
    assertEquals(cids.size(), 2);
    assertEquals(cids.get(0), cellIdentityGsm);
    assertEquals(cids.get(1), cellIdentityLte);
    // Test that WLAN is ignored
    ss.addNetworkRegistrationInfo(makeNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN, cellIdentityGsm, false));
    cids = ServiceStateTracker.getPrioritizedCellIdentities(ss);
    assertEquals(cids.size(), 2);
    assertEquals(cids.get(0), cellIdentityGsm);
    assertEquals(cids.get(1), cellIdentityLte);
    // Test that null CellIdentities are ignored
    ss.addNetworkRegistrationInfo(makeNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN, null, false));
    cids = ServiceStateTracker.getPrioritizedCellIdentities(ss);
    assertEquals(cids.size(), 2);
    assertEquals(cids.get(0), cellIdentityGsm);
    assertEquals(cids.get(1), cellIdentityLte);
    // Test that registered networks are prioritized over unregistered
    ss.addNetworkRegistrationInfo(makeNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, cellIdentityLte, true));
    cids = ServiceStateTracker.getPrioritizedCellIdentities(ss);
    assertEquals(cids.size(), 2);
    assertEquals(cids.get(0), cellIdentityLte);
    assertEquals(cids.get(1), cellIdentityGsm);
}
Also used : ServiceState(android.telephony.ServiceState) CellIdentityLte(android.telephony.CellIdentityLte) CellIdentity(android.telephony.CellIdentity) CellIdentityGsm(android.telephony.CellIdentityGsm) FlakyTest(androidx.test.filters.FlakyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 25 with CellIdentityGsm

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

the class ServiceStateTrackerTest method getCellInfoGsm.

private CellInfoGsm getCellInfoGsm() {
    CellInfoGsm tmp = new CellInfoGsm();
    tmp.setCellIdentity(new CellIdentityGsm(0, 1, 900, 5, "001", "01", "test", "tst", Collections.emptyList()));
    tmp.setCellSignalStrength(new CellSignalStrengthGsm(-85, 2, 3));
    return tmp;
}
Also used : CellSignalStrengthGsm(android.telephony.CellSignalStrengthGsm) CellIdentityGsm(android.telephony.CellIdentityGsm) CellInfoGsm(android.telephony.CellInfoGsm)

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