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