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

Commit 994929ec authored by Arc Wang's avatar Arc Wang
Browse files

Hide 'Share' button and 'Add device' preference for a Passpoint Wi-Fi network

Passpoint provisioning is much different from other Wi-Fi networks and ZXing
does not support a QR code format to share a passpoint Wi-Fi network. We
should not show any button to share a passpoint Wi-Fi network.

Bug: 130609037
Test: manual
Change-Id: Ie2538ed9e030e5aa2e88452b50b6592223ca46a8
parent 96b53495
Loading
Loading
Loading
Loading
+16 −12
Original line number Diff line number Diff line
@@ -404,9 +404,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
                .setButton3Enabled(true)
                .setButton4Text(R.string.share)
                .setButton4Icon(R.drawable.ic_qrcode_24dp)
                .setButton4OnClickListener(view -> shareNetwork())
                .setButton4Visible(
                        WifiDppUtils.isSupportConfiguratorQrCodeGenerator(mContext, mAccessPoint));
                .setButton4OnClickListener(view -> shareNetwork());

        mSignalStrengthPref = screen.findPreference(KEY_SIGNAL_STRENGTH_PREF);
        mTxLinkSpeedPref = screen.findPreference(KEY_TX_LINK_SPEED);
@@ -739,14 +737,19 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
        mButtonsPref.setButton1Text(
                mIsEphemeral ? R.string.wifi_disconnect_button_text : R.string.forget);

        mButtonsPref.setButton1Visible(canForgetNetwork());
        mButtonsPref.setButton2Visible(canSignIntoNetwork());
        mButtonsPref.setButton3Visible(canConnectNetwork());
        mButtonsPref.setButton4Visible(canShareNetwork());
        mButtonsPref.setVisible(canSignIntoNetwork()
                || canForgetNetwork()
                || canShareNetwork()
                || canConnectNetwork());
        boolean canForgetNetwork = canForgetNetwork();
        boolean canSignIntoNetwork = canSignIntoNetwork();
        boolean canConnectNetwork = canConnectNetwork();
        boolean canShareNetwork = canShareNetwork();

        mButtonsPref.setButton1Visible(canForgetNetwork);
        mButtonsPref.setButton2Visible(canSignIntoNetwork);
        mButtonsPref.setButton3Visible(canConnectNetwork);
        mButtonsPref.setButton4Visible(canShareNetwork);
        mButtonsPref.setVisible(canForgetNetwork
                || canSignIntoNetwork
                || canConnectNetwork
                || canShareNetwork);
    }

    private boolean canConnectNetwork() {
@@ -843,7 +846,8 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
     * Returns whether the user can share the network represented by this preference with QR code.
     */
    private boolean canShareNetwork() {
        return mAccessPoint.getConfig() != null;
        return mAccessPoint.getConfig() != null &&
                WifiDppUtils.isSupportConfiguratorQrCodeGenerator(mContext, mAccessPoint);
    }

    /**
+6 −0
Original line number Diff line number Diff line
@@ -345,6 +345,9 @@ public class WifiDppUtils {
     */
    public static boolean isSupportConfiguratorQrCodeScanner(Context context,
            AccessPoint accessPoint) {
        if (accessPoint.isPasspoint()) {
            return false;
        }
        return isSupportWifiDpp(context, accessPoint.getSecurity());
    }

@@ -356,6 +359,9 @@ public class WifiDppUtils {
     */
    public static boolean isSupportConfiguratorQrCodeGenerator(Context context,
            AccessPoint accessPoint) {
        if (accessPoint.isPasspoint()) {
            return false;
        }
        return isSupportZxing(context, accessPoint.getSecurity());
    }