diff options
author | Quang Luong <qal@google.com> | 2019-12-19 17:03:31 -0800 |
---|---|---|
committer | Quang Luong <qal@google.com> | 2019-12-26 09:53:06 -0800 |
commit | 2b1b0b1a60bf206f8d04031ee3cec25b0b7bfa07 (patch) | |
tree | e5f7a58505e4cf821da6bbc04247b7dda4e60f79 /libs | |
parent | 50f5b40b2affd4e41a03bf6d6a06b33453263821 (diff) |
Handle unsaved secure StandardWifiEntry.connect()
Calling StandardWifiEntry.connect() for unsaved secure networks should
result in the listener receiving CONNECT_STATUS_FAILURE_NO_CONFIG. The
client should should then go through the appropriate flow for adding a
new network.
Bug: 70983952
Test: atest StandardWifiEntryTest
Change-Id: Iad6467bd7efa0d2794136d9da29248f279647759
Diffstat (limited to 'libs')
-rw-r--r-- | libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java | 3 | ||||
-rw-r--r-- | libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/StandardWifiEntryTest.java | 16 |
2 files changed, 17 insertions, 2 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java index 4f0ee9fb7..eefae5485 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java @@ -236,8 +236,7 @@ class StandardWifiEntry extends WifiEntry { mWifiManager.connect(connectConfig, new ConnectListener()); } else { // Secure network - // TODO(b/70983952): Add support for unsaved secure networks - // Return bad password failure to prompt user to enter password. + notifyOnConnectResult(WifiEntryCallback.CONNECT_STATUS_FAILURE_NO_CONFIG); } } else { // Saved network diff --git a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/StandardWifiEntryTest.java b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/StandardWifiEntryTest.java index 7b9d100e4..e4ddaa364 100644 --- a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/StandardWifiEntryTest.java +++ b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/StandardWifiEntryTest.java @@ -370,6 +370,22 @@ public class StandardWifiEntryTest { } @Test + public void testConnect_unsavedSecureNetwork_returnsNoConfigFailure() { + final ScanResult secureScan = buildScanResult("ssid", "bssid0", 0, GOOD_RSSI); + secureScan.capabilities = "PSK"; + final StandardWifiEntry entry = new StandardWifiEntry(mTestHandler, + Arrays.asList(secureScan), + mMockWifiManager); + entry.setListener(mMockListener); + + entry.connect(); + mTestLooper.dispatchAll(); + + verify(mMockListener, times(1)) + .onConnectResult(WifiEntry.WifiEntryCallback.CONNECT_STATUS_FAILURE_NO_CONFIG); + } + + @Test public void testGetMacAddress_randomizationOn_usesRandomizedValue() { final String randomizedMac = "01:23:45:67:89:ab"; final WifiConfiguration config = new WifiConfiguration(); |