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

Commit ec905460 authored by Sooraj Sasindran's avatar Sooraj Sasindran
Browse files

consider PS registration state for emergency

use PS registration state as well, while determining
emergency registration state.

Bug: 173408767
Test: unit test
Change-Id: Ie6c4c9e5425bd81e9c006b776d0905ba7fd1e7e4
parent 3f4a3085
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -540,6 +540,8 @@ public class ServiceStateTracker extends Handler {
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private boolean mEmergencyOnly = false;
    private boolean mCSEmergencyOnly = false;
    private boolean mPSEmergencyOnly = false;
    /** Started the recheck process after finding gprs should registered but not. */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private boolean mStartedGprsRegCheck;
@@ -2291,15 +2293,16 @@ public class ServiceStateTracker extends Handler {
                int cssIndicator = voiceSpecificStates.cssSupported ? 1 : 0;
                int newVoiceRat = ServiceState.networkTypeToRilRadioTechnology(
                        networkRegState.getAccessNetworkTechnology());

                mNewSS.setVoiceRegState(regCodeToServiceState(registrationState));
                mNewSS.setCssIndicator(cssIndicator);
                mNewSS.addNetworkRegistrationInfo(networkRegState);

                setPhyCellInfoFromCellIdentity(mNewSS, networkRegState.getCellIdentity());

                //Denial reason if registrationState = 3
                int reasonForDenial = networkRegState.getRejectCause();
                mEmergencyOnly = networkRegState.isEmergencyEnabled();
                mCSEmergencyOnly = networkRegState.isEmergencyEnabled();
                mEmergencyOnly = (mCSEmergencyOnly || mPSEmergencyOnly);
                if (mPhone.isPhoneTypeGsm()) {

                    mGsmVoiceRoaming = regCodeIsRoaming(registrationState);
@@ -2397,6 +2400,8 @@ public class ServiceStateTracker extends Handler {
                    mServiceStateStats.onServiceStateChanged(mSS);
                }

                mPSEmergencyOnly = networkRegState.isEmergencyEnabled();
                mEmergencyOnly = (mCSEmergencyOnly || mPSEmergencyOnly);
                if (mPhone.isPhoneTypeGsm()) {

                    mNewReasonDataDenied = networkRegState.getRejectCause();
@@ -5441,6 +5446,8 @@ public class ServiceStateTracker extends Handler {
        pw.println(" mGsmVoiceRoaming=" + mGsmVoiceRoaming);
        pw.println(" mGsmDataRoaming=" + mGsmDataRoaming);
        pw.println(" mEmergencyOnly=" + mEmergencyOnly);
        pw.println(" mCSEmergencyOnly=" + mCSEmergencyOnly);
        pw.println(" mPSEmergencyOnly=" + mPSEmergencyOnly);
        pw.flush();
        mNitzState.dumpState(pw);
        pw.println(" mLastNitzData=" + mLastNitzData);
+58 −0
Original line number Diff line number Diff line
@@ -2053,6 +2053,64 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertEquals(null, sst.getServiceState().getOperatorAlpha());
    }

    @Test
    public void testCSEmergencyRegistrationState() throws Exception {
        CellIdentityGsm cellIdentity =
                new CellIdentityGsm(0, 1, 900, 5, "001", "01", "test", "tst",
                        Collections.emptyList());

        NetworkRegistrationInfo dataReg = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                0, 16, 0, false, null, cellIdentity, getPlmnFromCellIdentity(cellIdentity),
                1, false, false, false, null);

        NetworkRegistrationInfo voiceReg = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                0, 16, 0, true, null, cellIdentity, getPlmnFromCellIdentity(cellIdentity),
                false, 0, 0, 0);

        sst.mPollingContext[0] = 2;
        // update data reg state to be in oos
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION,
                new AsyncResult(sst.mPollingContext, dataReg, null)));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION,
                new AsyncResult(sst.mPollingContext, voiceReg, null)));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
        assertTrue(sst.mSS.isEmergencyOnly());
    }

    @Test
    public void testPSEmergencyRegistrationState() throws Exception {
        CellIdentityGsm cellIdentity =
                new CellIdentityGsm(0, 1, 900, 5, "001", "01", "test", "tst",
                        Collections.emptyList());

        NetworkRegistrationInfo dataReg = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                0, 16, 0, true, null, cellIdentity, getPlmnFromCellIdentity(cellIdentity),
                1, false, false, false, null);

        NetworkRegistrationInfo voiceReg = new NetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                0, 16, 0, false, null, cellIdentity, getPlmnFromCellIdentity(cellIdentity),
                false, 0, 0, 0);

        sst.mPollingContext[0] = 2;
        // update data reg state to be in oos
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION,
                new AsyncResult(sst.mPollingContext, dataReg, null)));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION,
                new AsyncResult(sst.mPollingContext, voiceReg, null)));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
        assertTrue(sst.mSS.isEmergencyOnly());
    }

    // Edge and GPRS are grouped under the same family and Edge has higher rate than GPRS.
    // Expect no rat update when move from E to G.
    @Test