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

Commit 8d8ab947 authored by Muralidhar Reddy's avatar Muralidhar Reddy Committed by Automerger Merge Worker
Browse files

[MEP] Add port index in SubscriptionInfo database am: 1b38e22d

parents 1abdc3d6 1b38e22d
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -589,6 +589,8 @@ public class SubscriptionController extends ISub.Stub {
                SubscriptionManager.GROUP_UUID));
        int profileClass = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.PROFILE_CLASS));
        int portIndex = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.PORT_INDEX));
        int subType = cursor.getInt(cursor.getColumnIndexOrThrow(
                SubscriptionManager.SUBSCRIPTION_TYPE));
        String groupOwner = getOptionalStringFromCursor(cursor, SubscriptionManager.GROUP_OWNER,
@@ -606,7 +608,8 @@ public class SubscriptionController extends ISub.Stub {
                    + " countIso:" + countryIso + " isEmbedded:"
                    + isEmbedded + " accessRules:" + Arrays.toString(accessRules)
                    + " carrierConfigAccessRules: " + Arrays.toString(carrierConfigAccessRules)
                    + " cardId:" + cardIdToPrint + " publicCardId:" + publicCardId
                    + " cardId:" + cardIdToPrint + " portIndex:" + portIndex
                    + " publicCardId:" + publicCardId
                    + " isOpportunistic:" + isOpportunistic + " groupUUID:" + groupUUID
                    + " profileClass:" + profileClass + " subscriptionType: " + subType
                    + " carrierConfigAccessRules:" + carrierConfigAccessRules
@@ -622,7 +625,8 @@ public class SubscriptionController extends ISub.Stub {
                carrierName, nameSource, iconTint, number, dataRoaming, /* icon= */ null,
                mcc, mnc, countryIso, isEmbedded, accessRules, cardId, publicCardId,
                isOpportunistic, groupUUID, /* isGroupDisabled= */ false , carrierId, profileClass,
                subType, groupOwner, carrierConfigAccessRules, areUiccApplicationsEnabled);
                subType, groupOwner, carrierConfigAccessRules, areUiccApplicationsEnabled,
                portIndex);
        info.setAssociatedPlmns(ehplmns, hplmns);
        return info;
    }
@@ -1367,7 +1371,8 @@ public class SubscriptionController extends ISub.Stub {
            Cursor cursor = resolver.query(SubscriptionManager.CONTENT_URI,
                    new String[]{SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID,
                            SubscriptionManager.SIM_SLOT_INDEX, SubscriptionManager.NAME_SOURCE,
                            SubscriptionManager.ICC_ID, SubscriptionManager.CARD_ID},
                            SubscriptionManager.ICC_ID, SubscriptionManager.CARD_ID,
                            SubscriptionManager.PORT_INDEX},
                    selection, args, null);

            boolean setDisplayName = false;
@@ -1394,6 +1399,7 @@ public class SubscriptionController extends ISub.Stub {
                        int nameSource = cursor.getInt(2);
                        String oldIccId = cursor.getString(3);
                        String oldCardId = cursor.getString(4);
                        int oldPortIndex = cursor.getInt(5);
                        ContentValues value = new ContentValues();

                        if (slotIndex != oldSimInfoId) {
@@ -1413,6 +1419,15 @@ public class SubscriptionController extends ISub.Stub {
                            }
                        }

                        //update portIndex for pSim
                        UiccSlot slot = mUiccController.getUiccSlotForPhone(slotIndex);
                        if (slot != null && !slot.isEuicc()) {
                            int portIndex = slot.getPortIndexFromIccId(uniqueId);
                            if (portIndex != oldPortIndex) {
                                value.put(SubscriptionManager.PORT_INDEX, portIndex);
                            }
                        }

                        if (value.size() > 0) {
                            resolver.update(SubscriptionManager.getUriForSubscriptionId(subId),
                                    value, null, null);
@@ -1730,6 +1745,10 @@ public class SubscriptionController extends ISub.Stub {
                    value.put(SubscriptionManager.CARD_ID, cardId);
                }
            }
            UiccSlot slot = mUiccController.getUiccSlotForPhone(slotIndex);
            if (slot != null) {
                value.put(SubscriptionManager.PORT_INDEX, slot.getPortIndexFromIccId(uniqueId));
            }
        }
        value.put(SubscriptionManager.ALLOWED_NETWORK_TYPES,
                "user=" + RadioAccessFamily.getRafFromNetworkType(
+18 −1
Original line number Diff line number Diff line
@@ -65,8 +65,10 @@ import com.android.telephony.Rlog;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.stream.Collectors;

/**
 *@hide
@@ -698,8 +700,12 @@ public class SubscriptionInfoUpdater extends Handler {
            }
            String iccId = sInactiveIccIds[phoneId] != null
                    ? sInactiveIccIds[phoneId] : sIccId[phoneId];
            ContentValues value = new ContentValues(1);
            ContentValues value = new ContentValues();
            value.put(SubscriptionManager.UICC_APPLICATIONS_ENABLED, true);
            if (isSimAbsent) {
                // When sim is absent, set the port index to invalid port index -1;
                value.put(SubscriptionManager.PORT_INDEX, TelephonyManager.INVALID_PORT_INDEX);
            }
            sContext.getContentResolver().update(SubscriptionManager.CONTENT_URI, value,
                    SubscriptionManager.ICC_ID + "=\'" + iccId + "\'", null);
            sInactiveIccIds[phoneId] = null;
@@ -982,6 +988,8 @@ public class SubscriptionInfoUpdater extends Handler {
                        SubscriptionManager.NAME_SOURCE_CARRIER);
            }
            values.put(SubscriptionManager.PROFILE_CLASS, embeddedProfile.getProfileClass());
            values.put(SubscriptionManager.PORT_INDEX,
                    getEmbeddedProfilePortIndex(embeddedProfile.getIccid()));
            CarrierIdentifier cid = embeddedProfile.getCarrierIdentifier();
            if (cid != null) {
                // Due to the limited subscription information, carrier id identified here might
@@ -1046,6 +1054,15 @@ public class SubscriptionInfoUpdater extends Handler {
        return hasChanges;
    }

    private int getEmbeddedProfilePortIndex(String iccId) {
        UiccSlot[] slots = UiccController.getInstance().getUiccSlots();
        for (UiccSlot slot : slots) {
            if (slot != null && slot.isEuicc() && slot.isIccIdMappedToPortIndex(iccId)) {
                return slot.getPortIndexFromIccId(iccId);
            }
        }
        return TelephonyManager.INVALID_PORT_INDEX;
    }
    /**
     * Called by CarrierConfigLoader to update the subscription before sending a broadcast.
     */
+18 −0
Original line number Diff line number Diff line
@@ -241,6 +241,24 @@ public class UiccSlot extends Handler {
        }
    }

    public boolean isIccIdMappedToPortIndex(String iccId) {
        synchronized (mLock) {
            return mIccIds.containsValue(iccId);
        }
    }

    public int getPortIndexFromIccId(String iccId) {
        synchronized (mLock) {
            for (Map.Entry<Integer, String> entry : mIccIds.entrySet()) {
                if (entry.getValue().equalsIgnoreCase(iccId)) {
                    return entry.getKey();
                }
            }
            // If iccId is not found, return invalid port index.
            return TelephonyManager.INVALID_PORT_INDEX;
        }
    }

    public int getPhoneIdFromPortIndex(int portIndex) {
        synchronized (mLock) {
            return mPortIdxToPhoneId.getOrDefault(portIndex, INVALID_PHONE_ID);
+2 −1
Original line number Diff line number Diff line
@@ -118,7 +118,8 @@ public class FakeTelephonyProvider extends MockContentProvider {
                    + Telephony.SimInfo.COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS + " TEXT,"
                    + Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING + " INTEGER DEFAULT 0,"
                    + Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS + "TEXT,"
                    + Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED + " INTEGER DEFAULT -1"
                    + Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED + " INTEGER DEFAULT -1,"
                    + Telephony.SimInfo.COLUMN_PORT_INDEX + " INTEGER DEFAULT -1"
                    + ");";
        }