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

Commit 838cbbf5 authored by Arc Wang's avatar Arc Wang
Browse files

[Wi-Fi DPP] Remove scanner button of unsaved WiFi network dialogs

Romove it because we may not ensure the network of a QR code is
matching the selected one.

Bug: 134701332
Test: manual visual
Change-Id: I264e921c806f2b335d158fc4cffc48acf69f5c19
parent 64fec889
Loading
Loading
Loading
Loading
+5 −23
Original line number Diff line number Diff line
@@ -288,30 +288,12 @@
                        style="@style/wifi_item_label"
                        android:text="@string/wifi_password" />

                <androidx.constraintlayout.widget.ConstraintLayout
                    xmlns:app="http://schemas.android.com/apk/res-auto"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                <EditText android:id="@+id/password"
                              android:layout_width="0dp"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                              app:layout_constraintStart_toStartOf="parent"
                              app:layout_constraintEnd_toStartOf="@+id/password_scanner_button"
                        style="@style/wifi_item_edit_content"
                        android:singleLine="true"
                        android:password="true"/>

                    <ImageButton
                        android:id="@+id/password_scanner_button"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:minWidth="@dimen/min_tap_target_size"
                        android:minHeight="@dimen/min_tap_target_size"
                        app:layout_constraintEnd_toEndOf="parent"
                        android:background="?android:attr/selectableItemBackground"
                        android:src="@drawable/ic_scan_24dp"
                        android:contentDescription="@string/wifi_dpp_scan_qr_code"/>
                </androidx.constraintlayout.widget.ConstraintLayout>
            </LinearLayout>

            <LinearLayout android:id="@+id/show_password_layout"
+1 −11
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf
    @VisibleForTesting
    final static int CANCEL_BUTTON_ID = android.R.id.button2;
    final static int SSID_SCANNER_BUTTON_ID = R.id.ssid_scanner_button;
    final static int PASSWORD_SCANNER_BUTTON_ID = R.id.password_scanner_button;

    private static final int REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER = 0;

@@ -74,11 +73,9 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf
        mSubmitBtn = rootView.findViewById(SUBMIT_BUTTON_ID);
        mCancelBtn = rootView.findViewById(CANCEL_BUTTON_ID);
        final ImageButton ssidScannerButton = rootView.findViewById(SSID_SCANNER_BUTTON_ID);
        final ImageButton passwordScannerButton = rootView.findViewById(PASSWORD_SCANNER_BUTTON_ID);
        mSubmitBtn.setOnClickListener(this);
        mCancelBtn.setOnClickListener(this);
        ssidScannerButton.setOnClickListener(this);
        passwordScannerButton.setOnClickListener(this);
        mUIController = new WifiConfigController(this, rootView, null, getMode());

        return rootView;
@@ -92,24 +89,17 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf

    @Override
    public void onClick(View view) {
        String ssid = null;

        if (view.getId() == SUBMIT_BUTTON_ID) {
            handleSubmitAction();
        } else if (view.getId() == CANCEL_BUTTON_ID) {
            handleCancelAction();
        } else if (view.getId() == SSID_SCANNER_BUTTON_ID) {
            final TextView ssidEditText = getView().findViewById(R.id.ssid);
            ssid = ssidEditText.getText().toString();
            // No break and flows to case PASSWORD_SCANNER_BUTTON_ID
            final String ssid = ssidEditText.getText().toString();

            // Launch QR code scanner to join a network.
            startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid),
                    REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
        } else if (view.getId()
                == PASSWORD_SCANNER_BUTTON_ID) {// Launch QR code scanner to join a network.
            startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid),
                    REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
        }
    }

+0 −6
Original line number Diff line number Diff line
@@ -131,7 +131,6 @@ public class WifiConfigController implements TextWatcher,
    int mAccessPointSecurity;
    private TextView mPasswordView;
    private ImageButton mSsidScanButton;
    private ImageButton mPasswordScanButton;

    private String mUnspecifiedCertString;
    private String mMultipleCertSetString;
@@ -243,7 +242,6 @@ public class WifiConfigController implements TextWatcher,
            mContext.getString(R.string.wifi_do_not_validate_eap_server);

        mSsidScanButton = (ImageButton) mView.findViewById(R.id.ssid_scanner_button);
        mPasswordScanButton = (ImageButton) mView.findViewById(R.id.password_scanner_button);
        mDialogContainer = mView.findViewById(R.id.dialog_scrollview);
        mIpSettingsSpinner = (Spinner) mView.findViewById(R.id.ip_settings);
        mIpSettingsSpinner.setOnItemSelectedListener(this);
@@ -269,7 +267,6 @@ public class WifiConfigController implements TextWatcher,
        if (mAccessPoint == null) { // new network
            configureSecuritySpinner();
            mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
            mPasswordScanButton.setVisibility(View.GONE);
        } else {
            mConfigUi.setTitle(mAccessPoint.getTitle());

@@ -415,9 +412,6 @@ public class WifiConfigController implements TextWatcher,
                }
            }

            if (!WifiDppUtils.isSupportEnrolleeQrCodeScanner(mContext, mAccessPointSecurity)) {
                mPasswordScanButton.setVisibility(View.GONE);
            }
            mSsidScanButton.setVisibility(View.GONE);
        }

+8 −17
Original line number Diff line number Diff line
@@ -114,31 +114,22 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase,

    @Override
    protected void onStart() {
        final ImageButton ssidScannerButton = findViewById(R.id.ssid_scanner_button);
        if (mHideSubmitButton) {
            ssidScannerButton.setVisibility(View.GONE);
            return;
        }

        View.OnClickListener onClickScannerButtonListener = v -> {
            if (mListener == null) {
                return;
            }

            String ssid = null;
            if (mAccessPoint == null) {
            final TextView ssidEditText = findViewById(R.id.ssid);
                ssid = ssidEditText.getText().toString();
            } else {
                ssid = mAccessPoint.getSsidStr();
            }
            final String ssid = ssidEditText.getText().toString();
            mListener.onScan(/* WifiDialog */ this, ssid);
        };

        final ImageButton ssidScannerButton = findViewById(R.id.ssid_scanner_button);
        ssidScannerButton.setOnClickListener(onClickScannerButtonListener);

        final ImageButton passwordScannerButton = findViewById(R.id.password_scanner_button);
        passwordScannerButton.setOnClickListener(onClickScannerButtonListener);

        if (mHideSubmitButton) {
            ssidScannerButton.setVisibility(View.GONE);
            passwordScannerButton.setVisibility(View.GONE);
        }
    }

    public void onRestoreInstanceState(Bundle savedInstanceState) {
+1 −11
Original line number Diff line number Diff line
@@ -437,18 +437,8 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
            return false;
        }

        final String scheme = mWifiQrCode.getScheme();

        // When SSID is specified for enrollee, avoid to connect to the Wi-Fi of different SSID
        if (!mIsConfiguratorMode && WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG.equals(scheme)) {
            final String ssidQrCode = mWifiQrCode.getWifiNetworkConfig().getSsid();
            if (!TextUtils.isEmpty(mSsid) && !mSsid.equals(ssidQrCode)) {
                showErrorMessage(R.string.wifi_dpp_could_not_detect_valid_qr_code);
                return false;
            }
        }

        // It's impossible to provision other device with ZXing Wi-Fi Network config format
        final String scheme = mWifiQrCode.getScheme();
        if (mIsConfiguratorMode && WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG.equals(scheme)) {
            showErrorMessage(R.string.wifi_dpp_could_not_detect_valid_qr_code);
            return false;