Merge "To avoid the NullPointerException of UiccSlotInfo" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
1742fa2ed0
@@ -171,8 +171,11 @@ public class EnableMultiSimSidecar extends AsyncTaskSidecar<Void, Boolean> {
|
||||
}
|
||||
int activePorts = 0;
|
||||
for (UiccSlotInfo slotInfo : slotsInfo) {
|
||||
if (slotInfo == null) {
|
||||
continue;
|
||||
}
|
||||
for (UiccPortInfo portInfo : slotInfo.getPorts()) {
|
||||
if (slotInfo != null && portInfo.isActive()) {
|
||||
if (portInfo.isActive()) {
|
||||
activePorts++;
|
||||
}
|
||||
}
|
||||
@@ -189,8 +192,11 @@ public class EnableMultiSimSidecar extends AsyncTaskSidecar<Void, Boolean> {
|
||||
}
|
||||
Set<Integer> activeRemovableLogicalSlotIds = new ArraySet<>();
|
||||
for (UiccSlotInfo info : infos) {
|
||||
if (info == null) {
|
||||
continue;
|
||||
}
|
||||
for (UiccPortInfo portInfo : info.getPorts()) {
|
||||
if (info != null && portInfo.isActive() && info.isRemovable()) {
|
||||
if (portInfo.isActive() && info.isRemovable()) {
|
||||
activeRemovableLogicalSlotIds.add(portInfo.getLogicalSlotIndex());
|
||||
}
|
||||
}
|
||||
|
@@ -378,11 +378,11 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
||||
return mMobileNetworkInfoDao.queryMobileNetworkInfoBySubId(subId);
|
||||
}
|
||||
|
||||
private void getUiccInfoBySubscriptionInfo(UiccSlotInfo[] uiccSlotInfos,
|
||||
private void getUiccInfoBySubscriptionInfo(@NonNull UiccSlotInfo[] uiccSlotInfos,
|
||||
SubscriptionInfo subInfo) {
|
||||
for (int i = 0; i < uiccSlotInfos.length; i++) {
|
||||
UiccSlotInfo curSlotInfo = uiccSlotInfos[i];
|
||||
if (curSlotInfo.getCardStateInfo() == CARD_STATE_INFO_PRESENT) {
|
||||
if (curSlotInfo != null && curSlotInfo.getCardStateInfo() == CARD_STATE_INFO_PRESENT) {
|
||||
final int index = i;
|
||||
mIsEuicc = curSlotInfo.getIsEuicc();
|
||||
mCardState = curSlotInfo.getCardStateInfo();
|
||||
|
@@ -301,7 +301,8 @@ public class UiccSlotUtil {
|
||||
}
|
||||
if (slotId == INVALID_PHYSICAL_SLOT_ID) {
|
||||
for (int i = 0; i < slots.length; i++) {
|
||||
if (slots[i].isRemovable()
|
||||
if (slots[i] != null
|
||||
&& slots[i].isRemovable()
|
||||
&& !slots[i].getIsEuicc()
|
||||
&& !slots[i].getPorts().stream().findFirst().get().isActive()
|
||||
&& slots[i].getCardStateInfo() != UiccSlotInfo.CARD_STATE_INFO_ERROR
|
||||
@@ -310,8 +311,9 @@ public class UiccSlotUtil {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (slotId >= slots.length || !slots[slotId].isRemovable()) {
|
||||
throw new UiccSlotsException("The given slotId is not a removable slot: " + slotId);
|
||||
if (slotId >= slots.length || slots[slotId] == null || !slots[slotId].isRemovable()) {
|
||||
Log.d(TAG, "The given slotId is not a removable slot: " + slotId);
|
||||
return INVALID_PHYSICAL_SLOT_ID;
|
||||
}
|
||||
if (!slots[slotId].getPorts().stream().findFirst().get().isActive()) {
|
||||
return slotId;
|
||||
|
Reference in New Issue
Block a user