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

Commit 7d592679 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Fix ServiceStateTracker.pollState with radio-off.

IWLAN change dropped the "break" line causing us to always send
another round of ril requests even when the radio is off.

Change-Id: If838438c742abb4056a64fc7ae30afd53e7e229e
parent ab57df11
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2492,12 +2492,13 @@ public class ServiceStateTracker extends Handler {
                if (ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
                        != mSS.getRilDataRadioTechnology()) {
                    pollStateDone();
                    break;
                }
                // else fall through to query for the IWLAN info

            default:
                // Issue all poll-related commands at once then count down the responses, which
                // are allowed to arrive out-of-order

                mPollingContext[0]++;
                mCi.getOperator(obtainMessage(EVENT_POLL_STATE_OPERATOR, mPollingContext));

@@ -4587,7 +4588,8 @@ public class ServiceStateTracker extends Handler {
        pw.println(" mCellInfo=" + mCellInfo);
        pw.println(" mCellInfoLte=" + mCellInfoLte);
        pw.println(" mRestrictedState=" + mRestrictedState);
        pw.println(" mPollingContext=" + mPollingContext);
        pw.println(" mPollingContext=" + mPollingContext + " - " +
                (mPollingContext != null ? mPollingContext[0] : ""));
        pw.println(" mDesiredPowerState=" + mDesiredPowerState);
        pw.println(" mDontPollSignalStrength=" + mDontPollSignalStrength);
        pw.println(" mSignalStrength=" + mSignalStrength);
+34 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.internal.telephony.uicc.IccIoResult;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class SimulatedCommands extends BaseCommands
        implements CommandsInterface, SimulatedRadioControl {
@@ -119,7 +120,6 @@ public class SimulatedCommands extends BaseCommands
    private DataCallResponse mDcResponse;

    //***** Constructor

    public
    SimulatedCommands() {
        super(null);  // Don't log statistics
@@ -954,6 +954,7 @@ public class SimulatedCommands extends BaseCommands
     */
    @Override
    public void getVoiceRegistrationState(Message result) {
        mGetVoiceRegistrationStateCallCount.incrementAndGet();
        String ret[] = new String[14];

        ret[0] = Integer.toString(mVoiceRegState);
@@ -962,6 +963,13 @@ public class SimulatedCommands extends BaseCommands
        resultSuccess(result, ret);
    }

    private final AtomicInteger mGetVoiceRegistrationStateCallCount = new AtomicInteger(0);

    @VisibleForTesting
    public int getGetVoiceRegistrationStateCallCount() {
        return mGetVoiceRegistrationStateCallCount.get();
    }

    public void setDataRadioTech(int radioTech) {
        mDataRadioTech = radioTech;
    }
@@ -972,6 +980,7 @@ public class SimulatedCommands extends BaseCommands

    @Override
    public void getDataRegistrationState (Message result) {
        mGetDataRegistrationStateCallCount.incrementAndGet();
        String ret[] = new String[11];

        ret[0] = Integer.toString(mDataRegState);
@@ -980,6 +989,13 @@ public class SimulatedCommands extends BaseCommands
        resultSuccess(result, ret);
    }

    private final AtomicInteger mGetDataRegistrationStateCallCount = new AtomicInteger(0);

    @VisibleForTesting
    public int getGetDataRegistrationStateCallCount() {
        return mGetDataRegistrationStateCallCount.get();
    }

    /**
     * response.obj.result is a String[3]
     * response.obj.result[0] is long alpha or null if unregistered
@@ -988,6 +1004,7 @@ public class SimulatedCommands extends BaseCommands
     */
    @Override
    public void getOperator(Message result) {
        mGetOperatorCallCount.incrementAndGet();
        String[] ret = new String[3];

        ret[0] = FAKE_LONG_NAME;
@@ -997,6 +1014,14 @@ public class SimulatedCommands extends BaseCommands
        resultSuccess(result, ret);
    }

    private final AtomicInteger mGetOperatorCallCount = new AtomicInteger(0);

    @VisibleForTesting
    public int getGetOperatorCallCount() {
        final int count = mGetOperatorCallCount.get();
        return mGetOperatorCallCount.get();
    }

    /**
     *  ar.exception carries exception on failure
     *  ar.userObject contains the original value of result.obj
@@ -1337,12 +1362,20 @@ public class SimulatedCommands extends BaseCommands
    @Override
    public void getNetworkSelectionMode(Message result) {
        SimulatedCommandsVerifier.getInstance().getNetworkSelectionMode(result);
        getNetworkSelectionModeCallCount.incrementAndGet();
        int ret[] = new int[1];

        ret[0] = 0;
        resultSuccess(result, ret);
    }

    private final AtomicInteger getNetworkSelectionModeCallCount = new AtomicInteger(0);

    @VisibleForTesting
    public int getGetNetworkSelectionModeCallCount() {
        return getNetworkSelectionModeCallCount.get();
    }

    /**
     * Queries the currently available networks
     *
+26 −0
Original line number Diff line number Diff line
@@ -140,6 +140,32 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertTrue(oldState != mSimulatedCommands.getRadioState().isOn());
    }

    @Test
    @MediumTest
    public void testNoRilTrafficAfterSetRadioPower() {
        sst.setRadioPower(true);
        final int getOperatorCallCount = mSimulatedCommands.getGetOperatorCallCount();
        final int getDataRegistrationStateCallCount =
                mSimulatedCommands.getGetDataRegistrationStateCallCount();
        final int getVoiceRegistrationStateCallCount =
                mSimulatedCommands.getGetVoiceRegistrationStateCallCount();
        final int getNetworkSelectionModeCallCount =
                mSimulatedCommands.getGetNetworkSelectionModeCallCount();
        sst.setRadioPower(false);

        waitForMs(500);
        sst.pollState();
        waitForMs(250);

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

    @Test
    @MediumTest
    public void testSpnUpdateShowPlmnOnly() {