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