diff options
author | Glen Kuhne <kuh@google.com> | 2017-05-05 11:01:32 -0700 |
---|---|---|
committer | Glen Kuhne <kuh@google.com> | 2017-05-05 16:19:50 -0700 |
commit | 5a843c0d793abf48de2c77e0b1a54fded88bb018 (patch) | |
tree | 45806396794826722e33cbb32a8f1e87e8708c3c | |
parent | 0cb7ccda98c48bd45af272d2a888220f8b26e1c8 (diff) |
Fix P2P provision discovery config method
Fixes some more bugs introduced with HIDL. When using a PIN for
provision discovery, the target config method should be the opposite of
the role (KEYPAD or DISPLAY) that the sender is using.
This flips the role for the target config method when sending the
request, and sends the correct broadcast when completing the
provisioning on both devices.
Bug: 38002403
Test: Manually tested via Links app, CTS GO Negotiation Test (PIN),
updated unit test
Change-Id: Ic6f775030c6dd1476f56677fb79c895d59bb25b4
3 files changed, 35 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java index 5f4cb1773..1d106c066 100644 --- a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java +++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java @@ -413,11 +413,18 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub event.event = WifiP2pProvDiscEvent.PBC_RSP; mMonitor.broadcastP2pProvisionDiscoveryPbcResponse(mInterface, event); } - } else if ((configMethods & WpsConfigMethods.DISPLAY) != 0) { + } else if (!isRequest && (configMethods & WpsConfigMethods.KEYPAD) != 0) { event.event = WifiP2pProvDiscEvent.SHOW_PIN; event.pin = generatedPin; mMonitor.broadcastP2pProvisionDiscoveryShowPin(mInterface, event); - } else if ((configMethods & WpsConfigMethods.KEYPAD) != 0) { + } else if (!isRequest && (configMethods & WpsConfigMethods.DISPLAY) != 0) { + event.event = WifiP2pProvDiscEvent.ENTER_PIN; + mMonitor.broadcastP2pProvisionDiscoveryEnterPin(mInterface, event); + } else if (isRequest && (configMethods & WpsConfigMethods.DISPLAY) != 0) { + event.event = WifiP2pProvDiscEvent.SHOW_PIN; + event.pin = generatedPin; + mMonitor.broadcastP2pProvisionDiscoveryShowPin(mInterface, event); + } else if (isRequest && (configMethods & WpsConfigMethods.KEYPAD) != 0) { event.event = WifiP2pProvDiscEvent.ENTER_PIN; mMonitor.broadcastP2pProvisionDiscoveryEnterPin(mInterface, event); } else { diff --git a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java index fe91b27d4..98b268f73 100644 --- a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java +++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java @@ -729,10 +729,17 @@ public class SupplicantP2pIfaceHal { if (!checkSupplicantP2pIfaceAndLogFailure("provisionDiscovery")) return false; int targetMethod = wpsInfoToConfigMethod(config.wps.setup); - if (targetMethod == -1) { + if (targetMethod == RESULT_NOT_VALID) { Log.e(TAG, "Unrecognized WPS configuration method: " + config.wps.setup); return false; } + if (targetMethod == ISupplicantP2pIface.WpsProvisionMethod.DISPLAY) { + // We are doing display, so provision discovery is keypad. + targetMethod = ISupplicantP2pIface.WpsProvisionMethod.KEYPAD; + } else if (targetMethod == ISupplicantP2pIface.WpsProvisionMethod.KEYPAD) { + // We are doing keypad, so provision discovery is display. + targetMethod = ISupplicantP2pIface.WpsProvisionMethod.DISPLAY; + } if (config.deviceAddress == null) { Log.e(TAG, "Cannot parse null mac address."); diff --git a/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceCallbackTest.java b/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceCallbackTest.java index ec1d43364..aada83410 100644 --- a/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceCallbackTest.java +++ b/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceCallbackTest.java @@ -370,18 +370,35 @@ public class SupplicantP2pIfaceCallbackTest { ArgumentCaptor.forClass(WifiP2pProvDiscEvent.class); mDut.onProvisionDiscoveryCompleted( p2pDeviceAddr, isRequest, status, configMethods, generatedPin); + verify(mMonitor).broadcastP2pProvisionDiscoveryEnterPin( + anyString(), discEventCaptor.capture()); + assertEquals(WifiP2pProvDiscEvent.ENTER_PIN, discEventCaptor.getValue().event); + + configMethods = WpsConfigMethods.KEYPAD; + mDut.onProvisionDiscoveryCompleted( + p2pDeviceAddr, isRequest, status, configMethods, generatedPin); verify(mMonitor).broadcastP2pProvisionDiscoveryShowPin( anyString(), discEventCaptor.capture()); assertEquals(WifiP2pProvDiscEvent.SHOW_PIN, discEventCaptor.getValue().event); assertEquals(generatedPin, discEventCaptor.getValue().pin); + isRequest = true; configMethods = WpsConfigMethods.KEYPAD; mDut.onProvisionDiscoveryCompleted( p2pDeviceAddr, isRequest, status, configMethods, generatedPin); - verify(mMonitor).broadcastP2pProvisionDiscoveryEnterPin( + verify(mMonitor, times(2)).broadcastP2pProvisionDiscoveryEnterPin( anyString(), discEventCaptor.capture()); assertEquals(WifiP2pProvDiscEvent.ENTER_PIN, discEventCaptor.getValue().event); + configMethods = WpsConfigMethods.DISPLAY; + mDut.onProvisionDiscoveryCompleted( + p2pDeviceAddr, isRequest, status, configMethods, generatedPin); + verify(mMonitor, times(2)).broadcastP2pProvisionDiscoveryShowPin( + anyString(), discEventCaptor.capture()); + assertEquals(WifiP2pProvDiscEvent.SHOW_PIN, discEventCaptor.getValue().event); + assertEquals(generatedPin, discEventCaptor.getValue().pin); + + isRequest = false; configMethods = WpsConfigMethods.PUSHBUTTON; mDut.onProvisionDiscoveryCompleted( p2pDeviceAddr, isRequest, status, configMethods, generatedPin); |