Search in sources :

Example 11 with UiccSlot

use of com.android.internal.telephony.uicc.UiccSlot in project android_frameworks_opt_telephony by LineageOS.

the class SubscriptionControllerTest method testGetEnabledSubscriptionIdSingleSIM.

@Test
public void testGetEnabledSubscriptionIdSingleSIM() {
    // A single SIM device may have logical slot 0 mapped to physical slot 1
    // (i.e. logical slot -1 mapped to physical slot 0)
    UiccSlotInfo slot0 = getFakeUiccSlotInfo(false, -1);
    UiccSlotInfo slot1 = getFakeUiccSlotInfo(true, 0);
    UiccSlotInfo[] uiccSlotInfos = { slot0, slot1 };
    UiccSlot[] uiccSlots = { mUiccSlot, mUiccSlot };
    doReturn(uiccSlotInfos).when(mTelephonyManager).getUiccSlotsInfo();
    doReturn(uiccSlots).when(mUiccController).getUiccSlots();
    assertEquals(2, UiccController.getInstance().getUiccSlots().length);
    ContentResolver resolver = mContext.getContentResolver();
    // logical 0 should find physical 1, has settings enabled subscription 0
    Settings.Global.putInt(resolver, Settings.Global.ENABLED_SUBSCRIPTION_FOR_SLOT + 1, 0);
    int enabledSubscription = mSubscriptionControllerUT.getEnabledSubscriptionId(0);
    assertEquals(0, enabledSubscription);
}
Also used : UiccSlotInfo(android.telephony.UiccSlotInfo) UiccSlot(com.android.internal.telephony.uicc.UiccSlot) ContentResolver(android.content.ContentResolver) MockContentResolver(android.test.mock.MockContentResolver) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 12 with UiccSlot

use of com.android.internal.telephony.uicc.UiccSlot in project android_frameworks_opt_telephony by LineageOS.

the class SubscriptionInfoUpdater method isAllIccIdQueryDone.

@UnsupportedAppUsage
protected boolean isAllIccIdQueryDone() {
    for (int i = 0; i < TelephonyManager.getDefault().getActiveModemCount(); i++) {
        UiccSlot slot = UiccController.getInstance().getUiccSlotForPhone(i);
        int slotId = UiccController.getInstance().getSlotIdFromPhoneId(i);
        if (sIccId[i] == null || slot == null || !slot.isActive()) {
            if (sIccId[i] == null) {
                logd("Wait for SIM " + i + " Iccid");
            } else {
                logd(String.format("Wait for slot corresponding to phone %d to be active, " + "slotId is %d", i, slotId));
            }
            return false;
        }
    }
    logd("All IccIds query complete");
    return true;
}
Also used : UiccSlot(com.android.internal.telephony.uicc.UiccSlot) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 13 with UiccSlot

use of com.android.internal.telephony.uicc.UiccSlot in project android_frameworks_opt_telephony by LineageOS.

the class SubscriptionInfoUpdater method updateSubscriptionInfoByIccId.

protected synchronized void updateSubscriptionInfoByIccId(int phoneId, boolean updateEmbeddedSubs) {
    logd("updateSubscriptionInfoByIccId:+ Start - phoneId: " + phoneId);
    if (!SubscriptionManager.isValidPhoneId(phoneId)) {
        loge("[updateSubscriptionInfoByIccId]- invalid phoneId=" + phoneId);
        return;
    }
    logd("updateSubscriptionInfoByIccId: removing subscription info record: phoneId " + phoneId);
    // Clear phoneId only when sim absent is not enough. It's possible to switch SIM profile
    // within the same slot. Need to clear the slot index of the previous sub. Thus always clear
    // for the changing slot first.
    SubscriptionController.getInstance().clearSubInfoRecord(phoneId);
    // If SIM is not absent, insert new record or update existing record.
    if (!ICCID_STRING_FOR_NO_SIM.equals(sIccId[phoneId])) {
        logd("updateSubscriptionInfoByIccId: adding subscription info record: iccid: " + sIccId[phoneId] + ", phoneId:" + phoneId);
        mSubscriptionManager.addSubscriptionInfoRecord(sIccId[phoneId], phoneId);
    }
    List<SubscriptionInfo> subInfos = SubscriptionController.getInstance().getSubInfoUsingSlotIndexPrivileged(phoneId);
    if (subInfos != null) {
        boolean changed = false;
        for (int i = 0; i < subInfos.size(); i++) {
            SubscriptionInfo temp = subInfos.get(i);
            ContentValues value = new ContentValues(1);
            String msisdn = TelephonyManager.getDefault().getLine1Number(temp.getSubscriptionId());
            if (!TextUtils.equals(msisdn, temp.getNumber())) {
                value.put(SubscriptionManager.NUMBER, msisdn);
                sContext.getContentResolver().update(SubscriptionManager.getUriForSubscriptionId(temp.getSubscriptionId()), value, null, null);
                changed = true;
            }
        }
        if (changed) {
            // refresh Cached Active Subscription Info List
            SubscriptionController.getInstance().refreshCachedActiveSubscriptionInfoList();
        }
    }
    // TODO investigate if we can update for each slot separately.
    if (isAllIccIdQueryDone()) {
        // Ensure the modems are mapped correctly
        if (mSubscriptionManager.isActiveSubId(mSubscriptionManager.getDefaultDataSubscriptionId())) {
            mSubscriptionManager.setDefaultDataSubId(mSubscriptionManager.getDefaultDataSubscriptionId());
        } else {
            logd("bypass reset default data sub if inactive");
        }
        setSubInfoInitialized();
    }
    UiccController uiccController = UiccController.getInstance();
    UiccSlot[] uiccSlots = uiccController.getUiccSlots();
    if (uiccSlots != null && updateEmbeddedSubs) {
        List<Integer> cardIds = new ArrayList<>();
        for (UiccSlot uiccSlot : uiccSlots) {
            if (uiccSlot != null && uiccSlot.getUiccCard() != null) {
                int cardId = uiccController.convertToPublicCardId(uiccSlot.getUiccCard().getCardId());
                cardIds.add(cardId);
            }
        }
        updateEmbeddedSubscriptions(cardIds, (hasChanges) -> {
            if (hasChanges) {
                SubscriptionController.getInstance().notifySubscriptionInfoChanged();
            }
            if (DBG)
                logd("updateSubscriptionInfoByIccId: SubscriptionInfo update complete");
        });
    }
    SubscriptionController.getInstance().notifySubscriptionInfoChanged();
    if (DBG)
        logd("updateSubscriptionInfoByIccId: SubscriptionInfo update complete");
}
Also used : ContentValues(android.content.ContentValues) UiccController(com.android.internal.telephony.uicc.UiccController) ArrayList(java.util.ArrayList) SubscriptionInfo(android.telephony.SubscriptionInfo) UiccSlot(com.android.internal.telephony.uicc.UiccSlot)

Example 14 with UiccSlot

use of com.android.internal.telephony.uicc.UiccSlot in project android_frameworks_opt_telephony by LineageOS.

the class SubscriptionController method getIccIdsOfInsertedPhysicalSims.

private List<String> getIccIdsOfInsertedPhysicalSims() {
    List<String> ret = new ArrayList<>();
    UiccSlot[] uiccSlots = UiccController.getInstance().getUiccSlots();
    if (uiccSlots == null)
        return ret;
    for (UiccSlot uiccSlot : uiccSlots) {
        if (uiccSlot != null && uiccSlot.getCardState() != null && uiccSlot.getCardState().isCardPresent() && !uiccSlot.isEuicc() && !TextUtils.isEmpty(uiccSlot.getIccId())) {
            ret.add(IccUtils.stripTrailingFs(uiccSlot.getIccId()));
        }
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) UiccSlot(com.android.internal.telephony.uicc.UiccSlot)

Aggregations

UiccSlot (com.android.internal.telephony.uicc.UiccSlot)14 SubscriptionInfo (android.telephony.SubscriptionInfo)3 SmallTest (android.test.suitebuilder.annotation.SmallTest)3 FlakyTest (androidx.test.filters.FlakyTest)3 UiccController (com.android.internal.telephony.uicc.UiccController)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ContentResolver (android.content.ContentResolver)2 UiccSlotInfo (android.telephony.UiccSlotInfo)2 MockContentResolver (android.test.mock.MockContentResolver)2 UnsupportedAppUsage (android.compat.annotation.UnsupportedAppUsage)1 ContentValues (android.content.ContentValues)1 Pair (android.util.Pair)1 UiccCard (com.android.internal.telephony.uicc.UiccCard)1 EuiccCard (com.android.internal.telephony.uicc.euicc.EuiccCard)1