Loading res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -2291,6 +2291,10 @@ <string name="wifi_dpp_failure_enrollee_rejected_configuration">Contact the device manufacturer</string> <!-- Hint for Wi-Fi connection fail [CHAR LIMIT=NONE] --> <string name="wifi_dpp_check_connection_try_again">Check connection and try again</string> <!-- Hint for Wi-Fi connection fail [CHAR LIMIT=NONE] --> <string name="wifi_dpp_check_connection_no_matched_ssid">This Wi\u2011Fi network isn\u2019t available right now</string> <!-- Hint for Wi-Fi connection fail [CHAR LIMIT=NONE] --> <string name="wifi_dpp_check_connection_no_matched_security">There\u2019s a problem with this QR code. Try connecting another way.</string> <!-- Title for the fragment choose network [CHAR LIMIT=50] --> <string name="wifi_dpp_choose_network">Choose network</string> <!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] --> src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java +19 −8 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.settings.wifi.dpp; import static android.content.res.Resources.ID_NULL; import static android.net.wifi.WifiInfo.sanitizeSsid; import android.app.Activity; Loading Loading @@ -101,6 +102,8 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl // Interval between initiating WifiPickerTracker scans. private static final long SCAN_INTERVAL_MILLIS = 10_000; private static final @StringRes int REACHABLE_WIFI_NETWORK = ID_NULL; private QrCamera mCamera; private TextureView mTextureView; private QrDecorateView mDecorateView; Loading Loading @@ -201,8 +204,9 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl wifiManager.enableNetwork(id, /* attemptConnect */ false); // 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)) { @StringRes int wifiReachabilityStringId = getWifiReachabilityStringId(qrCodeWifiConfiguration); if (wifiReachabilityStringId == REACHABLE_WIFI_NETWORK) { hasHiddenOrReachableWifiNetwork = true; mEnrolleeWifiConfiguration = qrCodeWifiConfiguration; wifiManager.connect(id, Loading @@ -210,8 +214,7 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl } if (!hasHiddenOrReachableWifiNetwork) { showErrorMessageAndRestartCamera( R.string.wifi_dpp_check_connection_try_again); showErrorMessageAndRestartCamera(wifiReachabilityStringId); return; } Loading Loading @@ -242,7 +245,10 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl WifiDppUtils.triggerVibrationForQrCodeRecognition(getContext()); } private boolean isReachableWifiNetwork(WifiConfiguration wifiConfiguration) { private @StringRes int getWifiReachabilityStringId(WifiConfiguration wifiConfiguration) { if (wifiConfiguration.hiddenSSID) { return REACHABLE_WIFI_NETWORK; } final List<WifiEntry> wifiEntries = mWifiPickerTracker.getWifiEntries(); final WifiEntry connectedWifiEntry = mWifiPickerTracker.getConnectedWifiEntry(); if (connectedWifiEntry != null) { Loading @@ -250,24 +256,29 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl wifiEntries.add(connectedWifiEntry); } boolean canFindNetwork = false; for (WifiEntry wifiEntry : wifiEntries) { if (!TextUtils.equals(wifiEntry.getSsid(), sanitizeSsid(wifiConfiguration.SSID))) { continue; } canFindNetwork = true; final int security = WifiDppUtils.getSecurityTypeFromWifiConfiguration(wifiConfiguration); if (security == wifiEntry.getSecurity()) { return true; return REACHABLE_WIFI_NETWORK; } // Default security type of PSK/SAE transition mode WifiEntry is SECURITY_PSK and // there is no way to know if a WifiEntry is of transition mode. Give it a chance. if (security == WifiEntry.SECURITY_SAE && wifiEntry.getSecurity() == WifiEntry.SECURITY_PSK) { return true; return REACHABLE_WIFI_NETWORK; } } return false; if (canFindNetwork) { return R.string.wifi_dpp_check_connection_no_matched_security; } return R.string.wifi_dpp_check_connection_no_matched_ssid; } @VisibleForTesting Loading Loading
res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -2291,6 +2291,10 @@ <string name="wifi_dpp_failure_enrollee_rejected_configuration">Contact the device manufacturer</string> <!-- Hint for Wi-Fi connection fail [CHAR LIMIT=NONE] --> <string name="wifi_dpp_check_connection_try_again">Check connection and try again</string> <!-- Hint for Wi-Fi connection fail [CHAR LIMIT=NONE] --> <string name="wifi_dpp_check_connection_no_matched_ssid">This Wi\u2011Fi network isn\u2019t available right now</string> <!-- Hint for Wi-Fi connection fail [CHAR LIMIT=NONE] --> <string name="wifi_dpp_check_connection_no_matched_security">There\u2019s a problem with this QR code. Try connecting another way.</string> <!-- Title for the fragment choose network [CHAR LIMIT=50] --> <string name="wifi_dpp_choose_network">Choose network</string> <!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] -->
src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java +19 −8 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.settings.wifi.dpp; import static android.content.res.Resources.ID_NULL; import static android.net.wifi.WifiInfo.sanitizeSsid; import android.app.Activity; Loading Loading @@ -101,6 +102,8 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl // Interval between initiating WifiPickerTracker scans. private static final long SCAN_INTERVAL_MILLIS = 10_000; private static final @StringRes int REACHABLE_WIFI_NETWORK = ID_NULL; private QrCamera mCamera; private TextureView mTextureView; private QrDecorateView mDecorateView; Loading Loading @@ -201,8 +204,9 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl wifiManager.enableNetwork(id, /* attemptConnect */ false); // 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)) { @StringRes int wifiReachabilityStringId = getWifiReachabilityStringId(qrCodeWifiConfiguration); if (wifiReachabilityStringId == REACHABLE_WIFI_NETWORK) { hasHiddenOrReachableWifiNetwork = true; mEnrolleeWifiConfiguration = qrCodeWifiConfiguration; wifiManager.connect(id, Loading @@ -210,8 +214,7 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl } if (!hasHiddenOrReachableWifiNetwork) { showErrorMessageAndRestartCamera( R.string.wifi_dpp_check_connection_try_again); showErrorMessageAndRestartCamera(wifiReachabilityStringId); return; } Loading Loading @@ -242,7 +245,10 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl WifiDppUtils.triggerVibrationForQrCodeRecognition(getContext()); } private boolean isReachableWifiNetwork(WifiConfiguration wifiConfiguration) { private @StringRes int getWifiReachabilityStringId(WifiConfiguration wifiConfiguration) { if (wifiConfiguration.hiddenSSID) { return REACHABLE_WIFI_NETWORK; } final List<WifiEntry> wifiEntries = mWifiPickerTracker.getWifiEntries(); final WifiEntry connectedWifiEntry = mWifiPickerTracker.getConnectedWifiEntry(); if (connectedWifiEntry != null) { Loading @@ -250,24 +256,29 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl wifiEntries.add(connectedWifiEntry); } boolean canFindNetwork = false; for (WifiEntry wifiEntry : wifiEntries) { if (!TextUtils.equals(wifiEntry.getSsid(), sanitizeSsid(wifiConfiguration.SSID))) { continue; } canFindNetwork = true; final int security = WifiDppUtils.getSecurityTypeFromWifiConfiguration(wifiConfiguration); if (security == wifiEntry.getSecurity()) { return true; return REACHABLE_WIFI_NETWORK; } // Default security type of PSK/SAE transition mode WifiEntry is SECURITY_PSK and // there is no way to know if a WifiEntry is of transition mode. Give it a chance. if (security == WifiEntry.SECURITY_SAE && wifiEntry.getSecurity() == WifiEntry.SECURITY_PSK) { return true; return REACHABLE_WIFI_NETWORK; } } return false; if (canFindNetwork) { return R.string.wifi_dpp_check_connection_no_matched_security; } return R.string.wifi_dpp_check_connection_no_matched_ssid; } @VisibleForTesting Loading