Merge "Sort in slot selectable subscriptions first" into main

This commit is contained in:
Chaohui Wang
2024-05-27 09:02:40 +00:00
committed by Android (Google) Code Review
2 changed files with 30 additions and 1 deletions

View File

@@ -124,6 +124,14 @@ fun Context.getSelectableSubscriptionInfoList(): List<SubscriptionInfo> {
}
}
// Matching the sorting order in SubscriptionManagerService.getAvailableSubscriptionInfoList
.sortedWith(compareBy({ it.simSlotIndex }, { it.subscriptionId }))
.sortedWith(compareBy({ it.sortableSimSlotIndex }, { it.subscriptionId }))
.also { Log.d(TAG, "getSelectableSubscriptionInfoList: $it") }
}
/** Subscription with invalid sim slot index has lowest sort order. */
private val SubscriptionInfo.sortableSimSlotIndex: Int
get() = if (simSlotIndex != SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
simSlotIndex
} else {
Int.MAX_VALUE
}