summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2020-04-14 11:54:01 -0700
committerRoshan Pius <rpius@google.com>2020-04-15 08:23:15 -0700
commitf85ddd3f8f0f2cba9bf1194983424e98088c5e11 (patch)
tree3fcc26966d33b8b757db8261527ba7da3f94554f /tests
parent7122a7bfaf34e4c50fee27a81f16b1372c29953f (diff)
HalDeviceManager: Allow NAN to bring down P2P iface
Assign P2P & NAN ifaces the same priority. So, they're able to bring each other down, but nothing else. Also, a) Fixed a bug in the proposal creation exposed by this change. The list of ifaces to be deleted for a proposal needs to be accumulated across all iface types. This bug was causing a failure in testInterfaceCreationFlowTestChipV2 because HalDevMgr was choosing a proposal which would delete 2 ifaces (NAN + 2nd STA for an AP) instead of choosing the best proposal which was to delete 1 iface (2nd STA for an AP). b) Few log message cleanups to make it more clearer (added a toString, Arrays.toSring, etc) c) Fixed all the unit tests to account for the new priority. Bug: 153842431 Test: atest com.android.server.wifi Change-Id: I06ca1f18347a8cbe8c495f4540365ed9c34ad009
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java146
1 files changed, 82 insertions, 64 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java b/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java
index 1b195cfc7..bd9a1691a 100644
--- a/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java
@@ -1144,7 +1144,6 @@ public class HalDeviceManagerTest extends WifiBaseTest {
collector.checkThat("allocated P2P interface", p2pIface, IsNull.notNullValue());
inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(false);
- inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false);
// Request AP
IWifiIface apIface = validateInterfaceSequence(chipMock,
@@ -1168,6 +1167,7 @@ public class HalDeviceManagerTest extends WifiBaseTest {
inOrderAvail.verify(apAvailListener).onAvailabilityChanged(false);
inOrderAvail.verify(staAvailListener).onAvailabilityChanged(true);
+ inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false);
// request AP2: should fail
IWifiIface apIface2 = mDut.createApIface(null, null);
@@ -1192,7 +1192,6 @@ public class HalDeviceManagerTest extends WifiBaseTest {
getName(apIface), apDestroyedListener)
);
collector.checkThat("allocated STA interface", staIface, IsNull.notNullValue());
-
inOrderAvail.verify(apAvailListener).onAvailabilityChanged(true);
inOrderAvail.verify(staAvailListener).onAvailabilityChanged(false);
inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(true);
@@ -1212,27 +1211,11 @@ public class HalDeviceManagerTest extends WifiBaseTest {
p2pDestroyedListener2, // destroyedListener
null // availableListener
);
-
+ collector.checkThat("allocated P2P interface", p2pIface, IsNull.notNullValue());
inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(false);
- inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false);
- // Request NAN: should fail
- IWifiIface nanIface = mDut.createNanIface(nanDestroyedListener, mHandler);
- mDut.registerInterfaceAvailableForRequestListener(IfaceType.NAN, nanAvailListener,
- mHandler);
- collector.checkThat("NAN can't be created", nanIface, IsNull.nullValue());
-
- // Tear down P2P
- mDut.removeIface(p2pIface);
- mTestLooper.dispatchAll();
-
- inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(true);
- inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(true);
- verify(chipMock.chip, times(2)).removeP2pIface("p2p0");
- verify(p2pDestroyedListener2).onDestroyed(getName(p2pIface));
-
- // Should now be able to request and get NAN
- nanIface = validateInterfaceSequence(chipMock,
+ // create NAN: will destroy P2P
+ IWifiIface nanIface = validateInterfaceSequence(chipMock,
true, // chipModeValid
TestChipV1.STA_CHIP_MODE_ID, // chipModeId
IfaceType.NAN, // ifaceTypeToCreate
@@ -1240,12 +1223,21 @@ public class HalDeviceManagerTest extends WifiBaseTest {
TestChipV1.STA_CHIP_MODE_ID, // finalChipMode
null, // tearDownList
nanDestroyedListener, // destroyedListener
- nanAvailListener // availableListener
+ nanAvailListener, // availableListener
+ new InterfaceDestroyedListenerWithIfaceName("p2p0", p2pDestroyedListener2)
);
collector.checkThat("allocated NAN interface", nanIface, IsNull.notNullValue());
-
+ inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(true);
inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false);
+ // Tear down NAN
+ mDut.removeIface(nanIface);
+ mTestLooper.dispatchAll();
+
+ inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(true);
+ verify(chipMock.chip, times(1)).removeNanIface("wlan0");
+ verify(nanDestroyedListener).onDestroyed(getName(nanIface));
+
verifyNoMoreInteractions(mManagerStatusListenerMock, staDestroyedListener, staAvailListener,
staDestroyedListener2, apDestroyedListener, apAvailListener, p2pDestroyedListener,
nanDestroyedListener, nanAvailListener, p2pDestroyedListener2);
@@ -1518,11 +1510,24 @@ public class HalDeviceManagerTest extends WifiBaseTest {
collector.checkThat("P2P interface wasn't created", p2pIface, IsNull.notNullValue());
inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(false);
- inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false);
- // request NAN: should fail
- IWifiIface nanIface = mDut.createNanIface(null, null);
- collector.checkThat("NAN should not be created", nanIface, IsNull.nullValue());
+ // create NAN
+ IWifiIface nanIface = validateInterfaceSequence(chipMock,
+ true, // chipModeValid
+ TestChipV2.CHIP_MODE_ID, // chipModeId
+ IfaceType.NAN, // ifaceTypeToCreate
+ "wlan0", // ifaceName
+ TestChipV2.CHIP_MODE_ID, // finalChipMode
+ null, // tearDownList
+ nanDestroyedListener, // destroyedListener
+ null, // availableListener (already registered)
+ new InterfaceDestroyedListenerWithIfaceName(
+ getName(p2pIface), p2pDestroyedListener)
+ );
+ collector.checkThat("NAN interface wasn't created", nanIface, IsNull.notNullValue());
+
+ inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(true);
+ inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false);
// create AP
IWifiIface apIface = validateInterfaceSequence(chipMock,
@@ -1595,14 +1600,13 @@ public class HalDeviceManagerTest extends WifiBaseTest {
inOrderAvail.verify(apAvailListener).onAvailabilityChanged(false);
- // tear down P2P
- mDut.removeIface(p2pIface);
+ // tear down NAN
+ mDut.removeIface(nanIface);
mTestLooper.dispatchAll();
- inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(true);
inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(true);
- verify(chipMock.chip).removeP2pIface("p2p0");
- verify(p2pDestroyedListener).onDestroyed(getName(p2pIface));
+ verify(chipMock.chip).removeNanIface("wlan0");
+ verify(nanDestroyedListener).onDestroyed(getName(nanIface));
// create NAN
nanIface = validateInterfaceSequence(chipMock,
@@ -1875,11 +1879,23 @@ public class HalDeviceManagerTest extends WifiBaseTest {
inOrderAvail.verify(staAvailListener).onAvailabilityChanged(false);
inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(false);
- inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false);
- // request NAN: should fail
- IWifiIface nanIface = mDut.createNanIface(null, null);
- collector.checkThat("NAN should not be created", nanIface, IsNull.nullValue());
+ // create NAN
+ IWifiIface nanIface = validateInterfaceSequence(chipMock,
+ true, // chipModeValid
+ TestChipV3.CHIP_MODE_ID, // chipModeId
+ IfaceType.NAN, // ifaceTypeToCreate
+ "wlan0", // ifaceName
+ TestChipV3.CHIP_MODE_ID, // finalChipMode
+ null, // tearDownList
+ nanDestroyedListener, // destroyedListener
+ null, // availableListener (already registered)
+ new InterfaceDestroyedListenerWithIfaceName("p2p0", p2pDestroyedListener)
+ );
+ collector.checkThat("NAN interface wasn't created", nanIface, IsNull.notNullValue());
+
+ inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(true);
+ inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false);
// create AP: will destroy P2P
IWifiIface apIface = validateInterfaceSequence(chipMock,
@@ -1891,12 +1907,13 @@ public class HalDeviceManagerTest extends WifiBaseTest {
null, // tearDownList
apDestroyedListener, // destroyedListener
null, // availableListener (already registered)
- new InterfaceDestroyedListenerWithIfaceName("p2p0", p2pDestroyedListener)
+ new InterfaceDestroyedListenerWithIfaceName("wlan0", nanDestroyedListener)
);
collector.checkThat("AP interface wasn't created", apIface, IsNull.notNullValue());
verify(chipMock.chip).removeP2pIface("p2p0");
inOrderAvail.verify(apAvailListener).onAvailabilityChanged(false);
+ inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(false);
// request STA2: should fail
IWifiIface staIface2 = mDut.createStaIface(null, null);
@@ -2134,13 +2151,24 @@ public class HalDeviceManagerTest extends WifiBaseTest {
collector.checkThat("P2P interface wasn't created", p2pIface, IsNull.notNullValue());
inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(false);
- inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false);
- // request NAN: should fail
- IWifiIface nanIface = mDut.createNanIface(null, null);
- collector.checkThat("NAN should not be created", nanIface, IsNull.nullValue());
+ // create NAN: will destroy P2P
+ IWifiIface nanIface = validateInterfaceSequence(chipMock,
+ true, // chipModeValid
+ TestChipV4.CHIP_MODE_ID, // chipModeId
+ IfaceType.NAN, // ifaceTypeToCreate
+ "wlan0", // ifaceName
+ TestChipV4.CHIP_MODE_ID, // finalChipMode
+ null, // tearDownList
+ nanDestroyedListener, // destroyedListener
+ nanAvailListener, // availableListener
+ new InterfaceDestroyedListenerWithIfaceName("p2p0", p2pDestroyedListener)
+ );
+ collector.checkThat("allocated NAN interface", nanIface, IsNull.notNullValue());
+ inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(true);
+ inOrderAvail.verify(nanAvailListener).onAvailabilityChanged(false);
- // create AP: will destroy P2P
+ // create AP: will destroy NAN
IWifiIface apIface = validateInterfaceSequence(chipMock,
true, // chipModeValid
TestChipV4.CHIP_MODE_ID, // chipModeId
@@ -2150,12 +2178,13 @@ public class HalDeviceManagerTest extends WifiBaseTest {
null, // tearDownList
apDestroyedListener, // destroyedListener
null, // availableListener (already registered)
- new InterfaceDestroyedListenerWithIfaceName("p2p0", p2pDestroyedListener)
+ new InterfaceDestroyedListenerWithIfaceName("wlan0", nanDestroyedListener)
);
collector.checkThat("AP interface wasn't created", apIface, IsNull.notNullValue());
verify(chipMock.chip).removeP2pIface("p2p0");
inOrderAvail.verify(apAvailListener).onAvailabilityChanged(false);
+ inOrderAvail.verify(p2pAvailListener).onAvailabilityChanged(false);
// request STA2: should fail
IWifiIface staIface2 = mDut.createStaIface(null, null);
@@ -2453,6 +2482,7 @@ public class HalDeviceManagerTest extends WifiBaseTest {
staDestroyedListener, // destroyedListener
staAvailListener // availableListener
);
+ collector.checkThat("STA can't be created", staIface, IsNull.notNullValue());
availInOrder.verify(staAvailListener).onAvailabilityChanged(
chipMock.chipMockId == CHIP_MOCK_V2 || chipMock.chipMockId == CHIP_MOCK_V3);
@@ -2486,41 +2516,29 @@ public class HalDeviceManagerTest extends WifiBaseTest {
new InterfaceDestroyedListenerWithIfaceName(
getName(nanIface), nanDestroyedListener)
);
-
- // Request NAN: expect failure
- nanIface = mDut.createNanIface(nanDestroyedListener, mHandler);
- mDut.registerInterfaceAvailableForRequestListener(IfaceType.NAN, nanAvailListener,
- mHandler);
- collector.checkThat("NAN can't be created", nanIface, IsNull.nullValue());
-
- // Destroy P2P interface
- boolean status = mDut.removeIface(p2pIface);
- mInOrder.verify(chipMock.chip).removeP2pIface("p2p0");
- collector.checkThat("P2P removal success", status, equalTo(true));
+ collector.checkThat("P2P can't be created", p2pIface, IsNull.notNullValue());
+ availInOrder.verify(nanAvailListener).onAvailabilityChanged(true);
mTestLooper.dispatchAll();
- verify(p2pDestroyedListener).onDestroyed(getName(p2pIface));
- if (chipMock.chipMockId == CHIP_MOCK_V3) {
- availInOrder.verify(staAvailListener).onAvailabilityChanged(true);
- }
- availInOrder.verify(nanAvailListener).onAvailabilityChanged(true);
+ verify(nanDestroyedListener).onDestroyed(getName(nanIface));
- // Request NAN: expect success now
+ // Request NAN
nanIface = validateInterfaceSequence(chipMock,
true, // chipModeValid
onlyChipMode, // chipModeId
IfaceType.NAN, // ifaceTypeToCreate
"wlan0", // ifaceName
onlyChipMode, // finalChipMode
- null, // tearDownList
+ new IWifiIface[]{p2pIface}, // tearDownList
nanDestroyedListener, // destroyedListener
nanAvailListener // availableListener
);
- if (chipMock.chipMockId == CHIP_MOCK_V3) {
- availInOrder.verify(staAvailListener).onAvailabilityChanged(false);
- }
+ collector.checkThat("NAN can't be created", nanIface, IsNull.notNullValue());
availInOrder.verify(nanAvailListener).onAvailabilityChanged(false);
+ mTestLooper.dispatchAll();
+ verify(p2pDestroyedListener).onDestroyed(getName(p2pIface));
+
verifyNoMoreInteractions(mManagerStatusListenerMock, staDestroyedListener, staAvailListener,
nanDestroyedListener, nanAvailListener, p2pDestroyedListener);
}