Search in sources :

Example 6 with UiccSlot

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

the class GsmCdmaPhoneTest method testGetIccCardUnknownAndAbsent.

@Test
@SmallTest
public void testGetIccCardUnknownAndAbsent() {
    // If UiccSlot.isStateUnknown is true, we should return a dummy IccCard with the state
    // set to UNKNOWN
    doReturn(null).when(mUiccController).getUiccProfileForPhone(anyInt());
    UiccSlot mockSlot = mock(UiccSlot.class);
    doReturn(mockSlot).when(mUiccController).getUiccSlotForPhone(anyInt());
    doReturn(true).when(mockSlot).isStateUnknown();
    IccCard iccCard = mPhoneUT.getIccCard();
    assertEquals(IccCardConstants.State.UNKNOWN, iccCard.getState());
    // if isStateUnknown is false, we should return a dummy IccCard with the state set to
    // ABSENT
    doReturn(false).when(mockSlot).isStateUnknown();
    iccCard = mPhoneUT.getIccCard();
    assertEquals(IccCardConstants.State.ABSENT, iccCard.getState());
}
Also used : UiccSlot(com.android.internal.telephony.uicc.UiccSlot) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 7 with UiccSlot

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

the class SimSlotState method getCurrentState.

/**
 * Returns the current SIM state.
 */
public static SimSlotState getCurrentState() {
    int numActiveSlots = 0;
    int numActiveSims = 0;
    int numActiveEsims = 0;
    UiccController uiccController = UiccController.getInstance();
    // since we cannot hold lock insider UiccController, using getUiccSlots() for length only
    for (int i = 0; i < uiccController.getUiccSlots().length; i++) {
        UiccSlot slot = uiccController.getUiccSlot(i);
        if (slot != null && slot.isActive()) {
            numActiveSlots++;
            // avoid CardState.isCardPresent() since this should not include restricted cards
            if (slot.getCardState() == CardState.CARDSTATE_PRESENT) {
                if (slot.isEuicc()) {
                    // need to check active profiles besides the presence of eSIM cards
                    UiccCard card = slot.getUiccCard();
                    if (card != null && card.getNumApplications() > 0) {
                        numActiveSims++;
                        numActiveEsims++;
                    }
                } else {
                    // physical SIMs do not always have non-null card
                    numActiveSims++;
                }
            }
        }
    }
    return new SimSlotState(numActiveSlots, numActiveSims, numActiveEsims);
}
Also used : UiccCard(com.android.internal.telephony.uicc.UiccCard) UiccController(com.android.internal.telephony.uicc.UiccController) UiccSlot(com.android.internal.telephony.uicc.UiccSlot)

Example 8 with UiccSlot

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

the class SubscriptionControllerTest method testGetEnabledSubscriptionIdDualSIM.

@Test
public void testGetEnabledSubscriptionIdDualSIM() {
    doReturn(SINGLE_SIM).when(mTelephonyManager).getSimCount();
    doReturn(SINGLE_SIM).when(mTelephonyManager).getPhoneCount();
    doReturn(SINGLE_SIM).when(mTelephonyManager).getActiveModemCount();
    // A dual SIM device may have logical slot 0 mapped to physical slot 0
    // (i.e. logical slot 1 mapped to physical slot 1)
    UiccSlotInfo slot0 = getFakeUiccSlotInfo(true, 0);
    UiccSlotInfo slot1 = getFakeUiccSlotInfo(true, 1);
    UiccSlotInfo[] uiccSlotInfos = { slot0, slot1 };
    UiccSlot[] uiccSlots = { mUiccSlot, mUiccSlot };
    doReturn(2).when(mTelephonyManager).getPhoneCount();
    doReturn(2).when(mTelephonyManager).getActiveModemCount();
    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 0, has settings enabled subscription 0
    Settings.Global.putInt(resolver, Settings.Global.ENABLED_SUBSCRIPTION_FOR_SLOT + 0, 0);
    Settings.Global.putInt(resolver, Settings.Global.ENABLED_SUBSCRIPTION_FOR_SLOT + 1, 1);
    int enabledSubscription = mSubscriptionControllerUT.getEnabledSubscriptionId(0);
    int secondEabledSubscription = mSubscriptionControllerUT.getEnabledSubscriptionId(1);
    assertEquals(0, enabledSubscription);
    assertEquals(1, secondEabledSubscription);
}
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 9 with UiccSlot

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

the class EuiccCardController method getEuiccCard.

private EuiccCard getEuiccCard(String cardId) {
    UiccController controller = UiccController.getInstance();
    int slotId = controller.getUiccSlotForCardId(cardId);
    if (slotId != UiccController.INVALID_SLOT_ID) {
        UiccSlot slot = controller.getUiccSlot(slotId);
        if (slot.isEuicc()) {
            return (EuiccCard) controller.getUiccCardForSlot(slotId);
        }
    }
    loge("EuiccCard is null. CardId : " + cardId);
    return null;
}
Also used : UiccController(com.android.internal.telephony.uicc.UiccController) EuiccCard(com.android.internal.telephony.uicc.euicc.EuiccCard) UiccSlot(com.android.internal.telephony.uicc.UiccSlot)

Example 10 with UiccSlot

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

the class VendorSubscriptionInfoUpdater method handleSimReady.

@Override
protected void handleSimReady(int phoneId) {
    List<Integer> cardIds = new ArrayList<>();
    Rlog.d(LOG_TAG, "handleSimReady: phoneId: " + phoneId);
    if (sIccId[phoneId] != null && sIccId[phoneId].equals(ICCID_STRING_FOR_NO_SIM)) {
        Rlog.d(LOG_TAG, " SIM" + (phoneId + 1) + " hot plug in");
        sIccId[phoneId] = null;
    }
    UiccSlot uiccSlot = UiccController.getInstance().getUiccSlotForPhone(phoneId);
    if (uiccSlot == null) {
        Rlog.d(LOG_TAG, "handleSimReady: uiccSlot null");
        return;
    }
    String iccId = uiccSlot.getIccId();
    if (IccUtils.stripTrailingFs(iccId) == null) {
        Rlog.d(LOG_TAG, "handleSimReady: IccID null");
        return;
    }
    sIccId[phoneId] = IccUtils.stripTrailingFs(iccId);
    updateSubscriptionInfoByIccId(phoneId, true);
    cardIds.add(getCardIdFromPhoneId(phoneId));
    updateEmbeddedSubscriptions(cardIds, (hasChanges) -> {
        if (hasChanges) {
            SubscriptionController.getInstance().notifySubscriptionInfoChanged();
        }
    });
    broadcastSimStateChanged(phoneId, IccCardConstants.INTENT_VALUE_ICC_READY, null);
    broadcastSimCardStateChanged(phoneId, TelephonyManager.SIM_STATE_PRESENT);
    broadcastSimApplicationStateChanged(phoneId, TelephonyManager.SIM_STATE_NOT_READY);
}
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