diff options
author | Roshan Pius <rpius@google.com> | 2019-10-30 09:11:44 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2019-11-07 11:08:35 -0800 |
commit | efc08d99de7aa84490fa26b76312bf7877814e1f (patch) | |
tree | fd8d14aaab81497b1ba023c4152370cb6c1a3591 /tests | |
parent | edd9332616700a2de9e2403fe30b1f39358a3323 (diff) |
WifiService: Add @SystemApi for STA/AP MAC randomization
This ensures that we don't use wifi overlays in settings.
Bug: 143464763
Test: atest com.android.server.wifi
Change-Id: I87ba1e05741efcaf8505ac3730d936b8b1d29e28
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java | 75 |
1 files changed, 60 insertions, 15 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 7c3bdf2d7..2efb7b77a 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -1834,7 +1834,7 @@ public class ClientModeImplTest extends WifiBaseTest { verify(mPropertyService, never()).set(anyString(), anyString()); } - private long testGetSupportedFeaturesCase(long supportedFeatures, boolean rttDisabled) { + private long testGetSupportedFeaturesCaseForRtt(long supportedFeatures, boolean rttDisabled) { AsyncChannel channel = mock(AsyncChannel.class); Message reply = Message.obtain(); reply.obj = Long.valueOf(supportedFeatures); @@ -1842,6 +1842,8 @@ public class ClientModeImplTest extends WifiBaseTest { when(channel.sendMessageSynchronously(ClientModeImpl.CMD_GET_SUPPORTED_FEATURES)) .thenReturn(reply); + // ugly, this is set to true by default in setup. + mResources.setBoolean(R.bool.config_wifi_connected_mac_randomization_supported, false); when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI_RTT)).thenReturn( !rttDisabled); return mCmi.syncGetSupportedFeatures(channel); @@ -1849,40 +1851,83 @@ public class ClientModeImplTest extends WifiBaseTest { /** Verifies that syncGetSupportedFeatures() masks out capabilities based on system flags. */ @Test - public void syncGetSupportedFeatures() { + public void syncGetSupportedFeaturesForRtt() { final long featureAware = WifiManager.WIFI_FEATURE_AWARE; final long featureInfra = WifiManager.WIFI_FEATURE_INFRA; final long featureD2dRtt = WifiManager.WIFI_FEATURE_D2D_RTT; final long featureD2apRtt = WifiManager.WIFI_FEATURE_D2AP_RTT; - final long featureLongBits = 0x1100000000L; + final long featureLongBits = 0x1000000000L; - assertEquals(0, testGetSupportedFeaturesCase(0, false)); - assertEquals(0, testGetSupportedFeaturesCase(0, true)); + assertEquals(0, testGetSupportedFeaturesCaseForRtt(0, false)); + assertEquals(0, testGetSupportedFeaturesCaseForRtt(0, true)); assertEquals(featureAware | featureInfra, - testGetSupportedFeaturesCase(featureAware | featureInfra, false)); + testGetSupportedFeaturesCaseForRtt(featureAware | featureInfra, false)); assertEquals(featureAware | featureInfra, - testGetSupportedFeaturesCase(featureAware | featureInfra, true)); + testGetSupportedFeaturesCaseForRtt(featureAware | featureInfra, true)); assertEquals(featureInfra | featureD2dRtt, - testGetSupportedFeaturesCase(featureInfra | featureD2dRtt, false)); + testGetSupportedFeaturesCaseForRtt(featureInfra | featureD2dRtt, false)); assertEquals(featureInfra, - testGetSupportedFeaturesCase(featureInfra | featureD2dRtt, true)); + testGetSupportedFeaturesCaseForRtt(featureInfra | featureD2dRtt, true)); assertEquals(featureInfra | featureD2apRtt, - testGetSupportedFeaturesCase(featureInfra | featureD2apRtt, false)); + testGetSupportedFeaturesCaseForRtt(featureInfra | featureD2apRtt, false)); assertEquals(featureInfra, - testGetSupportedFeaturesCase(featureInfra | featureD2apRtt, true)); + testGetSupportedFeaturesCaseForRtt(featureInfra | featureD2apRtt, true)); assertEquals(featureInfra | featureD2dRtt | featureD2apRtt, - testGetSupportedFeaturesCase(featureInfra | featureD2dRtt | featureD2apRtt, false)); + testGetSupportedFeaturesCaseForRtt( + featureInfra | featureD2dRtt | featureD2apRtt, false)); assertEquals(featureInfra, - testGetSupportedFeaturesCase(featureInfra | featureD2dRtt | featureD2apRtt, true)); + testGetSupportedFeaturesCaseForRtt( + featureInfra | featureD2dRtt | featureD2apRtt, true)); assertEquals(featureLongBits | featureInfra | featureD2dRtt | featureD2apRtt, - testGetSupportedFeaturesCase( + testGetSupportedFeaturesCaseForRtt( featureLongBits | featureInfra | featureD2dRtt | featureD2apRtt, false)); assertEquals(featureLongBits | featureInfra, - testGetSupportedFeaturesCase( + testGetSupportedFeaturesCaseForRtt( featureLongBits | featureInfra | featureD2dRtt | featureD2apRtt, true)); } + private long testGetSupportedFeaturesCaseForMacRandomization( + long supportedFeatures, boolean apMacRandomizationEnabled, + boolean staConnectedMacRandomizationEnabled, boolean p2pMacRandomizationEnabled) { + AsyncChannel channel = mock(AsyncChannel.class); + Message reply = Message.obtain(); + reply.obj = Long.valueOf(supportedFeatures); + reset(mPropertyService); // Ignore calls made in setUp() + when(channel.sendMessageSynchronously(ClientModeImpl.CMD_GET_SUPPORTED_FEATURES)) + .thenReturn(reply); + + mResources.setBoolean(R.bool.config_wifi_connected_mac_randomization_supported, + staConnectedMacRandomizationEnabled); + mResources.setBoolean(R.bool.config_wifi_ap_mac_randomization_supported, + apMacRandomizationEnabled); + mResources.setBoolean(R.bool.config_wifi_p2p_mac_randomization_supported, + p2pMacRandomizationEnabled); + return mCmi.syncGetSupportedFeatures(channel); + } + + /** Verifies that syncGetSupportedFeatures() masks out capabilities based on system flags. */ + @Test + public void syncGetSupportedFeaturesForMacRandomization() { + final long featureStaConnectedMacRandomization = + WifiManager.WIFI_FEATURE_CONNECTED_RAND_MAC; + final long featureApMacRandomization = + WifiManager.WIFI_FEATURE_AP_RAND_MAC; + final long featureP2pMacRandomization = + WifiManager.WIFI_FEATURE_CONNECTED_RAND_MAC; + + assertEquals(featureStaConnectedMacRandomization | featureApMacRandomization + | featureP2pMacRandomization, + testGetSupportedFeaturesCaseForMacRandomization( + featureP2pMacRandomization, true, true, true)); + // p2p supported by HAL, but disabled by overlay. + assertEquals(featureStaConnectedMacRandomization | featureApMacRandomization, + testGetSupportedFeaturesCaseForMacRandomization( + featureP2pMacRandomization, true, true, false)); + assertEquals(featureStaConnectedMacRandomization | featureApMacRandomization, + testGetSupportedFeaturesCaseForMacRandomization(0, true, true, false)); + } + /** * Verify that syncStartSubscriptionProvisioning will redirect calls with right parameters * to {@link PasspointManager} with expected true being returned when in client mode. |