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

Commit 6b513bf1 authored by Muralidhar Reddy's avatar Muralidhar Reddy
Browse files

isSimPortAvailable API should return true if the calling app can activate a...

isSimPortAvailable API should return true if the calling app can activate a new profile on the selected port without any user consent or deactivate dialog.

Currently isSimPortAvailable API returns true if the port is active without any profile enabled on it or the calling app has carrier privileges over the selected port. It is hampering switching to MEP mode when the psim is active and empty.

Test: Manually verified on C10.
Bug: 240273417
Change-Id: I67eeb182a1bd05875f13aa5f5514ad3b2adbf8bd
parent 610d8d55
Loading
Loading
Loading
Loading
+57 −45
Original line number Original line Diff line number Diff line
@@ -1939,13 +1939,10 @@ public class EuiccController extends IEuiccController.Stub {


    @Override
    @Override
    public boolean isSimPortAvailable(int cardId, int portIndex, String callingPackage) {
    public boolean isSimPortAvailable(int cardId, int portIndex, String callingPackage) {
        List<UiccCardInfo> cardInfos;
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);
        final long token = Binder.clearCallingIdentity();
        final long token = Binder.clearCallingIdentity();
        try {
        try {
            cardInfos = mTelephonyManager.getUiccCardsInfo();
            List<UiccCardInfo> cardInfos = mTelephonyManager.getUiccCardsInfo();
        } finally {
            Binder.restoreCallingIdentity(token);
        }
            for (UiccCardInfo info : cardInfos) {
            for (UiccCardInfo info : cardInfos) {
                if (info == null || info.getCardId() != cardId) {
                if (info == null || info.getCardId() != cardId) {
                    continue;
                    continue;
@@ -1960,9 +1957,21 @@ public class EuiccController extends IEuiccController.Stub {
                    if (portInfo == null || portInfo.getPortIndex() != portIndex) {
                    if (portInfo == null || portInfo.getPortIndex() != portIndex) {
                        continue;
                        continue;
                    }
                    }
                // Return false if port is not active.
                    if (!portInfo.isActive()) {
                    if (!portInfo.isActive()) {
                    return false;
                        // port is inactive, check whether the caller can activate a new profile
                        // seamlessly. This is possible in below condition:
                        // 1. Device in DSDS Mode(P+E).
                        // 2. pSIM slot is active but no active subscription.
                        // 3. Caller has carrier privileges on any phone
                        boolean hasActiveRemovableNonEuiccSlot = getRemovableNonEuiccSlot() != null
                                && getRemovableNonEuiccSlot().isActive();
                        boolean hasCarrierPrivileges = mTelephonyManager
                                .checkCarrierPrivilegesForPackageAnyPhone(callingPackage)
                                == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
                        return mTelephonyManager.isMultiSimEnabled()
                                && hasActiveRemovableNonEuiccSlot
                                && !isRemovalNonEuiccSlotHasActiveSubscription()
                                && hasCarrierPrivileges;
                    }
                    }
                    // A port is available if it has no profiles enabled on it or calling app has
                    // A port is available if it has no profiles enabled on it or calling app has
                    // Carrier privilege over the profile installed on the selected port.
                    // Carrier privilege over the profile installed on the selected port.
@@ -1993,6 +2002,9 @@ public class EuiccController extends IEuiccController.Stub {
                            == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS);
                            == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS);
                }
                }
            }
            }
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        return false;
        return false;
    }
    }