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

Commit 7ae1cb99 authored by Jack Yu's avatar Jack Yu Committed by android-build-merger
Browse files

Merge "API review feedback changes"

am: 5c7df49f

Change-Id: I54abd82ea6ddee9664f284b582681f33f915fe39
parents ac1376d9 5c7df49f
Loading
Loading
Loading
Loading
+29 −25
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

/**
@@ -129,22 +131,22 @@ public class CellularNetworkService extends NetworkService {
            switch (halRegState) {
                case RegState.NOT_REG_MT_NOT_SEARCHING_OP:
                case RegState.NOT_REG_MT_NOT_SEARCHING_OP_EM:
                    return NetworkRegistrationInfo.REG_STATE_NOT_REG_NOT_SEARCHING;
                    return NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING;
                case RegState.REG_HOME:
                    return NetworkRegistrationInfo.REG_STATE_HOME;
                    return NetworkRegistrationInfo.REGISTRATION_STATE_HOME;
                case RegState.NOT_REG_MT_SEARCHING_OP:
                case RegState.NOT_REG_MT_SEARCHING_OP_EM:
                    return NetworkRegistrationInfo.REG_STATE_NOT_REG_SEARCHING;
                    return NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_SEARCHING;
                case RegState.REG_DENIED:
                case RegState.REG_DENIED_EM:
                    return NetworkRegistrationInfo.REG_STATE_DENIED;
                    return NetworkRegistrationInfo.REGISTRATION_STATE_DENIED;
                case RegState.UNKNOWN:
                case RegState.UNKNOWN_EM:
                    return NetworkRegistrationInfo.REG_STATE_UNKNOWN;
                    return NetworkRegistrationInfo.REGISTRATION_STATE_UNKNOWN;
                case RegState.REG_ROAMING:
                    return NetworkRegistrationInfo.REG_STATE_ROAMING;
                    return NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING;
                default:
                    return NetworkRegistrationInfo.REG_STATE_NOT_REG_NOT_SEARCHING;
                    return NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING;
            }
        }

@@ -166,24 +168,23 @@ public class CellularNetworkService extends NetworkService {
            }
        }

        private int[] getAvailableServices(int regState, int domain, boolean emergencyOnly) {
            int[] availableServices = null;
        private List<Integer> getAvailableServices(int regState, int domain,
                                                   boolean emergencyOnly) {
            List<Integer> availableServices = new ArrayList<>();

            // In emergency only states, only SERVICE_TYPE_EMERGENCY is available.
            // Otherwise, certain services are available only if it's registered on home or roaming
            // network.
            if (emergencyOnly) {
                availableServices = new int[] {NetworkRegistrationInfo.SERVICE_TYPE_EMERGENCY};
            } else if (regState == NetworkRegistrationInfo.REG_STATE_ROAMING
                    || regState == NetworkRegistrationInfo.REG_STATE_HOME) {
                availableServices.add(NetworkRegistrationInfo.SERVICE_TYPE_EMERGENCY);
            } else if (regState == NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING
                    || regState == NetworkRegistrationInfo.REGISTRATION_STATE_HOME) {
                if (domain == NetworkRegistrationInfo.DOMAIN_PS) {
                    availableServices = new int[] {NetworkRegistrationInfo.SERVICE_TYPE_DATA};
                    availableServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA);
                } else if (domain == NetworkRegistrationInfo.DOMAIN_CS) {
                    availableServices = new int[] {
                            NetworkRegistrationInfo.SERVICE_TYPE_VOICE,
                            NetworkRegistrationInfo.SERVICE_TYPE_SMS,
                            NetworkRegistrationInfo.SERVICE_TYPE_VIDEO
                    };
                    availableServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE);
                    availableServices.add(NetworkRegistrationInfo.SERVICE_TYPE_SMS);
                    availableServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VIDEO);
                }
            }

@@ -224,7 +225,7 @@ public class CellularNetworkService extends NetworkService {
                int roamingIndicator = voiceRegState.roamingIndicator;
                int systemIsInPrl = voiceRegState.systemIsInPrl;
                int defaultRoamingIndicator = voiceRegState.defaultRoamingIndicator;
                int[] availableServices = getAvailableServices(
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity =
                        convertHalCellIdentityToCellIdentity(voiceRegState.cellIdentity);
@@ -244,7 +245,7 @@ public class CellularNetworkService extends NetworkService {
                int roamingIndicator = voiceRegState.roamingIndicator;
                int systemIsInPrl = voiceRegState.systemIsInPrl;
                int defaultRoamingIndicator = voiceRegState.defaultRoamingIndicator;
                int[] availableServices = getAvailableServices(
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity =
                        convertHalCellIdentityToCellIdentity(voiceRegState.cellIdentity);
@@ -270,15 +271,16 @@ public class CellularNetworkService extends NetworkService {
                int reasonForDenial = dataRegState.reasonDataDenied;
                boolean emergencyOnly = isEmergencyOnly(dataRegState.regState);
                int maxDataCalls = dataRegState.maxDataCalls;
                int[] availableServices = getAvailableServices(regState, domain, emergencyOnly);
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity =
                        convertHalCellIdentityToCellIdentity(dataRegState.cellIdentity);
                LteVopsSupportInfo lteVopsSupportInfo =
                        new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE,
                        LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE);
                return new NetworkRegistrationInfo(domain, transportType, regState,
                        accessNetworkTechnology, reasonForDenial, emergencyOnly, availableServices,
                        cellIdentity, maxDataCalls, false /* isDcNrRestricted */,
                        accessNetworkTechnology, reasonForDenial, emergencyOnly,
                        availableServices, cellIdentity, maxDataCalls, false /* isDcNrRestricted */,
                        false /* isNrAvailable */, false /* isEnDcAvailable */, lteVopsSupportInfo);

            } else if (result instanceof android.hardware.radio.V1_2.DataRegStateResult) {
@@ -289,7 +291,8 @@ public class CellularNetworkService extends NetworkService {
                int reasonForDenial = dataRegState.reasonDataDenied;
                boolean emergencyOnly = isEmergencyOnly(dataRegState.regState);
                int maxDataCalls = dataRegState.maxDataCalls;
                int[] availableServices = getAvailableServices(regState, domain, emergencyOnly);
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity =
                        convertHalCellIdentityToCellIdentity(dataRegState.cellIdentity);
                LteVopsSupportInfo lteVopsSupportInfo =
@@ -309,7 +312,8 @@ public class CellularNetworkService extends NetworkService {
                int reasonForDenial = dataRegState.base.reasonDataDenied;
                boolean emergencyOnly = isEmergencyOnly(dataRegState.base.regState);
                int maxDataCalls = dataRegState.base.maxDataCalls;
                int[] availableServices = getAvailableServices(regState, domain, emergencyOnly);
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity =
                        convertHalCellIdentityToCellIdentity(dataRegState.base.cellIdentity);
                android.hardware.radio.V1_4.NrIndicators nrIndicators = dataRegState.nrIndicators;
+27 −26
Original line number Diff line number Diff line
@@ -797,7 +797,7 @@ public class ServiceStateTracker extends Handler {
        if (nrs != null) {
            int rat = ServiceState.networkTypeToRilRadioTechnology(
                    nrs.getAccessNetworkTechnology());
            int drs = regCodeToServiceState(nrs.getRegState());
            int drs = regCodeToServiceState(nrs.getRegistrationState());
            if (DBG) {
                log("notifyDataRegStateRilRadioTechnologyChanged: drs=" + drs + " rat=" + rat);
            }
@@ -1515,7 +1515,7 @@ public class ServiceStateTracker extends Handler {
                    mLastPhysicalChannelConfigList = list;
                    boolean hasChanged =
                            updateNrFrequencyRangeFromPhysicalChannelConfigs(list, mSS);
                    hasChanged |= updateNrStatusFromPhysicalChannelConfigs(
                    hasChanged |= updateNrStateFromPhysicalChannelConfigs(
                            list,
                            mSS.getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS,
                                    AccessNetworkType.EUTRAN));
@@ -1895,13 +1895,13 @@ public class ServiceStateTracker extends Handler {
        return cdmaRoaming && !isSameOperatorNameFromSimAndSS(s);
    }

    private boolean isNrStatusChanged(
    private boolean isNrStateChanged(
            NetworkRegistrationInfo oldRegState, NetworkRegistrationInfo newRegState) {
        if (oldRegState == null || newRegState == null) {
            return oldRegState != newRegState;
        }

        return oldRegState.getNrStatus() != newRegState.getNrStatus();
        return oldRegState.getNrState() != newRegState.getNrState();
    }

    private boolean updateNrFrequencyRangeFromPhysicalChannelConfigs(
@@ -1933,7 +1933,7 @@ public class ServiceStateTracker extends Handler {
        return hasChanged;
    }

    private boolean updateNrStatusFromPhysicalChannelConfigs(
    private boolean updateNrStateFromPhysicalChannelConfigs(
            List<PhysicalChannelConfig> configs, NetworkRegistrationInfo regState) {

        if (regState == null || configs == null) return false;
@@ -1947,19 +1947,19 @@ public class ServiceStateTracker extends Handler {
            }
        }

        int newNrStatus = regState.getNrStatus();
        int newNrState = regState.getNrState();
        if (hasNrSecondaryServingCell) {
            if (regState.getNrStatus() == NetworkRegistrationInfo.NR_STATUS_NOT_RESTRICTED) {
                newNrStatus = NetworkRegistrationInfo.NR_STATUS_CONNECTED;
            if (regState.getNrState() == NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED) {
                newNrState = NetworkRegistrationInfo.NR_STATE_CONNECTED;
            }
        } else {
            if (regState.getNrStatus() == NetworkRegistrationInfo.NR_STATUS_CONNECTED) {
                newNrStatus = NetworkRegistrationInfo.NR_STATUS_NOT_RESTRICTED;
            if (regState.getNrState() == NetworkRegistrationInfo.NR_STATE_CONNECTED) {
                newNrState = NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED;
            }
        }

        boolean hasChanged = newNrStatus != regState.getNrStatus();
        regState.setNrStatus(newNrStatus);
        boolean hasChanged = newNrState != regState.getNrState();
        regState.setNrState(newNrState);
        return hasChanged;
    }

@@ -1984,13 +1984,14 @@ public class ServiceStateTracker extends Handler {
        if (wlanPsRegState != null
                && wlanPsRegState.getAccessNetworkTechnology()
                == TelephonyManager.NETWORK_TYPE_IWLAN
                && wlanPsRegState.getRegState() == NetworkRegistrationInfo.REG_STATE_HOME) {
                && wlanPsRegState.getRegistrationState()
                == NetworkRegistrationInfo.REGISTRATION_STATE_HOME) {
            serviceState.setRilDataRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN);
            serviceState.setDataRegState(ServiceState.STATE_IN_SERVICE);
        } else if (wwanPsRegState != null) {
            // If the device is not camped on IWLAN, then we use cellular PS registration state
            // to compute reg state and rat.
            int regState = wwanPsRegState.getRegState();
            int regState = wwanPsRegState.getRegistrationState();
            int dataRat = ServiceState.networkTypeToRilRadioTechnology(
                    wwanPsRegState.getAccessNetworkTechnology());
            serviceState.setDataRegState(regCodeToServiceState(regState));
@@ -2009,7 +2010,7 @@ public class ServiceStateTracker extends Handler {
                VoiceSpecificRegistrationStates voiceSpecificStates =
                        networkRegState.getVoiceSpecificStates();

                int registrationState = networkRegState.getRegState();
                int registrationState = networkRegState.getRegistrationState();
                int cssIndicator = voiceSpecificStates.cssSupported ? 1 : 0;
                int newVoiceRat = ServiceState.networkTypeToRilRadioTechnology(
                        networkRegState.getAccessNetworkTechnology());
@@ -2097,7 +2098,7 @@ public class ServiceStateTracker extends Handler {
                mNewSS.addNetworkRegistrationInfo(networkRegState);
                DataSpecificRegistrationStates dataSpecificStates =
                        networkRegState.getDataSpecificStates();
                int registrationState = networkRegState.getRegState();
                int registrationState = networkRegState.getRegistrationState();
                int serviceState = regCodeToServiceState(registrationState);
                int newDataRat = ServiceState.networkTypeToRilRadioTechnology(
                        networkRegState.getAccessNetworkTechnology());
@@ -2113,7 +2114,7 @@ public class ServiceStateTracker extends Handler {
                    mLastPhysicalChannelConfigList = null;
                    updateNrFrequencyRangeFromPhysicalChannelConfigs(null, mNewSS);
                }
                updateNrStatusFromPhysicalChannelConfigs(
                updateNrStateFromPhysicalChannelConfigs(
                        mLastPhysicalChannelConfigList, networkRegState);
                setPhyCellInfoFromCellIdentity(mNewSS, networkRegState.getCellIdentity());

@@ -3072,10 +3073,10 @@ public class ServiceStateTracker extends Handler {
                anyDataRatChanged = true;
            }

            int oldRegState = oldNrs != null ? oldNrs.getRegState()
                    : NetworkRegistrationInfo.REG_STATE_UNKNOWN;
            int newRegState = newNrs != null ? newNrs.getRegState()
                    : NetworkRegistrationInfo.REG_STATE_UNKNOWN;
            int oldRegState = oldNrs != null ? oldNrs.getRegistrationState()
                    : NetworkRegistrationInfo.REGISTRATION_STATE_UNKNOWN;
            int newRegState = newNrs != null ? newNrs.getRegistrationState()
                    : NetworkRegistrationInfo.REGISTRATION_STATE_UNKNOWN;
            hasDataRegStateChanged.put(transport, oldRegState != newRegState);
            if (oldRegState != newRegState) {
                anyDataRegChanged = true;
@@ -3088,7 +3089,7 @@ public class ServiceStateTracker extends Handler {
        boolean hasNrFrequencyRangeChanged =
                mSS.getNrFrequencyRange() != mNewSS.getNrFrequencyRange();

        boolean hasNrStatusChanged = isNrStatusChanged(
        boolean hasNrStateChanged = isNrStateChanged(
                mSS.getNetworkRegistrationInfo(
                        NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkType.EUTRAN),
                mNewSS.getNetworkRegistrationInfo(
@@ -3172,7 +3173,7 @@ public class ServiceStateTracker extends Handler {
                    + " hasLostMultiApnSupport = " + hasLostMultiApnSupport
                    + " hasCssIndicatorChanged = " + hasCssIndicatorChanged
                    + " hasNrFrequencyRangeChanged = " + hasNrFrequencyRangeChanged
                    + " hasNrStatusChanged = " + hasNrStatusChanged);
                    + " hasNrStateChanged = " + hasNrStateChanged);
        }

        // Add an event log when connection state changes
@@ -3578,8 +3579,8 @@ public class ServiceStateTracker extends Handler {
     * to service state */
    private int regCodeToServiceState(int code) {
        switch (code) {
            case NetworkRegistrationInfo.REG_STATE_HOME:
            case NetworkRegistrationInfo.REG_STATE_ROAMING:
            case NetworkRegistrationInfo.REGISTRATION_STATE_HOME:
            case NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING:
                return ServiceState.STATE_IN_SERVICE;
            default:
                return ServiceState.STATE_OUT_OF_SERVICE;
@@ -3591,7 +3592,7 @@ public class ServiceStateTracker extends Handler {
     * returns true if registered roam, false otherwise
     */
    private boolean regCodeIsRoaming (int code) {
        return NetworkRegistrationInfo.REG_STATE_ROAMING == code;
        return NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING == code;
    }

    private boolean isSameOperatorNameFromSimAndSS(ServiceState s) {
+2 −2
Original line number Diff line number Diff line
@@ -2877,8 +2877,8 @@ public class DataConnection extends StateMachine {

    /** Check if the device is connected to NR 5G Non-Standalone network. */
    private boolean isNRConnected() {
        return mPhone.getServiceState().getNrStatus()
                == NetworkRegistrationInfo.NR_STATUS_CONNECTED;
        return mPhone.getServiceState().getNrState()
                == NetworkRegistrationInfo.NR_STATE_CONNECTED;
    }

    private void dumpToLog() {
+2 −2
Original line number Diff line number Diff line
@@ -128,9 +128,9 @@ public class SimulatedCommands extends BaseCommands
    int mNetworkType;
    String mPin2Code;
    boolean mSsnNotifyOn = false;
    private int mVoiceRegState = NetworkRegistrationInfo.REG_STATE_HOME;
    private int mVoiceRegState = NetworkRegistrationInfo.REGISTRATION_STATE_HOME;
    private int mVoiceRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_UMTS;
    private int mDataRegState = NetworkRegistrationInfo.REG_STATE_HOME;
    private int mDataRegState = NetworkRegistrationInfo.REGISTRATION_STATE_HOME;
    private int mDataRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_UMTS;
    public boolean mCssSupported;
    public int mRoamingIndicator;
+9 −5
Original line number Diff line number Diff line
@@ -45,6 +45,10 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;

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

public class CellularNetworkServiceTest extends TelephonyTest {
    CellularNetworkService mCellularNetworkService;

@@ -93,8 +97,8 @@ public class CellularNetworkServiceTest extends TelephonyTest {
    @Test
    @MediumTest
    public void testGetNetworkRegistrationInfo() {
        int voiceRegState = NetworkRegistrationInfo.REG_STATE_HOME;
        int dataRegState = NetworkRegistrationInfo.REG_STATE_HOME;
        int voiceRegState = NetworkRegistrationInfo.REGISTRATION_STATE_HOME;
        int dataRegState = NetworkRegistrationInfo.REGISTRATION_STATE_HOME;
        int voiceRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_HSPA;
        int dataRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_HSPA;
        int domain = NetworkRegistrationInfo.DOMAIN_CS;
@@ -105,11 +109,11 @@ public class CellularNetworkServiceTest extends TelephonyTest {
        int defaultRoamingIndicator = 3;
        int reasonForDenial = 0;
        int maxDataCalls = 4;
        int[] availableServices = new int[] {
        List<Integer> availableServices = new ArrayList<>(Arrays.asList(new Integer[] {
                NetworkRegistrationInfo.SERVICE_TYPE_VOICE,
                NetworkRegistrationInfo.SERVICE_TYPE_SMS,
                NetworkRegistrationInfo.SERVICE_TYPE_VIDEO
        };
        }));

        mSimulatedCommands.setVoiceRegState(voiceRegState);
        mSimulatedCommands.setVoiceRadioTech(voiceRadioTech);
@@ -146,7 +150,7 @@ public class CellularNetworkServiceTest extends TelephonyTest {
        }

        domain = NetworkRegistrationInfo.DOMAIN_PS;
        availableServices = new int[] {NetworkRegistrationInfo.SERVICE_TYPE_DATA};
        availableServices = Arrays.asList(NetworkRegistrationInfo.SERVICE_TYPE_DATA);
        try {
            mBinder.getNetworkRegistrationInfo(0, domain, mCallback);
        } catch (RemoteException e) {
Loading