Search in sources :

Example 41 with CellIdentityGsm

use of android.telephony.CellIdentityGsm in project satstat by mvglasow.

the class CellTowerListGsm method update.

/**
 * Adds or updates a cell tower.
 * <p>
 * If the cell tower is already in the list, its data is updated; if not, a
 * new entry is created.
 * <p>
 * This method will set the cell's identity data, its signal strength and
 * whether it is the currently serving cell. If the API level is 18 or
 * higher, it will also set the generation.
 * @return The new or updated entry.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public CellTowerGsm update(CellInfoGsm cell) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
        return null;
    CellIdentityGsm cid = cell.getCellIdentity();
    CellTowerGsm result = null;
    CellTowerGsm cand = this.get(cid.getMcc(), cid.getMnc(), cid.getLac(), cid.getCid());
    if ((cand != null) && CellTower.matches(cid.getPsc(), cand.getPsc()))
        result = cand;
    if (result == null) {
        cand = this.get(cid.getPsc());
        if ((cand != null) && ((cid.getMcc() == Integer.MAX_VALUE) || CellTower.matches(cid.getMcc(), cand.getMcc())) && ((cid.getMnc() == Integer.MAX_VALUE) || CellTower.matches(cid.getMnc(), cand.getMnc())) && ((cid.getLac() == Integer.MAX_VALUE) || CellTower.matches(cid.getLac(), cand.getLac())) && ((cid.getCid() == Integer.MAX_VALUE) || CellTower.matches(cid.getCid(), cand.getCid())))
            result = cand;
    }
    if (result == null)
        result = new CellTowerGsm(cid.getMcc(), cid.getMnc(), cid.getLac(), cid.getCid(), cid.getPsc());
    if (result.getMcc() == CellTower.UNKNOWN)
        result.setMcc(cid.getMcc());
    if (result.getMnc() == CellTower.UNKNOWN)
        result.setMnc(cid.getMnc());
    if (result.getLac() == CellTower.UNKNOWN)
        result.setLac(cid.getLac());
    if (result.getCid() == CellTower.UNKNOWN)
        result.setCid(cid.getCid());
    if (result.getPsc() == CellTower.UNKNOWN)
        result.setPsc(cid.getPsc());
    this.put(result.getText(), result);
    this.put(result.getAltText(), result);
    result.setCellInfo(true);
    result.setDbm(cell.getCellSignalStrength().getDbm());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
        result.setGeneration(2);
    result.setServing(cell.isRegistered());
    if ((result.getText() == null) && (result.getAltText() == null))
        Log.d(this.getClass().getSimpleName(), String.format("Added %d G cell with no data from CellInfoGsm", result.getGeneration()));
    return result;
}
Also used : CellIdentityGsm(android.telephony.CellIdentityGsm) TargetApi(android.annotation.TargetApi)

Example 42 with CellIdentityGsm

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

the class RILTest method testConvertHalCellInfoList_1_2ForGSM.

@Test
public void testConvertHalCellInfoList_1_2ForGSM() {
    ArrayList<CellInfo> ret = getCellInfoListForGSM(MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT);
    assertEquals(1, ret.size());
    CellInfoGsm cellInfoGsm = (CellInfoGsm) ret.get(0);
    CellInfoGsm expected = new CellInfoGsm();
    expected.setRegistered(false);
    expected.setTimeStamp(TIMESTAMP);
    CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList());
    CellSignalStrengthGsm cs = new CellSignalStrengthGsm(RSSI, BIT_ERROR_RATE, TIMING_ADVANCE);
    expected.setCellIdentity(ci);
    expected.setCellSignalStrength(cs);
    expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
    // override the timestamp
    cellInfoGsm.setTimeStamp(TIMESTAMP);
    assertEquals(expected, cellInfoGsm);
}
Also used : CellInfo(android.telephony.CellInfo) CellSignalStrengthGsm(android.telephony.CellSignalStrengthGsm) CellIdentityGsm(android.telephony.CellIdentityGsm) CellInfoGsm(android.telephony.CellInfoGsm) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Example 43 with CellIdentityGsm

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

the class ServiceStateTrackerTest method testGetCidFromCellIdentity.

@Test
public void testGetCidFromCellIdentity() throws Exception {
    CellIdentity gsmCi = new CellIdentityGsm(0, 1, 0, 0, "", "", "", "", Collections.emptyList());
    CellIdentity wcdmaCi = new CellIdentityWcdma(0, 2, 0, 0, "", "", "", "", Collections.emptyList(), null);
    CellIdentity tdscdmaCi = new CellIdentityTdscdma("", "", 0, 3, 0, 0, "", "", Collections.emptyList(), null);
    CellIdentity lteCi = new CellIdentityLte(0, 0, 4, 0, 0);
    CellIdentity nrCi = new CellIdentityNr(0, 0, 0, new int[] {}, "", "", 5, "", "", Collections.emptyList());
    Method method = ServiceStateTracker.class.getDeclaredMethod("getCidFromCellIdentity", CellIdentity.class);
    method.setAccessible(true);
    assertEquals(1, (long) method.invoke(mSST, gsmCi));
    assertEquals(2, (long) method.invoke(mSST, wcdmaCi));
    assertEquals(3, (long) method.invoke(mSST, tdscdmaCi));
    assertEquals(4, (long) method.invoke(mSST, lteCi));
    assertEquals(5, (long) method.invoke(mSST, nrCi));
}
Also used : CellIdentityLte(android.telephony.CellIdentityLte) CellIdentity(android.telephony.CellIdentity) CellIdentityGsm(android.telephony.CellIdentityGsm) Method(java.lang.reflect.Method) CellIdentityWcdma(android.telephony.CellIdentityWcdma) CellIdentityTdscdma(android.telephony.CellIdentityTdscdma) CellIdentityNr(android.telephony.CellIdentityNr) FlakyTest(androidx.test.filters.FlakyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 44 with CellIdentityGsm

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

the class ServiceStateTrackerTest method testRatRatchetWithCellChangeBeforeRatChange.

// TODO(nharold): This actually seems like broken behavior; rather than preserve it, we should
// probably remove it.
// GSM, Edge, GPRS are grouped under the same family where Edge > GPRS > GSM.
// Expect no rat update from E to G immediately following cell id change.
// Expect ratratchet (from G to E) for the following rat update within the cell location.
@Test
public void testRatRatchetWithCellChangeBeforeRatChange() throws Exception {
    // cell ID update
    CellIdentityGsm cellIdentity = new CellIdentityGsm(0, 1, 900, 5, "001", "01", "test", "tst", Collections.emptyList());
    changeRegState(1, cellIdentity, 16, 2);
    assertEquals(ServiceState.STATE_IN_SERVICE, sst.getCurrentDataConnectionState());
    assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_EDGE, sst.mSS.getRilDataRadioTechnology());
    // RAT: EDGE -> GPRS, cell ID unchanged. Expect no rat ratchet following cell Id change.
    changeRegState(1, cellIdentity, 16, 1);
    assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_GPRS, sst.mSS.getRilDataRadioTechnology());
    // RAT: GPRS -> EDGE should ratchet.
    changeRegState(1, cellIdentity, 16, 2);
    assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_EDGE, sst.mSS.getRilDataRadioTechnology());
}
Also used : 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 45 with CellIdentityGsm

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

the class ServiceStateTrackerTest method testRatRatchetWithCellChange.

// Edge and GPRS are grouped under the same family and Edge has higher rate than GPRS.
// Bypass rat rachet when cell id changed. Expect rat update from E to G
@Test
public void testRatRatchetWithCellChange() throws Exception {
    CellIdentityGsm cellIdentity = new CellIdentityGsm(0, 1, 900, 5, "001", "01", "test", "tst", Collections.emptyList());
    // update data reg state to be in service
    changeRegState(1, cellIdentity, 16, 2);
    assertEquals(ServiceState.STATE_IN_SERVICE, sst.getCurrentDataConnectionState());
    assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_GSM, sst.mSS.getRilVoiceRadioTechnology());
    assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_EDGE, sst.mSS.getRilDataRadioTechnology());
    // RAT: EDGE -> GPRS cell ID: 1 -> 2
    cellIdentity = new CellIdentityGsm(0, 2, 900, 5, "001", "01", "test", "tst", Collections.emptyList());
    changeRegState(1, cellIdentity, 16, 1);
    assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_GPRS, sst.mSS.getRilDataRadioTechnology());
}
Also used : 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)

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