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

Commit b23ae3b7 authored by Nazanin Bakhshi's avatar Nazanin Bakhshi
Browse files

Make UiccProfile.isCdmaSupported static to avoid UiccController deadlock

Change: 116513453
Test: verified that UiccController is always called in a static fashion
from UiccProfile. + updated unittests.

Change-Id: I753dea4f3c84a8c44b4b4952ff76bbc7c8c11714
parent 8b29c937
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -115,7 +115,6 @@ 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;
@@ -183,11 +182,6 @@ 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) {
@@ -702,8 +696,16 @@ public class UiccController extends Handler {
        mCis[index].getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE, index));
    }

    public boolean isCdmaSupported() {
        return mIsCdmaSupported;
    /**
     * static method to return whether CDMA is supported on the device
     * @param context object representative of the application that is calling this method
     * @return true if CDMA is supported by the device
     */
    public static boolean isCdmaSupported(Context context) {
        PackageManager packageManager = context.getPackageManager();
        boolean isCdmaSupported =
                packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CDMA);
        return isCdmaSupported;
    }

    private boolean isValidPhoneIndex(int index) {
@@ -733,7 +735,7 @@ public class UiccController extends Handler {
        }
        pw.println();
        pw.flush();
        pw.println(" mIsCdmaSupported=" + mIsCdmaSupported);
        pw.println(" mIsCdmaSupported=" + isCdmaSupported(mContext));
        pw.println(" mUiccSlots: size=" + mUiccSlots.length);
        for (int i = 0; i < mUiccSlots.length; i++) {
            if (mUiccSlots[i] == null) {
+1 −1
Original line number Diff line number Diff line
@@ -960,7 +960,7 @@ public class UiccProfile extends IccCard {
        // 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_SIM
                || (UiccController.getInstance().isCdmaSupported()
                || (UiccController.isCdmaSupported(mContext)
                && (app.getType() == AppType.APPTYPE_CSIM
                || app.getType() == AppType.APPTYPE_RUIM))) {
            return true;
+6 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
@@ -551,7 +552,8 @@ public class UiccProfileTest extends TelephonyTest {
    @SmallTest
    public void testUpdateUiccProfileApplicationCdmaSupported() {
        // CDMA supported
        doReturn(true).when(mUiccController).isCdmaSupported();
        doReturn(true)
            .when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CDMA);

        testWithCsimApp();

@@ -562,8 +564,9 @@ public class UiccProfileTest extends TelephonyTest {
    @Test
    @SmallTest
    public void testUpdateUiccProfileApplicationCdmaNotSupported() {
        // CDMA supported
        doReturn(false).when(mUiccController).isCdmaSupported();
        // CDMA not supported
        doReturn(false)
            .when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CDMA);

        testWithCsimApp();