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()));
}
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());
}
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);
}
}
}
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);
}
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;
}
Aggregations