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

Commit 40bf1c7b authored by Nazanin Bakhshi's avatar Nazanin Bakhshi Committed by Gerrit Code Review
Browse files

Merge "Make UiccProfile.isCdmaSupported static to avoid UiccController deadlock"

parents 561aae59 b23ae3b7
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();