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

Commit e19df28f authored by Jason Zhang's avatar Jason Zhang
Browse files

Add MODE_LOGIN_SCREEN to Wifi config dialog

Add the new MODE_LOGIN_SCREEN to show a dedicated wifi config dialog
when user is at the login screen.

Bug: 408529970
Flag: com.android.systemui.qs_wifi_config
Test: manual test & atest WifiConfigController2Test
Change-Id: I1abd1083eb6576556bc66390b68399f89d475e36
parent 2488e2b6
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -411,6 +411,28 @@
                  android:orientation="vertical"
                  android:visibility="gone">

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

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_info_outline_24dp"
                android:tint="?android:attr/textColorTertiary"
                android:contentDescription="@string/wifi_shared_network_login_screen_warning"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingStart="8dp"
                android:text="@string/wifi_shared_network_login_screen_warning"
                style="@style/wifi_item_label"/>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/sharing_toggle_fields"
            android:layout_width="match_parent"
+2 −0
Original line number Diff line number Diff line
@@ -2605,6 +2605,8 @@
    <string name="wifi_scan_always_confirm_deny">Deny</string>
    <!-- Error message displayed below the Wi-Fi EditText when the filed is required. [CHAR LIMIT=NONE] -->
    <string name="wifi_field_required">*required</string>
    <!-- Message to inform user, the network can only be configured at a shared network.  [CHAR LIMIT=250] -->
    <string name="wifi_shared_network_login_screen_warning">This is a shared network. You can change this setting once logged in.</string>
    <!-- Label for the share wifi network toggle. [CHAR LIMIT=250] -->
    <string name="share_wifi_network">Share this network with other device users</string>
    <!-- Label for the share wifi network summary. [CHAR LIMIT=NONE] -->
+14 −0
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@ public class WifiConfigController2 implements TextWatcher,
    private TextView mDns1View;
    private TextView mDns2View;

    private LinearLayout mSharedNetworkLoginScreenWarning;
    private Switch mSharedSwitch;
    private Switch mEditConfigurationSwitch;
    private Spinner mProxySettingsSpinner;
@@ -346,6 +347,8 @@ public class WifiConfigController2 implements TextWatcher,
        mSharedSwitch = (Switch) mView.findViewById(R.id.share_wifi_network);
        mEditConfigurationSwitch =
            (Switch) mView.findViewById(R.id.edit_wifi_network_configuration);
        mSharedNetworkLoginScreenWarning =
            (LinearLayout) mView.findViewById(R.id.shared_network_login_screen_warning);

        if (mWifiEntry == null) { // new network
            configureSecuritySpinner();
@@ -435,6 +438,12 @@ public class WifiConfigController2 implements TextWatcher,
                mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
            } else if (mMode == WifiConfigUiBase2.MODE_CONNECT) {
                mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
            } else if (mMode == WifiConfigUiBase2.MODE_LOGIN_SCREEN) {
                mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
                mSharedNetworkLoginScreenWarning.setVisibility(View.VISIBLE);
                mView.findViewById(R.id.sharing_toggle_fields).setVisibility(View.GONE);
                mView.findViewById(R.id.edit_wifi_network_configuration_fields)
                        .setVisibility(View.GONE);
            } else {
                final String signalLevel = getSignalString();

@@ -621,6 +630,11 @@ public class WifiConfigController2 implements TextWatcher,
            config.SSID = "\"" + mWifiEntry.getTitle() + "\"";
        }

        if (mMode == WifiConfigUiBase2.MODE_LOGIN_SCREEN) {
            config.shared = true;
            // TODO: set allowEditConfig once the API is ready.
        }

        if (!com.android.settings.connectivity.Flags.wifiMultiuser()) {
            config.shared = mSharedCheckBox.isChecked();
        }
+6 −0
Original line number Diff line number Diff line
@@ -40,6 +40,12 @@ public interface WifiConfigUiBase2 {
     */
    int MODE_MODIFY = 2;

    /**
     * Connect mode specifically for the login screen. Data is displayed in editable mode partially,
     * for example: the shared toggle will be hidden at the login screen.
     */
    int MODE_LOGIN_SCREEN = 3;

    /**
     * UI like {@link WifiDialog} overrides to provide {@link Context} to controller.
     */
+13 −1
Original line number Diff line number Diff line
@@ -183,10 +183,12 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
            createDialogWithSuwTheme();
        } else {
            if (mIsWifiTrackerLib || mUseWifiDialog2ForAddNetwork) {
                final int mode = isAtLoginScreen()
                        ? WifiConfigUiBase2.MODE_LOGIN_SCREEN : WifiConfigUiBase2.MODE_CONNECT;
                mDialog2 = new WifiDialog2(this, this,
                        mNetworkDetailsTracker == null
                                ? null : mNetworkDetailsTracker.getWifiEntry(),
                        WifiConfigUiBase2.MODE_CONNECT, 0 /* style */,
                                mode, 0 /* style */,
                        false /* hideSubmitButton */, false /* hideMeteredAndPrivacy */,
                        Utils.SYSTEMUI_PACKAGE_NAME.equals(getLaunchedFromPackage()));
            } else {
@@ -406,6 +408,16 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
        }
    }

    @VisibleForTesting
    boolean isAtLoginScreen() {
        if (!Flags.wifiMultiuser()) {
            return false;
        }
        UserManager userManager = getSystemService(UserManager.class);
        return userManager != null
                && userManager.isHeadlessSystemUserMode() && userManager.isSystemUser();
    }

    @VisibleForTesting
    boolean isConfigWifiAllowed() {
        UserManager userManager = getSystemService(UserManager.class);
Loading