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

Commit e4a33e24 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7634030 from aadf244e to sc-qpr1-release

Change-Id: I5b222ab48c0ead4f652980a2de6e179dd5a92409
parents 1fb47330 aadf244e
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import static android.service.carrier.CarrierMessagingService.RECEIVE_OPTIONS_SK
import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Activity;
import android.app.AppOpsManager;
@@ -1704,10 +1705,15 @@ public abstract class InboundSmsHandler extends StateMachine {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent == null) {
                logeWithLocalLog("onReceive: received null intent, faking " + mWaitingForIntent,
                        mInboundSmsTracker.getMessageId());
                return;
            }
            handleAction(intent, true);
        }

        private synchronized void handleAction(Intent intent, boolean onReceive) {
        private synchronized void handleAction(@NonNull Intent intent, boolean onReceive) {
            String action = intent.getAction();
            if (mWaitingForIntent == null || !mWaitingForIntent.getAction().equals(action)) {
                logeWithLocalLog("handleAction: Received " + action + " when expecting "
+7 −3
Original line number Diff line number Diff line
@@ -1103,12 +1103,16 @@ public class UiccController extends Handler {
                options.toBundle());
    }

    private boolean slotStatusChanged(ArrayList<IccSlotStatus> slotStatusList) {
    /**
     * Check if slot status has changed from the last received one
     */
    @VisibleForTesting
    public boolean slotStatusChanged(ArrayList<IccSlotStatus> slotStatusList) {
        if (sLastSlotStatus == null || sLastSlotStatus.size() != slotStatusList.size()) {
            return true;
        }
        for (IccSlotStatus iccSlotStatus : slotStatusList) {
            if (!sLastSlotStatus.contains(iccSlotStatus)) {
        for (int i = 0; i < slotStatusList.size(); i++) {
            if (!sLastSlotStatus.get(i).equals(slotStatusList.get(i))) {
                return true;
            }
        }
+6 −0
Original line number Diff line number Diff line
@@ -423,6 +423,12 @@ public class ContextFixture implements TestFixture<Context> {
            sendBroadcast(intent);
        }

        @Override
        public void sendBroadcast(Intent intent, String receiverPermission, Bundle initialExtras) {
            logd("sendBroadcast called for " + intent.getAction());
            sendBroadcast(intent);
        }

        @Override
        public void sendOrderedBroadcast(Intent intent, String receiverPermission) {
            logd("sendOrderedBroadcast called for " + intent.getAction());
+29 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.internal.telephony.uicc;
import static junit.framework.Assert.fail;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -634,4 +635,32 @@ public class UiccControllerTest extends TelephonyTest {
        assertEquals(mUiccControllerUT.convertToPublicCardId(knownEidFromApdu),
                mUiccControllerUT.getCardIdForDefaultEuicc());
    }

    @Test
    public void testSlotStatusChanged() {
        // simulate slot status loaded so that the UiccController sets the last slot status
        IccSlotStatus iss1 = new IccSlotStatus();
        iss1.setSlotState(1 /* active */);
        iss1.eid = "eid1";
        IccSlotStatus iss2 = new IccSlotStatus();
        iss2.setSlotState(1 /* active */);
        iss2.eid = "eid2";
        ArrayList<IccSlotStatus> status = new ArrayList<IccSlotStatus>();
        status.add(iss1);
        status.add(iss2);
        AsyncResult ar = new AsyncResult(null, status, null);
        Message msg = Message.obtain(mUiccControllerUT, EVENT_GET_SLOT_STATUS_DONE, ar);
        mUiccControllerUT.handleMessage(msg);
        processAllMessages();

        assertFalse(mUiccControllerUT.slotStatusChanged(status));

        // change the order of the IccSlotStatus in the list
        status = new ArrayList<>();
        status.add(iss2);
        status.add(iss1);

        // status should be treated different from last status
        assertTrue(mUiccControllerUT.slotStatusChanged(status));
    }
}