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

Commit 4cca0d3d authored by Sooraj Sasindran's avatar Sooraj Sasindran
Browse files

Do not use IWLAN mcc for location

IWLAN mcc is not reliable and should not be used to report location.

Bug: 241318351
Test: atest ServiceStateTrackerTest
Change-Id: Iab1559a901400b5707301d6fd1c33267bb35158b
parent 4c5c285d
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -3784,8 +3784,10 @@ public class ServiceStateTracker extends Handler {
            // incomplete.
            // CellIdentity can return a null MCC and MNC in CDMA
            String localeOperator = operatorNumeric;
            if (isInvalidOperatorNumeric(operatorNumeric)
                    || mSS.getDataNetworkType() == TelephonyManager.NETWORK_TYPE_IWLAN) {
            if (mSS.getDataNetworkType() == TelephonyManager.NETWORK_TYPE_IWLAN) {
                localeOperator = null;
            }
            if (isInvalidOperatorNumeric(localeOperator)) {
                for (CellIdentity cid : prioritizedCids) {
                    if (!TextUtils.isEmpty(cid.getPlmn())) {
                        localeOperator = cid.getPlmn();
+67 −0
Original line number Diff line number Diff line
@@ -2348,6 +2348,73 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN, sst.mSS.getRilDataRadioTechnology());
    }

    private void changeRegStateWithIwlanOperatorNumeric(int psState, int psRat, int wlanState,
            String[] opNamesResult, boolean passCellId) {
        LteVopsSupportInfo lteVopsSupportInfo =
                new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE,
                        LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE);
        CellIdentityLte cellIdentity =
                new CellIdentityLte(1, 1, 5, 1, new int[] {1, 2}, 5000, "001", "01", "test",
                        "tst", Collections.emptyList(), null);
        if (!passCellId) {
            cellIdentity = null;
        }
        sst.mPollingContext[0] = 3;
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_OPERATOR,
                new AsyncResult(sst.mPollingContext, opNamesResult, null)));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());


        // PS WWAN
        NetworkRegistrationInfo dataResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                psState, psRat, 0, false, null, cellIdentity,
                getPlmnFromCellIdentity(cellIdentity),
                1, false, false, false, lteVopsSupportInfo);
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION,
                new AsyncResult(sst.mPollingContext, dataResult, null)));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());

        // PS WLAN
        NetworkRegistrationInfo dataIwlanResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN,
                wlanState, TelephonyManager.NETWORK_TYPE_IWLAN, 0, false,
                null, null, "", 1, false, false, false, lteVopsSupportInfo);
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_PS_IWLAN_REGISTRATION,
                new AsyncResult(sst.mPollingContext, dataIwlanResult, null)));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
        assertEquals(opNamesResult[0], sst.getServiceState().getOperatorAlpha());
        assertEquals(opNamesResult[2], sst.getServiceState().getOperatorNumeric());
        verify(mLocaleTracker).updateOperatorNumeric(eq(opNamesResult[2]));
    }

    /**
     * Ensure that LocaleTracker is not updated with mcc when only IWLAN is in service
     */
    @Test
    public void testLocaleTrackerUpdateWithIWLANInService() {
        // Start state: Cell data only LTE + IWLAN
        final String[] OpNamesResult = new String[] { "carrier long", "carrier", "310310" };
        changeRegStateWithIwlanOperatorNumeric(NetworkRegistrationInfo.REGISTRATION_STATE_HOME,
                TelephonyManager.NETWORK_TYPE_LTE,
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, OpNamesResult, true);
        verify(mLocaleTracker).updateOperatorNumeric(eq(OpNamesResult[2]));
        changeRegStateWithIwlanOperatorNumeric(
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING,
                TelephonyManager.NETWORK_TYPE_LTE,
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, OpNamesResult, true);
        /* cellId based mccmnc */
        verify(mLocaleTracker).updateOperatorNumeric(eq("00101"));
        changeRegStateWithIwlanOperatorNumeric(
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING,
                TelephonyManager.NETWORK_TYPE_LTE,
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, OpNamesResult, false);
        verify(mLocaleTracker).updateOperatorNumeric(eq(""));
    }

    @Test
    public void testGetServiceProviderNameWithBrandOverride() {
        String brandOverride = "spn from brand override";