From 7e9eafab778c3920732a965ca9a0b330c6c676d6 Mon Sep 17 00:00:00 2001 From: Glen Kuhne Date: Thu, 4 May 2017 12:46:10 -0700 Subject: P2P: handle null p2p_dev_address sta auth/deauth This fixes an issue introduced with the HIDL interface, legacy STA devices have a null p2p device address, and only use a src address. The pre-HIDL behaviour was to use the srcAddress if the p2pDeviceAddress was unavailable, this CL restores that. Bug: 37961262 Test: Manual verification with LINKS app, added unit test Change-Id: Ib270228e8a2d1f90423c7057052623115f586f64 --- .../wifi/p2p/SupplicantP2pIfaceCallbackTest.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests') 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..d3e304c9c 100644 --- a/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceCallbackTest.java +++ b/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceCallbackTest.java @@ -32,6 +32,8 @@ import android.net.wifi.p2p.WifiP2pDevice; import android.net.wifi.p2p.WifiP2pGroup; import android.net.wifi.p2p.WifiP2pProvDiscEvent; +import com.android.server.wifi.util.NativeUtil; + import org.junit.Assert.*; import org.junit.Before; import org.junit.Test; @@ -396,4 +398,32 @@ public class SupplicantP2pIfaceCallbackTest { anyString(), discEventCaptor.capture()); assertEquals(WifiP2pProvDiscEvent.PBC_REQ, discEventCaptor.getValue().event); } + + /** + * Test staAuth with device address, should trigger ApStaConnected broadcast + */ + @Test + public void testStaAuth_success() { + // Trigger onStaAuthorized callback, ensure wifimonitor broadcast is sent with WifiP2pDevice + // using the p2pDeviceAddress + ArgumentCaptor p2pDeviceCaptor = + ArgumentCaptor.forClass(WifiP2pDevice.class); + mDut.onStaAuthorized(mDeviceAddress1Bytes, mDeviceAddress2Bytes); + verify(mMonitor).broadcastP2pApStaConnected(any(String.class), p2pDeviceCaptor.capture()); + assertEquals(mDeviceAddress2String, p2pDeviceCaptor.getValue().deviceAddress); + } + + /** + * Test staAuth without device address, should trigger ApStaConnected broadcast using srcAddress + */ + @Test + public void testStaAuth_noDeviceAddress_success() { + // Trigger onStaAuthorized callback, using a zero'd p2pDeviceAddress, ensure wifimonitor + // broadcast is sent with WifiP2pDevice using the srcAddress + ArgumentCaptor p2pDeviceCaptor = + ArgumentCaptor.forClass(WifiP2pDevice.class); + mDut.onStaAuthorized(mDeviceAddress1Bytes, NativeUtil.ANY_MAC_BYTES); + verify(mMonitor).broadcastP2pApStaConnected(any(String.class), p2pDeviceCaptor.capture()); + assertEquals(mDeviceAddress1String, p2pDeviceCaptor.getValue().deviceAddress); + } } -- cgit v1.2.3