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.");
}
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;
}
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;
}
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;
}
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);
}
Aggregations