summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-04-29 14:20:34 -0700
committerNate Jiang <qiangjiang@google.com>2020-04-29 14:22:25 -0700
commit07b8d667df82fa5ffda9cf7527cf910a25e00c8a (patch)
treec2c2f6128f40a4ffe2c2164d4e9562f5ad3dcd90
parent9f756c8e97656f1edbb744de5b74a8ca693ae755 (diff)
Add overlay to control if ignore saved open network
Bug: 154654080 Test: atest com.android.server.wifi Change-Id: I0e41dc95c1b6a2e0e9a0ab79aacab7fa7a846154
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java4
-rw-r--r--service/res/values/config.xml2
-rw-r--r--service/res/values/overlayable.xml1
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java52
4 files changed, 59 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index fc1b32d05..b83af52f2 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -2028,6 +2028,10 @@ public class WifiNetworkSuggestionsManager {
*/
public boolean shouldBeIgnoredBySecureSuggestionFromSameCarrier(
@NonNull WifiConfiguration configuration, List<ScanDetail> scanDetails) {
+ if (!mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable)) {
+ return false;
+ }
if (configuration == null || scanDetails == null || !configuration.isOpenNetwork()) {
return false;
}
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index c58ab196b..5d8a47ca9 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -412,4 +412,6 @@
cause the wifi stack to turn wifi off and wait for user input.
Set to 0 to turn off recovery attempts and always turn off wifi on failures -->
<integer translatable="false" name="config_wifiMaxNativeFailureSelfRecoveryPerHour">2</integer>
+ <!-- Ignore the open saved network if from carrier provisioning app, there is a same open suggestion and a secure suggestion from same carrier available -->
+ <bool translatable="false" name="config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable">true</bool>
</resources>
diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml
index 687b6b9e8..60454728d 100644
--- a/service/res/values/overlayable.xml
+++ b/service/res/values/overlayable.xml
@@ -129,6 +129,7 @@
<item type="bool" name="config_wifiSaeUpgradeEnabled" />
<item type="bool" name="config_wifiSaeUpgradeOffloadEnabled" />
<item type="integer" name="config_wifiMaxNativeFailureSelfRecoveryPerHour" />
+ <item type="bool" name="config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable" />
<!-- Params from config.xml that can be overlayed -->
<!-- Params from strings.xml that can be overlayed -->
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index 5018337d9..79c9c0a3e 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -3721,6 +3721,9 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
@Test
public void testShouldNotBeIgnoredBySecureSuggestionFromSameCarrierWithoutSameOpenSuggestion() {
+ when(mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable))
+ .thenReturn(true);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(anyInt()))
.thenReturn(true);
WifiConfiguration network1 = WifiConfigurationTestUtil.createOpenNetwork();
@@ -3746,6 +3749,9 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
@Test
public void testShouldNotBeIgnoredBySecureSuggestionFromSameCarrierWithoutSecureSuggestion() {
+ when(mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable))
+ .thenReturn(true);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(anyInt()))
.thenReturn(true);
WifiConfiguration network1 = WifiConfigurationTestUtil.createOpenNetwork();
@@ -3771,6 +3777,9 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
@Test
public void testShouldNotBeIgnoredWithoutCarrierProvisioningPermission() {
+ when(mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable))
+ .thenReturn(true);
when(mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(anyString()))
.thenReturn(TEST_CARRIER_ID);
WifiConfiguration network1 = WifiConfigurationTestUtil.createOpenNetwork();
@@ -3796,6 +3805,9 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
@Test
public void testShouldNotBeIgnoredBySecureSuggestionFromDifferentCarrierId() {
+ when(mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable))
+ .thenReturn(true);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(anyInt()))
.thenReturn(true);
WifiConfiguration network1 = WifiConfigurationTestUtil.createOpenNetwork();
@@ -3821,6 +3833,9 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
@Test
public void testShouldNotBeIgnoredBySecureSuggestionFromSameCarrierWithAutojoinDisabled() {
+ when(mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable))
+ .thenReturn(true);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(anyInt()))
.thenReturn(true);
WifiConfiguration network1 = WifiConfigurationTestUtil.createOpenNetwork();
@@ -3846,6 +3861,9 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
@Test
public void testShouldNotBeIgnoredBySecureSuggestionFromSameCarrierWithDifferentMeterness() {
+ when(mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable))
+ .thenReturn(true);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(anyInt()))
.thenReturn(true);
WifiConfiguration network1 = WifiConfigurationTestUtil.createOpenNetwork();
@@ -3872,6 +3890,9 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
@Test
public void testShouldNotBeIgnoredBySecureSuggestionFromSameCarrierWithNetworkDisabled() {
+ when(mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable))
+ .thenReturn(true);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(anyInt()))
.thenReturn(true);
WifiConfiguration network1 = WifiConfigurationTestUtil.createOpenNetwork();
@@ -3903,7 +3924,38 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}
@Test
+ public void testShouldNotBeIgnoredBySecureSuggestionFromSameCarrierWithOverlayFalse() {
+ when(mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable))
+ .thenReturn(false);
+ when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(anyInt()))
+ .thenReturn(true);
+ WifiConfiguration network1 = WifiConfigurationTestUtil.createOpenNetwork();
+ ScanDetail scanDetail1 = createScanDetailForNetwork(network1);
+ network1.carrierId = TEST_CARRIER_ID;
+ WifiNetworkSuggestion suggestion1 = new WifiNetworkSuggestion(
+ network1, null, false, false, true, true);
+ WifiConfiguration network2 = WifiConfigurationTestUtil.createPskNetwork();
+ ScanDetail scanDetail2 = createScanDetailForNetwork(network2);
+ network2.carrierId = TEST_CARRIER_ID;
+ WifiNetworkSuggestion suggestion2 = new WifiNetworkSuggestion(
+ network2, null, false, false, true, true);
+
+ List<ScanDetail> scanDetails = Arrays.asList(scanDetail1, scanDetail2);
+ // Both open and secure suggestions with same carrierId,
+ List<WifiNetworkSuggestion> suggestionList = Arrays.asList(suggestion1, suggestion2);
+ assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
+ mWifiNetworkSuggestionsManager.add(suggestionList, TEST_UID_1,
+ TEST_PACKAGE_1, TEST_FEATURE));
+ assertFalse(mWifiNetworkSuggestionsManager
+ .shouldBeIgnoredBySecureSuggestionFromSameCarrier(network1, scanDetails));
+ }
+
+ @Test
public void testShouldBeIgnoredBySecureSuggestionFromSameCarrier() {
+ when(mResources.getBoolean(
+ R.bool.config_wifiIgnoreOpenSavedNetworkWhenSecureSuggestionAvailable))
+ .thenReturn(true);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(anyInt()))
.thenReturn(true);
WifiConfiguration network1 = WifiConfigurationTestUtil.createOpenNetwork();