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

Commit 402c0d49 authored by Chen Xu's avatar Chen Xu
Browse files

isSimPortAvailable should clear calling identity before call TM APIs

Bug: 209060082
Test: Manual
Change-Id: I5124890e0aaefed88b6450f1ba9d0365dc77541c
parent 59e23da6
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -1627,13 +1627,19 @@ public class EuiccController extends IEuiccController.Stub {
                Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
                == PackageManager.PERMISSION_GRANTED;
    }

    @Override
    public boolean isSimPortAvailable(int cardId, int portIndex, String callingPackage) {
        List<UiccCardInfo> cardInfos = mTelephonyManager.getUiccCardsInfo();
        List<UiccCardInfo> cardInfos;
        final long token = Binder.clearCallingIdentity();
        try {
            cardInfos = mTelephonyManager.getUiccCardsInfo();
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        if (ArrayUtils.isEmpty(cardInfos)) {
            return false;
        }
        int result = TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED;
        for (UiccCardInfo info : cardInfos) {
            //return false if physical card
            if (info != null && info.getCardId() == cardId && (!info.isEuicc()
@@ -1647,7 +1653,7 @@ public class EuiccController extends IEuiccController.Stub {
                }
                // port is available if port is inactive and ICCID or calling app has carrier
                // privilege over the profile installed on the selected port.
                result = port.getUiccProfile().getCarrierPrivilegeStatus(
                int result = port.getUiccProfile().getCarrierPrivilegeStatus(
                        mContext.getPackageManager(), callingPackage);
                if ((result == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS)
                        || (portInfo.getIccId() == null && portInfo.isActive())) {