diff options
5 files changed, 17 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java index 7ccca0625..329c330e6 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java @@ -406,6 +406,7 @@ public class PasspointManager { if (!result.isSuccess()) { Log.e(TAG, "Failed to update config in WifiConfigManager"); } else { + mWifiConfigManager.allowAutojoin(result.getNetworkId(), newConfig.allowAutojoin); if (mVerboseLoggingEnabled) { Log.v(TAG, "Updated config in WifiConfigManager"); } diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java index e1491aa7a..bf2e460d8 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java @@ -208,7 +208,7 @@ public class PasspointNetworkNominateHelper { mLocalLog.log("Failed to add passpoint network"); return existingNetwork; } - + mWifiConfigManager.allowAutojoin(result.getNetworkId(), config.allowAutojoin); mWifiConfigManager.enableNetwork(result.getNetworkId(), false, Process.WIFI_UID, null); mWifiConfigManager.setNetworkCandidateScanResult(result.getNetworkId(), candidate.mScanDetail.getScanResult(), 0); diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java index 9174534c7..8e7364d4b 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java @@ -514,6 +514,7 @@ public class PasspointProvider { // Check server certificate using OCSP (Online Certificate Status Protocol). wifiConfig.enterpriseConfig.setOcsp(WifiEnterpriseConfig.OCSP_REQUIRE_CERT_STATUS); } + wifiConfig.allowAutojoin = isAutojoinEnabled(); wifiConfig.shared = mIsShared; wifiConfig.fromWifiNetworkSuggestion = mIsFromSuggestion; wifiConfig.ephemeral = mIsFromSuggestion; diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java index 885cf87a3..94fe673c3 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java @@ -32,7 +32,6 @@ import static android.net.wifi.WifiManager.EXTRA_SUBSCRIPTION_REMEDIATION_METHOD import static android.net.wifi.WifiManager.EXTRA_URL; import static com.android.server.wifi.WifiConfigurationTestUtil.SECURITY_EAP; -import static com.android.server.wifi.WifiConfigurationTestUtil.TEST_NETWORK_ID; import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; import static org.junit.Assert.assertEquals; @@ -174,6 +173,7 @@ public class PasspointManagerTest extends WifiBaseTest { private static final int TEST_CREATOR_UID = 1234; private static final int TEST_CREATOR_UID1 = 1235; private static final int TEST_UID = 1500; + private static final int TEST_NETWORK_ID = 2; @Mock Context mContext; @Mock WifiNative mWifiNative; @@ -921,6 +921,7 @@ public class PasspointManagerTest extends WifiBaseTest { origWifiConfig.getKey()); verify(mWifiConfigManager).addOrUpdateNetwork( argThat((c) -> c.FQDN.equals(TEST_FQDN)), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE)); + verify(mWifiConfigManager).allowAutojoin(TEST_NETWORK_ID, origWifiConfig.allowAutojoin); verify(mWifiConfigManager).saveToStore(true); verify(mWifiMetrics).incrementNumPasspointProviderInstallation(); verify(mWifiMetrics).incrementNumPasspointProviderInstallSuccess(); @@ -2123,6 +2124,7 @@ public class PasspointManagerTest extends WifiBaseTest { origWifiConfig.getKey()); verify(mWifiConfigManager).addOrUpdateNetwork( argThat((c) -> c.FQDN.equals(TEST_FQDN)), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE)); + verify(mWifiConfigManager).allowAutojoin(TEST_NETWORK_ID, origWifiConfig.allowAutojoin); verify(mWifiConfigManager).saveToStore(true); verify(mWifiMetrics).incrementNumPasspointProviderInstallation(); verify(mWifiMetrics).incrementNumPasspointProviderInstallSuccess(); diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java index 19ced12fc..936a8c4c9 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java @@ -1250,6 +1250,17 @@ public class PasspointProviderTest extends WifiBaseTest { verifyWifiConfigWithTestData(config, mProvider.getWifiConfig()); } + @Test + public void getWifiConfigWithWithAutojoinDisable() throws Exception { + PasspointConfiguration config = generateTestPasspointConfiguration( + CredentialType.USER, false); + mProvider = createProvider(config); + + assertTrue(mProvider.getWifiConfig().allowAutojoin); + mProvider.setAutojoinEnabled(false); + assertFalse(mProvider.getWifiConfig().allowAutojoin); + } + /** * Verify that the mac randomization setting will be included in the generated * WifiConfiguration. |