[framework] Handle more possible route string from service.
There are more possible values for routing status. Should only check if
the return value has these prefixes.
Bug: 356419585
Test: atest CtsNfcTestCases
Change-Id: I7626573dce4bcb59ee7ac6aa35dd162f60d2fbae
diff --git a/nfc/java/android/nfc/NfcOemExtension.java b/nfc/java/android/nfc/NfcOemExtension.java
index 905d6f6..520ba89 100644
--- a/nfc/java/android/nfc/NfcOemExtension.java
+++ b/nfc/java/android/nfc/NfcOemExtension.java
@@ -923,12 +923,15 @@
}
private @CardEmulation.ProtocolAndTechnologyRoute int routeStringToInt(String route) {
- return switch (route) {
- case "DH" -> PROTOCOL_AND_TECHNOLOGY_ROUTE_DH;
- case "eSE" -> PROTOCOL_AND_TECHNOLOGY_ROUTE_ESE;
- case "SIM" -> PROTOCOL_AND_TECHNOLOGY_ROUTE_UICC;
- default -> throw new IllegalStateException("Unexpected value: " + route);
- };
+ if (route.equals("DH")) {
+ return PROTOCOL_AND_TECHNOLOGY_ROUTE_DH;
+ } else if (route.startsWith("eSE")) {
+ return PROTOCOL_AND_TECHNOLOGY_ROUTE_ESE;
+ } else if (route.startsWith("SIM")) {
+ return PROTOCOL_AND_TECHNOLOGY_ROUTE_UICC;
+ } else {
+ throw new IllegalStateException("Unexpected value: " + route);
+ }
}
private class ReceiverWrapper<T> implements Consumer<T> {