[Settings] eSIM existance detection rule change

1. eSIM retrieved from SubscriptionManager#getAvailableSubscriptionInfoList()
should be considered as existed all the time.

2. When SIM are both inactive(or active), sorted the ordering based on ordering provided by telephony framework.

Bug: 195090132
Bug: 195091953
Bug: 194197762
Test: local
Change-Id: I2fe43a35e5b7965bde3b579e2297e9cdd89ec228
(cherry picked from commit 848d097b94)
(cherry picked from commit 824deb0ee3727f23ab68a75176825c4c73f482a9)
This commit is contained in:
Bonian Chen
2021-07-30 23:47:04 +08:00
parent 66a2f625e4
commit 35df60f316
3 changed files with 8 additions and 5 deletions

View File

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

View File

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

View File

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