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

Commit be812694 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Treat CSIM/RUIM as supported apps only if CDMA is supported."

parents 232eaaa0 d6e9181e
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.internal.telephony.uicc;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
@@ -29,6 +30,7 @@ import android.telephony.Rlog;
import android.telephony.TelephonyManager;
import android.util.LocalLog;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.IccCardConstants;
@@ -114,6 +116,7 @@ public class UiccController extends Handler {
    private UiccSlot[] mUiccSlots;
    private int[] mPhoneIdToSlotId;
    private boolean mIsSlotStatusSupported = true;
    private boolean mIsCdmaSupported = true;

    private static final Object mLock = new Object();
    private static UiccController mInstance;
@@ -181,6 +184,11 @@ public class UiccController extends Handler {
        }

        mLauncher = new UiccStateChangedLauncher(c, this);

        // set mIsCdmaSupported based on PackageManager.FEATURE_TELEPHONY_CDMA
        PackageManager packageManager = c.getPackageManager();
        mIsCdmaSupported =
                packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CDMA);
    }

    private int getSlotIdFromPhoneId(int phoneId) {
@@ -673,6 +681,10 @@ public class UiccController extends Handler {
        mCis[index].getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE, index));
    }

    public boolean isCdmaSupported() {
        return mIsCdmaSupported;
    }

    private boolean isValidPhoneIndex(int index) {
        return (index >= 0 && index < TelephonyManager.getDefault().getPhoneCount());
    }
@@ -700,6 +712,7 @@ public class UiccController extends Handler {
        }
        pw.println();
        pw.flush();
        pw.println(" mIsCdmaSupported=" + mIsCdmaSupported);
        pw.println(" mUiccSlots: size=" + mUiccSlots.length);
        for (int i = 0; i < mUiccSlots.length; i++) {
            if (mUiccSlots[i] == null) {
+7 −4
Original line number Diff line number Diff line
@@ -956,16 +956,19 @@ public class UiccProfile extends IccCard {
     * this only checks for SIM/USIM and CSIM/RUIM apps. ISIM is considered not supported for this
     * purpose as there are cards that have ISIM app that is never read (there are SIMs for which
     * the state of ISIM goes to DETECTED but never to READY).
     * CSIM/RUIM apps are considered not supported if CDMA is not supported.
     */
    private boolean isSupportedApplication(UiccCardApplication app) {
        // TODO: 2/15/18 Add check to see if ISIM app will go to READY state, and if yes, check for
        // ISIM also (currently ISIM is considered as not supported in this function)
        if (app.getType() != AppType.APPTYPE_USIM && app.getType() != AppType.APPTYPE_CSIM
                && app.getType() != AppType.APPTYPE_SIM && app.getType() != AppType.APPTYPE_RUIM) {
            return false;
        }
        if (app.getType() == AppType.APPTYPE_USIM || app.getType() == AppType.APPTYPE_SIM
                || (UiccController.getInstance().isCdmaSupported()
                && (app.getType() == AppType.APPTYPE_CSIM
                || app.getType() == AppType.APPTYPE_RUIM))) {
            return true;
        }
        return false;
    }

    private void checkAndUpdateIfAnyAppToBeIgnored() {
        boolean[] appReadyStateTracker = new boolean[AppType.APPTYPE_ISIM.ordinal() + 1];
+57 −0
Original line number Diff line number Diff line
@@ -492,6 +492,63 @@ public class UiccProfileTest extends TelephonyTest {
        assertEquals(State.NOT_READY, mUiccProfile.getState());
    }

    private void testWithCsimApp() {
        /* update app status and index */
        IccCardApplicationStatus umtsApp = composeUiccApplicationStatus(
                IccCardApplicationStatus.AppType.APPTYPE_USIM,
                AppState.APPSTATE_READY, "0xA2");
        IccCardApplicationStatus imsApp = composeUiccApplicationStatus(
                IccCardApplicationStatus.AppType.APPTYPE_ISIM,
                AppState.APPSTATE_READY, "0xA1");
        IccCardApplicationStatus cdmaApp = composeUiccApplicationStatus(
                IccCardApplicationStatus.AppType.APPTYPE_CSIM,
                AppState.APPSTATE_DETECTED, "0xA2");
        mIccCardStatus.mApplications = new IccCardApplicationStatus[]{imsApp, umtsApp, cdmaApp};
        mIccCardStatus.mCdmaSubscriptionAppIndex = 2;
        mIccCardStatus.mImsSubscriptionAppIndex = 0;
        mIccCardStatus.mGsmUmtsSubscriptionAppIndex = 1;

        Message mProfileUpdate = mHandler.obtainMessage(UICCPROFILE_UPDATE_APPLICATION_EVENT);
        setReady(false);
        mProfileUpdate.sendToTarget();

        waitUntilReady();

        /* wait for the carrier privilege rules to be loaded */
        waitForMs(50);
        assertEquals(3, mUiccProfile.getNumApplications());

        mUiccProfile.mHandler.sendMessage(
                mUiccProfile.mHandler.obtainMessage(UiccProfile.EVENT_APP_READY));
        waitForMs(SCARY_SLEEP_MS);
    }

    @Test
    @SmallTest
    public void testUpdateUiccProfileApplicationCdmaSupported() {
        // CDMA supported
        doReturn(true).when(mUiccController).isCdmaSupported();

        testWithCsimApp();

        // CDMA is supported and CSIM app is not ready, so state should be NOT_READY
        assertEquals(State.NOT_READY, mUiccProfile.getState());
    }

    @Test
    @SmallTest
    public void testUpdateUiccProfileApplicationCdmaNotSupported() {
        // CDMA supported
        doReturn(false).when(mUiccController).isCdmaSupported();

        testWithCsimApp();

        // state is loaded as all records are loaded right away as SimulatedCommands returns
        // response for them right away. Ideally applications and records should be mocked.
        // CSIM is not ready but that should not matter since CDMA is not supported.
        assertEquals(State.LOADED, mUiccProfile.getState());
    }

    @Test
    @SmallTest
    public void testUpdateExternalState() {