Search in sources :

Example 11 with UiccSlotInfo

use of android.telephony.UiccSlotInfo in project android_packages_apps_Settings by omnirom.

the class SimSlotChangeHandler method onSlotsStatusChange.

void onSlotsStatusChange(Context context) {
    init(context);
    if (Looper.myLooper() == Looper.getMainLooper()) {
        throw new IllegalStateException("Cannot be called from main thread.");
    }
    if (mTelMgr.getActiveModemCount() > 1) {
        Log.i(TAG, "The device is already in DSDS mode. Do nothing.");
        return;
    }
    UiccSlotInfo removableSlotInfo = getRemovableUiccSlotInfo();
    if (removableSlotInfo == null) {
        Log.e(TAG, "Unable to find the removable slot. Do nothing.");
        return;
    }
    int lastRemovableSlotState = getLastRemovableSimSlotState(mContext);
    int currentRemovableSlotState = removableSlotInfo.getCardStateInfo();
    // Sets the current removable slot state.
    setRemovableSimSlotState(mContext, currentRemovableSlotState);
    if (lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT && currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT) {
        handleSimInsert(removableSlotInfo);
        return;
    }
    if (lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT && currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT) {
        handleSimRemove(removableSlotInfo);
        return;
    }
    Log.i(TAG, "Do nothing on slot status changes.");
}
Also used : UiccSlotInfo(android.telephony.UiccSlotInfo)

Example 12 with UiccSlotInfo

use of android.telephony.UiccSlotInfo in project android_packages_apps_Settings by omnirom.

the class EnableMultiSimSidecar method getActiveRemovableLogicalSlotIds.

/**
 * Returns a list of active removable logical slot ids.
 */
public Set<Integer> getActiveRemovableLogicalSlotIds() {
    UiccSlotInfo[] infos = mTelephonyManager.getUiccSlotsInfo();
    if (infos == null) {
        return Collections.emptySet();
    }
    Set<Integer> activeRemovableLogicalSlotIds = new ArraySet<>();
    for (UiccSlotInfo info : infos) {
        if (info != null && info.getIsActive() && info.isRemovable()) {
            activeRemovableLogicalSlotIds.add(info.getLogicalSlotIdx());
        }
    }
    return activeRemovableLogicalSlotIds;
}
Also used : ArraySet(android.util.ArraySet) UiccSlotInfo(android.telephony.UiccSlotInfo)

Example 13 with UiccSlotInfo

use of android.telephony.UiccSlotInfo in project android_packages_apps_Settings by omnirom.

the class EnableMultiSimSidecar method getActiveSlotsCount.

// Get active slots count from {@code TelephonyManager#getUiccSlotsInfo}.
private int getActiveSlotsCount() {
    UiccSlotInfo[] slotsInfo = mTelephonyManager.getUiccSlotsInfo();
    if (slotsInfo == null) {
        return 0;
    }
    int activeSlots = 0;
    for (UiccSlotInfo slotInfo : slotsInfo) {
        if (slotInfo != null && slotInfo.getIsActive()) {
            activeSlots++;
        }
    }
    return activeSlots;
}
Also used : UiccSlotInfo(android.telephony.UiccSlotInfo)

Example 14 with UiccSlotInfo

use of android.telephony.UiccSlotInfo in project android_packages_apps_Settings by omnirom.

the class SubscriptionUtil method isPrimarySubscriptionWithinSameUuid.

private static boolean isPrimarySubscriptionWithinSameUuid(UiccSlotInfo[] slotsInfo, ParcelUuid groupUuid, List<SubscriptionInfo> subscriptions, int subId) {
    // only interested in subscriptions with this group UUID
    final ArrayList<SubscriptionInfo> physicalSubInfoList = new ArrayList<SubscriptionInfo>();
    final ArrayList<SubscriptionInfo> nonOpportunisticSubInfoList = new ArrayList<SubscriptionInfo>();
    final ArrayList<SubscriptionInfo> activeSlotSubInfoList = new ArrayList<SubscriptionInfo>();
    final ArrayList<SubscriptionInfo> inactiveSlotSubInfoList = new ArrayList<SubscriptionInfo>();
    for (SubscriptionInfo subInfo : subscriptions) {
        if (groupUuid.equals(subInfo.getGroupUuid())) {
            if (!subInfo.isEmbedded()) {
                physicalSubInfoList.add(subInfo);
            } else {
                if (!subInfo.isOpportunistic()) {
                    nonOpportunisticSubInfoList.add(subInfo);
                }
                if (subInfo.getSimSlotIndex() != SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
                    activeSlotSubInfoList.add(subInfo);
                } else {
                    inactiveSlotSubInfoList.add(subInfo);
                }
            }
        }
    }
    // and which is our target subscription
    if ((slotsInfo != null) && (physicalSubInfoList.size() > 0)) {
        final SubscriptionInfo subInfo = searchForSubscriptionId(physicalSubInfoList, subId);
        if (subInfo == null) {
            return false;
        }
        // verify if subscription is inserted within slot
        for (UiccSlotInfo slotInfo : slotsInfo) {
            if ((slotInfo != null) && (!slotInfo.getIsEuicc()) && (slotInfo.getLogicalSlotIdx() == subInfo.getSimSlotIndex())) {
                return true;
            }
        }
        return false;
    }
    // first opportunistic subscriptions with same group UUID can be primary.
    if (nonOpportunisticSubInfoList.size() <= 0) {
        if (physicalSubInfoList.size() > 0) {
            return false;
        }
        if (activeSlotSubInfoList.size() > 0) {
            return (activeSlotSubInfoList.get(0).getSubscriptionId() == subId);
        }
        return (inactiveSlotSubInfoList.get(0).getSubscriptionId() == subId);
    }
    // Allow non-opportunistic + active eSIM subscription as primary
    int numberOfActiveNonOpportunisticSubs = 0;
    boolean isTargetNonOpportunistic = false;
    for (SubscriptionInfo subInfo : nonOpportunisticSubInfoList) {
        final boolean isTargetSubInfo = (subInfo.getSubscriptionId() == subId);
        if (subInfo.getSimSlotIndex() != SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
            if (isTargetSubInfo) {
                return true;
            }
            numberOfActiveNonOpportunisticSubs++;
        } else {
            isTargetNonOpportunistic |= isTargetSubInfo;
        }
    }
    if (numberOfActiveNonOpportunisticSubs > 0) {
        return false;
    }
    return isTargetNonOpportunistic;
}
Also used : ArrayList(java.util.ArrayList) UiccSlotInfo(android.telephony.UiccSlotInfo) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 15 with UiccSlotInfo

use of android.telephony.UiccSlotInfo 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)

Aggregations

UiccSlotInfo (android.telephony.UiccSlotInfo)15 Test (org.junit.Test)6 SubscriptionInfo (android.telephony.SubscriptionInfo)4 TelephonyManager (android.telephony.TelephonyManager)3 SmallTest (android.test.suitebuilder.annotation.SmallTest)3 FlakyTest (androidx.test.filters.FlakyTest)3 ContentResolver (android.content.ContentResolver)2 MockContentResolver (android.test.mock.MockContentResolver)2 UiccSlot (com.android.internal.telephony.uicc.UiccSlot)2 ArrayList (java.util.ArrayList)2 SubscriptionManager (android.telephony.SubscriptionManager)1 UiccCardInfo (android.telephony.UiccCardInfo)1 EuiccManager (android.telephony.euicc.EuiccManager)1 ArraySet (android.util.ArraySet)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Config (org.robolectric.annotation.Config)1