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

Commit 1efe5eb8 authored by Nate Jiang's avatar Nate Jiang Committed by Android (Google) Code Review
Browse files

Merge "Rename API setIsUserAllowedToManuallyConnect to setCredentialSharedWithUser"

parents 88246a50 2f8fec07
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30663,11 +30663,11 @@ package android.net.wifi {
    ctor public WifiNetworkSuggestion.Builder();
    method @NonNull public android.net.wifi.WifiNetworkSuggestion build();
    method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setBssid(@NonNull android.net.MacAddress);
    method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setCredentialSharedWithUser(boolean);
    method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setIsAppInteractionRequired(boolean);
    method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setIsEnhancedOpen(boolean);
    method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setIsHiddenSsid(boolean);
    method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setIsMetered(boolean);
    method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setIsUserAllowedToManuallyConnect(boolean);
    method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setIsUserInteractionRequired(boolean);
    method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setPasspointConfig(@NonNull android.net.wifi.hotspot2.PasspointConfiguration);
    method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setPriority(@IntRange(from=0) int);
+13 −13
Original line number Diff line number Diff line
@@ -116,12 +116,12 @@ public final class WifiNetworkSuggestion implements Parcelable {
        /**
         * Whether this network is shared credential with user to allow user manually connect.
         */
        private boolean mIsUserAllowed;
        private boolean mIsSharedWithUser;

        /**
         * Whether the setIsUserAllowedToManuallyConnect have been called.
         * Whether the setCredentialSharedWithUser have been called.
         */
        private boolean mIsUserAllowedBeenSet;
        private boolean mIsSharedWithUserSet;
        /**
         * Pre-shared key for use with WAPI-PSK networks.
         */
@@ -146,8 +146,8 @@ public final class WifiNetworkSuggestion implements Parcelable {
            mIsAppInteractionRequired = false;
            mIsUserInteractionRequired = false;
            mIsMetered = false;
            mIsUserAllowed = true;
            mIsUserAllowedBeenSet = false;
            mIsSharedWithUser = true;
            mIsSharedWithUserSet = false;
            mPriority = UNASSIGNED_PRIORITY;
            mCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
            mWapiPskPassphrase = null;
@@ -430,13 +430,13 @@ public final class WifiNetworkSuggestion implements Parcelable {
         * <li>If not set, defaults to true (i.e. allow user to manually connect) for secure
         * networks and false for open networks.</li>
         *
         * @param isAllowed {@code true} to indicate that the credentials may be used by the user to
         * @param isShared {@code true} to indicate that the credentials may be used by the user to
         *                              manually connect to the network, {@code false} otherwise.
         * @return Instance of {@link Builder} to enable chaining of the builder method.
         */
        public @NonNull Builder setIsUserAllowedToManuallyConnect(boolean isAllowed) {
            mIsUserAllowed = isAllowed;
            mIsUserAllowedBeenSet = true;
        public @NonNull Builder setCredentialSharedWithUser(boolean isShared) {
            mIsSharedWithUser = isShared;
            mIsSharedWithUserSet = true;
            return this;
        }

@@ -602,11 +602,11 @@ public final class WifiNetworkSuggestion implements Parcelable {
                }
                wifiConfiguration = buildWifiConfiguration();
                if (wifiConfiguration.isOpenNetwork()) {
                    if (mIsUserAllowedBeenSet && mIsUserAllowed) {
                    if (mIsSharedWithUserSet && mIsSharedWithUser) {
                        throw new IllegalStateException("Open network should not be "
                                + "setIsUserAllowedToManuallyConnect to true");
                                + "setCredentialSharedWithUser to true");
                    }
                    mIsUserAllowed = false;
                    mIsSharedWithUser = false;
                }
            }

@@ -615,7 +615,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
                    mPasspointConfiguration,
                    mIsAppInteractionRequired,
                    mIsUserInteractionRequired,
                    mIsUserAllowed);
                    mIsSharedWithUser);
        }
    }

+4 −4
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ public class WifiNetworkSuggestionTest {
                .setSsid(TEST_SSID)
                .setWpa2Passphrase(TEST_PRESHARED_KEY)
                .setIsAppInteractionRequired(true)
                .setIsUserAllowedToManuallyConnect(false)
                .setCredentialSharedWithUser(false)
                .setPriority(0)
                .build();

@@ -151,7 +151,7 @@ public class WifiNetworkSuggestionTest {
        WifiNetworkSuggestion suggestion = new WifiNetworkSuggestion.Builder()
                .setSsid(TEST_SSID)
                .setWpa3Passphrase(TEST_PRESHARED_KEY)
                .setIsUserAllowedToManuallyConnect(true)
                .setCredentialSharedWithUser(true)
                .build();

        assertEquals("\"" + TEST_SSID + "\"", suggestion.wifiConfiguration.SSID);
@@ -709,14 +709,14 @@ public class WifiNetworkSuggestionTest {

    /**
     * Ensure {@link WifiNetworkSuggestion.Builder#build()} throws an exception
     * when {@link WifiNetworkSuggestion.Builder#setIsUserAllowedToManuallyConnect(boolean)} to
     * when {@link WifiNetworkSuggestion.Builder#setCredentialSharedWithUser(boolean)} to
     * true on a open network suggestion.
     */
    @Test(expected = IllegalStateException.class)
    public void testSetIsUserAllowedToManuallyConnectToWithOpenNetwork() {
        WifiNetworkSuggestion suggestion = new WifiNetworkSuggestion.Builder()
                .setSsid(TEST_SSID)
                .setIsUserAllowedToManuallyConnect(true)
                .setCredentialSharedWithUser(true)
                .build();
    }
}