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

Commit 8d4ef86d authored by Nate(Qiang) Jiang's avatar Nate(Qiang) Jiang
Browse files

set SharedWithUser and IsAutoJoinEnabled both to false is not allowed

Fix the issue that passpoint suggestion can set both to false.

Bug: 139199957
Test: atest android.net.wifi

Change-Id: I44ef0116efeb04220b3f710664aecab614ae849c
parent 0ac2268b
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();
    }
}