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

Commit fb56736a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11078623 from b322161f to 24Q1-release

Change-Id: I2c8987c14310e3072ce5bad9cd82d25a1b351561
parents a4cf1445 b322161f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -21,3 +21,10 @@ flag {
  description: "Enable system api isWpsCallNumber. Its an utility api to check if the dialed number is for Wireless Priority Service call."
  bug: "304272356"
}

flag {
  name: "ensure_access_to_call_settings_is_restricted"
  namespace: "telephony"
  description: "Check if access to mobile network configs restricted before displaying call options"
  bug: "309655251"
}
 No newline at end of file
+25 −36
Original line number Diff line number Diff line
@@ -1946,16 +1946,15 @@ public class ServiceStateTracker extends Handler {
                err = ((CommandException)(ar.exception)).getCommandError();
            }

            if (mCi.getRadioState() != TelephonyManager.RADIO_POWER_ON) {
                log("handlePollStateResult: Invalid response due to radio off or unavailable. "
                        + "Set ServiceState to out of service.");
                pollStateInternal(false);
                return;
            }

            if (err == CommandException.Error.RADIO_NOT_AVAILABLE) {
                loge("handlePollStateResult: RIL returned RADIO_NOT_AVAILABLE when radio is on.");
                loge("handlePollStateResult: RIL returned RADIO_NOT_AVAILABLE.");
                if (mCi.getRadioState() == TelephonyManager.RADIO_POWER_ON) {
                    cancelPollState();
                } else {
                    handlePollStateInternalForRadioOffOrUnavailable(
                            mCi.getRadioState() == TelephonyManager.RADIO_POWER_OFF);
                    pollStateDone();
                }
                return;
            }

@@ -3312,42 +3311,17 @@ public class ServiceStateTracker extends Handler {

    private void pollStateInternal(boolean modemTriggered) {
        mPollingContext = new int[1];
        NetworkRegistrationInfo nri;

        log("pollState: modemTriggered=" + modemTriggered + ", radioState=" + mCi.getRadioState());

        switch (mCi.getRadioState()) {
            case TelephonyManager.RADIO_POWER_UNAVAILABLE:
                // Preserve the IWLAN registration state, because that should not be affected by
                // radio availability.
                nri = mNewSS.getNetworkRegistrationInfo(
                        NetworkRegistrationInfo.DOMAIN_PS,
                        AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
                mNewSS.setOutOfService(false);
                // Add the IWLAN registration info back to service state.
                if (nri != null) {
                    mNewSS.addNetworkRegistrationInfo(nri);
                }
                mPhone.getSignalStrengthController().setSignalStrengthDefaultValues();
                mLastNitzData = null;
                mNitzState.handleNetworkUnavailable();
                handlePollStateInternalForRadioOffOrUnavailable(false);
                pollStateDone();
                break;

            case TelephonyManager.RADIO_POWER_OFF:
                // Preserve the IWLAN registration state, because that should not be affected by
                // radio availability.
                nri = mNewSS.getNetworkRegistrationInfo(
                        NetworkRegistrationInfo.DOMAIN_PS,
                        AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
                mNewSS.setOutOfService(true);
                // Add the IWLAN registration info back to service state.
                if (nri != null) {
                    mNewSS.addNetworkRegistrationInfo(nri);
                }
                mPhone.getSignalStrengthController().setSignalStrengthDefaultValues();
                mLastNitzData = null;
                mNitzState.handleNetworkUnavailable();
                handlePollStateInternalForRadioOffOrUnavailable(true);
                // Don't poll when device is shutting down or the poll was not modemTriggered
                // (they sent us new radio data) and the current network is not IWLAN
                if (mDeviceShuttingDown ||
@@ -3391,6 +3365,21 @@ public class ServiceStateTracker extends Handler {
        }
    }

    private void handlePollStateInternalForRadioOffOrUnavailable(boolean radioOff) {
        // Preserve the IWLAN registration state, which should not be affected by radio availability
        NetworkRegistrationInfo nri = mNewSS.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS,
                AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
        mNewSS.setOutOfService(radioOff);
        // Add the IWLAN registration info back to service state.
        if (nri != null) {
            mNewSS.addNetworkRegistrationInfo(nri);
        }
        mPhone.getSignalStrengthController().setSignalStrengthDefaultValues();
        mLastNitzData = null;
        mNitzState.handleNetworkUnavailable();
    }

    /**
     * Get the highest-priority CellIdentity for a provided ServiceState.
     *
+73 −0
Original line number Diff line number Diff line
@@ -2064,6 +2064,79 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertEquals(null, sst.getServiceState().getOperatorAlpha());
    }

    @Test
    public void testPollStateExceptionRadioPowerOn() {
        assertEquals(TelephonyManager.RADIO_POWER_ON, mSimulatedCommands.getRadioState());
        assertEquals(ServiceState.STATE_IN_SERVICE, sst.getServiceState().getState());
        assertEquals(ServiceState.STATE_IN_SERVICE,
                sst.getServiceState().getDataRegistrationState());

        sst.mPollingContext[0] = 1;
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_OPERATOR,
                new AsyncResult(sst.mPollingContext, null,
                        new CommandException(CommandException.Error.RADIO_NOT_AVAILABLE))));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());

        assertEquals(ServiceState.STATE_IN_SERVICE, sst.getServiceState().getState());
        assertEquals(ServiceState.STATE_IN_SERVICE,
                sst.getServiceState().getDataRegistrationState());
        assertEquals(0, sst.mPollingContext[0]);
    }

    @Test
    public void testPollStateExceptionRadioPowerOff() {
        // Turn off radio first.
        sst.setRadioPower(false);
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
        assertEquals(TelephonyManager.RADIO_POWER_OFF, mSimulatedCommands.getRadioState());
        assertEquals(ServiceState.STATE_POWER_OFF, sst.getServiceState().getState());
        assertEquals(ServiceState.STATE_POWER_OFF,
                sst.getServiceState().getDataRegistrationState());
        // Override service state
        sst.getServiceState().setVoiceRegState(ServiceState.STATE_IN_SERVICE);
        sst.getServiceState().setDataRegState(ServiceState.STATE_IN_SERVICE);

        sst.mPollingContext[0] = 1;
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_OPERATOR,
                new AsyncResult(sst.mPollingContext, null,
                        new CommandException(CommandException.Error.RADIO_NOT_AVAILABLE))));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());

        assertEquals(ServiceState.STATE_POWER_OFF, sst.getServiceState().getVoiceRegState());
        assertEquals(ServiceState.STATE_POWER_OFF, sst.getServiceState().getDataRegState());
        assertEquals(1, sst.mPollingContext[0]);
    }

    @Test
    public void testPollStateExceptionRadioPowerOffOnIwlan() {
        // Turn off radio first.
        sst.setRadioPower(false);
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
        assertEquals(TelephonyManager.RADIO_POWER_OFF, mSimulatedCommands.getRadioState());
        assertEquals(ServiceState.STATE_POWER_OFF, sst.getServiceState().getState());
        assertEquals(ServiceState.STATE_POWER_OFF,
                sst.getServiceState().getDataRegistrationState());
        // Override service state
        sst.getServiceState().setVoiceRegState(ServiceState.STATE_IN_SERVICE);
        sst.getServiceState().setDataRegState(ServiceState.STATE_IN_SERVICE);
        // Override to IWLAN
        sst.mSS.setRilDataRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN);

        sst.mPollingContext[0] = 1;
        sst.sendMessage(sst.obtainMessage(
                ServiceStateTracker.EVENT_POLL_STATE_OPERATOR,
                new AsyncResult(sst.mPollingContext, null,
                        new CommandException(CommandException.Error.RADIO_NOT_AVAILABLE))));
        waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());

        assertNull(null, sst.getServiceState().getOperatorAlpha());
        assertEquals(ServiceState.STATE_POWER_OFF, sst.getServiceState().getVoiceRegState());
        assertEquals(ServiceState.STATE_POWER_OFF, sst.getServiceState().getDataRegState());
        assertEquals(1, sst.mPollingContext[0]);
    }

    @Test
    public void testCSEmergencyRegistrationState() throws Exception {
        CellIdentityGsm cellIdentity =