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

Commit ba4cb789 authored by Nikhil Nayunigari's avatar Nikhil Nayunigari
Browse files

Add edit configuration toggle to the add network dialog

This lets the user to allow other device users to edit network
configuration.

Bug: b/409845314

Flag: com.android.settings.connectivity.wifi_multiuser

Test: Manual test on a pixel tablet
Change-Id: I8fd2f38de787fc59cf1b5dca45148a440046db43
parent bced4c67
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -425,6 +425,29 @@
                android:gravity="center_vertical" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/edit_wifi_network_configuration_fields"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="center_vertical"
            style="@style/wifi_item"
            android:visibility="gone">

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/edit_wifi_network_configuration"
                style="@style/wifi_item_label"/>

            <Switch
                android:id="@+id/edit_wifi_network_configuration"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_vertical" />
        </LinearLayout>

        <LinearLayout android:id="@+id/hidden_settings_field"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
+1 −0
Original line number Diff line number Diff line
@@ -2602,6 +2602,7 @@
    <string name="share_wifi_network">Share this network with other device users</string>
    <!-- Label for the share wifi network summary. [CHAR LIMIT=NONE] -->
    <string name="share_wifi_network_summary">All users on this device can view and connect to a shared network. Administrators can delete a shared network. Learn more</string>
    <string name="edit_wifi_network_configuration">Allow other users to edit network configuration</string>
    <!-- Dialog text to tell the user that the selected network does not have Internet access. -->
    <string name="no_internet_access_text">This network has no internet access. Stay connected?</string>
+12 −0
Original line number Diff line number Diff line
@@ -208,6 +208,7 @@ public class WifiConfigController2 implements TextWatcher,
    private TextView mDns2View;

    private Switch mSharedSwitch;
    private Switch mEditConfigurationSwitch;
    private Spinner mProxySettingsSpinner;
    @Nullable
    private Spinner mMeteredSettingsSpinner;
@@ -338,12 +339,18 @@ public class WifiConfigController2 implements TextWatcher,
                        : View.VISIBLE);
        mSecurityInPosition = new Integer[WifiEntry.NUM_SECURITY_TYPES];
        mSharedSwitch = (Switch) mView.findViewById(R.id.share_wifi_network);
        mEditConfigurationSwitch =
            (Switch) mView.findViewById(R.id.edit_wifi_network_configuration);

        if (mWifiEntry == null) { // new network
            configureSecuritySpinner();
            mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
            if (com.android.settings.connectivity.Flags.wifiMultiuser()) {
                mSharedSwitch.setOnCheckedChangeListener(this);
                mView.findViewById(R.id.sharing_toggle_fields).setVisibility(View.VISIBLE);
                mEditConfigurationSwitch.setEnabled(false);
                mView.findViewById(R.id.edit_wifi_network_configuration_fields)
                        .setVisibility(View.VISIBLE);
            }
        } else {
            mConfigUi.setTitle(mWifiEntry.getTitle());
@@ -1731,6 +1738,11 @@ public class WifiConfigController2 implements TextWatcher,
            hideSoftKeyboard(mView.getWindowToken());
            view.setVisibility(View.GONE);
            mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
        } else if (view.getId() == R.id.share_wifi_network) {
            mEditConfigurationSwitch.setEnabled(isChecked);
            if (!isChecked) {
                mEditConfigurationSwitch.setChecked(false);
            }
        }
    }

+17 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.WifiEnterpriseConfig.Eap;
import android.net.wifi.WifiEnterpriseConfig.Phase2;
import android.net.wifi.WifiManager;
import android.os.Looper;
import android.platform.test.annotations.EnableFlags;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
@@ -235,6 +236,22 @@ public class WifiConfigController2Test {
        assertThat(config.shared).isTrue();
    }

    @Test
    @EnableFlags(Flags.FLAG_WIFI_MULTIUSER)
    public void editConfigurationFieldState() {
        createController(null, WifiConfigUiBase2.MODE_CONNECT, false);
        final Switch editConfigurationSwitch =
                mView.findViewById(R.id.edit_wifi_network_configuration);
        final Switch sharedSwitch = mView.findViewById(R.id.share_wifi_network);

        assertThat(editConfigurationSwitch).isNotNull();

        sharedSwitch.setChecked(true);
        shadowOf(Looper.getMainLooper()).idle();

        assertThat(editConfigurationSwitch.isEnabled()).isTrue();
    }

    @Test
    public void isSubmittable_EapWithAkaMethod_shouldReturnTrue() {
        createController(mWifiEntry, WifiConfigUiBase2.MODE_CONNECT, false);