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

Commit d8364b13 authored by Mingming Cai's avatar Mingming Cai Committed by Automerger Merge Worker
Browse files

Merge "Use new global cell ID for hasLocationChanged" am: 99ba3d7f

Change-Id: I1773e01d257298eccee3c1a36b0c5e3e0b162028
parents e3e255e6 99ba3d7f
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -123,7 +123,6 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -3230,11 +3229,8 @@ public class ServiceStateTracker extends Handler {
                mNewSS.getNetworkRegistrationInfo(
                        NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkType.EUTRAN));

        // TODO: loosen this restriction to exempt fields that are provided through system
        // information; otherwise, we will get false positives when things like the operator
        // alphas are provided later - that's better than missing location changes, but
        // still not ideal.
        boolean hasLocationChanged = !Objects.equals(mNewCellIdentity, mCellIdentity);
        boolean hasLocationChanged = (mCellIdentity == null ? mNewCellIdentity != null
                : !mCellIdentity.isSameCell(mNewCellIdentity));

        // ratchet the new tech up through its rat family but don't drop back down
        // until cell change or device is OOS
+5 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.test.suitebuilder.annotation.SmallTest;
/** Unit tests for {@link CellIdentityCdma}. */

public class CellIdentityCdmaTest extends AndroidTestCase {
    private static final String LOG_TAG = "CellIdentityCdmaTest";

    // Network Id ranges from 0 to 65535.
    private static final int NETWORK_ID  = 65535;
@@ -51,6 +52,10 @@ public class CellIdentityCdmaTest extends AndroidTestCase {
        assertEquals(LONGITUDE, ci.getLongitude());
        assertEquals(ALPHA_LONG, ci.getOperatorAlphaLong());
        assertEquals(ALPHA_SHORT, ci.getOperatorAlphaShort());

        String globalCi = Integer.toString(SYSTEM_ID, 16) + Integer.toString(NETWORK_ID, 16)
                + Integer.toString(BASESTATION_ID, 16);
        assertEquals(globalCi, ci.getGlobalCellId());
    }

    @SmallTest
+44 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import java.util.Collections;

/** Unit tests for {@link CellIdentityGsm}. */
public class CellIdentityGsmTest extends AndroidTestCase {
    private static final String LOG_TAG = "CellIdentityGsmTest";

    // Location Area Code ranges from 0 to 65535.
    private static final int LAC = 65535;
@@ -60,6 +61,10 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        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()));
    }

    @SmallTest
@@ -74,6 +79,10 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        assertEquals(MCC_STR, ci.getMccString());
        assertEquals(mncWithThreeDigit, ci.getMncString());
        assertEquals(MCC_STR + mncWithThreeDigit, ci.getMobileNetworkOperator());

        String globalCi = MCC_STR + mncWithThreeDigit + Integer.toString(LAC, 16)
                + Integer.toString(CID, 16);
        assertEquals(globalCi, ci.getGlobalCellId());
    }

    @SmallTest
@@ -88,6 +97,10 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        assertEquals(MCC_STR, ci.getMccString());
        assertEquals(mncWithTwoDigit, ci.getMncString());
        assertEquals(MCC_STR + mncWithTwoDigit, ci.getMobileNetworkOperator());

        String globalCi = MCC_STR + mncWithTwoDigit + Integer.toString(LAC, 16)
                + Integer.toString(CID, 16);
        assertEquals(globalCi, ci.getGlobalCellId());
    }

    @SmallTest
@@ -101,6 +114,7 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        assertNull(ci.getMccString());
        assertNull(ci.getMncString());
        assertNull(ci.getMobileNetworkOperator());
        assertNull(ci.getGlobalCellId());

        ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, null, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList());
@@ -110,6 +124,7 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        assertEquals(MCC_STR, ci.getMccString());
        assertNull(ci.getMncString());
        assertNull(ci.getMobileNetworkOperator());
        assertNull(ci.getGlobalCellId());

        ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, MNC_STR, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList());
@@ -119,6 +134,7 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        assertEquals(MNC_STR, ci.getMncString());
        assertNull(ci.getMccString());
        assertNull(ci.getMobileNetworkOperator());
        assertNull(ci.getGlobalCellId());

        ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, "", "", ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList());
@@ -128,6 +144,7 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        assertNull(ci.getMccString());
        assertNull(ci.getMncString());
        assertNull(ci.getMobileNetworkOperator());
        assertNull(ci.getGlobalCellId());
    }

    @SmallTest
@@ -200,4 +217,31 @@ public class CellIdentityGsmTest extends AndroidTestCase {
        CellIdentityGsm newCi = CellIdentityGsm.CREATOR.createFromParcel(p);
        assertEquals(ci, newCi);
    }

    @SmallTest
    public void testgetGlobalCellId() {
        CellIdentityGsm ci = new CellIdentityGsm(
                LAC + 1, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList());
        assertNull(ci.getGlobalCellId());

        ci = new CellIdentityGsm(
                LAC, CID + 1, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList());
        assertNull(ci.getGlobalCellId());

        ci = new CellIdentityGsm(
                LAC, -1, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList());
        assertNull(ci.getGlobalCellId());

        // Test id with one digit and corresponding zero padding
        int cid = 1;
        ci = new CellIdentityGsm(
                LAC, cid, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT,
                Collections.emptyList());
        String globalCi = MCC_STR + MNC_STR + Integer.toString(LAC, 16)
                + "000" + Integer.toString(cid, 16);
        assertEquals(globalCi, ci.getGlobalCellId());
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import java.util.Collections;
/** Unit tests for {@link CellIdentityLte}. */

public class CellIdentityLteTest extends AndroidTestCase {
    private static final String LOG_TAG = "CellIdentityLteTest";

    // Cell identity ranges from 0 to 268435455.
    private static final int CI = 268435455;
@@ -64,6 +65,9 @@ public class CellIdentityLteTest extends AndroidTestCase {
        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(CI, 16);
        assertEquals(globalCi, ci.getGlobalCellId());
    }

    @SmallTest
+18 −15
Original line number Diff line number Diff line
@@ -30,10 +30,11 @@ import java.util.Arrays;
import java.util.Collections;

public class CellIdentityNrTest extends AndroidTestCase {
    private static final String MCC = "310";
    private static final String MNC = "260";
    private static final String ANOTHER_MCC = "134";
    private static final String ANOTHER_MNC = "256";
    private static final String LOG_TAG = "CellIdentityNrTest";
    private static final String MCC_STR = "310";
    private static final String MNC_STR = "260";
    private static final String ANOTHER_MCC_STR = "134";
    private static final String ANOTHER_MNC_STR = "256";
    private static final String ALPHAL = "long operator name";
    private static final String ALPHAS = "lon";
    private static final int NRARFCN = 13456;
@@ -49,7 +50,7 @@ public class CellIdentityNrTest extends AndroidTestCase {
    public void testGetMethod() {
        // GIVEN an instance of CellIdentityNr
        CellIdentityNr cellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC, MNC, NCI, ALPHAL, ALPHAS,
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI, ALPHAL, ALPHAS,
                        Collections.emptyList());

        // THEN the get method should return correct value
@@ -59,20 +60,22 @@ public class CellIdentityNrTest extends AndroidTestCase {
        assertThat(cellIdentityNr.getTac()).isEqualTo(TAC);
        assertThat(cellIdentityNr.getOperatorAlphaLong()).isEqualTo(ALPHAL);
        assertThat(cellIdentityNr.getOperatorAlphaShort()).isEqualTo(ALPHAS);
        assertThat(cellIdentityNr.getMccString()).isEqualTo(MCC);
        assertThat(cellIdentityNr.getMncString()).isEqualTo(MNC);
        assertThat(cellIdentityNr.getMncString()).isEqualTo(MNC);
        assertThat(cellIdentityNr.getMccString()).isEqualTo(MCC_STR);
        assertThat(cellIdentityNr.getMncString()).isEqualTo(MNC_STR);
        assertThat(cellIdentityNr.getNci()).isEqualTo(NCI);

        String globalCi = MCC_STR + MNC_STR + "000" + Integer.toString(NCI, 16);
        assertEquals(globalCi, cellIdentityNr.getGlobalCellId());
    }

    @Test
    public void testEquals_sameParameters() {
        // GIVEN an instance of CellIdentityNr, and create another object with the same parameters
        CellIdentityNr cellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC, MNC, NCI,
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI,
                        ALPHAL, ALPHAS, Collections.emptyList());
        CellIdentityNr anotherCellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC, MNC, NCI,
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI,
                        ALPHAL, ALPHAS, Collections.emptyList());

        // THEN this two objects are equivalent
@@ -83,10 +86,10 @@ public class CellIdentityNrTest extends AndroidTestCase {
    public void testEquals_differentParameters() {
        // GIVEN an instance of CellIdentityNr, and create another object with different parameters
        CellIdentityNr cellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC, MNC, NCI,
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI,
                        ALPHAL, ALPHAS, Collections.emptyList());
        CellIdentityNr anotherCellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC, MNC, NCI + 1,
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI + 1,
                        ALPHAL, ALPHAS, Collections.emptyList());

        // THEN this two objects are different
@@ -97,7 +100,7 @@ public class CellIdentityNrTest extends AndroidTestCase {
    public void testParcel() {
        // GIVEN an instance of CellIdentityNr
        CellIdentityNr cellIdentityNr =
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC, MNC, NCI,
                new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI,
                        ALPHAL, ALPHAS, Collections.emptyList());

        // WHEN write the object to parcel and create another object with that parcel
@@ -115,8 +118,8 @@ public class CellIdentityNrTest extends AndroidTestCase {
        assertTrue(Arrays.equals(anotherCellIdentityNr.getBands(), BANDS));
        assertThat(anotherCellIdentityNr.getOperatorAlphaLong()).isEqualTo(ALPHAL);
        assertThat(anotherCellIdentityNr.getOperatorAlphaShort()).isEqualTo(ALPHAS);
        assertThat(anotherCellIdentityNr.getMccString()).isEqualTo(MCC);
        assertThat(anotherCellIdentityNr.getMncString()).isEqualTo(MNC);
        assertThat(anotherCellIdentityNr.getMccString()).isEqualTo(MCC_STR);
        assertThat(anotherCellIdentityNr.getMncString()).isEqualTo(MNC_STR);
        assertThat(anotherCellIdentityNr.getNci()).isEqualTo(NCI);
    }
}
Loading