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

Commit 9665ba1e authored by sangyun's avatar sangyun Committed by Sangyun Yun
Browse files

Fix wrong report previous country code when releaseing airplane mode

1. Clears CellInfo in LocaleTracker in radio off state, to that the
previous remaining country code (iso) is not notified when radio off.
2. Avoid multiple time starts for EVENT_OPERATOR_LOST, On posting
EVENT_OPERATOR_LOST with SendingMessageDelayed, it is been overriden
/restarted with a new delay/multiple handler events, which seems to
causing abnormal behaviour.

Bug: 270659322
Bug: 278671974
Test: atest LocaleTrackerTest
Test: Manually Tested.
Change-Id: Id6588632c73761ff5427f7237d922cbc3fd07faf
parent 78a688e5
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -372,7 +372,10 @@ public class LocaleTracker extends Handler {
     */
     */
    public void updateOperatorNumeric(String operatorNumeric) {
    public void updateOperatorNumeric(String operatorNumeric) {
        if (TextUtils.isEmpty(operatorNumeric)) {
        if (TextUtils.isEmpty(operatorNumeric)) {
            sendMessageDelayed(obtainMessage(EVENT_OPERATOR_LOST), SERVICE_OPERATOR_LOST_DELAY_MS);
            if (!hasMessages(EVENT_OPERATOR_LOST)) {
                sendMessageDelayed(obtainMessage(EVENT_OPERATOR_LOST),
                        SERVICE_OPERATOR_LOST_DELAY_MS);
            }
        } else {
        } else {
            removeMessages(EVENT_OPERATOR_LOST);
            removeMessages(EVENT_OPERATOR_LOST);
            updateOperatorNumericImmediate(operatorNumeric);
            updateOperatorNumericImmediate(operatorNumeric);
@@ -528,6 +531,9 @@ public class LocaleTracker extends Handler {
        if (!mPhone.isRadioOn()) {
        if (!mPhone.isRadioOn()) {
            countryIso = "";
            countryIso = "";
            countryIsoDebugInfo = "radio off";
            countryIsoDebugInfo = "radio off";

            // clear cell infos, we don't know where the next network to camp on.
            mCellInfoList = null;
        }
        }


        log("updateLocale: countryIso = " + countryIso
        log("updateLocale: countryIso = " + countryIso
+15 −0
Original line number Original line Diff line number Diff line
@@ -319,4 +319,19 @@ public class LocaleTrackerTest extends TelephonyTest {
        mLocaleTracker.updateOperatorNumeric(TEST_CELL_MCC + FAKE_MNC);
        mLocaleTracker.updateOperatorNumeric(TEST_CELL_MCC + FAKE_MNC);
        verify(mNitzStateMachine, times(1)).handleCountryDetected("");
        verify(mNitzStateMachine, times(1)).handleCountryDetected("");
    }
    }

    @Test
    public void testClearCellInfoForLostOperator() {
        doReturn(true).when(mPhone).isRadioOn();
        sendServiceState(ServiceState.STATE_OUT_OF_SERVICE);
        processAllMessages();
        assertTrue(mLocaleTracker.isTracking());
        assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry());

        // airplane mode + VoWiFI case
        doReturn(false).when(mPhone).isRadioOn();
        sendServiceState(ServiceState.STATE_POWER_OFF);
        sendServiceState(ServiceState.STATE_IN_SERVICE);
        assertEquals(COUNTRY_CODE_UNAVAILABLE, mLocaleTracker.getCurrentCountry());
    }
}
}