Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dcda777c authored by Nathan Harold's avatar Nathan Harold Committed by android-build-merger
Browse files

Merge "Unit Tests for CellInfo Timestamp" am: d7826fe1 am: d6109046

am: 32ce5575

Change-Id: I17550a8c96e582be6b550b9eed0b429881223a9d
parents 85bdeb19 32ce5575
Loading
Loading
Loading
Loading
+86 −20
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ import org.mockito.MockitoAnnotations;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class RILTest extends TelephonyTest {

@@ -218,7 +219,7 @@ public class RILTest extends TelephonyTest {
    private static final int RSSI_ASU = 24;
    private static final int SYSTEM_ID = 65533;
    private static final int TAC = 65535;
    private static final int TIME_ADVANCE = 4;
    private static final int TIMING_ADVANCE = 4;
    private static final long TIMESTAMP = 215924934;
    private static final int UARFCN = 690;
    private static final int TYPE_CDMA = 2;
@@ -1158,7 +1159,7 @@ public class RILTest extends TelephonyTest {
        lte.signalStrengthLte.rsrq = -RSRQ;
        lte.signalStrengthLte.rssnr = RSSNR;
        lte.signalStrengthLte.cqi = CQI;
        lte.signalStrengthLte.timingAdvance = TIME_ADVANCE;
        lte.signalStrengthLte.timingAdvance = TIMING_ADVANCE;
        android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo();
        record.cellInfoType = TYPE_LTE;
        record.registered = false;
@@ -1179,7 +1180,7 @@ public class RILTest extends TelephonyTest {
        CellIdentityLte cil = new CellIdentityLte(CI, PCI, TAC, EARFCN, Integer.MAX_VALUE, MCC_STR,
                MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
        CellSignalStrengthLte css = new CellSignalStrengthLte(
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIME_ADVANCE);
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIMING_ADVANCE);
        expected.setCellIdentity(cil);
        expected.setCellSignalStrength(css);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_UNKNOWN);
@@ -1199,7 +1200,7 @@ public class RILTest extends TelephonyTest {
        cellinfo.cellIdentityGsm.mnc = MNC_STR;
        cellinfo.signalStrengthGsm.signalStrength = RSSI_ASU;
        cellinfo.signalStrengthGsm.bitErrorRate = BIT_ERROR_RATE;
        cellinfo.signalStrengthGsm.timingAdvance = TIME_ADVANCE;
        cellinfo.signalStrengthGsm.timingAdvance = TIMING_ADVANCE;
        android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo();
        record.cellInfoType = TYPE_GSM;
        record.registered = false;
@@ -1220,7 +1221,7 @@ public class RILTest extends TelephonyTest {
        CellIdentityGsm ci = new CellIdentityGsm(
                LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
        CellSignalStrengthGsm cs = new CellSignalStrengthGsm(
                RSSI, BIT_ERROR_RATE, TIME_ADVANCE);
                RSSI, BIT_ERROR_RATE, TIMING_ADVANCE);
        expected.setCellIdentity(ci);
        expected.setCellSignalStrength(cs);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_UNKNOWN);
@@ -1364,7 +1365,7 @@ public class RILTest extends TelephonyTest {
        CellIdentityLte cil = new CellIdentityLte(
                CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT);
        CellSignalStrengthLte css = new CellSignalStrengthLte(
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIME_ADVANCE);
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIMING_ADVANCE);
        expected.setCellIdentity(cil);
        expected.setCellSignalStrength(css);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
@@ -1385,7 +1386,7 @@ public class RILTest extends TelephonyTest {
        CellIdentityLte cil = new CellIdentityLte(CI, PCI, TAC, EARFCN, BANDWIDTH, MCC_STR, MNC_STR,
                EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
        CellSignalStrengthLte css = new CellSignalStrengthLte(
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIME_ADVANCE);
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIMING_ADVANCE);
        expected.setCellIdentity(cil);
        expected.setCellSignalStrength(css);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
@@ -1408,7 +1409,7 @@ public class RILTest extends TelephonyTest {
        CellIdentityLte cil = new CellIdentityLte(
                CI, PCI, TAC, EARFCN, BANDWIDTH, null, null, ALPHA_LONG, ALPHA_SHORT);
        CellSignalStrengthLte css = new CellSignalStrengthLte(
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIME_ADVANCE);
                RSSI, RSRP, RSRQ, RSSNR, CQI, TIMING_ADVANCE);
        expected.setCellIdentity(cil);
        expected.setCellSignalStrength(css);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
@@ -1428,7 +1429,7 @@ public class RILTest extends TelephonyTest {
        CellIdentityGsm ci = new CellIdentityGsm(
                LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT);
        CellSignalStrengthGsm cs = new CellSignalStrengthGsm(
                RSSI, BIT_ERROR_RATE, TIME_ADVANCE);
                RSSI, BIT_ERROR_RATE, TIMING_ADVANCE);
        expected.setCellIdentity(ci);
        expected.setCellSignalStrength(cs);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
@@ -1449,7 +1450,7 @@ public class RILTest extends TelephonyTest {
        CellIdentityGsm ci = new CellIdentityGsm(
                LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
        CellSignalStrengthGsm cs = new CellSignalStrengthGsm(
                RSSI, BIT_ERROR_RATE, TIME_ADVANCE);
                RSSI, BIT_ERROR_RATE, TIMING_ADVANCE);
        expected.setCellIdentity(ci);
        expected.setCellSignalStrength(cs);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
@@ -1472,7 +1473,7 @@ public class RILTest extends TelephonyTest {
        CellIdentityGsm ci = new CellIdentityGsm(
                LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT);
        CellSignalStrengthGsm cs = new CellSignalStrengthGsm(
                RSSI, BIT_ERROR_RATE, TIME_ADVANCE);
                RSSI, BIT_ERROR_RATE, TIMING_ADVANCE);
        expected.setCellIdentity(ci);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
        expected.setCellSignalStrength(cs);
@@ -1662,24 +1663,89 @@ public class RILTest extends TelephonyTest {
        assertEquals("100:foo", request.getWorkSourceClientId());
    }

    private ArrayList<CellInfo> getCellInfoListForLTE(
            String mcc, String mnc, String alphaLong, String alphaShort) {
        android.hardware.radio.V1_2.CellInfoLte lte = new android.hardware.radio.V1_2.CellInfoLte();
    @Test
    public void testCellInfoTimestamp_1_4() {
        ArrayList<android.hardware.radio.V1_4.CellInfo> records =
                new ArrayList<android.hardware.radio.V1_4.CellInfo>();

        for (int i = 0; i < 5 /* arbitrary */; i++) {
            android.hardware.radio.V1_4.CellInfo record =
                    new android.hardware.radio.V1_4.CellInfo();
            record.info = new android.hardware.radio.V1_4.CellInfo.Info();
            record.info.lte(new android.hardware.radio.V1_4.CellInfoLte());
            initializeCellInfoLte_1_2(record.info.lte().base);
            record.info.lte().base.cellIdentityLte.base.ci += i; // make them marginally unique

            records.add(record);
        }
        List<CellInfo> cil = RIL.convertHalCellInfoList_1_4(records);

        // Check that all timestamps are set to a valid number and are equal
        final long ts = cil.get(0).getTimeStamp();
        for (CellInfo ci : cil) {
            assertTrue(ci.getTimeStamp() > 0 && ci.getTimeStamp() != Long.MAX_VALUE);
            assertEquals(ci.getTimeStamp(), ts);
        }
    }

    @Test
    public void testCellInfoTimestamp_1_2() {
        ArrayList<android.hardware.radio.V1_2.CellInfo> records =
                new ArrayList<android.hardware.radio.V1_2.CellInfo>();

        for (int i = 0; i < 5 /* arbitrary */; i++) {
            android.hardware.radio.V1_2.CellInfo record =
                    new android.hardware.radio.V1_2.CellInfo();
            record.cellInfoType = TYPE_LTE;
            record.timeStamp = Long.MAX_VALUE;
            record.registered = false;
            record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL;
            record.lte.add(new android.hardware.radio.V1_2.CellInfoLte());
            initializeCellInfoLte_1_2(record.lte.get(0));
            record.lte.get(0).cellIdentityLte.base.ci += i; // make them marginally unique

            records.add(record);
        }
        List<CellInfo> cil = RIL.convertHalCellInfoList_1_2(records);

        // Check that all timestamps are set to a valid number and are equal
        final long ts = cil.get(0).getTimeStamp();
        for (CellInfo ci : cil) {
            assertTrue(ci.getTimeStamp() > 0 && ci.getTimeStamp() != Long.MAX_VALUE);
            assertEquals(ci.getTimeStamp(), ts);
        }
    }

    private static void initializeCellInfoLte_1_2(android.hardware.radio.V1_2.CellInfoLte lte) {
        lte.cellIdentityLte.base.ci = CI;
        lte.cellIdentityLte.base.pci = PCI;
        lte.cellIdentityLte.base.tac = TAC;
        lte.cellIdentityLte.base.earfcn = EARFCN;
        lte.cellIdentityLte.bandwidth = BANDWIDTH;
        lte.cellIdentityLte.base.mcc = mcc;
        lte.cellIdentityLte.base.mnc = mnc;
        lte.cellIdentityLte.operatorNames.alphaLong = alphaLong;
        lte.cellIdentityLte.operatorNames.alphaShort = alphaShort;
        lte.signalStrengthLte.signalStrength = RSSI_ASU;
        lte.signalStrengthLte.rsrp = -RSRP;
        lte.signalStrengthLte.rsrq = -RSRQ;
        lte.signalStrengthLte.rssnr = RSSNR;
        lte.signalStrengthLte.cqi = CQI;
        lte.signalStrengthLte.timingAdvance = TIME_ADVANCE;
        lte.signalStrengthLte.timingAdvance = TIMING_ADVANCE;

        lte.cellIdentityLte.operatorNames.alphaLong = ALPHA_LONG;
        lte.cellIdentityLte.operatorNames.alphaShort = ALPHA_SHORT;
        lte.cellIdentityLte.base.mcc = MCC_STR;
        lte.cellIdentityLte.base.mnc = MNC_STR;
    }

    private ArrayList<CellInfo> getCellInfoListForLTE(
            String mcc, String mnc, String alphaLong, String alphaShort) {
        android.hardware.radio.V1_2.CellInfoLte lte = new android.hardware.radio.V1_2.CellInfoLte();

        initializeCellInfoLte_1_2(lte);
        // Override the defaults for test-specific purposes
        lte.cellIdentityLte.operatorNames.alphaLong = alphaLong;
        lte.cellIdentityLte.operatorNames.alphaShort = alphaShort;
        lte.cellIdentityLte.base.mcc = mcc;
        lte.cellIdentityLte.base.mnc = mnc;

        android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo();
        record.cellInfoType = TYPE_LTE;
        record.registered = false;
@@ -1707,7 +1773,7 @@ public class RILTest extends TelephonyTest {
        cellinfo.cellIdentityGsm.operatorNames.alphaShort = alphaShort;
        cellinfo.signalStrengthGsm.signalStrength = RSSI_ASU;
        cellinfo.signalStrengthGsm.bitErrorRate = BIT_ERROR_RATE;
        cellinfo.signalStrengthGsm.timingAdvance = TIME_ADVANCE;
        cellinfo.signalStrengthGsm.timingAdvance = TIMING_ADVANCE;
        android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo();
        record.cellInfoType = TYPE_GSM;
        record.registered = false;