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

Commit 49539dcf authored by Hyein Yu's avatar Hyein Yu Committed by Android (Google) Code Review
Browse files

Merge "Update CellBroadcastConfigTraker state for cleanupCdma case" into main

parents bbe56992 dd4d094b
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.util.LocalLog;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
import com.android.internal.telephony.flags.Flags;
import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
@@ -192,7 +193,8 @@ public final class CellBroadcastConfigTracker extends StateMachine {
                        // set gsm config if the config is changed
                        setGsmConfig(request.get3gppRanges(), request);
                        transitionTo(mGsmConfiguringState);
                    } else if (!mCbRanges3gpp2.equals(request.get3gpp2Ranges())) {
                    } else if (!Flags.cleanupCdma()
                            && !mCbRanges3gpp2.equals(request.get3gpp2Ranges())) {
                        // set cdma config directly if no gsm config change but cdma config is
                        // changed
                        setCdmaConfig(request.get3gpp2Ranges(), request);
@@ -283,7 +285,8 @@ public final class CellBroadcastConfigTracker extends StateMachine {
                    }
                    if (ar.exception == null) {
                        mCbRanges3gpp = request.get3gppRanges();
                        if (!mCbRanges3gpp2.equals(request.get3gpp2Ranges())) {
                        if (!Flags.cleanupCdma()
                                && !mCbRanges3gpp2.equals(request.get3gpp2Ranges())) {
                            // set cdma config and transit to cdma configuring state if the config
                            // is changed.
                            setCdmaConfig(request.get3gpp2Ranges(), request);
+133 −82
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.testing.TestableLooper;

import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
import com.android.internal.telephony.flags.FeatureFlags;
import com.android.internal.telephony.flags.Flags;
import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;

import org.junit.After;
@@ -132,6 +133,7 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
        verify(mSpyCi, never()).setCdmaBroadcastConfig(any(), any());
        verify(mSpyCi, never()).setCdmaBroadcastActivation(anyBoolean(), any());

        List<CellBroadcastIdRange> gsmRanges = new ArrayList<>(ranges);
        assertEquals(mPhone.getCellBroadcastIdRanges(), mergeRangesAsNeeded(ranges));

        //Verify to set cdma config and activate, but no more for gsm as no change
@@ -150,8 +152,11 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
        processAllMessages();

        verify(mSpyCi, times(1)).setGsmBroadcastConfig(any(), any());
        verify(mSpyCi, times(1)).setCdmaBroadcastConfig(cdmaCaptor.capture(), msgCaptor.capture());
        List<CdmaSmsBroadcastConfigInfo> cdmaArgs = Arrays.asList(
        List<CdmaSmsBroadcastConfigInfo> cdmaArgs;
        if (!Flags.cleanupCdma()) {
            verify(mSpyCi, times(1)).setCdmaBroadcastConfig(cdmaCaptor.capture(),
                    msgCaptor.capture());
            cdmaArgs = Arrays.asList(
                    (CdmaSmsBroadcastConfigInfo[]) cdmaCaptor.getValue());
            assertEquals(cdmaConfigs, cdmaArgs);

@@ -160,8 +165,12 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
            AsyncResult.forMessage(msg);
            msg.sendToTarget();
            processAllMessages();
        } else {
            verify(mSpyCi, never()).setCdmaBroadcastConfig(any(), any());
        }

        verify(mSpyCi, times(1)).setGsmBroadcastActivation(anyBoolean(), any());
        if (!Flags.cleanupCdma()) {
            verify(mSpyCi, times(1)).setCdmaBroadcastActivation(eq(true), msgCaptor.capture());

            msg = msgCaptor.getValue();
@@ -169,20 +178,36 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
            AsyncResult.forMessage(msg);
            msg.sendToTarget();
            processAllMessages();
        } else {
            verify(mSpyCi, never()).setCdmaBroadcastActivation(anyBoolean(), any());
        }

        if (!Flags.cleanupCdma()) {
            assertEquals(mPhone.getCellBroadcastIdRanges(), mergeRangesAsNeeded(ranges));
        } else {
            assertEquals(mPhone.getCellBroadcastIdRanges(), mergeRangesAsNeeded(gsmRanges));
        }

        // Verify not to set cdma or gsm config as the config is not changed
        mPhone.setCellBroadcastIdRanges(ranges, r -> assertTrue(
                TelephonyManager.CELL_BROADCAST_RESULT_SUCCESS == r));
        processAllMessages();

        if (!Flags.cleanupCdma()) {
            verify(mSpyCi, times(1)).setCdmaBroadcastConfig(any(), any());
            verify(mSpyCi, times(1)).setCdmaBroadcastActivation(anyBoolean(), any());
        } else {
            verify(mSpyCi, never()).setCdmaBroadcastConfig(any(), any());
            verify(mSpyCi, never()).setCdmaBroadcastActivation(anyBoolean(), any());
        }
        verify(mSpyCi, times(1)).setGsmBroadcastConfig(any(), any());
        verify(mSpyCi, times(1)).setGsmBroadcastActivation(anyBoolean(), any());

        if (!Flags.cleanupCdma()) {
            assertEquals(mPhone.getCellBroadcastIdRanges(), mergeRangesAsNeeded(ranges));
        } else {
            assertEquals(mPhone.getCellBroadcastIdRanges(), mergeRangesAsNeeded(gsmRanges));
        }

        // Verify to reset ranges with empty ranges list
        mPhone.setCellBroadcastIdRanges(new ArrayList<>(), r -> assertTrue(
@@ -208,7 +233,9 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
        msg.sendToTarget();
        processAllMessages();

        verify(mSpyCi, times(2)).setCdmaBroadcastConfig(cdmaCaptor.capture(), msgCaptor.capture());
        if (!Flags.cleanupCdma()) {
            verify(mSpyCi, times(2)).setCdmaBroadcastConfig(cdmaCaptor.capture(),
                    msgCaptor.capture());
            assertEquals(0, ((CdmaSmsBroadcastConfigInfo[]) cdmaCaptor.getValue()).length);

            msg = msgCaptor.getValue();
@@ -225,6 +252,10 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
            AsyncResult.forMessage(msg);
            msg.sendToTarget();
            processAllMessages();
        } else {
            verify(mSpyCi, never()).setCdmaBroadcastConfig(any(), any());
            verify(mSpyCi, never()).setCdmaBroadcastActivation(anyBoolean(), any());
        }

        assertTrue(mPhone.getCellBroadcastIdRanges().isEmpty());

@@ -252,7 +283,9 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
        msg.sendToTarget();
        processAllMessages();

        verify(mSpyCi, times(3)).setCdmaBroadcastConfig(cdmaCaptor.capture(), msgCaptor.capture());
        if (!Flags.cleanupCdma()) {
            verify(mSpyCi, times(3)).setCdmaBroadcastConfig(cdmaCaptor.capture(),
                    msgCaptor.capture());
            cdmaArgs = Arrays.asList((CdmaSmsBroadcastConfigInfo[]) cdmaCaptor.getValue());
            assertEquals(cdmaConfigs, cdmaArgs);

@@ -269,8 +302,16 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
            AsyncResult.forMessage(msg);
            msg.sendToTarget();
            processAllMessages();
        } else {
            verify(mSpyCi, never()).setCdmaBroadcastConfig(any(), any());
            verify(mSpyCi, never()).setCdmaBroadcastActivation(anyBoolean(), any());
        }

        if (!Flags.cleanupCdma()) {
            assertEquals(mPhone.getCellBroadcastIdRanges(), mergeRangesAsNeeded(ranges));
        } else {
            assertEquals(mPhone.getCellBroadcastIdRanges(), mergeRangesAsNeeded(gsmRanges));
        }
    }

    @Test
@@ -335,8 +376,9 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
        assertTrue(mPhone.getCellBroadcastIdRanges().isEmpty());

        // Verify the result on setCdmaBroadcastConfig failure
        mPhone.setCellBroadcastIdRanges(ranges, r -> assertTrue(
                TelephonyManager.CELL_BROADCAST_RESULT_FAIL_CONFIG == r));
        mPhone.setCellBroadcastIdRanges(ranges, !Flags.cleanupCdma()
                ? r -> assertTrue(TelephonyManager.CELL_BROADCAST_RESULT_FAIL_CONFIG == r)
                : r -> assertTrue(TelephonyManager.CELL_BROADCAST_RESULT_SUCCESS == r));
        processAllMessages();

        verify(mSpyCi, times(3)).setGsmBroadcastConfig(any(), msgCaptor.capture());
@@ -355,6 +397,7 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
        msg.sendToTarget();
        processAllMessages();

        if (!Flags.cleanupCdma()) {
            verify(mSpyCi, times(1)).setCdmaBroadcastConfig(any(), msgCaptor.capture());

            msg = msgCaptor.getValue();
@@ -362,7 +405,9 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
            AsyncResult.forMessage(msg).exception = new RuntimeException();
            msg.sendToTarget();
            processAllMessages();

        } else {
            verify(mSpyCi, times(0)).setCdmaBroadcastConfig(any(), any());
        }
        verify(mSpyCi, times(0)).setCdmaBroadcastActivation(anyBoolean(), any());

        List<CellBroadcastIdRange> ranges3gpp = new ArrayList<>();
@@ -371,13 +416,15 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
        assertEquals(mPhone.getCellBroadcastIdRanges(), ranges3gpp);

        // Verify the result on setCdmaBroadcastActivation failure
        mPhone.setCellBroadcastIdRanges(ranges, r -> assertTrue(
                TelephonyManager.CELL_BROADCAST_RESULT_FAIL_ACTIVATION == r));
        mPhone.setCellBroadcastIdRanges(ranges, !Flags.cleanupCdma()
                ? r -> assertTrue(TelephonyManager.CELL_BROADCAST_RESULT_FAIL_ACTIVATION == r)
                : r -> assertTrue(TelephonyManager.CELL_BROADCAST_RESULT_SUCCESS == r));
        processAllMessages();

        // Verify no more calls as there is no change of ranges for 3gpp
        verify(mSpyCi, times(3)).setGsmBroadcastConfig(any(), any());
        verify(mSpyCi, times(2)).setGsmBroadcastActivation(anyBoolean(), any());
        if (!Flags.cleanupCdma()) {
            verify(mSpyCi, times(2)).setCdmaBroadcastConfig(any(), msgCaptor.capture());

            msg = msgCaptor.getValue();
@@ -393,6 +440,10 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
            AsyncResult.forMessage(msg).exception = new RuntimeException();
            msg.sendToTarget();
            processAllMessages();
        } else {
            verify(mSpyCi, times(0)).setCdmaBroadcastConfig(any(), any());
            verify(mSpyCi, times(0)).setCdmaBroadcastActivation(anyBoolean(), any());
        }

        assertEquals(mPhone.getCellBroadcastIdRanges(), ranges3gpp);
    }