diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-04-01 01:59:56 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-04-01 01:59:57 +0000 |
commit | c77b158ce8a31267240607e31f7bb19833e7e934 (patch) | |
tree | f1d0b384fd135afe8c695ce0a95c9656e5e732d8 | |
parent | 3c6394d352ff171e74cdf3380bde654ccebd5dc2 (diff) | |
parent | 7f7b374b3e75a929ab0d46426daf9a5e92c2d85b (diff) |
Merge "SupplicantP2pIfaceHal: Fixed the usage of the wrong enum" into oc-dev
-rw-r--r-- | service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java | 10 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceCallbackTest.java (renamed from tests/wifitests/src/com/android/server/wifi/SupplicantP2pIfaceCallbackTest.java) | 44 |
2 files changed, 49 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java index c7004adf9..836898d7f 100644 --- a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java +++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java @@ -16,8 +16,8 @@ package com.android.server.wifi.p2p; -import android.hardware.wifi.supplicant.V1_0.ISupplicantP2pIface; import android.hardware.wifi.supplicant.V1_0.ISupplicantP2pIfaceCallback; +import android.hardware.wifi.supplicant.V1_0.WpsConfigMethods; import android.net.wifi.WpsInfo; import android.net.wifi.p2p.WifiP2pConfig; import android.net.wifi.p2p.WifiP2pDevice; @@ -385,7 +385,7 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub */ public void onProvisionDiscoveryCompleted(byte[] p2pDeviceAddress, boolean isRequest, byte status, short configMethods, String generatedPin) { - if (status != 0) { + if (status != ISupplicantP2pIfaceCallback.P2pProvDiscStatusCode.SUCCESS) { Log.e(TAG, "Provision discovery failed: " + status); mMonitor.broadcastP2pProvisionDiscoveryFailure(mInterface); return; @@ -404,7 +404,7 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub return; } - if ((configMethods & ISupplicantP2pIface.WpsProvisionMethod.PBC) != 0) { + if ((configMethods & WpsConfigMethods.PUSHBUTTON) != 0) { if (isRequest) { event.event = WifiP2pProvDiscEvent.PBC_REQ; mMonitor.broadcastP2pProvisionDiscoveryPbcRequest(mInterface, event); @@ -412,11 +412,11 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub event.event = WifiP2pProvDiscEvent.PBC_RSP; mMonitor.broadcastP2pProvisionDiscoveryPbcResponse(mInterface, event); } - } else if ((configMethods & ISupplicantP2pIface.WpsProvisionMethod.DISPLAY) != 0) { + } else if ((configMethods & WpsConfigMethods.DISPLAY) != 0) { event.event = WifiP2pProvDiscEvent.SHOW_PIN; event.pin = generatedPin; mMonitor.broadcastP2pProvisionDiscoveryShowPin(mInterface, event); - } else if ((configMethods & ISupplicantP2pIface.WpsProvisionMethod.KEYPAD) != 0) { + } else if ((configMethods & WpsConfigMethods.KEYPAD) != 0) { event.event = WifiP2pProvDiscEvent.ENTER_PIN; mMonitor.broadcastP2pProvisionDiscoveryEnterPin(mInterface, event); } else { diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantP2pIfaceCallbackTest.java b/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceCallbackTest.java index e91709ce1..ff39a203e 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantP2pIfaceCallbackTest.java +++ b/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceCallbackTest.java @@ -32,11 +32,13 @@ import android.net.wifi.WpsInfo; import android.net.wifi.p2p.WifiP2pConfig; import android.net.wifi.p2p.WifiP2pDevice; import android.net.wifi.p2p.WifiP2pGroup; +import android.net.wifi.p2p.WifiP2pProvDiscEvent; import android.net.wifi.p2p.WifiP2pWfdInfo; import org.junit.Assert.*; import org.junit.Before; import org.junit.Test; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.stubbing.Answer; @@ -61,6 +63,7 @@ public class SupplicantP2pIfaceCallbackTest { private byte[] mDeviceAddress2Bytes = { 0x01, 0x12, 0x23, 0x34, 0x45, 0x56 }; private String mDeviceAddress2String = "01:12:23:34:45:56"; private byte[] mDeviceInfoBytes = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; + private static final byte[] DEVICE_ADDRESS = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; private class SupplicantP2pIfaceCallbackSpy extends SupplicantP2pIfaceCallback { SupplicantP2pIfaceCallbackSpy(String iface, WifiP2pMonitor monitor) { @@ -357,4 +360,45 @@ public class SupplicantP2pIfaceCallbackTest { anyString(), any(WifiP2pGroup.class)); } + /** + * Test provision disovery callback. + */ + @Test + public void testOnProvisionDisconveryCompleted() throws Exception { + byte[] p2pDeviceAddr = DEVICE_ADDRESS; + boolean isRequest = false; + byte status = ISupplicantP2pIfaceCallback.P2pProvDiscStatusCode.SUCCESS; + short configMethods = WpsConfigMethods.DISPLAY; + String generatedPin = "12345678"; + + ArgumentCaptor<WifiP2pProvDiscEvent> discEventCaptor = + ArgumentCaptor.forClass(WifiP2pProvDiscEvent.class); + 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); + + configMethods = WpsConfigMethods.KEYPAD; + mDut.onProvisionDiscoveryCompleted( + p2pDeviceAddr, isRequest, status, configMethods, generatedPin); + verify(mMonitor).broadcastP2pProvisionDiscoveryEnterPin( + anyString(), discEventCaptor.capture()); + assertEquals(WifiP2pProvDiscEvent.ENTER_PIN, discEventCaptor.getValue().event); + + configMethods = WpsConfigMethods.PUSHBUTTON; + mDut.onProvisionDiscoveryCompleted( + p2pDeviceAddr, isRequest, status, configMethods, generatedPin); + verify(mMonitor).broadcastP2pProvisionDiscoveryPbcResponse( + anyString(), discEventCaptor.capture()); + assertEquals(WifiP2pProvDiscEvent.PBC_RSP, discEventCaptor.getValue().event); + + isRequest = true; + mDut.onProvisionDiscoveryCompleted( + p2pDeviceAddr, isRequest, status, configMethods, generatedPin); + verify(mMonitor).broadcastP2pProvisionDiscoveryPbcRequest( + anyString(), discEventCaptor.capture()); + assertEquals(WifiP2pProvDiscEvent.PBC_REQ, discEventCaptor.getValue().event); + } } |