Merge "[Settings] eSIM existance detection rule change" into sc-dev

This commit is contained in:
Bonian Chen
2021-08-06 03:15:49 +00:00
committed by Android (Google) Code Review
3 changed files with 8 additions and 5 deletions

View File

@@ -90,16 +90,15 @@ public class SubscriptionAnnotation {
mOrderWithinList = subInfoIndex; mOrderWithinList = subInfoIndex;
mType = mSubInfo.isEmbedded() ? TYPE_ESIM : TYPE_PSIM; mType = mSubInfo.isEmbedded() ? TYPE_ESIM : TYPE_PSIM;
mIsExisted = true;
if (mType == TYPE_ESIM) { if (mType == TYPE_ESIM) {
int cardId = mSubInfo.getCardId(); int cardId = mSubInfo.getCardId();
mIsExisted = eSimCardId.contains(cardId);
mIsActive = activeSimSlotIndexList.contains(mSubInfo.getSimSlotIndex()); mIsActive = activeSimSlotIndexList.contains(mSubInfo.getSimSlotIndex());
mIsAllowToDisplay = (cardId < 0) // always allow when eSIM not in slot mIsAllowToDisplay = (cardId < 0) // always allow when eSIM not in slot
|| isDisplayAllowed(context); || isDisplayAllowed(context);
return; return;
} }
mIsExisted = true;
mIsActive = (mSubInfo.getSimSlotIndex() > SubscriptionManager.INVALID_SIM_SLOT_INDEX) mIsActive = (mSubInfo.getSimSlotIndex() > SubscriptionManager.INVALID_SIM_SLOT_INDEX)
&& activeSimSlotIndexList.contains(mSubInfo.getSimSlotIndex()); && activeSimSlotIndexList.contains(mSubInfo.getSimSlotIndex());
mIsAllowToDisplay = isDisplayAllowed(context); mIsAllowToDisplay = isDisplayAllowed(context);

View File

@@ -16,6 +16,7 @@
package com.android.settings.network.helper; package com.android.settings.network.helper;
import android.os.ParcelUuid; import android.os.ParcelUuid;
import android.util.Log;
import androidx.annotation.Keep; import androidx.annotation.Keep;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@@ -44,9 +45,12 @@ import java.util.stream.Collectors;
*/ */
public class SubscriptionGrouping public class SubscriptionGrouping
implements UnaryOperator<List<SubscriptionAnnotation>> { implements UnaryOperator<List<SubscriptionAnnotation>> {
private static final String LOG_TAG = "SubscriptionGrouping";
// implementation of UnaryOperator // implementation of UnaryOperator
public List<SubscriptionAnnotation> apply(List<SubscriptionAnnotation> listOfSubscriptions) { public List<SubscriptionAnnotation> apply(List<SubscriptionAnnotation> listOfSubscriptions) {
Log.d(LOG_TAG, "Grouping " + listOfSubscriptions);
// group by GUID // group by GUID
Map<ParcelUuid, List<SubscriptionAnnotation>> groupedSubInfoList = Map<ParcelUuid, List<SubscriptionAnnotation>> groupedSubInfoList =
listOfSubscriptions.stream() listOfSubscriptions.stream()
@@ -89,8 +93,8 @@ public class SubscriptionGrouping
annoSelector = annoSelector annoSelector = annoSelector
// eSIM in front of pSIM // eSIM in front of pSIM
.thenComparingInt(anno -> -anno.getType()) .thenComparingInt(anno -> -anno.getType())
// subscription ID in reverse order // maintain the ordering given within constructor
.thenComparingInt(anno -> -anno.getSubscriptionId()); .thenComparingInt(anno -> annoList.indexOf(anno));
return annoList.stream().sorted(annoSelector).findFirst().orElse(null); return annoList.stream().sorted(annoSelector).findFirst().orElse(null);
} }
} }

View File

@@ -68,7 +68,7 @@ public class SubscriptionGroupingTest {
List<SubscriptionAnnotation> result = mTarget List<SubscriptionAnnotation> result = mTarget
.apply(Arrays.asList(subAnno2, subAnno1, subAnno3)); .apply(Arrays.asList(subAnno2, subAnno1, subAnno3));
assertThat(result.size()).isEqualTo(1); assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0)).isEqualTo(subAnno3); assertThat(result.get(0)).isEqualTo(subAnno1);
} }
@Test @Test