From 497d9fc7c3c8ff23993a9767d6027ebef513fb69 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 30 Oct 2019 06:52:20 -0700 Subject: WifiStack: Formalize wifi resource usages Move all wifi specific resources (only used from within wifi stack) from framework core to wifi APK. Also, add a AndroidManifestBase.xml (included in wifi-service android library) to ensure that the resources are always compiled into com.android.wifi package regardless of which APK in use (com.android.wifi - network stack process or com.android.wifi.inprocess - system_server process) Bug: 143464763 Test: Compiles Change-Id: I2a0471176799dbf9d1802fdc06daadebe2f82edb --- .../src/com/android/server/wifi/ActiveModeWardenTest.java | 2 +- .../wifitests/src/com/android/server/wifi/ClientModeImplTest.java | 2 +- .../src/com/android/server/wifi/DeviceConfigFacadeTest.java | 2 +- tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java | 2 +- .../src/com/android/server/wifi/LinkProbeManagerTest.java | 2 +- tests/wifitests/src/com/android/server/wifi/SarManagerTest.java | 2 +- .../src/com/android/server/wifi/SavedNetworkEvaluatorTest.java | 3 +-- .../wifitests/src/com/android/server/wifi/ScoringParamsTest.java | 2 +- .../wifitests/src/com/android/server/wifi/SoftApManagerTest.java | 2 +- .../src/com/android/server/wifi/SupplicantStaNetworkHalTest.java | 2 +- .../com/android/server/wifi/VelocityBasedConnectedScoreTest.java | 2 +- .../src/com/android/server/wifi/WifiApConfigStoreTest.java | 2 +- .../src/com/android/server/wifi/WifiConfigManagerTest.java | 2 +- .../src/com/android/server/wifi/WifiConnectivityManagerTest.java | 2 +- .../src/com/android/server/wifi/WifiDiagnosticsTest.java | 2 +- .../src/com/android/server/wifi/WifiNetworkSelectorTest.java | 2 +- .../android/server/wifi/WifiNetworkSuggestionsManagerTest.java | 2 +- .../src/com/android/server/wifi/WifiScoreReportTest.java | 2 +- .../src/com/android/server/wifi/WifiServiceImplTest.java | 8 ++++---- .../src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java | 2 +- .../com/android/server/wifi/scanner/WificondPnoScannerTest.java | 2 +- 21 files changed, 24 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java index 7d788c3d1..4ec6b8575 100644 --- a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java @@ -56,9 +56,9 @@ import android.util.Log; import androidx.test.filters.SmallTest; -import com.android.internal.R; import com.android.server.wifi.util.GeneralUtil; import com.android.server.wifi.util.WifiPermissionsUtil; +import com.android.wifi.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index f4b47776e..7c3bdf2d7 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -87,7 +87,6 @@ import android.util.Pair; import androidx.test.filters.SmallTest; import com.android.dx.mockito.inline.extended.ExtendedMockito; -import com.android.internal.R; import com.android.internal.util.AsyncChannel; import com.android.internal.util.IState; import com.android.internal.util.StateMachine; @@ -101,6 +100,7 @@ import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiIsUnusableEvent; import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiUsabilityStats; import com.android.server.wifi.util.WifiPermissionsUtil; import com.android.server.wifi.util.WifiPermissionsWrapper; +import com.android.wifi.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java index 1c04b7439..e23d402aa 100644 --- a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java +++ b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java @@ -32,7 +32,7 @@ import android.provider.DeviceConfig.OnPropertiesChangedListener; import androidx.test.filters.SmallTest; import com.android.dx.mockito.inline.extended.ExtendedMockito; -import com.android.internal.R; +import com.android.wifi.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java index e2a32272f..8a5d4deae 100644 --- a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java @@ -38,8 +38,8 @@ import android.os.test.TestLooper; import androidx.test.filters.SmallTest; -import com.android.internal.R; import com.android.server.wifi.util.NativeUtil; +import com.android.wifi.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java b/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java index 91692be32..46b0ba067 100644 --- a/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java @@ -37,7 +37,7 @@ import android.provider.Settings; import androidx.test.filters.SmallTest; -import com.android.internal.R; +import com.android.wifi.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java index 39f4d6a0e..85eecbc0c 100644 --- a/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java @@ -40,7 +40,7 @@ import android.telephony.TelephonyManager; import androidx.test.filters.SmallTest; -import com.android.internal.R; +import com.android.wifi.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java index 19f7422ec..b14f210f6 100644 --- a/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SavedNetworkEvaluatorTest.java @@ -31,10 +31,9 @@ import android.telephony.SubscriptionManager; import android.test.suitebuilder.annotation.SmallTest; import android.util.LocalLog; - -import com.android.internal.R; import com.android.server.wifi.WifiNetworkSelector.NetworkEvaluator.OnConnectableListener; import com.android.server.wifi.WifiNetworkSelectorTestUtil.ScanDetailsAndWifiConfigs; +import com.android.wifi.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java index a6a3b0f76..3fefb443c 100644 --- a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java @@ -35,7 +35,7 @@ import android.provider.Settings; import androidx.test.filters.SmallTest; -import com.android.internal.R; +import com.android.wifi.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java index a00c1bac6..68c0cf866 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java @@ -64,10 +64,10 @@ import android.provider.Settings; import androidx.test.filters.SmallTest; -import com.android.internal.R; import com.android.internal.util.WakeupMessage; import com.android.server.wifi.wificond.IApInterfaceEventCallback; import com.android.server.wifi.wificond.NativeWifiClient; +import com.android.wifi.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java index 101331868..a9436e7e1 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java @@ -46,8 +46,8 @@ import android.text.TextUtils; import androidx.test.filters.SmallTest; -import com.android.internal.R; import com.android.server.wifi.util.NativeUtil; +import com.android.wifi.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java b/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java index 1de160084..ae8c8c0d5 100644 --- a/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java @@ -26,7 +26,7 @@ import android.net.wifi.WifiInfo; import androidx.test.filters.SmallTest; -import com.android.internal.R; +import com.android.wifi.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java index 774af4de0..3d78e1e46 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java @@ -43,8 +43,8 @@ import android.os.test.TestLooper; import androidx.test.filters.SmallTest; -import com.android.internal.R; import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; +import com.android.wifi.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 74f102652..14a17b877 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -49,10 +49,10 @@ import android.util.Pair; import androidx.test.filters.SmallTest; import com.android.dx.mockito.inline.extended.ExtendedMockito; -import com.android.internal.R; import com.android.server.wifi.util.TelephonyUtil; import com.android.server.wifi.util.WifiPermissionsUtil; import com.android.server.wifi.util.WifiPermissionsWrapper; +import com.android.wifi.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index 3e9e0a6a3..fb80b23dd 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -51,7 +51,7 @@ import android.util.LocalLog; import androidx.test.filters.SmallTest; -import com.android.internal.R; +import com.android.wifi.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java index e4b1d7029..e5c91cb12 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java @@ -39,8 +39,8 @@ import android.content.Context; import androidx.test.filters.SmallTest; -import com.android.internal.R; import com.android.server.am.ActivityManagerService; +import com.android.wifi.R; import org.junit.Before; import org.junit.Ignore; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java index bf610c2c9..f576d2ce3 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java @@ -39,9 +39,9 @@ import android.util.LocalLog; import androidx.test.filters.SmallTest; -import com.android.internal.R; import com.android.server.wifi.WifiNetworkSelectorTestUtil.ScanDetailsAndWifiConfigs; import com.android.server.wifi.proto.nano.WifiMetricsProto; +import com.android.wifi.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java index 5755c5858..b94a37511 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java @@ -55,12 +55,12 @@ import android.os.UserHandle; import android.os.test.TestLooper; import android.test.suitebuilder.annotation.SmallTest; -import com.android.internal.R; import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; import com.android.server.wifi.WifiNetworkSuggestionsManager.ExtendedWifiNetworkSuggestion; import com.android.server.wifi.WifiNetworkSuggestionsManager.PerAppInfo; import com.android.server.wifi.hotspot2.PasspointManager; import com.android.server.wifi.util.WifiPermissionsUtil; +import com.android.wifi.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java index 2ed9e420f..f80201bac 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java @@ -38,7 +38,7 @@ import android.net.wifi.WifiInfo; import androidx.test.filters.SmallTest; -import com.android.internal.R; +import com.android.wifi.R; import org.junit.After; import org.junit.Before; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index a436d97c2..cac9cbd44 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -1646,7 +1646,7 @@ public class WifiServiceImplTest extends WifiBaseTest { @Test public void testStartLocalOnlyHotspotAt5Ghz() { when(mResources.getBoolean( - eq(com.android.internal.R.bool.config_wifi_local_only_hotspot_5ghz))) + eq(com.android.wifi.R.bool.config_wifi_local_only_hotspot_5ghz))) .thenReturn(true); when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)).thenReturn(true); when(mClientModeImpl.syncGetSupportedFeatures(any(AsyncChannel.class))) @@ -3196,7 +3196,7 @@ public class WifiServiceImplTest extends WifiBaseTest { @Test public void testNeeds5GHzToAnyApBandConversionReturnedTrue() { when(mResources.getBoolean( - eq(com.android.internal.R.bool.config_wifi_convert_apband_5ghz_to_any))) + eq(com.android.wifi.R.bool.config_wifi_convert_apband_5ghz_to_any))) .thenReturn(true); assertTrue(mWifiServiceImpl.needs5GHzToAnyApBandConversion()); @@ -3211,7 +3211,7 @@ public class WifiServiceImplTest extends WifiBaseTest { @Test public void testNeeds5GHzToAnyApBandConversionReturnedFalse() { when(mResources.getBoolean( - eq(com.android.internal.R.bool.config_wifi_convert_apband_5ghz_to_any))) + eq(com.android.wifi.R.bool.config_wifi_convert_apband_5ghz_to_any))) .thenReturn(false); assertFalse(mWifiServiceImpl.needs5GHzToAnyApBandConversion()); @@ -4120,7 +4120,7 @@ public class WifiServiceImplTest extends WifiBaseTest { private void setupMaxApInterfaces(int val) { when(mResources.getInteger( - eq(com.android.internal.R.integer.config_wifi_max_ap_interfaces))) + eq(com.android.wifi.R.integer.config_wifi_max_ap_interfaces))) .thenReturn(val); } diff --git a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java index 483b60686..bc51b6d4b 100644 --- a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java @@ -74,7 +74,6 @@ import android.provider.Settings; import androidx.test.filters.SmallTest; -import com.android.internal.R; import com.android.server.wifi.FakeWifiLog; import com.android.server.wifi.FrameworkFacade; import com.android.server.wifi.HalDeviceManager; @@ -83,6 +82,7 @@ import com.android.server.wifi.WifiInjector; import com.android.server.wifi.proto.nano.WifiMetricsProto.P2pConnectionEvent; import com.android.server.wifi.util.WifiPermissionsUtil; import com.android.server.wifi.util.WifiPermissionsWrapper; +import com.android.wifi.R; import org.junit.Before; import org.junit.Test; diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java index e4b6ec578..ad66e55ab 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java @@ -30,7 +30,6 @@ import android.os.test.TestLooper; import androidx.test.filters.SmallTest; -import com.android.internal.R; import com.android.server.wifi.Clock; import com.android.server.wifi.MockResources; import com.android.server.wifi.MockWifiMonitor; @@ -39,6 +38,7 @@ import com.android.server.wifi.WifiBaseTest; import com.android.server.wifi.WifiMonitor; import com.android.server.wifi.WifiNative; import com.android.server.wifi.scanner.ChannelHelper.ChannelCollection; +import com.android.wifi.R; import org.junit.Before; import org.junit.Test; -- cgit v1.2.3 From efc08d99de7aa84490fa26b76312bf7877814e1f Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 30 Oct 2019 09:11:44 -0700 Subject: 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 --- .../android/server/wifi/ClientModeImplTest.java | 75 +++++++++++++++++----- 1 file changed, 60 insertions(+), 15 deletions(-) (limited to 'tests') 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. -- cgit v1.2.3