Fix the IndexOutOfBoundsException
Bug: 276460284 Test: build pass Change-Id: If70bd4624b9b94aafa0930f0deba106cff5a2212
This commit is contained in:
@@ -438,6 +438,7 @@ public class SubscriptionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Log.d(TAG, "getSelectableSubscriptionInfoList: " + selectableList);
|
||||||
return selectableList;
|
return selectableList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,6 @@ import com.android.settings.sim.SwitchToEsimConfirmDialogActivity;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -100,6 +99,9 @@ public class SimSlotChangeHandler {
|
|||||||
|
|
||||||
int lastRemovableSlotState = getLastRemovableSimSlotState(mContext);
|
int lastRemovableSlotState = getLastRemovableSimSlotState(mContext);
|
||||||
int currentRemovableSlotState = removableSlotInfo.getCardStateInfo();
|
int currentRemovableSlotState = removableSlotInfo.getCardStateInfo();
|
||||||
|
Log.i(TAG,
|
||||||
|
"lastRemovableSlotState: " + lastRemovableSlotState + ",currentRemovableSlotState: "
|
||||||
|
+ currentRemovableSlotState);
|
||||||
boolean isRemovableSimInserted =
|
boolean isRemovableSimInserted =
|
||||||
lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT
|
lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT
|
||||||
&& currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT;
|
&& currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT;
|
||||||
@@ -259,7 +261,7 @@ public class SimSlotChangeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<SubscriptionInfo> subscriptionInfos = getAvailableRemovableSubscription();
|
List<SubscriptionInfo> subscriptionInfos = getAvailableRemovableSubscription();
|
||||||
if (subscriptionInfos == null || subscriptionInfos.get(0) == null) {
|
if (subscriptionInfos.isEmpty()) {
|
||||||
Log.e(TAG, "Unable to find the removable subscriptionInfo. Do nothing.");
|
Log.e(TAG, "Unable to find the removable subscriptionInfo. Do nothing.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -275,6 +277,7 @@ public class SimSlotChangeHandler {
|
|||||||
private void setRemovableSimSlotState(Context context, int state) {
|
private void setRemovableSimSlotState(Context context, int state) {
|
||||||
final SharedPreferences prefs = context.getSharedPreferences(EUICC_PREFS, MODE_PRIVATE);
|
final SharedPreferences prefs = context.getSharedPreferences(EUICC_PREFS, MODE_PRIVATE);
|
||||||
prefs.edit().putInt(KEY_REMOVABLE_SLOT_STATE, state).apply();
|
prefs.edit().putInt(KEY_REMOVABLE_SLOT_STATE, state).apply();
|
||||||
|
Log.d(TAG, "setRemovableSimSlotState: " + state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getSuwRemovableSlotAction(Context context) {
|
private int getSuwRemovableSlotAction(Context context) {
|
||||||
@@ -332,13 +335,14 @@ public class SimSlotChangeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected List<SubscriptionInfo> getAvailableRemovableSubscription() {
|
protected List<SubscriptionInfo> getAvailableRemovableSubscription() {
|
||||||
List<SubscriptionInfo> subList = new ArrayList<>();
|
List<SubscriptionInfo> removableSubscriptions =
|
||||||
for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mContext)) {
|
SubscriptionUtil.getAvailableSubscriptions(mContext);
|
||||||
if (!info.isEmbedded()) {
|
return ImmutableList.copyOf(
|
||||||
subList.add(info);
|
removableSubscriptions.stream()
|
||||||
}
|
// ToDo: This condition is for psim only. If device supports removable
|
||||||
}
|
// esim, it needs an new condition.
|
||||||
return subList;
|
.filter(sub -> !sub.isEmbedded())
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startChooseSimActivity(boolean psimInserted) {
|
private void startChooseSimActivity(boolean psimInserted) {
|
||||||
|
Reference in New Issue
Block a user