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
This commit is contained in:
Arc Wang
2019-04-16 16:46:57 +08:00
parent 96b534951c
commit 994929ecc7
2 changed files with 22 additions and 12 deletions

View File

@@ -404,9 +404,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
.setButton3Enabled(true) .setButton3Enabled(true)
.setButton4Text(R.string.share) .setButton4Text(R.string.share)
.setButton4Icon(R.drawable.ic_qrcode_24dp) .setButton4Icon(R.drawable.ic_qrcode_24dp)
.setButton4OnClickListener(view -> shareNetwork()) .setButton4OnClickListener(view -> shareNetwork());
.setButton4Visible(
WifiDppUtils.isSupportConfiguratorQrCodeGenerator(mContext, mAccessPoint));
mSignalStrengthPref = screen.findPreference(KEY_SIGNAL_STRENGTH_PREF); mSignalStrengthPref = screen.findPreference(KEY_SIGNAL_STRENGTH_PREF);
mTxLinkSpeedPref = screen.findPreference(KEY_TX_LINK_SPEED); mTxLinkSpeedPref = screen.findPreference(KEY_TX_LINK_SPEED);
@@ -739,14 +737,19 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
mButtonsPref.setButton1Text( mButtonsPref.setButton1Text(
mIsEphemeral ? R.string.wifi_disconnect_button_text : R.string.forget); mIsEphemeral ? R.string.wifi_disconnect_button_text : R.string.forget);
mButtonsPref.setButton1Visible(canForgetNetwork()); boolean canForgetNetwork = canForgetNetwork();
mButtonsPref.setButton2Visible(canSignIntoNetwork()); boolean canSignIntoNetwork = canSignIntoNetwork();
mButtonsPref.setButton3Visible(canConnectNetwork()); boolean canConnectNetwork = canConnectNetwork();
mButtonsPref.setButton4Visible(canShareNetwork()); boolean canShareNetwork = canShareNetwork();
mButtonsPref.setVisible(canSignIntoNetwork()
|| canForgetNetwork() mButtonsPref.setButton1Visible(canForgetNetwork);
|| canShareNetwork() mButtonsPref.setButton2Visible(canSignIntoNetwork);
|| canConnectNetwork()); mButtonsPref.setButton3Visible(canConnectNetwork);
mButtonsPref.setButton4Visible(canShareNetwork);
mButtonsPref.setVisible(canForgetNetwork
|| canSignIntoNetwork
|| canConnectNetwork
|| canShareNetwork);
} }
private boolean canConnectNetwork() { 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. * Returns whether the user can share the network represented by this preference with QR code.
*/ */
private boolean canShareNetwork() { private boolean canShareNetwork() {
return mAccessPoint.getConfig() != null; return mAccessPoint.getConfig() != null &&
WifiDppUtils.isSupportConfiguratorQrCodeGenerator(mContext, mAccessPoint);
} }
/** /**

View File

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