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

Commit 3437eba2 authored by Nathan Harold's avatar Nathan Harold
Browse files

Add Registered PLMN to NetworkRegistrationInfo

-Add the Registered PLMN field to construction of
 NetworkRegistrationInfo.
-Update unit tests to match the updated builder.

Bug: 135921133
Test: atest FrameworksTelephonyTests
Merged-In: I56cc6cd16f8f72930e2d9e7817a46ea096a819b0
Change-Id: I56cc6cd16f8f72930e2d9e7817a46ea096a819b0
(cherry picked from commit e2ef4473)
parent b2726468
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.telephony;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.hardware.radio.V1_0.RegState;
import android.hardware.radio.V1_4.DataRegStateResult.VopsInfo.hidl_discriminator;
import android.os.AsyncResult;
@@ -25,6 +27,7 @@ import android.os.Message;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.CellIdentity;
import android.telephony.CellIdentityCdma;
import android.telephony.LteVopsSupportInfo;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.NetworkService;
@@ -32,6 +35,9 @@ import android.telephony.NetworkServiceCallback;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import com.android.telephony.Rlog;

import com.android.telephony.Rlog;

@@ -195,6 +201,17 @@ public class CellularNetworkService extends NetworkService {
            }
        }

        private @NonNull String getPlmnFromCellIdentity(@Nullable final CellIdentity ci) {
            if (ci == null || ci instanceof CellIdentityCdma) return "";

            final String mcc = ci.getMccString();
            final String mnc = ci.getMncString();

            if (TextUtils.isEmpty(mcc) || TextUtils.isEmpty(mnc)) return "";

            return mcc + mnc;
        }

        private NetworkRegistrationInfo createRegistrationStateFromVoiceRegState(Object result) {
            int transportType = AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
            int domain = NetworkRegistrationInfo.DOMAIN_CS;
@@ -216,10 +233,11 @@ public class CellularNetworkService extends NetworkService {
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity = CellIdentity.create(voiceRegState.cellIdentity);
                final String rplmn = getPlmnFromCellIdentity(cellIdentity);

                return new NetworkRegistrationInfo(domain, transportType, regState,
                        networkType, reasonForDenial, emergencyOnly, availableServices,
                        cellIdentity, cssSupported, roamingIndicator, systemIsInPrl,
                        cellIdentity, rplmn, cssSupported, roamingIndicator, systemIsInPrl,
                        defaultRoamingIndicator);
            } else if (result instanceof android.hardware.radio.V1_2.VoiceRegStateResult) {
                android.hardware.radio.V1_2.VoiceRegStateResult voiceRegState =
@@ -238,10 +256,11 @@ public class CellularNetworkService extends NetworkService {
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity = CellIdentity.create(voiceRegState.cellIdentity);
                final String rplmn = getPlmnFromCellIdentity(cellIdentity);

                return new NetworkRegistrationInfo(domain, transportType, regState,
                        networkType, reasonForDenial, emergencyOnly, availableServices,
                        cellIdentity, cssSupported, roamingIndicator, systemIsInPrl,
                        cellIdentity, rplmn, cssSupported, roamingIndicator, systemIsInPrl,
                        defaultRoamingIndicator);
            }

@@ -318,6 +337,7 @@ public class CellularNetworkService extends NetworkService {
                return null;
            }

            String rplmn = getPlmnFromCellIdentity(cellIdentity);
            List<Integer> availableServices = getAvailableServices(
                    regState, domain, emergencyOnly);

@@ -327,9 +347,9 @@ public class CellularNetworkService extends NetworkService {
            }

            return new NetworkRegistrationInfo(domain, transportType, regState, networkType,
                    reasonForDenial, emergencyOnly, availableServices, cellIdentity, maxDataCalls,
                    isDcNrRestricted, isNrAvailable, isEndcAvailable, lteVopsSupportInfo,
                    isUsingCarrierAggregation);
                    reasonForDenial, emergencyOnly, availableServices, cellIdentity, rplmn,
                    maxDataCalls, isDcNrRestricted, isNrAvailable, isEndcAvailable,
                    lteVopsSupportInfo, isUsingCarrierAggregation);
        }

        private LteVopsSupportInfo convertHalLteVopsSupportInfo(
+2 −2
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ public class CellularNetworkServiceTest extends TelephonyTest {
        NetworkRegistrationInfo expectedState = new NetworkRegistrationInfo(
                domain, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, voiceRegState,
                ServiceState.rilRadioTechnologyToNetworkType(voiceRadioTech), reasonForDenial,
                false, availableServices, null, cssSupported,
                false, availableServices, null, "", cssSupported,
                roamingIndicator, systemIsInPrl, defaultRoamingIndicator);

        try {
@@ -160,7 +160,7 @@ public class CellularNetworkServiceTest extends TelephonyTest {
        expectedState = new NetworkRegistrationInfo(
                domain, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, voiceRegState,
                ServiceState.rilRadioTechnologyToNetworkType(voiceRadioTech), reasonForDenial,
                false, availableServices, null, maxDataCalls, false, false, false,
                false, availableServices, null, "", maxDataCalls, false, false, false,
                lteVopsSupportInfo, false);

        try {
+16 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ public class NetworkRegistrationInfoTest {
                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
                .setAvailableServices(Arrays.asList(NetworkRegistrationInfo.SERVICE_TYPE_DATA))
                .setCellIdentity(new CellIdentityLte())
                .setRegisteredPlmn("12345")
                .build();

        Parcel p = Parcel.obtain();
@@ -52,4 +53,19 @@ public class NetworkRegistrationInfoTest {
        NetworkRegistrationInfo newNrs = NetworkRegistrationInfo.CREATOR.createFromParcel(p);
        assertEquals(nri, newNrs);
    }


    @Test
    @SmallTest
    public void testDefaultValues() {
        NetworkRegistrationInfo nri = new NetworkRegistrationInfo.Builder().build();
        assertEquals("", nri.getRegisteredPlmn());
    }

    @Test
    @SmallTest
    public void testBuilder() {
        assertEquals("12345", new NetworkRegistrationInfo.Builder()
                .setRegisteredPlmn("12345").build().getRegisteredPlmn());
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -304,7 +304,7 @@ public class ServiceStateTest extends TestCase {
        NetworkRegistrationInfo wwanVoiceRegState = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                0, 0, 0, false,
                null, null, true, 0, 0, 0);
                null, null, "", true, 0, 0, 0);

        LteVopsSupportInfo lteVopsSupportInfo =
                new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE,
@@ -335,7 +335,7 @@ public class ServiceStateTest extends TestCase {

        wwanDataRegState = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                0, 0, 0, true, null, null, 0, false, false, false, lteVopsSupportInfo, false);
                0, 0, 0, true, null, null, "", 0, false, false, false, lteVopsSupportInfo, false);
        ss.addNetworkRegistrationInfo(wwanDataRegState);
        assertEquals(ss.getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS,
                AccessNetworkConstants.TRANSPORT_TYPE_WWAN), wwanDataRegState);
+29 −16
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.TextUtils;
import android.util.Pair;

import androidx.test.filters.FlakyTest;
@@ -336,6 +337,17 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        super.tearDown();
    }

    private static String getPlmnFromCellIdentity(final CellIdentity ci) {
        if (ci == null || ci instanceof CellIdentityCdma) return "";

        final String mcc = ci.getMccString();
        final String mnc = ci.getMncString();

        if (TextUtils.isEmpty(mcc) || TextUtils.isEmpty(mnc)) return "";

        return mcc + mnc;
    }

    @Test
    @MediumTest
    public void testSetRadioPower() {
@@ -879,6 +891,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                .setCellIdentity(cellIdentityGsm)
                .setRegisteredPlmn("00101")
                .build();

        sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_GET_LOC_DONE,
@@ -1890,8 +1903,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {
                    LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE);
        NetworkRegistrationInfo dataResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                state, dataRat, 0, false,
                null, cid, 1, false, false, false, lteVopsSupportInfo, false);
                state, dataRat, 0, false, null, cid, getPlmnFromCellIdentity(cid),
                1, false, false, false, lteVopsSupportInfo, false);
        sst.mPollingContext[0] = 2;
        // update data reg state to be in service
        sst.sendMessage(sst.obtainMessage(
@@ -1901,7 +1914,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        NetworkRegistrationInfo voiceResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                state, voiceRat, 0, false,
                null, cid, false, 0, 0, 0);
                null, cid, getPlmnFromCellIdentity(cid), false, 0, 0, 0);
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION,
                new AsyncResult(sst.mPollingContext, voiceResult, null)));
@@ -1918,8 +1931,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        // PS WWAN
        NetworkRegistrationInfo dataResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                state, dataRat, 0, false,
                null, cid, 1, false, false, false, lteVopsSupportInfo, false);
                state, dataRat, 0, false, null, cid, getPlmnFromCellIdentity(cid),
                1, false, false, false, lteVopsSupportInfo, false);
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION,
                new AsyncResult(sst.mPollingContext, dataResult, null)));
@@ -1928,8 +1941,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        // CS WWAN
        NetworkRegistrationInfo voiceResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                state, voiceRat, 0, false,
                null, cid, false, 0, 0, 0);
                state, voiceRat, 0, false, null, cid, getPlmnFromCellIdentity(cid), false, 0, 0, 0);
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION,
                new AsyncResult(sst.mPollingContext, voiceResult, null)));
@@ -1939,7 +1951,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        NetworkRegistrationInfo dataIwlanResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN,
                iwlanState, iwlanDataRat, 0, false,
                null, null, 1, false, false, false, lteVopsSupportInfo, false);
                null, null, "", 1, false, false, false, lteVopsSupportInfo, false);
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_PS_IWLAN_REGISTRATION,
                new AsyncResult(sst.mPollingContext, dataIwlanResult, null)));
@@ -2053,11 +2065,12 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        NetworkRegistrationInfo dataResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE,
                0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo, false);
                0, false, null, cellId, getPlmnFromCellIdentity(cellId), 1, false, false, false,
                lteVopsSupportInfo, false);
        NetworkRegistrationInfo voiceResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE,
                0, false, null, cellId, false, 0, 0, 0);
                0, false, null, cellId, getPlmnFromCellIdentity(cellId), false, 0, 0, 0);
        sst.mPollingContext[0] = 2;
        // update data reg state to be in service
        sst.sendMessage(sst.obtainMessage(
@@ -2128,12 +2141,12 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        NetworkRegistrationInfo dataResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING,
                TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, 1, false, false,
                TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, "", 1, false, false,
                false, lteVopsSupportInfo, false);
        NetworkRegistrationInfo voiceResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING,
                TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, false, 0, 0, 0);
                TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, "", false, 0, 0, 0);
        sst.mPollingContext[0] = 2;
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION,
@@ -2323,7 +2336,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        NetworkRegistrationInfo dataResult = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE,
                0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo, false);
                0, false, null, cellId, "00101", 1, false, false, false, lteVopsSupportInfo, false);
        sst.mPollingContext[0] = 2;

        sst.sendMessage(sst.obtainMessage(
@@ -2333,7 +2346,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME,
                TelephonyManager.NETWORK_TYPE_LTE, 0,
                false, null, cellId, false, 0, 0, 0);
                false, null, cellId, "00101", false, 0, 0, 0);
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION,
                new AsyncResult(sst.mPollingContext, voiceResult, null)));
@@ -2352,8 +2365,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        dataResult = new NetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS,
                AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME,
                TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false,
                lteVopsSupportInfo, false);
                TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, "00101",
                1, false, false, false, lteVopsSupportInfo, false);
        sst.mPollingContext[0] = 1;
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION,