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

Commit 9383ca3f authored by Robert Greenwalt's avatar Robert Greenwalt Committed by Android (Google) Code Review
Browse files

Merge "Refine pollState when the modem is off." into nyc-dev

parents ac4aeda5 b9e8a7d2
Loading
Loading
Loading
Loading
+17 −3
Original line number Original line Diff line number Diff line
@@ -945,7 +945,7 @@ public class ServiceStateTracker extends Handler {
                break;
                break;


            case EVENT_NETWORK_STATE_CHANGED:
            case EVENT_NETWORK_STATE_CHANGED:
                pollState();
                modemTriggeredPollState();
                break;
                break;


            case EVENT_GET_SIGNAL_STRENGTH:
            case EVENT_GET_SIGNAL_STRENGTH:
@@ -2457,6 +2457,18 @@ public class ServiceStateTracker extends Handler {
     * event has changed
     * event has changed
     */
     */
    public void pollState() {
    public void pollState() {
        pollState(false);
    }
    /**
     * We insist on polling even if the radio says its off.
     * Used when we get a network changed notification
     * but the radio is off - part of iwlan hack
     */
    private void modemTriggeredPollState() {
        pollState(true);
    }

    public void pollState(boolean modemTriggered) {
        mPollingContext = new int[1];
        mPollingContext = new int[1];
        mPollingContext[0] = 0;
        mPollingContext[0] = 0;


@@ -2476,12 +2488,14 @@ public class ServiceStateTracker extends Handler {
                setSignalStrengthDefaultValues();
                setSignalStrengthDefaultValues();
                mGotCountryCode = false;
                mGotCountryCode = false;
                mNitzUpdatedTime = false;
                mNitzUpdatedTime = false;
                if (ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
                // don't poll for state when the radio is off
                // EXCEPT, if the poll was modemTrigged (they sent us new radio data)
                // or we're on IWLAN
                if (!modemTriggered && ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
                        != mSS.getRilDataRadioTechnology()) {
                        != mSS.getRilDataRadioTechnology()) {
                    pollStateDone();
                    pollStateDone();
                    break;
                    break;
                }
                }
                // else fall through to query for the IWLAN info


            default:
            default:
                // Issue all poll-related commands at once then count down the responses, which
                // Issue all poll-related commands at once then count down the responses, which
+5 −0
Original line number Original line Diff line number Diff line
@@ -1996,6 +1996,11 @@ public class SimulatedCommands extends BaseCommands
        mOnRegistrants.notifyRegistrants();
        mOnRegistrants.notifyRegistrants();
    }
    }


    @VisibleForTesting
    public void notifyVoiceNetworkStateChanged() {
        mVoiceNetworkStateRegistrants.notifyRegistrants();
    }

    public void setIccCardStatus(IccCardStatus iccCardStatus){
    public void setIccCardStatus(IccCardStatus iccCardStatus){
        mIccCardStatus = iccCardStatus;
        mIccCardStatus = iccCardStatus;
    }
    }
+13 −0
Original line number Original line Diff line number Diff line
@@ -146,6 +146,19 @@ public class ServiceStateTrackerTest extends TelephonyTest {
                mSimulatedCommands.getGetVoiceRegistrationStateCallCount());
                mSimulatedCommands.getGetVoiceRegistrationStateCallCount());
        assertEquals(getNetworkSelectionModeCallCount,
        assertEquals(getNetworkSelectionModeCallCount,
                mSimulatedCommands.getGetNetworkSelectionModeCallCount());
                mSimulatedCommands.getGetNetworkSelectionModeCallCount());

        // Note that if the poll is triggered by a network change notification
        // and the modem is supposed to be off, we should still do the poll
        mSimulatedCommands.notifyVoiceNetworkStateChanged();
        waitForMs(250);

        assertEquals(getOperatorCallCount + 1 , mSimulatedCommands.getGetOperatorCallCount());
        assertEquals(getDataRegistrationStateCallCount + 1,
                mSimulatedCommands.getGetDataRegistrationStateCallCount());
        assertEquals(getVoiceRegistrationStateCallCount + 1,
                mSimulatedCommands.getGetVoiceRegistrationStateCallCount());
        assertEquals(getNetworkSelectionModeCallCount + 1,
                mSimulatedCommands.getGetNetworkSelectionModeCallCount());
    }
    }


    @Test
    @Test