Add FrequencyRange comparator to ServiceState

The FrequencyRange is not comparable beucase it's an enum. This change
add a comparator to ServiceState to make the enum comparable.

Bug: 111453000
Test: atest FrameworksTelephonyTests
Merged-In: I59a595bdaf5451d2c4d95b1b5bdfefcba123fea7
Change-Id: I59a595bdaf5451d2c4d95b1b5bdfefcba123fea7
This commit is contained in:
Pengquan Meng
2018-11-27 16:45:17 -08:00
parent 94becc7b4f
commit 424acc7f57

View File

@@ -118,6 +118,13 @@ public class ServiceState implements Parcelable {
*/
public static final int FREQUENCY_RANGE_MMWAVE = 4;
private static final List<Integer> FREQUENCY_RANGE_ORDER = Arrays.asList(
FREQUENCY_RANGE_UNKNOWN,
FREQUENCY_RANGE_LOW,
FREQUENCY_RANGE_MID,
FREQUENCY_RANGE_HIGH,
FREQUENCY_RANGE_MMWAVE);
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = "DUPLEX_MODE_",
@@ -1835,4 +1842,13 @@ public class ServiceState implements Parcelable {
mNetworkRegistrationStates.add(regState);
}
}
/**
* @hide
*/
public static final int getBetterNRFrequencyRange(int range1, int range2) {
return FREQUENCY_RANGE_ORDER.indexOf(range1) > FREQUENCY_RANGE_ORDER.indexOf(range2)
? range1
: range2;
}
}