diff options
| -rw-r--r-- | wifi/java/android/net/wifi/WifiNetworkSuggestion.java | 12 | ||||
| -rw-r--r-- | wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java | 16 |
2 files changed, 21 insertions, 7 deletions
diff --git a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java index 2fba5a3f4624..7ecad9ee1031 100644 --- a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java +++ b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java @@ -635,14 +635,12 @@ public final class WifiNetworkSuggestion implements Parcelable { } mIsSharedWithUser = false; } - - if (!mIsSharedWithUser && !mIsInitialAutoJoinEnabled) { - throw new IllegalStateException("Should have not a network with both " - + "setIsUserAllowedToManuallyConnect and " - + "setIsAutoJoinEnabled set to false"); - } } - + if (!mIsSharedWithUser && !mIsInitialAutoJoinEnabled) { + throw new IllegalStateException("Should have not a network with both " + + "setCredentialSharedWithUser and " + + "setIsAutoJoinEnabled set to false"); + } return new WifiNetworkSuggestion( wifiConfiguration, mPasspointConfiguration, diff --git a/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java b/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java index cb1b7747798d..e778b9ad47a3 100644 --- a/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java +++ b/wifi/tests/src/android/net/wifi/WifiNetworkSuggestionTest.java @@ -758,4 +758,20 @@ public class WifiNetworkSuggestionTest { .setIsInitialAutoJoinEnabled(false) .build(); } + + /** + * Ensure {@link WifiNetworkSuggestion.Builder#build()} throws an exception + * when set both {@link WifiNetworkSuggestion.Builder#setIsInitialAutoJoinEnabled(boolean)} + * and {@link WifiNetworkSuggestion.Builder#setCredentialSharedWithUser(boolean)} (boolean)} + * to false on a passpoint suggestion. + */ + @Test(expected = IllegalStateException.class) + public void testSetIsAutoJoinDisabledWithSecureNetworkNotSharedWithUserForPasspoint() { + PasspointConfiguration passpointConfiguration = PasspointTestUtils.createConfig(); + new WifiNetworkSuggestion.Builder() + .setPasspointConfig(passpointConfiguration) + .setCredentialSharedWithUser(false) + .setIsInitialAutoJoinEnabled(false) + .build(); + } } |