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

Commit 2758381b authored by youngtaecha's avatar youngtaecha
Browse files

Clear CellBroadcast Configuration cache when the modem reset

Bug: 313152282
Test: Build
Test: atest FrameworksTelephonyTests:com.android.internal.telephony (http://ab/I34100010230201004)

Change-Id: I1c8149a6052b8a02065172a5086b5f36b4081224
parent 326f7107
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ public final class CellBroadcastConfigTracker extends StateMachine {
    private static final int EVENT_ACTIVATION_DONE = 3;
    private static final int EVENT_RADIO_OFF = 4;
    private static final int EVENT_SUBSCRIPTION_CHANGED = 5;
    @VisibleForTesting
    public static final int EVENT_RADIO_RESET = 6;

    private static final int SMS_CB_CODE_SCHEME_MIN = 0;
    private static final int SMS_CB_CODE_SCHEME_MAX = 255;
@@ -122,6 +124,7 @@ public final class CellBroadcastConfigTracker extends StateMachine {
        @Override
        public void enter() {
            mPhone.registerForRadioOffOrNotAvailable(getHandler(), EVENT_RADIO_OFF, null);
            mPhone.mCi.registerForModemReset(getHandler(), EVENT_RADIO_RESET, null);
            mPhone.getContext().getSystemService(SubscriptionManager.class)
                    .addOnSubscriptionsChangedListener(new HandlerExecutor(getHandler()),
                            mSubChangedListener);
@@ -130,6 +133,7 @@ public final class CellBroadcastConfigTracker extends StateMachine {
        @Override
        public void exit() {
            mPhone.unregisterForRadioOffOrNotAvailable(getHandler());
            mPhone.mCi.unregisterForModemReset(getHandler());
            mPhone.getContext().getSystemService(SubscriptionManager.class)
                    .removeOnSubscriptionsChangedListener(mSubChangedListener);
        }
@@ -142,6 +146,7 @@ public final class CellBroadcastConfigTracker extends StateMachine {
            }
            switch (msg.what) {
                case EVENT_RADIO_OFF:
                case EVENT_RADIO_RESET:
                    resetConfig();
                    break;
                case EVENT_SUBSCRIPTION_CHANGED:
+20 −0
Original line number Diff line number Diff line
@@ -415,6 +415,26 @@ public final class CellBroadcastConfigTrackerTest extends TelephonyTest {
        assertTrue(mPhone.getCellBroadcastIdRanges().isEmpty());
    }

    @Test
    public void testClearCellBroadcastConfigOnModemReset() {
        List<CellBroadcastIdRange> ranges = new ArrayList<>();
        ranges.add(new CellBroadcastIdRange(0, 999, SmsCbMessage.MESSAGE_FORMAT_3GPP, true));

        mPhone.setCellBroadcastIdRanges(ranges, r -> assertTrue(
                TelephonyManager.CELL_BROADCAST_RESULT_SUCCESS == r));
        processAllMessages();

        assertEquals(mPhone.getCellBroadcastIdRanges(), ranges);

        Message m = mTracker.obtainMessage(CellBroadcastConfigTracker.EVENT_RADIO_RESET);
        AsyncResult.forMessage(m);
        m.sendToTarget();
        processAllMessages();

        // Verify the config is reset
        assertTrue(mPhone.getCellBroadcastIdRanges().isEmpty());
    }

    @Test
    public void testClearCellBroadcastConfigOnSubscriptionChanged() {
        List<CellBroadcastIdRange> ranges = new ArrayList<>();