Update RadioAccessFamily#compare in E911
The E911 phone selection logic uses a two-phase approach to pick
a phone based on the RAT type. This CL migrates those two stages
into the RadioAccessFamly class and removes references to
TelephonyManager#NETWORK_CLASS_ constants that are being removed
at the same time.
Bug: 128572818
Test: compilation
Merged-In: I11e3319e3f3351cc17f92260b4389e23bb016698
Change-Id: I11e3319e3f3351cc17f92260b4389e23bb016698
(cherry picked from commit 3f325af9e6cba13083eb524cc287679099e26518)
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 99b0e7c..c7686be 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -2146,30 +2146,24 @@
return 1;
}
// sort by number of RadioAccessFamily Capabilities.
- int compare = Integer.bitCount(o1.capabilities) -
- Integer.bitCount(o2.capabilities);
+ int compare = RadioAccessFamily.compare(o1.capabilities, o2.capabilities);
if (compare == 0) {
- // Sort by highest RAF Capability if the number is the same.
- compare = RadioAccessFamily.getHighestRafCapability(o1.capabilities) -
- RadioAccessFamily.getHighestRafCapability(o2.capabilities);
- if (compare == 0) {
- if (firstOccupiedSlot != null) {
- // If the RAF capability is the same, choose based on whether or
- // not any of the slots are occupied with a SIM card (if both
- // are, always choose the first).
- if (o1.slotId == firstOccupiedSlot.getPhoneId()) {
- return 1;
- } else if (o2.slotId == firstOccupiedSlot.getPhoneId()) {
- return -1;
- }
- } else {
- // No slots have SIMs detected in them, so weight the default
- // Phone Id greater than the others.
- if (o1.slotId == defaultPhoneId) {
- return 1;
- } else if (o2.slotId == defaultPhoneId) {
- return -1;
- }
+ if (firstOccupiedSlot != null) {
+ // If the RAF capability is the same, choose based on whether or
+ // not any of the slots are occupied with a SIM card (if both
+ // are, always choose the first).
+ if (o1.slotId == firstOccupiedSlot.getPhoneId()) {
+ return 1;
+ } else if (o2.slotId == firstOccupiedSlot.getPhoneId()) {
+ return -1;
+ }
+ } else {
+ // No slots have SIMs detected in them, so weight the default
+ // Phone Id greater than the others.
+ if (o1.slotId == defaultPhoneId) {
+ return 1;
+ } else if (o2.slotId == defaultPhoneId) {
+ return -1;
}
}
}