[Wi-Fi] Support hidden SSID Wi-Fi networks for Wi-Fi QR code scanner & generator

WifiTracker#getAccessPoints() only contains a hidden SSID Wi-Fi
network if it's a saved Wi-Fi network. We can't check if a hidden
SSID Wi-Fi network is reachable inadvance. That is the difference
after a user scanned a QR code of hidden SSID Wi-Fi network.

Bug: 135892509
Test: make RunSettingsRoboTests ROBOTEST_FILTER=WifiDppUtilsTest
      manual test:
      Click the Share button of a connected hidden SSID Wi-Fi network
      and save the QR code image. Use Wi-Fi QR code scanner in Wi-Fi
      Settings to scan the saved QR code image.

Change-Id: I9056622e6dadb04e5642ae1c50fb4d227a78d26d
This commit is contained in:
Arc Wang
2019-08-16 22:30:43 +08:00
parent 6ef36e9c34
commit 03f1ee1b50
5 changed files with 93 additions and 6 deletions

View File

@@ -167,22 +167,25 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
// Adds all Wi-Fi networks in QR code to the set of configured networks and
// connects to it if it's reachable.
boolean hasReachableWifiNetwork = false;
boolean hasHiddenOrReachableWifiNetwork = false;
for (WifiConfiguration qrCodeWifiConfiguration : qrCodeWifiConfigurations) {
final int id = wifiManager.addNetwork(qrCodeWifiConfiguration);
if (id == -1) {
continue;
}
wifiManager.enableNetwork(id, /* attemptConnect */ false);
if (isReachableWifiNetwork(qrCodeWifiConfiguration)) {
hasReachableWifiNetwork = true;
// WifiTracker only contains a hidden SSID Wi-Fi network if it's saved.
// We can't check if a hidden SSID Wi-Fi network is reachable in advance.
if (qrCodeWifiConfiguration.hiddenSSID ||
isReachableWifiNetwork(qrCodeWifiConfiguration)) {
hasHiddenOrReachableWifiNetwork = true;
mEnrolleeWifiConfiguration = qrCodeWifiConfiguration;
wifiManager.connect(id,
/* listener */ WifiDppQrCodeScannerFragment.this);
}
}
if (hasReachableWifiNetwork == false) {
if (!hasHiddenOrReachableWifiNetwork) {
showErrorMessageAndRestartCamera(
R.string.wifi_dpp_check_connection_try_again);
return;