Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c5ca138 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "set SharedWithUser and IsAutoJoinEnabled both to false is not allowed"

parents 0a5e31ee 8d4ef86d
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -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 "
                        + "setCredentialSharedWithUser and "
                        + "setIsAutoJoinEnabled set to false");
            }
            }

            return new WifiNetworkSuggestion(
                    wifiConfiguration,
                    mPasspointConfiguration,
+16 −0
Original line number Diff line number Diff line
@@ -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();
    }
}