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

Commit d79c0308 authored by Muralidhar Reddy Mule's avatar Muralidhar Reddy Mule Committed by Gerrit Code Review
Browse files

Merge "[MEP] Add port index to icc logical channel open, close and trasmit APIs."

parents f481da98 bddb006f
Loading
Loading
Loading
Loading
+6 −16
Original line number Diff line number Diff line
@@ -268,25 +268,15 @@ public class UiccController extends Handler {
    }

    /**
     * Given the slot index, return the phone ID, or -1 if no phone is associated with the given
     * slot.
     * Given the slot index and port index, return the phone ID, or -1 if no phone is associated
     * with the given slot and port.
     * @param slotId the slot index to check
     * @param portIndex unique index referring to a port belonging to the SIM slot
     * @return the associated phone ID or -1
     */
    // TODO In case of MEP, pass port index as well, so that proper phoneId can be retrieved.
    public int getPhoneIdFromSlotId(int slotId/*, int portIdx*/) {
        for (int i = 0; i < mPhoneIdToSlotId.length; i++) {
            if (mPhoneIdToSlotId[i] == slotId) {
                /*// In case of MEP, slotId can be same for different phoneIds.
                // So add condition check for portIdx as well.
                UiccPort uiccPort = getUiccPortForPhone(mPhoneIdToSlotId[i]);
                if (uiccPort != null && uiccPort.getPortIdx() == portIdx) {
                    return i;
                }*/
                return i;
            }
        }
        return -1;
    public int getPhoneIdFromSlotPortIndex(int slotId, int portIndex) {
        UiccSlot slot = getUiccSlot(slotId);
        return slot == null ? UiccSlot.INVALID_PHONE_ID : slot.getPhoneIdFromPortIndex(portIndex);
    }

    /**
+12 −3
Original line number Diff line number Diff line
@@ -197,7 +197,9 @@ public class UiccSlot extends Handler {
            }
            mPortIdxToPhoneId.clear();
            for (int i = 0; i < simPortInfos.length; i++) {
                mPortIdxToPhoneId.put(i, simPortInfos[i].mLogicalSlotIndex);
                // If port is not active, update with invalid phone id(i.e. -1)
                mPortIdxToPhoneId.put(i, simPortInfos[i].mPortActive ?
                        simPortInfos[i].mLogicalSlotIndex : INVALID_PHONE_ID);
            }
        }
    }
@@ -228,7 +230,7 @@ public class UiccSlot extends Handler {
        }
    }

    public int getPortIdx(int phoneId) {
    public int getPortIndexFromPhoneId(int phoneId) {
        synchronized (mLock) {
            for (Map.Entry<Integer, Integer> entry : mPortIdxToPhoneId.entrySet()) {
                if (entry.getValue() == phoneId) {
@@ -239,6 +241,12 @@ public class UiccSlot extends Handler {
        }
    }

    public int getPhoneIdFromPortIndex(int portIndex) {
        synchronized (mLock) {
            return mPortIdxToPhoneId.getOrDefault(portIndex, INVALID_PHONE_ID);
        }
    }

    public boolean isPortActive(int portIdx) {
        UiccPort uiccPort = null;
        synchronized (mLock) {
@@ -489,7 +497,8 @@ public class UiccSlot extends Handler {
        if (phoneId != INVALID_PHONE_ID) {
            UiccController.updateInternalIccState(
                    mContext, IccCardConstants.State.UNKNOWN, null, phoneId);
            mLastRadioState.put(getPortIdx(phoneId), TelephonyManager.RADIO_POWER_UNAVAILABLE);
            mLastRadioState.put(getPortIndexFromPhoneId(phoneId),
                    TelephonyManager.RADIO_POWER_UNAVAILABLE);
        }

        mCardState = null;