diff options
-rw-r--r-- | service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java | 4 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceHalTest.java | 13 |
2 files changed, 10 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java index a0f0ad946..42249786a 100644 --- a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java +++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java @@ -1434,9 +1434,9 @@ public class SupplicantP2pIfaceHal { return false; } - int id = 0; + long id = 0; try { - id = Integer.parseInt(identifier); + id = Long.parseLong(identifier); } catch (NumberFormatException e) { Log.e(TAG, "Service discovery identifier invalid: " + identifier, e); return false; diff --git a/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceHalTest.java index 4f5864bca..2ac70bae5 100644 --- a/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceHalTest.java @@ -1777,18 +1777,21 @@ public class SupplicantP2pIfaceHalTest { assertFalse(mDut.isInitializationComplete()); } + // Test constant used in cancelServiceDiscovery tests + static final String SERVICE_IDENTIFIER_STR = "521918410304"; + static final long SERVICE_IDENTIFIER_LONG = 521918410304L; /** * Sunny day scenario for cancelServiceDiscovery() */ @Test public void testCancelServiceDiscovery_success() throws Exception { - when(mISupplicantP2pIfaceMock.cancelServiceDiscovery(1234)) + when(mISupplicantP2pIfaceMock.cancelServiceDiscovery(SERVICE_IDENTIFIER_LONG)) .thenReturn(mStatusSuccess); // Default value when service is not initialized. - assertFalse(mDut.cancelServiceDiscovery("1234")); + assertFalse(mDut.cancelServiceDiscovery(SERVICE_IDENTIFIER_STR)); executeAndValidateInitializationSequence(false, false, false); - assertTrue(mDut.cancelServiceDiscovery("1234")); + assertTrue(mDut.cancelServiceDiscovery(SERVICE_IDENTIFIER_STR)); } /** @@ -1811,7 +1814,7 @@ public class SupplicantP2pIfaceHalTest { executeAndValidateInitializationSequence(false, false, false); when(mISupplicantP2pIfaceMock.cancelServiceDiscovery(anyLong())) .thenReturn(mStatusFailure); - assertFalse(mDut.cancelServiceDiscovery("1234")); + assertFalse(mDut.cancelServiceDiscovery(SERVICE_IDENTIFIER_STR)); // Check that service is still alive. assertTrue(mDut.isInitializationComplete()); } @@ -1824,7 +1827,7 @@ public class SupplicantP2pIfaceHalTest { executeAndValidateInitializationSequence(false, false, false); when(mISupplicantP2pIfaceMock.cancelServiceDiscovery(anyLong())) .thenThrow(mRemoteException); - assertFalse(mDut.cancelServiceDiscovery("1234")); + assertFalse(mDut.cancelServiceDiscovery(SERVICE_IDENTIFIER_STR)); // Check service is dead. assertFalse(mDut.isInitializationComplete()); } |