From 1f926f05fb2f5a78e1a0888df2a99d23b003c2a7 Mon Sep 17 00:00:00 2001 From: Patches Date: Sun, 19 Aug 2018 17:21:00 -0500 Subject: [PATCH] 3.x Rewrite --- .github/CODEOWNERS | 1 + .gitignore | 2 - .travis.yml | 6 +- CHANGE.md | 2 + README.md | 64 +- build.gradle | 79 +- .../proguard-test-rules.txt => changes/3.x.md | 0 config/checkstyle/import-control.xml | 31 + config/detekt-config.yml | 349 +++ documentation/adding_and_removing_networks.md | 155 +- documentation/checking_device_connectivity.md | 62 +- ...necting_and_disconnecting_from_networks.md | 81 +- documentation/current_network.md | 81 +- documentation/enabling_and_disabling_wifi.md | 78 +- documentation/frequency.md | 94 +- documentation/ip.md | 58 + documentation/nearby_access_points.md | 186 +- documentation/network_security.md | 60 +- documentation/permissions_example.md | 182 +- documentation/rssi.md | 57 +- documentation/saved_networks.md | 127 +- gradle.properties | 8 +- gradle/checkstyle.gradle | 29 + gradle/code-coverage.gradle | 35 + gradle/cpd.gradle | 22 + gradle/custom-tasks.gradle | 22 + gradle/detekt.gradle | 14 + gradle/dexcount.gradle | 10 + gradle/dokka.gradle | 6 + gradle/findbugs.gradle | 26 + gradle/gradle-bintray-install.gradle | 2 - gradle/gradle-bintray-upload.gradle | 17 +- gradle/jacoco.gradle | 178 +- gradle/ktlint.gradle | 8 + gradle/pmd.gradle | 15 + gradle/static-analysis.gradle | 55 + gradle/wrapper/gradle-wrapper.jar | Bin 54783 -> 54333 bytes gradle/wrapper/gradle-wrapper.properties | 3 +- gradlew | 6 +- javadoc/allclasses-frame.html | 53 - javadoc/allclasses-noframe.html | 53 - .../com/isupatches/wisefy/WiseFy.brains.html | 321 --- javadoc/com/isupatches/wisefy/WiseFy.html | 2091 ---------------- .../isupatches/wisefy/WiseFy.withContext.html | 320 --- .../isupatches/wisefy/WiseFyApplication.html | 350 --- .../isupatches/wisefy/annotations/Async.html | 165 -- .../wisefy/annotations/CallingThread.html | 165 -- .../wisefy/annotations/Internal.html | 164 -- .../wisefy/annotations/PublicAPI.html | 164 -- .../isupatches/wisefy/annotations/Sync.html | 165 -- .../wisefy/annotations/WaitsForTimeout.html | 165 -- .../wisefy/annotations/WiseFyThread.html | 165 -- .../wisefy/annotations/package-frame.html | 26 - .../wisefy/annotations/package-summary.html | 164 -- .../wisefy/annotations/package-tree.html | 137 - .../callbacks/AddOpenNetworkCallbacks.html | 245 -- .../callbacks/AddWEPNetworkCallbacks.html | 245 -- .../callbacks/AddWPA2NetworkCallbacks.html | 245 -- .../callbacks/ConnectToNetworkCallbacks.html | 258 -- .../callbacks/DisableWifiCallbacks.html | 245 -- ...DisconnectFromCurrentNetworkCallbacks.html | 245 -- .../wisefy/callbacks/EnableWifiCallbacks.html | 245 -- .../callbacks/GetCurrentNetworkCallbacks.html | 232 -- .../callbacks/GetFrequencyCallbacks.html | 245 -- .../GetNearbyAccessPointsCallbacks.html | 232 -- .../wisefy/callbacks/GetRSSICallbacks.html | 245 -- .../callbacks/GetSavedNetworkCallbacks.html | 245 -- .../callbacks/GetSavedNetworksCallbacks.html | 245 -- .../callbacks/RemoveNetworkCallbacks.html | 258 -- .../SearchForAccessPointCallbacks.html | 245 -- .../SearchForAccessPointsCallbacks.html | 245 -- .../callbacks/SearchForSSIDCallbacks.html | 245 -- .../callbacks/SearchForSSIDsCallbacks.html | 245 -- .../wisefy/callbacks/package-frame.html | 37 - .../wisefy/callbacks/package-summary.html | 208 -- .../wisefy/callbacks/package-tree.html | 148 -- .../wisefy/constants/Capabilities.html | 343 --- .../wisefy/constants/NetworkTypes.html | 292 --- .../wisefy/constants/WiseFyCodes.html | 309 --- .../wisefy/constants/package-frame.html | 22 - .../wisefy/constants/package-summary.html | 148 -- .../wisefy/constants/package-tree.html | 137 - .../com/isupatches/wisefy/package-frame.html | 21 - .../isupatches/wisefy/package-summary.html | 151 -- .../com/isupatches/wisefy/package-tree.html | 136 - .../wisefy/threads/WiseFyHandlerThread.html | 398 --- .../wisefy/threads/package-frame.html | 20 - .../wisefy/threads/package-summary.html | 144 -- .../wisefy/threads/package-tree.html | 143 -- .../wisefy/util/GetManagerUtil.html | 289 --- .../com/isupatches/wisefy/util/LogUtil.html | 288 --- .../isupatches/wisefy/util/ManagerUtil.html | 289 --- .../com/isupatches/wisefy/util/SSIDUtil.html | 197 -- .../com/isupatches/wisefy/util/SleepUtil.html | 278 --- .../wisefy/util/WifiConfigurationUtil.html | 313 --- .../isupatches/wisefy/util/package-frame.html | 23 - .../wisefy/util/package-summary.html | 160 -- .../isupatches/wisefy/util/package-tree.html | 138 -- javadoc/constant-values.html | 273 -- javadoc/deprecated-list.html | 122 - javadoc/help-doc.html | 223 -- javadoc/index-all.html | 788 ------ javadoc/index.html | 74 - javadoc/overview-frame.html | 26 - javadoc/overview-summary.html | 156 -- javadoc/overview-tree.html | 188 -- javadoc/script.js | 30 - javadoc/style.css | 283 +++ javadoc/stylesheet.css | 574 ----- javadoc/wisefy/alltypes/index.html | 191 ++ .../failure-adding-network.html | 23 + .../-add-network-callbacks/index.html | 62 + .../-add-network-callbacks/network-added.html | 22 + .../-base-callback/index.html | 201 ++ .../-base-callback/wisefy-failure.html | 25 + .../connected-to-network.html | 19 + .../failure-connecting-to-network.html | 23 + .../-connect-to-network-callbacks/index.html | 70 + .../network-not-found-to-connect-to.html | 23 + .../failure-disabling-wifi.html | 19 + .../-disable-wifi-callbacks/index.html | 60 + .../wifi-disabled.html | 19 + .../disconnected-from-current-network.html | 19 + ...re-disconnecting-from-current-network.html | 19 + .../index.html | 60 + .../failure-enabling-wifi.html | 19 + .../-enable-wifi-callbacks/index.html | 60 + .../-enable-wifi-callbacks/wifi-enabled.html | 19 + .../-get-current-network-callbacks/index.html | 51 + .../retrieved-current-network.html | 22 + .../index.html | 51 + .../retrieved-current-network-info.html | 22 + .../failure-getting-frequency.html | 20 + .../-get-frequency-callbacks/index.html | 60 + .../retrieved-frequency.html | 19 + .../failure-retrieving-i-p.html | 20 + .../-get-i-p-callbacks/index.html | 60 + .../-get-i-p-callbacks/retrieved-i-p.html | 19 + .../index.html | 51 + .../retrieved-nearby-access-points.html | 22 + .../-get-r-s-s-i-callbacks/index.html | 61 + ...network-not-found-to-retrieve-r-s-s-i.html | 20 + .../retrieved-r-s-s-i.html | 19 + .../-get-saved-network-callbacks/index.html | 58 + .../retrieved-saved-network.html | 22 + .../saved-network-not-found.html | 19 + .../-get-saved-networks-callbacks/index.html | 60 + .../no-saved-networks-found.html | 19 + .../retrieved-saved-networks.html | 22 + .../failure-removing-network.html | 19 + .../-remove-network-callbacks/index.html | 70 + .../network-not-found-to-remove.html | 21 + .../network-removed.html | 20 + .../access-point-found.html | 22 + .../access-point-not-found.html | 19 + .../index.html | 60 + .../found-access-points.html | 22 + .../index.html | 58 + .../no-access-points-found.html | 19 + .../-search-for-s-s-i-d-callbacks/index.html | 60 + .../ssid-found.html | 19 + .../ssid-not-found.html | 19 + .../-search-for-s-s-i-ds-callbacks/index.html | 60 + .../no-s-s-i-ds-found.html | 19 + .../retrieved-s-s-i-ds.html | 19 + .../index.html | 189 ++ .../-capability/-init-.html | 19 + .../-capability/index.html | 32 + ...p-r-e-c-h-e-c-k_-r-e-t-u-r-n_-c-o-d-e.html | 19 + .../-e-a-p.html | 19 + .../-m-i-s-s-i-n-g_-p-a-r-a-m-e-t-e-r.html | 19 + .../-m-o-b-i-l-e.html | 19 + ...k_-a-l-r-e-a-d-y_-c-o-n-f-i-g-u-r-e-d.html | 19 + .../-network-type/-init-.html | 19 + .../-network-type/index.html | 32 + .../-p-s-k.html | 19 + .../-w-e-p.html | 19 + .../-w-i-f-i.html | 19 + .../-w-p-a.html | 19 + .../-w-p-a2.html | 19 + .../-wise-fy-code/-init-.html | 19 + .../-wise-fy-code/index.html | 32 + .../index.html | 139 ++ .../-wise-fy-handler-thread/-init-.html | 20 + .../-wise-fy-handler-thread/index.html | 33 + .../com.isupatches.wisefy.threads/index.html | 26 + .../com.isupatches.wisefy/-wise-fy-lock.html | 21 + .../-wise-fy/-brains/-init-.html | 19 + .../-wise-fy/-brains/get-smarts.html | 22 + .../-wise-fy/-brains/index.html | 55 + .../-wise-fy/-brains/logging.html | 22 + .../-m-a-x_-f-r-e-q-u-e-n-c-y_5-g-h-z.html | 19 + .../-m-i-n_-f-r-e-q-u-e-n-c-y_5-g-h-z.html | 19 + ...w-i-f-i_-m-a-n-a-g-e-r_-f-a-i-l-u-r-e.html | 22 + .../-wise-fy/add-open-network.html | 49 + .../-wise-fy/add-w-e-p-network.html | 53 + .../-wise-fy/add-w-p-a2-network.html | 53 + .../-wise-fy/calculate-bars.html | 29 + .../-wise-fy/compare-signal-level.html | 34 + .../-wise-fy/connect-to-network.html | 57 + .../-wise-fy/disable-wifi.html | 42 + .../disconnect-from-current-network.html | 41 + .../com.isupatches.wisefy/-wise-fy/dump.html | 23 + .../-wise-fy/enable-wifi.html | 42 + .../-wise-fy/get-current-network-info.html | 44 + .../-wise-fy/get-current-network.html | 50 + .../-wise-fy/get-frequency.html | 81 + .../-wise-fy/get-i-p.html | 46 + .../-wise-fy/get-nearby-access-points.html | 58 + .../-wise-fy/get-r-s-s-i.html | 59 + .../-wise-fy/get-saved-network.html | 49 + .../-wise-fy/get-saved-networks.html | 81 + .../-wise-fy/get-wise-fy-lock.html | 24 + .../com.isupatches.wisefy/-wise-fy/index.html | 449 ++++ ...is-device-connected-to-mobile-network.html | 27 + ...e-connected-to-mobile-or-wifi-network.html | 26 + .../is-device-connected-to-s-s-i-d.html | 28 + .../is-device-connected-to-wifi-network.html | 27 + .../-wise-fy/is-device-roaming.html | 26 + .../-wise-fy/is-logging-enabled.html | 24 + .../-wise-fy/is-network-e-a-p.html | 29 + .../-wise-fy/is-network-p-s-k.html | 29 + .../-wise-fy/is-network-saved.html | 28 + .../-wise-fy/is-network-secure.html | 32 + .../-wise-fy/is-network-w-e-p.html | 29 + .../-wise-fy/is-network-w-p-a.html | 29 + .../-wise-fy/is-network-w-p-a2.html | 29 + .../-wise-fy/is-network5g-hz.html | 47 + .../-wise-fy/is-wifi-enabled.html | 25 + .../-wise-fy/remove-network.html | 53 + .../-wise-fy/search-for-access-point.html | 59 + .../-wise-fy/search-for-access-points.html | 55 + .../-wise-fy/search-for-s-s-i-d.html | 53 + .../-wise-fy/search-for-s-s-i-ds.html | 47 + .../wisefy/com.isupatches.wisefy/index.html | 36 + javadoc/wisefy/index-outline.html | 913 +++++++ javadoc/wisefy/index.html | 46 + javadoc/{ => wisefy}/package-list | 5 +- wisefy/build.gradle | 99 +- .../checkstyle/checkstyle-suppressions.xml | 11 + wisefy/config/checkstyle/checkstyle.xml | 421 ++++ .../config/findbugs/findbugs-suppressions.xml | 7 + wisefy/consumer-proguard-rules.pro | 6 + wisefy/proguard-rules.pro | 9 + wisefy/proguard-rules.txt | 17 - wisefy/proguard-test-rules.pro | 0 .../wisefy/AddOpenNetworkTests.java | 152 -- .../isupatches/wisefy/AddWEPNetworkTests.java | 177 -- .../wisefy/AddWPA2NetworkTests.java | 176 -- .../wisefy/BaseAndroidJUnit4TestClass.java | 70 - .../wisefy/BaseAndroidJUnit4TestClass.kt | 82 + .../wisefy/ConnectToNetworkTests.java | 218 -- .../isupatches/wisefy/DisableWifiTests.java | 99 - .../DisconnectFromCurrentNetworkTests.java | 98 - .../isupatches/wisefy/EnableWifiTests.java | 99 - .../com/isupatches/wisefy/GeneratorUtil.kt | 88 + .../wisefy/GetCurrentNetworkTests.java | 82 - .../isupatches/wisefy/GetFrequencyTests.java | 153 -- .../wisefy/GetNearbyAccessPointsTests.java | 205 -- .../com/isupatches/wisefy/GetRSSITests.java | 259 -- .../wisefy/GetSavedNetworkTests.java | 139 -- .../wisefy/GetSavedNetworksTests.java | 250 -- ...IsDeviceConnectedToMobileNetworkTests.java | 41 - ...ceConnectedToMobileOrWifiNetworkTests.java | 40 - .../wisefy/IsDeviceConnectedToSSIDTests.java | 43 - .../IsDeviceConnectedToWifiNetworkTests.java | 41 - .../wisefy/IsDeviceRoamingTests.java | 41 - .../isupatches/wisefy/IsNetwork5gHzTests.java | 97 - .../isupatches/wisefy/IsNetworkEAPTests.java | 44 - .../IsNetworkInConfigurationListTests.java | 94 - .../isupatches/wisefy/IsNetworkPSKTest.java | 44 - .../wisefy/IsNetworkSecureTests.java | 72 - .../isupatches/wisefy/IsNetworkWPA2Test.java | 44 - .../isupatches/wisefy/IsNetworkWPATests.java | 44 - .../isupatches/wisefy/IsNetworkWepTests.java | 44 - .../isupatches/wisefy/IsWifiEnabledTests.java | 28 - .../isupatches/wisefy/ManagerUtilTest.java | 37 - .../com/isupatches/wisefy/MockNetworkUtil.kt | 426 ++++ .../wisefy/MockWiseFyConnectionUtil.kt | 63 + .../wisefy/MockWiseFyPrechecksUtil.kt | 335 +++ .../isupatches/wisefy/MockWiseFySearchUtil.kt | 150 ++ .../com/isupatches/wisefy/NullCallbackUtil.kt | 329 +++ .../isupatches/wisefy/RemoveNetworkTests.java | 205 -- .../wisefy/SearchForAccessPointTests.java | 268 -- .../wisefy/SearchForAccessPointsTests.java | 281 --- .../isupatches/wisefy/SearchForSSIDTests.java | 145 -- .../wisefy/SearchForSSIDsTests.java | 141 -- .../com/isupatches/wisefy/VerificationUtil.kt | 206 ++ .../wisefy/WiseFyConnectionTests.java | 360 --- .../wisefy/WiseFyConnectionTests.kt | 190 ++ .../isupatches/wisefy/WiseFyPrechecksTests.kt | 183 ++ .../wisefy/WiseFyPrerequisitesTests.java | 49 - .../isupatches/wisefy/WiseFySearchTests.java | 857 ------- .../isupatches/wisefy/WiseFySearchTests.kt | 525 ++++ .../com/isupatches/wisefy/WiseFyTests.java | 48 - .../com/isupatches/wisefy/base/TestUtils.java | 40 - .../wisefy/main/AddOpenNetworkTests.kt | 90 + .../wisefy/main/AddWEPNetworkTests.kt | 91 + .../wisefy/main/AddWPA2NetworkTests.kt | 91 + .../wisefy/main/ConnectToNetworkTests.kt | 119 + .../wisefy/main/DisableWifiTests.kt | 87 + .../main/DisconnectFromCurrentNetworkTests.kt | 87 + .../isupatches/wisefy/main/EnableWifiTests.kt | 87 + .../wisefy/main/GetCurrentNetworkInfoTest.kt | 73 + .../wisefy/main/GetCurrentNetworkTests.kt | 69 + .../wisefy/main/GetFrequencyTests.kt | 165 ++ .../com/isupatches/wisefy/main/GetIIPTests.kt | 60 + .../wisefy/main/GetNearbyAccessPointsTests.kt | 107 + .../isupatches/wisefy/main/GetRSSITests.kt | 149 ++ .../wisefy/main/GetSavedNetworkTests.kt | 77 + .../wisefy/main/GetSavedNetworksTests.kt | 162 ++ .../IsDeviceConnectedToMobileNetworkTests.kt | 32 + ...viceConnectedToMobileOrWifiNetworkTests.kt | 32 + .../main/IsDeviceConnectedToSSIDTests.kt | 32 + .../IsDeviceConnectedToWifiNetworkTests.kt | 32 + .../wisefy/main/IsDeviceRoamingTests.kt | 37 + .../wisefy/main/IsNetwork5gHzTests.kt | 92 + .../wisefy/main/IsNetworkEAPTests.kt | 40 + .../wisefy/main/IsNetworkPSKTest.kt | 40 + .../wisefy/main/IsNetworkSavedTests.kt | 32 + .../wisefy/main/IsNetworkSecureTests.kt | 64 + .../wisefy/main/IsNetworkWPA2Test.kt | 40 + .../wisefy/main/IsNetworkWPATests.kt | 40 + .../wisefy/main/IsNetworkWepTests.kt | 40 + .../wisefy/main/IsWifiEnabledTests.kt | 30 + .../wisefy/main/RemoveNetworkTests.kt | 115 + .../wisefy/main/SearchForAccessPointTests.kt | 135 + .../wisefy/main/SearchForAccessPointsTests.kt | 135 + .../wisefy/main/SearchForSSIDTests.kt | 79 + .../wisefy/main/SearchForSSIDsTests.kt | 78 + .../isupatches/wisefy/test/BuilderTests.java | 23 - .../com/isupatches/wisefy/test/WiseFyTests.kt | 57 + .../java/com/isupatches/wisefy/TestUtils.kt | 69 + wisefy/src/main/AndroidManifest.xml | 13 +- .../java/com/isupatches/wisefy/WiseFy.java | 2018 --------------- .../main/java/com/isupatches/wisefy/WiseFy.kt | 2199 +++++++++++++++++ .../wisefy/WiseFyConfiguration.java | 66 - .../isupatches/wisefy/WiseFyConnection.java | 164 -- .../com/isupatches/wisefy/WiseFyConnection.kt | 193 ++ .../NetworkTypes.java => WiseFyLock.kt} | 18 +- .../com/isupatches/wisefy/WiseFyPrechecks.kt | 615 +++++ .../wisefy/WiseFyPrerequisites.java | 119 - .../com/isupatches/wisefy/WiseFySearch.java | 348 --- .../com/isupatches/wisefy/WiseFySearch.kt | 431 ++++ .../com/isupatches/wisefy/WisePublicApi.kt | 313 +++ .../Async.kt} | 24 +- .../CallingThread.kt} | 24 +- .../{Internal.java => PublicAPI.kt} | 25 +- .../annotations/{PublicAPI.java => Sync.kt} | 26 +- .../wisefy/annotations/WaitsForTimeout.java | 34 - .../wisefy/annotations/WaitsForTimeout.kt | 30 + .../wisefy/annotations/WiseFyThread.java | 33 - .../{Sync.java => WiseFyThread.kt} | 31 +- .../wisefy/callbacks/AddNetworkCallbacks.kt | 53 + .../callbacks/AddWPA2NetworkCallbacks.java | 26 - .../wisefy/callbacks/BaseCallback.kt | 42 + .../callbacks/ConnectToNetworkCallbacks.java | 24 - .../callbacks/ConnectToNetworkCallbacks.kt | 57 + .../callbacks/DisableWifiCallbacks.java | 23 - .../wisefy/callbacks/DisableWifiCallbacks.kt | 44 + ...DisconnectFromCurrentNetworkCallbacks.java | 23 - .../DisconnectFromCurrentNetworkCallbacks.kt | 44 + .../wisefy/callbacks/EnableWifiCallbacks.java | 23 - .../wisefy/callbacks/EnableWifiCallbacks.kt | 44 + .../callbacks/GetCurrentNetworkCallbacks.java | 25 - .../GetCurrentNetworkCallbacks.kt} | 32 +- .../GetCurrentNetworkInfoCallbacks.kt | 40 + .../callbacks/GetFrequencyCallbacks.java | 23 - .../wisefy/callbacks/GetFrequencyCallbacks.kt | 46 + .../wisefy/callbacks/GetIPCallbacks.kt | 46 + .../GetNearbyAccessPointsCallbacks.java | 26 - .../GetNearbyAccessPointsCallbacks.kt | 40 + .../wisefy/callbacks/GetRSSICallbacks.java | 23 - .../wisefy/callbacks/GetRSSICallbacks.kt | 45 + .../callbacks/GetSavedNetworkCallbacks.java | 26 - .../callbacks/GetSavedNetworkCallbacks.kt | 48 + .../callbacks/GetSavedNetworksCallbacks.java | 27 - .../callbacks/GetSavedNetworksCallbacks.kt | 48 + .../callbacks/RemoveNetworkCallbacks.java | 24 - .../callbacks/RemoveNetworkCallbacks.kt | 56 + .../SearchForAccessPointCallbacks.java | 26 - .../SearchForAccessPointCallbacks.kt | 48 + .../SearchForAccessPointsCallbacks.java | 27 - .../SearchForAccessPointsCallbacks.kt | 48 + .../callbacks/SearchForSSIDCallbacks.java | 23 - .../callbacks/SearchForSSIDCallbacks.kt | 44 + .../callbacks/SearchForSSIDsCallbacks.java | 26 - .../callbacks/SearchForSSIDsCallbacks.kt | 44 + .../wisefy/constants/Capabilities.java | 25 - .../wisefy/constants/Capabilities.kt | 69 + .../wisefy/constants/NetworkTypes.kt | 45 + .../{WiseFyLock.java => constants/Symbols.kt} | 15 +- .../wisefy/constants/WiseFyCodes.java | 23 - .../wisefy/constants/WiseFyCodes.kt | 57 + .../isupatches/wisefy/logging/WiseFyLogger.kt | 150 ++ .../logging/WiseFyLoggerImplementation.kt | 147 ++ .../wisefy/logging/WiseFyLoggingStrategy.kt | 33 + .../wisefy/threads/WiseFyHandlerThread.java | 66 - .../WiseFyHandlerThread.kt} | 31 +- .../com/isupatches/wisefy/util/LogUtil.java | 54 - .../isupatches/wisefy/util/ManagerUtil.java | 79 - .../com/isupatches/wisefy/util/SSIDUtil.java | 63 - .../wisefy/util/WifiConfigurationUtil.java | 121 - .../com/isupatches/wisefy/utils/SleepUtil.kt | 47 + .../StringUtil.kt} | 32 +- .../wisefy/utils/WifiConfigurationUtil.kt | 112 + wisefy/src/main/res/values/colors.xml | 3 - wisefy/src/main/res/values/strings.xml | 3 - .../wisefy/main/PublicApiVisibilityTests.kt | 553 +++++ .../wisefy/test/PublicApiVisibilityTests.java | 616 ----- 410 files changed, 20303 insertions(+), 26158 deletions(-) create mode 100644 .github/CODEOWNERS rename wisefy/proguard-test-rules.txt => changes/3.x.md (100%) create mode 100644 config/checkstyle/import-control.xml create mode 100644 config/detekt-config.yml create mode 100644 documentation/ip.md create mode 100644 gradle/checkstyle.gradle create mode 100644 gradle/code-coverage.gradle create mode 100644 gradle/cpd.gradle create mode 100644 gradle/custom-tasks.gradle create mode 100644 gradle/detekt.gradle create mode 100644 gradle/dexcount.gradle create mode 100644 gradle/dokka.gradle create mode 100644 gradle/findbugs.gradle create mode 100644 gradle/ktlint.gradle create mode 100644 gradle/pmd.gradle create mode 100644 gradle/static-analysis.gradle delete mode 100644 javadoc/allclasses-frame.html delete mode 100644 javadoc/allclasses-noframe.html delete mode 100644 javadoc/com/isupatches/wisefy/WiseFy.brains.html delete mode 100644 javadoc/com/isupatches/wisefy/WiseFy.html delete mode 100644 javadoc/com/isupatches/wisefy/WiseFy.withContext.html delete mode 100644 javadoc/com/isupatches/wisefy/WiseFyApplication.html delete mode 100644 javadoc/com/isupatches/wisefy/annotations/Async.html delete mode 100644 javadoc/com/isupatches/wisefy/annotations/CallingThread.html delete mode 100644 javadoc/com/isupatches/wisefy/annotations/Internal.html delete mode 100644 javadoc/com/isupatches/wisefy/annotations/PublicAPI.html delete mode 100644 javadoc/com/isupatches/wisefy/annotations/Sync.html delete mode 100644 javadoc/com/isupatches/wisefy/annotations/WaitsForTimeout.html delete mode 100644 javadoc/com/isupatches/wisefy/annotations/WiseFyThread.html delete mode 100644 javadoc/com/isupatches/wisefy/annotations/package-frame.html delete mode 100644 javadoc/com/isupatches/wisefy/annotations/package-summary.html delete mode 100644 javadoc/com/isupatches/wisefy/annotations/package-tree.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/AddOpenNetworkCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/AddWEPNetworkCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/AddWPA2NetworkCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/GetRSSICallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/package-frame.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/package-summary.html delete mode 100644 javadoc/com/isupatches/wisefy/callbacks/package-tree.html delete mode 100644 javadoc/com/isupatches/wisefy/constants/Capabilities.html delete mode 100644 javadoc/com/isupatches/wisefy/constants/NetworkTypes.html delete mode 100644 javadoc/com/isupatches/wisefy/constants/WiseFyCodes.html delete mode 100644 javadoc/com/isupatches/wisefy/constants/package-frame.html delete mode 100644 javadoc/com/isupatches/wisefy/constants/package-summary.html delete mode 100644 javadoc/com/isupatches/wisefy/constants/package-tree.html delete mode 100644 javadoc/com/isupatches/wisefy/package-frame.html delete mode 100644 javadoc/com/isupatches/wisefy/package-summary.html delete mode 100644 javadoc/com/isupatches/wisefy/package-tree.html delete mode 100644 javadoc/com/isupatches/wisefy/threads/WiseFyHandlerThread.html delete mode 100644 javadoc/com/isupatches/wisefy/threads/package-frame.html delete mode 100644 javadoc/com/isupatches/wisefy/threads/package-summary.html delete mode 100644 javadoc/com/isupatches/wisefy/threads/package-tree.html delete mode 100644 javadoc/com/isupatches/wisefy/util/GetManagerUtil.html delete mode 100644 javadoc/com/isupatches/wisefy/util/LogUtil.html delete mode 100644 javadoc/com/isupatches/wisefy/util/ManagerUtil.html delete mode 100644 javadoc/com/isupatches/wisefy/util/SSIDUtil.html delete mode 100644 javadoc/com/isupatches/wisefy/util/SleepUtil.html delete mode 100644 javadoc/com/isupatches/wisefy/util/WifiConfigurationUtil.html delete mode 100644 javadoc/com/isupatches/wisefy/util/package-frame.html delete mode 100644 javadoc/com/isupatches/wisefy/util/package-summary.html delete mode 100644 javadoc/com/isupatches/wisefy/util/package-tree.html delete mode 100644 javadoc/constant-values.html delete mode 100644 javadoc/deprecated-list.html delete mode 100644 javadoc/help-doc.html delete mode 100644 javadoc/index-all.html delete mode 100644 javadoc/index.html delete mode 100644 javadoc/overview-frame.html delete mode 100644 javadoc/overview-summary.html delete mode 100644 javadoc/overview-tree.html delete mode 100644 javadoc/script.js create mode 100644 javadoc/style.css delete mode 100644 javadoc/stylesheet.css create mode 100644 javadoc/wisefy/alltypes/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/failure-adding-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/network-added.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-base-callback/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-base-callback/wisefy-failure.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/connected-to-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/failure-connecting-to-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/network-not-found-to-connect-to.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/failure-disabling-wifi.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/wifi-disabled.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/disconnected-from-current-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/failure-disconnecting-from-current-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/failure-enabling-wifi.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/wifi-enabled.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-callbacks/retrieved-current-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-info-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-info-callbacks/retrieved-current-network-info.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/failure-getting-frequency.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/retrieved-frequency.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/failure-retrieving-i-p.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/retrieved-i-p.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-nearby-access-points-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-nearby-access-points-callbacks/retrieved-nearby-access-points.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/network-not-found-to-retrieve-r-s-s-i.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/retrieved-r-s-s-i.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/retrieved-saved-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/saved-network-not-found.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/no-saved-networks-found.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/retrieved-saved-networks.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/failure-removing-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/network-not-found-to-remove.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/network-removed.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/access-point-found.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/access-point-not-found.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/found-access-points.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/no-access-points-found.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/ssid-found.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/ssid-not-found.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/no-s-s-i-ds-found.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/retrieved-s-s-i-ds.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.callbacks/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-capability/-init-.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-capability/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-d-e-f-a-u-l-t_-p-r-e-c-h-e-c-k_-r-e-t-u-r-n_-c-o-d-e.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-e-a-p.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-m-i-s-s-i-n-g_-p-a-r-a-m-e-t-e-r.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-m-o-b-i-l-e.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-n-e-t-w-o-r-k_-a-l-r-e-a-d-y_-c-o-n-f-i-g-u-r-e-d.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-network-type/-init-.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-network-type/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-p-s-k.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-w-e-p.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-w-i-f-i.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-w-p-a.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-w-p-a2.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-wise-fy-code/-init-.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/-wise-fy-code/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.constants/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.threads/-wise-fy-handler-thread/-init-.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.threads/-wise-fy-handler-thread/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy.threads/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy-lock.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/-init-.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/get-smarts.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/logging.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-m-a-x_-f-r-e-q-u-e-n-c-y_5-g-h-z.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-m-i-n_-f-r-e-q-u-e-n-c-y_5-g-h-z.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-w-i-f-i_-m-a-n-a-g-e-r_-f-a-i-l-u-r-e.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-open-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-w-e-p-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-w-p-a2-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/calculate-bars.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/compare-signal-level.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/connect-to-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/disable-wifi.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/disconnect-from-current-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/dump.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/enable-wifi.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-current-network-info.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-current-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-frequency.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-i-p.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-nearby-access-points.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-r-s-s-i.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-saved-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-saved-networks.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-wise-fy-lock.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/index.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-mobile-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-mobile-or-wifi-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-s-s-i-d.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-wifi-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-roaming.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-logging-enabled.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-e-a-p.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-p-s-k.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-saved.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-secure.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-e-p.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-p-a.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-p-a2.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network5g-hz.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-wifi-enabled.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/remove-network.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-access-point.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-access-points.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-s-s-i-d.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-s-s-i-ds.html create mode 100644 javadoc/wisefy/com.isupatches.wisefy/index.html create mode 100644 javadoc/wisefy/index-outline.html create mode 100644 javadoc/wisefy/index.html rename javadoc/{ => wisefy}/package-list (65%) create mode 100644 wisefy/config/checkstyle/checkstyle-suppressions.xml create mode 100644 wisefy/config/checkstyle/checkstyle.xml create mode 100644 wisefy/config/findbugs/findbugs-suppressions.xml create mode 100644 wisefy/consumer-proguard-rules.pro create mode 100644 wisefy/proguard-rules.pro delete mode 100644 wisefy/proguard-rules.txt create mode 100644 wisefy/proguard-test-rules.pro delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.java create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.kt delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/GeneratorUtil.kt delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/MockNetworkUtil.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFyConnectionUtil.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFyPrechecksUtil.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFySearchUtil.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/NullCallbackUtil.kt delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/VerificationUtil.kt delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrechecksTests.kt delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.kt delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/base/TestUtils.java create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddOpenNetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddWEPNetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddWPA2NetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/ConnectToNetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/DisableWifiTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/DisconnectFromCurrentNetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/EnableWifiTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetCurrentNetworkInfoTest.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetCurrentNetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetFrequencyTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetIIPTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetNearbyAccessPointsTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetRSSITests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetSavedNetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetSavedNetworksTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToMobileNetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToMobileOrWifiNetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToSSIDTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToWifiNetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceRoamingTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetwork5gHzTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkEAPTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkPSKTest.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkSavedTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkSecureTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWPA2Test.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWPATests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWepTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsWifiEnabledTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/RemoveNetworkTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForAccessPointTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForAccessPointsTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForSSIDTests.kt create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForSSIDsTests.kt delete mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java create mode 100644 wisefy/src/androidTest/java/com/isupatches/wisefy/test/WiseFyTests.kt create mode 100644 wisefy/src/commonTest/java/com/isupatches/wisefy/TestUtils.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/WiseFy.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/WiseFy.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/WiseFyConfiguration.java delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/WiseFyConnection.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/WiseFyConnection.kt rename wisefy/src/main/java/com/isupatches/wisefy/{constants/NetworkTypes.java => WiseFyLock.kt} (71%) create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrechecks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrerequisites.java delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/WiseFySearch.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/WiseFySearch.kt create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/WisePublicApi.kt rename wisefy/src/main/java/com/isupatches/wisefy/{callbacks/AddWEPNetworkCallbacks.java => annotations/Async.kt} (61%) rename wisefy/src/main/java/com/isupatches/wisefy/{callbacks/AddOpenNetworkCallbacks.java => annotations/CallingThread.kt} (60%) rename wisefy/src/main/java/com/isupatches/wisefy/annotations/{Internal.java => PublicAPI.kt} (63%) rename wisefy/src/main/java/com/isupatches/wisefy/annotations/{PublicAPI.java => Sync.kt} (63%) delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/annotations/WaitsForTimeout.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/annotations/WaitsForTimeout.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/annotations/WiseFyThread.java rename wisefy/src/main/java/com/isupatches/wisefy/annotations/{Sync.java => WiseFyThread.kt} (57%) create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddNetworkCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddWPA2NetworkCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/BaseCallback.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.java rename wisefy/src/main/java/com/isupatches/wisefy/{util/SleepUtil.java => callbacks/GetCurrentNetworkCallbacks.kt} (53%) create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkInfoCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.kt create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetIPCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.kt create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.kt rename wisefy/src/main/java/com/isupatches/wisefy/{WiseFyLock.java => constants/Symbols.kt} (75%) delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.kt create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLogger.kt create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLoggerImplementation.kt create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLoggingStrategy.kt delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/threads/WiseFyHandlerThread.java rename wisefy/src/main/java/com/isupatches/wisefy/{annotations/Async.java => threads/WiseFyHandlerThread.kt} (56%) delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/util/LogUtil.java delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/util/ManagerUtil.java delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/util/SSIDUtil.java delete mode 100644 wisefy/src/main/java/com/isupatches/wisefy/util/WifiConfigurationUtil.java create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/utils/SleepUtil.kt rename wisefy/src/main/java/com/isupatches/wisefy/{annotations/CallingThread.java => utils/StringUtil.kt} (54%) create mode 100644 wisefy/src/main/java/com/isupatches/wisefy/utils/WifiConfigurationUtil.kt delete mode 100644 wisefy/src/main/res/values/colors.xml delete mode 100644 wisefy/src/main/res/values/strings.xml create mode 100644 wisefy/src/test/java/com/isupatches/wisefy/main/PublicApiVisibilityTests.kt delete mode 100644 wisefy/src/test/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..ac908a3e --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @isuPatches \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5f940083..ecf627d0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,4 @@ .gradle /local.properties /.idea -.DS_Store /build -/captures diff --git a/.travis.yml b/.travis.yml index a1bdc9ba..a67e4dd1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ jdk: env: global: - - TARGET_SDK=26 - - BUILD_TOOLS_VERSION=26.0.0 + - TARGET_SDK=27 + - BUILD_TOOLS_VERSION=27.0.3 matrix: - EMULATOR_SDK=android-19 ABI=armeabi-v7a - EMULATOR_SDK=android-22 ABI=armeabi-v7a @@ -32,7 +32,7 @@ before_script: - adb shell input keyevent 82 & script: - - travis_wait 60 ./gradlew jacocoDebugTestReport + - travis_wait 60 ./gradlew makeGoodChoices after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/CHANGE.md b/CHANGE.md index c816ad8a..d180b35a 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -5,3 +5,5 @@ WiseFy upon each new major release will start a brand new change log. [1.x Changes](/changes/1.x.md) [2.x Changes](/changes/2.x.md) + +[3.x Changes](/changes/3.x.md) \ No newline at end of file diff --git a/README.md b/README.md index 766927c9..04d8eeca 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,35 @@ Wifi configuration and util library built for Android. >
*Developed by Patches 04/24/2016 - present*
> ->
Supports Android SDK levels 16-26

+>
Supports Android SDK levels 16-27

-[![Build Status](https://travis-ci.org/isuPatches/WiseFy.svg?branch=master)](https://travis-ci.org/isuPatches/WiseFy) [ ![Download](https://api.bintray.com/packages/isupatches/Maven/wisefy/images/download.svg) ](https://bintray.com/isupatches/Maven/wisefy/_latestVersion) [![codecov](https://codecov.io/gh/isuPatches/WiseFy/branch/2.x/graph/badge.svg)](https://codecov.io/gh/isuPatches/WiseFy) +[![Build Status](https://travis-ci.org/isuPatches/WiseFy.svg?branch=master)](https://travis-ci.org/isuPatches/WiseFy) [ ![Download](https://api.bintray.com/packages/isupatches/Maven/wisefy/images/download.svg) ](https://bintray.com/isupatches/Maven/wisefy/_latestVersion) [![codecov](https://codecov.io/gh/isuPatches/WiseFy/branch/3.x/graph/badge.svg)](https://codecov.io/gh/isuPatches/WiseFy) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-WiseFy-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6011) [![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23230-blue.svg)](http://androidweekly.net/issues/issue-230) -## What's New in 2.x +## What's New in 3.x + +- Rewritten in Kotlin + - Static analysis tools added +- Ability to get the IP of a device +- Additional details in callbacks for adding a network: + - The new id of the network + - The WifiConfiguration of the network that was added +- isNetworkInConfigurationList renamed isNetworkSaved +- brains renamed Brains +- Nullability issues will be more visible +- Definitions for NetworkTypes and WiseFyCodes +- Immutability throughout the library +- Improved architecture +- Updated dependencies +- Updated to Gradle 4.x and AGP 3.x +- Target now is set to API 27 +- Less duplicate code +- Improved testing +- Updated documentation with new Kotlin examples +- Other improvements and adjustments! + +## What's New in 2.0.x - Asynchronous API - Certain methods have callbacks and are run on a WiseFy specific background thread @@ -62,7 +84,7 @@ For Maven: com.isupatches wisefy - + LATEST_VERSION pom ``` @@ -73,16 +95,34 @@ You may also download the @aar from the + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/detekt-config.yml b/config/detekt-config.yml new file mode 100644 index 00000000..b1ffb2f4 --- /dev/null +++ b/config/detekt-config.yml @@ -0,0 +1,349 @@ +autoCorrect: true +failFast: false + +test-pattern: # Configure exclusions for test sources + active: true + patterns: # Test file regular expressions + - '.*Spec.kt' + +build: + maxIssues: 1 + weights: + complexity: 2 + formatting: 1 + LongParameterList: 1 + comments: 1 + +processors: + active: true + exclude: + # - 'FunctionCountProcessor' + # - 'PropertyCountProcessor' + # - 'ClassCountProcessor' + # - 'PackageCountProcessor' + # - 'KtFileCountProcessor' + +console-reports: + active: true + exclude: + # - 'ProjectStatisticsReport' + # - 'ComplexityReport' + # - 'NotificationReport' + # - 'FindingsReport' + # - 'BuildFailureReport' + +output-reports: + active: true + exclude: + # - 'PlainOutputReport' + # - 'XmlOutputReport' + +comments: + active: true + CommentOverPrivateFunction: + active: false # Disabled because comments for some private functions can be valuable + CommentOverPrivateProperty: + active: false # Disabled because comments for some properties can be valuable + UndocumentedPublicClass: + active: true + searchInNestedClass: true + searchInInnerClass: true + searchInInnerObject: true + searchInInnerInterface: true + UndocumentedPublicFunction: + active: true + +complexity: + active: true + LongParameterList: + active: true + threshold: 5 + ignoreDefaultParameters: false + LongMethod: + active: true + threshold: 20 + LargeClass: + active: true + threshold: 150 + ComplexInterface: + active: true + threshold: 50 + includeStaticDeclarations: true + ComplexMethod: + active: true + threshold: 20 + StringLiteralDuplication: + active: true + threshold: 2 + ignoreAnnotation: true + excludeStringsWithLessThan5Characters: true + ignoreStringsRegex: '$^' + MethodOverloading: + active: true + threshold: 5 + NestedBlockDepth: + active: true + threshold: 5 + TooManyFunctions: + active: true + thresholdInFiles: 50 + thresholdInClasses: 75 # Increased from 50 + thresholdInInterfaces: 75 # Increased from 50 + thresholdInObjects: 20 + thresholdInEnums: 10 + ComplexCondition: + active: true + threshold: 3 + LabeledExpression: + active: false # Disabled since they can be required when the code is not complex + +empty-blocks: + active: true + EmptyCatchBlock: + active: true + EmptyClassBlock: + active: true + EmptyDefaultConstructor: + active: true + EmptyDoWhileBlock: + active: true + EmptyElseBlock: + active: true + EmptyFinallyBlock: + active: true + EmptyForBlock: + active: true + EmptyFunctionBlock: + active: true + EmptyIfBlock: + active: true + EmptyInitBlock: + active: true + EmptyKtFile: + active: true + EmptySecondaryConstructor: + active: true + EmptyWhenBlock: + active: true + EmptyWhileBlock: + active: true + +exceptions: + active: true + TooGenericExceptionCaught: + active: true + exceptions: + - ArrayIndexOutOfBoundsException + - Error + - Exception + - IllegalMonitorStateException + - NullPointerException + - IndexOutOfBoundsException + - RuntimeException + - Throwable + ExceptionRaisedInUnexpectedLocation: + active: true + methodNames: 'toString,hashCode,equals,finalize' + TooGenericExceptionThrown: + active: true + exceptions: + - Error + - Exception + - NullPointerException + - Throwable + - RuntimeException + NotImplementedDeclaration: + active: true + PrintStackTrace: + active: true + InstanceOfCheckForException: + active: true + ThrowingExceptionsWithoutMessageOrCause: + active: true + exceptions: 'IllegalArgumentException,IllegalStateException,IOException' + ReturnFromFinally: + active: true + ThrowingExceptionFromFinally: + active: true + ThrowingExceptionInMain: + active: true + RethrowCaughtException: + active: true + ThrowingNewInstanceOfSameException: + active: true + SwallowedException: + active: true + +performance: + active: true + ForEachOnRange: + active: true + SpreadOperator: + active: true + UnnecessaryTemporaryInstantiation: + active: true + +potential-bugs: + active: true + DuplicateCaseInWhenExpression: + active: true + EqualsAlwaysReturnsTrueOrFalse: + active: true + EqualsWithHashCodeExist: + active: true + IteratorNotThrowingNoSuchElementException: + active: true + IteratorHasNextCallsNextMethod: + active: true + UselessPostfixExpression: + active: true + InvalidRange: + active: true + WrongEqualsTypeParameter: + active: true + ExplicitGarbageCollectionCall: + active: true + LateinitUsage: + active: false # Disabled because lateinit usage is fine with `init` blocks and dagger + excludeAnnotatedProperties: "" + ignoreOnClassesPattern: "" + UnconditionalJumpStatementInLoop: + active: true + UnreachableCode: + active: true + UnsafeCallOnNullableType: + active: false # Disabled because with a null check in prechecks, !! is acceptable + UnsafeCast: + active: false # Disabled because there are cases where casting should not fail and `as` would be more appropriate + +style: + active: true + CollapsibleIfStatements: + active: true + ReturnCount: + active: true + max: 4 + excludedFunctions: "equals" + ThrowsCount: + active: true + max: 2 + NewLineAtEndOfFile: + active: true + WildcardImport: + active: true + excludeImports: 'java.util.*,kotlinx.android.synthetic.*' + MaxLineLength: + active: true + maxLineLength: 150 + excludePackageStatements: false + excludeImportStatements: false + EqualsNullCall: + active: true + ForbiddenComment: + active: true + values: 'TODO:,FIXME:,STOPSHIP:' + ForbiddenImport: + active: true + imports: '' + FunctionOnlyReturningConstant: + active: true + ignoreOverridableFunction: true + excludedFunctions: 'describeContents' + SpacingBetweenPackageAndImports: + active: true + LoopWithTooManyJumpStatements: + active: true + maxJumpCount: 3 # Increased from 1 + MemberNameEqualsClassName: + active: true + ignoreOverriddenFunction: true + VariableNaming: + active: true + variablePattern: '[a-z][A-Za-z0-9]*' + privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' + VariableMinLength: + active: true + minimumVariableNameLength: 1 + VariableMaxLength: + active: true + maximumVariableNameLength: 64 + TopLevelPropertyNaming: + active: true + constantPattern: '[A-Z][_A-Z0-9]*' + propertyPattern: '[a-z][A-Za-z\d]*' + privatePropertyPattern: '(_)?[a-z][A-Za-z0-9]*' + ObjectPropertyNaming: + active: true + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' + PackageNaming: + active: true + packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$' + ClassNaming: + active: true + classPattern: '[A-Z$][a-zA-Z0-9$]*' + EnumNaming: + active: true + enumEntryPattern: '^[A-Z$][a-zA-Z_$]*$' + FunctionNaming: + active: true + functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$' + FunctionMaxLength: + active: true + maximumFunctionNameLength: 30 + FunctionMinLength: + active: true + minimumFunctionNameLength: 3 + ForbiddenClassName: + active: true + forbiddenName: '' + SafeCast: + active: true + UnnecessaryAbstractClass: + active: true + UnnecessaryParentheses: + active: true + UnnecessaryInheritance: + active: true + UtilityClassWithPublicConstructor: + active: true + OptionalAbstractKeyword: + active: true + OptionalWhenBraces: + active: false # Disabled because braces can sometimes make parts of when more readable + OptionalReturnKeyword: + active: true + OptionalUnit: + active: true + ProtectedMemberInFinalClass: + active: true + SerialVersionUIDInSerializableClass: + active: true + MagicNumber: + active: true + ignoreNumbers: '-1,0,1,2' + ignoreHashCodeFunction: false + ignorePropertyDeclaration: false + ignoreConstantDeclaration: true + ignoreCompanionObjectPropertyDeclaration: true + ignoreAnnotation: false + ignoreNamedArgument: false + ignoreEnums: false + ModifierOrder: + active: true + DataClassContainsFunctions: + active: true + conversionFunctionPrefix: 'to' + UseDataClass: + active: true + UnusedImports: + active: true + ExpressionBodySyntax: + active: true + NestedClassesVisibility: + active: true + RedundantVisibilityModifierRule: + active: true + MatchingDeclarationName: + active: true + UntilInsteadOfRangeTo: + active: true \ No newline at end of file diff --git a/documentation/adding_and_removing_networks.md b/documentation/adding_and_removing_networks.md index 92bbd2de..0454d896 100644 --- a/documentation/adding_and_removing_networks.md +++ b/documentation/adding_and_removing_networks.md @@ -2,46 +2,98 @@ To add an open network: +_With Kotlin_ + +```kotlin +val result = wisefy.addOpenNetwork("Open Network") +``` + +_With Java_ + ```java -int addedSuccessfully = mWiseFy.addOpenNetwork("Open Network"); +int result = wisefy.addOpenNetwork("Open Network"); ``` To add a WEP network: +_With Kotlin_ + +```kotlin +val result = wisefy.addWEPNetwork("WEP Network", "123456") +``` + +_With Java_ + ```java -int addedSuccessfully = mWiseFy.addWEPNetwork("WEP Network", "123456"); +int result = wisefy.addWEPNetwork("WEP Network", "123456"); ``` To add a WPA2 network: +_With Kotlin_ + +```kotlin +val result = wisefy.addWEPNetwork("WPA2 Network", "123456") +``` + +_With Java_ + ```java -int addedSuccessfully = mWiseFy.addWPA2Network("WPA2 Network", "12345678"); +int result = wisefy.addWPA2Network("WPA2 Network", "12345678"); ``` To remove a configured network: +_With Kotlin_ + +```kotlin +val removedSuccessfully = wisefy.removeNetwork("SSID to remove"); +``` + +_With Java_ + ```java -boolean removedSuccessfully = mWiseFy.removeNetwork("SSID to remove"); +boolean removedSuccessfully = wisefy.removeNetwork("SSID to remove"); ``` #### Via The Asynchronous API To add an open network: +_With Kotlin_ + +```kotlin +wisefy.addOpenNetwork("Open Network", object: AddNetworkCallbacks { + override fun failureAddingNetwork(wifiManagerReturn: Int) { + + } + + override fun networkAdded(newNetworkId: Int, networkConfig: WifiConfiguration) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.addOpenNetwork("Open Network", new AddOpenNetworkCallbacks() { +wisefy.addOpenNetwork("Open Network", new AddNetworkCallbacks() { @Override - public void addOpenNetworkWiseFyFailure(Integer wisefyReturnCode) { + public void failureAddingNetwork(int i) { } @Override - public void failureAddingOpenNetwork(Integer wifiManagerReturnCode) { + public void networkAdded(int i, WifiConfiguration wifiConfiguration) { } @Override - public void openNetworkAdded(WifiConfiguration openNetwork) { + public void wisefyFailure(int i) { } }); @@ -49,20 +101,40 @@ mWiseFy.addOpenNetwork("Open Network", new AddOpenNetworkCallbacks() { To add a WEP network: +_With Kotlin_ + +```Kotlin +wisefy.addWEPNetwork("WEP Network", "123456", object: AddNetworkCallbacks { + override fun failureAddingNetwork(wifiManagerReturn: Int) { + + } + + override fun networkAdded(newNetworkId: Int, networkConfig: WifiConfiguration) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.addWEPNetwork("WEP Network", "123456", new AddWEPNetworkCallbacks() { +wisefy.addWEPNetwork("WEP Network", "123456", new AddNetworkCallbacks() { @Override - public void addWEPNetworkWiseFyFailure(Integer wisefyReturnCode) { + public void failureAddingNetwork(int i) { } @Override - public void failureAddingWEPNetwork(Integer wifiManagerReturnCode) { + public void networkAdded(int i, WifiConfiguration wifiConfiguration) { } @Override - public void wepNetworkAdded(WifiConfiguration wepNetwork) { + public void wisefyFailure(int i) { } }); @@ -70,20 +142,40 @@ mWiseFy.addWEPNetwork("WEP Network", "123456", new AddWEPNetworkCallbacks() { To add a WPA2 network: +_With Kotlin_ + +```kotlin +wisefy.addWPA2Network("WPA2 Network", "12345678", object: AddNetworkCallbacks { + override fun failureAddingNetwork(wifiManagerReturn: Int) { + + } + + override fun networkAdded(newNetworkId: Int, networkConfig: WifiConfiguration) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.addWPA2Network("WPA2 Network", "12345678", new AddWPA2NetworkCallbacks() { +wisefy.addWPA2Network("WPA2 Network", "12345678", new AddNetworkCallbacks() { @Override - public void addWPA2NetworkWiseFyFailure(Integer wisefyReturnCode) { + public void failureAddingNetwork(int i) { } @Override - public void failureAddingWPA2Network(Integer wifiManagerReturnCode) { + public void networkAdded(int i, WifiConfiguration wifiConfiguration) { } @Override - public void wpa2NetworkAdded(WifiConfiguration wpa2Network) { + public void wisefyFailure(int i) { } }); @@ -91,8 +183,32 @@ mWiseFy.addWPA2Network("WPA2 Network", "12345678", new AddWPA2NetworkCallbacks() To remove a configured network: +_With Kotlin_ + +```kotlin +wisefy.removeNetwork("SSID to remove", object: RemoveNetworkCallbacks { + override fun failureRemovingNetwork() { + + } + + override fun networkNotFoundToRemove() { + + } + + override fun networkRemoved() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.removeNetwork("SSID to remove", new RemoveNetworkCallbacks() { +wisefy.removeNetwork("SSID to remove", new RemoveNetworkCallbacks() { @Override public void failureRemovingNetwork() { @@ -109,7 +225,7 @@ mWiseFy.removeNetwork("SSID to remove", new RemoveNetworkCallbacks() { } @Override - public void removeNetworkWiseFyFailure(Integer wisefyReturnCode) { + public void wisefyFailure(int i) { } }); @@ -118,5 +234,4 @@ mWiseFy.removeNetwork("SSID to remove", new RemoveNetworkCallbacks() { ***Notes*** - Will return a WiseFy error code if network is already a saved configuration -- Will return a WiseFy error code if parameter is missing -- Will return a WiseFy error code if the instance has a missing prerequisite \ No newline at end of file +- Will return a WiseFy error code if parameter is missing \ No newline at end of file diff --git a/documentation/checking_device_connectivity.md b/documentation/checking_device_connectivity.md index de282a43..3deaf7d8 100644 --- a/documentation/checking_device_connectivity.md +++ b/documentation/checking_device_connectivity.md @@ -2,36 +2,84 @@ To check and see if the device is connected to a mobile network: +_With Kotlin_ + +```Kotlin +val isConnected = wisefy.isDeviceConnectedToMobileNetwork(); +``` + +_With Java_ + ```java -boolean isConnected = mWiseFy.isDeviceConnectedToMobileNetwork(); +boolean isConnected = wisefy.isDeviceConnectedToMobileNetwork(); ``` To check and see if the device is connected to a mobile or wifi network: +_With Kotlin_ + +```kotlin +val isConnected = wisefy.isDeviceConnectedToMobileOrWifiNetwork(); +``` + +_With Java_ + ```java -boolean isConnected = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(); +boolean isConnected = wisefy.isDeviceConnectedToMobileOrWifiNetwork(); ``` To check and see if the device is connected to a given SSID: +_With Kotlin_ + +```kotlin +val isConnected = wisefy.isDeviceConnectedToSSID("SSID"); +``` + +_With Java_ + ```java -boolean isConnected = mWiseFy.isDeviceConnectedToSSID("SSID"); +boolean isConnected = wisefy.isDeviceConnectedToSSID("SSID"); ``` To check and see if the device is connected to a wifi network: +_With Kotlin_ + +```kotlin +val isConnected = wisefy.isDeviceConnectedToWifiNetwork(); +``` + +_With Java_ + ```java -boolean isConnected = mWiseFy.isDeviceConnectedToWifiNetwork(); +boolean isConnected = wisefy.isDeviceConnectedToWifiNetwork(); ``` To check and see if the device is roaming: +_With Kotlin_ + +```kotlin +val isDeviceRoaming = wisefy.isDeviceRoaming(); +``` + +_With Java_ + ```java -mWiseFy.isDeviceRoaming(); +boolean isDeviceRoaming = wisefy.isDeviceRoaming(); ``` To check and see if Wifi is enabled on a device: +_With Kotlin_ + +```kotlin +boolean wifiEnabled = wisefy.isWifiEnabled(); +``` + +_With Java_ + ```java -boolean wifiEnabled = mWiseFy.isWifiEnabled(); -``` \ No newline at end of file +boolean wifiEnabled = wisefy.isWifiEnabled(); +``` diff --git a/documentation/connecting_and_disconnecting_from_networks.md b/documentation/connecting_and_disconnecting_from_networks.md index 81bfe652..c02bce83 100644 --- a/documentation/connecting_and_disconnecting_from_networks.md +++ b/documentation/connecting_and_disconnecting_from_networks.md @@ -2,39 +2,79 @@ To connect to a network given an SSID: +_With Kotlin_ + +```kotlin +val connectedSuccessfully = wisefy.connectToNetwork("SSID to connect to", 3000); +``` + +_With Java_ + ```java -boolean connectedSuccessfully = mWiseFy.connectToNetwork("SSID to connect to", 30000); +boolean connectedSuccessfully = wisefy.connectToNetwork("SSID to connect to", 3000); ``` To disconnect from current network: +_With Kotlin_ + +```kotlin +val disconnectedSuccessfully = wisefy.disconnectFromCurrentNetwork(); +``` + +_With Java_ + ```java -boolean disconnectedSuccessfully = mWiseFy.disconnectFromCurrentNetwork(); +boolean disconnectedSuccessfully = wisefy.disconnectFromCurrentNetwork(); ``` #### Via The Asynchronous API To connect to a network given an SSID: +_With Kotlin_ + +```kotlin +wisefy.connectToNetwork("SSID to connect to", 3000, object: ConnectToNetworkCallbacks { + override fun connectedToNetwork() { + + } + + override fun failureConnectingToNetwork() { + + } + + override fun networkNotFoundToConnectTo() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.connectToNetwork("SSID to connect to", 30000, new ConnectToNetworkCallbacks() { +wisefy.connectToNetwork("SSID to connect to", 3000, new ConnectToNetworkCallbacks() { @Override public void connectedToNetwork() { } @Override - public void connectToNetworkWiseFyFailure(Integer wisefyReturnCode) { + public void failureConnectingToNetwork() { } @Override - public void failureConnectingToNetwork() { + public void networkNotFoundToConnectTo() { } @Override - public void networkNotFoundToConnectTo() { + public void wisefyFailure(int i) { } }); @@ -42,20 +82,40 @@ mWiseFy.connectToNetwork("SSID to connect to", 30000, new ConnectToNetworkCallba To disconnect from current network: +_With Kotlin_ + +```Kotlin +wisefy.disconnectFromCurrentNetwork(object: DisconnectFromCurrentNetworkCallbacks { + override fun disconnectedFromCurrentNetwork() { + + } + + override fun failureDisconnectingFromCurrentNetwork() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.disconnectFromCurrentNetwork(new DisconnectFromCurrentNetworkCallbacks() { +wisefy.disconnectFromCurrentNetwork(new DisconnectFromCurrentNetworkCallbacks() { @Override public void disconnectedFromCurrentNetwork() { } @Override - public void disconnectFromCurrentNetworkWiseFyFailure(Integer wisefyReturnCode) { + public void failureDisconnectingFromCurrentNetwork() { } @Override - public void failureDisconnectingFromCurrentNetwork() { + public void wisefyFailure(int i) { } }); @@ -63,5 +123,4 @@ mWiseFy.disconnectFromCurrentNetwork(new DisconnectFromCurrentNetworkCallbacks() ***Notes*** -- Will return a WiseFy error code if parameter is missing -- Will return a WiseFy error code if the instance has a missing prerequisite \ No newline at end of file +- Will return a WiseFy error code if parameter is missing \ No newline at end of file diff --git a/documentation/current_network.md b/documentation/current_network.md index 19833bfc..e23296a7 100644 --- a/documentation/current_network.md +++ b/documentation/current_network.md @@ -2,23 +2,93 @@ To get current network: +_With Kotlin_ + +```Kotlin +val currentNetwork = wisefy.getCurrentNetwork() +``` + +_With Java_ + ```java -WifiInfo currentNetwork = mWiseFy.getCurrentNetwork(); +WifiInfo currentNetwork = wisefy.getCurrentNetwork(); +``` + +To get current network info: + +_With Kotlin_ + +```kotlin +val currentNetworkInfo = wisefy.getCurrentNetworkInfo() +``` + +_With Java_ + +```java +NetworkInfo currentNetworkInfo = wisefy.getCurrentNetworkInfo(); ``` #### Via The Asynchronous API To get current network: +_With Kotlin_ + +```kotlin +wisefy.getCurrentNetwork(object: GetCurrentNetworkCallbacks { + override fun retrievedCurrentNetwork(currentNetwork: WifiInfo) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + +```java +wisefy.getCurrentNetwork(new GetCurrentNetworkCallbacks() { + @Override + public void retrievedCurrentNetwork(WifiInfo wifiInfo) { + + } + + @Override + public void wisefyFailure(int i) { + + } +}); +``` + +To get current network info: + +_With Kotlin_ + +```kotlin +wisefy.getCurrentNetworkInfo(object: GetCurrentNetworkInfoCallbacks { + override fun retrievedCurrentNetworkInfo(currentNetworkDetails: NetworkInfo) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.getCurrentNetwork(new GetCurrentNetworkCallbacks() { +wisefy.getCurrentNetworkInfo(new GetCurrentNetworkInfoCallbacks() { @Override - public void getCurrentNetworkWiseFyFailure(Integer wisefyReturnCode) { + public void retrievedCurrentNetworkInfo(NetworkInfo networkInfo) { } @Override - public void retrievedCurrentNetwork(WifiInfo currentNetwork) { + public void wisefyFailure(int i) { } }); @@ -26,5 +96,4 @@ mWiseFy.getCurrentNetwork(new GetCurrentNetworkCallbacks() { ***Notes*** -- Will return a WiseFy error code if parameter is missing -- Will return a WiseFy error code if the instance has a missing prerequisite \ No newline at end of file +- Will return a WiseFy error code if parameter is missing \ No newline at end of file diff --git a/documentation/enabling_and_disabling_wifi.md b/documentation/enabling_and_disabling_wifi.md index aae3b432..3867d37b 100644 --- a/documentation/enabling_and_disabling_wifi.md +++ b/documentation/enabling_and_disabling_wifi.md @@ -2,27 +2,58 @@ To disable wifi: +_With Kotlin_ + +```kotlin +val disabledWifiSuccessfully = wisefy.disableWifi() +``` + +_With Java_ + ```java -boolean disabledWifiSuccessfully = mWiseFy.disableWifi(); +boolean disabledWifiSuccessfully = wisefy.disableWifi(); ``` To enable wifi: +_With Kotlin_ + +```kotlin +val enabledWifiSuccessfully = wisefy.enableWiFi() +``` + +_With Java_ + ```java -boolean wifiEnabled = mWiseFy.enableWiFi(); +boolean enabledWifiSuccessfully = wisefy.enableWiFi(); ``` #### Via The Asynchronous API To disable wifi: -```java -mWiseFy.disableWifi(new DisableWifiCallbacks() { - @Override - public void disableWifiWiseFyFailure(Integer wisefyReturnCode) { +_With Kotlin_ + +```kotlin +wisefy.disableWifi(object : DisableWifiCallbacks { + override fun failureDisablingWifi() { + + } + + override fun wifiDisabled() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { } +}) +``` +_With Java_ + +```java +wisefy.disableWifi(new DisableWifiCallbacks() { @Override public void failureDisablingWifi() { @@ -32,18 +63,37 @@ mWiseFy.disableWifi(new DisableWifiCallbacks() { public void wifiDisabled() { } + + @Override + public void wisefyFailure(int i) { + + } }); ``` To enable wifi: -```java -mWiseFy.enableWifi(new EnableWifiCallbacks() { - @Override - public void enableWifiWiseFyFailure(Integer wisefyReturnCode) { +_With Kotlin_ + +```kotlin +wisefy.enableWifi(object: EnableWifiCallbacks { + override fun failureEnablingWifi() { + + } + + override fun wifiEnabled() { } + override fun wisefyFailure(wisefyFailureCode: Int) { + } +}) +``` + +_With Java_ + +```java +wisefy.enableWifi(new EnableWifiCallbacks() { @Override public void failureEnablingWifi() { @@ -53,10 +103,14 @@ mWiseFy.enableWifi(new EnableWifiCallbacks() { public void wifiEnabled() { } + + @Override + public void wisefyFailure(int i) { + + } }); ``` ***Notes*** -- Will return a WiseFy error code if parameter is missing -- Will return a WiseFy error code if the instance has a missing prerequisite \ No newline at end of file +- Will return a WiseFy error code if parameter is missing \ No newline at end of file diff --git a/documentation/frequency.md b/documentation/frequency.md index 445e578d..b2d59d65 100644 --- a/documentation/frequency.md +++ b/documentation/frequency.md @@ -3,29 +3,61 @@ To get the frequency of the devices current network:

* NOTE * Only supported on API >= 21 +_With Kotlin_ + +```kotlin +val frequency = wisefy.getFrequency() +``` + +_With Java_ + ```java -int frequency = mWiseFy.getFrequency(); +int frequency = wisefy.getFrequency(); ``` To get the frequency of a network:

* NOTE * Only supported on API >= 21 +_With Kotlin_ + +```kotlin +val frequency = wisefy.getFrequency(wifiInfo) +``` + +_With Java_ + ```java -int frequency = mWiseFy.getFrequency(wifiInfo); +int frequency = wisefy.getFrequency(wifiInfo); ``` To check if the device's current network is 5gHz:

* NOTE * Only supported on API >= 21 +_With Kotlin_ + +```kotlin +val is5gHz = wisefy.isNetwork5gHz() +``` + +_With Java_ + ```java -boolean is5gHz = mWiseFy.isNetwork5gHz(); +boolean is5gHz = wisefy.isNetwork5gHz(); ``` To check if a network is 5gHz:

* NOTE * Only supported on API >= 21 +_With Kotlin_ + +```kotlin +val is5gHz = wisefy.isNetwork5gHz(wifiInfo) +``` + +_With Java_ + ```java -boolean is5gHz = mWiseFy.isNetwork5gHz(wifiInfo); +boolean is5gHz = wisefy.isNetwork5gHz(wifiInfo); ``` #### Via The Asynchronous API @@ -33,20 +65,40 @@ boolean is5gHz = mWiseFy.isNetwork5gHz(wifiInfo); To get the frequency of the devices current network:

* NOTE * Only supported on API >= 21 +_With Kotlin_ + +```kotlin +wisefy.getFrequency(object: GetFrequencyCallbacks { + override fun failureGettingFrequency() { + + } + + override fun retrievedFrequency(frequency: Int) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.getFrequency(new GetFrequencyCallbacks() { +wisefy.getFrequency(new GetFrequencyCallbacks() { @Override public void failureGettingFrequency() { } @Override - public void getFrequencyWiseFyFailure(Integer wisefyReturnCode) { + public void retrievedFrequency(int i) { } @Override - public void retrievedFrequency(int frequency) { + public void wisefyFailure(int i) { } }); @@ -55,21 +107,41 @@ mWiseFy.getFrequency(new GetFrequencyCallbacks() { To get the frequency of a network:

* NOTE * Only supported on API >= 21 +_With Kotlin_ + +```kotlin +wisefy.getFrequency(wifiInfo, object: GetFrequencyCallbacks { + override fun failureGettingFrequency() { + + } + + override fun retrievedFrequency(frequency: Int) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.getFrequency(wifiInfo, new GetFrequencyCallbacks() { +wisefy.getFrequency(wifiInfo, new GetFrequencyCallbacks() { @Override public void failureGettingFrequency() { } @Override - public void getFrequencyWiseFyFailure(Integer wisefyReturnCode) { + public void retrievedFrequency(int i) { } @Override - public void retrievedFrequency(int frequency) { - + public void wisefyFailure(int i) { + } }); ``` \ No newline at end of file diff --git a/documentation/ip.md b/documentation/ip.md new file mode 100644 index 00000000..1f10dd45 --- /dev/null +++ b/documentation/ip.md @@ -0,0 +1,58 @@ +#### Via The Synchronous API + +To get the device's current IP: + +_With Kotlin_ + +```kotlin +val ip = wisefy.getIP() +``` + +_With Java_ + +```java +String ip = wisefy.getIP(); +``` + +#### Via The Asynchronous API + +To get the device's current IP: + +_With Kotlin_ + +```kotlin +wisefy.getIP(object: GetIPCallbacks { + override fun failureRetrievingIP() { + + } + + override fun retrievedIP(ip: String) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + +```java +wisefy.getIP(new GetIPCallbacks() { + @Override + public void failureRetrievingIP() { + + } + + @Override + public void retrievedIP(String s) { + + } + + @Override + public void wisefyFailure(int i) { + + } +}); +``` \ No newline at end of file diff --git a/documentation/nearby_access_points.md b/documentation/nearby_access_points.md index 784f430c..ad21e12d 100644 --- a/documentation/nearby_access_points.md +++ b/documentation/nearby_access_points.md @@ -3,34 +3,74 @@ To get nearby access points:

Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI (will always take the highest signal strength) +_With Kotlin_ + +```kotlin +val nearbyAccessPoints = wisefy.getNearbyAccessPoints(true) +``` + +_With Java_ + ```java -List nearbyAccessPoints = mWiseFy.getNearbyAccessPoints(true); +List nearbyAccessPoints = wisefy.getNearbyAccessPoints(true); ``` To search for an access point given a regex (will return first match):

Setting filterDuplicates to true will return the access point with the highest RSSI for the given SSID +_With Kotlin_ + +```kotlin +val wisefy.searchForAccessPoint("regex for SSID", 3000, true); +``` + +_With Java_ + ```java -mWiseFy.searchForAccessPoint("regex for SSID", 3000, true); +wisefy.searchForAccessPoint("regex for SSID", 3000, true); ``` To search for all access points matching a given regex:

Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI (will always take the highest signal strength) +_With Kotlin_ + +```kotlin +val wisefy.searchForAccessPoints("regex for SSID", true) +``` + +_With Java_ + ```java -mWiseFy.searchForAccessPoints("regex for SSID", true); +wisefy.searchForAccessPoints("regex for SSID", true); ``` To search for an SSID given a regex (will return first match): +_With Kotlin_ + +```kotlin +val ssid = wisefy.searchForSSID("regex for SSID", 3000) +``` + +_With Java_ + ```java -String ssid = mWiseFy.searchForSSID("regex for SSID", 3000); +String ssid = wisefy.searchForSSID("regex for SSID", 3000); ``` To search for all SSIDs matching a given regex: +_With Kotlin_ + +```kotlin +val ssids = wisefy.searchForSSIDs("regex for SSIDs") +``` + +_With Java_ + ```java -List ssids = mWiseFy.searchForSSIDs("regex for SSIDs"); +List ssids = wisefy.searchForSSIDs("regex for SSIDs"); ``` #### Via The Asynchronous API @@ -38,15 +78,31 @@ List ssids = mWiseFy.searchForSSIDs("regex for SSIDs"); To get nearby access points:

Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI (will always take the highest signal strength) +_With Kotlin_ + +```kotlin +wisefy.getNearbyAccessPoints(true, object: GetNearbyAccessPointsCallbacks { + override fun retrievedNearbyAccessPoints(nearbyAccessPoints: List) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -WiseFy.getNearbyAccessPoints(true, new GetNearbyAccessPointsCallbacks() { +wisefy.getNearbyAccessPoints(true, new GetNearbyAccessPointsCallbacks() { @Override - public void getNearbyAccessPointsWiseFyFailure(Integer wisefyReturnCode) { + public void retrievedNearbyAccessPoints(List accessPoints) { } @Override - public void retrievedNearbyAccessPoints(List nearbyAccessPoints) { + public void wisefyFailure(int wisefyFailureCode) { } }); @@ -55,20 +111,40 @@ WiseFy.getNearbyAccessPoints(true, new GetNearbyAccessPointsCallbacks() { To search for an access point given a regex (will return first match):

Setting filterDuplicates to true will return the access point with the highest RSSI (will always take the highest signal strength) +_With Kotlin_ + +```kotlin +wisefy.searchForAccessPoint("regex for SSID", 3000, true, object: SearchForAccessPointCallbacks { + override fun accessPointFound(accessPoint: ScanResult) { + + } + + override fun accessPointNotFound() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.searchForAccessPoint("regex for SSID", 3000, true, new SearchForAccessPointCallbacks() { +wisefy.searchForAccessPoint("regex for SSID", 3000, true, new SearchForAccessPointCallbacks() { @Override - public void searchForAccessPointWiseFyFailure(Integer wisefyReturnCode) { + public void accessPointFound(ScanResult scanResult) { } @Override - public void accessPointFound(ScanResult accessPoint) { + public void accessPointNotFound() { } @Override - public void accessPointNotFound() { + public void wisefyFailure(int i) { } }); @@ -77,14 +153,28 @@ mWiseFy.searchForAccessPoint("regex for SSID", 3000, true, new SearchForAccessPo To search for all access points matching a given regex:

Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI (will always take the highest signal strength) +_With Kotlin_ -```java -mWiseFy.searchForAccessPoints("regex for SSID", true, new SearchForAccessPointsCallbacks() { - @Override - public void searchForAccessPointsWiseFyFailure(Integer wisefyReturnCode) { +```kotlin +wisefy.searchForAccessPoints("regex for SSID", true, object: SearchForAccessPointsCallbacks { + override fun foundAccessPoints(accessPoints: List) { + + } + + override fun noAccessPointsFound() { } + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + +```java +wisefy.searchForAccessPoints("regex for SSID", true, new SearchForAccessPointsCallbacks() { @Override public void foundAccessPoints(List accessPoints) { @@ -94,25 +184,50 @@ mWiseFy.searchForAccessPoints("regex for SSID", true, new SearchForAccessPointsC public void noAccessPointsFound() { } + + @Override + public void wisefyFailure(int i) { + + } }); ``` To search for an SSID given a regex (will return first match): +_With Kotlin_ + +```kotlin +wisefy.searchForSSID("regex for SSID", 3000, object: SearchForSSIDCallbacks { + override fun ssidFound(ssid: String) { + + } + + override fun ssidNotFound() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.searchForSSID("regex for SSID", 3000, new SearchForSSIDCallbacks() { +wisefy.searchForSSID("regex for SSID", 3000, new SearchForSSIDCallbacks() { @Override - public void searchForSSIDWiseFyFailure(Integer wisefyReturnCode) { + public void ssidFound(String s) { } @Override - public void ssidFound(String ssid) { + public void ssidNotFound() { } @Override - public void ssidNotFound() { + public void wisefyFailure(int i) { } }); @@ -120,20 +235,40 @@ mWiseFy.searchForSSID("regex for SSID", 3000, new SearchForSSIDCallbacks() { To search for all SSIDs matching a given regex: +_With Kotlin_ + +```kotlin +wisefy.searchForSSIDs("regex for SSID", object: SearchForSSIDsCallbacks { + override fun noSSIDsFound() { + + } + + override fun retrievedSSIDs(ssids: List) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.searchForSSIDs("regex for SSID", new SearchForSSIDsCallbacks() { +wisefy.searchForSSIDs("regex for SSID", new SearchForSSIDsCallbacks() { @Override - public void searchForSSIDsWiseFyFailure(Integer wisefyReturnCode) { + public void retrievedSSIDs(List list) { } @Override - public void retrievedSSIDs(List ssids) { + public void noSSIDsFound() { } @Override - public void noSSIDsFound() { + public void wisefyFailure(int i) { } }); @@ -141,5 +276,4 @@ mWiseFy.searchForSSIDs("regex for SSID", new SearchForSSIDsCallbacks() { ***Notes*** -- Will return a WiseFy error code if parameter is missing -- Will return a WiseFy error code if the instance has a missing prerequisite \ No newline at end of file +- Will return a WiseFy error code if parameter is missing \ No newline at end of file diff --git a/documentation/network_security.md b/documentation/network_security.md index 2a816987..02e36de6 100644 --- a/documentation/network_security.md +++ b/documentation/network_security.md @@ -2,36 +2,84 @@ To check and see if a network is secure (defined by having EAP/PSK/WPA/WPA2 capabilities): +_With Kotlin_ + +```kotlin +val isSecure = wisefy.isNetworkSecure(scanResult) +``` + +_With Java_ + ```java -boolean isSecure = mWiseFy.isNetworkSecure(scanResult); +boolean isSecure = wisefy.isNetworkSecure(scanResult); ``` To check and see if a network has EAP capabilities): +_With Kotlin_ + +```kotlin +val hasEAPCapabilities = wisefy.isNetworkEAP(scanResult) +``` + +_With Java_ + ```java -boolean hasEAPCapabilities = mWiseFy.isNetworkEAP(scanResult); +boolean hasEAPCapabilities = wisefy.isNetworkEAP(scanResult); ``` To check and see if a network has PSK capabilities): +_With Kotlin_ + +```kotlin +val hasPSKCapabilities = wisefy.isNetworkPSK(scanResult) +``` + +_With Java_ + ```java -boolean hasPSKCapabilities = mWiseFy.isNetworkPSK(scanResult); +boolean hasPSKCapabilities = wisefy.isNetworkPSK(scanResult); ``` To check and see if a network has WEP capabilities): +_With Kotlin_ + +```kotlin +val hasWEPCapabilities = wisefy.isNetworkWEP(scanResult) +``` + +_With Java_ + ```java -boolean hasWEPCapabilities = mWiseFy.isNetworkWEP(scanResult); +boolean hasWEPCapabilities = wisefy.isNetworkWEP(scanResult); ``` To check and see if a network has WPA capabilities): +_With Kotlin_ + +```kotlin +val hasWPACapabilities = wisefy.isNetworkWPA(scanResult) +``` + +_With Java_ + ```java -boolean hasWPACapabilities = mWiseFy.isNetworkWPA(scanResult); +boolean hasWPACapabilities = wisefy.isNetworkWPA(scanResult); ``` To check and see if a network has WPA2 capabilities): +_With Kotlin_ + +```kotlin +val hasWPA2Capabilities = wisefy.isNetworkWPA2(scanResult) +``` + +_With Java_ + ```java -boolean hasWPA2Capabilities = mWiseFy.isNetworkWPA2(scanResult); +boolean hasWPA2Capabilities = wisefy.isNetworkWPA2(scanResult); ``` \ No newline at end of file diff --git a/documentation/permissions_example.md b/documentation/permissions_example.md index 0aeda3a8..cbcc98ed 100644 --- a/documentation/permissions_example.md +++ b/documentation/permissions_example.md @@ -13,6 +13,103 @@ First we define the permissions in the manifest: Then on the activity using WiseFy then we can start asking for permissions and handling the permission callbacks. +_With Kotlin_ + +```kotlin +package com.isupatches.wisefysample.ui.main + +import android.Manifest.permission.ACCESS_COARSE_LOCATION +import android.content.pm.PackageManager +import android.net.wifi.ScanResult +import android.os.Bundle +import android.support.v4.content.ContextCompat +import android.support.v7.app.AppCompatActivity +import android.util.Log + +import com.isupatches.wisefy.WiseFy +import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks +import com.isupatches.wisefysample.R +import com.isupatches.wisefysample.util.PermissionUtil + +class MainActivity : AppCompatActivity() { + + companion object { + private val TAG = MainActivity::class.java.simpleName + } + + private lateinit var wisefy: WiseFy + + private val permissionUtil = PermissionUtil.getInstance() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + wisefy = WiseFy.Brains(this).logging(true).getSmarts() + + if (checkForPermissions()) { + getNearbyAccessPoints() + } + } + + override fun onDestroy() { + super.onDestroy() + wisefy.dump() + } + + private fun checkForPermissions(): Boolean { + return isPermissionGranted(ACCESS_COARSE_LOCATION, WISEFY_PERMISSION_REQUEST_CODE) + } + + private fun isPermissionGranted(permission: String, requestCode: Int): Boolean { + return if (permissionUtil.permissionNotGranted(this, permission)) { + if (permissionUtil.shouldShowPermissionRationale(this, permission)) { + // Display dialog or rationale for requesting permission here + } else { + permissionUtil.requestPermissions(this, arrayOf(permission), requestCode) + } + false + } else { + true + } + } + + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { + when (requestCode) { + WISEFY_PERMISSION_REQUEST_CODE -> { + if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + Log.d(TAG, "WiseFy permissions granted") + // Continue WiseFy logic here + } else { + Log.e(TAG, "Access course location permission denied") + // Display permission error here + } + } else -> { + // Display permission error here + Log.wtf(TAG, "Weird permission requested, not handled") + } + } + } + + @Throws(SecurityException::class) + private fun getNearbyAccessPoints() { + wisefy.getNearbyAccessPoints(true, object : GetNearbyAccessPointsCallbacks { + override fun wisefyFailure(wisefyFailureCode: Int) { + // failure logic goes here + } + + override fun retrievedNearbyAccessPoints(accessPoints: List) { + // You should see this populate with results after approving the + // the ACCESS_COARSE_LOCATION permission + Log.d(TAG, "List: $nearbyAccessPoints") + } + }) + } +} +``` + +_With Java_ + ```java package wisefy_sample.isupatches.com.wisefysample.ui; @@ -36,15 +133,17 @@ public class MainActivity extends AppCompatActivity { private static final String TAG = MainActivity.class.getSimpleName(); - private WiseFy mWiseFy; + private WiseFy wisefy; - private PermissionUtil mPermissionUtil = PermissionUtil.getInstance(); + private PermissionUtil permissionUtil = PermissionUtil.getInstance(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + wisefy = new WiseFy.Brains(this).logging(true).getSmarts(); + if (checkForPermissions()) { getNearbyAccessPoints(); } @@ -53,7 +152,7 @@ public class MainActivity extends AppCompatActivity { @Override protected void onDestroy() { super.onDestroy(); - mWiseFy.dump(); + wisefy.dump(); } private boolean checkForPermissions() { @@ -61,11 +160,11 @@ public class MainActivity extends AppCompatActivity { } public boolean isPermissionGranted(String permission, int rationaleResId, int requestCode) { - if (mPermissionUtil.permissionNotGranted(this, permission)) { - if (mPermissionUtil.shouldShowPermissionRationale(this, permission)) { + if (permissionUtil.permissionNotGranted(this, permission)) { + if (permissionUtil.shouldShowPermissionRationale(this, permission)) { // Display dialog or rationale for requesting permission here } else { - mPermissionUtil.requestPermissions(this, new String[]{permission}, requestCode); + permissionUtil.requestPermissions(this, new String[]{permission}, requestCode); } return false; } else { @@ -76,9 +175,9 @@ public class MainActivity extends AppCompatActivity { @Override public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { switch (requestCode) { - case Permissions.ACCESS_COARSE_LOCATION_RESULT_CODE: + case Permissions.WISEFY_PERMISSION_REQUEST_CODE: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - Log.d(TAG, "Access course location permission granted"); + Log.d(TAG, "Wisefy permissions granted"); // Continue WiseFy logic here } else { Log.e(TAG, "Access course location permission denied"); @@ -92,21 +191,19 @@ public class MainActivity extends AppCompatActivity { } } - private void getNearbyAccessPoints() { - mWiseFy = new WiseFy.brains(this).logging(true).getSmarts(); - - mWiseFy.getNearbyAccessPoints(true, new GetNearbyAccessPointsCallbacks() { - @Override - public void getNearbyAccessPointsWiseFyFailure(Integer integer) { - - } - + private void getNearbyAccessPoints() throws SecurityException { + wisefy.getNearbyAccessPoints(true, new GetNearbyAccessPointsCallbacks() { @Override - public void retrievedNearbyAccessPoints(List list) { + public void retrievedNearbyAccessPoints(List accessPoints) { // You should see this populate with results after approving the // the ACCESS_COARSE_LOCATION permission Log.d(TAG, "List: " + list.toString()); } + + @Override + public void wisefyFailure(int wisefyFailureCode) { + + } }); } } @@ -114,16 +211,48 @@ public class MainActivity extends AppCompatActivity { In this example, PermissionUtil is just an abstracted, shared piece of logic: +_With Kotlin_ + +```kotlin +package com.isupatches.wisefysample.util + +import android.app.Activity +import android.support.v4.app.ActivityCompat +import android.content.pm.PackageManager +import android.support.v4.content.ContextCompat + +class PermissionUtil private constructor() { + + companion object { + private val INSTANCE: PermissionUtil = PermissionUtil() + + fun getInstance(): PermissionUtil = INSTANCE + } + + fun permissionNotGranted(activity: Activity, permission: String): Boolean { + return ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED + } + + fun shouldShowPermissionRationale(activity: Activity, permission: String): Boolean = + ActivityCompat.shouldShowRequestPermissionRationale(activity, permission) + + + fun requestPermissions(activity: Activity, permissions: Array, requestCode: Int) { + ActivityCompat.requestPermissions(activity, permissions, requestCode) + } +} +``` + +_With Java_ + ```java package wisefy_sample.isupatches.com.wisefysample.util; - import android.app.Activity; import android.content.pm.PackageManager; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; - public class PermissionUtil { private static final PermissionUtil PERMISSION_UTIL = new PermissionUtil(); @@ -152,11 +281,20 @@ public class PermissionUtil { And there is a class for storing constants for permission checks: -```java +_With Kotlin_ + +``` package wisefy_sample.isupatches.com.wisefysample.constants; +internal const val WISEFY_PERMISSION_REQUEST_CODE = 1 +``` + +_With Java_ + +```java +package wisefy_sample.isupatches.com.wisefysample.constants; public class Permissions { - public static final int ACCESS_COARSE_LOCATION_RESULT_CODE = 1; + public static final int WISEFY_PERMISSION_REQUEST_CODE = 1; } ``` \ No newline at end of file diff --git a/documentation/rssi.md b/documentation/rssi.md index 7c828d5d..ab9e9828 100644 --- a/documentation/rssi.md +++ b/documentation/rssi.md @@ -2,31 +2,75 @@ To calculate number of bars given a networks signal strength and total number of bars: +_With Kotlin_ + +```kotlin +val bars = wisefy.calculateBars(-35, 5) +``` + +_With Java_ + ```java -int bars = mWiseFy.calculateBars(-35, 5); +int bars = wisefy.calculateBars(-35, 5); ``` To compare the signal strength of two networks: +_With Kotlin_ + +```kotlin +val result = wisefy.compareSignalLevel(-35, -70) +``` + +_With Java_ + ```java -int result = mWiseFy.compareSignalLevel(-35, -70); +int result = wisefy.compareSignalLevel(-35, -70); ``` To get the RSSI of the first SSID matching a given regex:

Setting takeHighest to true will return the access point with the highest RSSI for the given SSID +_With Kotlin_ + +```kotlin +val rssi = wisefy.getRSSI("regex for SSID", true, 3000) +``` + +_With Java_ + ```java -Integer rssi = mWiseFy.getRSSI("regex for SSID", true, 3000); +Integer rssi = wisefy.getRSSI("regex for SSID", true, 3000); ``` #### Via The Asynchronous API To get the RSSI of the first SSID matching a given regex: +_With Kotlin_ + +```kotlin +wisefy.getRSSI("regex for SSID", true, 3000, object: GetRSSICallbacks{ + override fun networkNotFoundToRetrieveRSSI() { + + } + + override fun retrievedRSSI(rssi: Int) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.getRSSI("regex for SSID", true, 3000, new GetRSSICallbacks() { +wisefy.getRSSI("regex for SSID", true, 3000, new GetRSSICallbacks() { @Override - public void retrievedRSSI(Integer rssi) { + public void retrievedRSSI(int i) { } @@ -36,7 +80,7 @@ mWiseFy.getRSSI("regex for SSID", true, 3000, new GetRSSICallbacks() { } @Override - public void getRSSIWiseFyFailure(Integer wisefyReturnCode) { + public void wisefyFailure(int i) { } }); @@ -45,4 +89,3 @@ mWiseFy.getRSSI("regex for SSID", true, 3000, new GetRSSICallbacks() { ***Notes*** - Will return a WiseFy error code if parameter is missing -- Will return a WiseFy error code if the instance has a missing prerequisite \ No newline at end of file diff --git a/documentation/saved_networks.md b/documentation/saved_networks.md index e5404e6d..1737a606 100644 --- a/documentation/saved_networks.md +++ b/documentation/saved_networks.md @@ -2,46 +2,98 @@ To get the first saved network that matches a given regex: +_With Kotlin_ + +```kotlin +val savedNetwork = wisefy.getSavedNetwork("regex for SSID") +``` + +_With Java_ + ```java -WifiConfiguration savedNetwork = mWiseFy.getSavedNetwork("regex for SSID"); +WifiConfiguration savedNetwork = wisefy.getSavedNetwork("regex for SSID"); ``` To retrieve all of the saved networks: +_With Kotlin_ + +```kotlin +val savedNetworks = wisefy.getSavedNetworks() +``` + +_With Java_ + ```java -List savedNetworks = mWiseFy.getSavedNetworks(); +List savedNetworks = wisefy.getSavedNetworks(); ``` To return all saved networks that match a given regex: +_With Kotlin_ + +```kotlin +val savedNetworks = wisefy.getSavedNetworks("regex for SSID") +``` + +_With Java_ + ```java -List savedNetworks = mWiseFy.getSavedNetworks("regex for SSID"); +List savedNetworks = wisefy.getSavedNetworks("regex for SSID"); ``` To check and see if a given SSID is in the devices set of configured networks: +_With Kotlin_ + +```kotlin +val saved = wisefy.isNetworkSaved("regex for SSID") +``` + +_With Java_ + ```java -boolean isConfigured = mWiseFy.isNetworkInConfigurationList("regex for SSID"); +boolean saved = wisefy.isNetworkSaved("regex for SSID"); ``` #### Via The Asynchronous API To get the first saved network that matches a given regex: +_With Kotlin_ + +```kotlin +wisefy.getSavedNetwork("regex for SSID", object: GetSavedNetworkCallbacks { + override fun retrievedSavedNetwork(savedNetwork: WifiConfiguration) { + + } + + override fun savedNetworkNotFound() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java - mWiseFy.getSavedNetwork("regex for SSID", new GetSavedNetworkCallbacks() { +wisefy.getSavedNetwork("regex for SSID", new GetSavedNetworkCallbacks() { @Override - public void getSavedNetworkWiseFyFailure(Integer wisefyReturnCode) { + public void savedNetworkNotFound() { } @Override - public void savedNetworkNotFound() { + public void retrievedSavedNetwork(WifiConfiguration wifiConfiguration) { } @Override - public void retrievedSavedNetwork(WifiConfiguration savedNetwork) { + public void wisefyFailure(int i) { } }); @@ -49,13 +101,28 @@ To get the first saved network that matches a given regex: To retrieve all of the saved networks: -```java -mWiseFy.getSavedNetworks(new GetSavedNetworksCallbacks() { - @Override - public void getSavedNetworksWiseFyFailure(Integer wisefyReturnCode) { +_With Kotlin_ + +```kotlin +wisefy.getSavedNetworks(object: GetSavedNetworksCallbacks { + override fun noSavedNetworksFound() { + + } + + override fun retrievedSavedNetworks(savedNetworks: List) { } + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + +```java +wisefy.getSavedNetworks(new GetSavedNetworksCallbacks() { @Override public void noSavedNetworksFound() { @@ -65,25 +132,50 @@ mWiseFy.getSavedNetworks(new GetSavedNetworksCallbacks() { public void retrievedSavedNetworks(List savedNetworks) { } + + @Override + public void wisefyFailure(int wisefyFailureCode) { + + } }); ``` To return all saved networks that match a given regex: +_With Kotlin_ + +```kotlin +wisefy.getSavedNetworks("regex for SSID", object: GetSavedNetworksCallbacks { + override fun noSavedNetworksFound() { + + } + + override fun retrievedSavedNetworks(savedNetworks: List) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } +}) +``` + +_With Java_ + ```java -mWiseFy.getSavedNetwork("regex for SSID", new GetSavedNetworkCallbacks() { +wisefy.getSavedNetworks("regex for SSID", new GetSavedNetworksCallbacks() { @Override - public void getSavedNetworkWiseFyFailure(Integer wisefyReturnCode) { + public void noSavedNetworksFound() { } @Override - public void savedNetworkNotFound() { + public void retrievedSavedNetworks(List savedNetworks) { } @Override - public void retrievedSavedNetwork(WifiConfiguration savedNetwork) { + public void wisefyFailure(int wisefyFailureCode) { } }); @@ -91,5 +183,4 @@ mWiseFy.getSavedNetwork("regex for SSID", new GetSavedNetworkCallbacks() { ***Notes*** -- Will return a WiseFy error code if parameter is missing -- Will return a WiseFy error code if the instance has a missing prerequisite \ No newline at end of file +- Will return a WiseFy error code if parameter is missing \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 426a2114..df954bab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,26 +1,20 @@ # Project-wide Gradle settings. - # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. - # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html - # The Gradle daemon aims to improve the startup and execution time of Gradle. # When set to true the Gradle daemon is to run the build. org.gradle.daemon=true - # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -noverify -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects org.gradle.parallel=true - # Enables new incubating mode that makes Gradle selective when configuring projects. # Only relevant projects are configured which results in faster builds for large multi-projects. # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand diff --git a/gradle/checkstyle.gradle b/gradle/checkstyle.gradle new file mode 100644 index 00000000..9fc335a6 --- /dev/null +++ b/gradle/checkstyle.gradle @@ -0,0 +1,29 @@ +apply plugin: 'checkstyle' + +checkstyle { + toolVersion "8.4" + + // use one common config file for all subprojects + configFile = project(':').file('wisefy/config/checkstyle/checkstyle.xml') + configProperties = ['baseDir': "$rootDir"] + configProperties = ["suppressionFile": project(':').file('wisefy/config/checkstyle/checkstyle-suppressions.xml')] +} + +task checkstyle(type: Checkstyle) { + description 'Analyze code style' + group 'verification' + + source 'src' + include '**/*.java' + exclude '**/gen/**' + + classpath = files() + ignoreFailures = false + maxWarnings = 0 + maxErrors = 0 + + reports { + xml.enabled = false + html.enabled = true + } +} \ No newline at end of file diff --git a/gradle/code-coverage.gradle b/gradle/code-coverage.gradle new file mode 100644 index 00000000..f1f3858b --- /dev/null +++ b/gradle/code-coverage.gradle @@ -0,0 +1,35 @@ +task jacocoAllCombinedTests { + group = "verification" + + dependsOn ':wisefy:jacocoDebugCombinedTest' +} + +task jacocoAllCombinedTestReports { + group = "verification" + + dependsOn ':wisefy:jacocoDebugCombinedTestReport' +} + +task jacocoAllUnitTests { + group = "verification" + + dependsOn ':wisefy:jacocoDebugUnitTest' +} + +task jacocoAllUnitTestReports { + group = "verification" + + dependsOn ':wisefy:jacocoDebugUnitTestReport' +} + +task jacocoAllAndroidTests { + group = "verification" + + dependsOn ':wisefy:jacocoDebugAndroidTest' +} + +task jacocoAllAndroidTestReports { + group = "verification" + + dependsOn ':wisefy:jacocoDebugAndroidTestReport' +} \ No newline at end of file diff --git a/gradle/cpd.gradle b/gradle/cpd.gradle new file mode 100644 index 00000000..dc36c010 --- /dev/null +++ b/gradle/cpd.gradle @@ -0,0 +1,22 @@ +apply plugin: 'cpd' + +cpd { + language = 'java' +} + +cpdCheck { + ignoreFailures false + + def classes = fileTree('src/main/java') + classes += fileTree('src/androidTest/java') + classes += fileTree('src/commonTest/java') + classes += fileTree('src/test/java') + source = classes + + skipLexicalErrors true + + reports { + text.enabled = false + xml.enabled = true + } +} \ No newline at end of file diff --git a/gradle/custom-tasks.gradle b/gradle/custom-tasks.gradle new file mode 100644 index 00000000..e0b7c16a --- /dev/null +++ b/gradle/custom-tasks.gradle @@ -0,0 +1,22 @@ +task makeGoodChoices { + group = "verification" + + dependsOn 'androidFindbugs', 'pmd', 'lintDebug', 'cpdCheck', 'checkstyle', 'jacocoDebugTestReport' + doLast { + println "\n#############################################" + + "\n# All checks passed! You are doing so good! #" + + "\n# You may now push the awesome to origin :) #" + + "\n#############################################" + } +} + +task staticAnalysisSanityCheck { + group = "verification" + + dependsOn 'androidFindbugs', 'pmd', 'lintDebug', 'cpdCheck', 'checkstyle' + doLast { + println "\n##################################################" + + "\n# Static analysis passed! You are doing so good! #" + + "\n##################################################" + } +} diff --git a/gradle/detekt.gradle b/gradle/detekt.gradle new file mode 100644 index 00000000..00be5364 --- /dev/null +++ b/gradle/detekt.gradle @@ -0,0 +1,14 @@ +detekt { + version = "1.0.0.RC8" + + profile("main") { + input = "$projectDir/wisefy/src/" + output = "$projectDir/wisefy/build/reports/detekt" + config = "$projectDir/config/detekt-config.yml" + } + + profile("wisefy") { + input = "$projectDir/wisefy/src/" + output = "$projectDir/wisefy/build/reports/detekt" + } +} \ No newline at end of file diff --git a/gradle/dexcount.gradle b/gradle/dexcount.gradle new file mode 100644 index 00000000..d4244ccc --- /dev/null +++ b/gradle/dexcount.gradle @@ -0,0 +1,10 @@ +apply plugin: 'com.getkeepsafe.dexcount' + +dexcount { + format = "tree" + includeClasses = true + includeFieldCount = true + includeTotalMethodCount = true + orderByMethodCount = true + verbose = false +} \ No newline at end of file diff --git a/gradle/dokka.gradle b/gradle/dokka.gradle new file mode 100644 index 00000000..ef460a81 --- /dev/null +++ b/gradle/dokka.gradle @@ -0,0 +1,6 @@ +dokka { + moduleName = 'wisefy' + outputFormat = 'html' + outputDirectory = "$rootProject.projectDir/javadoc" + jdkVersion = 8 +} \ No newline at end of file diff --git a/gradle/findbugs.gradle b/gradle/findbugs.gradle new file mode 100644 index 00000000..35c11c42 --- /dev/null +++ b/gradle/findbugs.gradle @@ -0,0 +1,26 @@ +apply plugin: 'findbugs' + +task androidFindbugs(type: FindBugs, overwrite: true) { + description "Analyze code with findbugs" + group 'verification' + + source = fileTree(project.rootDir.absolutePath).include("**/*.java") + classes = files("$project.buildDir.absolutePath/intermediates/classes/debug/") + classpath = files() + + findbugs { + sourceSets = [android.sourceSets] + ignoreFailures = false + reportsDir = file("$project.buildDir/findbugsReports") + effort = "max" + + excludeFilter = file("../wisefy/config/findbugs/findbugs-suppressions.xml") + reports { + xml.enabled = false + html.enabled = true + html.destination new File(project.buildDir, 'reports/findbugs/findbugs.html') + } + } +} + +androidFindbugs.dependsOn(['assembleDebug']) \ No newline at end of file diff --git a/gradle/gradle-bintray-install.gradle b/gradle/gradle-bintray-install.gradle index 6e50fdf1..fb98a471 100644 --- a/gradle/gradle-bintray-install.gradle +++ b/gradle/gradle-bintray-install.gradle @@ -2,8 +2,6 @@ apply plugin: 'com.github.dcendents.android-maven' -group = GROUP // Maven Group ID for the artifact - install { repositories.mavenInstaller { // This generates POM.xml with proper parameters diff --git a/gradle/gradle-bintray-upload.gradle b/gradle/gradle-bintray-upload.gradle index 462f6bce..5a25abdf 100644 --- a/gradle/gradle-bintray-upload.gradle +++ b/gradle/gradle-bintray-upload.gradle @@ -10,10 +10,8 @@ if (project.hasProperty("android")) { // Android libraries from android.sourceSets.main.java.srcDirs } - task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - destinationDir = file("../javadoc/") - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + task javadoc(type: Javadoc, dependsOn: dokka) { + } } else { // Java libraries task sourcesJar(type: Jar, dependsOn: classes) { @@ -34,17 +32,21 @@ artifacts { // Bintray Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) +if (project.rootProject.file('local.properties').exists()) { + properties.load(project.rootProject.file('local.properties').newDataInputStream()) +} bintray { user = properties.getProperty("bintray.user") key = properties.getProperty("bintray.apikey") + def gpg_passphrase = properties.getProperty("bintray.gpg_passphrase") println("user: " + user) println("key: " + key) - + println("gpg_passphrase: " + gpg_passphrase) configurations = ['archives'] + pkg { repo = BINTRAY_REPO name = BINTRAY_NAME @@ -60,7 +62,8 @@ bintray { desc = LIBRARY_DESCRIPTION gpg { sign = true // Determines whether to GPG sign the files. The default is false - passphrase = properties.getProperty("bintray.gpg.password") // Optional. The passphrase for GPG signing' + passphrase = gpg_passphrase + // Optional. The passphrase for GPG signing' } } } diff --git a/gradle/jacoco.gradle b/gradle/jacoco.gradle index a35c74f5..baa2c35f 100644 --- a/gradle/jacoco.gradle +++ b/gradle/jacoco.gradle @@ -1,46 +1,144 @@ apply plugin: 'jacoco' -def coverageSourceDirs = [ - '../wisefy/src/main/java' -] - -def classDirs = fileTree( - dir: '../wisefy/build/intermediates/classes/debug/com/', - excludes: ['**/R.class', - '**/R$*.class', - '**/*$ViewBinder*.*', - '**/*MembersInjector*.*', - '**/BuildConfig.*', - '**/Manifest*.*', - '**/*$Lambda$*.class', - '**/*Factory*.class', - '**/*$Builder*']) - -task jacocoDebugTestReport(type: JacocoReport) { - dependsOn = ["connectedDebugAndroidTest", "testDebugUnitTest"] - group = "Reporting" - description = "Run tests and generate Jacoco coverage report for debug" - classDirectories = classDirs - additionalSourceDirs = files(coverageSourceDirs) - sourceDirectories = files(coverageSourceDirs) - executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec'), fileTree(dir: 'build/jacoco', include: '**/*.exec')]) - - reports { - xml.enabled = true - html.enabled = true +jacoco { + toolVersion = "0.8.1" +} + +def srcDirs = ["src/main/java"] + +def excludes = ['**/R.class', + '**/R$*.class', + '**/*$ViewBinder*.*', + '**/*MembersInjector*.*', + '**/BuildConfig.*', + '**/Manifest*.*', + '**/*$Lambda$*.class', + '**/*Factory*.class', + '**/*$Builder*'] + +project.afterEvaluate { + def variants = getVariants() + if (variants != null) { + variants.all { variant -> + task("jacoco${variant.name.capitalize()}UnitTest", type: JacocoReport, dependsOn: "test${variant.name.capitalize()}UnitTest") { + group = "verification" + + classDirectories = getClassDirs('debug', 'debug', excludes) + additionalSourceDirs = files(srcDirs) + sourceDirectories = files(srcDirs) + executionData = fileTree(dir: "$project.buildDir/jacoco", includes: [ + "**/*.exec" + ]) + + reports { + xml.enabled = false + html.enabled = true + } + } + + task("jacoco${variant.name.capitalize()}UnitTestReport", type: JacocoReport) { + group = "verification" + + classDirectories = getClassDirs('debug', 'debug', excludes) + additionalSourceDirs = files(srcDirs) + sourceDirectories = files(srcDirs) + executionData = fileTree(dir: "$project.buildDir/jacoco", includes: [ + "**/*.exec" + ]) + + reports { + xml.enabled = false + html.enabled = true + } + } + + task("jacoco${variant.name.capitalize()}AndroidTest", type: JacocoReport, dependsOn: "connected${variant.name.capitalize()}AndroidTest") { + group = "verification" + + classDirectories = getClassDirs('debug', 'debug', excludes) + additionalSourceDirs = files(srcDirs) + sourceDirectories = files(srcDirs) + executionData = fileTree(dir: "$project.buildDir/outputs/code-coverage/connected", includes: [ + '**/*.ec' + ]) + + reports { + xml.enabled = false + html.enabled = true + } + } + + task("jacoco${variant.name.capitalize()}AndroidTestReport", type: JacocoReport) { + group = "verification" + + classDirectories = getClassDirs('debug', 'debug', excludes) + additionalSourceDirs = files(srcDirs) + sourceDirectories = files(srcDirs) + executionData = fileTree(dir: "$project.buildDir/outputs/code-coverage/connected", includes: [ + '**/*.ec' + ]) + + reports { + xml.enabled = false + html.enabled = true + } + } + + task("jacoco${variant.name.capitalize()}CombinedTest", type: JacocoReport, dependsOn: ["test${variant.name.capitalize()}UnitTest", "connected${variant.name.capitalize()}AndroidTest"]) { + group = "verification" + + classDirectories = getClassDirs('debug', 'debug', excludes) + additionalSourceDirs = files(srcDirs) + sourceDirectories = files(srcDirs) + executionData = files([ + fileTree(dir: "$project.buildDir/outputs/code-coverage/connected", include: '**/*.ec'), + fileTree(dir: "$project.buildDir/jacoco", include: '**/*.exec') + ]) + + reports { + xml.enabled = false + html.enabled = true + } + } + + task("jacoco${variant.name.capitalize()}CombinedTestReport", type: JacocoReport) { + group = "verification" + + classDirectories = getClassDirs('debug', 'debug', excludes) + additionalSourceDirs = files(srcDirs) + sourceDirectories = files(srcDirs) + executionData = files([ + fileTree(dir: "$project.buildDir/outputs/code-coverage/connected", include: '**/*.ec'), + fileTree(dir: "$project.buildDir/jacoco", include: '**/*.exec') + ]) + + reports { + xml.enabled = false + html.enabled = true + } + } + } } } -task jacocoDebugReport(type: JacocoReport) { - group = "Reporting" - description = "Generate Jacoco coverage report for debug" - classDirectories = classDirs - additionalSourceDirs = files(coverageSourceDirs) - sourceDirectories = files(coverageSourceDirs) - executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec'), fileTree(dir: 'build/jacoco', include: '**/*.exec')]) - - reports { - xml.enabled = true - html.enabled = true +private def getClassDirs(String javaDirSuffix, String kotlinDirSuffix, excludes) { + def java = fileTree( + dir: "${buildDir}/intermediates/classes/${javaDirSuffix}", + excludes: excludes + ) + def kotlin = fileTree( + dir: "${buildDir}/tmp/kotlin-classes/${kotlinDirSuffix}", + excludes: excludes + ) + files([java], [kotlin]) +} + +private def getVariants() { + if (project.hasProperty("android")) { + if (project.android.hasProperty('libraryVariants')) { + return project.android.libraryVariants + } else { + return project.android.applicationVariants + } } -} \ No newline at end of file +} diff --git a/gradle/ktlint.gradle b/gradle/ktlint.gradle new file mode 100644 index 00000000..9a9951ca --- /dev/null +++ b/gradle/ktlint.gradle @@ -0,0 +1,8 @@ +ktlint { + version '0.27.0' + debug = true + verbose = true + android = true + reporters = ["PLAIN", "CHECKSTYLE"] + ignoreFailures = false +} \ No newline at end of file diff --git a/gradle/pmd.gradle b/gradle/pmd.gradle new file mode 100644 index 00000000..ae38b8aa --- /dev/null +++ b/gradle/pmd.gradle @@ -0,0 +1,15 @@ +apply plugin: 'pmd' + +task pmd(type: Pmd) { + description 'Analyze code with pmd' + group 'verification' + + ignoreFailures = false + + source = fileTree('src/main/java') + + reports { + xml.enabled = false + html.enabled = true + } +} \ No newline at end of file diff --git a/gradle/static-analysis.gradle b/gradle/static-analysis.gradle new file mode 100644 index 00000000..f61c667d --- /dev/null +++ b/gradle/static-analysis.gradle @@ -0,0 +1,55 @@ +task staticAnalysisSanityCheck { + group = "verification" + + dependsOn 'lintAll', 'detektAll', 'ktlintAll', 'cpdAll' + doLast { + println "\n##################################################" + + "\n# Static analysis passed! You are doing so good! #" + + "\n##################################################" + } +} + +task lintAll { + group = 'verification' + + dependsOn ':wisefy:lintDebug' + doLast { + println "\n##################################################" + + "\n# Linted all the things! Go you! #" + + "\n##################################################" + } +} + +task ktlintAll { + group = 'verification' + + dependsOn ':wisefy:ktlintDebugCheck' + doLast { + println "\n##################################################" + + "\n# KTLinted all the things! Go you! #" + + "\n##################################################" + } +} + +task detektAll { + group = 'verification' + + dependsOn 'detektCheck' + doLast { + println "\n##################################################" + + "\n# Detekt'ed all the things! Go you! #" + + "\n##################################################" + } +} + +task cpdAll { + group = 'verification' + + dependsOn ':wisefy:cpdCheck' + doLast { + println "\n##################################################" + + "\n# Code so DRY, it must have an umbrella! #" + + "\n##################################################" + } + +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 74a595f41d8998a35af05a9ba154a92ce9cd8f4a..99340b4ad18d3c7e764794d300ffd35017036793 100644 GIT binary patch delta 30587 zcmV(=K-s_ls{_5L1CTcf%K^lJK>z>%R*^ta3!3Pe=o#{I@p1tGkQ%YH^#~1+@e$4s z4gdfq8~^|zlW_(fe=cKeVRLhxSqoqk*L6Kl+T9tAMjuv4uwd|Fz!v%%8-pzjMiK%9 zk`P)XvS4hFv?FO@H6zc?0&-h7jzi)!P299`K2BmMPFnY0?1mKyPVA;FZqwHNH*J%C z(l-6NY5Gk+Y0~rFezaO`6sNZJ=6&vc_r812z3;yD=fC;sf6oHgDJ~dD;JSffyi~*9 zXJqqP*}N>9SLEt1==hw0U&JqI_+O=AYzFUz0Om)9}wynSYVZ zzsly{Wb^N``48EAT{izI75Xn7|83v|{zu0*bo{S|ZyMN#mvnrKU%}%hgpj=|+DKFz zI3fbN2pS?JG+pSLsF72KE^2jQYIv6>>I_jY8g$Xfe_h2IO@uYkq>Ht>Xx2oFF4h?s z7wdHq(ZvS2??!4OZqmgjU2N9H&AN!{Vv8{8=Ah%)UVq9; zr|q;rc+_(*E%avmS=;fGQ~0`;R~#}AJU#9|Nj9~mDxCLjg{>iS(L?OTpNVWl#5 zwX~x^e{J9Rp+f^>55@*h4^#uKoC>AfnHihAY#egEneG|SN~G-Wi=H(7?rjG|qeOjAy6QL&>ynJ96{RN}C^a zFFGmLN{p6~bHC8NNhj&=7wBtUMXi;Zten{~e<2X)cN5gSVJPX?Bbm8L+dFAZrqo&7 zDJwN$c}Y3WPX_$iBu%|(HI=ENyQ*g2&2iu8F>ac2o$2IE#gONS3!nzHBRBAFWt ze=-Lh-}W3UMP)Kxs%+OGvejqOw%0pj=V3`lPiCg4B|@ss^idxtGdE^S-RpQ(TE`!< zof&_YzAIp=-_1xN1o=@?k-lJ7n_K~MQQP&)#4->ZdrGQG1*+YQFVIpv&hd;tpYdsA z+nVEYRg&z@#nnNlbWuxN)AqQR6xdv5f7u=7*5mP$nrNjYTDZ?jC#TB2wWFeQR;n!B zWK0#ubg(qxpfl|ha` z8&V78S;Kgp%A_pc9xs~Vmdf5(er9DhM`bX5o;zN2Jsu^zY&!)^fwip_cQEAKgzY3` z&aKT2@)>W<(o%6Q@;H*TfD}wBb2{u2nM6ww1RB<%o7obeN)3bZMg7 z6t|0=rnp1gY2pdI#l#2kv?+FpyO@3oQPHPD)=reh4uh^VLzFH_5xZrxM-z9O;vUgs z;v;y*#0z+lhLGxaD$8qPuPN>o`%JN4+-HgdqE{1rrsx+3H8Eg{L*lS0e~w7So{|?_ zZBpg|FEj7k2~8X|#W67?&{PcF<3*?mL<$y&UbNED62>m67un?5hfOgej%#An6eq-( zCSs;IDaK7PA%;wGN*diPg_$YdgcnT_m(6L>Yl<_ncfV}Tvf;iDnD`m|tUyruDs74f z#X|y@PxX$C42~R*j;9H$f9R2uCr6_yK}45lh^TwP_M(*SnPO6&a!MpjVT);m60?tV~Sb9Old5oe;Ow7vZyx2IdMLZ zoKp5}MUMJhsyXTAbjph=O*ooJnPN`x1i|r>hdK!`SIjS?E3h_I$U*{9IeV$=(p;)* zGU+6`4qCqDFU;Fa!E}JSY1Yhh13#x)AFo7jf%$T2voT&s$vL}Z&$9)%NrPALO*(op z>Cdj>`(!%mxPCO9f0>_msY4>lxdkSS=+TK`1=)w0x^h9@l@D?mM!as8Pmbmjo%Ee& zinI(kmASeu?G^4rcu3XwQ*jqMjsZ6$Ud%AmjI@-EDy;uFWqoivJ zUt~zKN={;4sjxb@w7hAxgtn8Lmj-2Q!SSt2C9WvN!2;_oeo@X zx`11XGRjJCBW?Q!?P)8M;=Qr4b$lR z#(30=UeYJ3HJW^IP!d-2oyqyBl$(|{5giztnzdzK(bzxYru|%RlnF22v!q{j_D*DM znR8{}9`dZ2IaQ_2zae0)oEiN8vB@)pXlg5!F7sf%@RcFj`GzX+{LLzhQoney$#bep zQCfOOe|i18Hy0iywXh8E6=cOSxw+y3?Jgag7qk64C|eLLeN`y^4^-eevx28|mlcnR z_1|ud_Dwn$-1CIQJr(SGrh>^UJwK!&`xbopYe`F`6UujH+v?b1yt@}w@Tg~ZYyWCK zl&D;Ki-e|KZ_e_|j!?l;6^@Xn!WJYj3;`Pg(sfd@Jy4koF=jv0dP396<#5t!Zl)9i591FQ{!EQG``&qtGe-d)RBs5#oFCed>3( z8YM`mo)lH3dQw=m67gtW#1mYRzuawZTSQe``&Cr8bzViFEfTnjU|Yvkgt(wB$=wW% zf9+OE+s6I2qaL?nEp9^ut=NPeN|#-^9gDhbF6y#b9kWXHJf(~5Nv#5$SQ@b4iza#os|2bfO8}O17Ef%gYvc3~wQI&Y0DTzM&(Fx-9BX zwY7IFqM>}dJGkAQ?C(jht_1KfswW_Ma#Ss~RU3W)H-8Y#FCrS=lEp38f3Yz#^+_UnuUZ$OU(v*_x)fws;px}V3^o`%Znnp}@Gy!?W~ z+G}{7CVL%URo|THf0$?j?&he6e-!u9{QHQD{lwRO^zQ*Wr5AhA$A9}VhyjceAu$}r z1dcHH1{r8aiL7Hp&@de`f+uktPm}5sIDwz0Ykr>8pCk2ah~o=5jW6L0zKpZ@3Lc;q zaeSR~-@qBcw}1%Z0b#;Y?teEmsmCjL2Y!GKy#pV{JBd||5-;Ni@h(E;e<23=yBXp& zl=dj)o@Zpn$ooTh4{9m#63_M?)bS**;z#ga8Kt7G04MhHaAGe9rz%m4r|>>h3yI_$ zM^NZ^KR!UqEP+jzFa12Sk5RgWHhZPQm65{@uyHUHrR?f4dj4=StDwA;oa6 zBxJVWLsSJt5g#TcpZ$3ef6wGI(f+pfMch5o`6>c0gzssmtSow-hN&FCmyYiU-+LYV z;)~cHzAuXdZOmG|{ASTdM3<)#hkCd)*gQ?;VI55yr5pD#MJ%PX{l(bZUyQx|c$S8# zBKO_+s7fORt+#TPPu^S_5&I}5#FZy`{{Acu4tInHvN#kzT>Tjwf5~ESq$7M(j*kU6 zj#oEfD8|{IK&K$Va26vy!AKwyG}1f_&AYXe@*JG_)+!(oLP?_!}E07Ihr*$_c$H>A@;f+^?${ZA6EpH~IL>yY;|6YKd~eKqoPmF!u_ueuojH$R zAwJG5VXj483s2D_@1rX3XOjK^gZt?cU+*j`vs0mw_cPk@e{<^kG8sZwl&`DgFHw25 zzQ{c#lFo+jr$R&Fvr4%Kq;la0+4cm&56Mq3Y{^e3JlUu#_YkmwSUkW_FcznmWARXg zJuMQ7#r5`ByfM_lM(d1S!_<{B*giwGo~1$`<+c4W-h9sywjbvm_z88CBRPfgM+xB+ zvyZf^NsoV0F&!n$h`p+g62U=a)$JE0>=)S!a-ZF}#$Je&pHh-PjagM9RAHLg4vo6} zzg|ef_&<~47yb=?h%gae1^@u%3jhE!lW_(XldQ)ef0b5Sa}(zoem+^!+Uqqo4mc6V zHPA#d*n;#xD!U{`!Bik~vT@^tLe|oUy?C{&u2z6cPf1JKq-}ai+J-3dQtj(yRwlFxD(I#JHChKec$JMSAYHQM;`+?gxflv!nqDS zi3v4Ke`+|dBaSHzU(=DqIkkB~t)|=YqMBb)Cl}Q4bv0a6!zB$bx5HA)867<+=`>Z= zAlq?S$5ti26|*|#V5^%eI_BZDqoVA&?eIEL#W!^LsObn$PeA>3AAPP9S8+|lbqxy| zzA4aCJe@yzX{=B@c4^}L*jV8Of!^X3>#CJ?e=K)4I}!M{J3B1UmG|6QV7bAR< zM_^Z^R}aQ(0-_+Wsp>gS!40H;)pFEfa>RD+;D|sXT_|Lx1mbzGOvUb^?aEX2%8c|U ztr6)mE3T&s|U7|EqQLK?)%aWvU$sKl*i#rOVp=luEXFIG;Um=7St3~tY;uNFnXqSFE2#U_A0L^_txfci&s3_&Nroe{Ju8DrGI88?9L1Nm zbcU7MT(K5rWZv;=@@(Cffx~q5J@gS?L`5erJ4#DifydU7VKft7-7hukx%<)Ve;ZQD z28M9MzlCYN;fe{?UI->6H!z}~9 z!wpvIVe~Cw4}PX@!8f#;iXnrhB3_*dGZuy1lg_Mu#~MXWSruMxNoUq;f0;?;-z^hW zdhPXEjV1-u!wf2)hO-0`M{Vv!;tM zh_KC|pC9X|_$h8f3Tb2@Fu+|5I(k*l;JR0}4bE}i4I#_%Aa~Q0X;Yu@fjbZb+do8X zV8@4Odp}e@6spBJ_H*2W4(!Dy?8DPMF(Wm69$$!l1B7lwxKfT{e_VeNU!oM<#L7sZ z3lPsNB0jypfy5$`(|4e8+1@}$ug;-?&O0zp4e~Y@PsJPPx`jh(-t-PS)!cmx{fp?C zZtC`KrV^!lmvkSyFLDWyOEQ!#10NuE(>kn)Tt}+oFBny4ecD^Mad;71rw4oc?%?rU zB9&<1iCi+3Y#WIX%S#Gc-t4p-lpO=pd#4Dc8BaOy~Wa(IRNvXa4_*PenI#*ey1z8D$X@nQ*^f z&CIl_*K4d5NQFJ5fg-|ltjk4K#A4CQl&G?LHP-A^R_9IDf9Gu+#%+8Vzef&#z%bs! z2pZH{#3(%;!>2fof1!YXvwi;uC-DG95yNSr;S5n67kwy*?KmNJvAOT%U50lDaVF%* z1u~|Jd-U)OGavj$EbO{N$=0$t08|2{O3ofN%g10JD~k8`nODs+=K7EbUsfD1@%$ohF7VmB++w~P zr*K+D&qOH@Xa5IKO9KQH000OG0000%00gOe-CP0yv#B4T0uAe|YLli4001-?001hJ zaRwHXY$7CoY=dktA`C$QFKmU8gxG}Cu?-kx8*F1@NJ0+zutg-DkxqClaS7|=}!0FE8TmK|GPWOvUGrd{RKbW``)+L`(B>>&%=)a*dR8k*oM1R zY{X0C@>03HOu=atB@$eMmn(RMAFuS|RdV-g6|cd6J$~Hl$7>b5PDPc(s>18#;Tu%E z5pPoPW)(FK_$?~7U}$>lygq~QI2d_YAVKByv#3HdcCmk-J1VLzt)ctnLCkIMaH3eKu{93NKk5qwm| z$MA7~6`#Np3O=deQ!2LLNfn>QXZ-lAr1_j5pI7h&`T0e8_>?^Sl4SIhA77S?zT(GM z6?{$Fa<^Q*?#CVS_ZxnEQ^mLNZ3W-)Eq)@D!jvg z-tKpHJ$fujqkIYe3M{TaSZuN_T~CdYU$w`vfa-GIrKbcc9gLV6-X4n^Jgpp0nLM;& zMp{Ayl$2>&oiXB;j_awk!H?DXdPd{1aEF;l=*baj>>eA3jLM>B@;Dhuf=det22Q0d zBe5qZDvv?OG#Pm)=C~DO{5(Y3az^rh=!m``UBH$ua_q}kv3Pg}F70%9?W3|g%>?Z% zjhmyRQrU~Vq7bnUNmu1Ux=tF=jAaskjTip@*;vx;T_>Z)v^mxK$Vj0N1XkA1j>hbr z46N#iaWr00fZk9T%Z08s`7##N7oqv%Oi8I&E*+AF72en1%`-tc%Vz-xP9-gW{bbG< z=}K43kdaE;TxzCe6qMp|2f?Was**C&W+oLi+S9}_^n}2ooNnF8@r>nwNva*r#Ns3U zM%0LnTRAkFeZD3e>o1%pMdn{MC!+J^ggRiG;nd6GqJnLa0ySKV>oknwRt>k{W(`Mi zGrQ4+3Q5B+@HAaj=uSq4e+wLc(&h{?o5z?G8h(jiDfqR9-{7~zIVMnYEE6;6vrYd; z32OKqey`yV_@jb9Y4|h#!larhsGWLxtVbW$@K^jz!{6}_4Qbq|;S`>!!NOe%{;A<# z__x4P5BGJ;z8sIU;5-gH%@fJEsgJM+I437GJQuf1FaBq?+omb@=+;<&dpd0-*ilmw z@4sB=0@QgRU(KGDwz!e;8L)KQSRuqbrdob_&|HVIWu`4kw(}L?(?p3V)r7)`3O`j7 zWw@Pf;rKnQG0!=Iw0Yy}6qDCxI#9~dgzi~Gc~bHEEm|;p(m536&f+cS%gDp+HKC;4 zY(nXABN{srGe$zO_{nG_3aZBg4THb!1~CHB-YS8F`S zf;=+2>G3KWHLUzwamnj;^@X@JcJ+lv z2`bB4++TRJJKbt?(MT|-*<`k51@~LA*S&|%g@v*SyZ*d?jJ+;}>BjGQI;+Rq0u;lx zf~Ftz$`4Nw&b{M#=5;UFaxV59%?e%6=)tn^p54h*iOcb)nmKsk8L&8m?A+B;tUD*> zWx2h)EDftym&2i!GREV&97m- zP0s}Go-N5TdFd8m%6WN7zOx3$QsxQy!n3`T&!pQ4+dy>8u-_iWv5X$4zZT__J6C91 z!vP|&#rIpXL z-cx+?o}2e<<*PmTF%r?ZDKCe{^XKU7Kos6?MO~c1;q5kk(|Nj$G1=;=`h|Gs?!t9* z!{qaf4s-wKh1V#%W7a!1VwyK*#u; z6jx5z!|&*g)TGfT!!1Q1$UqoFTz%w#+5jWcH4J< z`Yn!q!E&brF9 zPvGh^wyXv8&E>8pD<}gPAZ&=xLDXO$Q)fSu=o(h<0b9cmJ-UE@x8Ygb)i8L^#&gJN zIhtLVU%roBt)FHvOZYoPtpgodbnb3^0u{DqU5+~2nZ!FHP1I>;Q=mJGT|MikF?LIg z^}RfbG@ogewG;{Z&hEC)dRg#)eP_viCEDm}>Fy5u7r2UL(8KRt_OD~vMtTzzgkYrE#Zg_Z~Zm>CwhOSr&WlL5-8P-0aPwUwVHM12Z|`rWKShfqjJ;byFUfN|%dZ(MhZq{|~bzEer?^oeQ}@BohDt z_9*}WAd_(h7L#Df4S$_k349ghwLd5K=FZK{umwW6tRoW19(FV+8j>KfAs}HfAmSu< zl8oFX&YepV>sB9DTJ55Bw-tA&rBzfCG%B`r*VIKNMVg>Ad4JM`^3dclcXsK@noJNO<{aZ z5~ArmH^is%Jn1Qx<}`)phiDFu4{-^XhNzayWl_5Tx&k5nJR^e44S`J90{@!waxm@8ZnTSbkjK>YDE~+P!Mv^I9->|xNQ`5#B^^GkXH#Dx= zw6Sqr^M8)@wHwzk6*OI<@6xNIdc3o`#kS0N=L)8Ab%}V=*5meOJ(_|pS1|>miOx>L zVw%yEusW+dEj7tTP z(d*MSIlkDXo0}_(>(R}+Wy*KD({Fc~@Z3yK&f=SB z6w-&)M_pi`9X+j=9}ZkgS#%lr}3f;to36&R0JH<^x}Q%6F+uX_mg+Nil_j(_B~ zQr7NrWlu+6U6;|mGbz4VS~6DJ<7$JzRAR0dU_-s#PU%s{(|O56%4#Zd-jBUpRKg(rVdoq6(vvWuP}T8ocQ>$tgPh}IIJRe3VBwhk{|DvQrQ zfyF1AS95w74|7>2TvnX4yR)NZh}80v)>am`IO*I)yqca@CDT-To_}6Y=>z(EmHKHw zrJvI;RC=18QRy1`JC&}cFR1hgJ*v_kz6Oj>s=|~-pz%ezPNm&+t-`xizLvkJ@^!pN z;V;R@msP%=Z&3Lwd;_-UV=Fapp%DA3%3tHJLxpS&5zQ@YYAaEsD14*JH}N+R)!7rW zViiQ_1%+=``4+xa<$v4wc9rkoJCRzvYX*hyQu&+wEtT))y(-_s_eyi0%J+)~52*Yg zy@Op~c=3i*+%{uICR;OIe6FLAmR%@l^NW-7wMfE9YVm}vq5QOUGp_0JK1{Q)*(M~L zRcQ_BomaCHS_iVYX7pl{j`nE_GxPeYP-6`9U)OdCx>bIN_kW4O_N)AD-pjQ8m_np^ zC&412#Xg$^DnHEMQE4yTqw)d%uFBtoRk+J3v&?oU0c(j4%}a(39S(||QXDUiw*sS{ zb7Fd*)}`+14bNn>E&97m56D&W?QMG*vl=T zszfm@yVBH9Q`Kn2$>R7>TGXT*lp(h}WAXNMZCB$s3S_ier$8GspzOa4^`T z$8Cwm6y^y2(h;+%5s5%aB&*`6?Nt5|zoGDtRsIRTsq#RJ1!^gI5!!oN`YJweAW`TZeFkEzjA{uO-8zke3&%pC2Ebt8(mY1t_`dr187fw%=* z&>!g&g+EmJH++rCzvbJJTaUdbp!OZ=k&s9Ax9H?g$wQuX+?VAu)XGw$mNYiXbN&fl z2%u`j5pyK{i6y0@Zv>`|nv`|Mo>Jm@s@9ID8PkrFxdHi1*9irq#CA>&8TE!M(Gcck zZhsbbf9A4hq}5JXIq!Nbpr_9=wVnqP2ie#Q+f&H+al5(>!byaVxZ`j)S135+Q!X-a zV21jRe(`qbztH1gUV5CHkjWnD3+V`th+uNts?tVil-7)xh2fE6KjSqOA1RGJ@FR6ai!Dla)07Lc!{0mbUCA>ZtVQb{Yu5Lb@iGav=c*e zj2~IvLn$-a5bL&aJ`8j?Y1ui%jG?}5tb085DfE&|?j@7vWiX)+E*oQvjJpHIrAWca zQB;Q5$&uPUNxRWs+m=j3Q??=TG;)*dLuCLz`mjZ0pa0iGn&GqTWRGr`qg%eBa(}O6 z^qP)`U613-Nqu>8FC&0Mh5T*@hgx_?R@NQ#K~uw6XO%$C?v@&(H-+_?X95Id3NfR!%5p#ZXaJ zwi3>GL2@>Vf8T1Xh z8B{{Fgl>U-eOOyYx6&QZYzFkalkUQ-xipi$iMIfK3#vkfyhm573Ne-!lKCiS%@^Cb!U^vzKO8hI9LA<}!bw|L&uIt_bJ)3ZdkzeMdj4 z=%?8=&~i@e0BJRfZ+}^^Fc=Ozdmk;BL`TDc!rQgq40O9yZHrnuPWOh}}vPXe*$x4KBQp=FoPUPZz;ZJLq(3gE=B} zE*Z3eI_P5RB$K-6Qo01tGXS)hW5Nz7crjMr3nS&xd9;-7qksD;C`xC{dM!NwBOzk2 z>Op!4QcR#-w2$_~tOb;$Z)1fYG@|q{eFtV;39bk57Qk~QeV4umH)R|65qdNYn5Qu! zP-`xOU2~f&pQO_mKAJX2^IHo_{LfHntFNNvFah1=M=)A}RI)ccTseB!_as&2P#QqK zEC5+(laSd4Xn%JBK0Q-zIiqQ_0}OWF4#FZiShZG6-qPwv$KsaO+{%{LK-e#; z)Z{)!O9W3#{fBAUaLmqioN@&iUPbwc$0>-&Frx8v2!DSL#IFbTZ*XEDfIbzmcm)K> zMwnuJ@U3(<#2O0l5}^G7CrGDIIXz29uznhF{+xrl8Sv@%@s=yXWfZJU`!NV= z;=P=V_uQUC==p(T+8^TYd3wQ3r~E#+fku|ufAn~8r=N08u<;bJNHgH6@Lj%8KgBZR%5|={q#9;G#>rb)K6>o z(dt2JZXKj`tulZ80G&TT8zfV-V8O;3Ma;LUwI=u?6@`_8%`Vi#!Ipm7vITiX62b+| z`)I1mb}L@<-Pa470lU&{=G#Xzm%)OI@Ny8k7b2qfBag`QapVyfY!^`x+IwLAdttHr zv4812fEf?bVnlrn=C4A`w;{rN5a(ATzOP42??uEsh$z?(IuFC%kK+AtSo#oRV-RpW z0wBH*;QbD;65nB~E zW2E;}TT^*Kdp|{T9-v(R0pEd4=oL6TjsQQ;(Nv&q8c-t|Om!)wd8;&@-gUw%M{dj0 zd>(|9g3aaSPCQiMVXXD7oK=BM;FK~4UKO(z0bc{;mks1j%Jm)C?UPu+)P=)BxPS5g z5)AY*SiOQ^coiml4Jqt(B>Y!s5fm4pmVjL`X1zzhgxKQ|9+J>~SaTZ8|0_r2x+FcDlAcYxT*5HMP8aUcJE%xBsgREtbm^x! zQ2N#&B>?g6))8X^bm;(DC;-BK>3>Rw0|R6W+*A8#oD2L^SUIxq=*_}(mvjc5w{Y;t zL1?rc8<^!Jb=!G{kPoFUx(+qbb)&Y(cQN`NO@!WIXg&`*RzSh72wI<@uK5!veS&=YPmV=5z#j9k-F`^Ffo->AoBb_T2SB$6V1ND?wuP-S z7QKo7A-#p%1eyZC8}a4N3jy4J02hBI%eG?tkKpBI+3V3KU@4yDM|II$UWuxrb(#Mz z8edWA)D%7Yj{XU-=tVrIMwfH{g7)8`_Fquc{1*zlze4E$&Oic0Ga?p4!TpYi#Zd7h zXP2Af?A<;9rilL8$*dU>Cw~U%&!Fy#*nl~ruu@iztt~iQlmr}tGaQDRJB9u=%}}9# zOWQ<&h_bC_b{P==3;jnrSgP@qS-Fy;yh*F>1eY`x|0i@EyEt%Si~kA(xr=Mk=^)?~ zBHpXra1Ug(3bw6_C_~ zq{IuQwMo&GQX35yO$BLd>?9e&&}1ggOfdWj-(AahU)z^aTuWD<{T==eb)QK{6DHD> zC0U$v_MUzD_TFdjnLq#j?GFI&qaooEJ{Iwbgo{Y?<&K0^+?B9~dz}1~pYBV@;4=xI zBRhVc(D$@*-6Y82$Z4=0(6$uQB3wKX12y-| zF!ySCk~Uhd&XR5-BWbbNOaa3k4;t5GsY5H-Oh(<-Dv5QamW-aFsd6=gioh~dq^Ii9 zf3{Mot80y#salo`DcCEUK5d>d-C-(21yO8+2O~Cvv3f+~MaLl3+EwNk=QO&D-52Mm zc5->HcZ;UHFuj}=?r*J8RGSDzJf`aAw6d<)Zgqcn?R@s>HhNC5_xlFqYHk(|)S{h? zdRYvm|LU?{y_Gr_UN^ltqiz<}dm67%f2_YwUgWl9yopJMvD0>Cyp0(dvzQU_jf{7Z z7xAr(Cm@YE{-l7Sh!TIIirAA;#=Zzm#sQv+sK}^7mtmkrcl@@D??6on85V3AbsX~L zdxi^L@ydu|fv(uO<`RYd8kzP=cSxnpa=ohRcKgaQ%)Dxx&^(Pi@>VC>&ty5nfB4CG zmG>3v1Qs>ye55bKBc#_d8U>Mqg!u4}itsOcrOvAM?(>XnKN zpZRrCzZvmr_c=|5tUABcWRHiEf64TG=Y}G^_`)oGKwJX<6Tx`b)A|-s3EHVQ5m@*I z>^U8Ln4)#SWri>f-nXs*F5?Oy2z)fS`)q5U<2%W`gZY-x8cF+UzZwht4&SbS!GS-w zE6^t790bX}KC_>td z4-b;!-v1)+1GML3+^>Tn2huTy88)sRLuU99Yjn84@B+SD!lV!!aWJ|Z2nBw^c$~>v^)aMDbm3*MW1EiF1R_ z0&#BQBR7Ay#?s^~Nhh9zC9=qEN(-_03rsi&Jv*beQp@v8o4%IS6mGlw%D+%c0|b-b z%o?(7<^l?|?b89n1pojy4wLY2FMoFvRTTav4Vg3<+7f8fau*7u32oF`Kw3d4w`wm) zYb!;BX)>mR(@dC5xQL4P>o4HNH|50#a0#r+S}vb_@Mri#)bC8DlSw9#E+2YkpUeLC zclQ4FY5x5C*WUoVfbU}1fdv_F#Sp?mJGSFuI~H+CSZ|BravbmAN*q_Aihp5AMlOy# zG#T&8D8$fF^;#B|F05-&ycgrw5R;WCiekqULrDzRg|{V!vJ6{BMS^UWY~3uDC3H?+ zQ*Wr*ime;jSON47MsjirTWJb$m1bC&Lqk&p<&ONi;kTxChMIg=nQl3&3xE2Rb9UY0Q2 z$j`J2*@C6!4K159^z68~vZ5CAlX_8`ae_E}V|lG)X*t!_@)9CrdQrEJNl2!A;U{d( zQkM*EbYNaWc-+iuB2|Q$uBcr`B~$@$ux9J9z(7e!*^8yKlW@BbHXK7`$0uVE1H2 zH}aZLz(%!H(u(;ht$$or3#?i;)$;ISFo-Beq>8|9UReX_AmKWOhk~f<%TR)MJz*H; zO@9K~QUh$jt=`rYZ>g6I&38o6NubtUoKE=qSE1|KTKkR!^|G!8PNW*7C(>~!^*^v2 zSm;3nWbx5&UVBwzed~Hm^XD+JUn;t z{Ardb_^wEZ>VNJF$UN7T-uE&lf~!=!V$^Wa`P6q_m6B+xIt7rUnkS|1RPd}2 z@?g{EXx*|=+pI3J_YAFA5E5nP|1!>c7uODAknOSp$^G-49{=JBgn}CwkF?ZREWRqvUjk)&x&H&l72$7)6}FhW67l#hn*1OnzjA zmoNf2)_+bMBJ;zv6@IHLN4)#JOzS97s<+B=CeCaS)E+novQ84k;yx#66=Z`Opb9d^ zwO4S=1$l#CK|)SvL?#}1_lh~o19VP1P(9US9#`3|OpU8p>G!xEcf!2NQG_|n6>+9L zy&3VfKp|hCA-ZRMoZH<%5>7M)+1LzZ*x}a<4=5S& zeT+>DX<;Q2o1b8dV|FKcXl5QGSqrz7Sq2LeWl1_&l3reQFLOFXuC-(hyWyi0VMMbh7#5}>MZ0~6OQU6`n>LjKkhGlS0I&B3_0DR@S+8U^d@<#3U<`3Oc(PNVN?A8 zIeZ`Cwx1eQdBInlF0VM#&2d=dA6wweH^s?#N*Qr+@xZ3$c>+o{KqJZ#vfezmu+Y z`UThyI@~;yt#(O&P7_fO{?4|ruq{v!D&7$*fnL}aM8G0iP%cthNRWtVIh z@fCak-vbj3Dv9x*iI3t#80YL3EEc+jkof1!oS8Y_nVFrLJwJbc{RSX`WeKg2n`wzl zXoD<~Y{-XU+!HY(;y%}mNf0qE;(>?>2|i3pknl*vV-YEThDPhPRtm)#deeqkkPD`= zUR33LQIn^Qtt~}gPiwlmq?jeuOp^74rfb$D!)(91`M(ync)h|dIk3Xuoi^50hBhw9 z>};*6=5uAONRp1UkynZe zWrJbd)sYwarf%%&CzL? zbG21HF*!G;b`?`S9@A-xp|kf1mAiWt)hq(Xi0Vwq=hadvG!~~S9j>D>2As~^v9zMR zsBH6psc}p|9b8Z?hQ7)nkzLzR^VZ?nN|A^q8db+adw0@!xqx=8oHO+{??PRpu3ofX z=NLS-E4-F@dFuVI)J4yNiXQsQx6ylm1p<7a5$A!x=NrxIPTI}U-b2(Mj(ma;jzst2 z`9OOCU9`4x9h*f1n}d(dBS^9!>Bt_JaTTzCIhsr)W4J-LIjHZ^1TWE4_#=eR@Lhd# ze4I@iZq(SeZQHhO+x9kT>||pn4I0~MW7}?QyGfIiujf7Ad;0BP_sm>_-QPU(>|D1b zzvqkm@M5<#6`FPdap4fnEMZ=gy4?gV(s1+w*|H^P+Ai98kB9Mai+JOP;Zy@XsYQSw^fpiHyLbu3IG1T86Z!@KKAfdGo!49$?3mmSy0S>eMrW^oozaGGaQRHyd$E*?v$f57Tg{zT{%a&-#v@hErQ-s6Cj~6Wm&*uYXI*LC z`vN|@Yt;!S<;bZmJ6Do@qznAGJg98ay?D{prIoiHZ-HyNk8OusvG8KRVy#yOE&@i| zgZ9gn!e;iSfrOui3Y1HnBh!ab(4qqzVL>J9F|t6x1widW&^n2xKZ=8W+q+{rU=YKu z`bkaUpawpbZvm5t30G#o1CqIta5sH-WFQ|Sxr^tSmNkaJ3g%1m#f2}%X#slZ4a-Us6`s8xBl{ z$y6!X4_Od;b_2a1`q0Uq}%$d znFOyqfAiO5NBqy{L?g~*Nhak3GTXAX4yw3)-U%}c#`_RC==pOzWz5XNhE_KGX~{yu z;FM|B^wSaknQuXmmifOS|K71`C7j16;2!gs-f&H^eyBKj&BZ8cd&VjcaG^d(QlNT+zvc3<{*SPw%@KslK~ez zQvna_4UaV+F9QT&TqKL^{#h1VR@Pqao#By$T6(f*IZ*vUj5wu!^H4L5AA%_)yR<`1 zB>IP~B)gP?KmbdOM_gwNGAB1IehUud`Q@FYdz=ZWlkS50f@+JMZn^55nw@1=HSU_v z#N7d;@zb+tOvO1v-IWTz7B(g4PBC_bn2Am zxZet7p#cB-z0v}k0B^qors1?K!<2+3)L)T#yP2_v1HxFC;68Mv1Om7W7Wj!VB z(tV<^XA$otS9eBw#9_@%yugh|xGkF@!%-q=Ec!`L2~pvMy#ocMT~|KQZn>CE&+9h2svjAxZ(1 zM*5}+JvRD&j%47IcvI>3B`Ed|5jUZGS^76P|2l6|sJA@pi@xxALM%IbP;h$`P)|al zM2F->=y;bK1S|1{RC{=$UH!4sE$m*9`&9sAkt%z3r;r{wtOeV<2Dk!MKQ~< zQjx)J9TCcEsD9KOJ2F}4jXzdj@wCe^hGO#T$POHY7xT>vqbNlk84qQbWcOpI!XrEP z%mnfR{h$sanmrDTCk&5g=w@^U;%|vG?X2!F8hJDamdt`gBv5;jFbINx>^&J%OjQ6f zxlX%BD_E8Eyqgq5bLnEfbKgM@GYi%%Vjqjr37b{p&m#)SXzok@c(}OuXl}9Jv^HKz zxqYQ0sKtS*s8jp&J9o5-D)B#&``vsHc383p7uE5> z$`Fs_V1j6GgX%e+Q&9dZ$*=n=N{$*2{ugnl3f@cc1&z>Q$ppbzOhW9lbekB@g$}Vn zY4zPWsAYV-^olYdP7=P-E%LX-yE=UEpnuW&%=KqblEAWdUoiwdzkp%oS1k5ETP0mY zBuZJQTO|YqFq^FJVe{Eb%cSMoWM`icEseC6wFCU z=-g#c6qNDIOypdocAb;&5V-^SG0(+mXrdyhHk^L*d>@WHJ`0WyY20FM7dCcSrYo`<;qK&94J zj+ve1+<*&))|8VdYXoHo#%LkInd@;cnUr4*rlY;!i%4GhB%v?jAopqMODq2S$94Hh z>f7U_{47OKqyODl*5gIT+RKLDR=~*RyZ$Z$$QwvDLG^8ZSal@KcwjVvBq@sASdCC(?QYMTUaCOtx{+v8;zLp|bENEjF`O9;n-o{C?6mtoK&n9W7US_Rg!$Wjt_kOc2ODAWeO2+~L zOQ`J>6yR2~=sw|y$!(O86_BYi9P96xUkYWpU zv}V7cZvTa?Vz{O3pi3M=WQMMOv!81mE0dqQqo8(t3jB%bxpg2Zr2 z!ql7Em~gvi!t`KVSnbk8_OB-lxTVjX@VUH*nK72@)MgxxKUeg?+y+HgOfyFjyRE$K z@&GZXwW^XFCl>7aDw1faquOB@tgAC5$^j;Msu_)*#O1!*MkfwSl-5Ffh6@Ezt`(%{ zZ0dAHc%H+WgsNgugt8X?1RL>YINwdyJUL`@yJCNzZRW>-b5qy0OCXgAbUnm1YJW4T z6YVOQDIJ*CJ`(AJmtZn(SL`Lh33m~fgaDjc;7f$ZcukXR8wBn1kX%mFN7s)|;Pcjd z0g}y&8>TK37b9F~;zqrRhRFSicg672u2B$Wxk+}-{7HA!5GCEDSWWEID{Rg+zZr2X z(44-*=gB>Z4$2JvMDNc2+@&YT+HJc0eJ~-!BuKg1G>Ij64vdcRnis=5)6_!=ITMf* zs>xSnCz@}`%c1DN<>djZzSlk3+40%Y2p5jVSOC^wkglOIvFaQM_k~w3^+GwR>QmiK zNcqsY99wvi6D)?vkeNJ3oOvaR3EeRd@0ot*DVkajSYz{t zr7|$>BJr=~7AYKzcKLcu9;3~(0=xjYBp_1C4EE8!WPWk`Mu5)esf_?u-p5d1@-9<) z2dWi)Rt`|tIMe18KMzQ{3f8S0xLFYe1B%_?)1^*Er2vcItJVvm@gh}CcREZVg<+G8 z=kcn_QF&TK9eU1(w}g>2Jq5Cr4vAgz9DyG5(orxrDrD(?b-$SIJC`vg%sT-3Y8FZ% zk&wwR7mWyFF5b*fZA&~xwqBEIyt%i&dYvbbi=5AqU$<4akS#;xB5}F*t?dh3P{@6s@P&oXq$0T^ zKJ6e^qlT+6#^vkc58&?TgnX^~O&|kpKu~x9p5~BG-=#ed#%?h?b6XowdH`Za1}|=o11Nf&*ZZ z!ktJm_+*zt{irVZ6FU&A{X>&52W^XUR1wAmtHWGDYqguVE^t0d@xp*)AjUhhETqcl zgCvWRF*4hfaUj+gzvq$2607U$0jz!xRFdmrGeu7fp96^R2K;0SaVpB}`eb<}_voxS zckv@Hb2o{}KvOi(5#skAVZ=hy>~KcgVjY#Np3^z)pSlLi7f}WxNaZH_$MS?%1adk4 zDzso)7V$r*bI=GlzP17~CsL>PaD#|yxm6ALV(NF_-}cLCh>DqGt_^Z`Dk5sd`gMI? zw}fnPvHR*H6%k!9-TGUS{e_gF0sX&ssP3ZO?u6fQzU=TLMjE+jzJ|H&c)gOoIbYdQ z-aV*}I^^dcm|
k~vc4Si$u1WkU#vL|)87^C2x+c19`M2U7zMo-vt3DUXx5A-7L5 zS5=K{dZ7EuWK>pnwG9q$ih;6&2I{%J86G~LNOv7;gw5^mVZ{dp6oanL4A&2nZ-2*y zLMb2SD@#kTf7XR?W(Y`od3sL*U6;rAn#CFj95208yfR`1_wK`bLi+nP$RoG?_(2W; z6=I|S4oY*%=tJ*bcpHltIMfmG^1<~`=J1Im`H_?1*i@Ou%spCIi{qIWm`-prPlH^) zZ2U-fqnA+SG+5i_WQ|8RMuqLBX69!A}IGE*el~|`qOZE+| z4tfJobJor(6}r9fuO)FJn$)A^6!e#bVmxa|#4SC@72F)7R?;}t=bX**&rwb*?yRaF z&23#h#l?45%m-af)EhI0si(Sygv6I)zS;|_m-Owvsx-%t@2wU|lwCgwBt|s1t^opu zjcwnsmIP!R>Dm;+sM9=Bw(8R0zr-C0+k1+*2R$tPP9|H#cfqDzVA+D&aJ?ibVG~|O zaiEMBkF}jT;M{4Q014v?Kt}Y$#AF-K>kfhkcCGa=2Lx|J#42iE zY$G1O{qV9^3(XkI^)+$-j?saj<_(`=I5|8GMGw;?OJ<8pZWHkhW@d!hMoBt)nk~f& zDq;^#2xWtcL-c_7mfGjS`16NPANl0$inei_8+lI}dg_b^;Vy|gPl)ZaC>o&7i6IxV zY2MEPziME{85Ao3(LrX|NAj8m9R2`6yxK2pQUY`Sg0fCUlm-K@*V=Eca-1Cg>+vn!Osc zRL7C-J4AnP;4iP2klYS*<{L#B+hTijP%8Y-&EBT zf=N?avic#gh9s8|$4ak0bzXs>eiEk;{2VVjuAm^DLYx+r7GrfV&I9CgJ0}wQ9spGv z(E&rwQYIp$D5zj_=cdrdeuE3ktUhk7%u;Gci>Z-}o#fH7u%ih0YR^L{)_fNA z;ojxl#~JOhMk~0}%Z8T)V77y2dC%D2$ArxHbIuVZnK?~0dv3uY-0R!kz6quMQh&_( zZ6z80tWl3cjsJiniBIv?TT_Ve_QJ3}pi>vT0ko^u#{!@FxL z?ZpS%%C3h zK986R>a@FOKwJHgK-Rfn6VT0~&t(*%i^Rj%OOlyZ3tzf)e^!kgHuS+dgwijpla-{< zd~R@DFukXn*mN9lLH3K~+ouK9T#JG_nIdgOGxRa#INRY|C|)I1GSO@-W7jjZ&QO@Y{nhbeH=zJ(w{4R%1|1tf+Vu)V&*Ga{hOq2ARb!2tYSGs zTO=Nz`yGGU618V$nj5=CG&~b-sA{#KA4xhlsR0Lg>LF>ksE%J;H6y2WFr6h5jWWP2 zVG@b;$Tv^T6XV|h=k75-C=2NMxZhTN+&{SfFtW}wn1B?GKL>E&#o~+#Cw9%Kzlh5y zYz(U~auoEWbt=6vtJuyEYo?FPQc^S78$1Bo=oL&7wa@B3R^>bHlmTA0y{dfkrrVUy zq}${NW&3biGi3yVel043%Le;v;44xC>jAoSy4G+rv6;$XQgG2SRUN&V#E-mT?UXu7 zF{>kh&LQU`7xs>iN16yN&kJRraOm2BXG5J;yHkunG`ko^sik&D*w}!ey6hX@1&g^S zV!*{RMX8H*YuIHgd|ACimg5L3{}g$@>43|r?gqyLgIa}-KAC-A?W08cQrKyR;{_|! zKIM`wAM711;FHMDGAXioRu^7|wqa(Rb7xS1QGNqw>lJP}KDJbtC61>-#V^K|Q(t4U zVfF5b)&?)*MgK0fuc;Q5Z26(_^l~a#4v}4XR>KBR6VrP89&1-wg^noziut>?;@>n6 zzU~a15xQl(3N4o1dxg(t1lxxY9l^r5ihvxPrwV{Uq zcE7Z>o?0B7dUJ2fl?VB?T|psMJ~Jh8VpVLZ$ZbRQ1qjA5<=4yO_fun$Lu|?RrZ`9* zU;1wz9&<>+(;oQa6%J;~909*a8zAW6zn)(+M7zQs?XbV8Klm4Cb-nyJwmmdAY#07u ztmeO2jL+#+<~dG-bb(X!_YcoFMtI@^s@&TW(gh{X$Y5CD=NhD_SGZylvSC562NWXg zq#0mygphTD7xy#J`lpDyEJ~&QMW=Z7&Q}l@GTp<9mLD+(i_xfuux5UtQ0-h|TM97` z1U45kei}DXC)wyd*Q6Y46-&DE|J;#IyhX#iERa+*j%nc~H0~Hm-yeNl3W~-M~rJH9|IxJjQz^hXs1)Z;oyn&HGT)}2@5qy9F6G5hvvtsop_ou zRLJY1i|ugJ?PC1(?PVA1Gi>hTE^HJoj+z)G1wH3Db+4oF)+3RkKb7wp9(nBjK+FoS8vh*A6g?Yg;>srB$nk_g&}0E z9s7C7V6D6@PUAjH;bK7|x`iM5oEU(s1jdTM=X)H&kOt7%S2$tQrv`YUWyZZW*X*Ex zV{ht9TR910@WAcgW;0`$9N^qw^{~KS=}sW_`CFL8{aom!Sn$FquX^banF!pED2Vq| zPscze&@wq1HkD2v;)OIpzID|ZKqH9OHpS*M`ZZ9!yLc`L|ML?-MZALcZNVe-cUW0eJZrZLG<{WwQ zO(#Zi%&EI|wUS5)F^YZHD2SZp9vO?GnafOSBk^_XLw8V3&i9z+7wx4dAhwzOPy)yu zMTAfs2h4_>!2Z$!!%6L@-gk4r9&{#1$hGb(qQa%wn{()Q5Cn{3YqNeQ%TORFyriQH z6y4w#)eZTbY}JS_`Vw}%8ym!i=SP+OOPrxZme9Auar{eUDe_~ZHHII}E%Gm)+CbQB z+b;+toLFC$qzPfdZBs4d^3U=@cjH5{&dI3Qlv!}5ga?wdgRUIO;zJS#3D(bzC3ha$ zQw1$KY2@hAQ=4f%yZBJRZd?TDe+koT?3I28|9kJYrAqMyew@-8pFS8ODxmWWB+xyR z2;jLES{xdsjKM&vX-!j)jw~u0Q4}cyl$2*C_r)76g4gjJxk!Dg`7x3O<#!DhNjca6 zNWPwEE>vwC?3;XH+48&0;&OU8ZHdnVO|G*wLvG--@6x8$PH!+VHDrospg(d*iVKy1 zvk2P@yHRf(F-DK-fVW)ON`oi!*dIBp0(=#~=|uNq^pQLb6l?7uRbIW|oj4K>g-9XAzWJ7+bcE_!Dh4v%w3@|tgg%-ux ztC>xt{Y~26UeMqO}p7xw25%&5$9|zJ)eGW}UjwoPPDMUBXH7D=)>XE<& zWpTaNtLAjVRC0HRy;9pJf@D$HWAxNI(`}f(xo-Rl(qs;%WW#Ty9;ANZKLd$Es<~5o zx$EIGDmrl%-`p$%2>buMtkylmg){O@ThKBKZ&Hbu?slLa@K{z?$n_^<6(axWVBV{dJ=%Y0oN;b!#>c{KHy6q zJb0~HEYIKz6>!WY=~-)ItI8!cX%_17A7D(NM&VuQrstOdz+ORw`JnPRngGI(@_#ra zKO?95@KQF;(yUSxHR-hy0M~m7X1Npf1|cp`yYO#Xr7|;CNO#&8uQ^s(q)QHEjf^Me zyyAi$j1==O(8sL(%CpRK$S<4Y47S?sp`1t9gP_t&0>F{X{0ZYtdA?+kQw8z|QFs9| z3iF_8IcR1Brst3YmLxIxI9-=VzS{1>(YL9op;Pe zy$N*3NkXwL(wXc>(G=wgwKPdnmc6&@R60b@Q1f)*V_P0CKpyQ=HcSd&tH~=qL?10n zXmPbJkO3*sG=le-UR>i86e3f9|G1Vu_QG*oZ9e;6R7j5zZXl~@d7@`r3t_MI$=Y_LtSeq53XGeM#&~Z14`QM^JO`t8y~59nFB3LeJg9cxg=c$_Skwj9N3RVA1kBB zHZqBxcZQKiPgsytB%rv{;*zyb$?C7#7iHrniQuKEg z`a;`#K*qkJBO?g}SPZPVG`SxLh3GOoGKVY}HbfukCOOy04`wtgN>Tk2!-}TWcFf9! zS=;i3MGlgZ+3v+ELA@8lm)uK_nFogMf#NCy`zoc)%XL1s3>ikshxm233!bgV9H-wK zm-2>hM;Tv1Fvoyx%U@dNcOCA%r2s=d-dcT5?oU_Maa%iHylGo=SAGb9;Xa~kDgxfk zrNn3l|`uS9~X@n)F`JGzOV_m0vT2^BhdEhCwT1MjQLq=Z%WPL8ky zh<$7al;de^DTIjC%A(OB%rhxNd1bE|l~Rv0$EQ`oyuelaRV>Sg=m%Kz1OUOZKVW1p zB2QeBX6FvFfK+Z4ghWruKvMz_*LuoZ4|?FI%w%iTaIRVuCs#&Y zD~6pyI*c69f&Y4a_soDe{h)rGlG+w=V3&V&#Ua9DO|P-IfX-wfd!dzb?GxKs3Y%D+ zcVSaaj_)}eSq^&b;z`tCCCh2%nKWO%$#|v7 znRs4Kw#)U!*PWOm&VW9`ThxYTCKTAE!Ai$d;q#A2sfv^iLhWl@z1@o%Yl)>YS5{Zi zhy#L$)VR1&3?`@LWwpCupJh?UB1)~P82h5Z8UY($pQeKpw|Z8igBZ0b&uF!_LdM*< zGk5!U9`_$7^6hf@uN)hOQ&Cu6C28NzB37JE#atQ$>}Mk1QUC?g)OET)Y3QtyyG{#p zQfKq1n(of+T1@rO3-X=C8vEd#ILt`ybM@~ieMOV`-_7PdvK1@>x@;-AyX=R&{l#?yG39Exib0J%xGbF3Q!kCB`=mAY6Z25(i$er!|viZ z#wm0i2TwW8>PhV=IR(~^GFC=rx3XlhTdZ4)zRO-9084Vz*$-nEVe3dUWUj-8t@o3Y zW6}0fhuRse$>8ej>POBf2kiz;;Y+#fCAj5JvGslu838n8kfo{M7MSp^IcZpXm;f71lz~33@d>YY5`g z>(3~&m<8-v(J1WuoA`eDYL(|BTx(njWiZ!b9wRbDqPJ}swg%Oc;&wX=A(KwKbz**_y(u#F zVJYw7k3yA6i>TZA5$8BNCRNf@I+UOkbGPmjU%N)8#U4VLg3EE2B->9p7*S_GLTF;5D}}W0n%C;G+i(?$@%lt)pNJq=WnG=_ ztR4YqE*uqn;RD$pt?QQ(YR}lnNmY7BmXUF1>9FQD78b(#Lu_;ewhJ;GzVSwvm1<~R zwmL6V%ZmNlGZkY@{2hj$5Gcl&G8TbnVYjm{6Q#j{5vI?mMO~!h&Mfv+{b zCVwfKc?rF_a5!=4An_W`q2U8AYt~-z|SSp+ zq3=e6P}NrI*iOF4+ojHwc@I>>j%`Ck2?&Mp8^kXtMl&LR(IIR_?cscvi)G`oe!xYZ z$xs{DNE<&2D{DL5!t(*k>qZZ+j@J&5jA^9h7&x2|uE8;1!$y{9UATO9MjvN+mAMyN zq{)k)>D?Pc5%n03Dlh<7fwhR;3Ys^whZn|A8gF}}pn>uN!AD6`$Bhf~h~*_t2E&G4 zP}n748FJ7sN-#hm5TgyHMnCzgZne^P5z0Z7RjYW#@tjH$Pa~m7yViDalhXxA;|QU7 zj3PMJxxX;L*bn1pRGKbBJ3#fjVxuI_yb|p47eyKB&{d+`+F;rYrpSA3XT_lwoGcDF z-uvmkP7qjs&;LNl^zGM2grbq30S`4GDMO`RG+n_gt)lMtSuUZB-6FI^TbGI> zU|6uVd`7aF2AYALgtXq-h>A^sord+A?)4SENKCUGzJ>m@-hl_3(A_5EXjIuv1DHUa z1B-PVxS<+U9=~z#Xb)nOcjF$&QM@`M%jA>}kAhDx<8PiGv9T1YOXY>EX>X1l?cYA~ zf`sjwL91?)ip+7>{5}_)dBQk9Qt6q9eQX*6@@T0q?yUk9Rcta$dOfiKXm6=@-%gP* zpGW$Vf#*bwm z@qu&Qzw6!%EQm_;3e$y2GrRj!+sbpd94MC4V#;gy1QeE4y>|}>y7^|zN@)lZuwom< z$;v=5my>DOa8m+v9T)fjIXkI-j*&T_n4WX{+gNEM^90ck_l|I7Zg6Y`A{)OoHW{*8 zZ-6+wkUFYHY<^QyeYm~b@j*nX(TZPYxsGgfI4)jM6Z2v}$B8ZJUB_ut-#2L0w2v{l zU5}7=?QPlJuU(7~ZP;_Bc=^+k;G}*2-4LvR_VZdVhY0UAoA-DZ@T$-3t1&4b1Y<04 zOBD)Sr}bn1$cD7t&E1r_eV`C{LYdJq5`A-{RAlF=+EGX*R=xJyXkDf%=7ImT^oqTD z;LPsqTfWEHv2J9IW>MehO=92X8FQ6$;(B%x7l&BpFD@vS;<>1BQ%$R1B}K^j@p!sW za|_*9f$}pQuL)}=5btxtKI;daU#9$3LFBdvSmh_Ke=2t4AR=A#Zs6A(P`nVA zrF3fGyKx_AsuKorM*J|d5edvHo55tBBawwwZV+n?e=*uw2aH`CzFi+oex;dr!tWBvQ45pBvV8f zMyekDtbEENI)FAugpWsHczp!=K$Iq&tw^^IQ@xK8<(!UrrW0F^{hV)rjA|6ZuUDIP zA0^`+67%JQ1Saf3(skxm{6X(M|p~|JpP$QL?MOI>Lq(w1{oiZ zd+1T>Z=JQK$SF~+uE-j;{AGg3@bHDdh+)43CAX=6;sTWIXJQ%|II2{;>YSUT_L?Mk``d7FWGO`$Kifh2U%3c8d2wJ6Z$+Gd8aDgPEarL5lWe%oUng~Hbse$ zFE3XZBQJ|3E3_7*%K8Up_Ltk|by&2uS}d%5B8OJgH6290bT7VZ5YKHI{fO^w>=eqTfbpD7| z{@%yZI-~B`Kp)Vw(Tb zZ<7LcZ21+K)=2y1COE3k)mvFYC?--E7Nkx)b9s#tYli*ODRlNeB0Sc}E-aSuU=P~x zEPLj}Kfm}cFsH)mmJ=}dRGyHh&eMdH;r1Vc4{cUrPmDa@aUP|C1hA$(HAR>anAK*m zY!0S7Siz@s^WoIAje}Fs^0N6vJROoOr)~qFk2}-DR0j{48P?^aO!)hnG}6t6#?9oU zO%4@fmX~pi4*+;mvutJ3JakeHRDt2LYlPSKMf`y%@Uix~3#X>S4Zu+HO$L3IL#Mq8YYa(gYMnW)DsYz;D|Io~r zIyLp0zRM;xb`-8}*}P#bJWpGrb>#&>KWTUSEml+Hl(>01e_w;fZ?cp|0-~!bbPfNj zzs{b+W|4UK_40 ~_}l>Ca+$`dV){ooyj2#rDUJt`%!LdAse0E@ z{P9F1a^4z-B=*HW&lxMJ`cW&LF+jD7?HQ*6p|`&J$ChrzUGDOf9A;7X+!l@Pm$_X9 zPt--W!(UCs`*I`i@2-R)1ZIvmjqR9-nsJ%DO1yry%c7Yv{K%p~3pZ&vxW%^bw$IZU zOjHjYe1je+j=--?`uJ0$w=OLeARyPJkx^F26Z`e+p-|ENt5k5g+oDqI!7z7b>a|*G zadlvN!*gyBxj!Q_zG$RMW4)!neGWKM(C008Q5YHRslq zC7c@eErxyHr<;inWu^~HZ;VFZ{2ttXY4!~0%05#tOw$~Ckh()2t=%~}yXU`YL9Br0 zZhy8%68KsvsJo)?;oej_skfKohW%0z)hTxpz*+w*sY}`!qGJt~Nfz^S%{}xuNn=Bw zio|B(>Lq^1I|TiHMzx4L5kPkKE~dC`Qtn5$3xtP5`8~eqx3*EpJo(pLy&Oi1nyR!G z+E5TD_1HkelVu8UClkm`%A)UmlaE|?6HY72o#BkHglTSqo>lQyyY_NS51Y~^9A$7<<4X#DTLVy6olN{S6!y>| zuAH78_m=8XzedH})E*|X1U$^fToxj|7eFLE3+cG-X1EP<9$$>V@B7xv@0e%4ZXMG} z<#d5(GZXkh)}=Y05qw^{CC5Y$i#Of^))Ka?eV(~|RW0!$uzEMkyZe6BWa3C$U>{$l z4L%g@gA(Nuvcg7HKBx2kB62LG?zmmf3z`^ka%2gnU}iuK<O3&YwodF({ys4jPbQj1~++|DP%$P!wSG zm@=p{@O_LQG!Mu>E{^|i00j^bzJKTVkZ7%e0^>M9Lu+!N^T!&F$8o`??16Q2_&{6- zEFkv;EtrMlpW^2UBK&_{qd(G<{x!^i(;pDBGyF#%WZ>-tF4(xoM-?gX%mW(8Gl`7< z$M5dL-C`8xf0xke`3HD42?^Zv!~i->A>;q$P4w493cmk<$?*Sm-~a*P{|h7<@CRfX zfd6N-|F!h~7aJDz2iP&iiT|&uE(nOgzlaZsD&!A{X`12FA44Xf$utI-N%Wt}%xQZ3 zKgJ;+bZPmAqW$llMsa^YPBTzIKs+W;ei|A7FRlDv)2Jo>1E#|Nk3zE)6a=K?OKSisb&&$8=9$5q zIzB|kKiej49v94`8>sPv|IcQ8|0v4*0OBoJfZ_K7U;9YtmE}Oe&_U2Yv=jd~tHl3* VDq;V%ActPy)B-K!aPNO={|_wF6(axu delta 31066 zcmV)4K+3M=RTa&PMoyvUF?Px2~O;$Eosx%y_>d4kF-sjwr-l9 z>5(S=-rGZ~)kbv+=*>I+>;3=t|L;BV`EPydGXQppiv|+7VPF`4FV(R3Y1w>6HZRNO z6}kEgIzDUQ7x7CPe%XM5n+86IUor5j_`Ga>P15|jY<|PQ9e7p4Z)*5015NmC17ZA* zf#1dN$>rad%^&Faf`LE8AIavAW%ES?U&5al_*49uZ2r84s=ln_FAV%8{z}7Fbo{k} zt@xWD)Sr>4j;|Vj_*?v4E&d*_8Tbc$O~;I!`9~?~>vHDn8vaQd^Ut#R7uo!)Z2nC) z|1O(v$mTz!LI0`azYLtjf9v?Bj{ni{Ed%@Ul8$flE4bZ+5VBWAABk!MM@2vvK|_Ru zrVCvYHFC<(MXfGO4R6y#ogwN)gDx5=RjkoOSQAaUSgVVFW=*u{Vx56;v0fJuU2KqY zH_{Sui!L_lVzVx8)kRbnTXb=oF1AVm+cdFV6Sr$(hX4f3LC3MZ{*;wY+i8LDsOMf@ z=*{@Ew&N$KEZ_A6>PN>;92pyk#UAQEIzDn-Knx1h^}9~mw;X@MN@eV7=|_RuzVX9{ z2gV+X4W1c);M9&rfl$hwnXxHlDVKGnYl^ZJ7rC#)Lz^vD>Y$xNjc6> z2K?D1UA<{FlWC&6s%78Jc3Euktv&&JS++N)(iS$HXjliv~IXRB)caM(^ z=A|ax?!(EHtt4tzA|Xv7hL)2ODhWI7C!M_P`sKU~_`u~UdtNS*xv`*g(D7~0u~IZ9 z1-IJds&+HJKugis6B&O#A4Lhbe=t(qPFhb8tF}25f^B+ z+|XNI3rt9*e&j6`6*;YpGsLfQJP)Ms?rKkx+GQXk9Q* zG`~}MUK9IFai7?4iUZ<)Qydh%n&>k{zc{3c0aF|nM@(^48uo5^z||&Y9q=-L^S+(X z#4%GG7efL~#ne4fgqlF4;DP8RD;+Ii?2>koP40cz6eHqRd7PxY{cWh*E zbucG$&HdJdPK!Ln&64z zB_}hIrYky{vRNJ^TRO?)iDrrlV_n3YROfohNAvY)T{+_WGRc%m#!${Y=^bM8qj=5~ zlX90+B4G+!OtYRy-Y%+5b@i!=q=^|*%nDXYW2w}zh?ixxDb9-vdE}ITvTrML)aOdg zDK}?RUR7zq(L~A=bAmevj-NW*Nr1Uxei>bXwW&fC5{Sy#%Uze}QeBftC((7t@-2U1 z-ew7A0MtpdW}X84oN0YL61@f1%OzoBJdl!ec8Sb$1-MCvSBOnIdMWA8t`hrXI_kK7 zG@Y5BcWFZ+%DDv=jOej{iD3oVM_9UYN#2!Da+yXvZkA7u<_n#Soo9-)OgL4!x-RDH zn3*5t>r+E+IJY#Tx#_N4*)-T&Hf^a&wsCv9dwV+Cx;?#5{o7g6HH9xSBw3{vBmbN^!8j`xXmTEg{K5NICw3Iy_c?RiF;wmZFZbtGAK1 z{X_P&l}Yj3*jRE7Eu&L1%+mVE{F7E#9%*vp#=@bqbjJ$KT}ULow7S`yA-;W=SA!DD zrEAri)|Gd=NNeS5(2^~Aer6e+;q;f>F*cN`SawHhsk}l&(ivm+BN<*Cm;Ae-Wcf`@USRr{Ul8e|!P4?yDk$KoJ7uu-Y@Z}5!NjRqFMr+4crq4+ z@$xG`ZkBrMlIg*v!=v=3I4Vm-(Y~e%)6}o(2)QcV(`3ZH<9mWwkVA(m?9PpsFTOHGJ73ogJb$vvOQ~Nx*yKLdp(s7Qv;6+M zFP9!AcVU@-;48?A*W~7k3-r4TY+lXw|HIgVVi~K#)&F1xp0g`>N~NrLOsxM-YxHl@ zx#(UXB<`)?-?J55Ug`NE9oe_w%ior?RNA3@XSS`59p<}xNhObZcDMGg7DI{3rMF0E z+V$ovzibN?JXK)}c`9r{0>con5yA$X#|8FN0ID#5$FWl~b`h3O1op%7m7u!%l zzXoY9;WFC=j>Zv0fZv+7cG1zf2=Rgv^Qa=MVjG1{_20u@TaFOli|bA~n2((24*AQ&$xP}lHv?aZpp|RacZQCes zJL++NJJw{Pbw&PgoVvbku>X0^>K)$^1svL~$yaF#Enyj6#lmB8AtejPP8 zQGWwQTr8sYI?N?o>J@(neb9*}bSvFvjxVoU;BmZ()H!EXEBc0xEb6kTKi$^ev51Cp zad%SOUF`2x;-Wd0;#L~)1m3JvG~fz;fSf;n$bNt`W9&a!P*!!ESZJjFI^N`Zg6-GQ zn8li&&<%v+H_#NP;30@dNxEOwq&llI`$ae(-Lx}Whq$e{FMANu&WAA=acC=n9F5lrAHlW&lT zc8th6P6Q1zAR~ARC-5|>K8}<4X@=(KN&Q(;zlu1%fHU|K&f?2Bhp*s4S`o)LIQLDQ z6?_YbARZJZEEWDYqmH(`g16v@7|=WMVZ4=C)u{0bei&~fR32u6znv*wLv4?LQSSw2 zW{kY=z&lY(jhDH%cTx(WPyi8oc@VLe15uTz#k=tyf^9p#iudAugj7)Ict1Wse=I>v zm+$*Lo{v+f1mcz(xFg<{#V*0-PX64*pWXbqn?HLNvG;1x%^}5bz9dn$;6pS8MHL?= zB_I2F70=}B&w;k~Mcgye`8foCUI^dYPF-2_JPlKYdmqEy5x(yR_Qw}-Abfuo2isVy zdil+wk2o$b9uDnr>85!)$iq51G|J%ZXJJ?>WCw~Fcc7SY2k8kY731J)WwLi^F-R?MA;L>mvqqsjQo01e2n<6 zCiPbQD0>0UtjCYxc?Ru&Jl&d`dxC-far^{(G3M1zvL_4LQ$_barCiBln0kMTxk4<; z--6`p@LM>N;n)>^1MBc`IL>yY<0fupR&UHloauhBu_uc&owru5S#vEEfQW|u-EPi3^@=hUHPG9j+2SXas4KjqDT`XXgYB%KRCK!b+D z=ag{|O5?&0vF!)*R_qlM(-f+De!i zdrfU6f-qqj!_s2g0IEr8CcpRk;d=eMbFs zI)CDLPQ#3jBuZ-Yyjs1`ju+MZC3W(W8ZN5gWi?nDX4_F#%ZiR(NS&rGX_#xrypA18 zd0hxNb(kErT{}1~kVqE_nQ4J|-m6ftr)azKY@<3W{gO57NafEf zTh6rQ+iKrBj0f{Jtz?UyKbM{Jt%@VFSADBilYaK(wX)Nw+gIec?Z~lmS=Q?lmVax_ zNuNNIR(K#VmX6}Ey{wWOiFS>^cCuy9EjN5$x zeVrwewZJB4NR=sj&b5MuPyLC}Qf_0SkAJLEMNTptne90ll*q&h+i?_M+R_ zoRxXUtIKB_whSDmtN($I@FFTYd6^_SPhs1!3fKyM`sgSx%L_cRi4lf7<$pE&a;xC` z9!}3;rEFjr*9{!PVFN=rEMTmT-N4uJiom1mpWumx?Np?1;2Zd+fmiV@5^2~eFBtf? zIvBlG;5a1vRPSXn0d+b zO~pI&5^)F#Cg82VW4gpX`JS3`9GZuy1o6f9%=o&@NT7OkuZck@6>#0fQ z->nc;dgJv*jTQw|X9&FLNZ`PxPiKuG#qsI_>l(d}=fk#U*8^@l?fR;Y(nG*wvvtpD z1ai^}=J_Nx14er~CG*SeWMDbEEgH(6Ed`jXz+Wte?RD=%t+g8Ls*;rE$r|P_QFo-Q z@kOLhD|EZlg{`u;XMfA?LMv>2&ibOQd=hp(92~>&r6aAnT!V6Iu^z}OtL9p+r>M^c zwV{hJh_KCIfM4^+`K@k43Tb2@FvwjDI{H-4;JQz>4bE}i4I|6(2zN7-X;a_$!P^jn zyFNf{aQ6pjdp}e@8mh%P4shI$4je!?4&n)(n2{Qu#HXSk34fs*5w4V@7}uZ1XDCHC zu?iCC0>o2Gh|e5qBC&+z%x!2~wl~qyr*mkc^EQmLL%hw!Q}HIcZsMq#yWd5pntN_y zUvhE}IL@pt6Nrtk0@DGUHu#RaW*OBV@E5_7WzxL)W99zPUnW4V^ z+jumWNF|zhEPt0wC7Vcvg7^QCO5VZFRDuIdwB5LaUGLrhvobNX+VyVwR4$s>)3=xF zLu+6hzKeYVIX%S#Gc-t4p-lpO;2@>{KG(UqOy|9vu}aXm$Nc{bABrC4ut#iDGb$n` zGU5J^nwe=;uh&>BkP7=r14V?VS(les5sO8yP@=}_)qh#DS6Q7mSf96W47c!E{2Dp@ z1|#?_M$x3!62|E9BtFC`{2K-Qhwb~nID`8riWtrb4U3cHy+x%jSN7cNyLt z!DPsh7s;3!?$X0k(CD>EKRKR}2g|(SYJ?s|xcVH9lQ;Wm^Yc7wLt69_$*B5Wi+>W& z39_hyzkef-XZU;dB-M=-&2eg;YSH@>_(I6v0{{8ZX;J-&@D6CdgMsbXU;W(*$CKgt zg%Gn5$+Yn4>J!w`e}Qu>d@6rI*Wg_o6nGEu;`=;~Q?QF}BXj*ogfA;j6`jfNVj{Zn za%jGvGTofd;#}*oOyXIU2b>S#O#L5FO9KQH0Fx5N7_+D!mjVvAiD2uZ3IG5q7ytk& z0F#l%ER%U64Szh44Mv0^2;c=)7)gjtNFCdN!2`UAAqhF;!xoWrMmjN?)sb{0ZQ9bA zv`u%@bdt1{-8c#9Oq=d>@4eE!_xQiNvn)%8@vlGN>E8Fg{eAEIzQ>dQdH68^o5U6s zJ8-v(&3K7iUMiQDDLA8|NP>&-as{vO-I->hOM-XeLvRW5In%iC4lk9R0|K*2lxc$WmdTg3{zN5Okltj7CP zEXP>|52{!zx!jM36ujS$52&cc2UTP+A-^W&@*%lA?8lTJkErnDQMrFi!8sL=8O;d{+{GPsR7~1G)TA#gFh~6+gjG75q%a z0Ddk|v#YPQy{qH!V1Gy7;oZI69fy1O4RrSQ2!8~+j_D`#a7<5(hWo8#G%?yDP}XK9 zQkI^uhV)q45C|2Jw|5M*c6N2NXZcjQDEkLHI|j1Q<+Gp#M8(^qiKw+hU}0VTkbtkv z9HF#|u4uyONym>E$pQUH%#cc&5j{4fC!=!j0)5t4G$pXU%S?`jN0a(U%m|-M>f_@^ zGJm|w-X3sv-Fh@ZqkM7x3M{ERRA{m-T~CgZUzNwPfa-GIqbCK*9gL_M-WiPxmI*>^>WZj7lPA;shBMfmv%b52C3|B zGfq2;W9I0nRQ4jTD0JC}q^oct9jA;)+A@j1)(ii@Y%J;aj#Ck1+MFtVWF+4Q0;}p~ zM`QL*23B>%I2y0aL$A+|On+PX zolO}RRl3p@Gh`%FHb(WdjJ&IO!a;EE164^HDKnjn7_BMd7q|oq7{7S*EHT(v@CC+hyqT}hP zL7#2;KdzvL-{JQf{(wI!_>+b|<1b9AnG3aBPmOi!;~M^oziIe8{-Gg-J2jlfGc{Pa zOTj-i{0sjUSmxorPFa^@F`a-rll-yWPJK9-8NPTv4E+Tn;taRp=_Edi<0d^MffyPB#Jem zFrvaw)kFzyXBoMc;ZCj zi5jt#PMhPt(%&=r(w9zH(SNv+J(Ow$6|qbc7fF46M`@-emWvevJKFR_!n8so2Hg>7 zB7`C_J(U`#XG2HLWXM%F#Lf{qnl$5~2%FpyJ!OPy*QIKkW~FKGkz+>0(!@%!N=giA zVzm?(4BIz(W74_GvwXBhT+Gn+m?0Y_)l6tdj53!heaxigYg4dvTx@oMftDjHfEjC?! zFZUb|=3vn~T}S6AOMksC^U^Ur)tVel$Bl$_A=R>cE(WqhNcEzRB9jkCqP~162;OcoaiX1Mij4kzfdpSgCu6UsFkSdPPiNJ5 zTYzHNR?zfAUislE!s$DnXI_25mUFS^XqNAS1`n3`eRelfB__w8D(2vYXTZV?vU68Y z^4>WyFUjs@vox$8T@Hs@(io5Fawtirc(AQ*USaea+iK@WO7kmbplz~oI5yHci>-ha zpxt!dEo-K4TYrkNOGd5J;d~s5T{$;~;|KZ5a)vKH&NZzc!ftW4tdac1#+tVUZd=;S?|~`)4VY~&N$Q^tRKQ^Y{m`%J_Ip@10060;cfv+xF62h ztK1*V*?*UDe<){PP6{C(FkG)EBn&xN14RuJ5D(fYhq)Hpz?HaxtL7j;#}WRPAc7HM zkyxCexKhF%pTvT$#z`#f=Hly_LecO9ikp2wUk1v7ps(mr_=gt;O8SR=0kuDa(hRg2 zaG3;`OYngyRFJZ=xhPm9X%_{34H*QQiziXltbYU*LW`$RO_aqMEXklI$djeb{-A&3 zB!Y6Ythr>vBra-JgKEPRmJbI@rm%u*VC5uMO&~Od)x$ym1lCO8;wh{pr*#>upRs!n z0$kV8&Fg7tE!|a*8Z=-98nG1{up3R-Pp4gjP4vwc7=)g}Ww;I7a0i<4B5cPQT#0jN zwSRp#?)ZmzNA2J}!e`?c{aJzuMENBH@(>@8V^~Nz58y_`h_xRk;z-cvH}H>1F2&?< z2*;6xLRqaGKF8pvw5@!crOE9K^*Vu*jK?WkjzBlR`FeB193ig-{H>)Yr%*fG5U86# z{Uqq#8W+@<1DbJ2ITZuiQH2h=WT$P^5`TvkZlV&fzmC~Psq!W43cS?Kt5ULSbpD>r z%dXCx>?*bW0i>#tB?;jxw49Eg5XT7fU5DaHa22>=<6y&_9W*CV%jZ zbFMP26S(@UEvu5gx!l!cC1n8pgbfiofNBgfbq+9zuHo%HnDt&YLv|aUMfyr6&9m_w z!u|49?CSb7Ls-P$A?g}v%bDs-|PF?!3AyAURzI#yZBr7-jGw72(pG5ym&5>AvmY%C2o45qADSH#008VM z001BWlaa<1lTI}ee^lkQKPNMpJDFS{1VR|r5s73EI~ouTNs!nOkgymK@g{SVT$v@_ zxkD1`Rv%Vc?MB^g#T{yC6_o^yif!GswpOdHwY9d^_OQD0~$YF{w?lm~Pfbv_wKrFa;YLSJ!Q7-ngTosdeLqrd69ZHmz&f zvA%BOe;TI3=1a9*T1`ZYb=9<5rV;B}&NQw*9!pqS%-XC)lF;R9CSN4p)uo$E)0^XF zS523xg(G@Ruc`I)=w?l`J&2Y5aJ)AbiECk|S#A@X8dBrJrAM>6>mXvZJtCCnxGh+p zJqL@X>3toMWWv~`uQnojT}OwWNUYUjnk`$6e;b9y<1PR>-wGpUSSy(>F8u_(K3S6! zi(R&v$y*-}>r4}xjhNn&jJE6MMh%1Ffp~`&*{qp{e5X3SR<{Aq&2Z%`zKKL2eW1hC zHA`lc=#g*O5;)O&WLZMt&%rGi>_|pn-YkLVl#ZlQ<`zAkZoQ9*4g591 zlbtsCoG3zKrZYXEcO*^2>aSS~ECPrPe@2&{uw-SYIK3#tqbb&tv_Mzaq8MeE!PlPb z>=dZyY+HqBYww5mHA`d415-x=rm173T4k>SjTv3KRTm3y)=i_cKigIt;&EVT{wV#% zsy7BY#o4}X&=Vb|(c`$x8#YX+Q{b$?c%-J;u=SiW67u~$Y1oHG&0R5)+e%rxf6I|Q z6@B&HddJR$_-0AzSZPnF4FXe%I$nScwGJz(MQl&!CE`i5L$~pqulM!n9hM%pNBj{7 zQcx}A4u@=2y_#vxMUZS8Z8vX3k6|FkK$F*Mbj36)Y3gHLFq)=|Nv0-rtFaHDvc!t( zbu(%t5&~p|(r9X%g=Hdx5%fFQf6&7lbS>=U#Do=&C#?(+ZPu&fW>m8*dxAHD90oc) z?a0SjMqO{lCA+Rl8WD#Q_B5I_c7lxPBXGVh6MV}vAh1_7#lX@`_Q3erQvyyRSQC$e z&N%0zJ|2x~F+`b)6>)QI#;ZnRixI=V1g$-#Wm}1B%afjiqcy%RL3r2_5mC{;V9t zR9)(to7|;xum)>+Y&3Zye`2|SW?OXb{Q2{lnq9Z7^!|3rsVJv!zBCJ@SvbsUfv|Gl z9n-8__q$9{lP0uK2(37ELfJ)6n%1Hd(>h^pNz+;^w5m>p*4E+0OJwl{C$acc^J-4t zqG2veh0F3&c6WBPq)9D1Wo>0~tDVjr#H*=!)iO<`=jeHr-lt!ye>6aYD*cRpuF_NV zv`W{~Kd5vKeNLr^=@FIo@U>ukN)@Io0*%kp^(yVA>lEIt@^$=qm9OVL3V%U9zNqpI ze51-=;v2C&A781t3xwF0RsITp6)I$Fh-hwIQ&)u|Md7chyqCX@sLq~{6{{dZ&ntYB z$~W^ZD&NYtseC)%e}UBEUNb0sr^?^pZ>oG3?^F41zDJsSRlZL&xL@T5=xyu*!;3d0 zW0n!sGufKylJjhZLfM5vXkJNTUML*b6QNk#3ZeY8G$R($V*QwAVzZ4)0;>)+rgq+t z6%TbHi-+_+Y|@eb(1Ogo{%X`1!~EB^Uy5#(ALRXFumdW8e~b4qZ9lFMDc%XNh=-z| zP6Cx5;%}?8kM36aAb&^Y@4_nFZI@X_hn;gn@y?K&44oPr6h5saRuXFiMqTGbwf<1I zwo4DS>v}9?Y0)0putU9u)m>c@vkP)F8nU`I3ymI{=UQ&h3-y?BEVTMVuynuha*$S) zLRxid9BPN8e`pOE2^hx|9pRX;ED32QL`!8eV8mvZS{~{&1|dP==iDjKw=rwOy_4D3A%&*#+8|0hJ#XG(Mv8A%0Zh$5eh? z9DkSxuvHJI%{tT6`XzU&JV$8Q^n!T@3K!jV=BMEFN#zzN%Qgu3uUT2m0#gKC@91q5=*b9 zr;V)Ee^h==rp@}~f{m%XKAwz(?NCpgKtXKP>m$0B5S)eN6f7|brz7HwP8);0TFjDY zOk$4UFBLJHnve*Tc%nLn+D_#k^6Lu!NaY{%8!G>V-^5t2QwFO17XMV`xA`5^psux# zO26lyDg1Ml-xYNHg5OJ9dQ6R`@-N|I{*_>7f5vEMtQ%3hP0dcp*+b%o_r)#Pg8oDw zEBt}Vzu{|D{w?2z+y0kv`}nv`|Mo?PmBst%nRb;dHnOo7b|jJUV^&Q)gp&vzamV3ou269LCtPIUzzp?m z{bC)^e}T)vyzB%wA(LFv7t#?PVZr3KRb@@kDA^O%EGd7`;lR`vPKn?xEt4CPi6b+U zeM^{c#n%j9mK2pXx#G=-<4Tv+ZO4J|e-b;(>2i8${n+`L`<2S$>*_Y$Z^hGcj2~Iv zLn$NC811oeKJ<0kY1ux+jG?}5tb1JbDRPrc?j;k(0G zqw3r@lP7mk~hQ*B)hKE?n}BL_@k@g9us}&OH6Z_g!F70G;Z!SUiSOF5)OPrPSpH zz|NOIy=hxA+mOQ-9}~xP%EqJ_7PemdSaVYFNnfx8k9%yD^LAWdWrt!`3>9Z(tC9DM zQ{4~uqSd6~q0}{z^!gM%rQ4gk}oqCHj+Kor%F|(Gfv7R%hNb>0!UJ~ z+)!<5&HRTWYhbyZ1DfN#NSr7%hIwSqapj?)g3$Zcbsi_2n(Vu=gyVkKE23a&wh2aF z$rQN`Af&pr#M-#2H%9a*GBW^^AJhA+)aU38GZV84%;;Qm`Jy|WtJvVMe;dc#)YN3# zV8kud@$fR)jh0lvk+>K&w-=dRr_-pP%7`eJf^-F4NlaJaD~GP8LOEOGy-*I?_7g{B z`-$^1o|7Cp2Ix)ZbJ&k6kHq2Ssf zn$}h^NYh(9OT7~d=qZ0~Zjm=k9}Ax187m(gq=|E60E)lM#`h}X$jp+_mN+ef6kcoI=UZ5Ld0Oz1N0!I zm_WN|KOKNs3n@Y0!U`{FMCc*00; z=C)KlL1!?0G7;L{Cf<&3%*> z3!avEkI>TLn4M!g)3@%`BVXO;GD*_~sTWrCSl! zw?W`rf9M>Dl@9Pyp#6S3NGDSTJwr#aekySOtc|+q@agyPmMg+#6s$}6(GP0ky_}5q zoSwtz`Mz!1AK>pfdfrK={2sXEq5mTw>TKkSLqk;DR#CWekj`1lEkkr}o9}6=Yx5MY zg6j(F;W+rOp>>cNo&2^M`3E^xQ{njo^cit99s|@oKx_BY>LF@r z8=`e>GJpLbT`))+BvZ6v!Nyue%(tnn*8c((2bIFj4%CDG)&bhG1$jjh!i6pSX^O*k zD_--R*Na*JyRvNN+eb5(!NQC2atOK?A)*f;kI3^eD-SQ ze-F|kM13vhuR_eXBf@(T=hq;W+2yi?KAif9S z{SL4a-}V5Uy@d&7qIM;Xt5L_e`TKZ)MN@13@We{axRHnel(GAp%lZpD|tep=ylaVVsCt2Cb8vBN4yZp%}A9)OgB z&1DsKJXGVMul1~)S&2>Hv~n9>l`|ItUxVb84df2W^&H&okyydh1;au(@&6(WfAkVq zy^LUZ1txnHDeN^Q{FiAV6c?cugIx(`y-UA<*y9l%lF&U^a|X=+OIze+8FMY8U)ko$ zk*ogHu6H3gNf7KEqE6ZGx*TM6OL{gWJsWtrlwpjW4%{QRQ?Y1LDIZbjGC(n)^vxlP z1L8exBgO{lvOzLY00h0#l?eI7h2l&aLa&-T(n}q2u>Ga!gLI2T1&}ch0 zFw;)zmi-JMA4*+xJ!+!sM{SYsVDw!ofZjo9J{LMxLd&!117yq(LFpsV`UA!3A3^C4 zsKfpUS|6jX`7fVv}MBj$MUe^kmVu%Y>fOA((M|O)*sH-%>VFAfjxhnY{(X z|4RRn3XvK-Wmc{vCU?@RGr=K^#s3Li$1e7r+~U8%K+fXYR1)yn<%j!fC&+ynt$dDF zpz}ZUzixEA2TzgC|Iy!5W?m2LNUHI}%&3Pwhg>N+MTPsc{? z<^_J(iCx{9VUL?J*q!!qj6pdps^xGleb&yqIY@KP&#gQKwE_P> zvwujr9}0LT;#6P+000^blhAe*lgwoZlV4~je|H*H6#fnjOfs3~f}u4gtw{_O0u8OU zX)QEL)6`(eMX8BtD|UbhnG|MlW{5=pgYT~8dtd7dZCp!NpZy*F4t1Y_AY`zmS;FF6 z_St9eZ-4uoefZaQ<#MdHn4F061YxWX@Hyqhw5SERi z$}p1AbalN}$*bmlC0`~ z*qf$NRZUw{t!1N9QS>4=yKLwOBvj1=f5TWwJyts0sM?yLGmM8LnSJFziI)|<6wlhG zrk6-{!limgwH2+b78#~`tXTz9YgrsD82YYOs+j~i6g~;I1KOryT7-)e;jcPlhS}Ha zleW=v^(yTqGSU_cO$r!pyU;i$iygZXO)_e>R*tVJ)kNgPoHAE6C>ha;Z z)~%X!!*olQxWAQpL2V)w@eO4+tCe)ccC!298}r$x+sG-wuJ#Sc*}0M5R||F`;ucZL z>X&(Qr8}eT<>G%`!d_P|d8%+6fA+IR%`B*QHJ-v~e;0j$+mi7%CKyIf+LiGxre(}v zTEt@+??Vxhmr+1b#w=e^u`8m)SN23`GWPLAL|H}!x(Gu?72nD*!LPtA88&JRka2+T zWYlrUo9`LUbj2$pf_XZDrz%?%_8Tzm*6z?snWb7q)$R6)W|)3mwV`qwe}3rBPNbj0 z^9tj~)mPqAtYcV2>0G!k!^5%x%i$F^%<+r!2FG^w!AtKw8s;vo?3 ztNY}C>)%wOR zL$DVWY5pYCX#0(@dv~A3e`e6C@k34acqr*~&nGz;?j;vy=>Nqz@Q(<_Z#}i|&@4_p z-A(xBpM(8E0}m#t^*h2Kroiv5qk!|c00;sv4NgDP>SuXRI`3hwWwc7#Ug|GKeZRr8 z!7|sl!Dj@5fcl zV-wsK0+ggs2)95;fTT%7phdA&M^uqqS?1FFz5NTk^sVKk542Olq|9{s#6xHLC;CI$ zen(bh*|JNflZnor)t=pNcfURIAAkS)8-SPbZ5%r=C1W~{HcWM3JKpHP3}%J&rg+RH za0BxR+{Aw^@pwzd+X>u;Dq}%LK90`nse+I+A-yA{qIfLEpvQ1WDBq325UM3{))Ws* zMoGqd5@f67=$2WQ&^3NXy{qObj&9_pG-p^s$CO?)Ri|QW686@=9jR^&)hy zYI%QYwdwtS0bEe7Q^&FyHR3Gl?82TGW2~>Ck4r*NeQ>tG1JEpw79Gs4*;dpcUeuh) zRRV2D4}>VRuTj?`Y+_L@pZ2&TVJICU&cIsgay)cSkZVmx`_pSOQvx`dawqdY8zk9DUgp-d9iX~VGY1+liL2RI&E{a05A zNG};$z$CspVOl}LW;eI+#3|HYsLj|=xWj9jvShk}EP_u*)BnSlOT;OwV&}Ers^B1O(zF)gqFP>L6a_o6OGa6NgS`s&h(|_fDhlr6o{akn9$-wt`}jaYcVmA~ zWPGULBYeyb)?AP4WwtxjqT34gVZVY;@Tr0WLi!A!i|rTmF<)y!-(VjvwOb0(7+~S& zYj+)WUt(0jSNK}NHzIc5iz-!zd~)HAmUmoI%&g*eU(8rKdmoveyLyg23SR{hV!C%} zvCwtB4_s!+u$G@1@_RzN&!`d8UFv^_r3#6M*Vj>i7}bKHV>)ar2pv^RCC#M4VAE-7 zJ#JA$GmC=3tihOs?dj3~vW_`cRV5-83LGI0bC9j0mSGT+pri}S)|RZh8g}#ZyMy2Q zD3XF@V57KeqrOcL&ENO)pPX>z1K!H6b4>~^`gU1<#w8MYkn$mFen&eZTrYoRoj>9TFa58-=*U^NESfFNh4TKxxD5qksPTiQd|g z<8u#UeD0+G6uQuh9_F%}ScZw^Jf$&OyhMu(EryZc@0tBPndX~UaG3ar3P&&mxYAA> zCGumG6|PmyaX+tDDV?B~YF2+a?u5-c0qwDCkaLSDl>6MERVVAb097X=)V+q2o|9`_ z1qeBl6_t4G=M{I=13a8@UG-GWe5|t9nHpB1>G!doa>KmNrwDV58e!9s*@(nypteAu zLp+`fVD9h&NjTlq$@*qa4!ii8IXQz-&&i)&!rC)*vguvptX}tXC|Q58E@Q(i*W`1g zv&-1{9pc&UzGZBh%_cXCcfu&?3dtVNHuVs_jkdk6$uhRo0G=Qv!B)oD#4hf7*@s;$ z(0+DekQp9fp05$+S^izdIb0`s=5Ud}LN5i%uXzc@aEo^5TmqcO1uwNz!CrQUsx!e} zPPXW!m@47yBKcZ%cEW!vb~kg3a!$U79C?ID`;QGon+nvs+pqVf=6=|>A6odCZR+Q8 z^W>7D&%@)ZW@RCdWOd9e)$(hI#q(aVa)0rB;Bl~#9eI5m;FWESKT9fGmt~4E8 zx$&^xa&#x$dt}mcqInfb2`9X`w(@EcVrB)~DAum1POiWbFCQ9{)v*FqO8MAQ-o;xR zXQ9dZ<9wCUHCMX+FO$r5`UOU|2=_gc%XUeBQqxcn{!Uv6qyb6=#5-bTpe?io5wLhE zRW4E}SVhrap~M;}36lo#6?_2S17~zlnQ{E*jE~|&IPOUb6ib`JFyo)Idv^DHXLqx^ zIlumV`wk$6MG?)2G}00k(SnFbvOzC~a7)0jfZJR%Dnh`RfI9-lMR;*fgoyhB9tcQ( zFw~oG)IuQ2(4EqaTqI}6t9d1o&8v~5zOf-|t0`4e7G$HK7;&;5S2fkV$1v6FZ2qr> zC0;GDi}x)tc#`_6!qCD6^IID$it$ul$&=wTp1pHIo+}+r%FOg7iHDH zy=@a0@Q?uv>u2)eox_V+#o>Avrw zL#u#C5+*SvU|PZq9y4?~WrJbN(UE7`x~6Yy$CN;4C6$CrxXc}!quO=6V73B$M|DNUy9ZS#$qvsYt*AjjAJ|y+3Ze zoIyL5&Y4=9cebWcS1a1@Qw*N!6<*D}IQ9Nl>cS^MMHl_$Tj)K&d_F$Vh;zfm=NrxI zHrh?o-c3{rhCag;425^${z!Wl+G%a(I<|;9_5@y*K?lh?NJsWKkBfkR#nEIU8N(I2 z%|`uz26%`jf}h~}0#EoW>RkAN`uYB!@b5ub4w0rI$ac}Vvj=gR+wH--914?2>fcv3 z?Hst`=YZ@vTGWc$qc^TF##akccc5cIdu9MM2D!#Bm` z-QnoUDVzVw*B=;1F{(Ta`5_A5Y!CJ^TRCPcc>ubimj_DlM&f;c8v{1?6CUH&vsOwD@CX*XR(v51u-&B@Y8~cq#-gAoQ zVQrJ=aKmXetE=-B?DJqa4E7v;ZSpboCv}!GvM3K^Djbz~RR-3*6W_WKfwCQU&OY}6 zT;w{k=KU4Zb(e8!oqB64mrb)EGN-ZY^exW5J?C2Bi(CR($B8x+lXTy+Yn^FCQTsuh zN%PK9i}rqRtf#RYthPb~8Sv0VKVrxZV(1~i^}wT1!^NY_1Y}7ZNf?1gMMkxAN_%Pu z>ZoKtDIJd9Yw+0uu%b{k)^D#Gq@nJLOX6k99_42iZ>OmdG&1)f%kcs%yfGP}g`TNEbXk@<{J3a&Y ziH=Q<&;&l9aoaAU^|d>;f@Ni&jVWTBJfz)QcPx)2HJmbdU;LTvvf;4n)-!!$*+7|f z&;^_8Mq^MuxW(uvY2TScW0t}7se3}(>OC2WKb_3oz_@7RTlE=j+;jG@Ao&=W1?ned^YLSA)NosG5z8bM z=zu$7@o=@p>7kS9?u} zOTM!N*P-vCS7aa2cuPIEyUVzp(e@4_N>iVwrTNH%y_2G zJUToQ)X+!H3Uo+Fu}c>CQ~CR-)7{WC__FM|$pye{e;)HL@c;KJ|BsT2&EOoIK!SmJ zBZ7hPgL3>SK;I__KCa2;#Q_rsYYc)kTU?bp&HH#iXINLaQ~ID=IE~3{7w5A}z78P}`+# znuf!Nm4+ZVNApLi7O=_+D(#j6@BAcG0iT9MxGi+f11DHyj%K;k7?m@pjj$TFkTe>G^zFOwIZ&I%krff-^$5{lRupf@<&-a}KE| z;MaH(vAIdwE*}t@PUeGQ%692tEN2Y&wEYA0cG5{-0#_Mq2b!bUM?AjIk$7 zo0k>lCgRn-R^?%l4xj_B^#Et~-!uKiPJS=TCp3NbT(JT=SEa&yH50{7|58^N$8f9b zzQLzgqSk=o_Je-s^%lltd3R~+74@;JUp~E`{=;21!W>^DbU<$V+%RfZ@%`O{XN)PA z#YK@`*Z?qy2}kj)=Z$T`$31Ih&M-<>j6_@1Pj?8`n4plO*C^h*4^OFqlAuqjdHL>{ z3uaoXqY)KY0#K|LxU(7X^}ob>#+>T$d4z;SoDIFBo~?YESA;tk`#5NUABwK$(HhfZ zcvOGKH;MH+(#r<*zqVS?WEysY99gRxS;IlG%*$#Wuo1x% z^4layBcd}HUJk>CB{eq|75t1e7>dXze(#eZ{ueYLg=VWqGk=Bjypt58YqnaKeIHH+ zGYjr4LLZCl37eVo$c${{$6cdCFC7POoq>?~s_(95$2{Jd3`!?Ml-D|X!s&Vgv?u6< ze(oR5$cXz8n!cuhZ0URdX^oNaW(qPvPaBCnb^-tm52knQgmO;_nk| zEXza3Z5WzBPmOfl$QO@9pu0cpHunkm)pID;4HCkKUE8vO(NTioa?-^)#|N3(H}w@ULL#RS0C8R~3Sr zO474He&_4}1oE{G>a}>$O$M1Dnpsc8PV7q;i1A!#X6qE?yl6r&M5C6}<=_LO02+q~ zFE77K2%#qSLro8}P(ETxnLXzlbQ=mwH#I&|RWBPa{PgG(Mt~sKXf7%mJ$qvd`4dvb9p0w{LOlN1tv7Um8Z!5Nx7HnAKz%J z(D{QX6v_M8m|O5_)eck8%kCSM;OO@qK>P}B%npc6=wltZscyNccIbJ=B;P9*eMyyy z-k{^^5^$L&{Ub0m*9JPO#c}xdt_h{X48?zaV~B~@FH4{q2S@CMLKn=x1-Od+B99k+ z0dVySa*ybVMPK-4F*ufN{`0;gglqmb1PcZhf(a4|lmJ?}W9?)6b{T^-sUU-c!2H#U zQokEJp@K(D*OTSu2MZI(Mb@tvxXHnAv8|^3fI1tH(LP_-o90yWs)1Ya^q0X9ZJ*bx z&i%QVtN3>B@yze@yqQ%YU}oxCm$qIVCiHTccAIgz*6H*zc`@*o2?Q7B+eoN^cB{;$ zB+J7z!T`$Qk!eJJy1DVtv(_Wj(FQneqVQH7^z;^p^fIyT^I`4ux4Ri>GWI6eH0Zqyz7`l<`|5wW3)}wdb8pP!BR7c< z=`Mgc{>li?rMmYK9!TxsK@*vE^I(7%vt=gtatlQG1@R#JNLl8g(pyE5j`q1c-%8`a z&x+t6G!PW{BPl4yrpn^PRZ-N5a2?(JyzVS^5nVfi`fgF9*ZjO@aFCsC!z}sPcf!@V zjVcWoBHU6XvUM_6{md_}i=HNhqkpZ^Uk3;)7BIUHLL_^}vT+Ky87a3DszJ--B+M%TkUTo^iB6mQSh>;69I zgqG`=V@7V0-4gY2xG|B;X+DhL^Yoas24KPc)Nr_2#Fm@Q!sp9hg{>EZ?-hS8Pfi5P zTL(OVv-WRbXt;qaQqS*CrF6b9POEiU6O~CiyTu%gYwKxk+LyWE?Z{C%-^-*V)k088Ms=^0x1YJV zXge`ZmLrT2Eu8y^;L&|zsz0{TtKF9n97cnWK@{HFd_z6fOmAJ6-Hs!-X|KPX?E#MA z=<#~|81>PIH>A;rR2z*x<^rT2oZgsgahoIDXRG%hH^=5sLoJSn)UGx*B?&tgd2E6jntoWa zUpFyF(XjbU8cdhm!vkN3FlnUF7D>N#3TlWB%ou#{}gQve<{b{ao1 zZ9icA&fbbS3lQ2CjlO)nQMzJnd!2HZ=#glrtM(-usEm&dJ>~ql44Kzjy2bG;C}|0r zGk*au8h;7YNKBs9zhL^o6S7L$UAae_;g`)X)!t30dBcR#EsPEH=6lF{OaExf#%RLA z1!((;u@eyp`7sO9yFy$hAAex$P6w+w`}~RpW05sru6WLl=}MC5Ok2a{&Kld@vlOAj zj)6ZXjr^jxs4Ph@X$>!UT8qEakFO$FF9S|May=}NBi1A4s3sA~j0^Y41hcQJsJn-f zoBZusuN0ELUPI0;J@tN))AEOa>|z2Q7=pXwcEODv5kBIG#c|PHBLpy->398p6m*0@ zw@PQU1Mcx!J39<(v>_)TvOe}X_*agr5moWAU;_49HF_l4o%ueqSrksJH-pJQ@xj%a z7);uRnT?N_?-z&Ro$IIV!f@*rL30t~*YBojdb$U!W`>}!2es&jdrBlqe?Xt*x+3cu zS=!}LKvSaJ2~~lwQxCAmKGw9=2>dk{n@5qvwZgeh^PQi{Q76s~o_KZ`k84GZj>p)3 zpmOs1&2Mr;J0*Y=N1LQ>kgcYwBVB5?gbOagH_mldal=vEJ)e}OS2^gRpr`j`)_U8= z;v)O$(({{abz5y*2zE?epcyXj6U8~PIIV$Sq4_SBOs*kJ!3>ZmFxc!fXV8uL99F*h zEmrT$$uyRlco{r>)-}b3_-Vp-^L~DCP5yAYYXE0Bs97dmw8EV*Y6t!fU7mVWL-5{^ zWJ|=_Eey71zks;EF@!&~f{Fa}epeZffHJ02h&L)cq}l>y)ZW(T$#r{P^`CT|o%*G> zp9h>Wc?WQ@iZS^qVPtsu3$o20WirQyY0cW*X(NQvx4VFpHu>&;gr5{}OwNWs&6{W* zc~!J#FR5MqCggn9;`;eyO_Dp~f=_bqHx;CiZ|7^m3!#o3-OaF$>6K=BjjpCG(Y^4^ zw94w4AgxHr>EspoWN68h9grR8w9FsED>L*g-N&BGV1pkOOGRQT`mIo;o$+_43yzH@ z0%tyU{lhI#KD2Uo{^gD0b0%u93l>Z$q6WEMVR?si4G_C2Vu_hdZ^+>qhH4m4*Q0F`Gw*41y6g#8Zh0_HMuqy>p>sWc0eTVl^A-PO)vN@fNo$Y_BNo~ zc?R&Pxdx*IUn<22S0i6bfnr!+Q_{k#qRR>CU@BslOmba+aed6HS+a$;&~%lp@!0@j zM^v`!52Ivdh-VM&l~<1QFx-__b1GUcY=-of6>g2AOh+t&go+fy-jhpR-77VlXkM= z#&?h!h5GqXePd!#VDHiYrjA;k!m+MAi?hkpemzL=N~$NFOMcypx)s8jS;Xi>AUl{y zb>i=?>HMfI8z`NiFVtIOiP}k3Ept$!B@lghrHU3# zq#X?>LwdmJ6Ky0Bwgr*ZnyS)diC8pus;@4d7kRJdgSKlM`X=OU3BI7BkY6AM%o2GR zb4Qbv3f?s8BA05NWlBgX(ow4J+BLb%S}y^mlz_GSNx!g}Qgu`!2rA`m$66SJnVZU3 zyU3aF;u6h8tX+hi{qC1u11T379RPGQteXo8EpDiD_@pLbRG_w8(FQZ8G$kD~u)f>Q z;Ena7Jx0l+iOBW@09EvEZ?>(5*L}3_)b|Kh&wf*_d$B&!FE^Z3A_MTqh=953Py+nP zZD4yaWu%ly`P1+FP=nGW9JcZM4dGz92Ulh}Vk2(fJfmQzX0cMPD_!Lz1JhaorpS{9 z!>U5WB(n7hJd0<)0Wx(94TS&-Xfhr$Uc3+If)-?+R5xc}Io{jUy)XH}!-U4fR8wvM z{mYzMRPIk^d7V58u~3R}8j?#EkKW+4tIpTFF@-Z8szA2Y}}^~=CTlz zV&RH-q$zLy_C%0DCA{&MHqDB}AI}Lm?MJ|U@D;rH0idUyVhXm_-?@(qPJopa10kAV6adir_QtY0GrOWaGTl= zE*4{?uHk>}qRNX$Q3(2>nxtzdYR#rf>|{+&j;A;kx*c5n{`K<}*3YAy`g=bzGH>mT zg=k(@8a@?E0U4~=Ks^jL8=WZ!1#^+1o8G{;ms zXh_H1)aMq}G=c0usHy!-hr}7TQkRCpbHb6~?PFhGiM@NXcV%z3b*qadCnY3bh3Nv8 zqWePO@aK^Vhqm4z%2(3jVOKoX7`^AjQ|tDF51;8@){5FY&$$bi>st;}0<}@jSy!{d zep|JUY^nj}Zvug#27na0^K12XeWxNNnwMTj{IZrJB&Cn|wcD8#QT;BiI)|a89_2q? zUXObD1UCxRT(xseZ8dM)Sp|+XOR~v>>Z9v4rddMScx{bT26Ce*8Ok(fYQi~!gFf#^ znRU`OGHgHXt8qxPAw3|_QSb8eli(+BoXY@FRvHGBC%==uF`1R@5JLi}`qcUO zHuct<_lb~Q8LXG^U_3g0Z$&Y=2dy&RGL5Mm7n~>+rQB*w+_j(e66&snVd_Y<8FANoDu^T2Nro-nZ43cG}#rne(R zDphMDs28`xwplAbXKvFCLSzac)hkKtvgL|%2q*f8oe{CZes(LMW}El;CGZ7S`V6M> zz9z5a6HH?$xAw^_qpNd-zb(|#D#vcK@FM9xCxy?~NqThNF~UmP8+wpfCK`M#^iGEa z&hew&KXsST3a4h`U3XXCmtroEehKO!P5Jrv3unLF9A=0p~vQI14!JqVWn_<@__-? z7?YeJ`C#|Wx}`-yu0NF%CFkQ6FLO++EfEG>iWMCBaOeb&Z`7DAtBu$aT16lHKneKL z$gobEl6ra)s8PDCpj*MWl2cN~G4~mMb-G-P_yBa!+{)$w${QwK_(cT${JkxR^on7S z{KjOb-lwIT8U1ql8`G>V0n7t_F`)&JI@QurO}D}`+F&8VKZ;bjg>!eKCsyw^JOkes zVSBaLrF43b5gJ|v<%_^1-!MfNt8KQG~psNoo|@VN?!;97Hq!m`DZ zDE)_%SK$&8l}Dgz&6G%)w$5`qey^=#guC9*$lG!xKz|Y!wkY|905qVhX1T`=S-017UA1X_jPU+}Z#&BGH z<#;-o1Nb!}pVSR?>qoNlN!Q}V0mS^rPA^+={s8Zl@WluyTo#(?45*%%Rzl_wrItIm zm{(Bw7W}8RTb@kANbjN}!(EE76dT_4x+`ar5z%&O#VMU!v&2j`nxa@8bwX6X3VjPX zG@jdnPjP`rkAR?lt9k^3Ne$=8TJUU%WQtzGADF{0j~3&Prwqi?ydoZQ%CxodKXB_m zfIdXY2-PY*i#9R1HWOuDts6v!*y0qQNUE5Gh4J`fyQYR2>|4&;$237kW1jBn5# zO`=Ktrn2QP3=|bRea{N+A$QQhL=LczJc083)VXTN|uoJDyY;s6}0U0u~iACuwL!rHTrtYl$ z*FMN#?uRs_mIi^}vDzqZX~0F(qg7j{6oYQ7kjBHfI>R>C=22$tGl8WvS{oJ$OFc1W z<0WhL^2;XIz_-LpZc*2pleHf^os7FQDR6G*ej=Nnk@-w$y!Tsst9ba~pw6|dGB@i} z1?{+dOZggAZ?zaNIE^E?)=&e#az{~vrxe0{T^3p0&RX(_c#g!8eFX*`Y8ITP1O3dBMjqvD^FxLyRE>{)A9(gnMRfmw}SgOOLPm^b_;&U8n zPml)Rop$)Va*0{T(}6;4o?{X`ws~np$0(u~Aw7J2YbJnGrUE@gQ?wM{?}%t*F}JQ{NN`&1%;Hw{L!fCG=c*2v|R2A&0By&op)#;j~kq8cD4~h zV)g@1Ak-Yoa52r8e)`Q53KC{B42@!=!6+!oaBt2=+(xh%0MuaVB9E0NHrPTe^c7td zl#~e$h&QVzBzwgMy>SLlT6^?SrCg{!o*}jQ1j`F zg-=LrA;(Ge=A`Vm811jRlh{&SsfFPCSHeP5>op#S}h0R#G;LPFANVqlYV zlc(SCO)KZKF)gXIOlW=>d<{A#QrJe}c_C;r1sCXAA!=pG?Yxop(CKlxYPWGWG{v+D zhIKvOjdp+xu$-yMHk$DZrff*&O;k;_RvHSARt@%NJRa6hBTLK@(w`o+T{i@jNDp}~ z@K-j_~Cn8Q)%vnH2a zkA2eR-3?v{5BI^%2I-NZ{}Nk5gd5s;-6+?ws#h1NwG=7g%f-Kb7*qEW=Sd(dSOTCW zp1wQ{#I**ly@BBc-<$NIiztWH{$whh5C*OskWeC|N zL+Wn~p;%LC6tL~_HQHobyDi#|rxR(fWI=#<&Ihe@HxG*HyQ#G9;Y77VpGE7Jaz>m! zccuma@qHJ3Dqz(SzsKM)*c{*VIirVFKr}#d2S-2?SqEOW&0r%7T#IE#k!?f#)rP|?w8cmNvO!TO z8pqcxMojHkHoWz5X6!?V*PcZQ(T7Z6RA^VeT%@&Q&K1$~hu4qH%O_7i*=+QSG~;L# zLMGzk)6|$bIFz>KYx(0qKNH#3VVn^LOZ1~}Sol${>yi;|h>eWdut-F~^Y#QtBj!oh z^}!XtKSBRfJsGjhzrnt%XWP5KG3%c_12ZNwM+0MP6DClVKMqJ@2AwfMdDCw8GuCef zS}a7T?ll#5OfEuZ&J%AofILNN@^>3}Q&g`u;l9>*ZKqX6P)<4pa7Yq=m6LUOGS_k! z&y``GksU5YJ@YPiDNv=uL6n)VXPUCyRp6LdFY=}GndVv0OJ-f4^cQ9hzl~zLsq;Zl z;9AY+oHEbY(B+gj(t3aG6JeFJv@S05R2%q3NW*N+O;OPC+MeC|%X{er& zH;SCX$7$P|Gw`erz9a4#kX8+MW-Lw3Iw9<-4D<2SPgD4PE@KMjH9xf>$jZVjeZ!Qm z_UZ}3Z@v`hc#KL(PPC;#Mb!MJ3dH2R*Oo{0@;J*g&yiTx1{MljTx|M9KObI@erVV5 zy$P%sm{_Mtv<~nBM3~zbGTED;f79IVqKACdV7`NMhj&|c)VPuSzVQmaOF$1}{oAx2 zG&)?9sR*G_2|>js!U98ABPYC)Zeo69O8b-OU`d-fjb&UCBd)uD1^>byU{8cUYH|t`ZN$3>O^YF0ByfKO&c$0;W`) zJ5TphsVrCDN4=y%P2y9iQhCLtp-q|3x}f#t`OgjQRWCcQRZlDJVPJ>&phWjbD!~nBwdaiU+eO&%mc&KnX#Tk;5wdSH`5@3M8j{Im*1}`m-fr zn!AJ<&KA17cxQ`0`t(v3+3zjV(}s8tk5#&Z6`uG-cVl_6uZ#I755Mt$++*8g)7t%z zfpP^PiCM7VkC|Jpnxi1T+-2K;fO?X{3jf5b+XwQ|VIVgfF$<5B`+3c7J~HRy-8jhR z3`Ag#*u#jDbtyHxcSxzcfS8T9#CC=(|+EdQH*2%zeY8bqA z)*8L#(93p+QW$g3QD|tF4#lx*7caUUK#+B5{cMVJ+k(Gz;#|Y5Gw9^4L#@W6Xqxz9 zUL?))RS@^co2=^lh6MiCbg5JKf|yedTj2K#I`o#6AuI7qS?@KPt|d$F5(Ra*T^AkF zj-NZ>es>V~Uk`Svek{RcXnEw_aXz`%X&gFcG+klyrnN5&P2|G=n#rvjs1URTjkrby z$n_hS!-Z6s>kdZ_lmq6HRWq*jDb@fnFnu;IvC#@_mV@L zTMG1Pp|qQN8J)I#bIr1St9`M$240R0cu|@&gUxtN>?k5T14SvP`gHaH6gKPySR$b{)Br(Sqi7Wh+ZqJSSoxy#{3!m?J59LXimvJW z==TWz;W0qBZ;4uOUDoR)U`oyTF zGRufmMzXR}9;|YiGaD0T>mQ>Zbs#dKO=+-xsFJMNG*FBW^b=G=a%65ZjRUb7H8PaS zeyDW%VbP!xtked?(s9%a;`cLaWU;zp)ui{UU_=wczk?#d?XP!^mfuerqH z$Z{e!;J5NNYRxo=!YR>{Pneo#;31D*_Gj~L5C`Hb3mVupnu&XVlBo)m`M@OP^?hWH zRyO${!J5!|VAfhG94MPAY!4i^B7TJLL9qtQ7<1#&9`WlZK1j+}s_>(#?b{Axi|>U8 zvP|I3;?KdDpf;^Eqic##5*k9}oYCssH+!Cv{1?1&ri{Mt$d843RrKgTH+X&WJk5v3b)!52rsO-Gp zVc~Q!q7&|6V+UVH06RHbe6V9CTDkw?g29DpYO0OM&{alaL(bfHM(35_IhNgK&x`3H z&@S&oqcj?NV=;w|k1hpPZEC_$hUf}-IX^d5|H!d)qva_lGZ1}E8B`NbUu)8h%|fp_ z?B3+s&={^bh>TG$Hxb&bMoYpv^#C3mF=}iio8d+Q>RX#HnmkgWJ27>t!;X+o<8z{# zyNk;a$;N^fp1eqbq(2-RbqcO?{5%t9TqCTpN9jBMrIZ06*e5a&WQTrqE-Gpl=`4|^ z)CV6OgV&$?1qc8*kSmQTWLRyw zMBL@dLEM&1UZ(?Wg+r!Tuto!>aB$PJx@+G)kXkpWgyS%UrF2-e~bH~ zE-7T#aK&3m7B_c$-lGx2=BM;m`yQ-E_N0RCEuVutsi)&(qAyIZ?Z?pr711K7@b?bw z_SxlAyv3@TLY~u%z<|~RvmBgJfhs)Avp59v-L2MYXZsYP50I_h!q~sI*emnzoPh;- zZ|p&3N9>DFgE1-ReKdi=oigu{&6x%H*eHt-KUJ6=OknFxt(ng0zH+-`HLuwY;+L;G z{LBt$ogq>al1z%{#ol}(GJQ~M>5$qTSv6J)6Vq%H*`RiHPRY^05t-E`)nFO6d~26y zPoJ4M-&tGJSX$KhkQ*VR#+|rBP60fcYpm`uKztiNU%k#SH5N?U?dx_&F;<|FRM~H&R+7q4($BF{FL`VI@Cak0cdc1V?I>)$gU}`P$STwVeG?-7 zw7xD&s7ms~bU^7RQgPKPw(>9r`)zQ!y>`29&^s{~En>{iIE~BGyMR9YST8b$dj>DkpmCr|* zTd>EuMq(u)0pB7Cn@IE}O+RGYOy8DkII$;tpP$B4M?Rr&;uR*euU6QaWX3{*eimvB zk%Pl`JbR&v*!Xbg59y8Hmrn7pHF7sF9R08Vp&yD2? z^ZO##`(L`hDHd3ne&)+1*QqQ!VKog=)4I;Ob_>F)e2+8p@lztA8$?NA1eTnV-c3OgxC!lZ{ZtlF{!zDg zk|$cI$D5ZVx%8l{q^#-ZWg#c#K@v5vFm&$rFvDFa=KaOfx6lqa{fMs^v^ghcM!ZA) zE3+3~fc+Y6|6wklN|U!`8*VdVdxx0!6fFw2U=wnOR)D=>@buw+njP&7yvJGM^YOzT z(?w2QSqG;HI*ln@#lh0A$Nf&x3dWvX#Oh)dMqb&ORsr}g)jz%3Xqu3x-A@SQ9`d@KA6U8%ZnkVpy zp5gmz!SA-wz46}NEm`&NVZc=jdKYCjU3o@lOik$;HE~S>0on6A4Cv#w`Y2zR(gzxG zk}t3sxy&)ya4`i6nbLgC$+rT!GLwarzRshXS1p34sCSPaQ{ z1z+^U=(2j^@q`gTO}OQ&?q~V*lhBP7b;b+od3&)N*d<|0B$cSJ|5b@Z05KUfnacf17W<|M zwzy{8Fn@8tJLr2!NKpVW%XGSLFrIPD*Hnb(wzH_K`#7@QQ}lY44TUQo#|yYAYMd}T zN~`BWhJnZ%Q=dFWi9N*duH~N_ZP1tKt{_uyfZDJ1_3yM$lhEFa5Nb&r;LxX@$L+!4 zSe^GXj>)-MlOe|+iyhQytmeV`Fz&f&I|4=8Inxk>CJ?HXq(dXSXh!x7nKi@47p*_G z{9c1fa+#GCuK!5-<=oe=@X<#BFemj>-!+g5RZbDW?{lKmRaL#sUGWX8xLRwuQ^q6w z0cbFbu%zF8KK1j|$2m;)$m|2@UbcC>K!mFvJWRnl#W7|5TsZ$X#f2dYn+DizGTDzr z?fGmC#u*wpF^gsUGLI?#y<=-kpOrxn=JTyl0`=$wT4>T2W|)m%pr%)K+*>+m6=6I; zd_6OI?k7}%+lfWWWbTv@vcgoj@Mls8NkGxIAJSV3aEO=|1d^#2qNy^8>!=k9q<6oe z!S9^{XI|ivHpv17MW?;xs5Oh4z`{1Sy*<+or`?`(o{5)c9$KO{wsr45ZpsMlsUHpf z;(ZNN{3eUBfs$*;O{*`l1eQ!`>_qm$;)&SKA>EbHDP~8`zgc7f)<(_p!WVe|Fb@o0 znEpxAyDrONEEW%2iwy0HulU8n0cm;}ruj{Tq48vDV4|EMgW*NdwU3`s=dg>Y zEbRF($vg*EcV1DwJH@oa>(i6f9wShvuC_d;u@IMvT|g;$-kplLa1Cto*TGM4o-?id zLx|d6aG4D--34D})$aVMJ~&b2<4jk96ThKkdyojuAttQane+H$x7R?eKz+7- zrGF*3Kadgvf99qGM!DpBUiLLY;Eo*$b(6!c1x;lfztg({0~UjyQNe1Zj+=n+-)%xn zjF+fKPa&xjn@iUvF2Yb}DurXcT%)AO%BYnh9$!itN~#%S!7>MT=Qm_URJh~zR^x70 z>kebSNHfgMh;8@5r%H29_;P{04Ek!VQ52Xlxh%qBJ?8H|Y)7`QxOHAz+e-eE$j|WIC zu%rbbp_xyK0IR;a;+}aId~@YO2}Gx>T<1nED#(5nM_5s$$bQ9nRCoM9y%{3+blHEb z5v0aXj^iqnscNQPlo3JvOkxl^@Fv^krg1j=gm?hi^k>(|Q%Zngi}zTv~C?T>x2uu0ktQxgEr}66Qi7 z_b~NbtxiW^D^mf#sp`2<0&Iz3JU=1R?mJyrhcY_@I&jG>}F=K7<;~pRP%GI8baqD+Dj>UriTSJkU!&8sR?^o4(8Z ztE9pI8;k-%9zp|Y4d6rU;Qlq90)X=`DTMz_Y4g|M_sT5b4;TrL6ofEH2N6&5-Xs7i z4N?&NGtIz%kKqG-A5@2+Wc)MoGb8G|WI71ckAIp9LnMU%WOn`Uk>nhIK$$~a5WdoX zs@2j+?}E`laKrcz=(2yhvWAgCpJf3cyo< z@j+JaO-P+T&GHc;a5T`_$Y*dnkiaNEcqYhmRGjc{It(x{zW+WRFj{j^n+e`KIR*u& zauf|jJ@$V3tU>;^grKiuBH-?zoH2gFzeCx#EQM!(rMpaqS^j4*`IG_&wm4v zK1L!oNMS!N3ImM!nZ?0{;TqPBK9M z@!$ewO=3fENB;Fgb_4+^d=icDZ-1EoorO2%FK}k``{|uRBm9R0!aqbZ#{C7ZoT4K9 z*WPUrI2c&r`#I$P2T(ELFJNXg45%_5{a-WxduLZ@8XH0`=^udaDKMa*X&l18_tgIP zIGIxaF<@(&itvATIQ~8Yf{eew5;J6k|FU*(zh6Gv_sjRMB*lLh$E?4At(nAs{{7!3 z@c&h->fC>WVL*8UI3Vg-d - - - - -All Classes (wisefy 2.0.1 API) - - - - - -

All Classes

-
- - diff --git a/javadoc/allclasses-noframe.html b/javadoc/allclasses-noframe.html deleted file mode 100644 index 1628cd74..00000000 --- a/javadoc/allclasses-noframe.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - -All Classes (wisefy 2.0.1 API) - - - - - -

All Classes

- - - diff --git a/javadoc/com/isupatches/wisefy/WiseFy.brains.html b/javadoc/com/isupatches/wisefy/WiseFy.brains.html deleted file mode 100644 index 9b61969b..00000000 --- a/javadoc/com/isupatches/wisefy/WiseFy.brains.html +++ /dev/null @@ -1,321 +0,0 @@ - - - - - -WiseFy.brains (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy
-

Class WiseFy.brains

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.WiseFy.brains
    • -
    -
  • -
-
-
    -
  • -
    -
    Enclosing class:
    -
    WiseFy
    -
    -
    -
    -
    public static class WiseFy.brains
    -extends java.lang.Object
    -
    Static class for builder pattern - - Implements builder interfaces #Logging #GetSmarts
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      brains(android.content.Context context) -
      Mandatory - The public constructor for the builder that requires a context
      -
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      WiseFygetSmarts() -
      Mandatory - To build and return a WiseFy instance - - *NOTE* Must be called after brains
      -
      WiseFy.brainslogging(boolean loggingEnabled) -
      Optional - Builder method that enables/disables logging for a WiseWy instance
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        brains

        -
        public brains(android.content.Context context)
        -
        Mandatory - The public constructor for the builder that requires a context
        -
        -
        Parameters:
        -
        context - The activity or application context to get a WifiConfiguration and - ConnectivityManager instance
        -
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        getSmarts

        -
        public WiseFy getSmarts()
        -
        Mandatory - To build and return a WiseFy instance - - *NOTE* Must be called after brains
        -
        -
        Returns:
        -
        WiseFy - The instance created by the builder
        -
        See Also:
        -
        WiseFy.brains
        -
        -
      • -
      - - - -
        -
      • -

        logging

        -
        public WiseFy.brains logging(boolean loggingEnabled)
        -
        Optional - Builder method that enables/disables logging for a WiseWy instance
        -
        -
        Parameters:
        -
        loggingEnabled - If logging is enabled or disabled for an instance
        -
        Returns:
        -
        brains - The builder with updated logging setting
        -
        See Also:
        -
        Logging
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/WiseFy.html b/javadoc/com/isupatches/wisefy/WiseFy.html deleted file mode 100644 index 88fb77cf..00000000 --- a/javadoc/com/isupatches/wisefy/WiseFy.html +++ /dev/null @@ -1,2091 +0,0 @@ - - - - - -WiseFy (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy
-

Class WiseFy

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.WiseFy
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    @PublicAPI
    -public class WiseFy
    -extends java.lang.Object
    -
    Main class for WiseFy that provides a synchronous and asynchronous API to manipulate and query - for different parts of a device's wifi configuration and status.
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Nested Class Summary

      - - - - - - - - - - -
      Nested Classes 
      Modifier and TypeClass and Description
      static class WiseFy.brains -
      Static class for builder pattern - - Implements builder interfaces #Logging #GetSmarts
      -
      -
    • -
    - - - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      intaddOpenNetwork(java.lang.String ssid) -
      To add an open network to the user's configured network list
      -
      voidaddOpenNetwork(java.lang.String ssid, - AddOpenNetworkCallbacks callbacks) -
      To add an open network to the user's configured network list
      -
      intaddWEPNetwork(java.lang.String ssid, - java.lang.String password) -
      To add a WEP network to the user's configured network list
      -
      voidaddWEPNetwork(java.lang.String ssid, - java.lang.String password, - AddWEPNetworkCallbacks callbacks) -
      To add a WEP network to the user's configured network list
      -
      intaddWPA2Network(java.lang.String ssid, - java.lang.String password) -
      To add a WPA2 network to the user's configured network list
      -
      voidaddWPA2Network(java.lang.String ssid, - java.lang.String password, - AddWPA2NetworkCallbacks callbacks) -
      To add a WPA2 network to the user's configured network list
      -
      intcalculateBars(int rssiLevel, - int targetNumberOfBars) -
      To convert an RSSI level for a network to a number of bars
      -
      intcompareSignalLevel(int rssi1, - int rssi2) -
      To compare the signal strength of two networks
      -
      booleanconnectToNetwork(java.lang.String ssidToConnectTo, - int timeoutInMillis) -
      Used to connect to a network - - Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity
      -
      voidconnectToNetwork(java.lang.String ssidToConnectTo, - int timeoutInMillis, - ConnectToNetworkCallbacks callbacks) -
      Used to connect to a network - - Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity
      -
      booleandisableWifi() -
      To disable Wifi on a user's device
      -
      voiddisableWifi(DisableWifiCallbacks callbacks) -
      To disable Wifi on a user's device
      -
      booleandisconnectFromCurrentNetwork() -
      To disconnect the user from their current network
      -
      voiddisconnectFromCurrentNetwork(DisconnectFromCurrentNetworkCallbacks callbacks) -
      To disconnect the user from their current network
      -
      voiddump() -
      Used to cleanup the thread started by WiseFy
      -
      booleanenableWifi() -
      To enable Wifi on a user's device
      -
      voidenableWifi(EnableWifiCallbacks callbacks) -
      To enable Wifi on a user's device
      -
      android.net.wifi.WifiInfogetCurrentNetwork() -
      To retrieve the user's current network
      -
      voidgetCurrentNetwork(GetCurrentNetworkCallbacks callbacks) -
      To retrieve the user's current network
      -
      java.lang.IntegergetFrequency() -
      To retrieve the frequency of the device's current network
      -
      voidgetFrequency(GetFrequencyCallbacks callbacks) -
      To retrieve the frequency of the device's current network
      -
      java.lang.IntegergetFrequency(android.net.wifi.WifiInfo network) -
      To retrieve the frequency of a network
      -
      voidgetFrequency(android.net.wifi.WifiInfo network, - GetFrequencyCallbacks callbacks) -
      To retrieve the frequency of a network
      -
      java.util.List<android.net.wifi.ScanResult>getNearbyAccessPoints(boolean filterDuplicates) -
      To retrieve a list of nearby access points - - *NOTE* Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI (will always take the highest signal strength)
      -
      voidgetNearbyAccessPoints(boolean filterDuplicates, - GetNearbyAccessPointsCallbacks callbacks) -
      To retrieve a list of nearby access points - - *NOTE* Setting filterDuplicates to true will not return SSIDs with a weaker signal strength (will always take the highest)
      -
      java.lang.IntegergetRSSI(java.lang.String regexForSSID, - boolean takeHighest, - int timeoutInMillis) -
      To retrieve the RSSI of the first network matching a given regex - - *NOTE* Setting takeHighest to true will return the access point with the highest RSSI for the given SSID
      -
      voidgetRSSI(java.lang.String regexForSSID, - boolean takeHighest, - int timeoutInMillis, - GetRSSICallbacks callbacks) -
      To retrieve the RSSI of the first network matching a given regex - - *NOTE* Setting takeHighest to true will return the access point with the highest RSSI for the given SSID
      -
      android.net.wifi.WifiConfigurationgetSavedNetwork(java.lang.String regexForSSID) -
      To search for and return a saved WiFiConfiguration given an SSID
      -
      voidgetSavedNetwork(java.lang.String regexForSSID, - GetSavedNetworkCallbacks callbacks) -
      To search for and return a saved WiFiConfiguration given an SSID
      -
      java.util.List<android.net.wifi.WifiConfiguration>getSavedNetworks() -
      To retrieve a list of saved networks on a user's device
      -
      voidgetSavedNetworks(GetSavedNetworksCallbacks callbacks) -
      To retrieve a list of saved networks on a user's device
      -
      java.util.List<android.net.wifi.WifiConfiguration>getSavedNetworks(java.lang.String regexForSSID) -
      To retrieve a list of saved networks on a user's device that match a given regex
      -
      voidgetSavedNetworks(java.lang.String regexForSSID, - GetSavedNetworksCallbacks callbacks) -
      To retrieve a list of saved networks on a user's device that match a given regex
      -
      com.isupatches.wisefy.WiseFyLockgetWiseFyLock() -
      To retrieve the lock in use by WiseFy for synchronization
      -
      booleanisDeviceConnectedToMobileNetwork() -
      To check if the device is connected to a mobile network
      -
      booleanisDeviceConnectedToMobileOrWifiNetwork() -
      To check if the device is connected to a mobile or wifi network
      -
      booleanisDeviceConnectedToSSID(java.lang.String ssid) -
      To check if the device is connected to a given SSID
      -
      booleanisDeviceConnectedToWifiNetwork() -
      To check if the device is connected to a wifi network
      -
      booleanisDeviceRoaming() -
      To query if the device is roaming
      -
      booleanisLoggingEnabled() -
      To query if logging is enabled or disabled for a WiseFy instance
      -
      booleanisNetwork5gHz() -
      To check if the device's current network is 5gHz
      -
      booleanisNetwork5gHz(android.net.wifi.WifiInfo network) -
      To check if a given network is 5gHz
      -
      booleanisNetworkEAP(android.net.wifi.ScanResult scanResult) -
      To check and return if a network is a EAP network
      -
      booleanisNetworkInConfigurationList(java.lang.String ssid) -
      To check if an SSID is in the list of configured networks
      -
      booleanisNetworkPSK(android.net.wifi.ScanResult scanResult) -
      To check and return if a network is a PSK network
      -
      booleanisNetworkSecure(android.net.wifi.ScanResult scanResult) -
      To check and return if a network is secure (WEP/WPA/WPA2 capabilities)
      -
      booleanisNetworkWEP(android.net.wifi.ScanResult scanResult) -
      To check and return if a network is a WEP network
      -
      booleanisNetworkWPA(android.net.wifi.ScanResult scanResult) -
      To check and return if a network is a WPA network
      -
      booleanisNetworkWPA2(android.net.wifi.ScanResult scanResult) -
      To check and return if a network is a WPA2 network
      -
      booleanisWifiEnabled() -
      To check if Wifi is enabled on the device or not
      -
      booleanremoveNetwork(java.lang.String ssidToRemove) -
      To remove a configured network
      -
      voidremoveNetwork(java.lang.String ssidToRemove, - RemoveNetworkCallbacks callbacks) -
      To remove a configured network
      -
      android.net.wifi.ScanResultsearchForAccessPoint(java.lang.String regexForSSID, - int timeoutInMillis, - boolean filterDuplicates) -
      To return the first access point that matches a given regex - - *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest)
      -
      voidsearchForAccessPoint(java.lang.String regexForSSID, - int timeoutInMillis, - boolean filterDuplicates, - SearchForAccessPointCallbacks callbacks) -
      To return the first access point that matches a given regex - - *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest)
      -
      java.util.List<android.net.wifi.ScanResult>searchForAccessPoints(java.lang.String regexForSSID, - boolean filterDuplicates) -
      To return nearby access points that match a given regex - - *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest)
      -
      voidsearchForAccessPoints(java.lang.String regexForSSID, - boolean filterDuplicates, - SearchForAccessPointsCallbacks callbacks) -
      To return nearby access points that match a given regex - - *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest)
      -
      java.lang.StringsearchForSSID(java.lang.String regexForSSID, - int timeoutInMillis) -
      To search local networks and return the first one that contains a given ssid
      -
      voidsearchForSSID(java.lang.String regexForSSID, - int timeoutInMillis, - SearchForSSIDCallbacks callbacks) -
      To search local networks and return the first one that contains a given ssid
      -
      java.util.List<java.lang.String>searchForSSIDs(java.lang.String regexForSSID) -
      To search local networks and return the first one that contains a given ssid
      -
      voidsearchForSSIDs(java.lang.String regexForSSID, - SearchForSSIDsCallbacks callbacks) -
      To search local networks and return the first one that contains a given ssid
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - - - -
      -
    • - - -

      Method Detail

      - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        -
      • -

        calculateBars

        -
        @Sync
        - @CallingThread
        -public int calculateBars(int rssiLevel,
        -                                               int targetNumberOfBars)
        -
        To convert an RSSI level for a network to a number of bars
        -
        -
        Parameters:
        -
        rssiLevel - The signal strength of the network
        -
        targetNumberOfBars - How many bars or levels there will be total
        -
        Returns:
        -
        int - The number of bars for the given RSSI value
        -
        -
      • -
      - - - -
        -
      • -

        compareSignalLevel

        -
        @Sync
        - @CallingThread
        -public int compareSignalLevel(int rssi1,
        -                                                    int rssi2)
        -
        To compare the signal strength of two networks
        -
        -
        Parameters:
        -
        rssi1 - The signal strength of network 1
        -
        rssi2 - The signal strength of network 2
        -
        Returns:
        -
        int - Returns negative value if the first signal is weaker than the second signal, 0 if the two - signals have the same strength, and a positive value if the first signal is stronger than the second signal.
        -
        -
      • -
      - - - -
        -
      • -

        connectToNetwork

        -
        @Sync
        - @CallingThread
        - @WaitsForTimeout
        -public boolean connectToNetwork(java.lang.String ssidToConnectTo,
        -                                                                        int timeoutInMillis)
        -
        Used to connect to a network - - Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity
        -
        -
        Parameters:
        -
        ssidToConnectTo - The ssid to connect/reconnect to
        -
        timeoutInMillis - The number of milliseconds to continue waiting for the device to connect to the given SSID
        -
        Returns:
        -
        boolean - If the network was successfully reconnected
        -
        See Also:
        -
        WiseFyConfiguration.isLoggingEnabled(), -WiseFyConnection.waitToConnectToSSID(String, int), -WiseFyPrerequisites.getWifiManager(), -WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findSavedNetworkByRegex(String)
        -
        -
      • -
      - - - -
        -
      • -

        connectToNetwork

        -
        @Async
        - @WiseFyThread
        - @WaitsForTimeout
        -public void connectToNetwork(java.lang.String ssidToConnectTo,
        -                                                                     int timeoutInMillis,
        -                                                                     ConnectToNetworkCallbacks callbacks)
        -
        Used to connect to a network - - Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity
        -
        -
        Parameters:
        -
        ssidToConnectTo - The ssid to connect/reconnect to
        -
        timeoutInMillis - The number of milliseconds to continue waiting for the device to connect to the given SSID
        -
        callbacks - The listener to return results to
        -
        See Also:
        -
        execute(Runnable), -ConnectToNetworkCallbacks, -WiseFyCodes, -WiseFyConnection.waitToConnectToSSID(String, int), -WiseFyConfiguration.isLoggingEnabled(), -WiseFyPrerequisites.getWifiManager(), -WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findSavedNetworkByRegex(String)
        -
        -
      • -
      - - - -
        -
      • -

        disableWifi

        -
        @Sync
        - @CallingThread
        -public boolean disableWifi()
        -
        To disable Wifi on a user's device
        -
        -
        Returns:
        -
        boolean - True if the command succeeded in disabling wifi
        -
        See Also:
        -
        WiseFyPrerequisites.getWifiManager(), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - - - - - -
        -
      • -

        disconnectFromCurrentNetwork

        -
        @Sync
        - @CallingThread
        -public boolean disconnectFromCurrentNetwork()
        -
        To disconnect the user from their current network
        -
        -
        Returns:
        -
        boolean - If the command succeeded in disconnecting the device from the current network
        -
        See Also:
        -
        WiseFyPrerequisites.getWifiManager(), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - - - - - -
        -
      • -

        dump

        -
        public void dump()
        -
        Used to cleanup the thread started by WiseFy
        -
        -
        See Also:
        -
        WiseFyConfiguration.isLoggingEnabled()
        -
        -
      • -
      - - - -
        -
      • -

        enableWifi

        -
        @Sync
        - @CallingThread
        -public boolean enableWifi()
        -
        To enable Wifi on a user's device
        -
        -
        Returns:
        -
        boolean - If the command succeeded in enabling wifi
        -
        See Also:
        -
        WiseFyPrerequisites.getWifiManager(), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - - - - - -
        -
      • -

        getCurrentNetwork

        -
        @Sync
        - @CallingThread
        -public android.net.wifi.WifiInfo getCurrentNetwork()
        -
        To retrieve the user's current network
        -
        -
        Returns:
        -
        WifiInfo|null - The user's current network information
        -
        See Also:
        -
        WiseFyPrerequisites.getWifiManager(), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - - - - - -
        -
      • -

        getFrequency

        -
        @Sync
        - @CallingThread
        -public java.lang.Integer getFrequency()
        -
        To retrieve the frequency of the device's current network
        -
        -
        Returns:
        -
        Integer - The frequency of the devices current network or null if no network
        -
        See Also:
        -
        getCurrentNetwork()
        -
        -
      • -
      - - - - - - - -
        -
      • -

        getFrequency

        -
        @Sync
        - @CallingThread
        -public java.lang.Integer getFrequency(android.net.wifi.WifiInfo network)
        -
        To retrieve the frequency of a network
        -
        -
        Parameters:
        -
        network - The network to return the frequency of
        -
        Returns:
        -
        Integer - The frequency of the devices current network or null if no network
        -
        -
      • -
      - - - - - - - -
        -
      • -

        getNearbyAccessPoints

        -
        @Sync
        - @CallingThread
        -public java.util.List<android.net.wifi.ScanResult> getNearbyAccessPoints(boolean filterDuplicates)
        -
        To retrieve a list of nearby access points - - *NOTE* Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI (will always take the highest signal strength)
        -
        -
        Parameters:
        -
        filterDuplicates - If you want to exclude SSIDs with that same name that have a weaker signal strength
        -
        Returns:
        -
        List of ScanResults|null - List of nearby access points
        -
        See Also:
        -
        WiseFyPrerequisites.getWifiManager(), -WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.removeEntriesWithLowerSignalStrength(List)
        -
        -
      • -
      - - - -
        -
      • -

        getNearbyAccessPoints

        -
        @Async
        - @WiseFyThread
        -public void getNearbyAccessPoints(boolean filterDuplicates,
        -                                                        GetNearbyAccessPointsCallbacks callbacks)
        -
        To retrieve a list of nearby access points - - *NOTE* Setting filterDuplicates to true will not return SSIDs with a weaker signal strength (will always take the highest)
        -
        -
        Parameters:
        -
        filterDuplicates - If you want to exclude SSIDs with that same name that have a weaker signal strength
        -
        callbacks - The listener to return results to
        -
        See Also:
        -
        execute(Runnable), -GetNearbyAccessPointsCallbacks, -WiseFyCodes, -WiseFyPrerequisites.getWifiManager(), -WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.removeEntriesWithLowerSignalStrength(List)
        -
        -
      • -
      - - - -
        -
      • -

        getRSSI

        -
        @Sync
        - @CallingThread
        - @WaitsForTimeout
        -public java.lang.Integer getRSSI(java.lang.String regexForSSID,
        -                                                                         boolean takeHighest,
        -                                                                         int timeoutInMillis)
        -
        To retrieve the RSSI of the first network matching a given regex - - *NOTE* Setting takeHighest to true will return the access point with the highest RSSI for the given SSID
        -
        -
        Parameters:
        -
        regexForSSID - The regex to be used to search for the ssid
        -
        takeHighest - Whether to return the access point with the highest RSSI for the given SSID
        -
        timeoutInMillis - The amount of time to search for a matching SSID
        -
        Returns:
        -
        Integer - The RSSI value for the found SSID or null if no matching network found
        -
        See Also:
        -
        WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findAccessPointByRegex(String, Integer, boolean)
        -
        -
      • -
      - - - -
        -
      • -

        getRSSI

        -
        @Async
        - @WiseFyThread
        - @WaitsForTimeout
        -public void getRSSI(java.lang.String regexForSSID,
        -                                                            boolean takeHighest,
        -                                                            int timeoutInMillis,
        -                                                            GetRSSICallbacks callbacks)
        -
        To retrieve the RSSI of the first network matching a given regex - - *NOTE* Setting takeHighest to true will return the access point with the highest RSSI for the given SSID
        -
        -
        Parameters:
        -
        regexForSSID - The regex to be used to search for the ssid
        -
        takeHighest - Whether to return the access point with the highest RSSI for the given SSID
        -
        timeoutInMillis - The amount of time to search for a matching SSID
        -
        callbacks - The listener to return results to
        -
        See Also:
        -
        execute(Runnable), -GetRSSICallbacks, -WiseFyCodes, -WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findAccessPointByRegex(String, Integer, boolean)
        -
        -
      • -
      - - - -
        -
      • -

        getSavedNetwork

        -
        @Sync
        - @CallingThread
        -public android.net.wifi.WifiConfiguration getSavedNetwork(java.lang.String regexForSSID)
        -
        To search for and return a saved WiFiConfiguration given an SSID
        -
        -
        Parameters:
        -
        regexForSSID - The ssid to use while searching for saved configuration
        -
        Returns:
        -
        WifiConfiguration|null - Saved network that matches the ssid
        -
        See Also:
        -
        WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findSavedNetworkByRegex(String)
        -
        -
      • -
      - - - -
        -
      • -

        getSavedNetwork

        -
        @Async
        - @WiseFyThread
        -public void getSavedNetwork(java.lang.String regexForSSID,
        -                                                  GetSavedNetworkCallbacks callbacks)
        -
        To search for and return a saved WiFiConfiguration given an SSID
        -
        -
        Parameters:
        -
        regexForSSID - The ssid to use while searching for saved configuration
        -
        callbacks - The listener to return results to
        -
        See Also:
        -
        execute(Runnable), -GetSavedNetworkCallbacks, -WiseFyCodes, -WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findSavedNetworkByRegex(String)
        -
        -
      • -
      - - - -
        -
      • -

        getSavedNetworks

        -
        @Sync
        - @CallingThread
        -public java.util.List<android.net.wifi.WifiConfiguration> getSavedNetworks()
        -
        To retrieve a list of saved networks on a user's device
        -
        -
        Returns:
        -
        List of WifiConfiguration|null - List of saved networks on a users device
        -
        See Also:
        -
        WiseFyPrerequisites.getWifiManager(), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - - - - - -
        -
      • -

        getSavedNetworks

        -
        @Sync
        - @CallingThread
        -public java.util.List<android.net.wifi.WifiConfiguration> getSavedNetworks(java.lang.String regexForSSID)
        -
        To retrieve a list of saved networks on a user's device that match a given regex
        -
        -
        Parameters:
        -
        regexForSSID - The ssid to use while searching for saved configurations
        -
        Returns:
        -
        List of WifiConfigurations|null - The list of saved network configurations that match the given regex
        -
        See Also:
        -
        WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findSavedNetworkByRegex(String)
        -
        -
      • -
      - - - -
        -
      • -

        getSavedNetworks

        -
        @Async
        - @WiseFyThread
        -public void getSavedNetworks(java.lang.String regexForSSID,
        -                                                   GetSavedNetworksCallbacks callbacks)
        -
        To retrieve a list of saved networks on a user's device that match a given regex
        -
        -
        Parameters:
        -
        regexForSSID - The ssid to use while searching for saved configurations
        -
        callbacks - The listener to return results to
        -
        See Also:
        -
        WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findSavedNetworkByRegex(String)
        -
        -
      • -
      - - - -
        -
      • -

        getWiseFyLock

        -
        public com.isupatches.wisefy.WiseFyLock getWiseFyLock()
        -
        To retrieve the lock in use by WiseFy for synchronization
        -
        -
        Returns:
        -
        WiseFyLock - The instance of the lock in use by WiseFy
        -
        See Also:
        -
        WiseFyLock
        -
        -
      • -
      - - - -
        -
      • -

        isDeviceConnectedToMobileNetwork

        -
        @Sync
        - @CallingThread
        -public boolean isDeviceConnectedToMobileNetwork()
        -
        To check if the device is connected to a mobile network
        -
        -
        Returns:
        -
        bool - If the device is currently connected to a mobile network
        -
        See Also:
        -
        NetworkTypes, -WiseFyConnection.isNetworkConnectedAndMatchesType(NetworkInfo, String), -WiseFyPrerequisites.getConnectivityManager(), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - -
        -
      • -

        isDeviceConnectedToMobileOrWifiNetwork

        -
        @Sync
        - @CallingThread
        -public boolean isDeviceConnectedToMobileOrWifiNetwork()
        -
        To check if the device is connected to a mobile or wifi network
        -
        -
        Returns:
        -
        bool - If the device is currently connected to a mobile or wifi network
        -
        See Also:
        -
        WiseFyConnection.isNetworkConnected(NetworkInfo), -WiseFyPrerequisites.getConnectivityManager(), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - -
        -
      • -

        isDeviceConnectedToSSID

        -
        @Sync
        - @CallingThread
        -public boolean isDeviceConnectedToSSID(java.lang.String ssid)
        -
        To check if the device is connected to a given SSID
        -
        -
        Parameters:
        -
        ssid - The SSID to check if the device is attached to
        -
        Returns:
        -
        bool - If the device is currently attached to the given SSID
        -
        See Also:
        -
        WiseFyConnection.isCurrentNetworkConnectedToSSID(String), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - -
        -
      • -

        isDeviceConnectedToWifiNetwork

        -
        @Sync
        - @CallingThread
        -public boolean isDeviceConnectedToWifiNetwork()
        -
        To check if the device is connected to a wifi network
        -
        -
        Returns:
        -
        bool - If the device is currently connected to a wifi network
        -
        See Also:
        -
        NetworkTypes, -WiseFyConnection.isNetworkConnectedAndMatchesType(NetworkInfo, String), -WiseFyPrerequisites.getConnectivityManager(), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - -
        -
      • -

        isDeviceRoaming

        -
        @Sync
        - @CallingThread
        -public boolean isDeviceRoaming()
        -
        To query if the device is roaming
        -
        -
        Returns:
        -
        boolean - If the current network is roaming
        -
        See Also:
        -
        WiseFyPrerequisites.getConnectivityManager(), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - -
        -
      • -

        isLoggingEnabled

        -
        @Sync
        - @CallingThread
        -public boolean isLoggingEnabled()
        -
        To query if logging is enabled or disabled for a WiseFy instance
        -
        -
        Returns:
        -
        boolean - If logging is enabled for the WiseFy instance
        -
        See Also:
        -
        WiseFyConfiguration.isLoggingEnabled()
        -
        -
      • -
      - - - - - - - - - - - -
        -
      • -

        isNetworkInConfigurationList

        -
        @Sync
        - @CallingThread
        -public boolean isNetworkInConfigurationList(java.lang.String ssid)
        -
        To check if an SSID is in the list of configured networks
        -
        -
        Parameters:
        -
        ssid - The SSID to check and see if it's in the list of configured networks
        -
        Returns:
        -
        boolean - If the SSID is in the list of configured networks
        -
        See Also:
        -
        WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.isNetworkASavedConfiguration(String)
        -
        -
      • -
      - - - -
        -
      • -

        isNetworkEAP

        -
        @Sync
        - @CallingThread
        -public boolean isNetworkEAP(android.net.wifi.ScanResult scanResult)
        -
        To check and return if a network is a EAP network
        -
        -
        Parameters:
        -
        scanResult - The network to check
        -
        Returns:
        -
        boolean - Whether the network has EAP capabilities listed
        -
        See Also:
        -
        Capabilities, -containsCapability(ScanResult, String)
        -
        -
      • -
      - - - -
        -
      • -

        isNetworkPSK

        -
        @Sync
        - @CallingThread
        -public boolean isNetworkPSK(android.net.wifi.ScanResult scanResult)
        -
        To check and return if a network is a PSK network
        -
        -
        Parameters:
        -
        scanResult - The network to check
        -
        Returns:
        -
        boolean - Whether the network has PSK capabilities listed
        -
        See Also:
        -
        Capabilities, -containsCapability(ScanResult, String)
        -
        -
      • -
      - - - -
        -
      • -

        isNetworkSecure

        -
        @Sync
        - @CallingThread
        -public boolean isNetworkSecure(android.net.wifi.ScanResult scanResult)
        -
        To check and return if a network is secure (WEP/WPA/WPA2 capabilities)
        -
        -
        Parameters:
        -
        scanResult - The network to see if it is secure
        -
        Returns:
        -
        boolean - Whether the network is secure
        -
        See Also:
        -
        Capabilities
        -
        -
      • -
      - - - -
        -
      • -

        isNetworkWEP

        -
        @Sync
        - @CallingThread
        -public boolean isNetworkWEP(android.net.wifi.ScanResult scanResult)
        -
        To check and return if a network is a WEP network
        -
        -
        Parameters:
        -
        scanResult - The network to check
        -
        Returns:
        -
        boolean - Whether the network has WEP capabilities listed
        -
        See Also:
        -
        Capabilities, -containsCapability(ScanResult, String)
        -
        -
      • -
      - - - -
        -
      • -

        isNetworkWPA

        -
        @Sync
        - @CallingThread
        -public boolean isNetworkWPA(android.net.wifi.ScanResult scanResult)
        -
        To check and return if a network is a WPA network
        -
        -
        Parameters:
        -
        scanResult - The network to check
        -
        Returns:
        -
        boolean - Whether the network has WPA capabilities listed
        -
        See Also:
        -
        Capabilities, -containsCapability(ScanResult, String)
        -
        -
      • -
      - - - -
        -
      • -

        isNetworkWPA2

        -
        @Sync
        - @CallingThread
        -public boolean isNetworkWPA2(android.net.wifi.ScanResult scanResult)
        -
        To check and return if a network is a WPA2 network
        -
        -
        Parameters:
        -
        scanResult - The network to check
        -
        Returns:
        -
        boolean - Whether the network has WPA2 capabilities listed
        -
        See Also:
        -
        Capabilities, -containsCapability(ScanResult, String)
        -
        -
      • -
      - - - -
        -
      • -

        isWifiEnabled

        -
        @Sync
        - @CallingThread
        -public boolean isWifiEnabled()
        -
        To check if Wifi is enabled on the device or not
        -
        -
        Returns:
        -
        boolean - if Wifi is enabled on device
        -
        See Also:
        -
        WiseFyPrerequisites.getWifiManager(), -WiseFyPrerequisites.hasPrerequisites()
        -
        -
      • -
      - - - -
        -
      • -

        removeNetwork

        -
        @Sync
        - @CallingThread
        -public boolean removeNetwork(java.lang.String ssidToRemove)
        -
        To remove a configured network
        -
        -
        Parameters:
        -
        ssidToRemove - The ssid of the network you want to remove from the configured network list
        -
        Returns:
        -
        boolean - If the command succeeded in removing the network
        -
        See Also:
        -
        WiseFyConfiguration.isLoggingEnabled(), -WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findSavedNetworkByRegex(String)
        -
        -
      • -
      - - - -
        -
      • -

        removeNetwork

        -
        @Async
        - @WiseFyThread
        -public void removeNetwork(java.lang.String ssidToRemove,
        -                                                RemoveNetworkCallbacks callbacks)
        -
        To remove a configured network
        -
        -
        Parameters:
        -
        ssidToRemove - The ssid of the network you want to remove from the configured network list
        -
        callbacks - The listener to return results to
        -
        See Also:
        -
        execute(Runnable), -RemoveNetworkCallbacks, -WiseFyCodes, -WiseFyConfiguration.isLoggingEnabled(), -WiseFyPrerequisites.hasPrerequisites(), -WiseFyPrerequisites.getWifiManager(), -WiseFySearch.findSavedNetworkByRegex(String)
        -
        -
      • -
      - - - -
        -
      • -

        searchForAccessPoint

        -
        @Sync
        - @CallingThread
        -public android.net.wifi.ScanResult searchForAccessPoint(java.lang.String regexForSSID,
        -                                                                              int timeoutInMillis,
        -                                                                              boolean filterDuplicates)
        -
        To return the first access point that matches a given regex - - *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest)
        -
        -
        Parameters:
        -
        regexForSSID - The regex to use when iterating through nearby access points
        -
        timeoutInMillis - The amount of time (in milliseconds) to wait for a matching access point
        -
        filterDuplicates - If you want to exclude access points with the same name that have a weaker signal strength
        -
        Returns:
        -
        ScanResult|null - The first access point or access point with the highest signal strength matching the regex
        -
        See Also:
        -
        WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findAccessPointByRegex(String, Integer, boolean)
        -
        -
      • -
      - - - -
        -
      • -

        searchForAccessPoint

        -
        @Async
        - @WiseFyThread
        -public void searchForAccessPoint(java.lang.String regexForSSID,
        -                                                       int timeoutInMillis,
        -                                                       boolean filterDuplicates,
        -                                                       SearchForAccessPointCallbacks callbacks)
        -
        To return the first access point that matches a given regex - - *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest)
        -
        -
        Parameters:
        -
        regexForSSID - The regex to use when iterating through nearby access points
        -
        timeoutInMillis - The amount of time (in milliseconds) to wait for a matching access point
        -
        filterDuplicates - If you want to exclude access points with the same name that have a weaker signal strength
        -
        callbacks - The listener to return results to
        -
        See Also:
        -
        execute(Runnable), -SearchForAccessPointCallbacks, -WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findAccessPointByRegex(String, Integer, boolean)
        -
        -
      • -
      - - - -
        -
      • -

        searchForAccessPoints

        -
        @Sync
        - @CallingThread
        -public java.util.List<android.net.wifi.ScanResult> searchForAccessPoints(java.lang.String regexForSSID,
        -                                                                                               boolean filterDuplicates)
        -
        To return nearby access points that match a given regex - - *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest)
        -
        -
        Parameters:
        -
        regexForSSID - The regex to use when iterating through nearby access points
        -
        filterDuplicates - If you want to exclude access points with the same name that have a weaker signal strength
        -
        Returns:
        -
        List of ScanResult|null - The list of matching access points or null if none match the given regex
        -
        See Also:
        -
        WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findAccessPointsMatchingRegex(String, boolean)
        -
        -
      • -
      - - - -
        -
      • -

        searchForAccessPoints

        -
        @Async
        - @WiseFyThread
        -public void searchForAccessPoints(java.lang.String regexForSSID,
        -                                                        boolean filterDuplicates,
        -                                                        SearchForAccessPointsCallbacks callbacks)
        -
        To return nearby access points that match a given regex - - *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest)
        -
        -
        Parameters:
        -
        regexForSSID - The regex to use when iterating through nearby access points
        -
        filterDuplicates - If you want to exclude access points with the same name that have a weaker signal strength
        -
        callbacks - The listener to return results to
        -
        See Also:
        -
        execute(Runnable), -SearchForAccessPointsCallbacks, -WiseFyCodes, -WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findAccessPointsMatchingRegex(String, boolean)
        -
        -
      • -
      - - - -
        -
      • -

        searchForSSID

        -
        @Sync
        - @CallingThread
        - @WaitsForTimeout
        -public java.lang.String searchForSSID(java.lang.String regexForSSID,
        -                                                                              int timeoutInMillis)
        -
        To search local networks and return the first one that contains a given ssid
        -
        -
        Parameters:
        -
        regexForSSID - The regex to be used to search for the ssid
        -
        timeoutInMillis - The number of milliseconds to keep searching for the SSID
        -
        Returns:
        -
        String|null - The first SSID that contains the search ssid (if any, else null)
        -
        See Also:
        -
        WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findAccessPointByRegex(String, Integer, boolean)
        -
        -
      • -
      - - - -
        -
      • -

        searchForSSID

        -
        @Async
        - @WiseFyThread
        - @WaitsForTimeout
        -public void searchForSSID(java.lang.String regexForSSID,
        -                                                                  int timeoutInMillis,
        -                                                                  SearchForSSIDCallbacks callbacks)
        -
        To search local networks and return the first one that contains a given ssid
        -
        -
        Parameters:
        -
        regexForSSID - The regex to be used to search for the ssid
        -
        timeoutInMillis - The number of milliseconds to keep searching for the SSID
        -
        callbacks - The listener to return results to
        -
        See Also:
        -
        execute(Runnable), -SearchForSSIDCallbacks, -WiseFyCodes, -WiseFySearch.findAccessPointByRegex(String, Integer, boolean)
        -
        -
      • -
      - - - -
        -
      • -

        searchForSSIDs

        -
        @Sync
        - @CallingThread
        -public java.util.List<java.lang.String> searchForSSIDs(java.lang.String regexForSSID)
        -
        To search local networks and return the first one that contains a given ssid
        -
        -
        Parameters:
        -
        regexForSSID - The regex to be used to search for the ssid
        -
        Returns:
        -
        String|null - The first SSID that contains the search ssid (if any, else null)
        -
        See Also:
        -
        WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findSSIDsMatchingRegex(String)
        -
        -
      • -
      - - - -
        -
      • -

        searchForSSIDs

        -
        @Async
        - @WiseFyThread
        -public void searchForSSIDs(java.lang.String regexForSSID,
        -                                                 SearchForSSIDsCallbacks callbacks)
        -
        To search local networks and return the first one that contains a given ssid
        -
        -
        Parameters:
        -
        regexForSSID - The regex to be used to search for the ssid
        -
        callbacks - The listener to return results to
        -
        See Also:
        -
        execute(Runnable), -SearchForSSIDCallbacks, -WiseFyCodes, -WiseFyPrerequisites.hasPrerequisites(), -WiseFySearch.findSSIDsMatchingRegex(String)
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/WiseFy.withContext.html b/javadoc/com/isupatches/wisefy/WiseFy.withContext.html deleted file mode 100644 index 8f57a6bd..00000000 --- a/javadoc/com/isupatches/wisefy/WiseFy.withContext.html +++ /dev/null @@ -1,320 +0,0 @@ - - - - - -WiseFy.withContext (wisefy 2.0.0-BETA API) - - - - - - - - - - - - -
-
com.isupatches.wisefy
-

Class WiseFy.withContext

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.WiseFy.withContext
    • -
    -
  • -
-
-
    -
  • -
    -
    Enclosing class:
    -
    WiseFy
    -
    -
    -
    -
    public static class WiseFy.withContext
    -extends java.lang.Object
    -
    Static class for builder pattern - - Implements builder interfaces #Logging #GetSmarts
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      withContext(android.content.Context context) -
      Mandatory - The public constructor for the builder that requires a context
      -
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      WiseFygetSmarts() -
      Mandatory - To build and return a WiseFy instance - - Must be called after withContext - WiseFy.withContext
      -
      WiseFy.withContextlogging(boolean loggingEnabled) -
      Optional - Builder method that enables/disables logging for a WiseWy instance
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        withContext

        -
        public withContext(android.content.Context context)
        -
        Mandatory - The public constructor for the builder that requires a context
        -
        -
        Parameters:
        -
        context - The activity or application context to get a WifiConfiguration and - ConnectivityManager instance
        -
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        getSmarts

        -
        public WiseFy getSmarts()
        -
        Mandatory - To build and return a WiseFy instance - - Must be called after withContext - WiseFy.withContext
        -
        -
        Returns:
        -
        WiseFy - The instance created by the builder
        -
        -
      • -
      - - - -
        -
      • -

        logging

        -
        public WiseFy.withContext logging(boolean loggingEnabled)
        -
        Optional - Builder method that enables/disables logging for a WiseWy instance
        -
        -
        Parameters:
        -
        loggingEnabled - If logging is enabled or disabled for an instance - Logging
        -
        Returns:
        -
        withContext - The builder with updated logging setting
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/WiseFyApplication.html b/javadoc/com/isupatches/wisefy/WiseFyApplication.html deleted file mode 100644 index 55a42a03..00000000 --- a/javadoc/com/isupatches/wisefy/WiseFyApplication.html +++ /dev/null @@ -1,350 +0,0 @@ - - - - - -WiseFyApplication (wisefy 2.0.0-BETA API) - - - - - - - - - - - - -
-
com.isupatches.wisefy
-

Class WiseFyApplication

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • android.content.Context
    • -
    • -
        -
      • android.content.ContextWrapper
      • -
      • -
          -
        • android.app.Application
        • -
        • -
            -
          • com.isupatches.wisefy.WiseFyApplication
          • -
          -
        • -
        -
      • -
      -
    • -
    -
  • -
-
-
    -
  • -
    -
    All Implemented Interfaces:
    -
    android.content.ComponentCallbacks, android.content.ComponentCallbacks2
    -
    -
    -
    -
    public class WiseFyApplication
    -extends android.app.Application
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Nested Class Summary

      -
        -
      • - - -

        Nested classes/interfaces inherited from class android.app.Application

        -android.app.Application.ActivityLifecycleCallbacks, android.app.Application.OnProvideAssistDataListener
      • -
      -
    • -
    - -
      -
    • - - -

      Field Summary

      -
        -
      • - - -

        Fields inherited from class android.content.Context

        -ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, COMPANION_DEVICE_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, FINGERPRINT_SERVICE, HARDWARE_PROPERTIES_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_STATS_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, RECEIVER_VISIBLE_TO_INSTANT_APPS, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SHORTCUT_SERVICE, STORAGE_SERVICE, STORAGE_STATS_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_CLASSIFICATION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_AWARE_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
      • -
      -
        -
      • - - -

        Fields inherited from interface android.content.ComponentCallbacks2

        -TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
      • -
      -
    • -
    - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      WiseFyApplication() 
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      voidonCreate() 
      -
        -
      • - - -

        Methods inherited from class android.app.Application

        -onConfigurationChanged, onLowMemory, onTerminate, onTrimMemory, registerActivityLifecycleCallbacks, registerComponentCallbacks, registerOnProvideAssistDataListener, unregisterActivityLifecycleCallbacks, unregisterComponentCallbacks, unregisterOnProvideAssistDataListener
      • -
      -
        -
      • - - -

        Methods inherited from class android.content.ContextWrapper

        -attachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createContextForSplit, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getSystemServiceName, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startForegroundService, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterReceiver
      • -
      -
        -
      • - - -

        Methods inherited from class android.content.Context

        -getColor, getColorStateList, getDrawable, getString, getString, getSystemService, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes
      • -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        WiseFyApplication

        -
        public WiseFyApplication()
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        onCreate

        -
        public void onCreate()
        -
        -
        Overrides:
        -
        onCreate in class android.app.Application
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/annotations/Async.html b/javadoc/com/isupatches/wisefy/annotations/Async.html deleted file mode 100644 index 2f0f2c2e..00000000 --- a/javadoc/com/isupatches/wisefy/annotations/Async.html +++ /dev/null @@ -1,165 +0,0 @@ - - - - - -Async (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.annotations
-

Annotation Type Async

-
-
-
-
    -
  • -
    -
    -
    @Documented
    - @Target(value=METHOD)
    - @Inherited
    - @Retention(value=RUNTIME)
    -public @interface Async
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/annotations/CallingThread.html b/javadoc/com/isupatches/wisefy/annotations/CallingThread.html deleted file mode 100644 index 6ef214e7..00000000 --- a/javadoc/com/isupatches/wisefy/annotations/CallingThread.html +++ /dev/null @@ -1,165 +0,0 @@ - - - - - -CallingThread (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.annotations
-

Annotation Type CallingThread

-
-
-
-
    -
  • -
    -
    -
    @Documented
    - @Target(value=METHOD)
    - @Inherited
    - @Retention(value=RUNTIME)
    -public @interface CallingThread
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/annotations/Internal.html b/javadoc/com/isupatches/wisefy/annotations/Internal.html deleted file mode 100644 index c213d0d0..00000000 --- a/javadoc/com/isupatches/wisefy/annotations/Internal.html +++ /dev/null @@ -1,164 +0,0 @@ - - - - - -Internal (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.annotations
-

Annotation Type Internal

-
-
-
-
    -
  • -
    -
    -
    @Documented
    - @Inherited
    - @Retention(value=RUNTIME)
    -public @interface Internal
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/annotations/PublicAPI.html b/javadoc/com/isupatches/wisefy/annotations/PublicAPI.html deleted file mode 100644 index 3d2c13d7..00000000 --- a/javadoc/com/isupatches/wisefy/annotations/PublicAPI.html +++ /dev/null @@ -1,164 +0,0 @@ - - - - - -PublicAPI (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.annotations
-

Annotation Type PublicAPI

-
-
-
-
    -
  • -
    -
    -
    @Documented
    - @Inherited
    - @Retention(value=RUNTIME)
    -public @interface PublicAPI
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/annotations/Sync.html b/javadoc/com/isupatches/wisefy/annotations/Sync.html deleted file mode 100644 index 51e01d37..00000000 --- a/javadoc/com/isupatches/wisefy/annotations/Sync.html +++ /dev/null @@ -1,165 +0,0 @@ - - - - - -Sync (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.annotations
-

Annotation Type Sync

-
-
-
-
    -
  • -
    -
    -
    @Documented
    - @Target(value=METHOD)
    - @Inherited
    - @Retention(value=RUNTIME)
    -public @interface Sync
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/annotations/WaitsForTimeout.html b/javadoc/com/isupatches/wisefy/annotations/WaitsForTimeout.html deleted file mode 100644 index 3d6612d3..00000000 --- a/javadoc/com/isupatches/wisefy/annotations/WaitsForTimeout.html +++ /dev/null @@ -1,165 +0,0 @@ - - - - - -WaitsForTimeout (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.annotations
-

Annotation Type WaitsForTimeout

-
-
-
-
    -
  • -
    -
    -
    @Documented
    - @Target(value=METHOD)
    - @Inherited
    - @Retention(value=RUNTIME)
    -public @interface WaitsForTimeout
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/annotations/WiseFyThread.html b/javadoc/com/isupatches/wisefy/annotations/WiseFyThread.html deleted file mode 100644 index ad44491a..00000000 --- a/javadoc/com/isupatches/wisefy/annotations/WiseFyThread.html +++ /dev/null @@ -1,165 +0,0 @@ - - - - - -WiseFyThread (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.annotations
-

Annotation Type WiseFyThread

-
-
-
-
    -
  • -
    -
    -
    @Documented
    - @Target(value=METHOD)
    - @Inherited
    - @Retention(value=RUNTIME)
    -public @interface WiseFyThread
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/annotations/package-frame.html b/javadoc/com/isupatches/wisefy/annotations/package-frame.html deleted file mode 100644 index 8a2eb1a2..00000000 --- a/javadoc/com/isupatches/wisefy/annotations/package-frame.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - -com.isupatches.wisefy.annotations (wisefy 2.0.1 API) - - - - - -

com.isupatches.wisefy.annotations

- - - diff --git a/javadoc/com/isupatches/wisefy/annotations/package-summary.html b/javadoc/com/isupatches/wisefy/annotations/package-summary.html deleted file mode 100644 index 230743b8..00000000 --- a/javadoc/com/isupatches/wisefy/annotations/package-summary.html +++ /dev/null @@ -1,164 +0,0 @@ - - - - - -com.isupatches.wisefy.annotations (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Package com.isupatches.wisefy.annotations

-
-
- -
- - - - - - diff --git a/javadoc/com/isupatches/wisefy/annotations/package-tree.html b/javadoc/com/isupatches/wisefy/annotations/package-tree.html deleted file mode 100644 index cd43612c..00000000 --- a/javadoc/com/isupatches/wisefy/annotations/package-tree.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - - -com.isupatches.wisefy.annotations Class Hierarchy (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Hierarchy For Package com.isupatches.wisefy.annotations

-Package Hierarchies: - -
-
-

Annotation Type Hierarchy

-
    -
  • com.isupatches.wisefy.annotations.CallingThread (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.Internal (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.Sync (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.WaitsForTimeout (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.PublicAPI (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.WiseFyThread (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.Async (implements java.lang.annotation.Annotation)
  • -
-
- - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/AddOpenNetworkCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/AddOpenNetworkCallbacks.html deleted file mode 100644 index 55726798..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/AddOpenNetworkCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -AddOpenNetworkCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface AddOpenNetworkCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface AddOpenNetworkCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        addOpenNetworkWiseFyFailure

        -
        void addOpenNetworkWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        failureAddingOpenNetwork

        -
        void failureAddingOpenNetwork(java.lang.Integer wifiManagerReturnCode)
        -
      • -
      - - - -
        -
      • -

        openNetworkAdded

        -
        void openNetworkAdded(android.net.wifi.WifiConfiguration openNetwork)
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/AddWEPNetworkCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/AddWEPNetworkCallbacks.html deleted file mode 100644 index 51de4917..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/AddWEPNetworkCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -AddWEPNetworkCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface AddWEPNetworkCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface AddWEPNetworkCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        addWEPNetworkWiseFyFailure

        -
        void addWEPNetworkWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        failureAddingWEPNetwork

        -
        void failureAddingWEPNetwork(java.lang.Integer wifiManagerReturnCode)
        -
      • -
      - - - -
        -
      • -

        wepNetworkAdded

        -
        void wepNetworkAdded(android.net.wifi.WifiConfiguration wepNetwork)
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/AddWPA2NetworkCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/AddWPA2NetworkCallbacks.html deleted file mode 100644 index e0d5fc3c..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/AddWPA2NetworkCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -AddWPA2NetworkCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface AddWPA2NetworkCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface AddWPA2NetworkCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        addWPA2NetworkWiseFyFailure

        -
        void addWPA2NetworkWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        failureAddingWPA2Network

        -
        void failureAddingWPA2Network(java.lang.Integer wifiManagerReturnCode)
        -
      • -
      - - - -
        -
      • -

        wpa2NetworkAdded

        -
        void wpa2NetworkAdded(android.net.wifi.WifiConfiguration wpa2Network)
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.html deleted file mode 100644 index 57177114..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.html +++ /dev/null @@ -1,258 +0,0 @@ - - - - - -ConnectToNetworkCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface ConnectToNetworkCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface ConnectToNetworkCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        connectedToNetwork

        -
        void connectedToNetwork()
        -
      • -
      - - - -
        -
      • -

        connectToNetworkWiseFyFailure

        -
        void connectToNetworkWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        failureConnectingToNetwork

        -
        void failureConnectingToNetwork()
        -
      • -
      - - - -
        -
      • -

        networkNotFoundToConnectTo

        -
        void networkNotFoundToConnectTo()
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.html deleted file mode 100644 index 6f4814f7..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -DisableWifiCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface DisableWifiCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface DisableWifiCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        disableWifiWiseFyFailure

        -
        void disableWifiWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        failureDisablingWifi

        -
        void failureDisablingWifi()
        -
      • -
      - - - -
        -
      • -

        wifiDisabled

        -
        void wifiDisabled()
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.html deleted file mode 100644 index 4ace6a80..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -DisconnectFromCurrentNetworkCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface DisconnectFromCurrentNetworkCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface DisconnectFromCurrentNetworkCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        disconnectedFromCurrentNetwork

        -
        void disconnectedFromCurrentNetwork()
        -
      • -
      - - - -
        -
      • -

        disconnectFromCurrentNetworkWiseFyFailure

        -
        void disconnectFromCurrentNetworkWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        failureDisconnectingFromCurrentNetwork

        -
        void failureDisconnectingFromCurrentNetwork()
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.html deleted file mode 100644 index a5377a18..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -EnableWifiCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface EnableWifiCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface EnableWifiCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        enableWifiWiseFyFailure

        -
        void enableWifiWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        failureEnablingWifi

        -
        void failureEnablingWifi()
        -
      • -
      - - - -
        -
      • -

        wifiEnabled

        -
        void wifiEnabled()
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.html deleted file mode 100644 index db312d05..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.html +++ /dev/null @@ -1,232 +0,0 @@ - - - - - -GetCurrentNetworkCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface GetCurrentNetworkCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface GetCurrentNetworkCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        getCurrentNetworkWiseFyFailure

        -
        void getCurrentNetworkWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        retrievedCurrentNetwork

        -
        void retrievedCurrentNetwork(android.net.wifi.WifiInfo currentNetwork)
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.html deleted file mode 100644 index f11a4ef1..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -GetFrequencyCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface GetFrequencyCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface GetFrequencyCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        failureGettingFrequency

        -
        void failureGettingFrequency()
        -
      • -
      - - - -
        -
      • -

        getFrequencyWiseFyFailure

        -
        void getFrequencyWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        retrievedFrequency

        -
        void retrievedFrequency(int frequency)
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.html deleted file mode 100644 index de6fdf6e..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.html +++ /dev/null @@ -1,232 +0,0 @@ - - - - - -GetNearbyAccessPointsCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface GetNearbyAccessPointsCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface GetNearbyAccessPointsCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        getNearbyAccessPointsWiseFyFailure

        -
        void getNearbyAccessPointsWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        retrievedNearbyAccessPoints

        -
        void retrievedNearbyAccessPoints(java.util.List<android.net.wifi.ScanResult> nearbyAccessPoints)
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/GetRSSICallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/GetRSSICallbacks.html deleted file mode 100644 index ce6a28de..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/GetRSSICallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -GetRSSICallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface GetRSSICallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface GetRSSICallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        retrievedRSSI

        -
        void retrievedRSSI(java.lang.Integer rssi)
        -
      • -
      - - - -
        -
      • -

        networkNotFoundToRetrieveRSSI

        -
        void networkNotFoundToRetrieveRSSI()
        -
      • -
      - - - -
        -
      • -

        getRSSIWiseFyFailure

        -
        void getRSSIWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.html deleted file mode 100644 index 24df1244..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -GetSavedNetworkCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface GetSavedNetworkCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface GetSavedNetworkCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        getSavedNetworkWiseFyFailure

        -
        void getSavedNetworkWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        savedNetworkNotFound

        -
        void savedNetworkNotFound()
        -
      • -
      - - - -
        -
      • -

        retrievedSavedNetwork

        -
        void retrievedSavedNetwork(android.net.wifi.WifiConfiguration savedNetwork)
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.html deleted file mode 100644 index 2badcf2d..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -GetSavedNetworksCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface GetSavedNetworksCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface GetSavedNetworksCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        getSavedNetworksWiseFyFailure

        -
        void getSavedNetworksWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        noSavedNetworksFound

        -
        void noSavedNetworksFound()
        -
      • -
      - - - -
        -
      • -

        retrievedSavedNetworks

        -
        void retrievedSavedNetworks(java.util.List<android.net.wifi.WifiConfiguration> savedNetworks)
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.html deleted file mode 100644 index bbfab91b..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.html +++ /dev/null @@ -1,258 +0,0 @@ - - - - - -RemoveNetworkCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface RemoveNetworkCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface RemoveNetworkCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        failureRemovingNetwork

        -
        void failureRemovingNetwork()
        -
      • -
      - - - -
        -
      • -

        networkNotFoundToRemove

        -
        void networkNotFoundToRemove()
        -
      • -
      - - - -
        -
      • -

        networkRemoved

        -
        void networkRemoved()
        -
      • -
      - - - -
        -
      • -

        removeNetworkWiseFyFailure

        -
        void removeNetworkWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.html deleted file mode 100644 index 5552d05a..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -SearchForAccessPointCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface SearchForAccessPointCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface SearchForAccessPointCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        searchForAccessPointWiseFyFailure

        -
        void searchForAccessPointWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        accessPointFound

        -
        void accessPointFound(android.net.wifi.ScanResult accessPoint)
        -
      • -
      - - - -
        -
      • -

        accessPointNotFound

        -
        void accessPointNotFound()
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.html deleted file mode 100644 index 233654da..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -SearchForAccessPointsCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface SearchForAccessPointsCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface SearchForAccessPointsCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        searchForAccessPointsWiseFyFailure

        -
        void searchForAccessPointsWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        foundAccessPoints

        -
        void foundAccessPoints(java.util.List<android.net.wifi.ScanResult> accessPoints)
        -
      • -
      - - - -
        -
      • -

        noAccessPointsFound

        -
        void noAccessPointsFound()
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.html deleted file mode 100644 index a1ee119c..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -SearchForSSIDCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface SearchForSSIDCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface SearchForSSIDCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        searchForSSIDWiseFyFailure

        -
        void searchForSSIDWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        ssidFound

        -
        void ssidFound(java.lang.String ssid)
        -
      • -
      - - - -
        -
      • -

        ssidNotFound

        -
        void ssidNotFound()
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.html b/javadoc/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.html deleted file mode 100644 index 66cea915..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - -SearchForSSIDsCallbacks (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.callbacks
-

Interface SearchForSSIDsCallbacks

-
-
-
-
    -
  • -
    -
    -
    public interface SearchForSSIDsCallbacks
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        searchForSSIDsWiseFyFailure

        -
        void searchForSSIDsWiseFyFailure(java.lang.Integer wisefyReturnCode)
        -
      • -
      - - - -
        -
      • -

        retrievedSSIDs

        -
        void retrievedSSIDs(java.util.List<java.lang.String> ssids)
        -
      • -
      - - - -
        -
      • -

        noSSIDsFound

        -
        void noSSIDsFound()
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/package-frame.html b/javadoc/com/isupatches/wisefy/callbacks/package-frame.html deleted file mode 100644 index 781e0135..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/package-frame.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - -com.isupatches.wisefy.callbacks (wisefy 2.0.1 API) - - - - - -

com.isupatches.wisefy.callbacks

- - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/package-summary.html b/javadoc/com/isupatches/wisefy/callbacks/package-summary.html deleted file mode 100644 index f8c03a0b..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/package-summary.html +++ /dev/null @@ -1,208 +0,0 @@ - - - - - -com.isupatches.wisefy.callbacks (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Package com.isupatches.wisefy.callbacks

-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/callbacks/package-tree.html b/javadoc/com/isupatches/wisefy/callbacks/package-tree.html deleted file mode 100644 index 12c957e0..00000000 --- a/javadoc/com/isupatches/wisefy/callbacks/package-tree.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - -com.isupatches.wisefy.callbacks Class Hierarchy (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Hierarchy For Package com.isupatches.wisefy.callbacks

-Package Hierarchies: - -
-
-

Interface Hierarchy

- -
- - - - - - diff --git a/javadoc/com/isupatches/wisefy/constants/Capabilities.html b/javadoc/com/isupatches/wisefy/constants/Capabilities.html deleted file mode 100644 index 72eefe0a..00000000 --- a/javadoc/com/isupatches/wisefy/constants/Capabilities.html +++ /dev/null @@ -1,343 +0,0 @@ - - - - - -Capabilities (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.constants
-

Class Capabilities

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.constants.Capabilities
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class Capabilities
    -extends java.lang.Object
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Field Summary

      - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Fields 
      Modifier and TypeField and Description
      static java.lang.StringEAP 
      static java.lang.StringPSK 
      static java.lang.StringWEP 
      static java.lang.StringWPA 
      static java.lang.StringWPA2 
      -
    • -
    - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      Capabilities() 
      -
    • -
    - -
      -
    • - - -

      Method Summary

      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
- -
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/constants/NetworkTypes.html b/javadoc/com/isupatches/wisefy/constants/NetworkTypes.html deleted file mode 100644 index 1fc9bf67..00000000 --- a/javadoc/com/isupatches/wisefy/constants/NetworkTypes.html +++ /dev/null @@ -1,292 +0,0 @@ - - - - - -NetworkTypes (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.constants
-

Class NetworkTypes

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.constants.NetworkTypes
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class NetworkTypes
    -extends java.lang.Object
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Field Summary

      - - - - - - - - - - - - - - -
      Fields 
      Modifier and TypeField and Description
      static java.lang.StringMOBILE 
      static java.lang.StringWIFI 
      -
    • -
    - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      NetworkTypes() 
      -
    • -
    - -
      -
    • - - -

      Method Summary

      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - - - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        NetworkTypes

        -
        public NetworkTypes()
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/constants/WiseFyCodes.html b/javadoc/com/isupatches/wisefy/constants/WiseFyCodes.html deleted file mode 100644 index 88b7c0c0..00000000 --- a/javadoc/com/isupatches/wisefy/constants/WiseFyCodes.html +++ /dev/null @@ -1,309 +0,0 @@ - - - - - -WiseFyCodes (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.constants
-

Class WiseFyCodes

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.constants.WiseFyCodes
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class WiseFyCodes
    -extends java.lang.Object
    -
  • -
-
-
-
    -
  • - - - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      WiseFyCodes() 
      -
    • -
    - -
      -
    • - - -

      Method Summary

      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - - - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        WiseFyCodes

        -
        public WiseFyCodes()
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/constants/package-frame.html b/javadoc/com/isupatches/wisefy/constants/package-frame.html deleted file mode 100644 index 4d9eff45..00000000 --- a/javadoc/com/isupatches/wisefy/constants/package-frame.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - -com.isupatches.wisefy.constants (wisefy 2.0.1 API) - - - - - -

com.isupatches.wisefy.constants

- - - diff --git a/javadoc/com/isupatches/wisefy/constants/package-summary.html b/javadoc/com/isupatches/wisefy/constants/package-summary.html deleted file mode 100644 index 7133fb60..00000000 --- a/javadoc/com/isupatches/wisefy/constants/package-summary.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - -com.isupatches.wisefy.constants (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Package com.isupatches.wisefy.constants

-
-
- -
- - - - - - diff --git a/javadoc/com/isupatches/wisefy/constants/package-tree.html b/javadoc/com/isupatches/wisefy/constants/package-tree.html deleted file mode 100644 index fbb5a155..00000000 --- a/javadoc/com/isupatches/wisefy/constants/package-tree.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - - -com.isupatches.wisefy.constants Class Hierarchy (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Hierarchy For Package com.isupatches.wisefy.constants

-Package Hierarchies: - -
-
-

Class Hierarchy

- -
- - - - - - diff --git a/javadoc/com/isupatches/wisefy/package-frame.html b/javadoc/com/isupatches/wisefy/package-frame.html deleted file mode 100644 index c845c99b..00000000 --- a/javadoc/com/isupatches/wisefy/package-frame.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - -com.isupatches.wisefy (wisefy 2.0.1 API) - - - - - -

com.isupatches.wisefy

-
-

Classes

- -
- - diff --git a/javadoc/com/isupatches/wisefy/package-summary.html b/javadoc/com/isupatches/wisefy/package-summary.html deleted file mode 100644 index 0fae9889..00000000 --- a/javadoc/com/isupatches/wisefy/package-summary.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - - -com.isupatches.wisefy (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Package com.isupatches.wisefy

-
-
-
    -
  • - - - - - - - - - - - - - - - - -
    Class Summary 
    ClassDescription
    WiseFy -
    Main class for WiseFy that provides a synchronous and asynchronous API to manipulate and query - for different parts of a device's wifi configuration and status.
    -
    WiseFy.brains -
    Static class for builder pattern - - Implements builder interfaces #Logging #GetSmarts
    -
    -
  • -
-
- - - - - - diff --git a/javadoc/com/isupatches/wisefy/package-tree.html b/javadoc/com/isupatches/wisefy/package-tree.html deleted file mode 100644 index 337de58d..00000000 --- a/javadoc/com/isupatches/wisefy/package-tree.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - - -com.isupatches.wisefy Class Hierarchy (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Hierarchy For Package com.isupatches.wisefy

-Package Hierarchies: - -
-
-

Class Hierarchy

- -
- - - - - - diff --git a/javadoc/com/isupatches/wisefy/threads/WiseFyHandlerThread.html b/javadoc/com/isupatches/wisefy/threads/WiseFyHandlerThread.html deleted file mode 100644 index b4edee60..00000000 --- a/javadoc/com/isupatches/wisefy/threads/WiseFyHandlerThread.html +++ /dev/null @@ -1,398 +0,0 @@ - - - - - -WiseFyHandlerThread (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.threads
-

Class WiseFyHandlerThread

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • java.lang.Thread
    • -
    • -
        -
      • android.os.HandlerThread
      • -
      • -
          -
        • com.isupatches.wisefy.threads.WiseFyHandlerThread
        • -
        -
      • -
      -
    • -
    -
  • -
-
-
    -
  • -
    -
    All Implemented Interfaces:
    -
    java.lang.Runnable
    -
    -
    -
    -
    public class WiseFyHandlerThread
    -extends android.os.HandlerThread
    -
    A Thread to use for all WiseFy background processing - - *NOTE* Must be cleaned!! WiseFy.dump()
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Nested Class Summary

      -
        -
      • - - -

        Nested classes/interfaces inherited from class java.lang.Thread

        -java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
      • -
      -
    • -
    - -
      -
    • - - -

      Field Summary

      - - - - - - - - - - -
      Fields 
      Modifier and TypeField and Description
      static java.lang.StringTAG 
      -
        -
      • - - -

        Fields inherited from class java.lang.Thread

        -MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
      • -
      -
    • -
    - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      WiseFyHandlerThread(java.lang.String name, - boolean loggingEnabled) 
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      booleanquit() 
      booleanquitSafely() 
      voidstart() 
      -
        -
      • - - -

        Methods inherited from class android.os.HandlerThread

        -getLooper, getThreadId, onLooperPrepared, run
      • -
      -
        -
      • - - -

        Methods inherited from class java.lang.Thread

        -activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
      • -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Field Detail

      - - - -
        -
      • -

        TAG

        -
        public static final java.lang.String TAG
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        WiseFyHandlerThread

        -
        public WiseFyHandlerThread(java.lang.String name,
        -                           boolean loggingEnabled)
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        start

        -
        public void start()
        -
        -
        Overrides:
        -
        start in class java.lang.Thread
        -
        -
      • -
      - - - -
        -
      • -

        quit

        -
        public boolean quit()
        -
        -
        Overrides:
        -
        quit in class android.os.HandlerThread
        -
        -
      • -
      - - - -
        -
      • -

        quitSafely

        -
        public boolean quitSafely()
        -
        -
        Overrides:
        -
        quitSafely in class android.os.HandlerThread
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/threads/package-frame.html b/javadoc/com/isupatches/wisefy/threads/package-frame.html deleted file mode 100644 index 7c3b531b..00000000 --- a/javadoc/com/isupatches/wisefy/threads/package-frame.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - -com.isupatches.wisefy.threads (wisefy 2.0.1 API) - - - - - -

com.isupatches.wisefy.threads

-
-

Classes

- -
- - diff --git a/javadoc/com/isupatches/wisefy/threads/package-summary.html b/javadoc/com/isupatches/wisefy/threads/package-summary.html deleted file mode 100644 index e24e5c0b..00000000 --- a/javadoc/com/isupatches/wisefy/threads/package-summary.html +++ /dev/null @@ -1,144 +0,0 @@ - - - - - -com.isupatches.wisefy.threads (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Package com.isupatches.wisefy.threads

-
-
-
    -
  • - - - - - - - - - - - - -
    Class Summary 
    ClassDescription
    WiseFyHandlerThread -
    A Thread to use for all WiseFy background processing - - *NOTE* Must be cleaned!! WiseFy.dump()
    -
    -
  • -
-
- - - - - - diff --git a/javadoc/com/isupatches/wisefy/threads/package-tree.html b/javadoc/com/isupatches/wisefy/threads/package-tree.html deleted file mode 100644 index 11ae16c3..00000000 --- a/javadoc/com/isupatches/wisefy/threads/package-tree.html +++ /dev/null @@ -1,143 +0,0 @@ - - - - - -com.isupatches.wisefy.threads Class Hierarchy (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Hierarchy For Package com.isupatches.wisefy.threads

-Package Hierarchies: - -
-
-

Class Hierarchy

-
    -
  • java.lang.Object -
      -
    • java.lang.Thread (implements java.lang.Runnable) - -
    • -
    -
  • -
-
- - - - - - diff --git a/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html b/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html deleted file mode 100644 index 57d01775..00000000 --- a/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html +++ /dev/null @@ -1,289 +0,0 @@ - - - - - -GetManagerUtil (wisefy 1.0.8 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.test.util
-

Class GetManagerUtil

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.test.util.GetManagerUtil
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    public class GetManagerUtil
    -extends java.lang.Object
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - -
      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      android.net.ConnectivityManagergetConnectivityManager(android.content.Context context) -
      To get a Connectivity manger instance from an activity's context.
      -
      static GetManagerUtilgetInstance() 
      android.net.wifi.WifiManagergetWiFiManager(android.content.Context context) -
      To get a WiFi manger instance from an activity's context.
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        getInstance

        -
        public static GetManagerUtil getInstance()
        -
        -
        Returns:
        -
        instance of GetManagerUtil
        -
        -
      • -
      - - - -
        -
      • -

        getConnectivityManager

        -
        public android.net.ConnectivityManager getConnectivityManager(android.content.Context context)
        -
        To get a Connectivity manger instance from an activity's context.
        -
        -
        Parameters:
        -
        context - - The context to use to retrieve a connectivity manager via getSystemService
        -
        Returns:
        -
        ConnectivityManager|null
        -
        See Also:
        -
        ConnectivityManager, -WiseFy
        -
        -
      • -
      - - - -
        -
      • -

        getWiFiManager

        -
        public android.net.wifi.WifiManager getWiFiManager(android.content.Context context)
        -
        To get a WiFi manger instance from an activity's context.
        -
        -
        Parameters:
        -
        context - - The context to use to retrieve a wifi manager via getSystemService
        -
        Returns:
        -
        WifiManager|null
        -
        See Also:
        -
        WifiManager, -WiseFy
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/util/LogUtil.html b/javadoc/com/isupatches/wisefy/util/LogUtil.html deleted file mode 100644 index 8f709909..00000000 --- a/javadoc/com/isupatches/wisefy/util/LogUtil.html +++ /dev/null @@ -1,288 +0,0 @@ - - - - - -LogUtil (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.util
-

Class LogUtil

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.util.LogUtil
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    @Internal
    -public class LogUtil
    -extends java.lang.Object
    -
    Logging helper class
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      LogUtil() 
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - -
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static booleanisLoggable(java.lang.String tag, - int level, - boolean loggingEnabled) -
      Checks to see given a TAG, log level, and if logging is enabled if logging should occur
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        LogUtil

        -
        public LogUtil()
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        isLoggable

        -
        public static boolean isLoggable(java.lang.String tag,
        -                                 int level,
        -                                 boolean loggingEnabled)
        -
        Checks to see given a TAG, log level, and if logging is enabled if logging should occur
        -
        -
        Parameters:
        -
        tag - The tag to be used for the log
        -
        level - The level of logging (i.e Log.DEBUG, Log.WARN, Log.ERROR, etc)
        -
        loggingEnabled - If the instances of WiseFy has logging set to always be enabled
        -
        Returns:
        -
        boolean - True if logging should occur based off level and other factors
        -
        See Also:
        -
        Log
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/util/ManagerUtil.html b/javadoc/com/isupatches/wisefy/util/ManagerUtil.html deleted file mode 100644 index 327e64e8..00000000 --- a/javadoc/com/isupatches/wisefy/util/ManagerUtil.html +++ /dev/null @@ -1,289 +0,0 @@ - - - - - -ManagerUtil (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.util
-

Class ManagerUtil

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.util.ManagerUtil
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    @Internal
    -public class ManagerUtil
    -extends java.lang.Object
    -
    Manager helper class
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - -
      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      android.net.ConnectivityManagergetConnectivityManager(android.content.Context context) -
      To get a Connectivity manger instance from an activity's context.
      -
      static ManagerUtilgetInstance() 
      android.net.wifi.WifiManagergetWiFiManager(android.content.Context context) -
      To get a WiFi manger instance from an activity's context.
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        getInstance

        -
        public static ManagerUtil getInstance()
        -
        -
        Returns:
        -
        instance of ManagerUtil
        -
        -
      • -
      - - - -
        -
      • -

        getConnectivityManager

        -
        public android.net.ConnectivityManager getConnectivityManager(android.content.Context context)
        -
        To get a Connectivity manger instance from an activity's context.
        -
        -
        Parameters:
        -
        context - The context to use to retrieve a connectivity manager via getSystemService
        -
        Returns:
        -
        ConnectivityManager|null
        -
        See Also:
        -
        ConnectivityManager
        -
        -
      • -
      - - - -
        -
      • -

        getWiFiManager

        -
        public android.net.wifi.WifiManager getWiFiManager(android.content.Context context)
        -
        To get a WiFi manger instance from an activity's context.
        -
        -
        Parameters:
        -
        context - The context to use to retrieve a wifi manager via getSystemService
        -
        Returns:
        -
        WifiManager|null
        -
        See Also:
        -
        WifiManager
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/util/SSIDUtil.html b/javadoc/com/isupatches/wisefy/util/SSIDUtil.html deleted file mode 100644 index 1e84e046..00000000 --- a/javadoc/com/isupatches/wisefy/util/SSIDUtil.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - -SSIDUtil (wisefy 2.0.0 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.util
-

Class SSIDUtil

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.util.SSIDUtil
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    @Internal
    -public class SSIDUtil
    -extends java.lang.Object
    -
    A helper class to manipulate the string value for SSIDs
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Method Summary

      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/util/SleepUtil.html b/javadoc/com/isupatches/wisefy/util/SleepUtil.html deleted file mode 100644 index dd312ae6..00000000 --- a/javadoc/com/isupatches/wisefy/util/SleepUtil.html +++ /dev/null @@ -1,278 +0,0 @@ - - - - - -SleepUtil (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.util
-

Class SleepUtil

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.util.SleepUtil
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    @Internal
    -public class SleepUtil
    -extends java.lang.Object
    -
    A helper class for shared wait logic
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Summary

      - - - - - - - - -
      Constructors 
      Constructor and Description
      SleepUtil() 
      -
    • -
    - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - -
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static voidsleep(long timeToSleepInMillis) -
      Used to wait for a given amount of time (in milliseconds)
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        SleepUtil

        -
        public SleepUtil()
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        sleep

        -
        public static void sleep(long timeToSleepInMillis)
        -
        Used to wait for a given amount of time (in milliseconds)
        -
        -
        Parameters:
        -
        timeToSleepInMillis - The number of milliseconds to sleep
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/util/WifiConfigurationUtil.html b/javadoc/com/isupatches/wisefy/util/WifiConfigurationUtil.html deleted file mode 100644 index ac851be5..00000000 --- a/javadoc/com/isupatches/wisefy/util/WifiConfigurationUtil.html +++ /dev/null @@ -1,313 +0,0 @@ - - - - - -WifiConfigurationUtil (wisefy 2.0.1 API) - - - - - - - - - - - - -
-
com.isupatches.wisefy.util
-

Class WifiConfigurationUtil

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.isupatches.wisefy.util.WifiConfigurationUtil
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    @Internal
    -public class WifiConfigurationUtil
    -extends java.lang.Object
    -
    A helper class to generate WifiConfigurations
    -
  • -
-
-
- -
-
-
    -
  • - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        getInstance

        -
        public static WifiConfigurationUtil getInstance()
        -
        -
        Returns:
        -
        instance of WifiConfigurationUtil
        -
        -
      • -
      - - - -
        -
      • -

        generateOpenNetworkConfiguration

        -
        public android.net.wifi.WifiConfiguration generateOpenNetworkConfiguration(java.lang.String ssid)
        -
        To generate a configuration for an open network
        -
        -
        Parameters:
        -
        ssid - The ssid for the open network's configuration
        -
        Returns:
        -
        WifiConfiguration - The open network configuration
        -
        -
      • -
      - - - -
        -
      • -

        generateWEPNetworkConfiguration

        -
        public android.net.wifi.WifiConfiguration generateWEPNetworkConfiguration(java.lang.String ssid,
        -                                                                          java.lang.String password)
        -
        To generate a configuration for a WEP network
        -
        -
        Parameters:
        -
        ssid - The ssid for the WEP network's configuration
        -
        password - The password for the WEP network's configuration
        -
        Returns:
        -
        WifiConfiguration - The WEP network configuration
        -
        -
      • -
      - - - -
        -
      • -

        generateWPA2NetworkConfiguration

        -
        public android.net.wifi.WifiConfiguration generateWPA2NetworkConfiguration(java.lang.String ssid,
        -                                                                           java.lang.String password)
        -
        To generate a configuration for a WPA2 network
        -
        -
        Parameters:
        -
        ssid - The ssid for the WPA2 network's configuration
        -
        password - The password for the WPA2 network's configuration
        -
        Returns:
        -
        WifiConfiguration - The WPA2 network configuration
        -
        -
      • -
      -
    • -
    -
  • -
-
-
- - - - - - - diff --git a/javadoc/com/isupatches/wisefy/util/package-frame.html b/javadoc/com/isupatches/wisefy/util/package-frame.html deleted file mode 100644 index 6ae90248..00000000 --- a/javadoc/com/isupatches/wisefy/util/package-frame.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - -com.isupatches.wisefy.util (wisefy 2.0.1 API) - - - - - -

com.isupatches.wisefy.util

- - - diff --git a/javadoc/com/isupatches/wisefy/util/package-summary.html b/javadoc/com/isupatches/wisefy/util/package-summary.html deleted file mode 100644 index 24c13b24..00000000 --- a/javadoc/com/isupatches/wisefy/util/package-summary.html +++ /dev/null @@ -1,160 +0,0 @@ - - - - - -com.isupatches.wisefy.util (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Package com.isupatches.wisefy.util

-
-
-
    -
  • - - - - - - - - - - - - - - - - - - - - - - - - -
    Class Summary 
    ClassDescription
    LogUtil -
    Logging helper class
    -
    ManagerUtil -
    Manager helper class
    -
    SleepUtil -
    A helper class for shared wait logic
    -
    WifiConfigurationUtil -
    A helper class to generate WifiConfigurations
    -
    -
  • -
-
- - - - - - diff --git a/javadoc/com/isupatches/wisefy/util/package-tree.html b/javadoc/com/isupatches/wisefy/util/package-tree.html deleted file mode 100644 index b891e573..00000000 --- a/javadoc/com/isupatches/wisefy/util/package-tree.html +++ /dev/null @@ -1,138 +0,0 @@ - - - - - -com.isupatches.wisefy.util Class Hierarchy (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Hierarchy For Package com.isupatches.wisefy.util

-Package Hierarchies: - -
-
-

Class Hierarchy

- -
- - - - - - diff --git a/javadoc/constant-values.html b/javadoc/constant-values.html deleted file mode 100644 index 1ba3d3f3..00000000 --- a/javadoc/constant-values.html +++ /dev/null @@ -1,273 +0,0 @@ - - - - - -Constant Field Values (wisefy 2.0.1 API) - - - - - - - - - - - -
-

Constant Field Values

-

Contents

- -
-
- - -

com.isupatches.*

- -
    -
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    com.isupatches.wisefy.constants.Capabilities 
    Modifier and TypeConstant FieldValue
    - -public static final java.lang.StringEAP"EAP"
    - -public static final java.lang.StringPSK"PSK"
    - -public static final java.lang.StringWEP"WEP"
    - -public static final java.lang.StringWPA"WPA"
    - -public static final java.lang.StringWPA2"WPA2"
    -
  • -
  • - - - - - - - - - - - - - - - - - - - -
    com.isupatches.wisefy.constants.NetworkTypes 
    Modifier and TypeConstant FieldValue
    - -public static final java.lang.StringMOBILE"MOBILE"
    - -public static final java.lang.StringWIFI"WIFI"
    -
  • -
  • - - - - - - - - - - - - - - - - - - - - - - - - -
    com.isupatches.wisefy.constants.WiseFyCodes 
    Modifier and TypeConstant FieldValue
    - -public static final intMISSING_PARAMETER-1000
    - -public static final intMISSING_PREREQUISITE-1001
    - -public static final intNETWORK_ALREADY_CONFIGURED-1002
    -
  • -
-
- - - - - - diff --git a/javadoc/deprecated-list.html b/javadoc/deprecated-list.html deleted file mode 100644 index 5e79a13b..00000000 --- a/javadoc/deprecated-list.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - -Deprecated List (wisefy 2.0.1 API) - - - - - - - - -
- - - - - - - -
- - -
-

Deprecated API

-

Contents

-
- -
- - - - - - - -
- - - - diff --git a/javadoc/help-doc.html b/javadoc/help-doc.html deleted file mode 100644 index fed15ea2..00000000 --- a/javadoc/help-doc.html +++ /dev/null @@ -1,223 +0,0 @@ - - - - - -API Help (wisefy 2.0.1 API) - - - - - - - - -
- - - - - - - -
- - -
-

How This API Document Is Organized

-
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
-
-
-
    -
  • -

    Overview

    -

    The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

    -
  • -
  • -

    Package

    -

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    -
      -
    • Interfaces (italic)
    • -
    • Classes
    • -
    • Enums
    • -
    • Exceptions
    • -
    • Errors
    • -
    • Annotation Types
    • -
    -
  • -
  • -

    Class/Interface

    -

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    -
      -
    • Class inheritance diagram
    • -
    • Direct Subclasses
    • -
    • All Known Subinterfaces
    • -
    • All Known Implementing Classes
    • -
    • Class/interface declaration
    • -
    • Class/interface description
    • -
    -
      -
    • Nested Class Summary
    • -
    • Field Summary
    • -
    • Constructor Summary
    • -
    • Method Summary
    • -
    -
      -
    • Field Detail
    • -
    • Constructor Detail
    • -
    • Method Detail
    • -
    -

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    -
  • -
  • -

    Annotation Type

    -

    Each annotation type has its own separate page with the following sections:

    -
      -
    • Annotation Type declaration
    • -
    • Annotation Type description
    • -
    • Required Element Summary
    • -
    • Optional Element Summary
    • -
    • Element Detail
    • -
    -
  • -
  • -

    Enum

    -

    Each enum has its own separate page with the following sections:

    -
      -
    • Enum declaration
    • -
    • Enum description
    • -
    • Enum Constant Summary
    • -
    • Enum Constant Detail
    • -
    -
  • -
  • -

    Tree (Class Hierarchy)

    -

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    -
      -
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • -
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • -
    -
  • -
  • -

    Deprecated API

    -

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    -
  • -
  • -

    Index

    -

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    -
  • -
  • -

    Prev/Next

    -

    These links take you to the next or previous class, interface, package, or related page.

    -
  • -
  • -

    Frames/No Frames

    -

    These links show and hide the HTML frames. All pages are available with or without frames.

    -
  • -
  • -

    All Classes

    -

    The All Classes link shows all classes and interfaces except non-static nested types.

    -
  • -
  • -

    Serialized Form

    -

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    -
  • -
  • -

    Constant Field Values

    -

    The Constant Field Values page lists the static final fields and their values.

    -
  • -
-This help file applies to API documentation generated using the standard doclet.
- -
- - - - - - - -
- - - - diff --git a/javadoc/index-all.html b/javadoc/index-all.html deleted file mode 100644 index 0076988b..00000000 --- a/javadoc/index-all.html +++ /dev/null @@ -1,788 +0,0 @@ - - - - - -Index (wisefy 2.0.1 API) - - - - - - - - -
- - - - - - - -
- - -
A B C D E F G I L M N O P Q R S T W  - - -

A

-
-
accessPointFound(ScanResult) - Method in interface com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks
-
 
-
accessPointNotFound() - Method in interface com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks
-
 
-
addOpenNetwork(String) - Method in class com.isupatches.wisefy.WiseFy
-
-
To add an open network to the user's configured network list
-
-
addOpenNetwork(String, AddOpenNetworkCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To add an open network to the user's configured network list
-
-
AddOpenNetworkCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
addOpenNetworkWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks
-
 
-
addWEPNetwork(String, String) - Method in class com.isupatches.wisefy.WiseFy
-
-
To add a WEP network to the user's configured network list
-
-
addWEPNetwork(String, String, AddWEPNetworkCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To add a WEP network to the user's configured network list
-
-
AddWEPNetworkCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
addWEPNetworkWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks
-
 
-
addWPA2Network(String, String) - Method in class com.isupatches.wisefy.WiseFy
-
-
To add a WPA2 network to the user's configured network list
-
-
addWPA2Network(String, String, AddWPA2NetworkCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To add a WPA2 network to the user's configured network list
-
-
AddWPA2NetworkCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
addWPA2NetworkWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks
-
 
-
Async - Annotation Type in com.isupatches.wisefy.annotations
-
 
-
- - - -

B

-
-
brains(Context) - Constructor for class com.isupatches.wisefy.WiseFy.brains
-
-
Mandatory - The public constructor for the builder that requires a context
-
-
- - - -

C

-
-
calculateBars(int, int) - Method in class com.isupatches.wisefy.WiseFy
-
-
To convert an RSSI level for a network to a number of bars
-
-
CallingThread - Annotation Type in com.isupatches.wisefy.annotations
-
 
-
Capabilities - Class in com.isupatches.wisefy.constants
-
 
-
Capabilities() - Constructor for class com.isupatches.wisefy.constants.Capabilities
-
 
-
com.isupatches.wisefy - package com.isupatches.wisefy
-
 
-
com.isupatches.wisefy.annotations - package com.isupatches.wisefy.annotations
-
 
-
com.isupatches.wisefy.callbacks - package com.isupatches.wisefy.callbacks
-
 
-
com.isupatches.wisefy.constants - package com.isupatches.wisefy.constants
-
 
-
com.isupatches.wisefy.threads - package com.isupatches.wisefy.threads
-
 
-
com.isupatches.wisefy.util - package com.isupatches.wisefy.util
-
 
-
compareSignalLevel(int, int) - Method in class com.isupatches.wisefy.WiseFy
-
-
To compare the signal strength of two networks
-
-
connectedToNetwork() - Method in interface com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks
-
 
-
connectToNetwork(String, int) - Method in class com.isupatches.wisefy.WiseFy
-
-
Used to connect to a network - - Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity
-
-
connectToNetwork(String, int, ConnectToNetworkCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
Used to connect to a network - - Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity
-
-
ConnectToNetworkCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
connectToNetworkWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks
-
 
-
- - - -

D

-
-
disableWifi() - Method in class com.isupatches.wisefy.WiseFy
-
-
To disable Wifi on a user's device
-
-
disableWifi(DisableWifiCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To disable Wifi on a user's device
-
-
DisableWifiCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
disableWifiWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.DisableWifiCallbacks
-
 
-
disconnectedFromCurrentNetwork() - Method in interface com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks
-
 
-
disconnectFromCurrentNetwork() - Method in class com.isupatches.wisefy.WiseFy
-
-
To disconnect the user from their current network
-
-
disconnectFromCurrentNetwork(DisconnectFromCurrentNetworkCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To disconnect the user from their current network
-
-
DisconnectFromCurrentNetworkCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
disconnectFromCurrentNetworkWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks
-
 
-
dump() - Method in class com.isupatches.wisefy.WiseFy
-
-
Used to cleanup the thread started by WiseFy
-
-
- - - -

E

-
-
EAP - Static variable in class com.isupatches.wisefy.constants.Capabilities
-
 
-
enableWifi() - Method in class com.isupatches.wisefy.WiseFy
-
-
To enable Wifi on a user's device
-
-
enableWifi(EnableWifiCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To enable Wifi on a user's device
-
-
EnableWifiCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
enableWifiWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.EnableWifiCallbacks
-
 
-
- - - -

F

-
-
failureAddingOpenNetwork(Integer) - Method in interface com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks
-
 
-
failureAddingWEPNetwork(Integer) - Method in interface com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks
-
 
-
failureAddingWPA2Network(Integer) - Method in interface com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks
-
 
-
failureConnectingToNetwork() - Method in interface com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks
-
 
-
failureDisablingWifi() - Method in interface com.isupatches.wisefy.callbacks.DisableWifiCallbacks
-
 
-
failureDisconnectingFromCurrentNetwork() - Method in interface com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks
-
 
-
failureEnablingWifi() - Method in interface com.isupatches.wisefy.callbacks.EnableWifiCallbacks
-
 
-
failureGettingFrequency() - Method in interface com.isupatches.wisefy.callbacks.GetFrequencyCallbacks
-
 
-
failureRemovingNetwork() - Method in interface com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks
-
 
-
foundAccessPoints(List<ScanResult>) - Method in interface com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks
-
 
-
- - - -

G

-
-
generateOpenNetworkConfiguration(String) - Method in class com.isupatches.wisefy.util.WifiConfigurationUtil
-
-
To generate a configuration for an open network
-
-
generateWEPNetworkConfiguration(String, String) - Method in class com.isupatches.wisefy.util.WifiConfigurationUtil
-
-
To generate a configuration for a WEP network
-
-
generateWPA2NetworkConfiguration(String, String) - Method in class com.isupatches.wisefy.util.WifiConfigurationUtil
-
-
To generate a configuration for a WPA2 network
-
-
getConnectivityManager(Context) - Method in class com.isupatches.wisefy.util.ManagerUtil
-
-
To get a Connectivity manger instance from an activity's context.
-
-
getCurrentNetwork() - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve the user's current network
-
-
getCurrentNetwork(GetCurrentNetworkCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve the user's current network
-
-
GetCurrentNetworkCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
getCurrentNetworkWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks
-
 
-
getFrequency() - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve the frequency of the device's current network
-
-
getFrequency(GetFrequencyCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve the frequency of the device's current network
-
-
getFrequency(WifiInfo) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve the frequency of a network
-
-
getFrequency(WifiInfo, GetFrequencyCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve the frequency of a network
-
-
GetFrequencyCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
getFrequencyWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.GetFrequencyCallbacks
-
 
-
getInstance() - Static method in class com.isupatches.wisefy.util.ManagerUtil
-
 
-
getInstance() - Static method in class com.isupatches.wisefy.util.WifiConfigurationUtil
-
 
-
getNearbyAccessPoints(boolean) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve a list of nearby access points - - *NOTE* Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI (will always take the highest signal strength)
-
-
getNearbyAccessPoints(boolean, GetNearbyAccessPointsCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve a list of nearby access points - - *NOTE* Setting filterDuplicates to true will not return SSIDs with a weaker signal strength (will always take the highest)
-
-
GetNearbyAccessPointsCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
getNearbyAccessPointsWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks
-
 
-
getRSSI(String, boolean, int) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve the RSSI of the first network matching a given regex - - *NOTE* Setting takeHighest to true will return the access point with the highest RSSI for the given SSID
-
-
getRSSI(String, boolean, int, GetRSSICallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve the RSSI of the first network matching a given regex - - *NOTE* Setting takeHighest to true will return the access point with the highest RSSI for the given SSID
-
-
GetRSSICallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
getRSSIWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.GetRSSICallbacks
-
 
-
getSavedNetwork(String) - Method in class com.isupatches.wisefy.WiseFy
-
-
To search for and return a saved WiFiConfiguration given an SSID
-
-
getSavedNetwork(String, GetSavedNetworkCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To search for and return a saved WiFiConfiguration given an SSID
-
-
GetSavedNetworkCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
getSavedNetworks() - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve a list of saved networks on a user's device
-
-
getSavedNetworks(GetSavedNetworksCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve a list of saved networks on a user's device
-
-
getSavedNetworks(String) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve a list of saved networks on a user's device that match a given regex
-
-
getSavedNetworks(String, GetSavedNetworksCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve a list of saved networks on a user's device that match a given regex
-
-
GetSavedNetworksCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
getSavedNetworksWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks
-
 
-
getSavedNetworkWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks
-
 
-
getSmarts() - Method in class com.isupatches.wisefy.WiseFy.brains
-
-
Mandatory - To build and return a WiseFy instance - - *NOTE* Must be called after brains
-
-
getWiFiManager(Context) - Method in class com.isupatches.wisefy.util.ManagerUtil
-
-
To get a WiFi manger instance from an activity's context.
-
-
getWiseFyLock() - Method in class com.isupatches.wisefy.WiseFy
-
-
To retrieve the lock in use by WiseFy for synchronization
-
-
- - - -

I

-
-
Internal - Annotation Type in com.isupatches.wisefy.annotations
-
 
-
isDeviceConnectedToMobileNetwork() - Method in class com.isupatches.wisefy.WiseFy
-
-
To check if the device is connected to a mobile network
-
-
isDeviceConnectedToMobileOrWifiNetwork() - Method in class com.isupatches.wisefy.WiseFy
-
-
To check if the device is connected to a mobile or wifi network
-
-
isDeviceConnectedToSSID(String) - Method in class com.isupatches.wisefy.WiseFy
-
-
To check if the device is connected to a given SSID
-
-
isDeviceConnectedToWifiNetwork() - Method in class com.isupatches.wisefy.WiseFy
-
-
To check if the device is connected to a wifi network
-
-
isDeviceRoaming() - Method in class com.isupatches.wisefy.WiseFy
-
-
To query if the device is roaming
-
-
isLoggable(String, int, boolean) - Static method in class com.isupatches.wisefy.util.LogUtil
-
-
Checks to see given a TAG, log level, and if logging is enabled if logging should occur
-
-
isLoggingEnabled() - Method in class com.isupatches.wisefy.WiseFy
-
-
To query if logging is enabled or disabled for a WiseFy instance
-
-
isNetwork5gHz() - Method in class com.isupatches.wisefy.WiseFy
-
-
To check if the device's current network is 5gHz
-
-
isNetwork5gHz(WifiInfo) - Method in class com.isupatches.wisefy.WiseFy
-
-
To check if a given network is 5gHz
-
-
isNetworkEAP(ScanResult) - Method in class com.isupatches.wisefy.WiseFy
-
-
To check and return if a network is a EAP network
-
-
isNetworkInConfigurationList(String) - Method in class com.isupatches.wisefy.WiseFy
-
-
To check if an SSID is in the list of configured networks
-
-
isNetworkPSK(ScanResult) - Method in class com.isupatches.wisefy.WiseFy
-
-
To check and return if a network is a PSK network
-
-
isNetworkSecure(ScanResult) - Method in class com.isupatches.wisefy.WiseFy
-
-
To check and return if a network is secure (WEP/WPA/WPA2 capabilities)
-
-
isNetworkWEP(ScanResult) - Method in class com.isupatches.wisefy.WiseFy
-
-
To check and return if a network is a WEP network
-
-
isNetworkWPA(ScanResult) - Method in class com.isupatches.wisefy.WiseFy
-
-
To check and return if a network is a WPA network
-
-
isNetworkWPA2(ScanResult) - Method in class com.isupatches.wisefy.WiseFy
-
-
To check and return if a network is a WPA2 network
-
-
isWifiEnabled() - Method in class com.isupatches.wisefy.WiseFy
-
-
To check if Wifi is enabled on the device or not
-
-
- - - -

L

-
-
logging(boolean) - Method in class com.isupatches.wisefy.WiseFy.brains
-
-
Optional - Builder method that enables/disables logging for a WiseWy instance
-
-
LogUtil - Class in com.isupatches.wisefy.util
-
-
Logging helper class
-
-
LogUtil() - Constructor for class com.isupatches.wisefy.util.LogUtil
-
 
-
- - - -

M

-
-
ManagerUtil - Class in com.isupatches.wisefy.util
-
-
Manager helper class
-
-
MAX_FREQUENCY_5GHZ - Static variable in class com.isupatches.wisefy.WiseFy
-
 
-
MIN_FREQUENCY_5GHZ - Static variable in class com.isupatches.wisefy.WiseFy
-
 
-
MISSING_PARAMETER - Static variable in class com.isupatches.wisefy.constants.WiseFyCodes
-
 
-
MISSING_PREREQUISITE - Static variable in class com.isupatches.wisefy.constants.WiseFyCodes
-
 
-
MOBILE - Static variable in class com.isupatches.wisefy.constants.NetworkTypes
-
 
-
- - - -

N

-
-
NETWORK_ALREADY_CONFIGURED - Static variable in class com.isupatches.wisefy.constants.WiseFyCodes
-
 
-
networkNotFoundToConnectTo() - Method in interface com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks
-
 
-
networkNotFoundToRemove() - Method in interface com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks
-
 
-
networkNotFoundToRetrieveRSSI() - Method in interface com.isupatches.wisefy.callbacks.GetRSSICallbacks
-
 
-
networkRemoved() - Method in interface com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks
-
 
-
NetworkTypes - Class in com.isupatches.wisefy.constants
-
 
-
NetworkTypes() - Constructor for class com.isupatches.wisefy.constants.NetworkTypes
-
 
-
noAccessPointsFound() - Method in interface com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks
-
 
-
noSavedNetworksFound() - Method in interface com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks
-
 
-
noSSIDsFound() - Method in interface com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks
-
 
-
- - - -

O

-
-
openNetworkAdded(WifiConfiguration) - Method in interface com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks
-
 
-
- - - -

P

-
-
PSK - Static variable in class com.isupatches.wisefy.constants.Capabilities
-
 
-
PublicAPI - Annotation Type in com.isupatches.wisefy.annotations
-
 
-
- - - -

Q

-
-
quit() - Method in class com.isupatches.wisefy.threads.WiseFyHandlerThread
-
 
-
quitSafely() - Method in class com.isupatches.wisefy.threads.WiseFyHandlerThread
-
 
-
- - - -

R

-
-
removeNetwork(String) - Method in class com.isupatches.wisefy.WiseFy
-
-
To remove a configured network
-
-
removeNetwork(String, RemoveNetworkCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To remove a configured network
-
-
RemoveNetworkCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
removeNetworkWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks
-
 
-
retrievedCurrentNetwork(WifiInfo) - Method in interface com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks
-
 
-
retrievedFrequency(int) - Method in interface com.isupatches.wisefy.callbacks.GetFrequencyCallbacks
-
 
-
retrievedNearbyAccessPoints(List<ScanResult>) - Method in interface com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks
-
 
-
retrievedRSSI(Integer) - Method in interface com.isupatches.wisefy.callbacks.GetRSSICallbacks
-
 
-
retrievedSavedNetwork(WifiConfiguration) - Method in interface com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks
-
 
-
retrievedSavedNetworks(List<WifiConfiguration>) - Method in interface com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks
-
 
-
retrievedSSIDs(List<String>) - Method in interface com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks
-
 
-
- - - -

S

-
-
savedNetworkNotFound() - Method in interface com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks
-
 
-
searchForAccessPoint(String, int, boolean) - Method in class com.isupatches.wisefy.WiseFy
-
-
To return the first access point that matches a given regex - - *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest)
-
-
searchForAccessPoint(String, int, boolean, SearchForAccessPointCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To return the first access point that matches a given regex - - *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest)
-
-
SearchForAccessPointCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
searchForAccessPoints(String, boolean) - Method in class com.isupatches.wisefy.WiseFy
-
-
To return nearby access points that match a given regex - - *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest)
-
-
searchForAccessPoints(String, boolean, SearchForAccessPointsCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To return nearby access points that match a given regex - - *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest)
-
-
SearchForAccessPointsCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
searchForAccessPointsWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks
-
 
-
searchForAccessPointWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks
-
 
-
searchForSSID(String, int) - Method in class com.isupatches.wisefy.WiseFy
-
-
To search local networks and return the first one that contains a given ssid
-
-
searchForSSID(String, int, SearchForSSIDCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To search local networks and return the first one that contains a given ssid
-
-
SearchForSSIDCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
searchForSSIDs(String) - Method in class com.isupatches.wisefy.WiseFy
-
-
To search local networks and return the first one that contains a given ssid
-
-
searchForSSIDs(String, SearchForSSIDsCallbacks) - Method in class com.isupatches.wisefy.WiseFy
-
-
To search local networks and return the first one that contains a given ssid
-
-
SearchForSSIDsCallbacks - Interface in com.isupatches.wisefy.callbacks
-
 
-
searchForSSIDsWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks
-
 
-
searchForSSIDWiseFyFailure(Integer) - Method in interface com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks
-
 
-
sleep(long) - Static method in class com.isupatches.wisefy.util.SleepUtil
-
-
Used to wait for a given amount of time (in milliseconds)
-
-
SleepUtil - Class in com.isupatches.wisefy.util
-
-
A helper class for shared wait logic
-
-
SleepUtil() - Constructor for class com.isupatches.wisefy.util.SleepUtil
-
 
-
ssidFound(String) - Method in interface com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks
-
 
-
ssidNotFound() - Method in interface com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks
-
 
-
start() - Method in class com.isupatches.wisefy.threads.WiseFyHandlerThread
-
 
-
Sync - Annotation Type in com.isupatches.wisefy.annotations
-
 
-
- - - -

T

-
-
TAG - Static variable in class com.isupatches.wisefy.threads.WiseFyHandlerThread
-
 
-
- - - -

W

-
-
WaitsForTimeout - Annotation Type in com.isupatches.wisefy.annotations
-
 
-
WEP - Static variable in class com.isupatches.wisefy.constants.Capabilities
-
 
-
wepNetworkAdded(WifiConfiguration) - Method in interface com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks
-
 
-
WIFI - Static variable in class com.isupatches.wisefy.constants.NetworkTypes
-
 
-
WIFI_MANAGER_FAILURE - Static variable in class com.isupatches.wisefy.WiseFy
-
 
-
WifiConfigurationUtil - Class in com.isupatches.wisefy.util
-
-
A helper class to generate WifiConfigurations
-
-
wifiDisabled() - Method in interface com.isupatches.wisefy.callbacks.DisableWifiCallbacks
-
 
-
wifiEnabled() - Method in interface com.isupatches.wisefy.callbacks.EnableWifiCallbacks
-
 
-
WiseFy - Class in com.isupatches.wisefy
-
-
Main class for WiseFy that provides a synchronous and asynchronous API to manipulate and query - for different parts of a device's wifi configuration and status.
-
-
WiseFy.brains - Class in com.isupatches.wisefy
-
-
Static class for builder pattern - - Implements builder interfaces #Logging #GetSmarts
-
-
WiseFyCodes - Class in com.isupatches.wisefy.constants
-
 
-
WiseFyCodes() - Constructor for class com.isupatches.wisefy.constants.WiseFyCodes
-
 
-
WiseFyHandlerThread - Class in com.isupatches.wisefy.threads
-
-
A Thread to use for all WiseFy background processing - - *NOTE* Must be cleaned!! WiseFy.dump()
-
-
WiseFyHandlerThread(String, boolean) - Constructor for class com.isupatches.wisefy.threads.WiseFyHandlerThread
-
 
-
WiseFyThread - Annotation Type in com.isupatches.wisefy.annotations
-
 
-
WPA - Static variable in class com.isupatches.wisefy.constants.Capabilities
-
 
-
WPA2 - Static variable in class com.isupatches.wisefy.constants.Capabilities
-
 
-
wpa2NetworkAdded(WifiConfiguration) - Method in interface com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks
-
 
-
-A B C D E F G I L M N O P Q R S T W 
- -
- - - - - - - -
- - - - diff --git a/javadoc/index.html b/javadoc/index.html deleted file mode 100644 index a85eddc0..00000000 --- a/javadoc/index.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - -wisefy 2.0.1 API - - - - - - - - - -<noscript> -<div>JavaScript is disabled on your browser.</div> -</noscript> -<h2>Frame Alert</h2> -<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> - - - diff --git a/javadoc/overview-frame.html b/javadoc/overview-frame.html deleted file mode 100644 index 5206e1fa..00000000 --- a/javadoc/overview-frame.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - -Overview List (wisefy 2.0.1 API) - - - - - - - -

 

- - diff --git a/javadoc/overview-summary.html b/javadoc/overview-summary.html deleted file mode 100644 index fc5986a6..00000000 --- a/javadoc/overview-summary.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - - -Overview (wisefy 2.0.1 API) - - - - - - - - -
- - - - - - - -
- - -
-

wisefy 2.0.1 API

-
- - -
- - - - - - - -
- - - - diff --git a/javadoc/overview-tree.html b/javadoc/overview-tree.html deleted file mode 100644 index 7bbf6db1..00000000 --- a/javadoc/overview-tree.html +++ /dev/null @@ -1,188 +0,0 @@ - - - - - -Class Hierarchy (wisefy 2.0.1 API) - - - - - - - - -
- - - - - - - -
- - - -
-

Class Hierarchy

- -

Interface Hierarchy

- -

Annotation Type Hierarchy

-
    -
  • com.isupatches.wisefy.annotations.Async (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.CallingThread (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.Internal (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.PublicAPI (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.Sync (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.WaitsForTimeout (implements java.lang.annotation.Annotation)
  • -
  • com.isupatches.wisefy.annotations.WiseFyThread (implements java.lang.annotation.Annotation)
  • -
-
- -
- - - - - - - -
- - - - diff --git a/javadoc/script.js b/javadoc/script.js deleted file mode 100644 index b3463569..00000000 --- a/javadoc/script.js +++ /dev/null @@ -1,30 +0,0 @@ -function show(type) -{ - count = 0; - for (var key in methods) { - var row = document.getElementById(key); - if ((methods[key] & type) != 0) { - row.style.display = ''; - row.className = (count++ % 2) ? rowColor : altColor; - } - else - row.style.display = 'none'; - } - updateTabs(type); -} - -function updateTabs(type) -{ - for (var value in tabs) { - var sNode = document.getElementById(tabs[value][0]); - var spanNode = sNode.firstChild; - if (value == type) { - sNode.className = activeTableTab; - spanNode.innerHTML = tabs[value][1]; - } - else { - sNode.className = tableTab; - spanNode.innerHTML = "" + tabs[value][1] + ""; - } - } -} diff --git a/javadoc/style.css b/javadoc/style.css new file mode 100644 index 00000000..914be69d --- /dev/null +++ b/javadoc/style.css @@ -0,0 +1,283 @@ +@import url(https://fonts.googleapis.com/css?family=Open+Sans:300i,400,700); + +body, table { + padding:50px; + font:14px/1.5 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif; + color:#555; + font-weight:300; + margin-left: auto; + margin-right: auto; + max-width: 1440px; +} + +.keyword { + color:black; + font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; + font-size:12px; +} + +.symbol { + font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; + font-size:12px; +} + +.identifier { + color: darkblue; + font-size:12px; + font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; +} + +h1, h2, h3, h4, h5, h6 { + color:#222; + margin:0 0 20px; +} + +p, ul, ol, table, pre, dl { + margin:0 0 20px; +} + +h1, h2, h3 { + line-height:1.1; +} + +h1 { + font-size:28px; +} + +h2 { + color:#393939; +} + +h3, h4, h5, h6 { + color:#494949; +} + +a { + color:#258aaf; + font-weight:400; + text-decoration:none; +} + +a:hover { + color: inherit; + text-decoration:underline; +} + +a small { + font-size:11px; + color:#555; + margin-top:-0.6em; + display:block; +} + +.wrapper { + width:860px; + margin:0 auto; +} + +blockquote { + border-left:1px solid #e5e5e5; + margin:0; + padding:0 0 0 20px; + font-style:italic; +} + +code, pre { + font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; + color:#333; + font-size:12px; +} + +pre { + display: block; +/* + padding:8px 8px; + background: #f8f8f8; + border-radius:5px; + border:1px solid #e5e5e5; +*/ + overflow-x: auto; +} + +table { + width:100%; + border-collapse:collapse; +} + +th, td { + text-align:left; + vertical-align: top; + padding:5px 10px; +} + +dt { + color:#444; + font-weight:700; +} + +th { + color:#444; +} + +img { + max-width:100%; +} + +header { + width:270px; + float:left; + position:fixed; +} + +header ul { + list-style:none; + height:40px; + + padding:0; + + background: #eee; + background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); + background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%); + + border-radius:5px; + border:1px solid #d2d2d2; + box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0; + width:270px; +} + +header li { + width:89px; + float:left; + border-right:1px solid #d2d2d2; + height:40px; +} + +header ul a { + line-height:1; + font-size:11px; + color:#999; + display:block; + text-align:center; + padding-top:6px; + height:40px; +} + +strong { + color:#222; + font-weight:700; +} + +header ul li + li { + width:88px; + border-left:1px solid #fff; +} + +header ul li + li + li { + border-right:none; + width:89px; +} + +header ul a strong { + font-size:14px; + display:block; + color:#222; +} + +section { + width:500px; + float:right; + padding-bottom:50px; +} + +small { + font-size:11px; +} + +hr { + border:0; + background:#e5e5e5; + height:1px; + margin:0 0 20px; +} + +footer { + width:270px; + float:left; + position:fixed; + bottom:50px; +} + +@media print, screen and (max-width: 960px) { + + div.wrapper { + width:auto; + margin:0; + } + + header, section, footer { + float:none; + position:static; + width:auto; + } + + header { + padding-right:320px; + } + + section { + border:1px solid #e5e5e5; + border-width:1px 0; + padding:20px 0; + margin:0 0 20px; + } + + header a small { + display:inline; + } + + header ul { + position:absolute; + right:50px; + top:52px; + } +} + +@media print, screen and (max-width: 720px) { + body { + word-wrap:break-word; + } + + header { + padding:0; + } + + header ul, header p.view { + position:static; + } + + pre, code { + word-wrap:normal; + } +} + +@media print, screen and (max-width: 480px) { + body { + padding:15px; + } + + header ul { + display:none; + } +} + +@media print { + body { + padding:0.4in; + font-size:12pt; + color:#444; + } +} diff --git a/javadoc/stylesheet.css b/javadoc/stylesheet.css deleted file mode 100644 index 98055b22..00000000 --- a/javadoc/stylesheet.css +++ /dev/null @@ -1,574 +0,0 @@ -/* Javadoc style sheet */ -/* -Overall document style -*/ - -@import url('resources/fonts/dejavu.css'); - -body { - background-color:#ffffff; - color:#353833; - font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; - font-size:14px; - margin:0; -} -a:link, a:visited { - text-decoration:none; - color:#4A6782; -} -a:hover, a:focus { - text-decoration:none; - color:#bb7a2a; -} -a:active { - text-decoration:none; - color:#4A6782; -} -a[name] { - color:#353833; -} -a[name]:hover { - text-decoration:none; - color:#353833; -} -pre { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; -} -h1 { - font-size:20px; -} -h2 { - font-size:18px; -} -h3 { - font-size:16px; - font-style:italic; -} -h4 { - font-size:13px; -} -h5 { - font-size:12px; -} -h6 { - font-size:11px; -} -ul { - list-style-type:disc; -} -code, tt { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; - padding-top:4px; - margin-top:8px; - line-height:1.4em; -} -dt code { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; - padding-top:4px; -} -table tr td dt code { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; - vertical-align:top; - padding-top:4px; -} -sup { - font-size:8px; -} -/* -Document title and Copyright styles -*/ -.clear { - clear:both; - height:0px; - overflow:hidden; -} -.aboutLanguage { - float:right; - padding:0px 21px; - font-size:11px; - z-index:200; - margin-top:-9px; -} -.legalCopy { - margin-left:.5em; -} -.bar a, .bar a:link, .bar a:visited, .bar a:active { - color:#FFFFFF; - text-decoration:none; -} -.bar a:hover, .bar a:focus { - color:#bb7a2a; -} -.tab { - background-color:#0066FF; - color:#ffffff; - padding:8px; - width:5em; - font-weight:bold; -} -/* -Navigation bar styles -*/ -.bar { - background-color:#4D7A97; - color:#FFFFFF; - padding:.8em .5em .4em .8em; - height:auto;/*height:1.8em;*/ - font-size:11px; - margin:0; -} -.topNav { - background-color:#4D7A97; - color:#FFFFFF; - float:left; - padding:0; - width:100%; - clear:right; - height:2.8em; - padding-top:10px; - overflow:hidden; - font-size:12px; -} -.bottomNav { - margin-top:10px; - background-color:#4D7A97; - color:#FFFFFF; - float:left; - padding:0; - width:100%; - clear:right; - height:2.8em; - padding-top:10px; - overflow:hidden; - font-size:12px; -} -.subNav { - background-color:#dee3e9; - float:left; - width:100%; - overflow:hidden; - font-size:12px; -} -.subNav div { - clear:left; - float:left; - padding:0 0 5px 6px; - text-transform:uppercase; -} -ul.navList, ul.subNavList { - float:left; - margin:0 25px 0 0; - padding:0; -} -ul.navList li{ - list-style:none; - float:left; - padding: 5px 6px; - text-transform:uppercase; -} -ul.subNavList li{ - list-style:none; - float:left; -} -.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { - color:#FFFFFF; - text-decoration:none; - text-transform:uppercase; -} -.topNav a:hover, .bottomNav a:hover { - text-decoration:none; - color:#bb7a2a; - text-transform:uppercase; -} -.navBarCell1Rev { - background-color:#F8981D; - color:#253441; - margin: auto 5px; -} -.skipNav { - position:absolute; - top:auto; - left:-9999px; - overflow:hidden; -} -/* -Page header and footer styles -*/ -.header, .footer { - clear:both; - margin:0 20px; - padding:5px 0 0 0; -} -.indexHeader { - margin:10px; - position:relative; -} -.indexHeader span{ - margin-right:15px; -} -.indexHeader h1 { - font-size:13px; -} -.title { - color:#2c4557; - margin:10px 0; -} -.subTitle { - margin:5px 0 0 0; -} -.header ul { - margin:0 0 15px 0; - padding:0; -} -.footer ul { - margin:20px 0 5px 0; -} -.header ul li, .footer ul li { - list-style:none; - font-size:13px; -} -/* -Heading styles -*/ -div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { - background-color:#dee3e9; - border:1px solid #d0d9e0; - margin:0 0 6px -8px; - padding:7px 5px; -} -ul.blockList ul.blockList ul.blockList li.blockList h3 { - background-color:#dee3e9; - border:1px solid #d0d9e0; - margin:0 0 6px -8px; - padding:7px 5px; -} -ul.blockList ul.blockList li.blockList h3 { - padding:0; - margin:15px 0; -} -ul.blockList li.blockList h2 { - padding:0px 0 20px 0; -} -/* -Page layout container styles -*/ -.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { - clear:both; - padding:10px 20px; - position:relative; -} -.indexContainer { - margin:10px; - position:relative; - font-size:12px; -} -.indexContainer h2 { - font-size:13px; - padding:0 0 3px 0; -} -.indexContainer ul { - margin:0; - padding:0; -} -.indexContainer ul li { - list-style:none; - padding-top:2px; -} -.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { - font-size:12px; - font-weight:bold; - margin:10px 0 0 0; - color:#4E4E4E; -} -.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { - margin:5px 0 10px 0px; - font-size:14px; - font-family:'DejaVu Sans Mono',monospace; -} -.serializedFormContainer dl.nameValue dt { - margin-left:1px; - font-size:1.1em; - display:inline; - font-weight:bold; -} -.serializedFormContainer dl.nameValue dd { - margin:0 0 0 1px; - font-size:1.1em; - display:inline; -} -/* -List styles -*/ -ul.horizontal li { - display:inline; - font-size:0.9em; -} -ul.inheritance { - margin:0; - padding:0; -} -ul.inheritance li { - display:inline; - list-style:none; -} -ul.inheritance li ul.inheritance { - margin-left:15px; - padding-left:15px; - padding-top:1px; -} -ul.blockList, ul.blockListLast { - margin:10px 0 10px 0; - padding:0; -} -ul.blockList li.blockList, ul.blockListLast li.blockList { - list-style:none; - margin-bottom:15px; - line-height:1.4; -} -ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { - padding:0px 20px 5px 10px; - border:1px solid #ededed; - background-color:#f8f8f8; -} -ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { - padding:0 0 5px 8px; - background-color:#ffffff; - border:none; -} -ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { - margin-left:0; - padding-left:0; - padding-bottom:15px; - border:none; -} -ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { - list-style:none; - border-bottom:none; - padding-bottom:0; -} -table tr td dl, table tr td dl dt, table tr td dl dd { - margin-top:0; - margin-bottom:1px; -} -/* -Table styles -*/ -.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { - width:100%; - border-left:1px solid #EEE; - border-right:1px solid #EEE; - border-bottom:1px solid #EEE; -} -.overviewSummary, .memberSummary { - padding:0px; -} -.overviewSummary caption, .memberSummary caption, .typeSummary caption, -.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { - position:relative; - text-align:left; - background-repeat:no-repeat; - color:#253441; - font-weight:bold; - clear:none; - overflow:hidden; - padding:0px; - padding-top:10px; - padding-left:1px; - margin:0px; - white-space:pre; -} -.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, -.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, -.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, -.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, -.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, -.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, -.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, -.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { - color:#FFFFFF; -} -.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, -.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { - white-space:nowrap; - padding-top:5px; - padding-left:12px; - padding-right:12px; - padding-bottom:7px; - display:inline-block; - float:left; - background-color:#F8981D; - border: none; - height:16px; -} -.memberSummary caption span.activeTableTab span { - white-space:nowrap; - padding-top:5px; - padding-left:12px; - padding-right:12px; - margin-right:3px; - display:inline-block; - float:left; - background-color:#F8981D; - height:16px; -} -.memberSummary caption span.tableTab span { - white-space:nowrap; - padding-top:5px; - padding-left:12px; - padding-right:12px; - margin-right:3px; - display:inline-block; - float:left; - background-color:#4D7A97; - height:16px; -} -.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { - padding-top:0px; - padding-left:0px; - padding-right:0px; - background-image:none; - float:none; - display:inline; -} -.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, -.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { - display:none; - width:5px; - position:relative; - float:left; - background-color:#F8981D; -} -.memberSummary .activeTableTab .tabEnd { - display:none; - width:5px; - margin-right:3px; - position:relative; - float:left; - background-color:#F8981D; -} -.memberSummary .tableTab .tabEnd { - display:none; - width:5px; - margin-right:3px; - position:relative; - background-color:#4D7A97; - float:left; - -} -.overviewSummary td, .memberSummary td, .typeSummary td, -.useSummary td, .constantsSummary td, .deprecatedSummary td { - text-align:left; - padding:0px 0px 12px 10px; -} -th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, -td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ - vertical-align:top; - padding-right:0px; - padding-top:8px; - padding-bottom:3px; -} -th.colFirst, th.colLast, th.colOne, .constantsSummary th { - background:#dee3e9; - text-align:left; - padding:8px 3px 3px 7px; -} -td.colFirst, th.colFirst { - white-space:nowrap; - font-size:13px; -} -td.colLast, th.colLast { - font-size:13px; -} -td.colOne, th.colOne { - font-size:13px; -} -.overviewSummary td.colFirst, .overviewSummary th.colFirst, -.useSummary td.colFirst, .useSummary th.colFirst, -.overviewSummary td.colOne, .overviewSummary th.colOne, -.memberSummary td.colFirst, .memberSummary th.colFirst, -.memberSummary td.colOne, .memberSummary th.colOne, -.typeSummary td.colFirst{ - width:25%; - vertical-align:top; -} -td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { - font-weight:bold; -} -.tableSubHeadingColor { - background-color:#EEEEFF; -} -.altColor { - background-color:#FFFFFF; -} -.rowColor { - background-color:#EEEEEF; -} -/* -Content styles -*/ -.description pre { - margin-top:0; -} -.deprecatedContent { - margin:0; - padding:10px 0; -} -.docSummary { - padding:0; -} - -ul.blockList ul.blockList ul.blockList li.blockList h3 { - font-style:normal; -} - -div.block { - font-size:14px; - font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; -} - -td.colLast div { - padding-top:0px; -} - - -td.colLast a { - padding-bottom:3px; -} -/* -Formatting effect styles -*/ -.sourceLineNo { - color:green; - padding:0 30px 0 0; -} -h1.hidden { - visibility:hidden; - overflow:hidden; - font-size:10px; -} -.block { - display:block; - margin:3px 10px 2px 0px; - color:#474747; -} -.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, -.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, -.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { - font-weight:bold; -} -.deprecationComment, .emphasizedPhrase, .interfaceName { - font-style:italic; -} - -div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, -div.block div.block span.interfaceName { - font-style:normal; -} - -div.contentContainer ul.blockList li.blockList h2{ - padding-bottom:0px; -} diff --git a/javadoc/wisefy/alltypes/index.html b/javadoc/wisefy/alltypes/index.html new file mode 100644 index 00000000..3e838faa --- /dev/null +++ b/javadoc/wisefy/alltypes/index.html @@ -0,0 +1,191 @@ + + + +alltypes - wisefy + + + +

All Types

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+com.isupatches.wisefy.callbacks.AddNetworkCallbacks +

Callbacks for adding a network as a saved configuration on a device.

+
+com.isupatches.wisefy.callbacks.BaseCallback +

Callbacks that are applicable to all Async WiseFy operations. +All Async interfaces should extend this class.

+
+com.isupatches.wisefy.constants.Capability +

Annotation to help avoid crazy strings when working with network security capabilities.

+
+com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks +

Callbacks for attempting to connect to a network.

+
+com.isupatches.wisefy.callbacks.DisableWifiCallbacks +

Callbacks for disabling a device's wifi.

+
+com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks +

Callbacks for disconnecting a device from it's current network.

+
+com.isupatches.wisefy.callbacks.EnableWifiCallbacks +

Callbacks for enabling a device's wifi.

+
+com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks +

Callbacks for retrieving a device's current network.

+
+com.isupatches.wisefy.callbacks.GetCurrentNetworkInfoCallbacks +

Callbacks for retrieving a device's current network.

+
+com.isupatches.wisefy.callbacks.GetFrequencyCallbacks +

Callbacks for retrieving the frequency of a network.

+
+com.isupatches.wisefy.callbacks.GetIPCallbacks +

Callbacks for retrieving a device's IP.

+
+com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks +

Callbacks for retrieving a list of nearby access points.

+
+com.isupatches.wisefy.callbacks.GetRSSICallbacks +

Callbacks for retrieving RSSI level of a nearby access point.

+
+com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks +

Callbacks for retrieving a saved network on a device.

+
+com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks +

Callbacks for retrieving a list of saved networks on a device.

+
+com.isupatches.wisefy.constants.NetworkType +

Annotation to help avoid crazy strings when handling network types.

+
+com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks +

Callbacks for removing a saved network on a device.

+
+com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks +

Callbacks for finding a nearby access point on a device.

+
+com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks +

Callbacks for finding a list of nearby access points on a device.

+
+com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks +

Callbacks for finding a nearby SSID on a device.

+
+com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks +

Callbacks for finding a list of nearby SSIDs on a device.

+
+com.isupatches.wisefy.WiseFy +

Main class for WiseFy that provides a synchronous and asynchronous API to manipulate and query +for different parts of a device's wifi configuration and status.

+
+com.isupatches.wisefy.constants.WiseFyCode +

Interface to avoid magic numbers when handling internal WiseFy codes.

+
+com.isupatches.wisefy.threads.WiseFyHandlerThread +

A Thread to use for all WiseFy background processing.

+
+com.isupatches.wisefy.WiseFyLock +

A class used to synchronize logic.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/failure-adding-network.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/failure-adding-network.html new file mode 100644 index 00000000..ce75ff8e --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/failure-adding-network.html @@ -0,0 +1,23 @@ + + + +AddNetworkCallbacks.failureAddingNetwork - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / AddNetworkCallbacks / failureAddingNetwork
+
+

failureAddingNetwork

+ +abstract fun failureAddingNetwork(wifiManagerReturn: Int): Unit +

Called when android.net.wifi.WifiManager encounters an error adding a network.

+

See Also
+

android.net.wifi.WifiManager

+

com.isupatches.wisefy.WiseFy.WIFI_MANAGER_FAILURE

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/index.html new file mode 100644 index 00000000..7cd6060d --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/index.html @@ -0,0 +1,62 @@ + + + +AddNetworkCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / AddNetworkCallbacks
+
+

AddNetworkCallbacks

+interface AddNetworkCallbacks : BaseCallback +

Callbacks for adding a network as a saved configuration on a device.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.addOpenNetwork

+

com.isupatches.wisefy.WiseFy.addWEPNetwork

+

com.isupatches.wisefy.WiseFy.addWPA2Network

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

failureAddingNetwork

+
+abstract fun failureAddingNetwork(wifiManagerReturn: Int): Unit +

Called when android.net.wifi.WifiManager encounters an error adding a network.

+
+

networkAdded

+
+abstract fun networkAdded(newNetworkId: Int, networkConfig: WifiConfiguration): Unit +

Called upon successfully adding a network.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/network-added.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/network-added.html new file mode 100644 index 00000000..607d9d26 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-add-network-callbacks/network-added.html @@ -0,0 +1,22 @@ + + + +AddNetworkCallbacks.networkAdded - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / AddNetworkCallbacks / networkAdded
+
+

networkAdded

+ +abstract fun networkAdded(newNetworkId: Int, networkConfig: WifiConfiguration): Unit +

Called upon successfully adding a network.

+

See Also
+

android.net.wifi.WifiConfiguration

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-base-callback/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-base-callback/index.html new file mode 100644 index 00000000..18776513 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-base-callback/index.html @@ -0,0 +1,201 @@ + + + +BaseCallback - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / BaseCallback
+
+

BaseCallback

+interface BaseCallback +

Callbacks that are applicable to all Async WiseFy operations. +All Async interfaces should extend this class.

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+

Inheritors

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

AddNetworkCallbacks

+
+interface AddNetworkCallbacks : BaseCallback +

Callbacks for adding a network as a saved configuration on a device.

+
+

ConnectToNetworkCallbacks

+
+interface ConnectToNetworkCallbacks : BaseCallback +

Callbacks for attempting to connect to a network.

+
+

DisableWifiCallbacks

+
+interface DisableWifiCallbacks : BaseCallback +

Callbacks for disabling a device's wifi.

+
+

DisconnectFromCurrentNetworkCallbacks

+
+interface DisconnectFromCurrentNetworkCallbacks : BaseCallback +

Callbacks for disconnecting a device from it's current network.

+
+

EnableWifiCallbacks

+
+interface EnableWifiCallbacks : BaseCallback +

Callbacks for enabling a device's wifi.

+
+

GetCurrentNetworkCallbacks

+
+interface GetCurrentNetworkCallbacks : BaseCallback +

Callbacks for retrieving a device's current network.

+
+

GetCurrentNetworkInfoCallbacks

+
+interface GetCurrentNetworkInfoCallbacks : BaseCallback +

Callbacks for retrieving a device's current network.

+
+

GetFrequencyCallbacks

+
+interface GetFrequencyCallbacks : BaseCallback +

Callbacks for retrieving the frequency of a network.

+
+

GetIPCallbacks

+
+interface GetIPCallbacks : BaseCallback +

Callbacks for retrieving a device's IP.

+
+

GetNearbyAccessPointsCallbacks

+
+interface GetNearbyAccessPointsCallbacks : BaseCallback +

Callbacks for retrieving a list of nearby access points.

+
+

GetRSSICallbacks

+
+interface GetRSSICallbacks : BaseCallback +

Callbacks for retrieving RSSI level of a nearby access point.

+
+

GetSavedNetworkCallbacks

+
+interface GetSavedNetworkCallbacks : BaseCallback +

Callbacks for retrieving a saved network on a device.

+
+

GetSavedNetworksCallbacks

+
+interface GetSavedNetworksCallbacks : BaseCallback +

Callbacks for retrieving a list of saved networks on a device.

+
+

RemoveNetworkCallbacks

+
+interface RemoveNetworkCallbacks : BaseCallback +

Callbacks for removing a saved network on a device.

+
+

SearchForAccessPointCallbacks

+
+interface SearchForAccessPointCallbacks : BaseCallback +

Callbacks for finding a nearby access point on a device.

+
+

SearchForAccessPointsCallbacks

+
+interface SearchForAccessPointsCallbacks : BaseCallback +

Callbacks for finding a list of nearby access points on a device.

+
+

SearchForSSIDCallbacks

+
+interface SearchForSSIDCallbacks : BaseCallback +

Callbacks for finding a nearby SSID on a device.

+
+

SearchForSSIDsCallbacks

+
+interface SearchForSSIDsCallbacks : BaseCallback +

Callbacks for finding a list of nearby SSIDs on a device.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-base-callback/wisefy-failure.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-base-callback/wisefy-failure.html new file mode 100644 index 00000000..6757f0ca --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-base-callback/wisefy-failure.html @@ -0,0 +1,25 @@ + + + +BaseCallback.wisefyFailure - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / BaseCallback / wisefyFailure
+
+

wisefyFailure

+ +abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+

Example: A null or empty ssid is passed in but is a required parameter.

+

See Also
+

com.isupatches.wisefy.WiseFyPrechecks

+

com.isupatches.wisefy.constants.WiseFyCode

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/connected-to-network.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/connected-to-network.html new file mode 100644 index 00000000..cd39661d --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/connected-to-network.html @@ -0,0 +1,19 @@ + + + +ConnectToNetworkCallbacks.connectedToNetwork - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / ConnectToNetworkCallbacks / connectedToNetwork
+
+

connectedToNetwork

+ +abstract fun connectedToNetwork(): Unit +

Called when WiseFy has successfully connected to a network.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/failure-connecting-to-network.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/failure-connecting-to-network.html new file mode 100644 index 00000000..a7352421 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/failure-connecting-to-network.html @@ -0,0 +1,23 @@ + + + +ConnectToNetworkCallbacks.failureConnectingToNetwork - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / ConnectToNetworkCallbacks / failureConnectingToNetwork
+
+

failureConnectingToNetwork

+ +abstract fun failureConnectingToNetwork(): Unit +

Called when the network was found, but there was an issue attempting to connect to +it with android.net.wifi.WifiManager.

+

See Also
+

android.net.wifi.WifiManager

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/index.html new file mode 100644 index 00000000..6b04890c --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/index.html @@ -0,0 +1,70 @@ + + + +ConnectToNetworkCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / ConnectToNetworkCallbacks
+
+

ConnectToNetworkCallbacks

+interface ConnectToNetworkCallbacks : BaseCallback +

Callbacks for attempting to connect to a network.

+

See Also
+

com.isupatches.wisefy.WiseFy.connectToNetwork

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + + + + + +
+

connectedToNetwork

+
+abstract fun connectedToNetwork(): Unit +

Called when WiseFy has successfully connected to a network.

+
+

failureConnectingToNetwork

+
+abstract fun failureConnectingToNetwork(): Unit +

Called when the network was found, but there was an issue attempting to connect to +it with android.net.wifi.WifiManager.

+
+

networkNotFoundToConnectTo

+
+abstract fun networkNotFoundToConnectTo(): Unit +

Called when the SSID of the network to connect to cannot be found by android.net.wifi.WifiManager +and WiseFy.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/network-not-found-to-connect-to.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/network-not-found-to-connect-to.html new file mode 100644 index 00000000..32d35168 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-connect-to-network-callbacks/network-not-found-to-connect-to.html @@ -0,0 +1,23 @@ + + + +ConnectToNetworkCallbacks.networkNotFoundToConnectTo - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / ConnectToNetworkCallbacks / networkNotFoundToConnectTo
+
+

networkNotFoundToConnectTo

+ +abstract fun networkNotFoundToConnectTo(): Unit +

Called when the SSID of the network to connect to cannot be found by android.net.wifi.WifiManager +and WiseFy.

+

See Also
+

android.net.wifi.WifiManager

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/failure-disabling-wifi.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/failure-disabling-wifi.html new file mode 100644 index 00000000..19ad49b8 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/failure-disabling-wifi.html @@ -0,0 +1,19 @@ + + + +DisableWifiCallbacks.failureDisablingWifi - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / DisableWifiCallbacks / failureDisablingWifi
+
+

failureDisablingWifi

+ +abstract fun failureDisablingWifi(): Unit +

Called when there is an issue disabling Wifi on the device.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/index.html new file mode 100644 index 00000000..d5a7dd59 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/index.html @@ -0,0 +1,60 @@ + + + +DisableWifiCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / DisableWifiCallbacks
+
+

DisableWifiCallbacks

+interface DisableWifiCallbacks : BaseCallback +

Callbacks for disabling a device's wifi.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.disableWifi

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

failureDisablingWifi

+
+abstract fun failureDisablingWifi(): Unit +

Called when there is an issue disabling Wifi on the device.

+
+

wifiDisabled

+
+abstract fun wifiDisabled(): Unit +

Called when WiseFy has successfully disabled Wifi on the device.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/wifi-disabled.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/wifi-disabled.html new file mode 100644 index 00000000..9830e6ff --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disable-wifi-callbacks/wifi-disabled.html @@ -0,0 +1,19 @@ + + + +DisableWifiCallbacks.wifiDisabled - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / DisableWifiCallbacks / wifiDisabled
+
+

wifiDisabled

+ +abstract fun wifiDisabled(): Unit +

Called when WiseFy has successfully disabled Wifi on the device.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/disconnected-from-current-network.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/disconnected-from-current-network.html new file mode 100644 index 00000000..e61546b2 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/disconnected-from-current-network.html @@ -0,0 +1,19 @@ + + + +DisconnectFromCurrentNetworkCallbacks.disconnectedFromCurrentNetwork - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / DisconnectFromCurrentNetworkCallbacks / disconnectedFromCurrentNetwork
+
+

disconnectedFromCurrentNetwork

+ +abstract fun disconnectedFromCurrentNetwork(): Unit +

Called when WiseFy has successfully disconnected from the device's current network.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/failure-disconnecting-from-current-network.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/failure-disconnecting-from-current-network.html new file mode 100644 index 00000000..0dbe19ae --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/failure-disconnecting-from-current-network.html @@ -0,0 +1,19 @@ + + + +DisconnectFromCurrentNetworkCallbacks.failureDisconnectingFromCurrentNetwork - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / DisconnectFromCurrentNetworkCallbacks / failureDisconnectingFromCurrentNetwork
+
+

failureDisconnectingFromCurrentNetwork

+ +abstract fun failureDisconnectingFromCurrentNetwork(): Unit +

Called when there is an issue disconnecting the device from it's current network.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/index.html new file mode 100644 index 00000000..df9a0ca3 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-disconnect-from-current-network-callbacks/index.html @@ -0,0 +1,60 @@ + + + +DisconnectFromCurrentNetworkCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / DisconnectFromCurrentNetworkCallbacks
+
+

DisconnectFromCurrentNetworkCallbacks

+interface DisconnectFromCurrentNetworkCallbacks : BaseCallback +

Callbacks for disconnecting a device from it's current network.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.disconnectFromCurrentNetwork

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

disconnectedFromCurrentNetwork

+
+abstract fun disconnectedFromCurrentNetwork(): Unit +

Called when WiseFy has successfully disconnected from the device's current network.

+
+

failureDisconnectingFromCurrentNetwork

+
+abstract fun failureDisconnectingFromCurrentNetwork(): Unit +

Called when there is an issue disconnecting the device from it's current network.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/failure-enabling-wifi.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/failure-enabling-wifi.html new file mode 100644 index 00000000..aa3ed386 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/failure-enabling-wifi.html @@ -0,0 +1,19 @@ + + + +EnableWifiCallbacks.failureEnablingWifi - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / EnableWifiCallbacks / failureEnablingWifi
+
+

failureEnablingWifi

+ +abstract fun failureEnablingWifi(): Unit +

Called when there is an issue enabling wifi on the device.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/index.html new file mode 100644 index 00000000..f8d89842 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/index.html @@ -0,0 +1,60 @@ + + + +EnableWifiCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / EnableWifiCallbacks
+
+

EnableWifiCallbacks

+interface EnableWifiCallbacks : BaseCallback +

Callbacks for enabling a device's wifi.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.enableWifi

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

failureEnablingWifi

+
+abstract fun failureEnablingWifi(): Unit +

Called when there is an issue enabling wifi on the device.

+
+

wifiEnabled

+
+abstract fun wifiEnabled(): Unit +

Called when WiseFy has successfully enabled wifi on the device.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/wifi-enabled.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/wifi-enabled.html new file mode 100644 index 00000000..47354881 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-enable-wifi-callbacks/wifi-enabled.html @@ -0,0 +1,19 @@ + + + +EnableWifiCallbacks.wifiEnabled - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / EnableWifiCallbacks / wifiEnabled
+
+

wifiEnabled

+ +abstract fun wifiEnabled(): Unit +

Called when WiseFy has successfully enabled wifi on the device.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-callbacks/index.html new file mode 100644 index 00000000..ceac2150 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-callbacks/index.html @@ -0,0 +1,51 @@ + + + +GetCurrentNetworkCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetCurrentNetworkCallbacks
+
+

GetCurrentNetworkCallbacks

+interface GetCurrentNetworkCallbacks : BaseCallback +

Callbacks for retrieving a device's current network.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.getCurrentNetwork

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + +
+

retrievedCurrentNetwork

+
+abstract fun retrievedCurrentNetwork(currentNetwork: WifiInfo): Unit +

Called when WiseFy has successfully retrieved the device's current network.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-callbacks/retrieved-current-network.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-callbacks/retrieved-current-network.html new file mode 100644 index 00000000..d60d230d --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-callbacks/retrieved-current-network.html @@ -0,0 +1,22 @@ + + + +GetCurrentNetworkCallbacks.retrievedCurrentNetwork - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetCurrentNetworkCallbacks / retrievedCurrentNetwork
+
+

retrievedCurrentNetwork

+ +abstract fun retrievedCurrentNetwork(currentNetwork: WifiInfo): Unit +

Called when WiseFy has successfully retrieved the device's current network.

+

See Also
+

WifiInfo

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-info-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-info-callbacks/index.html new file mode 100644 index 00000000..511bb114 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-info-callbacks/index.html @@ -0,0 +1,51 @@ + + + +GetCurrentNetworkInfoCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetCurrentNetworkInfoCallbacks
+
+

GetCurrentNetworkInfoCallbacks

+interface GetCurrentNetworkInfoCallbacks : BaseCallback +

Callbacks for retrieving a device's current network.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.getCurrentNetworkInfo

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + +
+

retrievedCurrentNetworkInfo

+
+abstract fun retrievedCurrentNetworkInfo(currentNetworkDetails: NetworkInfo): Unit +

Called when WiseFy has successfully retrieved the device's current network info.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-info-callbacks/retrieved-current-network-info.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-info-callbacks/retrieved-current-network-info.html new file mode 100644 index 00000000..b069b94d --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-current-network-info-callbacks/retrieved-current-network-info.html @@ -0,0 +1,22 @@ + + + +GetCurrentNetworkInfoCallbacks.retrievedCurrentNetworkInfo - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetCurrentNetworkInfoCallbacks / retrievedCurrentNetworkInfo
+
+

retrievedCurrentNetworkInfo

+ +abstract fun retrievedCurrentNetworkInfo(currentNetworkDetails: NetworkInfo): Unit +

Called when WiseFy has successfully retrieved the device's current network info.

+

See Also
+

NetworkInfo

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/failure-getting-frequency.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/failure-getting-frequency.html new file mode 100644 index 00000000..9be3c6c7 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/failure-getting-frequency.html @@ -0,0 +1,20 @@ + + + +GetFrequencyCallbacks.failureGettingFrequency - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetFrequencyCallbacks / failureGettingFrequency
+
+

failureGettingFrequency

+ +abstract fun failureGettingFrequency(): Unit +

Called when there is an issue retrieving the frequency of a network.

+

i.e. Unable to retrieve current network or no current network

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/index.html new file mode 100644 index 00000000..b6de27e9 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/index.html @@ -0,0 +1,60 @@ + + + +GetFrequencyCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetFrequencyCallbacks
+
+

GetFrequencyCallbacks

+interface GetFrequencyCallbacks : BaseCallback +

Callbacks for retrieving the frequency of a network.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.getFrequency

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

failureGettingFrequency

+
+abstract fun failureGettingFrequency(): Unit +

Called when there is an issue retrieving the frequency of a network.

+
+

retrievedFrequency

+
+abstract fun retrievedFrequency(frequency: Int): Unit +

Called when WiseFy has successfully retrieved the frequency of a network.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/retrieved-frequency.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/retrieved-frequency.html new file mode 100644 index 00000000..96164162 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-frequency-callbacks/retrieved-frequency.html @@ -0,0 +1,19 @@ + + + +GetFrequencyCallbacks.retrievedFrequency - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetFrequencyCallbacks / retrievedFrequency
+
+

retrievedFrequency

+ +abstract fun retrievedFrequency(frequency: Int): Unit +

Called when WiseFy has successfully retrieved the frequency of a network.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/failure-retrieving-i-p.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/failure-retrieving-i-p.html new file mode 100644 index 00000000..e1769e4b --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/failure-retrieving-i-p.html @@ -0,0 +1,20 @@ + + + +GetIPCallbacks.failureRetrievingIP - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetIPCallbacks / failureRetrievingIP
+
+

failureRetrievingIP

+ +abstract fun failureRetrievingIP(): Unit +

Called when there is an issue retrieving the IP of a device.

+

i.e. No current IP for the device, bad formatting, etc.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/index.html new file mode 100644 index 00000000..60a42671 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/index.html @@ -0,0 +1,60 @@ + + + +GetIPCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetIPCallbacks
+
+

GetIPCallbacks

+interface GetIPCallbacks : BaseCallback +

Callbacks for retrieving a device's IP.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.getIP

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

failureRetrievingIP

+
+abstract fun failureRetrievingIP(): Unit +

Called when there is an issue retrieving the IP of a device.

+
+

retrievedIP

+
+abstract fun retrievedIP(ip: String): Unit +

Called when WiseFy has successfully retrieved the IP of a device.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/retrieved-i-p.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/retrieved-i-p.html new file mode 100644 index 00000000..b09de196 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-i-p-callbacks/retrieved-i-p.html @@ -0,0 +1,19 @@ + + + +GetIPCallbacks.retrievedIP - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetIPCallbacks / retrievedIP
+
+

retrievedIP

+ +abstract fun retrievedIP(ip: String): Unit +

Called when WiseFy has successfully retrieved the IP of a device.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-nearby-access-points-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-nearby-access-points-callbacks/index.html new file mode 100644 index 00000000..6f6040a5 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-nearby-access-points-callbacks/index.html @@ -0,0 +1,51 @@ + + + +GetNearbyAccessPointsCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetNearbyAccessPointsCallbacks
+
+

GetNearbyAccessPointsCallbacks

+interface GetNearbyAccessPointsCallbacks : BaseCallback +

Callbacks for retrieving a list of nearby access points.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.getNearbyAccessPoints

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + +
+

retrievedNearbyAccessPoints

+
+abstract fun retrievedNearbyAccessPoints(nearbyAccessPoints: List<ScanResult>): Unit +

Called when WiseFy has successfully retrieved a list of nearby access points.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-nearby-access-points-callbacks/retrieved-nearby-access-points.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-nearby-access-points-callbacks/retrieved-nearby-access-points.html new file mode 100644 index 00000000..081ee7cb --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-nearby-access-points-callbacks/retrieved-nearby-access-points.html @@ -0,0 +1,22 @@ + + + +GetNearbyAccessPointsCallbacks.retrievedNearbyAccessPoints - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetNearbyAccessPointsCallbacks / retrievedNearbyAccessPoints
+
+

retrievedNearbyAccessPoints

+ +abstract fun retrievedNearbyAccessPoints(nearbyAccessPoints: List<@JvmSuppressWildcards ScanResult>): Unit +

Called when WiseFy has successfully retrieved a list of nearby access points.

+

See Also
+

ScanResult

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/index.html new file mode 100644 index 00000000..4e52aaa0 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/index.html @@ -0,0 +1,61 @@ + + + +GetRSSICallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetRSSICallbacks
+
+

GetRSSICallbacks

+interface GetRSSICallbacks : BaseCallback +

Callbacks for retrieving RSSI level of a nearby access point.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.getRSSI

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

networkNotFoundToRetrieveRSSI

+
+abstract fun networkNotFoundToRetrieveRSSI(): Unit +

Called when the network to retrieve the RSSI level of is not found +in the list of nearby access points.

+
+

retrievedRSSI

+
+abstract fun retrievedRSSI(rssi: Int): Unit +

Called when WiseFy has successfully retrieved the RSSI level of a network.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/network-not-found-to-retrieve-r-s-s-i.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/network-not-found-to-retrieve-r-s-s-i.html new file mode 100644 index 00000000..dd172c92 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/network-not-found-to-retrieve-r-s-s-i.html @@ -0,0 +1,20 @@ + + + +GetRSSICallbacks.networkNotFoundToRetrieveRSSI - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetRSSICallbacks / networkNotFoundToRetrieveRSSI
+
+

networkNotFoundToRetrieveRSSI

+ +abstract fun networkNotFoundToRetrieveRSSI(): Unit +

Called when the network to retrieve the RSSI level of is not found +in the list of nearby access points.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/retrieved-r-s-s-i.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/retrieved-r-s-s-i.html new file mode 100644 index 00000000..584f6ac1 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-r-s-s-i-callbacks/retrieved-r-s-s-i.html @@ -0,0 +1,19 @@ + + + +GetRSSICallbacks.retrievedRSSI - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetRSSICallbacks / retrievedRSSI
+
+

retrievedRSSI

+ +abstract fun retrievedRSSI(rssi: Int): Unit +

Called when WiseFy has successfully retrieved the RSSI level of a network.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/index.html new file mode 100644 index 00000000..1e9501a9 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/index.html @@ -0,0 +1,58 @@ + + + +GetSavedNetworkCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetSavedNetworkCallbacks
+
+

GetSavedNetworkCallbacks

+interface GetSavedNetworkCallbacks : BaseCallback +

Callbacks for retrieving a saved network on a device.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.getSavedNetwork

+

+

Author
+Patches

+

Functions

+ + + + + + + + + + + +
+

retrievedSavedNetwork

+
+abstract fun retrievedSavedNetwork(savedNetwork: WifiConfiguration): Unit +

Called when WiseFy has successfully retrieved a matching saved network configuration.

+
+

savedNetworkNotFound

+
+abstract fun savedNetworkNotFound(): Unit +

Called when the given network is not a saved configuration.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/retrieved-saved-network.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/retrieved-saved-network.html new file mode 100644 index 00000000..6f776e12 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/retrieved-saved-network.html @@ -0,0 +1,22 @@ + + + +GetSavedNetworkCallbacks.retrievedSavedNetwork - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetSavedNetworkCallbacks / retrievedSavedNetwork
+
+

retrievedSavedNetwork

+ +abstract fun retrievedSavedNetwork(savedNetwork: WifiConfiguration): Unit +

Called when WiseFy has successfully retrieved a matching saved network configuration.

+

See Also
+

WifiConfiguration

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/saved-network-not-found.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/saved-network-not-found.html new file mode 100644 index 00000000..aabf6122 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-network-callbacks/saved-network-not-found.html @@ -0,0 +1,19 @@ + + + +GetSavedNetworkCallbacks.savedNetworkNotFound - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetSavedNetworkCallbacks / savedNetworkNotFound
+
+

savedNetworkNotFound

+ +abstract fun savedNetworkNotFound(): Unit +

Called when the given network is not a saved configuration.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/index.html new file mode 100644 index 00000000..ef8c929c --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/index.html @@ -0,0 +1,60 @@ + + + +GetSavedNetworksCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetSavedNetworksCallbacks
+
+

GetSavedNetworksCallbacks

+interface GetSavedNetworksCallbacks : BaseCallback +

Callbacks for retrieving a list of saved networks on a device.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.getSavedNetworks

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

noSavedNetworksFound

+
+abstract fun noSavedNetworksFound(): Unit +

Called when there are no saved network configuration on the device.

+
+

retrievedSavedNetworks

+
+abstract fun retrievedSavedNetworks(savedNetworks: List<WifiConfiguration>): Unit +

Called when WiseFy has successfully retrieved a list of saved networks.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/no-saved-networks-found.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/no-saved-networks-found.html new file mode 100644 index 00000000..7468ac01 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/no-saved-networks-found.html @@ -0,0 +1,19 @@ + + + +GetSavedNetworksCallbacks.noSavedNetworksFound - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetSavedNetworksCallbacks / noSavedNetworksFound
+
+

noSavedNetworksFound

+ +abstract fun noSavedNetworksFound(): Unit +

Called when there are no saved network configuration on the device.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/retrieved-saved-networks.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/retrieved-saved-networks.html new file mode 100644 index 00000000..d74ccad1 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-get-saved-networks-callbacks/retrieved-saved-networks.html @@ -0,0 +1,22 @@ + + + +GetSavedNetworksCallbacks.retrievedSavedNetworks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / GetSavedNetworksCallbacks / retrievedSavedNetworks
+
+

retrievedSavedNetworks

+ +abstract fun retrievedSavedNetworks(savedNetworks: List<@JvmSuppressWildcards WifiConfiguration>): Unit +

Called when WiseFy has successfully retrieved a list of saved networks.

+

See Also
+

WifiConfiguration

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/failure-removing-network.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/failure-removing-network.html new file mode 100644 index 00000000..bdb429f8 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/failure-removing-network.html @@ -0,0 +1,19 @@ + + + +RemoveNetworkCallbacks.failureRemovingNetwork - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / RemoveNetworkCallbacks / failureRemovingNetwork
+
+

failureRemovingNetwork

+ +abstract fun failureRemovingNetwork(): Unit +

Called when there is an issue removing a saved network configuration with WifiManager.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/index.html new file mode 100644 index 00000000..c9b3ff15 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/index.html @@ -0,0 +1,70 @@ + + + +RemoveNetworkCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / RemoveNetworkCallbacks
+
+

RemoveNetworkCallbacks

+interface RemoveNetworkCallbacks : BaseCallback +

Callbacks for removing a saved network on a device.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.removeNetwork

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + + + + + +
+

failureRemovingNetwork

+
+abstract fun failureRemovingNetwork(): Unit +

Called when there is an issue removing a saved network configuration with WifiManager.

+
+

networkNotFoundToRemove

+
+abstract fun networkNotFoundToRemove(): Unit +

Called when the network is not found in the save network configuration list.

+
+

networkRemoved

+
+abstract fun networkRemoved(): Unit +

Called when WiseFy has successfully removed a network from the +list of saved network configurations.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/network-not-found-to-remove.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/network-not-found-to-remove.html new file mode 100644 index 00000000..331ec8c8 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/network-not-found-to-remove.html @@ -0,0 +1,21 @@ + + + +RemoveNetworkCallbacks.networkNotFoundToRemove - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / RemoveNetworkCallbacks / networkNotFoundToRemove
+
+

networkNotFoundToRemove

+ +abstract fun networkNotFoundToRemove(): Unit +

Called when the network is not found in the save network configuration list.

+

This is not necessarily an error as it may have never been stored, +removed manually, or various other scenarios.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/network-removed.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/network-removed.html new file mode 100644 index 00000000..d07f0f66 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-remove-network-callbacks/network-removed.html @@ -0,0 +1,20 @@ + + + +RemoveNetworkCallbacks.networkRemoved - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / RemoveNetworkCallbacks / networkRemoved
+
+

networkRemoved

+ +abstract fun networkRemoved(): Unit +

Called when WiseFy has successfully removed a network from the +list of saved network configurations.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/access-point-found.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/access-point-found.html new file mode 100644 index 00000000..d1a0feee --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/access-point-found.html @@ -0,0 +1,22 @@ + + + +SearchForAccessPointCallbacks.accessPointFound - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForAccessPointCallbacks / accessPointFound
+
+

accessPointFound

+ +abstract fun accessPointFound(accessPoint: ScanResult): Unit +

Called when WiseFy has successfully found a matching access point.

+

See Also
+

ScanResult

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/access-point-not-found.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/access-point-not-found.html new file mode 100644 index 00000000..5990433f --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/access-point-not-found.html @@ -0,0 +1,19 @@ + + + +SearchForAccessPointCallbacks.accessPointNotFound - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForAccessPointCallbacks / accessPointNotFound
+
+

accessPointNotFound

+ +abstract fun accessPointNotFound(): Unit +

Called when WiseFy times out trying to find a matching access point.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/index.html new file mode 100644 index 00000000..d49c89cc --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-point-callbacks/index.html @@ -0,0 +1,60 @@ + + + +SearchForAccessPointCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForAccessPointCallbacks
+
+

SearchForAccessPointCallbacks

+interface SearchForAccessPointCallbacks : BaseCallback +

Callbacks for finding a nearby access point on a device.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.searchForAccessPoint

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

accessPointFound

+
+abstract fun accessPointFound(accessPoint: ScanResult): Unit +

Called when WiseFy has successfully found a matching access point.

+
+

accessPointNotFound

+
+abstract fun accessPointNotFound(): Unit +

Called when WiseFy times out trying to find a matching access point.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/found-access-points.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/found-access-points.html new file mode 100644 index 00000000..643418a0 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/found-access-points.html @@ -0,0 +1,22 @@ + + + +SearchForAccessPointsCallbacks.foundAccessPoints - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForAccessPointsCallbacks / foundAccessPoints
+
+

foundAccessPoints

+ +abstract fun foundAccessPoints(accessPoints: List<@JvmSuppressWildcards ScanResult>): Unit +

Called when WiseFy has successfully found matching access points.

+

See Also
+

ScanResult

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/index.html new file mode 100644 index 00000000..1bd71501 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/index.html @@ -0,0 +1,58 @@ + + + +SearchForAccessPointsCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForAccessPointsCallbacks
+
+

SearchForAccessPointsCallbacks

+interface SearchForAccessPointsCallbacks : BaseCallback +

Callbacks for finding a list of nearby access points on a device.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.searchForAccessPoints

+

+

Author
+Patches

+

Functions

+ + + + + + + + + + + +
+

foundAccessPoints

+
+abstract fun foundAccessPoints(accessPoints: List<ScanResult>): Unit +

Called when WiseFy has successfully found matching access points.

+
+

noAccessPointsFound

+
+abstract fun noAccessPointsFound(): Unit +

Called when WiseFy times out trying to find a matching access points.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/no-access-points-found.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/no-access-points-found.html new file mode 100644 index 00000000..1477dffb --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-access-points-callbacks/no-access-points-found.html @@ -0,0 +1,19 @@ + + + +SearchForAccessPointsCallbacks.noAccessPointsFound - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForAccessPointsCallbacks / noAccessPointsFound
+
+

noAccessPointsFound

+ +abstract fun noAccessPointsFound(): Unit +

Called when WiseFy times out trying to find a matching access points.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/index.html new file mode 100644 index 00000000..8f43b985 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/index.html @@ -0,0 +1,60 @@ + + + +SearchForSSIDCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForSSIDCallbacks
+
+

SearchForSSIDCallbacks

+interface SearchForSSIDCallbacks : BaseCallback +

Callbacks for finding a nearby SSID on a device.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.searchForSSID

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

ssidFound

+
+abstract fun ssidFound(ssid: String): Unit +

Called when WiseFy has successfully found an access point with a matching SSID.

+
+

ssidNotFound

+
+abstract fun ssidNotFound(): Unit +

Called when WiseFy times out trying to find an access point with a matching SSID.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/ssid-found.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/ssid-found.html new file mode 100644 index 00000000..31b52db1 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/ssid-found.html @@ -0,0 +1,19 @@ + + + +SearchForSSIDCallbacks.ssidFound - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForSSIDCallbacks / ssidFound
+
+

ssidFound

+ +abstract fun ssidFound(ssid: String): Unit +

Called when WiseFy has successfully found an access point with a matching SSID.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/ssid-not-found.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/ssid-not-found.html new file mode 100644 index 00000000..14546b14 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-d-callbacks/ssid-not-found.html @@ -0,0 +1,19 @@ + + + +SearchForSSIDCallbacks.ssidNotFound - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForSSIDCallbacks / ssidNotFound
+
+

ssidNotFound

+ +abstract fun ssidNotFound(): Unit +

Called when WiseFy times out trying to find an access point with a matching SSID.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/index.html new file mode 100644 index 00000000..d940cdf3 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/index.html @@ -0,0 +1,60 @@ + + + +SearchForSSIDsCallbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForSSIDsCallbacks
+
+

SearchForSSIDsCallbacks

+interface SearchForSSIDsCallbacks : BaseCallback +

Callbacks for finding a list of nearby SSIDs on a device.

+

See Also
+

BaseCallback

+

com.isupatches.wisefy.WiseFy.searchForSSIDs

+

+

Author
+Patches

+

Since
+3.0

+

Functions

+ + + + + + + + + + + +
+

noSSIDsFound

+
+abstract fun noSSIDsFound(): Unit +

Called when WiseFy times out trying to find access points with a matching SSID.

+
+

retrievedSSIDs

+
+abstract fun retrievedSSIDs(ssids: List<String>): Unit +

Called when WiseFy has successfully found access points with a matching SSID.

+
+

Inherited Functions

+ + + + + + + +
+

wisefyFailure

+
+abstract fun wisefyFailure(wisefyFailureCode: Int): Unit +

Called when com.isupatches.wisefy.WiseFyPrechecks determines that there +is an issue and an operation cannot be completed.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/no-s-s-i-ds-found.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/no-s-s-i-ds-found.html new file mode 100644 index 00000000..d059a19c --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/no-s-s-i-ds-found.html @@ -0,0 +1,19 @@ + + + +SearchForSSIDsCallbacks.noSSIDsFound - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForSSIDsCallbacks / noSSIDsFound
+
+

noSSIDsFound

+ +abstract fun noSSIDsFound(): Unit +

Called when WiseFy times out trying to find access points with a matching SSID.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/retrieved-s-s-i-ds.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/retrieved-s-s-i-ds.html new file mode 100644 index 00000000..7a1646de --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/-search-for-s-s-i-ds-callbacks/retrieved-s-s-i-ds.html @@ -0,0 +1,19 @@ + + + +SearchForSSIDsCallbacks.retrievedSSIDs - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks / SearchForSSIDsCallbacks / retrievedSSIDs
+
+

retrievedSSIDs

+ +abstract fun retrievedSSIDs(ssids: List<String>): Unit +

Called when WiseFy has successfully found access points with a matching SSID.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.callbacks/index.html b/javadoc/wisefy/com.isupatches.wisefy.callbacks/index.html new file mode 100644 index 00000000..f267e14f --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.callbacks/index.html @@ -0,0 +1,189 @@ + + + +com.isupatches.wisefy.callbacks - wisefy + + + +wisefy / com.isupatches.wisefy.callbacks
+
+

Package com.isupatches.wisefy.callbacks

+

Types

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

AddNetworkCallbacks

+
+interface AddNetworkCallbacks : BaseCallback +

Callbacks for adding a network as a saved configuration on a device.

+
+

BaseCallback

+
+interface BaseCallback +

Callbacks that are applicable to all Async WiseFy operations. +All Async interfaces should extend this class.

+
+

ConnectToNetworkCallbacks

+
+interface ConnectToNetworkCallbacks : BaseCallback +

Callbacks for attempting to connect to a network.

+
+

DisableWifiCallbacks

+
+interface DisableWifiCallbacks : BaseCallback +

Callbacks for disabling a device's wifi.

+
+

DisconnectFromCurrentNetworkCallbacks

+
+interface DisconnectFromCurrentNetworkCallbacks : BaseCallback +

Callbacks for disconnecting a device from it's current network.

+
+

EnableWifiCallbacks

+
+interface EnableWifiCallbacks : BaseCallback +

Callbacks for enabling a device's wifi.

+
+

GetCurrentNetworkCallbacks

+
+interface GetCurrentNetworkCallbacks : BaseCallback +

Callbacks for retrieving a device's current network.

+
+

GetCurrentNetworkInfoCallbacks

+
+interface GetCurrentNetworkInfoCallbacks : BaseCallback +

Callbacks for retrieving a device's current network.

+
+

GetFrequencyCallbacks

+
+interface GetFrequencyCallbacks : BaseCallback +

Callbacks for retrieving the frequency of a network.

+
+

GetIPCallbacks

+
+interface GetIPCallbacks : BaseCallback +

Callbacks for retrieving a device's IP.

+
+

GetNearbyAccessPointsCallbacks

+
+interface GetNearbyAccessPointsCallbacks : BaseCallback +

Callbacks for retrieving a list of nearby access points.

+
+

GetRSSICallbacks

+
+interface GetRSSICallbacks : BaseCallback +

Callbacks for retrieving RSSI level of a nearby access point.

+
+

GetSavedNetworkCallbacks

+
+interface GetSavedNetworkCallbacks : BaseCallback +

Callbacks for retrieving a saved network on a device.

+
+

GetSavedNetworksCallbacks

+
+interface GetSavedNetworksCallbacks : BaseCallback +

Callbacks for retrieving a list of saved networks on a device.

+
+

RemoveNetworkCallbacks

+
+interface RemoveNetworkCallbacks : BaseCallback +

Callbacks for removing a saved network on a device.

+
+

SearchForAccessPointCallbacks

+
+interface SearchForAccessPointCallbacks : BaseCallback +

Callbacks for finding a nearby access point on a device.

+
+

SearchForAccessPointsCallbacks

+
+interface SearchForAccessPointsCallbacks : BaseCallback +

Callbacks for finding a list of nearby access points on a device.

+
+

SearchForSSIDCallbacks

+
+interface SearchForSSIDCallbacks : BaseCallback +

Callbacks for finding a nearby SSID on a device.

+
+

SearchForSSIDsCallbacks

+
+interface SearchForSSIDsCallbacks : BaseCallback +

Callbacks for finding a list of nearby SSIDs on a device.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-capability/-init-.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-capability/-init-.html new file mode 100644 index 00000000..d76082bb --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-capability/-init-.html @@ -0,0 +1,19 @@ + + + +Capability.<init> - wisefy + + + +wisefy / com.isupatches.wisefy.constants / Capability / <init>
+
+

<init>

+ +Capability() +

Annotation to help avoid crazy strings when working with network security capabilities.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-capability/index.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-capability/index.html new file mode 100644 index 00000000..8e6775d5 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-capability/index.html @@ -0,0 +1,32 @@ + + + +Capability - wisefy + + + +wisefy / com.isupatches.wisefy.constants / Capability
+
+

Capability

+annotation class Capability +

Annotation to help avoid crazy strings when working with network security capabilities.

+

Author
+Patches

+

Since
+3.0

+

Constructors

+ + + + + + + +
+

<init>

+
+Capability() +

Annotation to help avoid crazy strings when working with network security capabilities.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-d-e-f-a-u-l-t_-p-r-e-c-h-e-c-k_-r-e-t-u-r-n_-c-o-d-e.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-d-e-f-a-u-l-t_-p-r-e-c-h-e-c-k_-r-e-t-u-r-n_-c-o-d-e.html new file mode 100644 index 00000000..41f423b8 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-d-e-f-a-u-l-t_-p-r-e-c-h-e-c-k_-r-e-t-u-r-n_-c-o-d-e.html @@ -0,0 +1,19 @@ + + + +DEFAULT_PRECHECK_RETURN_CODE - wisefy + + + +wisefy / com.isupatches.wisefy.constants / DEFAULT_PRECHECK_RETURN_CODE
+
+

DEFAULT_PRECHECK_RETURN_CODE

+ +const val DEFAULT_PRECHECK_RETURN_CODE: Int +

A constant that denotes a successful operation within WiseFy.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-e-a-p.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-e-a-p.html new file mode 100644 index 00000000..5064d48e --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-e-a-p.html @@ -0,0 +1,19 @@ + + + +EAP - wisefy + + + +wisefy / com.isupatches.wisefy.constants / EAP
+
+

EAP

+ +const val EAP: String +

Constant for EAP security capabilities.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-m-i-s-s-i-n-g_-p-a-r-a-m-e-t-e-r.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-m-i-s-s-i-n-g_-p-a-r-a-m-e-t-e-r.html new file mode 100644 index 00000000..dc2a9828 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-m-i-s-s-i-n-g_-p-a-r-a-m-e-t-e-r.html @@ -0,0 +1,19 @@ + + + +MISSING_PARAMETER - wisefy + + + +wisefy / com.isupatches.wisefy.constants / MISSING_PARAMETER
+
+

MISSING_PARAMETER

+ +const val MISSING_PARAMETER: Int +

A constant that denotes a parameter was null or empty ("")/ length 0.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-m-o-b-i-l-e.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-m-o-b-i-l-e.html new file mode 100644 index 00000000..9c386235 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-m-o-b-i-l-e.html @@ -0,0 +1,19 @@ + + + +MOBILE - wisefy + + + +wisefy / com.isupatches.wisefy.constants / MOBILE
+
+

MOBILE

+ +const val MOBILE: String +

Constant for a mobile network.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-n-e-t-w-o-r-k_-a-l-r-e-a-d-y_-c-o-n-f-i-g-u-r-e-d.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-n-e-t-w-o-r-k_-a-l-r-e-a-d-y_-c-o-n-f-i-g-u-r-e-d.html new file mode 100644 index 00000000..12aec029 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-n-e-t-w-o-r-k_-a-l-r-e-a-d-y_-c-o-n-f-i-g-u-r-e-d.html @@ -0,0 +1,19 @@ + + + +NETWORK_ALREADY_CONFIGURED - wisefy + + + +wisefy / com.isupatches.wisefy.constants / NETWORK_ALREADY_CONFIGURED
+
+

NETWORK_ALREADY_CONFIGURED

+ +const val NETWORK_ALREADY_CONFIGURED: Int +

A constant that denotes that a network is already a saved configuration.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-network-type/-init-.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-network-type/-init-.html new file mode 100644 index 00000000..9eebfcda --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-network-type/-init-.html @@ -0,0 +1,19 @@ + + + +NetworkType.<init> - wisefy + + + +wisefy / com.isupatches.wisefy.constants / NetworkType / <init>
+
+

<init>

+ +NetworkType() +

Annotation to help avoid crazy strings when handling network types.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-network-type/index.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-network-type/index.html new file mode 100644 index 00000000..78419995 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-network-type/index.html @@ -0,0 +1,32 @@ + + + +NetworkType - wisefy + + + +wisefy / com.isupatches.wisefy.constants / NetworkType
+
+

NetworkType

+annotation class NetworkType +

Annotation to help avoid crazy strings when handling network types.

+

Author
+Patches

+

Since
+3.0

+

Constructors

+ + + + + + + +
+

<init>

+
+NetworkType() +

Annotation to help avoid crazy strings when handling network types.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-p-s-k.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-p-s-k.html new file mode 100644 index 00000000..d92693c8 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-p-s-k.html @@ -0,0 +1,19 @@ + + + +PSK - wisefy + + + +wisefy / com.isupatches.wisefy.constants / PSK
+
+

PSK

+ +const val PSK: String +

Constant for PSK security capabilities.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-w-e-p.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-w-e-p.html new file mode 100644 index 00000000..5269064c --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-w-e-p.html @@ -0,0 +1,19 @@ + + + +WEP - wisefy + + + +wisefy / com.isupatches.wisefy.constants / WEP
+
+

WEP

+ +const val WEP: String +

Constant for WEP security capabilities.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-w-i-f-i.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-w-i-f-i.html new file mode 100644 index 00000000..37c9f057 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-w-i-f-i.html @@ -0,0 +1,19 @@ + + + +WIFI - wisefy + + + +wisefy / com.isupatches.wisefy.constants / WIFI
+
+

WIFI

+ +const val WIFI: String +

Constant for a Wifi network.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-w-p-a.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-w-p-a.html new file mode 100644 index 00000000..daa02b4d --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-w-p-a.html @@ -0,0 +1,19 @@ + + + +WPA - wisefy + + + +wisefy / com.isupatches.wisefy.constants / WPA
+
+

WPA

+ +const val WPA: String +

Constant for WPA security capabilities.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-w-p-a2.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-w-p-a2.html new file mode 100644 index 00000000..dfe8c3fd --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-w-p-a2.html @@ -0,0 +1,19 @@ + + + +WPA2 - wisefy + + + +wisefy / com.isupatches.wisefy.constants / WPA2
+
+

WPA2

+ +const val WPA2: String +

Constant for WPA2 security capabilities.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-wise-fy-code/-init-.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-wise-fy-code/-init-.html new file mode 100644 index 00000000..9076c581 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-wise-fy-code/-init-.html @@ -0,0 +1,19 @@ + + + +WiseFyCode.<init> - wisefy + + + +wisefy / com.isupatches.wisefy.constants / WiseFyCode / <init>
+
+

<init>

+ +WiseFyCode() +

Interface to avoid magic numbers when handling internal WiseFy codes.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/-wise-fy-code/index.html b/javadoc/wisefy/com.isupatches.wisefy.constants/-wise-fy-code/index.html new file mode 100644 index 00000000..a45d39ce --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/-wise-fy-code/index.html @@ -0,0 +1,32 @@ + + + +WiseFyCode - wisefy + + + +wisefy / com.isupatches.wisefy.constants / WiseFyCode
+
+

WiseFyCode

+annotation class WiseFyCode +

Interface to avoid magic numbers when handling internal WiseFy codes.

+

Author
+Patches

+

Since
+3.0

+

Constructors

+ + + + + + + +
+

<init>

+
+WiseFyCode() +

Interface to avoid magic numbers when handling internal WiseFy codes.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.constants/index.html b/javadoc/wisefy/com.isupatches.wisefy.constants/index.html new file mode 100644 index 00000000..81e48e60 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.constants/index.html @@ -0,0 +1,139 @@ + + + +com.isupatches.wisefy.constants - wisefy + + + +wisefy / com.isupatches.wisefy.constants
+
+

Package com.isupatches.wisefy.constants

+

Annotations

+ + + + + + + + + + + + + + + +
+

Capability

+
+annotation class Capability +

Annotation to help avoid crazy strings when working with network security capabilities.

+
+

NetworkType

+
+annotation class NetworkType +

Annotation to help avoid crazy strings when handling network types.

+
+

WiseFyCode

+
+annotation class WiseFyCode +

Interface to avoid magic numbers when handling internal WiseFy codes.

+
+

Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

DEFAULT_PRECHECK_RETURN_CODE

+
+const val DEFAULT_PRECHECK_RETURN_CODE: Int +

A constant that denotes a successful operation within WiseFy.

+
+

EAP

+
+const val EAP: String +

Constant for EAP security capabilities.

+
+

MISSING_PARAMETER

+
+const val MISSING_PARAMETER: Int +

A constant that denotes a parameter was null or empty ("")/ length 0.

+
+

MOBILE

+
+const val MOBILE: String +

Constant for a mobile network.

+
+

NETWORK_ALREADY_CONFIGURED

+
+const val NETWORK_ALREADY_CONFIGURED: Int +

A constant that denotes that a network is already a saved configuration.

+
+

PSK

+
+const val PSK: String +

Constant for PSK security capabilities.

+
+

WEP

+
+const val WEP: String +

Constant for WEP security capabilities.

+
+

WIFI

+
+const val WIFI: String +

Constant for a Wifi network.

+
+

WPA

+
+const val WPA: String +

Constant for WPA security capabilities.

+
+

WPA2

+
+const val WPA2: String +

Constant for WPA2 security capabilities.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.threads/-wise-fy-handler-thread/-init-.html b/javadoc/wisefy/com.isupatches.wisefy.threads/-wise-fy-handler-thread/-init-.html new file mode 100644 index 00000000..0bdd2dc6 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.threads/-wise-fy-handler-thread/-init-.html @@ -0,0 +1,20 @@ + + + +WiseFyHandlerThread.<init> - wisefy + + + +wisefy / com.isupatches.wisefy.threads / WiseFyHandlerThread / <init>
+
+

<init>

+ +WiseFyHandlerThread(name: String) +

A Thread to use for all WiseFy background processing.

+

NOTE Must be cleaned!! com.isupatches.wisefy.WiseFy.dump

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.threads/-wise-fy-handler-thread/index.html b/javadoc/wisefy/com.isupatches.wisefy.threads/-wise-fy-handler-thread/index.html new file mode 100644 index 00000000..1b238343 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.threads/-wise-fy-handler-thread/index.html @@ -0,0 +1,33 @@ + + + +WiseFyHandlerThread - wisefy + + + +wisefy / com.isupatches.wisefy.threads / WiseFyHandlerThread
+
+

WiseFyHandlerThread

+class WiseFyHandlerThread : HandlerThread +

A Thread to use for all WiseFy background processing.

+

NOTE Must be cleaned!! com.isupatches.wisefy.WiseFy.dump

+

Author
+Patches

+

Since
+3.0

+

Constructors

+ + + + + + + +
+

<init>

+
+WiseFyHandlerThread(name: String) +

A Thread to use for all WiseFy background processing.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy.threads/index.html b/javadoc/wisefy/com.isupatches.wisefy.threads/index.html new file mode 100644 index 00000000..1295da01 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy.threads/index.html @@ -0,0 +1,26 @@ + + + +com.isupatches.wisefy.threads - wisefy + + + +wisefy / com.isupatches.wisefy.threads
+
+

Package com.isupatches.wisefy.threads

+

Types

+ + + + + + + +
+

WiseFyHandlerThread

+
+class WiseFyHandlerThread : HandlerThread +

A Thread to use for all WiseFy background processing.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy-lock.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy-lock.html new file mode 100644 index 00000000..72f35568 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy-lock.html @@ -0,0 +1,21 @@ + + + +WiseFyLock - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFyLock
+
+

WiseFyLock

+class WiseFyLock +

A class used to synchronize logic.

+

See Also
+

WiseFy.getWiseFyLock

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/-init-.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/-init-.html new file mode 100644 index 00000000..375322c2 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/-init-.html @@ -0,0 +1,19 @@ + + + +WiseFy.Brains.<init> - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / Brains / <init>
+
+

<init>

+ +Brains(context: Context) +

The Builder class for WiseFy.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/get-smarts.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/get-smarts.html new file mode 100644 index 00000000..1653a1e9 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/get-smarts.html @@ -0,0 +1,22 @@ + + + +WiseFy.Brains.getSmarts - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / Brains / getSmarts
+
+

getSmarts

+ +fun getSmarts(): WiseFy +

Uses a private constructor and returns a WiseFy instance.

+

See Also
+

WiseFyLogger.configureWiseFyLoggerImplementation

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/index.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/index.html new file mode 100644 index 00000000..e6cb1ee0 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/index.html @@ -0,0 +1,55 @@ + + + +WiseFy.Brains - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / Brains
+
+

Brains

+class Brains +

The Builder class for WiseFy.

+

Author
+Patches

+

Since
+3.0

+

Constructors

+ + + + + + + +
+

<init>

+
+Brains(context: Context) +

The Builder class for WiseFy.

+
+

Functions

+ + + + + + + + + + + +
+

getSmarts

+
+fun getSmarts(): WiseFy +

Uses a private constructor and returns a WiseFy instance.

+
+

logging

+
+fun logging(loggingEnabled: Boolean): Brains +

Used to enable/or disable logging for a WiseFy instance.

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/logging.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/logging.html new file mode 100644 index 00000000..ea6a9ea1 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-brains/logging.html @@ -0,0 +1,22 @@ + + + +WiseFy.Brains.logging - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / Brains / logging
+
+

logging

+ +fun logging(loggingEnabled: Boolean): Brains +

Used to enable/or disable logging for a WiseFy instance.

+

Parameters

+

+loggingEnabled - If logging should be enabled for the WiseFy instance.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-m-a-x_-f-r-e-q-u-e-n-c-y_5-g-h-z.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-m-a-x_-f-r-e-q-u-e-n-c-y_5-g-h-z.html new file mode 100644 index 00000000..9ee4b4ae --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-m-a-x_-f-r-e-q-u-e-n-c-y_5-g-h-z.html @@ -0,0 +1,19 @@ + + + +WiseFy.MAX_FREQUENCY_5GHZ - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / MAX_FREQUENCY_5GHZ
+
+

MAX_FREQUENCY_5GHZ

+ +const val MAX_FREQUENCY_5GHZ: Int +

The max value possible for a 5gHz network.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-m-i-n_-f-r-e-q-u-e-n-c-y_5-g-h-z.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-m-i-n_-f-r-e-q-u-e-n-c-y_5-g-h-z.html new file mode 100644 index 00000000..9b86c572 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-m-i-n_-f-r-e-q-u-e-n-c-y_5-g-h-z.html @@ -0,0 +1,19 @@ + + + +WiseFy.MIN_FREQUENCY_5GHZ - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / MIN_FREQUENCY_5GHZ
+
+

MIN_FREQUENCY_5GHZ

+ +const val MIN_FREQUENCY_5GHZ: Int +

The minimum value possible for a 5gHz network.

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-w-i-f-i_-m-a-n-a-g-e-r_-f-a-i-l-u-r-e.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-w-i-f-i_-m-a-n-a-g-e-r_-f-a-i-l-u-r-e.html new file mode 100644 index 00000000..c11338f6 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/-w-i-f-i_-m-a-n-a-g-e-r_-f-a-i-l-u-r-e.html @@ -0,0 +1,22 @@ + + + +WiseFy.WIFI_MANAGER_FAILURE - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / WIFI_MANAGER_FAILURE
+
+

WIFI_MANAGER_FAILURE

+ +const val WIFI_MANAGER_FAILURE: Int +

The default error return from WifiManager

+

See Also
+

WifiManager

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-open-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-open-network.html new file mode 100644 index 00000000..272ccd06 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-open-network.html @@ -0,0 +1,49 @@ + + + +WiseFy.addOpenNetwork - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / addOpenNetwork
+
+

addOpenNetwork

+ +@Sync @CallingThread fun addOpenNetwork(ssid: String?): Int +

To add an open network to the user's configured network list.

+

Parameters

+

+ssid - The ssid of the open network you want to add

+

Return
+int - The return code from WifiManager for network creation (-1 for failure)

+

See Also
+

addNetworkConfiguration

+

generateOpenNetworkConfiguration

+

WiseFyPrechecks.addNetworkPrechecks

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun addOpenNetwork(ssid: String?, callbacks: AddNetworkCallbacks?): Unit +

To add an open network to the user's configured network list.

+

Parameters

+

+ssid - The ssid of the open network you want to add

+

+callbacks - The listener to return results to

+

See Also
+

addNetworkConfiguration

+

AddNetworkCallbacks

+

generateOpenNetworkConfiguration

+

runOnWiseFyThread

+

WiseFyLock

+

WiseFyPrechecks.addNetworkPrechecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-w-e-p-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-w-e-p-network.html new file mode 100644 index 00000000..5a43be82 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-w-e-p-network.html @@ -0,0 +1,53 @@ + + + +WiseFy.addWEPNetwork - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / addWEPNetwork
+
+

addWEPNetwork

+ +@Sync @CallingThread fun addWEPNetwork(ssid: String?, password: String?): Int +

To add a WEP network to the user's configured network list.

+

Parameters

+

+ssid - The ssid of the WEP network you want to add

+

+password - The password for the WEP network being added

+

Return
+int - The return code from WifiManager for network creation (-1 for failure)

+

See Also
+

addNetworkConfiguration

+

generateWEPNetworkConfiguration

+

WiseFyPrechecks.addNetworkPrechecks

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun addWEPNetwork(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?): Unit +

To add a WEP network to the user's configured network list.

+

Parameters

+

+ssid - The ssid of the WEP network you want to add

+

+password - The password for the WEP network being added

+

+callbacks - The listener to return results to

+

See Also
+

addNetworkConfiguration

+

AddNetworkCallbacks

+

generateWEPNetworkConfiguration

+

runOnWiseFyThread

+

WiseFyLock

+

WiseFyPrechecks.addNetworkPrechecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-w-p-a2-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-w-p-a2-network.html new file mode 100644 index 00000000..e4fa4af6 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/add-w-p-a2-network.html @@ -0,0 +1,53 @@ + + + +WiseFy.addWPA2Network - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / addWPA2Network
+
+

addWPA2Network

+ +@Sync @CallingThread fun addWPA2Network(ssid: String?, password: String?): Int +

To add a WPA2 network to the user's configured network list.

+

Parameters

+

+ssid - The ssid of the WPA2 network you want to add

+

+password - The password for the WPA2 network being added

+

Return
+int - The return code from WifiManager for network creation (-1 for failure)

+

See Also
+

addNetworkConfiguration

+

generateWPA2NetworkConfiguration

+

WiseFyPrechecks.addNetworkPrechecks

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun addWPA2Network(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?): Unit +

To add a WPA2 network to the user's configured network list.

+

Parameters

+

+ssid - The ssid of the WPA2 network you want to add

+

+password - The password for the WPA2 network being added

+

+callbacks - The listener to return results to

+

See Also
+

addNetworkConfiguration

+

AddNetworkCallbacks

+

generateWPA2NetworkConfiguration

+

runOnWiseFyThread

+

WiseFyLock

+

WiseFyPrechecks.addNetworkPrechecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/calculate-bars.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/calculate-bars.html new file mode 100644 index 00000000..82327128 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/calculate-bars.html @@ -0,0 +1,29 @@ + + + +WiseFy.calculateBars - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / calculateBars
+
+

calculateBars

+ +@Sync @CallingThread fun calculateBars(rssiLevel: Int, targetNumberOfBars: Int): Int +

To convert an RSSI level for a network to a number of bars.

+

Parameters

+

+rssiLevel - The signal strength of the network

+

+targetNumberOfBars - How many bars or levels there will be total

+

Return
+int - The number of bars for the given RSSI value

+

See Also
+

WifiManager.calculateSignalLevel

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/compare-signal-level.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/compare-signal-level.html new file mode 100644 index 00000000..eb0e7a51 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/compare-signal-level.html @@ -0,0 +1,34 @@ + + + +WiseFy.compareSignalLevel - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / compareSignalLevel
+
+

compareSignalLevel

+ +@Sync @CallingThread fun compareSignalLevel(rssi1: Int, rssi2: Int): Int +

To compare the signal strength of two networks.

+

This method will return:

+ +

Parameters

+

+rssi1 - The signal strength of network 1

+

+rssi2 - The signal strength of network 2

+

Return
+int - The result of the comparison

+

See Also
+

WifiManager.compareSignalLevel

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/connect-to-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/connect-to-network.html new file mode 100644 index 00000000..1b39f700 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/connect-to-network.html @@ -0,0 +1,57 @@ + + + +WiseFy.connectToNetwork - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / connectToNetwork
+
+

connectToNetwork

+ +@Sync @CallingThread @WaitsForTimeout fun connectToNetwork(ssidToConnectTo: String?, timeoutInMillis: Int): Boolean +

Used to connect to a network.

+

NOTE Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity.

+

Parameters

+

+ssidToConnectTo - The ssid to connect/reconnect to

+

+timeoutInMillis - The number of milliseconds to continue waiting for the device to connect to the given SSID

+

Return
+boolean - If the network was successfully reconnected

+

See Also
+

connectToNetworkWithId

+

WiseFyConnection.waitToConnectToSSID

+

WiseFyPrechecks.connectToNetworkPrechecks

+

WiseFySearch.findSavedNetworkByRegex

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread @WaitsForTimeout fun connectToNetwork(ssidToConnectTo: String?, timeoutInMillis: Int, callbacks: ConnectToNetworkCallbacks?): Unit +

Used to connect to a network.

+

Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity.

+

Parameters

+

+ssidToConnectTo - The ssid to connect/reconnect to

+

+timeoutInMillis - The number of milliseconds to continue waiting for the device to connect to the given SSID

+

+callbacks - The listener to return results to

+

See Also
+

connectToNetworkWithId

+

ConnectToNetworkCallbacks

+

runOnWiseFyThread

+

WiseFyConnection.waitToConnectToSSID

+

WiseFyLock

+

WiseFyPrechecks.connectToNetworkPrechecks

+

WiseFySearch.findSavedNetworkByRegex

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/disable-wifi.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/disable-wifi.html new file mode 100644 index 00000000..448f930f --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/disable-wifi.html @@ -0,0 +1,42 @@ + + + +WiseFy.disableWifi - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / disableWifi
+
+

disableWifi

+ +@Sync @CallingThread fun disableWifi(): Boolean +

To disable Wifi on a user's device.

+

Return
+boolean - True if the command succeeded in disabling wifi

+

See Also
+

WifiManager.setWifiEnabled

+

WiseFyPrechecks.disableWifiChecks

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun disableWifi(callbacks: DisableWifiCallbacks?): Unit +

To disable Wifi on a user's device.

+

Parameters

+

+callbacks - The listener to return results to

+

See Also
+

DisableWifiCallbacks

+

runOnWiseFyThread

+

WifiManager.setWifiEnabled

+

WiseFyLock

+

WiseFyPrechecks.disableWifiChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/disconnect-from-current-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/disconnect-from-current-network.html new file mode 100644 index 00000000..69d6d5dd --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/disconnect-from-current-network.html @@ -0,0 +1,41 @@ + + + +WiseFy.disconnectFromCurrentNetwork - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / disconnectFromCurrentNetwork
+
+

disconnectFromCurrentNetwork

+ +@Sync @CallingThread fun disconnectFromCurrentNetwork(): Boolean +

To disconnect the user from their current network.

+

Return
+boolean - If the command succeeded in disconnecting the device from the current network

+

See Also
+

WifiManager.disconnect

+

WiseFyPrechecks.disconnectFromCurrentNetworkChecks

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun disconnectFromCurrentNetwork(callbacks: DisconnectFromCurrentNetworkCallbacks?): Unit +

To disconnect the user from their current network.

+

Parameters

+

+callbacks - The listener to return results to

+

See Also
+

DisconnectFromCurrentNetworkCallbacks

+

runOnWiseFyThread

+

WifiManager.disconnect

+

WiseFyLock

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/dump.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/dump.html new file mode 100644 index 00000000..3a24708e --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/dump.html @@ -0,0 +1,23 @@ + + + +WiseFy.dump - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / dump
+
+

dump

+ +fun dump(): Unit +

Used to cleanup the thread started by WiseFy.

+

See Also
+

WiseFyHandlerThread

+

WiseFyLock

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/enable-wifi.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/enable-wifi.html new file mode 100644 index 00000000..7b5d8167 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/enable-wifi.html @@ -0,0 +1,42 @@ + + + +WiseFy.enableWifi - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / enableWifi
+
+

enableWifi

+ +@Sync @CallingThread fun enableWifi(): Boolean +

To enable Wifi on a user's device.

+

Return
+boolean - If the command succeeded in enabling wifi

+

See Also
+

WifiManager.setWifiEnabled

+

WiseFyPrechecks.enableWifiChecks

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun enableWifi(callbacks: EnableWifiCallbacks?): Unit +

To enable Wifi on a user's device.

+

Parameters

+

+callbacks - The listener to return results to

+

See Also
+

EnableWifiCallbacks

+

runOnWiseFyThread

+

WifiManager.setWifiEnabled

+

WiseFyLock

+

WiseFyPrechecks.enableWifiChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-current-network-info.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-current-network-info.html new file mode 100644 index 00000000..df5701d4 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-current-network-info.html @@ -0,0 +1,44 @@ + + + +WiseFy.getCurrentNetworkInfo - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / getCurrentNetworkInfo
+
+

getCurrentNetworkInfo

+ +@Sync @CallingThread fun getCurrentNetworkInfo(): NetworkInfo? +

To retrieve the details of the phones active network.

+

Return
+NetworkInfo

+

See Also
+

ConnectivityManager.getActiveNetworkInfo

+

NetworkInfo

+

WiseFyPrechecks.getCurrentNetworkInfoChecks

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun getCurrentNetworkInfo(callbacks: GetCurrentNetworkInfoCallbacks?): Unit +

To retrieve the details of the phones active network.

+

Parameters

+

+callbacks - The listener to return results to

+

See Also
+

ConnectivityManager.getActiveNetworkInfo

+

GetCurrentNetworkInfoCallbacks

+

NetworkInfo

+

runOnWiseFyThread

+

WiseFyLock

+

WiseFyPrechecks.getCurrentNetworkInfoChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-current-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-current-network.html new file mode 100644 index 00000000..6f7d967e --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-current-network.html @@ -0,0 +1,50 @@ + + + +WiseFy.getCurrentNetwork - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / getCurrentNetwork
+
+

getCurrentNetwork

+ +@Sync @CallingThread fun getCurrentNetwork(): WifiInfo? +

To retrieve the user's current network.

+

Exceptions

+

+SecurityException - Without necessary permissions granted

+

Return
+WifiInfo|null - The user's current network information

+

See Also
+

WifiInfo

+

WifiManager.getConnectionInfo

+

WiseFyPrechecks.getCurrentNetworkChecks

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun getCurrentNetwork(callbacks: GetCurrentNetworkCallbacks?): Unit +

To retrieve the user's current network.

+

Parameters

+

+callbacks - The listener to return results to

+

Exceptions

+

+SecurityException - Without necessary permissions granted

+

See Also
+

GetCurrentNetworkCallbacks

+

runOnWiseFyThread

+

WifiInfo

+

WifiManager.getConnectionInfo

+

WiseFyLock

+

WiseFyPrechecks.getCurrentNetworkChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-frequency.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-frequency.html new file mode 100644 index 00000000..df826b0a --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-frequency.html @@ -0,0 +1,81 @@ + + + +WiseFy.getFrequency - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / getFrequency
+
+

getFrequency

+ +@Sync @CallingThread fun getFrequency(): Int? +

To retrieve the frequency of the device's current network.

+

Exceptions

+

+SecurityException - Without necessary permissions granted

+

Return
+Integer - The frequency of the devices current network or null if no network

+

See Also
+

getCurrentNetwork

+

WifiInfo.getFrequency

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun getFrequency(callbacks: GetFrequencyCallbacks?): Unit +

To retrieve the frequency of the device's current network.

+

Parameters

+

+callbacks - The listener to return results to

+

Exceptions

+

+SecurityException - Without necessary permissions granted

+

See Also
+

getCurrentNetwork

+

GetFrequencyCallbacks

+

runOnWiseFyThread

+

WifiInfo.getFrequency

+

WiseFyLock

+

+

Author
+Patches

+

Since
+3.0

+ +@Sync @CallingThread fun getFrequency(network: WifiInfo?): Int? +

To retrieve the frequency of a network.

+

Parameters

+

+network - The network to return the frequency of

+

Return
+Integer - The frequency of the devices current network or null if no network

+

See Also
+

WifiInfo.getFrequency

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun getFrequency(network: WifiInfo?, callbacks: GetFrequencyCallbacks?): Unit +

To retrieve the frequency of a network.

+

Parameters

+

+network - The network to return the frequency of

+

+callbacks - The listener to return results to

+

See Also
+

GetFrequencyCallbacks

+

runOnWiseFyThread

+

WifiInfo.getFrequency

+

WiseFyLock

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-i-p.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-i-p.html new file mode 100644 index 00000000..0aa9ab75 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-i-p.html @@ -0,0 +1,46 @@ + + + +WiseFy.getIP - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / getIP
+
+

getIP

+ +@Sync @CallingThread fun getIP(): String? +

To retrieve the IPv4 or IPv6 of a device.

+

Return
+String - The IPv4 or IPv6 address

+

See Also
+

InetAddress.getHostAddress

+

WifiInfo.getIpAddress

+

WifiManager.getConnectionInfo

+

WiseFyPrechecks.getIPChecks

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun getIP(callbacks: GetIPCallbacks?): Unit +

To retrieve the IPv4 or IPv6 of a device.

+

Parameters

+

+callbacks - The listener to return results to

+

See Also
+

GetIPCallbacks

+

InetAddress.getHostAddress

+

runOnWiseFyThread

+

WifiInfo.getIpAddress

+

WifiManager.getConnectionInfo

+

WiseFyLock

+

WiseFyPrechecks.getIPChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-nearby-access-points.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-nearby-access-points.html new file mode 100644 index 00000000..ab810e11 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-nearby-access-points.html @@ -0,0 +1,58 @@ + + + +WiseFy.getNearbyAccessPoints - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / getNearbyAccessPoints
+
+

getNearbyAccessPoints

+ +@Sync @CallingThread fun getNearbyAccessPoints(filterDuplicates: Boolean): List<ScanResult>? +

To retrieve a list of nearby access points.

+

NOTE Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI +(will always take the highest signal strength).

+

Parameters

+

+filterDuplicates - If you want to exclude SSIDs with that same name that have a weaker signal strength

+

Exceptions

+

+SecurityException - Without necessary permissions granted

+

Return
+List of ScanResults|null - List of nearby access points

+

See Also
+

ScanResult

+

WifiManager.getScanResults

+

WifiManager.startScan

+

WiseFyPrechecks.getNearbyAccessPointsChecks

+

WiseFySearch.removeEntriesWithLowerSignalStrength

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun getNearbyAccessPoints(filterDuplicates: Boolean, callbacks: GetNearbyAccessPointsCallbacks?): Unit +

To retrieve a list of nearby access points.

+

NOTE Setting filterDuplicates to true will not return SSIDs with a weaker signal strength (will always take the highest).

+

Parameters

+

+filterDuplicates - If you want to exclude SSIDs with that same name that have a weaker signal strength

+

+callbacks - The listener to return results to

+

See Also
+

GetNearbyAccessPointsCallbacks

+

runOnWiseFyThread

+

WifiManager.getScanResults

+

WifiManager.startScan

+

WiseFyLock

+

WiseFyPrechecks.getNearbyAccessPointsChecks

+

WiseFySearch.removeEntriesWithLowerSignalStrength

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-r-s-s-i.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-r-s-s-i.html new file mode 100644 index 00000000..0b978bef --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-r-s-s-i.html @@ -0,0 +1,59 @@ + + + +WiseFy.getRSSI - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / getRSSI
+
+

getRSSI

+ +@Sync @CallingThread @WaitsForTimeout fun getRSSI(regexForSSID: String?, takeHighest: Boolean, timeoutInMillis: Int): Int? +

To retrieve the RSSI of the first network matching a given regex.

+

NOTE Setting takeHighest to true will return the access point with the highest RSSI for the given SSID.

+

Parameters

+

+regexForSSID - The regex to be used to search for the ssid

+

+takeHighest - Whether to return the access point with the highest RSSI for the given SSID

+

+timeoutInMillis - The amount of time to search for a matching SSID

+

Return
+Integer - The RSSI value for the found SSID or null if no matching network found

+

See Also
+

ScanResult.level

+

WiseFyPrechecks.getRSSIChecks

+

WiseFySearch.findAccessPointByRegex

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread @WaitsForTimeout fun getRSSI(regexForSSID: String?, takeHighest: Boolean, timeoutInMillis: Int, callbacks: GetRSSICallbacks?): Unit +

To retrieve the RSSI of the first network matching a given regex.

+

NOTE Setting takeHighest to true will return the access point with the highest RSSI for the given SSID.

+

Parameters

+

+regexForSSID - The regex to be used to search for the ssid

+

+takeHighest - Whether to return the access point with the highest RSSI for the given SSID

+

+timeoutInMillis - The amount of time to search for a matching SSID

+

+callbacks - The listener to return results to

+

See Also
+

GetRSSICallbacks

+

runOnWiseFyThread

+

ScanResult.level

+

WiseFyLock

+

WiseFyPrechecks.getRSSIChecks

+

WiseFySearch.findAccessPointByRegex

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-saved-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-saved-network.html new file mode 100644 index 00000000..adffad01 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-saved-network.html @@ -0,0 +1,49 @@ + + + +WiseFy.getSavedNetwork - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / getSavedNetwork
+
+

getSavedNetwork

+ +@Sync @CallingThread fun getSavedNetwork(regexForSSID: String?): WifiConfiguration? +

To search for and return a saved WiFiConfiguration given an SSID.

+

Parameters

+

+regexForSSID - The ssid to use while searching for saved configuration

+

Return
+WifiConfiguration|null - Saved network that matches the ssid

+

See Also
+

WifiConfiguration

+

WiseFyPrechecks.getSavedNetworkChecks

+

WiseFySearch.findSavedNetworkByRegex

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun getSavedNetwork(regexForSSID: String?, callbacks: GetSavedNetworkCallbacks?): Unit +

To search for and return a saved WiFiConfiguration given an SSID.

+

Parameters

+

+regexForSSID - The ssid to use while searching for saved configuration

+

+callbacks - The listener to return results to

+

See Also
+

GetSavedNetworkCallbacks

+

runOnWiseFyThread

+

WifiConfiguration

+

WiseFyLock

+

WiseFyPrechecks.getSavedNetworkChecks

+

WiseFySearch.findSavedNetworkByRegex

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-saved-networks.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-saved-networks.html new file mode 100644 index 00000000..3a1b0313 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-saved-networks.html @@ -0,0 +1,81 @@ + + + +WiseFy.getSavedNetworks - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / getSavedNetworks
+
+

getSavedNetworks

+ +@Sync @CallingThread fun getSavedNetworks(): List<WifiConfiguration>? +

To retrieve a list of saved networks on a user's device.

+

Return
+List of WifiConfiguration|null - List of saved networks on a users device

+

See Also
+

WifiConfiguration

+

WiseFyPrechecks.getSavedNetworksChecks

+

WiseFySearch.findSavedNetworksMatchingRegex

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun getSavedNetworks(callbacks: GetSavedNetworksCallbacks?): Unit +

To retrieve a list of saved networks on a user's device.

+

Parameters

+

+callbacks - The listener to return results to

+

See Also
+

GetSavedNetworksCallbacks

+

runOnWiseFyThread

+

WifiConfiguration

+

WiseFyLock

+

WiseFyPrechecks.getSavedNetworksChecks

+

WiseFySearch.findSavedNetworksMatchingRegex

+

+

Author
+Patches

+

Since
+3.0

+ +@Sync @CallingThread fun getSavedNetworks(regexForSSID: String?): List<WifiConfiguration>? +

To retrieve a list of saved networks on a user's device that match a given regex.

+

Parameters

+

+regexForSSID - The ssid to use while searching for saved configurations

+

Return
+List of WifiConfigurations|null - The list of saved network configurations that match the given regex

+

See Also
+

WifiConfiguration

+

WiseFyPrechecks.getSavedNetworksChecks

+

WiseFySearch.findSavedNetworksMatchingRegex

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun getSavedNetworks(regexForSSID: String?, callbacks: GetSavedNetworksCallbacks?): Unit +

To retrieve a list of saved networks on a user's device that match a given regex.

+

Parameters

+

+regexForSSID - The ssid to use while searching for saved configurations

+

+callbacks - The listener to return results to

+

See Also
+

GetSavedNetworksCallbacks

+

runOnWiseFyThread

+

WifiConfiguration

+

WiseFyLock

+

WiseFyPrechecks.getSavedNetworksChecks

+

WiseFySearch.findSavedNetworksMatchingRegex

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-wise-fy-lock.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-wise-fy-lock.html new file mode 100644 index 00000000..b27cdbfc --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/get-wise-fy-lock.html @@ -0,0 +1,24 @@ + + + +WiseFy.getWiseFyLock - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / getWiseFyLock
+
+

getWiseFyLock

+ +fun getWiseFyLock(): WiseFyLock +

To retrieve the lock in use by WiseFy for synchronization.

+

Return
+WiseFyLock - The instance of the lock in use by WiseFy

+

See Also
+

WiseFyLock

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/index.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/index.html new file mode 100644 index 00000000..f57ab59a --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/index.html @@ -0,0 +1,449 @@ + + + +WiseFy - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy
+
+

WiseFy

+@PublicAPI class WiseFy : WiseFyPublicApi +

Main class for WiseFy that provides a synchronous and asynchronous API to manipulate and query +for different parts of a device's wifi configuration and status.

+

Author
+Patches

+

Since
+3.0

+

Types

+ + + + + + + +
+

Brains

+
+class Brains +

The Builder class for WiseFy.

+
+

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

addOpenNetwork

+
+fun addOpenNetwork(ssid: String?): Int
+fun addOpenNetwork(ssid: String?, callbacks: AddNetworkCallbacks?): Unit +

To add an open network to the user's configured network list.

+
+

addWEPNetwork

+
+fun addWEPNetwork(ssid: String?, password: String?): Int
+fun addWEPNetwork(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?): Unit +

To add a WEP network to the user's configured network list.

+
+

addWPA2Network

+
+fun addWPA2Network(ssid: String?, password: String?): Int
+fun addWPA2Network(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?): Unit +

To add a WPA2 network to the user's configured network list.

+
+

calculateBars

+
+fun calculateBars(rssiLevel: Int, targetNumberOfBars: Int): Int +

To convert an RSSI level for a network to a number of bars.

+
+

compareSignalLevel

+
+fun compareSignalLevel(rssi1: Int, rssi2: Int): Int +

To compare the signal strength of two networks.

+
+

connectToNetwork

+
+fun connectToNetwork(ssidToConnectTo: String?, timeoutInMillis: Int): Boolean
+fun connectToNetwork(ssidToConnectTo: String?, timeoutInMillis: Int, callbacks: ConnectToNetworkCallbacks?): Unit +

Used to connect to a network.

+
+

disableWifi

+
+fun disableWifi(): Boolean
+fun disableWifi(callbacks: DisableWifiCallbacks?): Unit +

To disable Wifi on a user's device.

+
+

disconnectFromCurrentNetwork

+
+fun disconnectFromCurrentNetwork(): Boolean
+fun disconnectFromCurrentNetwork(callbacks: DisconnectFromCurrentNetworkCallbacks?): Unit +

To disconnect the user from their current network.

+
+

dump

+
+fun dump(): Unit +

Used to cleanup the thread started by WiseFy.

+
+

enableWifi

+
+fun enableWifi(): Boolean
+fun enableWifi(callbacks: EnableWifiCallbacks?): Unit +

To enable Wifi on a user's device.

+
+

getCurrentNetwork

+
+fun getCurrentNetwork(): WifiInfo?
+fun getCurrentNetwork(callbacks: GetCurrentNetworkCallbacks?): Unit +

To retrieve the user's current network.

+
+

getCurrentNetworkInfo

+
+fun getCurrentNetworkInfo(): NetworkInfo?
+fun getCurrentNetworkInfo(callbacks: GetCurrentNetworkInfoCallbacks?): Unit +

To retrieve the details of the phones active network.

+
+

getFrequency

+
+fun getFrequency(): Int?
+fun getFrequency(callbacks: GetFrequencyCallbacks?): Unit +

To retrieve the frequency of the device's current network.

+fun getFrequency(network: WifiInfo?): Int?
+fun getFrequency(network: WifiInfo?, callbacks: GetFrequencyCallbacks?): Unit +

To retrieve the frequency of a network.

+
+

getIP

+
+fun getIP(): String?
+fun getIP(callbacks: GetIPCallbacks?): Unit +

To retrieve the IPv4 or IPv6 of a device.

+
+

getNearbyAccessPoints

+
+fun getNearbyAccessPoints(filterDuplicates: Boolean): List<ScanResult>?
+fun getNearbyAccessPoints(filterDuplicates: Boolean, callbacks: GetNearbyAccessPointsCallbacks?): Unit +

To retrieve a list of nearby access points.

+
+

getRSSI

+
+fun getRSSI(regexForSSID: String?, takeHighest: Boolean, timeoutInMillis: Int): Int?
+fun getRSSI(regexForSSID: String?, takeHighest: Boolean, timeoutInMillis: Int, callbacks: GetRSSICallbacks?): Unit +

To retrieve the RSSI of the first network matching a given regex.

+
+

getSavedNetwork

+
+fun getSavedNetwork(regexForSSID: String?): WifiConfiguration?
+fun getSavedNetwork(regexForSSID: String?, callbacks: GetSavedNetworkCallbacks?): Unit +

To search for and return a saved WiFiConfiguration given an SSID.

+
+

getSavedNetworks

+
+fun getSavedNetworks(): List<WifiConfiguration>?
+fun getSavedNetworks(callbacks: GetSavedNetworksCallbacks?): Unit +

To retrieve a list of saved networks on a user's device.

+fun getSavedNetworks(regexForSSID: String?): List<WifiConfiguration>?
+fun getSavedNetworks(regexForSSID: String?, callbacks: GetSavedNetworksCallbacks?): Unit +

To retrieve a list of saved networks on a user's device that match a given regex.

+
+

getWiseFyLock

+
+fun getWiseFyLock(): WiseFyLock +

To retrieve the lock in use by WiseFy for synchronization.

+
+

isDeviceConnectedToMobileNetwork

+
+fun isDeviceConnectedToMobileNetwork(): Boolean +

To check if the device is connected to a mobile network.

+
+

isDeviceConnectedToMobileOrWifiNetwork

+
+fun isDeviceConnectedToMobileOrWifiNetwork(): Boolean +

To check if the device is connected to a mobile or wifi network.

+
+

isDeviceConnectedToSSID

+
+fun isDeviceConnectedToSSID(ssid: String?): Boolean +

To check if the device is connected to a given SSID.

+
+

isDeviceConnectedToWifiNetwork

+
+fun isDeviceConnectedToWifiNetwork(): Boolean +

To check if the device is connected to a wifi network.

+
+

isDeviceRoaming

+
+fun isDeviceRoaming(): Boolean +

To query if the device is roaming.

+
+

isLoggingEnabled

+
+fun isLoggingEnabled(): Boolean +

To query if logging is enabled or disabled for a WiseFy instance.

+
+

isNetwork5gHz

+
+fun isNetwork5gHz(): Boolean +

To check if the device's current network is 5gHz.

+fun isNetwork5gHz(network: WifiInfo?): Boolean +

To check if a given network is 5gHz.

+
+

isNetworkEAP

+
+fun isNetworkEAP(scanResult: ScanResult?): Boolean +

To check and return if a network is a EAP network.

+
+

isNetworkPSK

+
+fun isNetworkPSK(scanResult: ScanResult?): Boolean +

To check and return if a network is a PSK network.

+
+

isNetworkSaved

+
+fun isNetworkSaved(ssid: String?): Boolean +

To check if an SSID is in the list of configured networks.

+
+

isNetworkSecure

+
+fun isNetworkSecure(scanResult: ScanResult?): Boolean +

To check and return if a network is secure (contains EAP/PSK/WEP/WPA/WPA2 capabilities).

+
+

isNetworkWEP

+
+fun isNetworkWEP(scanResult: ScanResult?): Boolean +

To check and return if a network is a WEP network.

+
+

isNetworkWPA

+
+fun isNetworkWPA(scanResult: ScanResult?): Boolean +

To check and return if a network is a WPA network.

+
+

isNetworkWPA2

+
+fun isNetworkWPA2(scanResult: ScanResult?): Boolean +

To check and return if a network is a WPA2 network.

+
+

isWifiEnabled

+
+fun isWifiEnabled(): Boolean +

To check if Wifi is enabled on the device or not.

+
+

removeNetwork

+
+fun removeNetwork(ssidToRemove: String?): Boolean
+fun removeNetwork(ssidToRemove: String?, callbacks: RemoveNetworkCallbacks?): Unit +

To remove a configured network.

+
+

searchForAccessPoint

+
+fun searchForAccessPoint(regexForSSID: String?, timeoutInMillis: Int, filterDuplicates: Boolean): ScanResult?
+fun searchForAccessPoint(regexForSSID: String?, timeoutInMillis: Int, filterDuplicates: Boolean, callbacks: SearchForAccessPointCallbacks?): Unit +

To return the first access point that matches a given regex.

+
+

searchForAccessPoints

+
+fun searchForAccessPoints(regexForSSID: String?, filterDuplicates: Boolean): List<ScanResult>?
+fun searchForAccessPoints(regexForSSID: String?, filterDuplicates: Boolean, callbacks: SearchForAccessPointsCallbacks?): Unit +

To return nearby access points that match a given regex.

+
+

searchForSSID

+
+fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int): String?
+fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int, callbacks: SearchForSSIDCallbacks?): Unit +

To search local networks and return the first one that contains a given ssid.

+
+

searchForSSIDs

+
+fun searchForSSIDs(regexForSSID: String?): List<String>?
+fun searchForSSIDs(regexForSSID: String?, callbacks: SearchForSSIDsCallbacks?): Unit +

To search local networks and return the first one that contains a given ssid.

+
+

Companion Object Properties

+ + + + + + + + + + + + + + + +
+

MAX_FREQUENCY_5GHZ

+
+const val MAX_FREQUENCY_5GHZ: Int +

The max value possible for a 5gHz network.

+
+

MIN_FREQUENCY_5GHZ

+
+const val MIN_FREQUENCY_5GHZ: Int +

The minimum value possible for a 5gHz network.

+
+

WIFI_MANAGER_FAILURE

+
+const val WIFI_MANAGER_FAILURE: Int +

The default error return from WifiManager

+
+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-mobile-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-mobile-network.html new file mode 100644 index 00000000..d07262df --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-mobile-network.html @@ -0,0 +1,27 @@ + + + +WiseFy.isDeviceConnectedToMobileNetwork - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isDeviceConnectedToMobileNetwork
+
+

isDeviceConnectedToMobileNetwork

+ +@Sync @CallingThread fun isDeviceConnectedToMobileNetwork(): Boolean +

To check if the device is connected to a mobile network.

+

Return
+bool - If the device is currently connected to a mobile network

+

See Also
+

ConnectivityManager.getActiveNetworkInfo

+

MOBILE

+

WiseFyConnection.isNetworkConnectedAndMatchesType

+

WiseFyPrechecks.isDeviceConnectedToMobileNetworkChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-mobile-or-wifi-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-mobile-or-wifi-network.html new file mode 100644 index 00000000..a6a9f06d --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-mobile-or-wifi-network.html @@ -0,0 +1,26 @@ + + + +WiseFy.isDeviceConnectedToMobileOrWifiNetwork - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isDeviceConnectedToMobileOrWifiNetwork
+
+

isDeviceConnectedToMobileOrWifiNetwork

+ +@Sync @CallingThread fun isDeviceConnectedToMobileOrWifiNetwork(): Boolean +

To check if the device is connected to a mobile or wifi network.

+

Return
+bool - If the device is currently connected to a mobile or wifi network

+

See Also
+

ConnectivityManager.getActiveNetworkInfo

+

WiseFyConnection.isNetworkConnected

+

WiseFyPrechecks.isDeviceConnectedToMobileOrWifiNetworkChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-s-s-i-d.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-s-s-i-d.html new file mode 100644 index 00000000..ea8a6e55 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-s-s-i-d.html @@ -0,0 +1,28 @@ + + + +WiseFy.isDeviceConnectedToSSID - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isDeviceConnectedToSSID
+
+

isDeviceConnectedToSSID

+ +@Sync @CallingThread fun isDeviceConnectedToSSID(ssid: String?): Boolean +

To check if the device is connected to a given SSID.

+

Parameters

+

+ssid - The SSID to check if the device is attached to

+

Return
+bool - If the device is currently attached to the given SSID

+

See Also
+

WiseFyConnection.isCurrentNetworkConnectedToSSID

+

WiseFyPrechecks.isDeviceConnectedToSSIDChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-wifi-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-wifi-network.html new file mode 100644 index 00000000..8e094daa --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-connected-to-wifi-network.html @@ -0,0 +1,27 @@ + + + +WiseFy.isDeviceConnectedToWifiNetwork - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isDeviceConnectedToWifiNetwork
+
+

isDeviceConnectedToWifiNetwork

+ +@Sync @CallingThread fun isDeviceConnectedToWifiNetwork(): Boolean +

To check if the device is connected to a wifi network.

+

Return
+bool - If the device is currently connected to a wifi network

+

See Also
+

ConnectivityManager.getActiveNetworkInfo

+

WIFI

+

WiseFyConnection.isNetworkConnectedAndMatchesType

+

WiseFyPrechecks.isDeviceConnectedToWifiNetworkChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-roaming.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-roaming.html new file mode 100644 index 00000000..7b31a4b7 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-device-roaming.html @@ -0,0 +1,26 @@ + + + +WiseFy.isDeviceRoaming - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isDeviceRoaming
+
+

isDeviceRoaming

+ +@Sync @CallingThread fun isDeviceRoaming(): Boolean +

To query if the device is roaming.

+

Return
+boolean - If the current network is roaming

+

See Also
+

ConnectivityManager.getActiveNetworkInfo

+

NetworkInfo.isRoaming

+

WiseFyPrechecks.isDeviceRoamingChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-logging-enabled.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-logging-enabled.html new file mode 100644 index 00000000..25f9bada --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-logging-enabled.html @@ -0,0 +1,24 @@ + + + +WiseFy.isLoggingEnabled - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isLoggingEnabled
+
+

isLoggingEnabled

+ +@Sync @CallingThread fun isLoggingEnabled(): Boolean +

To query if logging is enabled or disabled for a WiseFy instance.

+

Return
+boolean - If logging is enabled for the WiseFy instance

+

See Also
+

WiseFyLogger.isLoggingEnabled

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-e-a-p.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-e-a-p.html new file mode 100644 index 00000000..2adeae28 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-e-a-p.html @@ -0,0 +1,29 @@ + + + +WiseFy.isNetworkEAP - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isNetworkEAP
+
+

isNetworkEAP

+ +@Sync @CallingThread fun isNetworkEAP(scanResult: ScanResult?): Boolean +

To check and return if a network is a EAP network.

+

Parameters

+

+scanResult - The network to check

+

Return
+boolean - Whether the network has EAP capabilities listed

+

See Also
+

containsCapability

+

ScanResult

+

EAP

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-p-s-k.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-p-s-k.html new file mode 100644 index 00000000..1c3159e6 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-p-s-k.html @@ -0,0 +1,29 @@ + + + +WiseFy.isNetworkPSK - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isNetworkPSK
+
+

isNetworkPSK

+ +@Sync @CallingThread fun isNetworkPSK(scanResult: ScanResult?): Boolean +

To check and return if a network is a PSK network.

+

Parameters

+

+scanResult - The network to check

+

Return
+boolean - Whether the network has PSK capabilities listed

+

See Also
+

containsCapability

+

ScanResult

+

PSK

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-saved.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-saved.html new file mode 100644 index 00000000..a35bcf0d --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-saved.html @@ -0,0 +1,28 @@ + + + +WiseFy.isNetworkSaved - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isNetworkSaved
+
+

isNetworkSaved

+ +@Sync @CallingThread fun isNetworkSaved(ssid: String?): Boolean +

To check if an SSID is in the list of configured networks.

+

Parameters

+

+ssid - The SSID to check and see if it's in the list of configured networks

+

Return
+boolean - If the SSID is in the list of configured networks

+

See Also
+

WiseFyPrechecks.isNetworkSavedChecks

+

WiseFySearch.isNetworkASavedConfiguration

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-secure.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-secure.html new file mode 100644 index 00000000..a2b11d1e --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-secure.html @@ -0,0 +1,32 @@ + + + +WiseFy.isNetworkSecure - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isNetworkSecure
+
+

isNetworkSecure

+ +@Sync @CallingThread fun isNetworkSecure(scanResult: ScanResult?): Boolean +

To check and return if a network is secure (contains EAP/PSK/WEP/WPA/WPA2 capabilities).

+

Parameters

+

+scanResult - The network to see if it is secure

+

Return
+boolean - Whether the network is secure

+

See Also
+

ScanResult.capabilities

+

EAP

+

PSK

+

WEP

+

WPA

+

WPA2

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-e-p.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-e-p.html new file mode 100644 index 00000000..02764f15 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-e-p.html @@ -0,0 +1,29 @@ + + + +WiseFy.isNetworkWEP - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isNetworkWEP
+
+

isNetworkWEP

+ +@Sync @CallingThread fun isNetworkWEP(scanResult: ScanResult?): Boolean +

To check and return if a network is a WEP network.

+

Parameters

+

+scanResult - The network to check

+

Return
+boolean - Whether the network has WEP capabilities listed

+

See Also
+

containsCapability

+

ScanResult

+

WEP

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-p-a.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-p-a.html new file mode 100644 index 00000000..96a0a6a0 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-p-a.html @@ -0,0 +1,29 @@ + + + +WiseFy.isNetworkWPA - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isNetworkWPA
+
+

isNetworkWPA

+ +@Sync @CallingThread fun isNetworkWPA(scanResult: ScanResult?): Boolean +

To check and return if a network is a WPA network.

+

Parameters

+

+scanResult - The network to check

+

Return
+boolean - Whether the network has WPA capabilities listed

+

See Also
+

containsCapability

+

ScanResult

+

WPA

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-p-a2.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-p-a2.html new file mode 100644 index 00000000..971b58c0 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network-w-p-a2.html @@ -0,0 +1,29 @@ + + + +WiseFy.isNetworkWPA2 - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isNetworkWPA2
+
+

isNetworkWPA2

+ +@Sync @CallingThread fun isNetworkWPA2(scanResult: ScanResult?): Boolean +

To check and return if a network is a WPA2 network.

+

Parameters

+

+scanResult - The network to check

+

Return
+boolean - Whether the network has WPA2 capabilities listed

+

See Also
+

containsCapability

+

ScanResult

+

WPA2

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network5g-hz.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network5g-hz.html new file mode 100644 index 00000000..fb774a8d --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-network5g-hz.html @@ -0,0 +1,47 @@ + + + +WiseFy.isNetwork5gHz - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isNetwork5gHz
+
+

isNetwork5gHz

+ +@Sync @CallingThread fun isNetwork5gHz(): Boolean +

To check if the device's current network is 5gHz.

+

Exceptions

+

+SecurityException - Without necessary permissions granted

+

Return
+boolean - If the network is 5gHz

+

See Also
+

getFrequency

+

MAX_FREQUENCY_5GHZ

+

MIN_FREQUENCY_5GHZ

+

+

Author
+Patches

+

Since
+3.0

+ +@Sync @CallingThread fun isNetwork5gHz(network: WifiInfo?): Boolean +

To check if a given network is 5gHz.

+

Parameters

+

+network - The network to check if it's 5gHz

+

Return
+boolean - If the network is 5gHz

+

See Also
+

getFrequency

+

MAX_FREQUENCY_5GHZ

+

MIN_FREQUENCY_5GHZ

+

WifiInfo

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-wifi-enabled.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-wifi-enabled.html new file mode 100644 index 00000000..64ce0d1e --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/is-wifi-enabled.html @@ -0,0 +1,25 @@ + + + +WiseFy.isWifiEnabled - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / isWifiEnabled
+
+

isWifiEnabled

+ +@Sync @CallingThread fun isWifiEnabled(): Boolean +

To check if Wifi is enabled on the device or not.

+

Return
+boolean - if Wifi is enabled on device

+

See Also
+

WifiManager.isWifiEnabled

+

WiseFyPrechecks.isWifiEnabledChecks

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/remove-network.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/remove-network.html new file mode 100644 index 00000000..b11e1130 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/remove-network.html @@ -0,0 +1,53 @@ + + + +WiseFy.removeNetwork - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / removeNetwork
+
+

removeNetwork

+ +@Sync @CallingThread fun removeNetwork(ssidToRemove: String?): Boolean +

To remove a configured network.

+

Parameters

+

+ssidToRemove - The ssid of the network you want to remove from the configured network list

+

Return
+boolean - If the command succeeded in removing the network

+

See Also
+

removeNetworkConfiguration

+

WifiConfiguration

+

WiseFyPrechecks.removeNetworkCheck

+

+

Sse
+WiseFySearch.findSavedNetworkByRegex

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun removeNetwork(ssidToRemove: String?, callbacks: RemoveNetworkCallbacks?): Unit +

To remove a configured network.

+

Parameters

+

+ssidToRemove - The ssid of the network you want to remove from the configured network list

+

+callbacks - The listener to return results to

+

See Also
+

RemoveNetworkCallbacks

+

removeNetworkConfiguration

+

runOnWiseFyThread

+

WifiConfiguration

+

WiseFyLock

+

WiseFyPrechecks.removeNetworkCheck

+

+

Sse
+WiseFySearch.findSavedNetworkByRegex

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-access-point.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-access-point.html new file mode 100644 index 00000000..d89c7041 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-access-point.html @@ -0,0 +1,59 @@ + + + +WiseFy.searchForAccessPoint - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / searchForAccessPoint
+
+

searchForAccessPoint

+ +@Sync @CallingThread fun searchForAccessPoint(regexForSSID: String?, timeoutInMillis: Int, filterDuplicates: Boolean): ScanResult? +

To return the first access point that matches a given regex.

+

NOTE Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest).

+

Parameters

+

+regexForSSID - The regex to use when iterating through nearby access points

+

+timeoutInMillis - The amount of time (in milliseconds) to wait for a matching access point

+

+filterDuplicates - If you want to exclude access points with the same name that have a weaker signal strength

+

Return
+ScanResult|null - The first access point or access point with the highest signal strength matching the regex

+

See Also
+

ScanResult

+

WiseFyPrechecks.searchForAccessPointChecks

+

WiseFySearch.findAccessPointByRegex

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun searchForAccessPoint(regexForSSID: String?, timeoutInMillis: Int, filterDuplicates: Boolean, callbacks: SearchForAccessPointCallbacks?): Unit +

To return the first access point that matches a given regex.

+

NOTE Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest).

+

Parameters

+

+regexForSSID - The regex to use when iterating through nearby access points

+

+timeoutInMillis - The amount of time (in milliseconds) to wait for a matching access point

+

+filterDuplicates - If you want to exclude access points with the same name that have a weaker signal strength

+

+callbacks - The listener to return results to

+

See Also
+

runOnWiseFyThread

+

ScanResult

+

SearchForAccessPointCallbacks

+

WiseFyLock

+

WiseFyPrechecks.searchForAccessPointChecks

+

WiseFySearch.findAccessPointByRegex

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-access-points.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-access-points.html new file mode 100644 index 00000000..7d168310 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-access-points.html @@ -0,0 +1,55 @@ + + + +WiseFy.searchForAccessPoints - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / searchForAccessPoints
+
+

searchForAccessPoints

+ +@Sync @CallingThread fun searchForAccessPoints(regexForSSID: String?, filterDuplicates: Boolean): List<ScanResult>? +

To return nearby access points that match a given regex.

+

NOTE Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest).

+

Parameters

+

+regexForSSID - The regex to use when iterating through nearby access points

+

+filterDuplicates - If you want to exclude access points with the same name that have a weaker signal strength

+

Return
+List of ScanResult|null - The list of matching access points or null if none match the given regex

+

See Also
+

ScanResult

+

WiseFyPrechecks.searchForAccessPointsChecks

+

WiseFySearch.findAccessPointsMatchingRegex

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun searchForAccessPoints(regexForSSID: String?, filterDuplicates: Boolean, callbacks: SearchForAccessPointsCallbacks?): Unit +

To return nearby access points that match a given regex.

+

NOTE Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest).

+

Parameters

+

+regexForSSID - The regex to use when iterating through nearby access points

+

+filterDuplicates - If you want to exclude access points with the same name that have a weaker signal strength

+

+callbacks - The listener to return results to

+

See Also
+

runOnWiseFyThread

+

ScanResult

+

SearchForAccessPointsCallbacks

+

WiseFyLock

+

WiseFyPrechecks.searchForAccessPointsChecks

+

WiseFySearch.findAccessPointsMatchingRegex

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-s-s-i-d.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-s-s-i-d.html new file mode 100644 index 00000000..dcbf29d9 --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-s-s-i-d.html @@ -0,0 +1,53 @@ + + + +WiseFy.searchForSSID - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / searchForSSID
+
+

searchForSSID

+ +@Sync @CallingThread @WaitsForTimeout fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int): String? +

To search local networks and return the first one that contains a given ssid.

+

Parameters

+

+regexForSSID - The regex to be used to search for the ssid

+

+timeoutInMillis - The number of milliseconds to keep searching for the SSID

+

Return
+String|null - The first SSID that contains the search ssid (if any, else null)

+

See Also
+

ScanResult.SSID

+

WiseFyPrechecks.searchForSSIDChecks

+

WiseFySearch.findAccessPointByRegex

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread @WaitsForTimeout fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int, callbacks: SearchForSSIDCallbacks?): Unit +

To search local networks and return the first one that contains a given ssid.

+

Parameters

+

+regexForSSID - The regex to be used to search for the ssid

+

+timeoutInMillis - The number of milliseconds to keep searching for the SSID

+

+callbacks - The listener to return results to

+

See Also
+

runOnWiseFyThread

+

ScanResult.SSID

+

SearchForSSIDCallbacks

+

WiseFyLock

+

WiseFyPrechecks.searchForSSIDChecks

+

WiseFySearch.findAccessPointByRegex

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-s-s-i-ds.html b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-s-s-i-ds.html new file mode 100644 index 00000000..be2f882f --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/-wise-fy/search-for-s-s-i-ds.html @@ -0,0 +1,47 @@ + + + +WiseFy.searchForSSIDs - wisefy + + + +wisefy / com.isupatches.wisefy / WiseFy / searchForSSIDs
+
+

searchForSSIDs

+ +@Sync @CallingThread fun searchForSSIDs(regexForSSID: String?): List<String>? +

To search local networks and return the first one that contains a given ssid.

+

Parameters

+

+regexForSSID - The regex to be used to search for the ssid

+

Return
+String|null - The first SSID that contains the search ssid (if any, else null)

+

See Also
+

WiseFyPrechecks.searchForSSIDsChecks

+

WiseFySearch.findSSIDsMatchingRegex

+

+

Author
+Patches

+

Since
+3.0

+ +@Async @WiseFyThread fun searchForSSIDs(regexForSSID: String?, callbacks: SearchForSSIDsCallbacks?): Unit +

To search local networks and return the first one that contains a given ssid.

+

Parameters

+

+regexForSSID - The regex to be used to search for the ssid

+

+callbacks - The listener to return results to

+

See Also
+

runOnWiseFyThread

+

SearchForSSIDsCallbacks

+

WiseFyLock

+

WiseFyPrechecks.searchForSSIDsChecks

+

WiseFySearch.findSSIDsMatchingRegex

+

+

Author
+Patches

+

Since
+3.0

+ + diff --git a/javadoc/wisefy/com.isupatches.wisefy/index.html b/javadoc/wisefy/com.isupatches.wisefy/index.html new file mode 100644 index 00000000..093b49fc --- /dev/null +++ b/javadoc/wisefy/com.isupatches.wisefy/index.html @@ -0,0 +1,36 @@ + + + +com.isupatches.wisefy - wisefy + + + +wisefy / com.isupatches.wisefy
+
+

Package com.isupatches.wisefy

+

Types

+ + + + + + + + + + + +
+

WiseFy

+
+class WiseFy : WiseFyPublicApi +

Main class for WiseFy that provides a synchronous and asynchronous API to manipulate and query +for different parts of a device's wifi configuration and status.

+
+

WiseFyLock

+
+class WiseFyLock +

A class used to synchronize logic.

+
+ + diff --git a/javadoc/wisefy/index-outline.html b/javadoc/wisefy/index-outline.html new file mode 100644 index 00000000..06a43201 --- /dev/null +++ b/javadoc/wisefy/index-outline.html @@ -0,0 +1,913 @@ + + + +Module Contents + + + +wisefy
+ + + diff --git a/javadoc/wisefy/index.html b/javadoc/wisefy/index.html new file mode 100644 index 00000000..ab841700 --- /dev/null +++ b/javadoc/wisefy/index.html @@ -0,0 +1,46 @@ + + + +wisefy + + + +wisefy
+
+

Packages

+ + + + + + + + + + + + + + + + + + + +
+

com.isupatches.wisefy

+
+
+

com.isupatches.wisefy.callbacks

+
+
+

com.isupatches.wisefy.constants

+
+
+

com.isupatches.wisefy.threads

+
+
+

Index

+All Types + + diff --git a/javadoc/package-list b/javadoc/wisefy/package-list similarity index 65% rename from javadoc/package-list rename to javadoc/wisefy/package-list index 6b1deb8f..e0eb76c5 100644 --- a/javadoc/package-list +++ b/javadoc/wisefy/package-list @@ -1,6 +1,7 @@ +$dokka.format:html +$dokka.linkExtension:html + com.isupatches.wisefy -com.isupatches.wisefy.annotations com.isupatches.wisefy.callbacks com.isupatches.wisefy.constants com.isupatches.wisefy.threads -com.isupatches.wisefy.util diff --git a/wisefy/build.gradle b/wisefy/build.gradle index 341dd890..aaeb3841 100644 --- a/wisefy/build.gradle +++ b/wisefy/build.gradle @@ -1,71 +1,106 @@ apply plugin: 'com.android.library' -apply plugin: 'com.getkeepsafe.dexcount' +apply plugin: 'kotlin-android' group = rootProject.ext.GROUP version = rootProject.ext.VERSION_NAME -dexcount { - format = "tree" - includeClasses = true - includeFieldCount = true - includeTotalMethodCount = true - orderByMethodCount = true - verbose = false -} - android { dexOptions { // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false. preDexLibraries = preDexEnabled && !travisBuild + javaMaxHeapSize "2g" } adbOptions { timeOutInMs 15 * 60 * 1000 // 15 minutes - installOptions "-d","-t" + installOptions "-d", "-t" } - compileSdkVersion 26 - buildToolsVersion "26.0.0" + lintOptions { + checkAllWarnings true + warningsAsErrors true + showAll true + explainIssues true + abortOnError true + enable 'AppLinksAutoVerifyError', 'AppLinksAutoVerifyWarning', 'BackButton', + 'EasterEgg', 'FieldGetter', 'GoogleAppIndexingApiWarning', 'IconExpectedSize', + 'LogConditional', 'MangledCRLF', 'NegativeMargin', 'NewerVersionAvailable', + 'SelectableText', 'StopShip', 'TrulyRandom', 'TypographyQuotes', 'UnusedIds' + } + + compileSdkVersion rootProject.ext.MAX_SDK_VERSION + buildToolsVersion rootProject.ext.BUILD_TOOLS_VERSION defaultConfig { - minSdkVersion 16 - targetSdkVersion 26 - versionCode 12 - versionName version + minSdkVersion rootProject.ext.MIN_SDK_VERSION + targetSdkVersion rootProject.ext.MAX_SDK_VERSION + versionCode rootProject.ext.VERSION_CODE + versionName rootProject.ext.VERSION_NAME testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' + consumerProguardFiles 'consumer-proguard-rules.pro' + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { testCoverageEnabled true minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' - testProguardFile file("proguard-test-rules.txt") + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + testProguardFile file("proguard-test-rules.pro") } release { minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + sourceSets { + main { + jni.srcDirs = [] //disable automatic ndk-build call + } + + test { + java.srcDirs += 'src/commonTest/java' + } + + androidTest { + java.srcDirs += 'src/commonTest/java' } } } +ext { + espresso_version = '3.0.2' + junit_version = '4.12' + mockito_version = '2.21.0' + support_libs_version = '27.1.1' + test_runner_version = '1.0.2' +} + dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "com.android.support:support-annotations:$support_libs_version" - androidTestCompile 'com.android.support:support-annotations:26.0.0-alpha1' - androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' - androidTestCompile 'org.mockito:mockito-android:2.8.47' - androidTestCompile 'com.android.support.test:runner:0.5' + // Kotlin + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + + androidTestImplementation "com.android.support.test.espresso:espresso-core:$espresso_version" + androidTestImplementation "org.mockito:mockito-core:$mockito_version" + androidTestImplementation "org.mockito:mockito-android:$mockito_version" + androidTestImplementation "com.android.support.test:runner:$test_runner_version" // For issue #55 / IllegalAccessError conflict test - androidTestCompile 'com.google.android.gms:play-services-gcm:8.3.0' + //noinspection GradleDependency + androidTestImplementation 'com.google.android.gms:play-services-gcm:8.3.0' - testCompile 'org.mockito:mockito-core:2.8.47' - testCompile 'junit:junit:4.12' + testImplementation "org.mockito:mockito-core:$mockito_version" + testImplementation "junit:junit:$junit_version" } - -apply from: rootProject.file('gradle/gradle-bintray-install.gradle') -apply from: rootProject.file('gradle/gradle-bintray-upload.gradle') -apply from: rootProject.file('gradle/jacoco.gradle') \ No newline at end of file +apply from: rootProject.file("$rootProject.projectDir/gradle/gradle-bintray-install.gradle") +apply from: rootProject.file("$rootProject.projectDir/gradle/gradle-bintray-upload.gradle") diff --git a/wisefy/config/checkstyle/checkstyle-suppressions.xml b/wisefy/config/checkstyle/checkstyle-suppressions.xml new file mode 100644 index 00000000..01de030c --- /dev/null +++ b/wisefy/config/checkstyle/checkstyle-suppressions.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/wisefy/config/checkstyle/checkstyle.xml b/wisefy/config/checkstyle/checkstyle.xml new file mode 100644 index 00000000..b84ab4d6 --- /dev/null +++ b/wisefy/config/checkstyle/checkstyle.xml @@ -0,0 +1,421 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wisefy/config/findbugs/findbugs-suppressions.xml b/wisefy/config/findbugs/findbugs-suppressions.xml new file mode 100644 index 00000000..d73f9f9a --- /dev/null +++ b/wisefy/config/findbugs/findbugs-suppressions.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/wisefy/consumer-proguard-rules.pro b/wisefy/consumer-proguard-rules.pro new file mode 100644 index 00000000..767b91ab --- /dev/null +++ b/wisefy/consumer-proguard-rules.pro @@ -0,0 +1,6 @@ +-verbose + +-dontobfuscate + +-keep class com.isupatches.wisefy.** { *; } +-keep public interface com.isupatches.wisefy.** { *; } \ No newline at end of file diff --git a/wisefy/proguard-rules.pro b/wisefy/proguard-rules.pro new file mode 100644 index 00000000..e0e5379e --- /dev/null +++ b/wisefy/proguard-rules.pro @@ -0,0 +1,9 @@ +-verbose + +-dontobfuscate +#-keepattributes SourceFile, LineNumberTable # For stacktraces +#-keepattributes LocalVariableTable, LocalVariableTypeTable # For debugging +#-keepattributes MethodParameters + +-keep class com.isupatches.wisefy.** { *; } +-keep public interface com.isupatches.wisefy.** { *; } \ No newline at end of file diff --git a/wisefy/proguard-rules.txt b/wisefy/proguard-rules.txt deleted file mode 100644 index 163e5472..00000000 --- a/wisefy/proguard-rules.txt +++ /dev/null @@ -1,17 +0,0 @@ --keepattributes SourceFile, LineNumberTable --keepattributes ** --keepattributes *Annotation* --keepattributes Signature --keepattributes Exceptions - --dontobfuscate --dontpreverify --dontoptimize - --dontskipnonpubliclibraryclassmembers --dontskipnonpubliclibraryclasses --useuniqueclassmembernames - --verbose - --keep class com.isupatches.** { *; } \ No newline at end of file diff --git a/wisefy/proguard-test-rules.pro b/wisefy/proguard-test-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java deleted file mode 100644 index f176decd..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddOpenNetworkTests.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.OPEN_NETWORK_SSID; -import static junit.framework.Assert.assertEquals; -import static org.junit.Assert.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class AddOpenNetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_failure_nullSSIDParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addOpenNetwork(null)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureAddingOpenNetwork(WiseFy.WIFI_MANAGER_FAILURE); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - try { - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_nullSSIDParam() { - AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); - mWiseFy.addOpenNetwork(null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.addOpenNetwork(null, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).openNetworkAdded(any(WifiConfiguration.class)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_success_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - try { - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - AddOpenNetworkCallbacks mockCallbacks = mock(AddOpenNetworkCallbacks.class); - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addOpenNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_success_alreadyConfigured_nullCallback() { - networkAlreadyInConfigurationList(); - try { - mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } -} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java deleted file mode 100644 index 5679f6e0..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWEPNetworkTests.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class AddWEPNetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_failure_nullPasswordParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_failure_nullSSIDParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureAddingWEPNetwork(WiseFy.WIFI_MANAGER_FAILURE); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_nullPasswordParam() { - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure_nullPasswordParam_nullCallback() { - try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_nullSSIDParam() { - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wepNetworkAdded(any(WifiConfiguration.class)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_success_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class); - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_success_alreadyConfigured_nullCallback() { - networkAlreadyInConfigurationList(); - try { - mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java deleted file mode 100644 index 1ead568e..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/AddWPA2NetworkTests.java +++ /dev/null @@ -1,176 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.*; -import static junit.framework.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class AddWPA2NetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_failure_nullPasswordParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_failure_nullSSIDParam() { - assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void sync_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureAddingWPA2Network(WiseFy.WIFI_MANAGER_FAILURE); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_nullPasswordParam() { - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure_nullPasswordParam_nullCallback() { - try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch(NullPointerException npe){ - fail(); - } - } - - @Test - public void async_failure_nullSSIDParam() { - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void async_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wpa2NetworkAdded(any(WifiConfiguration.class)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_success_nullCallback() { - when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); - try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_alreadyConfigured() { - networkAlreadyInConfigurationList(); - AddWPA2NetworkCallbacks mockCallbacks = mock(AddWPA2NetworkCallbacks.class); - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addWPA2NetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } - - @Test - public void async_success_alreadyConfigured_nullCallback() { - networkAlreadyInConfigurationList(); - try { - mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration.class)); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.java deleted file mode 100644 index f1a66701..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.ConnectivityManager; -import android.net.wifi.WifiManager; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -@RunWith(AndroidJUnit4.class) -public abstract class BaseAndroidJUnit4TestClass { - - ConnectivityManager mMockConnectivityManager; - - protected WifiManager mMockWiFiManager; - - protected WiseFy mWiseFy; - - protected static final Integer VERIFICATION_SUCCESS_TIMEOUT = 5000; - - static final Integer VERIFICATION_FAILURE_TIMEOUT = 3000; - - @Before - public void setUp() { - mMockWiFiManager = mock(WifiManager.class); - mMockConnectivityManager = mock(ConnectivityManager.class); - - mMockWiFiManager = mock(WifiManager.class); - mMockConnectivityManager = mock(ConnectivityManager.class); - - mWiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(true).getSmarts(); - setManagers(); - } - - @After - public void tearDown() { - mWiseFy.dump(); - } - - /** - * HELPERS - */ - - public void missingPrerequisite() { - WiseFyPrerequisites mockPrereqs = mock(WiseFyPrerequisites.class); - mWiseFy.mWiseFyPrerequisites = mockPrereqs; - when(mockPrereqs.hasPrerequisites()).thenReturn(false); - } - - void networkAlreadyInConfigurationList() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.isNetworkASavedConfiguration(anyString())).thenReturn(true); - } - - private void setManagers() { - WiseFyPrerequisites mockPrereqs = mock(WiseFyPrerequisites.class); - mWiseFy.mWiseFyPrerequisites = mockPrereqs; - mWiseFy.mWiseFySearch.mWiseFyPrerequisites = mockPrereqs; - when(mockPrereqs.hasPrerequisites()).thenReturn(true); - when(mockPrereqs.getWifiManager()).thenReturn(mMockWiFiManager); - when(mockPrereqs.getConnectivityManager()).thenReturn(mMockConnectivityManager); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.kt new file mode 100644 index 00000000..4b0a21f7 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/BaseAndroidJUnit4TestClass.kt @@ -0,0 +1,82 @@ +package com.isupatches.wisefy + +import android.net.ConnectivityManager +import android.net.wifi.WifiManager +import android.os.Build +import android.support.test.InstrumentationRegistry +import org.junit.After +import org.mockito.Mockito +import org.mockito.Mockito.mock + +/** + * A common test class to extend. + * + * @author Patches + */ +internal open class BaseAndroidJUnit4TestClass { + + protected val wiseFy: WiseFy + protected val mockWiseFySearch: WiseFySearch + + protected val mockConnectivityManager: ConnectivityManager + protected val mockWifiManager: WifiManager + + protected val mockNetworkUtil: MockNetworkUtil + protected val mockWiseFyConnectionUtil: MockWiseFyConnectionUtil + protected val mockWiseFyPrechecksUtil: MockWiseFyPrechecksUtil + protected val mockWiseFySearchUtil: MockWiseFySearchUtil + + protected val nullCallbackUtil: NullCallbackUtil + + protected val verificationUtil: VerificationUtil + + /** + * Constructor. + */ + init { + val mockWiseFyConnection = mock(WiseFyConnection::class.java) + val mockWiseFyPrechecks = mock(WiseFyPrechecks::class.java) + mockWiseFySearch = mock(WiseFySearch::class.java) + + mockWifiManager = mock(WifiManager::class.java) + mockConnectivityManager = mock(ConnectivityManager::class.java) + + wiseFy = WiseFy.Brains(InstrumentationRegistry.getTargetContext()) + .customConnectivityManager(mockConnectivityManager) + .customWifiManager(mockWifiManager) + .customWiseFyConnection(mockWiseFyConnection) + .customWiseFyPrechecks(mockWiseFyPrechecks) + .customWiseFySearch(mockWiseFySearch) + .logging(true) + .getSmarts() + + mockNetworkUtil = MockNetworkUtil(mockConnectivityManager, mockWifiManager) + + mockWiseFyConnectionUtil = MockWiseFyConnectionUtil(mockWiseFyConnection) + mockWiseFyPrechecksUtil = MockWiseFyPrechecksUtil(mockWiseFyPrechecks) + mockWiseFySearchUtil = MockWiseFySearchUtil(mockWiseFySearch) + + nullCallbackUtil = NullCallbackUtil(wiseFy) + + verificationUtil = VerificationUtil(mockConnectivityManager, mockWifiManager) + } + + @After fun tearDown() { + wiseFy.dump() + } + + /* + * HELPERS + */ + + /** + * Checks to see if the device has Lollipop or higher. + * + * @return boolean - True if device is at least Lollipop + * + * @see Build.VERSION_CODES + */ + protected fun preLollipop(): Boolean = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP + + protected fun any(type: Class): T = Mockito.any(type) +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java deleted file mode 100644 index 4bb85567..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/ConnectToNetworkTests.java +++ /dev/null @@ -1,218 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_TIMEOUT; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class ConnectToNetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure_nullSSIDParam() { - assertEquals(false, mWiseFy.connectToNetwork(null, TEST_TIMEOUT)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void sync_failure_missingPrerequisites() { - missingPrerequisite(); - assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void sync_failure_noSavedNetwork() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void sync_failure() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); - - assertEquals(false, mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void sync_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); - - assertEquals(true, mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void async_failure_nullSSIDParam() { - ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); - mWiseFy.connectToNetwork(null, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void async_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.connectToNetwork(null, TEST_TIMEOUT, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).enableNetwork(anyInt(), anyBoolean()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisites() { - missingPrerequisite(); - ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); - mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void async_failure_missingPrerequisites_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).enableNetwork(anyInt(), anyBoolean()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_noSavedNetwork() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); - mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkNotFoundToConnectTo(); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void async_failure_noSavedNetwork_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - try { - mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).enableNetwork(anyInt(), anyBoolean()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); - - ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); - mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureConnectingToNetwork(); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void async_failure_nullCallback() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(false); - - try { - mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); - - ConnectToNetworkCallbacks mockCallbacks = mock(ConnectToNetworkCallbacks.class); - mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).connectedToNetwork(); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); - } - - @Test - public void async_success_nullCallback() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(true); - - try { - mWiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()); - } catch (NullPointerException npe) { - fail(); - } - } -} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java deleted file mode 100644 index a26f31eb..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisableWifiTests.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.callbacks.DisableWifiCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class DisableWifiTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - assertEquals(false, mWiseFy.disableWifi()); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(false); - } - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(false, mWiseFy.disableWifi()); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).setWifiEnabled(false); - } - - @Test - public void sync_success() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - assertEquals(true, mWiseFy.disableWifi()); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(false); - } - - @Test - public void async_failure() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); - mWiseFy.disableWifi(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(false); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureDisablingWifi(); - } - - @Test - public void async_failure_nullCallback() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - try { - mWiseFy.disableWifi(null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(false); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); - mWiseFy.disableWifi(mockCallbacks); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).setWifiEnabled(false); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.disableWifi(null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).setWifiEnabled(false); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - DisableWifiCallbacks mockCallbacks = mock(DisableWifiCallbacks.class); - mWiseFy.disableWifi(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(false); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wifiDisabled(); - } - - @Test - public void async_success_nullCallback() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - try { - mWiseFy.disableWifi(null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(false); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java deleted file mode 100644 index 5a3eff39..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/DisconnectFromCurrentNetworkTests.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class DisconnectFromCurrentNetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure() { - when(mMockWiFiManager.disconnect()).thenReturn(false); - assertEquals(false, mWiseFy.disconnectFromCurrentNetwork()); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disconnect(); - } - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(false, mWiseFy.disconnectFromCurrentNetwork()); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).disconnect(); - } - - @Test - public void sync_success() { - when(mMockWiFiManager.disconnect()).thenReturn(true); - assertEquals(true, mWiseFy.disconnectFromCurrentNetwork()); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disconnect(); - } - - @Test - public void async_failure() { - when(mMockWiFiManager.disconnect()).thenReturn(false); - DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); - mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disconnect(); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureDisconnectingFromCurrentNetwork(); - } - - @Test - public void async_failure_nullCallback() { - when(mMockWiFiManager.disconnect()).thenReturn(false); - try { - mWiseFy.disconnectFromCurrentNetwork(null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disconnect(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); - mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).disconnect(); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disconnectFromCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.disconnectFromCurrentNetwork(null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).disconnect(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - when(mMockWiFiManager.disconnect()).thenReturn(true); - DisconnectFromCurrentNetworkCallbacks mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks.class); - mWiseFy.disconnectFromCurrentNetwork(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disconnect(); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disconnectedFromCurrentNetwork(); - } - - @Test - public void async_success_nullCallback() { - when(mMockWiFiManager.disconnect()).thenReturn(true); - try { - mWiseFy.disconnectFromCurrentNetwork(null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disconnect(); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java deleted file mode 100644 index 01916d1e..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/EnableWifiTests.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.callbacks.EnableWifiCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class EnableWifiTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - assertEquals(false, mWiseFy.enableWifi()); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(true); - } - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(false, mWiseFy.enableWifi()); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).setWifiEnabled(true); - } - - @Test - public void sync_success() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - assertEquals(true, mWiseFy.enableWifi()); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(true); - } - - @Test - public void async_failure() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); - mWiseFy.enableWifi(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(true); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureEnablingWifi(); - } - - @Test - public void async_failure_nullCallback() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - try { - mWiseFy.enableWifi(null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(true); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); - mWiseFy.enableWifi(mockCallbacks); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).setWifiEnabled(true); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).enableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.enableWifi(null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).setWifiEnabled(true); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - EnableWifiCallbacks mockCallbacks = mock(EnableWifiCallbacks.class); - mWiseFy.enableWifi(mockCallbacks); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(true); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wifiEnabled(); - } - - @Test - public void async_success_nullCallback() { - when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - try { - mWiseFy.enableWifi(null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).setWifiEnabled(true); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GeneratorUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/GeneratorUtil.kt new file mode 100644 index 00000000..a2c59e2f --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/GeneratorUtil.kt @@ -0,0 +1,88 @@ +package com.isupatches.wisefy + +import android.net.wifi.ScanResult +import android.net.wifi.WifiConfiguration +import org.mockito.Mockito.mock +import java.util.ArrayList + +/** + * Creates a mock of a nearby access point for tests with specified security capabilities. + * + * @param capabilities The security attributes you want the access point to have + * + * @return ScanResult - A mock access point with the given capabilities + * + * @see ScanResult + */ +internal fun createMockAccessPointWithCapabilities(capabilities: String?): ScanResult { + val scanResult = mock(ScanResult::class.java) + scanResult.capabilities = capabilities + return scanResult +} + +/** + * Mocks two nearby access points given ssids and rssi levels. + * + * @param ssid1 - SSID of access points 1 + * @param rssi1 - RSSI level of access point 1 + * @param ssid2 - SSID of access point 2 + * @param rssi2 - RSSI level of access point 2 + * + * @return List of ScanResults - The mocked access points + * + * @see ScanResult + */ +internal fun createMockAccessPointList(ssid1: String, rssi1: Int, + ssid2: String, rssi2: Int): List { + val accessPoints = ArrayList() + accessPoints.add(createMockAccessPointWithSSIDAndRSSI(ssid1, rssi1)) + accessPoints.add(createMockAccessPointWithSSIDAndRSSI(ssid2, rssi2)) + return accessPoints +} + +/** + * Creates a mock of a nearby access point for tests with a specified SSID. + * + * @param ssid Tne ssid for the access point + * + * @return ScanResult - A mock object representing a nearby access point + * + * @see ScanResult + */ +internal fun createMockAccessPointWithSSID(ssid: String?): ScanResult { + val scanResult = mock(ScanResult::class.java) + scanResult.SSID = ssid + return scanResult +} + +/** + * Creates a mock of a nearby access point. + * + * @param ssid Tne ssid for the access point + * @param rssi The rssi level for the access point + * + * @return ScanResult - A mock object representing a nearby access point + * + * @see ScanResult + */ +internal fun createMockAccessPointWithSSIDAndRSSI(ssid: String, rssi: Int): ScanResult { + val scanResult = mock(ScanResult::class.java) + scanResult.SSID = ssid + scanResult.level = rssi + return scanResult +} + +/** + * Creates a saved network configuration. + * + * @param ssid The ssid for the saved network + * + * @return WifiConfiguration - Saved network + * + * @see WifiConfiguration + */ +internal fun createSavedNetwork(ssid: String?): WifiConfiguration { + val wiFiConfiguration = WifiConfiguration() + wiFiConfiguration.SSID = ssid + return wiFiConfiguration +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java deleted file mode 100644 index bfd9d23c..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetCurrentNetworkTests.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiInfo; -import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetCurrentNetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getCurrentNetwork()); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConnectionInfo(); - } - - @Test - public void sync_success() { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(TEST_SSID, mWiseFy.getCurrentNetwork().getSSID()); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getConnectionInfo(); - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - GetCurrentNetworkCallbacks mockCallbacks = mock(GetCurrentNetworkCallbacks.class); - mWiseFy.getCurrentNetwork(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConnectionInfo(); - } - - @Test - public void async_failure_missingPrerequisite_nullCallbacks() { - missingPrerequisite(); - try { - mWiseFy.getCurrentNetwork(null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConnectionInfo(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - GetCurrentNetworkCallbacks mockCallbacks = mock(GetCurrentNetworkCallbacks.class); - mWiseFy.getCurrentNetwork(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedCurrentNetwork(mockWifiInfo); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getConnectionInfo(); - } - - @Test - public void async_success_nullCallback() { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - try { - mWiseFy.getCurrentNetwork(null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConnectionInfo(); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java deleted file mode 100644 index 2a9a0337..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetFrequencyTests.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiInfo; -import android.os.Build; -import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_24GHZ; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetFrequencyTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_getFrequency_currentNetwork_failure() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - assertEquals(null, mWiseFy.getFrequency()); - } - } - - @Test - public void sync_getFrequency_currentNetwork_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - assertEquals(TEST_NETWORK_FREQUENCY_24GHZ, (int) mWiseFy.getFrequency()); - verify(mockWifiInfo, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getFrequency(); - } - } - - @Test - public void async_getFrequency_currentNetwork_failure() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); - mWiseFy.getFrequency(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureGettingFrequency(); - } - } - - @Test - public void async_getFrequency_currentNetwork_failure_nullCallback() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - try { - mWiseFy.getFrequency((GetFrequencyCallbacks) null); - } catch (NullPointerException npe) { - fail(); - } - } - } - - @Test - public void async_getFrequency_currentNetwork_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); - mWiseFy.getFrequency(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ); - verify(mockWifiInfo, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getFrequency(); - } - } - - @Test - public void async_getFrequency_currentNetwork_success_nullCallback() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - try { - mWiseFy.getFrequency((GetFrequencyCallbacks) null); - } catch (NullPointerException npe) { - fail(); - } - } - } - - @Test - public void sync_getFrequency_provideWifiInfo_failure() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - assertEquals(null, mWiseFy.getFrequency((WifiInfo) null)); - } - } - - @Test - public void sync_getFrequency_provideWifiInfo_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - assertEquals(TEST_NETWORK_FREQUENCY_24GHZ, (int) mWiseFy.getFrequency(mockWifiInfo)); - } - } - - @Test - public void async_getFrequency_provideWifiInfo_failure() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); - mWiseFy.getFrequency(null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getFrequencyWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - } - - @Test - public void async_getFrequency_provideWifiInfo_failure_nullCallback() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - try { - mWiseFy.getFrequency(null, null); - } catch (NullPointerException npe) { - fail(); - } - } - } - - @Test - public void async_getFrequency_provideWifiInfo_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - GetFrequencyCallbacks mockCallbacks = mock(GetFrequencyCallbacks.class); - mWiseFy.getFrequency(mockWifiInfo, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ); - } - } - - @Test - public void async_getFrequency_provideWifiInfo_success_nullCallback() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_24GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - try { - mWiseFy.getFrequency(mockWifiInfo, null); - } catch (NullPointerException npe) { - fail(); - } - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java deleted file mode 100644 index 854dc88f..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetNearbyAccessPointsTests.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import org.mockito.ArgumentMatchers; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetNearbyAccessPointsTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure_missingPrerequisite_filterDuplicates_false() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getNearbyAccessPoints(false)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getScanResults(); - } - - @Test - public void sync_failure_missingPrerequisite_filterDuplicates_true() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getNearbyAccessPoints(true)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getScanResults(); - } - - @Test - public void sync_success_filterDuplicates_false() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - - List accessPoints = mWiseFy.getNearbyAccessPoints(false); - assertEquals(accessPoints, scanResults); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getScanResults(); - } - - @Test - public void sync_success_filterDuplicates_true() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); - - List accessPoints = mWiseFy.getNearbyAccessPoints(true); - assertEquals(accessPoints, scanResults); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getScanResults(); - } - - @Test - public void async_failure_missingPrerequisite_filterDuplicates_false() { - missingPrerequisite(); - GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); - mWiseFy.getNearbyAccessPoints(false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getScanResults(); - } - - @Test - public void async_failure_missingPrerequisite_filterDuplicates_false_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.getNearbyAccessPoints(false, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getScanResults(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisite_filterDuplicates_true() { - missingPrerequisite(); - GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); - mWiseFy.getNearbyAccessPoints(true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getScanResults(); - } - - @Test - public void async_failure_missingPrerequisite_filterDuplicates_true_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.getNearbyAccessPoints(true, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getScanResults(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_filterDuplicates_false() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - - GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); - mWiseFy.getNearbyAccessPoints(false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedNearbyAccessPoints(scanResults); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getScanResults(); - } - - @Test - public void async_success_filterDuplicates_false_nullCallback() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - - try { - mWiseFy.getNearbyAccessPoints(false, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getScanResults(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_filterDuplicates_true() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); - - GetNearbyAccessPointsCallbacks mockCallbacks = mock(GetNearbyAccessPointsCallbacks.class); - mWiseFy.getNearbyAccessPoints(true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedNearbyAccessPoints(scanResults); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getScanResults(); - } - - @Test - public void async_success_filterDuplicates_true_nullCallback() { - List scanResults = new ArrayList<>(); - ScanResult scanResult1 = mock(ScanResult.class); - scanResult1.SSID = TEST_SSID; - scanResult1.level = -35; - scanResults.add(scanResult1); - ScanResult scanResult2 = mock(ScanResult.class); - scanResult2.SSID = TEST_SSID2; - scanResult2.level = -70; - scanResults.add(scanResult2); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(scanResults); - - try { - mWiseFy.getNearbyAccessPoints(true, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getScanResults(); - } catch (NullPointerException npe) { - fail(); - } - } -} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java deleted file mode 100644 index 536e58b4..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetRSSITests.java +++ /dev/null @@ -1,259 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.callbacks.GetRSSICallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_RSSI_LEVEL; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_TIMEOUT; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetRSSITests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure_takeHighest_false_nullSSIDParam() { - assertEquals(null, mWiseFy.getRSSI(null, false, TEST_TIMEOUT)); - } - - @Test - public void sync_failure_takeHighest_true_nullSSIDParam() { - assertEquals(null, mWiseFy.getRSSI(null, true, TEST_TIMEOUT)); - } - - @Test - public void sync_failure_takeHighest_false_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT)); - } - - @Test - public void sync_failure_takeHighest_true_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT)); - } - - @Test - public void sync_failure_takeHighest_false_noNetworkFound() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT)); - } - - @Test - public void sync_failure_takeHighest_true_noNetworkFound() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT)); - } - - @Test - public void sync_success_takeHighest_false () { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - assertEquals(TEST_RSSI_LEVEL, (int) mWiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT)); - } - - @Test - public void sync_success_takeHighest_true () { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - assertEquals(TEST_RSSI_LEVEL, (int) mWiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT)); - } - - @Test - public void async_failure_takeHighest_false_nullSSIDParam() { - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(null, false, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void async_failure_takeHighest_false_nullSSIDParam_nullCallback() { - try { - mWiseFy.getRSSI(null, false, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_takeHighest_true_nullSSIDParam() { - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(null, true, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void async_failure_takeHighest_true_nullSSIDParam_nullCallback() { - try { - mWiseFy.getRSSI(null, true, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_takeHighest_false_missingPrerequisite() { - missingPrerequisite(); - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_takeHighest_false_nullSSIDParam_missingPrerequisite() { - missingPrerequisite(); - try { - mWiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_takeHighest_true_missingPrerequisite() { - missingPrerequisite(); - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_takeHighest_true_nullSSIDParam_missingPrerequisite() { - missingPrerequisite(); - try { - mWiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_takeHighest_false_noNetworkFound() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkNotFoundToRetrieveRSSI(); - } - - @Test - public void async_failure_takeHighest_false_noNetworkFound_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_takeHighest_true_noNetworkFound() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkNotFoundToRetrieveRSSI(); - } - - @Test - public void async_failure_takeHighest_true_noNetworkFound_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_takeHighest_false() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedRSSI(TEST_RSSI_LEVEL); - } - - @Test - public void async_success_takeHighest_false_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - try { - mWiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_takeHighest_true() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - - GetRSSICallbacks mockCallbacks = mock(GetRSSICallbacks.class); - mWiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedRSSI(TEST_RSSI_LEVEL); - } - - @Test - public void async_success_takeHighest_true_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.level = TEST_RSSI_LEVEL; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - try { - mWiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } -} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java deleted file mode 100644 index ee31743b..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworkTests.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetSavedNetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure_nullSSIDParam() { - assertEquals(null, mWiseFy.getSavedNetwork(null)); - } - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); - } - - @Test - public void sync_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - assertEquals(null, mWiseFy.getSavedNetwork(TEST_SSID)); - } - - @Test - public void sync_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - assertEquals(wiFiConfiguration, mWiseFy.getSavedNetwork(TEST_SSID)); - } - - @Test - public void async_failure_nullSSIDParam() { - GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); - mWiseFy.getSavedNetwork(null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void async_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.getSavedNetwork(null, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); - mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.getSavedNetwork(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); - mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).savedNetworkNotFound(); - } - - @Test - public void async_failure_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - try { - mWiseFy.getSavedNetwork(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - GetSavedNetworkCallbacks mockCallbacks = mock(GetSavedNetworkCallbacks.class); - mWiseFy.getSavedNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSavedNetwork(wiFiConfiguration); - } - - @Test - public void async_success_nullCallback() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - try { - mWiseFy.getSavedNetwork(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java deleted file mode 100644 index 04cb8349..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/GetSavedNetworksTests.java +++ /dev/null @@ -1,250 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class GetSavedNetworksTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getSavedNetworks()); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConfiguredNetworks(); - } - - @Test - public void sync_success() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - - assertEquals(wifiList, mWiseFy.getSavedNetworks()); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getConfiguredNetworks(); - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConfiguredNetworks(); - } - - @Test - public void async_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_nullSavedNetworks() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSavedNetworksFound(); - } - - @Test - public void async_failure_nullSavedNetworks_nullCallback() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); - try { - mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_emptyConfiguredNetworks() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSavedNetworksFound(); - } - - @Test - public void async_failure_emptyConfiguredNetworks_nullCallback() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - try { - mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSavedNetworks(wifiList); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getConfiguredNetworks(); - } - - @Test - public void async_success_nullCallback() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - - try { - mWiseFy.getSavedNetworks((GetSavedNetworksCallbacks) null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void sync_failure_withRegex_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.getSavedNetworks(TEST_SSID)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConfiguredNetworks(); - } - - @Test - public void sync_success_withRegex() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - - assertEquals(wifiList, mWiseFy.getSavedNetworks(TEST_SSID)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getConfiguredNetworks(); - } - - @Test - public void async_failure_withRegex_missingPrerequisite() { - missingPrerequisite(); - - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConfiguredNetworks(); - } - - @Test - public void async_failure_withRegex_missingPrerequisite_nullCallback() { - missingPrerequisite(); - - try{ - mWiseFy.getSavedNetworks(TEST_SSID, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_withRegex_nullSavedNetworks() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(null); - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSavedNetworksFound(); - } - - @Test - public void async_failure_withRegex_nullSavedNetworks_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(null); - try { - mWiseFy.getSavedNetworks(TEST_SSID, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_withRegex_emptyConfiguredNetworks() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(new ArrayList()); - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSavedNetworksFound(); - } - - @Test - public void async_failure_withRegex_emptyConfiguredNetworks_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(new ArrayList()); - try { - mWiseFy.getSavedNetworks(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_withRegex() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(wifiList); - - GetSavedNetworksCallbacks mockCallbacks = mock(GetSavedNetworksCallbacks.class); - mWiseFy.getSavedNetworks(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSavedNetworks(wifiList); - } - - @Test - public void async_success_withRegex_nullCallbacks() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(wifiList); - - try { - mWiseFy.getSavedNetworks(TEST_SSID, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).getConfiguredNetworks(); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java deleted file mode 100644 index 9353adc7..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileNetworkTests.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import org.junit.Test; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsDeviceConnectedToMobileNetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); - } - - @Test - public void failure() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); - assertFalse(mWiseFy.isDeviceConnectedToMobileNetwork()); - } - - @Test - public void success() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); - assertTrue(mWiseFy.isDeviceConnectedToMobileNetwork()); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java deleted file mode 100644 index a44b7cca..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToMobileOrWifiNetworkTests.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import org.junit.Test; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsDeviceConnectedToMobileOrWifiNetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertFalse(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); - } - - @Test - public void failure() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo.class))).thenReturn(false); - assertFalse(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); - } - - @Test - public void success() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo.class))).thenReturn(true); - assertTrue(mWiseFy.isDeviceConnectedToMobileOrWifiNetwork()); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java deleted file mode 100644 index 0fc5d2f7..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToSSIDTests.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.isupatches.wisefy; - - -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsDeviceConnectedToSSIDTests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_nullSSIDParams() { - assertFalse(mWiseFy.isDeviceConnectedToSSID(null)); - } - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertFalse(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); - } - - @Test - public void failure() { - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(false); - - assertFalse(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); - } - - @Test - public void success() { - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(true); - - assertTrue(mWiseFy.isDeviceConnectedToSSID(TEST_SSID)); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java deleted file mode 100644 index da3d209d..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceConnectedToWifiNetworkTests.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import org.junit.Test; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsDeviceConnectedToWifiNetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertFalse(mWiseFy.isDeviceConnectedToWifiNetwork()); - } - - @Test - public void failure() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(false); - assertFalse(mWiseFy.isDeviceConnectedToWifiNetwork()); - } - - @Test - public void success() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mock(NetworkInfo.class)); - - WiseFyConnection mockWiseFyConnection = mock(WiseFyConnection.class); - mWiseFy.mWiseFyConnection = mockWiseFyConnection; - when(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo.class), anyString())).thenReturn(true); - assertTrue(mWiseFy.isDeviceConnectedToWifiNetwork()); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java deleted file mode 100644 index 0ff64fc7..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsDeviceRoamingTests.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import org.junit.Test; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsDeviceRoamingTests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertFalse(mWiseFy.isDeviceRoaming()); - } - - @Test - public void failure_nullActiveNetworkInfo() { - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(null); - assertFalse(mWiseFy.isDeviceRoaming()); - } - - @Test - public void failure() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isRoaming()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - assertFalse(mWiseFy.isDeviceRoaming()); - } - - @Test - public void success() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isRoaming()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - assertTrue(mWiseFy.isDeviceRoaming()); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java deleted file mode 100644 index 0af93446..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetwork5gHzTests.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiInfo; -import android.os.Build; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_5GHZ; -import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_ABOVE_5GHZ; -import static com.isupatches.wisefy.base.TestUtils.TEST_NETWORK_FREQUENCY_BELOW_5GHZ; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class IsNetwork5gHzTests extends BaseAndroidJUnit4TestClass { - - @Test - public void currentNetwork_failure_above5ghz() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(false, mWiseFy.isNetwork5gHz()); - } - } - - @Test - public void currentNetwork_failure_below5ghz() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_BELOW_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(false, mWiseFy.isNetwork5gHz()); - } - } - - @Test - public void currentNetwork_failure_null() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - assertEquals(false, mWiseFy.isNetwork5gHz()); - } - } - - @Test - public void currentNetwork_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(true, mWiseFy.isNetwork5gHz()); - } - } - - @Test - public void provideWifiInfo_failure_above5ghz() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(false, mWiseFy.isNetwork5gHz(mockWifiInfo)); - } - } - - @Test - public void provideWifiInfo_failure_below5ghz() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_BELOW_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(false, mWiseFy.isNetwork5gHz(mockWifiInfo)); - } - } - - @Test - public void provideWifiInfo_failure_null() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - assertEquals(false, mWiseFy.isNetwork5gHz(null)); - } - } - - @Test - public void provideWifiInfo_success() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WifiInfo mockWifiInfo = mock(WifiInfo.class); - when(mockWifiInfo.getFrequency()).thenReturn(TEST_NETWORK_FREQUENCY_5GHZ); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - - assertEquals(true, mWiseFy.isNetwork5gHz(mockWifiInfo)); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java deleted file mode 100644 index 51a45406..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkEAPTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkEAPTests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_differentCapability() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkEAP(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkEAP(null)); - } - - @Test - public void success() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.EAP; - assertEquals(true, mWiseFy.isNetworkEAP(scanResult)); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java deleted file mode 100644 index b2981cd2..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkInConfigurationListTests.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID3; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - - -public class IsNetworkInConfigurationListTests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure() { - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void failure_multipleNetworks() { - List wifiList = new ArrayList<>(); - - WifiConfiguration wifiConfiguration1 = new WifiConfiguration(); - wifiConfiguration1.SSID = TEST_SSID2; - wifiList.add(wifiConfiguration1); - - WifiConfiguration wiFiConfiguration2 = new WifiConfiguration(); - wiFiConfiguration2.SSID = TEST_SSID3; - wifiList.add(wiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void failure_noNetworks() { - List wifiList = new ArrayList<>(); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void failure_nullSSID() { - List wifiList = new ArrayList<>(); - WifiConfiguration wifiConfiguration = new WifiConfiguration(); - wifiConfiguration.SSID = null; - wifiList.add(wifiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void failure_nullWifiConfiguration() { - List wifiList = new ArrayList<>(); - wifiList.add(0, null); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void failure_nmissingPrerequisite() { - missingPrerequisite(); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void success() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } - - @Test - public void success_multipleNetworks() { - List wifiList = new ArrayList<>(); - - WifiConfiguration wifiConfiguration1 = new WifiConfiguration(); - wifiConfiguration1.SSID = TEST_SSID; - wifiList.add(wifiConfiguration1); - - WifiConfiguration wiFiConfiguration2 = new WifiConfiguration(); - wiFiConfiguration2.SSID = TEST_SSID2; - wifiList.add(wiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java deleted file mode 100644 index 5ac26f84..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkPSKTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkPSKTest extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_differentCapability() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkPSK(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkPSK(null)); - } - - @Test - public void success() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.PSK; - assertEquals(true, mWiseFy.isNetworkPSK(scanResult)); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java deleted file mode 100644 index cd3823ec..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkSecureTests.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkSecureTests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkSecure(null)); - } - - @Test - public void success_withEAP() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.EAP; - assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void success_withPSK() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.PSK; - assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void success_withWEP() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WEP; - assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void success_withWPA() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WPA; - assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void success_withWPA2() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WPA2; - assertEquals(true, mWiseFy.isNetworkSecure(scanResult)); - } - - @Test - public void failure_otherCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkSecure(scanResult)); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java deleted file mode 100644 index 48f98ada..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPA2Test.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkWPA2Test extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_differentCapability() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkWPA2(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkWPA2(null)); - } - - @Test - public void success() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WPA2; - assertEquals(true, mWiseFy.isNetworkWPA2(scanResult)); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java deleted file mode 100644 index 64793f87..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWPATests.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static junit.framework.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkWPATests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_differentCapability() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkWPA(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkWPA(null)); - } - - @Test - public void success() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WPA; - assertEquals(true, mWiseFy.isNetworkWPA(scanResult)); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java deleted file mode 100644 index e94e8d90..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsNetworkWepTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.constants.Capabilities; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - - -public class IsNetworkWepTests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure_differentCapability() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = "Other"; - assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); - } - - @Test - public void failure_emptyCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = ""; - assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); - } - - @Test - public void failure_nullCapabilities() { - ScanResult scanResult = mock(ScanResult.class); - assertEquals(false, mWiseFy.isNetworkWEP(scanResult)); - } - - @Test - public void failure_nullScanResult() { - assertEquals(false, mWiseFy.isNetworkWEP(null)); - } - - @Test - public void success() { - ScanResult scanResult = mock(ScanResult.class); - scanResult.capabilities = Capabilities.WEP; - assertEquals(true, mWiseFy.isNetworkWEP(scanResult)); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java deleted file mode 100644 index 25bb11cb..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/IsWifiEnabledTests.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.isupatches.wisefy; - - -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - - -public class IsWifiEnabledTests extends BaseAndroidJUnit4TestClass { - - @Test - public void failure() { - when(mMockWiFiManager.isWifiEnabled()).thenReturn(false); - assertEquals(false, mWiseFy.isWifiEnabled()); - } - - @Test - public void failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(false, mWiseFy.isWifiEnabled()); - } - - @Test - public void success() { - when(mMockWiFiManager.isWifiEnabled()).thenReturn(true); - assertEquals(true, mWiseFy.isWifiEnabled()); - } -} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java deleted file mode 100644 index 43a8da60..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/ManagerUtilTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.ConnectivityManager; -import android.net.wifi.WifiManager; -import android.support.test.InstrumentationRegistry; -import com.isupatches.wisefy.util.ManagerUtil; -import org.junit.Test; -import static junit.framework.Assert.*; - - -public class ManagerUtilTest extends BaseAndroidJUnit4TestClass { - - @Test - public void getConnectivityManager_returnsNotNull() { - ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(InstrumentationRegistry.getContext()); - assertNotNull(connectivityManager); - } - - @Test - public void getConnectivityManager_returnsNull_noActivity() { - ConnectivityManager connectivityManager = ManagerUtil.getInstance().getConnectivityManager(null); - assertNull(connectivityManager); - } - - @Test - public void getWiFiManager_returnsNotNull() { - WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(InstrumentationRegistry.getContext()); - assertNotNull(wifiManager); - } - - @Test - public void getWiFiManager_returnsNull_noActivity() { - WifiManager wifiManager = ManagerUtil.getInstance().getWiFiManager(null); - assertNull(wifiManager); - } -} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/MockNetworkUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/MockNetworkUtil.kt new file mode 100644 index 00000000..f6e412f6 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/MockNetworkUtil.kt @@ -0,0 +1,426 @@ +package com.isupatches.wisefy + +import android.net.ConnectivityManager +import android.net.NetworkInfo +import android.net.wifi.ScanResult +import android.net.wifi.WifiConfiguration +import android.net.wifi.WifiInfo +import android.net.wifi.WifiManager +import com.isupatches.wisefy.WiseFy.Companion.WIFI_MANAGER_FAILURE +import org.mockito.ArgumentMatchers.any +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.Mockito.`when` +import org.mockito.Mockito.mock +import java.util.ArrayList + +/** + * A class that mocks lower level returns from ConnectivityManager and WifiManager. + * + * @see ConnectivityManager + * @see WifiManager + * + * @author Patches + */ +@Suppress("LargeClass") +internal class MockNetworkUtil internal constructor( + private val mockConnectivityManager: ConnectivityManager, + private val mockWifiManager: WifiManager +) { + + private var expectedNearbyAccessPoint: ScanResult? = null + private var expectedNearbyAccessPoints: MutableList? = null + + private var expectedSavedNetwork: WifiConfiguration? = null + private var expectedSavedNetworks: MutableList? = null + + private var expectedSSIDs: MutableList? = null + + internal fun activeNetwork() { + `when`(mockConnectivityManager.activeNetworkInfo).thenReturn(mock(NetworkInfo::class.java)) + } + + internal fun addNetwork_failure() { + `when`(mockWifiManager.addNetwork(any(WifiConfiguration::class.java))).thenReturn(WIFI_MANAGER_FAILURE) + } + + internal fun addNetwork_success() { + `when`(mockWifiManager.addNetwork(any(WifiConfiguration::class.java))).thenReturn(0) + } + + internal fun currentNetwork(ssid: String?): WifiInfo { + val mockCurrentNetwork = mock(WifiInfo::class.java) + `when`(mockCurrentNetwork.ssid).thenReturn(ssid) + `when`(mockWifiManager.connectionInfo).thenReturn(mockCurrentNetwork) + return mockCurrentNetwork + } + + internal fun currentNetworkConnectionStatus(isAvailable: Boolean, isConnected: Boolean, type: String?): NetworkInfo { + val networkInfo = mock(NetworkInfo::class.java) + `when`(networkInfo.isAvailable).thenReturn(isAvailable) + `when`(networkInfo.isConnected).thenReturn(isConnected) + if (type != null) { + `when`(networkInfo.typeName).thenReturn(type) + } + `when`(mockConnectivityManager.activeNetworkInfo).thenReturn(networkInfo) + return networkInfo + } + + internal fun currentNetwork_null() { + `when`(mockWifiManager.connectionInfo).thenReturn(null) + } + + internal fun disableWifi_failure() { + `when`(mockWifiManager.setWifiEnabled(false)).thenReturn(false) + } + + internal fun disableWifi_success() { + `when`(mockWifiManager.setWifiEnabled(false)).thenReturn(true) + } + + internal fun disconnectFromCurrentNetwork_failure() { + `when`(mockWifiManager.disconnect()).thenReturn(false) + } + + internal fun disconnectFromCurrentNetwork_success() { + `when`(mockWifiManager.disconnect()).thenReturn(true) + } + + internal fun enableWifi_failure() { + `when`(mockWifiManager.setWifiEnabled(true)).thenReturn(false) + } + + internal fun enableWifi_success() { + `when`(mockWifiManager.setWifiEnabled(true)).thenReturn(true) + } + + internal fun getExpectedNearbyAccessPoint(): ScanResult? = expectedNearbyAccessPoint + internal fun getExpectedNearbyAccessPoints(): List? = expectedNearbyAccessPoints + + internal fun getExpectedSavedNetwork(): WifiConfiguration? = expectedSavedNetwork + internal fun getExpectedSavedNetworks(): List? = expectedSavedNetworks + + internal fun getExpectedSSIDs(): List? = expectedSSIDs + + internal fun isDeviceRoaming(roaming: Boolean) { + val networkInfo = mock(NetworkInfo::class.java) + `when`(networkInfo.isRoaming).thenReturn(roaming) + `when`(mockConnectivityManager.activeNetworkInfo).thenReturn(networkInfo) + } + + internal fun isWifiEnabled(wifiEnabled: Boolean) { + `when`(mockWifiManager.isWifiEnabled).thenReturn(wifiEnabled) + } + + internal fun nearbyAccessPoints(): List { + val accessPoints = createMockAccessPointList(TEST_SSID, TEST_RSSI_LEVEL_HIGH, TEST_SSID2, TEST_RSSI_LEVEL_LOW) + `when`(mockWifiManager.scanResults).thenReturn(accessPoints) + return accessPoints + } + + internal fun networkWithFrequency(frequency: Int): WifiInfo { + val mockWifiInfo = mock(WifiInfo::class.java) + `when`(mockWifiInfo.frequency).thenReturn(frequency) + `when`(mockWifiManager.connectionInfo).thenReturn(mockWifiInfo) + return mockWifiInfo + } + + internal fun removeNetwork(removed: Boolean) { + `when`(mockWifiManager.removeNetwork(anyInt())).thenReturn(removed) + } + + internal fun savedNetworks(): List { + val savedNetworks = ArrayList() + val wiFiConfiguration = createSavedNetwork(TEST_SSID) + savedNetworks.add(wiFiConfiguration) + + `when`(mockWifiManager.configuredNetworks).thenReturn(savedNetworks) + return savedNetworks + } + + internal fun getConfiguredNetworks_null() { + `when`(mockWifiManager.configuredNetworks).thenReturn(null) + } + + internal fun getConfiguredNetworks_emptyList() { + `when`(mockWifiManager.configuredNetworks).thenReturn(ArrayList()) + } + + internal fun ip_failure() { + val wifiInfo = mock(WifiInfo::class.java) + `when`(wifiInfo.ipAddress).thenReturn(0) + `when`(mockWifiManager.connectionInfo).thenReturn(wifiInfo) + } + + internal fun ip_success() { + val wifiInfo = mock(WifiInfo::class.java) + `when`(wifiInfo.ipAddress).thenReturn(TEST_IP_ADDRESS_INT) + `when`(mockWifiManager.connectionInfo).thenReturn(wifiInfo) + } + + internal fun nearbyAccessPoints_emptyList() { + `when`(mockWifiManager.scanResults).thenReturn(ArrayList()) + } + + internal fun nearbyAccessPoints_matchingSSID() { + val accessPoint = createMockAccessPointWithSSID(TEST_SSID) + + val accessPoints = ArrayList() + accessPoints.add(accessPoint) + + addToExpectedNearbyAccessPoints(accessPoint) + addToExpectedSSIDs(accessPoint) + + `when`(mockWifiManager.scanResults).thenReturn(accessPoints) + } + + internal fun nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(takeHighest: Boolean): List { + val accessPoint1 = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL_HIGH) + val accessPoint2 = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL_LOW) + + val accessPoints = ArrayList() + accessPoints.add(accessPoint1) + accessPoints.add(accessPoint2) + + if (takeHighest) { + addToExpectedNearbyAccessPoints(accessPoint1) + } else { + addToExpectedNearbyAccessPoints(accessPoint1, accessPoint2) + } + addToExpectedSSIDs(accessPoint1) + + `when`(mockWifiManager.scanResults).thenReturn(accessPoints) + + return accessPoints + } + + internal fun nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(takeHighest: Boolean): List { + val accessPoint1 = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL_LOW) + val accessPoint2 = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL_HIGH) + + val accessPoints = ArrayList() + accessPoints.add(accessPoint1) + accessPoints.add(accessPoint2) + + if (takeHighest) { + addToExpectedNearbyAccessPoints(accessPoint2) + } else { + addToExpectedNearbyAccessPoints(accessPoint1, accessPoint2) + } + addToExpectedSSIDs(accessPoint1) + + `when`(mockWifiManager.scanResults).thenReturn(accessPoints) + + return accessPoints + } + + internal fun nearbyAccessPoints_multipleSSIDs_sameRSSI(addSecondNetwork: Boolean): List { + val accessPoint1 = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL) + val accessPoint2 = createMockAccessPointWithSSIDAndRSSI(TEST_SSID2, TEST_RSSI_LEVEL) + + val accessPoints = ArrayList() + accessPoints.add(accessPoint1) + accessPoints.add(accessPoint2) + + if (addSecondNetwork) { + addToExpectedNearbyAccessPoints(accessPoint1, accessPoint2) + } else { + addToExpectedNearbyAccessPoints(accessPoint1) + } + + if (addSecondNetwork) { + addToExpectedSSIDs(accessPoint1, accessPoint2) + } else { + addToExpectedSSIDs(accessPoint1) + } + + `when`(mockWifiManager.scanResults).thenReturn(accessPoints) + + return accessPoints + } + + internal fun nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(addSecondNetwork: Boolean): List { + val accessPoint1 = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL) + val accessPoint2 = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL) + + val accessPoints = ArrayList() + accessPoints.add(accessPoint1) + accessPoints.add(accessPoint2) + + if (addSecondNetwork) { + addToExpectedNearbyAccessPoints(accessPoint1, accessPoint2) + } else { + addToExpectedNearbyAccessPoints(accessPoint1) + } + addToExpectedSSIDs(accessPoint1) + + `when`(mockWifiManager.scanResults).thenReturn(accessPoints) + + return accessPoints + } + + internal fun nearbyAccessPoints_multipleNonMatchingSSIDs() { + val accessPoint1 = createMockAccessPointWithSSID(TEST_SSID2) + val accessPoint2 = createMockAccessPointWithSSID(TEST_SSID3) + + val accessPoints = ArrayList() + accessPoints.add(accessPoint1) + accessPoints.add(accessPoint2) + + `when`(mockWifiManager.scanResults).thenReturn(accessPoints) + } + + internal fun nearbyAccessPoints_nonMatchingSSID() { + val accessPoint = createMockAccessPointWithSSID(TEST_SSID2) + + val accessPoints = ArrayList() + accessPoints.add(accessPoint) + + `when`(mockWifiManager.scanResults).thenReturn(accessPoints) + } + + internal fun nearbyAccessPoints_nullAccessPoint() { + val accessPoints = emptyList() + `when`(mockWifiManager.scanResults).thenReturn(accessPoints) + } + + internal fun nearbyAccessPoints_nullList() { + `when`(mockWifiManager.scanResults).thenReturn(null) + } + + internal fun nearbyAccessPoints_nullSSID() { + val accessPoint = createMockAccessPointWithSSID(null) + + val accessPoints = ArrayList() + accessPoints.add(accessPoint) + + `when`(mockWifiManager.scanResults).thenReturn(accessPoints) + } + + internal fun savedNetworks_emptyList() { + `when`(mockWifiManager.configuredNetworks).thenReturn(ArrayList()) + } + + internal fun savedNetworks_matchingSSID() { + val savedNetwork = createSavedNetwork(TEST_SSID) + + val savedNetworks = ArrayList() + savedNetworks.add(savedNetwork) + + addToExpectedSavedNetworks(savedNetwork) + + `when`(mockWifiManager.configuredNetworks).thenReturn(savedNetworks) + } + + internal fun savedNetworks_multipleMatchingSSIDs() { + val savedNetwork1 = createSavedNetwork(TEST_SSID) + val savedNetwork2 = createSavedNetwork(TEST_SSID) + + val savedNetworks = ArrayList() + savedNetworks.add(savedNetwork1) + savedNetworks.add(savedNetwork2) + + addToExpectedSavedNetworks(savedNetwork1, savedNetwork2) + + `when`(mockWifiManager.configuredNetworks).thenReturn(savedNetworks) + } + + internal fun savedNetworks_multipleNonMatchingSSIDs() { + val savedNetwork1 = createSavedNetwork(TEST_SSID2) + val savedNetwork2 = createSavedNetwork(TEST_SSID3) + + val savedNetworks = ArrayList() + savedNetworks.add(savedNetwork1) + savedNetworks.add(savedNetwork2) + + `when`(mockWifiManager.configuredNetworks).thenReturn(savedNetworks) + } + + internal fun savedNetworks_multipleSSIDs(addSecondNetwork: Boolean) { + val savedNetwork1 = createSavedNetwork(TEST_SSID) + val savedNetwork2 = createSavedNetwork(TEST_SSID2) + + val savedNetworks = ArrayList() + savedNetworks.add(savedNetwork1) + savedNetworks.add(savedNetwork2) + + if (addSecondNetwork) { + addToExpectedSavedNetworks(savedNetwork1, savedNetwork2) + } else { + addToExpectedSavedNetworks(savedNetwork1) + } + + `when`(mockWifiManager.configuredNetworks).thenReturn(savedNetworks) + } + + internal fun savedNetworks_nonMatchingSSID() { + val savedNetwork = createSavedNetwork(TEST_SSID2) + + val savedNetworks = ArrayList() + savedNetworks.add(savedNetwork) + + `when`(mockWifiManager.configuredNetworks).thenReturn(savedNetworks) + } + + internal fun savedNetworks_nullList() { + `when`(mockWifiManager.configuredNetworks).thenReturn(null) + } + + internal fun savedNetworks_nullSavedNetwork() { + val wifiList = emptyList() + `when`(mockWifiManager.configuredNetworks).thenReturn(wifiList) + } + + internal fun savedNetworks_nullSSID() { + val savedNetwork = createSavedNetwork(null) + + val savedNetworks = ArrayList() + savedNetworks.add(savedNetwork) + + `when`(mockWifiManager.configuredNetworks).thenReturn(savedNetworks) + } + + /* + * HELPERS + */ + + private fun addToExpectedNearbyAccessPoints(accessPoint: ScanResult) { + expectedNearbyAccessPoint = accessPoint + + expectedNearbyAccessPoints = ArrayList() + expectedNearbyAccessPoints!!.add(accessPoint) + } + + private fun addToExpectedNearbyAccessPoints(accessPoint1: ScanResult, accessPoint2: ScanResult) { + expectedNearbyAccessPoint = accessPoint1 + + expectedNearbyAccessPoints = ArrayList() + expectedNearbyAccessPoints!!.add(accessPoint1) + expectedNearbyAccessPoints!!.add(accessPoint2) + } + + private fun addToExpectedSavedNetworks(savedNetwork: WifiConfiguration) { + expectedSavedNetwork = savedNetwork + + expectedSavedNetworks = ArrayList() + expectedSavedNetworks!!.add(savedNetwork) + } + + private fun addToExpectedSavedNetworks(savedNetwork1: WifiConfiguration, savedNetwork2: WifiConfiguration) { + expectedSavedNetwork = savedNetwork1 + + expectedSavedNetworks = ArrayList() + expectedSavedNetworks!!.add(savedNetwork1) + expectedSavedNetworks!!.add(savedNetwork2) + } + + private fun addToExpectedSSIDs(accessPoint: ScanResult) { + expectedSSIDs = ArrayList() + expectedSSIDs!!.add(accessPoint.SSID) + } + + private fun addToExpectedSSIDs(accessPoint1: ScanResult, accessPoint2: ScanResult) { + expectedSSIDs = ArrayList() + expectedSSIDs!!.add(accessPoint1.SSID) + expectedSSIDs!!.add(accessPoint2.SSID) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFyConnectionUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFyConnectionUtil.kt new file mode 100644 index 00000000..092d1b50 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFyConnectionUtil.kt @@ -0,0 +1,63 @@ +package com.isupatches.wisefy + +import android.net.NetworkInfo +import org.mockito.ArgumentMatchers.any +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.ArgumentMatchers.anyString +import org.mockito.Mockito.`when` + +/** + * A class to mock returns from the WiseFyConnection class. + * + * @see WiseFyConnection + * + * @author Patches + */ +internal class MockWiseFyConnectionUtil internal constructor( + private val mockWiseFyConnection: WiseFyConnection +) { + + /** + * Mocks if the device is connected to a specific SSID. + * + * @param connected Whether the device is connected to the specific SSID or not + * + * @see WiseFyConnection.isCurrentNetworkConnectedToSSID + */ + fun isCurrentNetworkConnectedToSSID(connected: Boolean) { + `when`(mockWiseFyConnection.isCurrentNetworkConnectedToSSID(anyString())).thenReturn(connected) + } + + /** + * Mocks if the device is connected to a network. + * + * @param connected Whether the device is connected or not + * + * @see WiseFyConnection.isNetworkConnected + */ + fun isNetworkConnected(connected: Boolean) { + `when`(mockWiseFyConnection.isNetworkConnected(any(NetworkInfo::class.java))).thenReturn(connected) + } + + /** + * To mock if the device is connected to a mobile network. + * + * @param connectedAndMatchesType If the device is connected to a mobile network + * + * @see WiseFyConnection.isNetworkConnectedAndMatchesType + */ + fun isNetworkConnectedAndMatchesType(connectedAndMatchesType: Boolean) { + `when`(mockWiseFyConnection.isNetworkConnectedAndMatchesType(any(NetworkInfo::class.java), anyString())).thenReturn(connectedAndMatchesType) + } + + /** + * Mocks if waitToConnectToSSID is successful. + * + * @param success Whether waitToConnectToSSID succeeds or not + * + * @see WiseFyConnection.waitToConnectToSSID + */ + fun waitToConnectToSSID(success: Boolean) { + `when`(mockWiseFyConnection.waitToConnectToSSID(anyString(), anyInt())).thenReturn(success) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFyPrechecksUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFyPrechecksUtil.kt new file mode 100644 index 00000000..1bfb3300 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFyPrechecksUtil.kt @@ -0,0 +1,335 @@ +package com.isupatches.wisefy + +import com.isupatches.wisefy.constants.MISSING_PARAMETER + +import org.mockito.ArgumentMatchers.anyString +import org.mockito.Mockito.`when` + +/** + * A class to mock returns from the WiseFyPrechecks class. + * + * @see WiseFyPrechecks + * + * + * @author Patches + */ +internal class MockWiseFyPrechecksUtil internal constructor(private val mockWiseFyPrechecks: WiseFyPrechecks) { + + /** + * Mocks a precheck failure adding a network. + * + * @see WiseFyPrechecks.addNetworkPrechecks + * @see WiseFyPrechecks.addNetworkPrechecks + */ + fun addNetwork_failure() { + `when`(mockWiseFyPrechecks.addNetworkPrechecks(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + `when`(mockWiseFyPrechecks.addNetworkPrechecks(anyString(), anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun addNetwork_success() { + `when`(mockWiseFyPrechecks.addNetworkPrechecks(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + `when`(mockWiseFyPrechecks.addNetworkPrechecks(anyString(), anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure connecting to a network. + * + * @see WiseFyPrechecks.connectToNetworkPrechecks + */ + fun connectToNetwork_failure() { + `when`(mockWiseFyPrechecks.connectToNetworkPrechecks(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun connectToNetwork_success() { + `when`(mockWiseFyPrechecks.connectToNetworkPrechecks(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure disabling wifi. + * + * @see WiseFyPrechecks.disableWifiChecks + */ + fun disableWifi_failure() { + `when`(mockWiseFyPrechecks.disableWifiChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun disableWifi_success() { + `when`(mockWiseFyPrechecks.disableWifiChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure disconnecting from the current network. + * + * @see WiseFyPrechecks.disconnectFromCurrentNetworkChecks + */ + fun disconnectFromCurrentNetwork_failure() { + `when`(mockWiseFyPrechecks.disconnectFromCurrentNetworkChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun disconnectFromCurrentNetwork_success() { + `when`(mockWiseFyPrechecks.disconnectFromCurrentNetworkChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure enabling wifi. + * + * @see WiseFyPrechecks.enableWifiChecks + */ + fun enableWifi_failure() { + `when`(mockWiseFyPrechecks.enableWifiChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun enableWifi_success() { + `when`(mockWiseFyPrechecks.enableWifiChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure getting the current network. + * + * @see WiseFyPrechecks.getCurrentNetworkChecks + */ + fun getCurrentNetwork_failure() { + `when`(mockWiseFyPrechecks.getCurrentNetworkChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun getCurrentNetwork_success() { + `when`(mockWiseFyPrechecks.getCurrentNetworkChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + fun getCurrentNetworkInfo_failure() { + `when`(mockWiseFyPrechecks.getCurrentNetworkInfoChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun getCurrentNetworkInfo_success() { + `when`(mockWiseFyPrechecks.getCurrentNetworkInfoChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure getting the ip of the device. + * + * @see WiseFyPrechecks.getIPChecks + */ + fun getIP_failure() { + `when`(mockWiseFyPrechecks.getIPChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun getIP_success() { + `when`(mockWiseFyPrechecks.getIPChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure getting nearby access points. + * + * @see WiseFyPrechecks.getNearbyAccessPointsChecks + */ + fun getNearbyAccessPoints_failure() { + `when`(mockWiseFyPrechecks.getNearbyAccessPointsChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun getNearbyAccessPoints_success() { + `when`(mockWiseFyPrechecks.getNearbyAccessPointsChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure getting the RSSI level of a network. + * + * @see WiseFyPrechecks.getRSSIChecks + */ + fun getRSSI_failure() { + `when`(mockWiseFyPrechecks.getRSSIChecks(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun getRSSI_success() { + `when`(mockWiseFyPrechecks.getRSSIChecks(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure getting a saved network. + * + * @see WiseFyPrechecks.getSavedNetworkChecks + */ + fun getSavedNetwork_failure() { + `when`(mockWiseFyPrechecks.getSavedNetworkChecks(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun getSavedNetwork_success() { + `when`(mockWiseFyPrechecks.getSavedNetworkChecks(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure getting saved networks. + * + * @see WiseFyPrechecks.getSavedNetworksChecks + * @see WiseFyPrechecks.getSavedNetworksChecks + */ + fun getSavedNetworks_failure() { + `when`(mockWiseFyPrechecks.getSavedNetworksChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + `when`(mockWiseFyPrechecks.getSavedNetworksChecks(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun getSavedNetworks_success() { + `when`(mockWiseFyPrechecks.getSavedNetworksChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + `when`(mockWiseFyPrechecks.getSavedNetworksChecks(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure checking if a device is connected to a mobile network. + * + * @see WiseFyPrechecks.isDeviceConnectedToMobileNetworkChecks + */ + fun isDeviceConnectedToMobileNetwork_failure() { + `when`(mockWiseFyPrechecks.isDeviceConnectedToMobileNetworkChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun isDeviceConnectedToMobileNetwork_success() { + `when`(mockWiseFyPrechecks.isDeviceConnectedToMobileNetworkChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure checking if a device is connected to a mobile or wifi network. + * + * @see WiseFyPrechecks.isDeviceConnectedToMobileOrWifiNetworkChecks + */ + fun isDeviceConnectedToMobileOrWifiNetwork_failure() { + `when`(mockWiseFyPrechecks.isDeviceConnectedToMobileOrWifiNetworkChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun isDeviceConnectedToMobileOrWifiNetwork_success() { + `when`(mockWiseFyPrechecks.isDeviceConnectedToMobileOrWifiNetworkChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure checking if a device is connected to a network with a specific SSID. + * + * @see WiseFyPrechecks.isDeviceConnectedToSSIDChecks + */ + fun isDeviceConnectedToSSIDChecks_failure() { + `when`(mockWiseFyPrechecks.isDeviceConnectedToSSIDChecks(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun isDeviceConnectedToSSIDChecks_success() { + `when`(mockWiseFyPrechecks.isDeviceConnectedToSSIDChecks(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure checking if a device is connected to a wifi network. + * + * @see WiseFyPrechecks.isDeviceConnectedToWifiNetworkChecks + */ + fun isDeviceConnectedToWifiNetwork_failure() { + `when`(mockWiseFyPrechecks.isDeviceConnectedToWifiNetworkChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun isDeviceConnectedToWifiNetwork_success() { + `when`(mockWiseFyPrechecks.isDeviceConnectedToWifiNetworkChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure checking if a device is roaming. + * + * @see WiseFyPrechecks.isDeviceRoamingChecks + */ + fun isDeviceRoaming_failure() { + `when`(mockWiseFyPrechecks.isDeviceRoamingChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun isDeviceRoaming_success() { + `when`(mockWiseFyPrechecks.isDeviceRoamingChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure checking if a network is saved on a device. + * + * @see WiseFyPrechecks.isNetworkSavedChecks + */ + fun isNetworkSaved_failure() { + `when`(mockWiseFyPrechecks.isNetworkSavedChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun isNetworkSaved_success() { + `when`(mockWiseFyPrechecks.isNetworkSavedChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure checking if Wifi is enabled on a device. + * + * @see WiseFyPrechecks.isWifiEnabledChecks + */ + fun isWifiEnabled_failure() { + `when`(mockWiseFyPrechecks.isWifiEnabledChecks()).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun isWifiEnabled_success() { + `when`(mockWiseFyPrechecks.isWifiEnabledChecks()).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure removing a network. + * + * @see WiseFyPrechecks.removeNetworkCheck + */ + fun removeNetwork_failure() { + `when`(mockWiseFyPrechecks.removeNetworkCheck(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun removeNetwork_success() { + `when`(mockWiseFyPrechecks.removeNetworkCheck(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure searching for a nearby access point. + * + * @see WiseFyPrechecks.searchForAccessPointsChecks + */ + fun searchForAccessPoints_failure() { + `when`(mockWiseFyPrechecks.searchForAccessPointsChecks(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun searchForAccessPoints_success() { + `when`(mockWiseFyPrechecks.searchForAccessPointsChecks(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure searching for nearby access points. + * + * @see WiseFyPrechecks.searchForAccessPointChecks + */ + fun searchForAccessPoint_failure() { + `when`(mockWiseFyPrechecks.searchForAccessPointChecks(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun searchForAccessPoint_success() { + `when`(mockWiseFyPrechecks.searchForAccessPointChecks(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure searching for an SSID. + * + * @see WiseFyPrechecks.searchForSSIDChecks + */ + fun searchForSSID_failure() { + `when`(mockWiseFyPrechecks.searchForSSIDChecks(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun searchForSSID_success() { + `when`(mockWiseFyPrechecks.searchForSSIDChecks(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + /** + * Mocks a precheck failure searching for SSIDs. + * + * @see WiseFyPrechecks.searchForSSIDsChecks + */ + fun searchForSSIDs_failure() { + `when`(mockWiseFyPrechecks.searchForSSIDsChecks(anyString())).thenReturn(PRECHECK_RESULT_FAILURE) + } + + fun searchForSSIDs_success() { + `when`(mockWiseFyPrechecks.searchForSSIDsChecks(anyString())).thenReturn(DEFAULT_PRECHECK_RESULT) + } + + companion object { + + private val PRECHECK_RESULT_FAILURE = PrecheckResult(MISSING_PARAMETER) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFySearchUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFySearchUtil.kt new file mode 100644 index 00000000..8723cb69 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/MockWiseFySearchUtil.kt @@ -0,0 +1,150 @@ +package com.isupatches.wisefy + +import android.net.wifi.ScanResult +import android.net.wifi.WifiConfiguration +import org.mockito.ArgumentMatchers +import org.mockito.ArgumentMatchers.anyBoolean +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.ArgumentMatchers.anyString +import org.mockito.Mockito.`when` +import java.util.ArrayList + +/** + * A class to mock returns from the WiseFySearch class. + * + * @see WiseFySearch + * + * @author Patches + */ +internal class MockWiseFySearchUtil internal constructor(private val mockWiseFySearch: WiseFySearch) { + + /** + * Mocks no nearby access point. + * + * @see WiseFySearch.findAccessPointByRegex + */ + fun findAccessPointByRegex_null() { + `when`(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null) + } + + /** + * Mocks a nearby access point. + * + * @return ScanResult - The mocked nearby access point. + */ + fun findAccessPointByRegex_success(): ScanResult { + val accessPoint = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL) + `when`(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint) + return accessPoint + } + + /** + * Mocks no nearby access points. + * + * @see WiseFySearch.findAccessPointsMatchingRegex + */ + fun findAccessPointsMatchingRegex_null() { + `when`>(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null) + } + + /** + * Mocks nearby access point. + * + * @return List of ScanResults - The mocked access points. + */ + fun findAccessPointsMatchingRegex_success(): List { + val accessPoints = ArrayList() + val accessPoint = createMockAccessPointWithSSIDAndRSSI(TEST_SSID, TEST_RSSI_LEVEL) + accessPoints.add(accessPoint) + `when`>(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints) + return accessPoints + } + + /** + * Mocks no saved network. + */ + fun findSavedNetworkByRegex_null() { + `when`(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null) + } + + /** + * Mocks a saved network. + * + * @return WifiConfiguration - The mocked saved network + */ + fun findSavedNetworkByRegex_success(): WifiConfiguration { + val savedNetwork = createSavedNetwork(TEST_SSID) + `when`(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(savedNetwork) + return savedNetwork + } + + /** + * Mocks an empty saved network list. + * + * @see WiseFySearch.findSavedNetworksMatchingRegex + */ + fun findSavedNetworksByRegex_emptyList() { + `when`>(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(ArrayList()) + } + + /** + * Mocks no saved networks. + */ + fun findSavedNetworksByRegex_null() { + `when`>(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(null) + } + + /** + * Mocks a list of saved networks. + * + * @return List of WifiConfigurations - The mocked saved network list + */ + fun findSavedNetworksMatchingRegex_success(): List { + val savedNetworks = ArrayList() + val wiFiConfiguration = createSavedNetwork(TEST_SSID) + savedNetworks.add(wiFiConfiguration) + + `when`>(mockWiseFySearch.findSavedNetworksMatchingRegex(anyString())).thenReturn(savedNetworks) + return savedNetworks + } + + /** + * Mocks a list of nearby SSIDs. + * + * @return List of Strings - The mocked list of SSIDs. + */ + fun findSSIDsMatchingRegex_success(): List { + val ssids = ArrayList() + ssids.add(TEST_SSID) + `when`>(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids) + return ssids + } + + /** + * Mocks no matching SSIDs. + */ + fun findSSIDsMatchingRegex_null() { + `when`>(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null) + } + + /** + * Mocks if a network is already saved. + * + * @param saved If the network is already saved + */ + fun isNetworkASavedConfiguration(saved: Boolean) { + `when`(mockWiseFySearch.isNetworkASavedConfiguration(anyString())).thenReturn(saved) + } + + /** + * Mocks a basic return of two networks from WiseFySearch#removeEntriesWithLowerSignalStrength. + * + * @see WiseFySearch.removeEntriesWithLowerSignalStrength + * @return List of ScanResults - The mocked networks that will be returned + */ + fun removeEntriesWithLowerSignalStrength(): List { + val accessPoints = createMockAccessPointList(TEST_SSID, TEST_RSSI_LEVEL_HIGH, TEST_SSID2, TEST_RSSI_LEVEL_LOW) + `when`(mockWiseFySearch.removeEntriesWithLowerSignalStrength(ArgumentMatchers.anyList())).thenReturn(accessPoints) + return accessPoints + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/NullCallbackUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/NullCallbackUtil.kt new file mode 100644 index 00000000..68249f32 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/NullCallbackUtil.kt @@ -0,0 +1,329 @@ +package com.isupatches.wisefy + +import android.net.wifi.WifiInfo +import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks +import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks +import org.junit.Assert.fail + +/** + * A helper class to call methods in WiseFy with no callbacks. + * + * @author Patches + */ +@Suppress("TooGenericExceptionCaught") +internal class NullCallbackUtil internal constructor(private val wisefy: WiseFy) { + + /** + * To try to adding an open network with null callbacks. + * + * @param ssid The ssid to use when adding + */ + fun callAddOpenNetwork(ssid: String?) { + try { + wisefy.addOpenNetwork(ssid, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try adding a WEP network with null callbacks. + * + * @param ssid The ssid to use when adding + * @param password The password to use when adding + */ + fun callAddWEPNetwork(ssid: String?, password: String?) { + try { + wisefy.addWEPNetwork(ssid, password, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try adding a WPA2 network with null callbacks. + * + * @param ssid The ssid to use when adding + * @param password The password to use when adding + */ + fun callAddWPA2Network(ssid: String?, password: String?) { + try { + wisefy.addWPA2Network(ssid, password, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try to connect to a network with null callbacks. + * + * @param ssid The ssid to use when connecting + * + * @see WiseFy.connectToNetwork + */ + fun callConnectToNetwork(ssid: String?) { + try { + wisefy.connectToNetwork(ssid, TEST_TIMEOUT, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try disable wifi with null callbacks. + * + * @see WiseFy.disableWifi + */ + fun callDisableWifi() { + try { + wisefy.disableWifi(null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try to disconnect from the current network with null callbacks. + * + * @see WiseFy.disconnectFromCurrentNetwork + */ + fun callDisconnectFromCurrentNetwork() { + try { + wisefy.disconnectFromCurrentNetwork(null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try to enable wifi with null callbacks. + * + * @see WiseFy.enableWifi + */ + fun callEnableWifi() { + try { + wisefy.enableWifi(null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try to get the current network with null callbacks. + * + * @see WiseFy.getCurrentNetwork + */ + fun callGetCurrentNetwork() { + try { + wisefy.getCurrentNetwork(null) + } catch (npe: NullPointerException) { + fail() + } + + } + + fun callGetCurrentNetworkInfo() { + try { + wisefy.getCurrentNetworkInfo(null) + } catch (npe: NullPointerException) { + fail() + } + } + + /** + * To try and get the frequency of a network with null callbacks. + * + * @see WiseFy.getFrequency + */ + fun callGetFrequency() { + try { + wisefy.getFrequency(null as GetFrequencyCallbacks?) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try and get the frequency of a network with null callbacks. + * + * @param network The network to use when trying + * + * @see WiseFy.getFrequency + */ + fun callGetFrequency_networkProvided(network: WifiInfo?) { + try { + wisefy.getFrequency(network, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try to get nearby access points with null callbacks. + * + * @param filterDuplicates The filterDuplicates param to use when trying. + * + * @see WiseFy.getCurrentNetwork + */ + fun callGetNearbyAccessPoints(filterDuplicates: Boolean) { + try { + wisefy.getNearbyAccessPoints(filterDuplicates, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try to get the RSSI level of a nearby access point with null callbacks. + * + * @param takeHighest The takeHighest param to use when trying + * + * @see WiseFy.getRSSI + */ + fun callGetRSSI(takeHighest: Boolean) { + try { + wisefy.getRSSI(TEST_SSID, takeHighest, TEST_TIMEOUT, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try to retrieve a saved network with a given regex. + * + * @param regexForSSID The regex to use while trying + * + * @see WiseFy.getSavedNetwork + */ + fun callGetSavedNetwork(regexForSSID: String?) { + try { + wisefy.getSavedNetwork(regexForSSID, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try getting all nearby access points with a null callback. + * + * @see WiseFy.getSavedNetworks + */ + fun callGetSavedNetworks() { + try { + wisefy.getSavedNetworks(null as GetSavedNetworksCallbacks?) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try to get all nearby access points matching a given regex with null callbacks. + * + * @param regexForSSID The ssid to use while trying + * + * @see WiseFy.getSavedNetwork + */ + fun callGetSavedNetworks_withRegex(regexForSSID: String?) { + try { + wisefy.getSavedNetworks(regexForSSID, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try to remove a network with null callbacks. + * + * @param ssid The ssid to use while trying. + * + * @see WiseFy.removeNetwork + */ + fun callRemoveNetwork(ssid: String?) { + try { + wisefy.removeNetwork(ssid, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try and search for a nearby access point with null callbacks. + * + * @param ssid The ssid to use when trying + * @param filterDuplicates The filter duplicate param to use when trying + * + * @see WiseFy.searchForAccessPoint + */ + fun callSearchForAccessPoint(ssid: String?, filterDuplicates: Boolean) { + try { + wisefy.searchForAccessPoint(ssid, TEST_TIMEOUT, filterDuplicates, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try and search for nearby access points with null callbacks. + * + * @param regexForSSID The regex to use when trying + * @param filterDuplicates The filter duplicates param to use when trying + * + * @see WiseFy.searchForAccessPoints + */ + fun callSearchForAccessPoints(regexForSSID: String, filterDuplicates: Boolean) { + try { + wisefy.searchForAccessPoints(regexForSSID, filterDuplicates, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try and search for a nearby SSID given a regex with null callbacks. + * + * @param regexForSSID The regex to use when trying + * + * @see WiseFy.searchForSSID + */ + fun callSearchForSSID(regexForSSID: String?) { + try { + wisefy.searchForSSID(regexForSSID, TEST_TIMEOUT, null) + } catch (npe: NullPointerException) { + fail() + } + + } + + /** + * To try and search for nearby SSIDs that match a given regex with null callbacks. + * + * @param regexForSSID The regex to use when trying + * + * @see WiseFy.searchForSSIDs + */ + fun callSearchForSSIDs(regexForSSID: String?) { + try { + wisefy.searchForSSIDs(regexForSSID, null) + } catch (npe: NullPointerException) { + fail() + } + + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java deleted file mode 100644 index 9b84eeb2..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/RemoveNetworkTests.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.after; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class RemoveNetworkTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure_nullSSIDParam() { - assertEquals(false, mWiseFy.removeNetwork(null)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).removeNetwork(anyInt()); - } - - @Test - public void sync_failure_missingPrerequisites() { - missingPrerequisite(); - assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).removeNetwork(anyInt()); - } - - @Test - public void sync_failure_noSavedNetwork() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).removeNetwork(anyInt()); - } - - @Test - public void sync_failure() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); - - assertEquals(false, mWiseFy.removeNetwork(TEST_SSID)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).removeNetwork(anyInt()); - - } - - @Test - public void sync_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); - - assertEquals(true, mWiseFy.removeNetwork(TEST_SSID)); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).removeNetwork(anyInt()); - } - - @Test - public void async_failure_nullSSIDParam() { - RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); - mWiseFy.removeNetwork(null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).removeNetwork(anyInt()); - } - - @Test - public void async_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.removeNetwork(null, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).removeNetwork(anyInt()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisites() { - missingPrerequisite(); - RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); - mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).removeNetwork(anyInt()); - } - - @Test - public void async_failure_missingPrerequisites_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.removeNetwork(TEST_SSID, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).removeNetwork(anyInt()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_noSavedNetwork() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); - mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkNotFoundToRemove(); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).removeNetwork(anyInt()); - } - - @Test - public void async_failure_noSavedNetwork_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(null); - - try { - mWiseFy.removeNetwork(TEST_SSID, null); - verify(mMockWiFiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).removeNetwork(anyInt()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); - - RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); - mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureRemovingNetwork(); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).removeNetwork(anyInt()); - } - - @Test - public void async_failure_nullCallback() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); - - try { - mWiseFy.removeNetwork(TEST_SSID, null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).removeNetwork(anyInt()); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); - - RemoveNetworkCallbacks mockCallbacks = mock(RemoveNetworkCallbacks.class); - mWiseFy.removeNetwork(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkRemoved(); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).removeNetwork(anyInt()); - } - - @Test - public void async_success_nullCallback() { - WifiConfiguration wiFiConfiguration = new WifiConfiguration(); - wiFiConfiguration.SSID = TEST_SSID; - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSavedNetworkByRegex(anyString())).thenReturn(wiFiConfiguration); - - when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); - - try { - mWiseFy.removeNetwork(TEST_SSID, null); - verify(mMockWiFiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).removeNetwork(anyInt()); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java deleted file mode 100644 index fd809c79..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointTests.java +++ /dev/null @@ -1,268 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_TIMEOUT; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class SearchForAccessPointTests extends BaseAndroidJUnit4TestClass{ - - @Test - public void sync_failure_filterDuplicates_false_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForAccessPoint(null, TEST_TIMEOUT, false)); - } - - @Test - public void sync_failure_filterDuplicates_true_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForAccessPoint(null, TEST_TIMEOUT, true)); - } - - @Test - public void sync_failure_filterDuplicates_false_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void sync_failure_filterDuplicates_true_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void sync_failure_filterDuplicates_false() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void sync_failure_filterDuplicates_true() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void sync_success_filterDuplicates_false() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - assertEquals(accessPoint, mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void sync_success_filterDuplicates_true() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - assertEquals(accessPoint, mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void async_failure_filterDuplicates_false_nullSSIDParam() { - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(null, TEST_TIMEOUT, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void async_failure_filterDuplicates_false_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForAccessPoint(null, TEST_TIMEOUT, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_filterDuplicates_true_nullSSIDParam() { - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(null, TEST_TIMEOUT, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void async_failure_filterDuplicates_true_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForAccessPoint(null, TEST_TIMEOUT, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_filterDuplicates_false_missingPrerequisite() { - missingPrerequisite(); - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_filterDuplicates_false_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_filterDuplicates_true_missingPrerequisite() { - missingPrerequisite(); - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_filterDuplicates_true_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_filterDuplicates_false() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointNotFound(); - } - - @Test - public void async_failure_filterDuplicates_false_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_filterDuplicates_true() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointNotFound(); - } - - - @Test - public void async_failure_filterDuplicates_true_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_filterDuplicates_false() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointFound(accessPoint); - } - - @Test - public void async_success_filterDuplicates_false_nullCallback() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - try { - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_filterDuplicates_true() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - SearchForAccessPointCallbacks mockCallbacks = mock(SearchForAccessPointCallbacks.class); - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointFound(accessPoint); - } - - @Test - public void async_success_filterDuplicates_true_nullCallback() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - try { - mWiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true, null); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java deleted file mode 100644 index 3f00f754..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForAccessPointsTests.java +++ /dev/null @@ -1,281 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class SearchForAccessPointsTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure_filterDuplicates_false_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForAccessPoints(null, false)); - } - - @Test - public void sync_failure_filterDuplicates_true_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForAccessPoints(null, true)); - } - - @Test - public void sync_failure_filterDuplicates_false_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, false)); - } - - @Test - public void sync_failure_filterDuplicates_true_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, true)); - } - - @Test - public void sync_failure_filterDuplicates_false() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, false)); - } - - @Test - public void sync_failure_filterDuplicates_true() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForAccessPoints(TEST_SSID, true)); - } - - @Test - public void sync_success_filterDuplicates_false() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - assertEquals(accessPoints, mWiseFy.searchForAccessPoints(TEST_SSID, false)); - } - - @Test - public void sync_success_filterDuplicates_true() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - assertEquals(accessPoints, mWiseFy.searchForAccessPoints(TEST_SSID, true)); - } - - @Test - public void async_failure_filterDuplicates_false_nullSSIDParam() { - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(null, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void async_failure_filterDuplicates_false_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForAccessPoints(null, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_filterDuplicates_true_nullSSIDParam() { - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(null, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void async_failure_filterDuplicates_true_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForAccessPoints(null, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_filterDuplicates_false_missingPrerequisite() { - missingPrerequisite(); - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_filterDuplicates_false_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForAccessPoints(TEST_SSID, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_filterDuplicates_true_missingPrerequisite() { - missingPrerequisite(); - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_filterDuplicates_true_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForAccessPoints(TEST_SSID, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_filterDuplicates_false() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noAccessPointsFound(); - } - - @Test - public void async_failure_filterDuplicates_false_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.searchForAccessPoints(TEST_SSID, false, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_filterDuplicates_true() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noAccessPointsFound(); - } - - - @Test - public void async_failure_filterDuplicates_true_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.searchForAccessPoints(TEST_SSID, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_filterDuplicates_false() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).foundAccessPoints(accessPoints); - } - - @Test - public void async_success_filterDuplicates_false_nullCallback() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - try { - mWiseFy.searchForAccessPoints(TEST_SSID, true, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success_filterDuplicates_true() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - SearchForAccessPointsCallbacks mockCallbacks = mock(SearchForAccessPointsCallbacks.class); - mWiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).foundAccessPoints(accessPoints); - } - - @Test - public void async_success_filterDuplicates_true_nullCallback() { - List accessPoints = new ArrayList<>(); - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - accessPoints.add(accessPoint); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointsMatchingRegex(anyString(), anyBoolean())).thenReturn(accessPoints); - - try { - mWiseFy.searchForAccessPoints(TEST_SSID, true, null); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java deleted file mode 100644 index 1c5abd68..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDTests.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_TIMEOUT; -import static junit.framework.Assert.fail; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class SearchForSSIDTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForSSID(null, TEST_TIMEOUT)); - } - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT)); - } - - @Test - public void sync_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT)); - } - - @Test - public void sync_success() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - assertEquals(TEST_SSID, mWiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT)); - } - - @Test - public void async_failure_nullSSIDParam() { - SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); - mWiseFy.searchForSSID(null, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void async_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForSSID(null, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); - mWiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); - mWiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).ssidNotFound(); - } - - - @Test - public void async_failure_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(null); - - try { - mWiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoint.level = -35; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - SearchForSSIDCallbacks mockCallbacks = mock(SearchForSSIDCallbacks.class); - mWiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).ssidFound(TEST_SSID); - } - - @Test - public void async_success_nullCallback() { - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findAccessPointByRegex(anyString(), anyInt(), anyBoolean())).thenReturn(accessPoint); - - try { - mWiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT, null); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java deleted file mode 100644 index e0be19a8..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/SearchForSSIDsTests.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks; -import com.isupatches.wisefy.constants.WiseFyCodes; -import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static junit.framework.Assert.fail; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -public class SearchForSSIDsTests extends BaseAndroidJUnit4TestClass { - - @Test - public void sync_failure_nullSSIDParam() { - assertEquals(null, mWiseFy.searchForSSIDs(null)); - } - - @Test - public void sync_failure_missingPrerequisite() { - missingPrerequisite(); - assertEquals(null, mWiseFy.searchForSSIDs(TEST_SSID)); - } - - @Test - public void sync_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); - - assertEquals(null, mWiseFy.searchForSSIDs(TEST_SSID)); - } - - @Test - public void sync_success() { - List ssids = new ArrayList<>(); - ssids.add(TEST_SSID); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); - - assertEquals(ssids, mWiseFy.searchForSSIDs(TEST_SSID)); - } - - @Test - public void async_failure_nullSSIDParam() { - SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); - mWiseFy.searchForSSIDs(null, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - - @Test - public void async_failure_nullSSIDParam_nullCallback() { - try { - mWiseFy.searchForSSIDs(null, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure_missingPrerequisite() { - missingPrerequisite(); - SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); - mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - - @Test - public void async_failure_missingPrerequisite_nullCallback() { - missingPrerequisite(); - try { - mWiseFy.searchForSSIDs(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_failure() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); - - SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); - mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSSIDsFound(); - } - - - @Test - public void async_failure_nullCallback() { - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(null); - - try { - mWiseFy.searchForSSIDs(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } - - @Test - public void async_success() { - List ssids = new ArrayList<>(); - ssids.add(TEST_SSID); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); - - SearchForSSIDsCallbacks mockCallbacks = mock(SearchForSSIDsCallbacks.class); - mWiseFy.searchForSSIDs(TEST_SSID, mockCallbacks); - verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSSIDs(ssids); - } - - @Test - public void async_success_nullCallback() { - List ssids = new ArrayList<>(); - ssids.add(TEST_SSID); - - WiseFySearch mockWiseFySearch = mock(WiseFySearch.class); - mWiseFy.mWiseFySearch = mockWiseFySearch; - when(mockWiseFySearch.findSSIDsMatchingRegex(anyString())).thenReturn(ssids); - - try { - mWiseFy.searchForSSIDs(TEST_SSID, null); - } catch (NullPointerException npe) { - fail(); - } - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/VerificationUtil.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/VerificationUtil.kt new file mode 100644 index 00000000..47694735 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/VerificationUtil.kt @@ -0,0 +1,206 @@ +package com.isupatches.wisefy + +import android.net.ConnectivityManager +import android.net.wifi.WifiConfiguration +import android.net.wifi.WifiManager +import org.mockito.ArgumentMatchers.any +import org.mockito.ArgumentMatchers.anyBoolean +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.Mockito.after +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * A helper class with common logic to verify operations with WifiManager. + * + * @see WifiManager + * + * @author Patches + */ +internal class VerificationUtil internal constructor( + private val mockConnectivityManager: ConnectivityManager, + private val mockWifiManager: WifiManager +) { + + /* + * Anti-methods (checking for things TO NOT happen) + */ + + /** + * To verify no attempt to add a network was made. + * + * @see WifiManager.addNetwork + */ + fun didNoTryToAddNetwork() { + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).addNetwork(any(WifiConfiguration::class.java)) + } + + /** + * To verify no attempt attempt to connect to a network was made. + * + * @see WifiManager.enableNetwork + * @see WifiManager.reconnect + */ + fun didNotTryToConnectToNetwork() { + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).enableNetwork(anyInt(), anyBoolean()) + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).reconnect() + } + + /** + * To verify no attempt to disable wifi was made. + * + * @see WifiManager.setWifiEnabled + */ + fun didNotTryToDisableWifi() { + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).isWifiEnabled = false + } + + /** + * To verify no attempt to disconnect the device from it's current network was made. + * + * @see WifiManager.disconnect + */ + fun didNotTryToDisconnectFromCurrentNetwork() { + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).disconnect() + } + + /** + * To verify no attempt to enable wifi was made. + * + * @see WifiManager.setWifiEnabled + */ + fun didNotTryToEnableWifi() { + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).isWifiEnabled = true + } + + /** + * To verify no attempt to get the device's current network was made. + * + * @see WifiManager.getConnectionInfo + */ + fun didNotTryToGetCurrentNetwork() { + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).connectionInfo + } + + fun didNotTryToGetCurrentNetworkInfo() { + verify(mockConnectivityManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).activeNetworkInfo + } + + /** + * To verify no attempt to get nearby access points was made. + * + * @see WifiManager.getScanResults + */ + fun didNotTryToGetNearbyAccessPoints() { + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).scanResults + } + + /** + * To verify no attempt to get saved networks was made. + * + * @see WifiManager.getConfiguredNetworks + */ + fun didNotTryToGetSavedNetworks() { + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).configuredNetworks + } + + /** + * To verify no attempt to remove a network was made. + * + * @see WifiManager.removeNetwork + */ + fun didNotTryToRemoveNetwork() { + verify(mockWifiManager, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).removeNetwork(anyInt()) + } + + /* + * Positive-methods (checking for things TO happen) + */ + + /** + * To verify no attempt to add a network was made. + * + * @see WifiManager.addNetwork + */ + fun triedToAddNetwork() { + verify(mockWifiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).addNetwork(any(WifiConfiguration::class.java)) + } + + /** + * To verify an attempt to connect to a network was made. + * + * @see WifiManager.enableNetwork + * @see WifiManager.reconnect + */ + fun triedToConnectToNetwork() { + verify(mockWifiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).enableNetwork(anyInt(), anyBoolean()) + verify(mockWifiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).reconnect() + } + + /** + * To verify an attempt to disable wifi was made. + * + * @see WifiManager.setWifiEnabled + */ + fun triedToDisableWifi() { + verify(mockWifiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).isWifiEnabled = false + } + + /** + * To verify an attempt to disconnect the device from it's current network was made. + * + * @see WifiManager.disconnect + */ + fun triedToDisconnectFromCurrentNetwork() { + verify(mockWifiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disconnect() + } + + /** + * To verify an attempt to enable wifi was made. + * + * @see WifiManager.setWifiEnabled + */ + fun triedToEnableWifi() { + verify(mockWifiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).isWifiEnabled = true + } + + /** + * To verify an attempt to get the device's current network was made. + * + * @see WifiManager.getConnectionInfo + */ + fun triedToGetCurrentNetwork() { + verify(mockWifiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).connectionInfo + } + + fun triedToGetCurrentNetworkInfo() { + verify(mockConnectivityManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).activeNetworkInfo + } + + /** + * To verify an attempt to get nearby access points was made. + * + * @see WifiManager.getScanResults + */ + fun triedToGetNearbyAccessPoints() { + verify(mockWifiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).scanResults + } + + /** + * To verify an attempt to get saved networks was made. + * + * @see WifiManager.getConfiguredNetworks + */ + fun triedToGetSavedNetworks() { + verify(mockWifiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).configuredNetworks + } + + /** + * To verify an attempt to remove a network was made. + * + * @see WifiManager.removeNetwork + */ + fun triedToRemoveNetwork() { + verify(mockWifiManager, timeout(VERIFICATION_SUCCESS_TIMEOUT)).removeNetwork(anyInt()) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java deleted file mode 100644 index 0c697884..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.java +++ /dev/null @@ -1,360 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import android.net.wifi.WifiInfo; -import org.junit.Before; -import org.junit.Test; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -import static com.isupatches.wisefy.base.TestUtils.TEST_TIMEOUT; -import static com.isupatches.wisefy.base.TestUtils.TEST_TYPE1; -import static com.isupatches.wisefy.base.TestUtils.TEST_TYPE2; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class WiseFyConnectionTests extends BaseAndroidJUnit4TestClass { - - @Before - public void setUp() { - super.setUp(); - WiseFyConnection.getInstance().mWiseFyPrerequisites.setWifiManager(mMockWiFiManager); - WiseFyConnection.getInstance().mWiseFyPrerequisites.setConnectivityManager(mMockConnectivityManager); - } - - /* - * isCurrentNetworkConnectedToSSID tests - */ - - @Test - public void isCurrentNetworkConnectedToSSID_failure_nullSSIDParam() { - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(null)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_nullConnectionInfo() { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_nullSSID() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(null); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(null)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_differentSSID() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID2); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_notAvailable() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_notAvailableOrConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_failure_notConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - @Test - public void isCurrentNetworkConnectedToSSID_success() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertTrue(WiseFyConnection.getInstance().isCurrentNetworkConnectedToSSID(TEST_SSID)); - } - - /* - * isNetworkConnected tests - */ - - @Test - public void isNetworkConnected_failure_nullNetworkInfoParam() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnected(null)); - } - - @Test - public void isNetworkConnected_failure_notAvailable() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); - } - - @Test - public void isNetworkConnected_failure_notAvailableOrConnected() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); - } - - @Test - public void isNetworkConnected_failure_notConnected() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); - } - - @Test - public void isNetworkConnected_success() { - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertTrue(WiseFyConnection.getInstance().isNetworkConnected(networkInfo)); - } - - /* - * isNetworkConnectedAndMatchesType tests - */ - - @Test - public void isNetworkConnectedAndMatchesType_failure_nullNetworkInfoParam() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(null, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_failure_notAvailable() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_failure_notAvailableOrConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_failure_notConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_failure_nullTypeName() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(networkInfo.getTypeName()).thenReturn(null); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_failure_differentTypeName() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(networkInfo.getTypeName()).thenReturn(TEST_TYPE2); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - @Test - public void isNetworkConnectedAndMatchesType_success() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(networkInfo.getTypeName()).thenReturn(TEST_TYPE1); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertTrue(WiseFyConnection.getInstance().isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)); - } - - /* - * waitToConnectToSSID tests - */ - - @Test - public void waitToConnectToSSID_failure_nullSSIDParam() { - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(null, TEST_TIMEOUT)); - } - - @Test - public void waitToConnectToSSID_failure_nullConnectionInfo() { - when(mMockWiFiManager.getConnectionInfo()).thenReturn(null); - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)); - } - - @Test - public void waitToConnectToSSID_failure_nullSSID() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(null); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(null, TEST_TIMEOUT)); - } - - @Test - public void waitToConnectToSSID_failure_differentSSID() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID2); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)); - } - - @Test - public void waitToConnectToSSID_failure_notAvailable() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)); - } - - @Test - public void waitToConnectToSSID_failure_notAvailableOrConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(false); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)); - } - - @Test - public void waitToConnectToSSID_failure_notConnected() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(false); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertFalse(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)); - } - - @Test - public void waitToConnectToSSID_success() { - WifiInfo currentNetwork = mock(WifiInfo.class); - when(currentNetwork.getSSID()).thenReturn(TEST_SSID); - when(mMockWiFiManager.getConnectionInfo()).thenReturn(currentNetwork); - - NetworkInfo networkInfo = mock(NetworkInfo.class); - when(networkInfo.isAvailable()).thenReturn(true); - when(networkInfo.isConnected()).thenReturn(true); - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); - - assertTrue(WiseFyConnection.getInstance().waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.kt new file mode 100644 index 00000000..7d79dae0 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyConnectionTests.kt @@ -0,0 +1,190 @@ +package com.isupatches.wisefy + +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue + +import org.junit.Before +import org.junit.Test + +/** + * Used to test the WiseFyConnection class and functionality determining various connection states. + * + * @author Patches + */ +internal class WiseFyConnectionTests : BaseAndroidJUnit4TestClass() { + + private lateinit var wisefyConnection: WiseFyConnection + + @Before fun setUp() { + wisefyConnection = WiseFyConnectionImpl.create(mockConnectivityManager, mockWifiManager) + } + + /* + * isCurrentNetworkConnectedToSSID tests + */ + + @Test fun isCurrentNetworkConnectedToSSID_failure_nullSSIDParam() { + assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(null)) + } + + @Test fun isCurrentNetworkConnectedToSSID_failure_nullConnectionInfo() { + mockNetworkUtil.currentNetwork_null() + assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) + } + + @Test fun isCurrentNetworkConnectedToSSID_failure_nullSSID() { + mockNetworkUtil.currentNetwork(null) + mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) + } + + @Test fun isCurrentNetworkConnectedToSSID_failure_differentSSID() { + mockNetworkUtil.currentNetwork(TEST_SSID2) + mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) + } + + @Test fun isCurrentNetworkConnectedToSSID_failure_notAvailable() { + mockNetworkUtil.currentNetwork(TEST_SSID) + mockNetworkUtil.currentNetworkConnectionStatus(false, true, null) + assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) + } + + @Test fun isCurrentNetworkConnectedToSSID_failure_notAvailableOrConnected() { + mockNetworkUtil.currentNetwork(TEST_SSID) + mockNetworkUtil.currentNetworkConnectionStatus(false, false, null) + assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) + } + + @Test fun isCurrentNetworkConnectedToSSID_failure_notConnected() { + mockNetworkUtil.currentNetwork(TEST_SSID) + mockNetworkUtil.currentNetworkConnectionStatus(true, false, null) + assertFalse(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) + } + + @Test fun isCurrentNetworkConnectedToSSID_success() { + mockNetworkUtil.currentNetwork(TEST_SSID) + mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + assertTrue(wisefyConnection.isCurrentNetworkConnectedToSSID(TEST_SSID)) + } + + /* + * isNetworkConnected tests + */ + + @Test fun isNetworkConnected_failure_nullNetworkInfoParam() { + assertFalse(wisefyConnection.isNetworkConnected(null)) + } + + @Test fun isNetworkConnected_failure_notAvailable() { + val networkInfo = mockNetworkUtil.currentNetworkConnectionStatus(false, true, null) + assertFalse(wisefyConnection.isNetworkConnected(networkInfo)) + } + + @Test fun isNetworkConnected_failure_notAvailableOrConnected() { + val networkInfo = mockNetworkUtil.currentNetworkConnectionStatus(false, false, null) + assertFalse(wisefyConnection.isNetworkConnected(networkInfo)) + } + + @Test fun isNetworkConnected_failure_notConnected() { + val networkInfo = mockNetworkUtil.currentNetworkConnectionStatus(true, false, null) + assertFalse(wisefyConnection.isNetworkConnected(networkInfo)) + } + + @Test fun isNetworkConnected_success() { + val networkInfo = mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + assertTrue(wisefyConnection.isNetworkConnected(networkInfo)) + } + + /* + * isNetworkConnectedAndMatchesType tests + */ + + @Test fun isNetworkConnectedAndMatchesType_failure_nullNetworkInfo() { + assertFalse(wisefyConnection.isNetworkConnectedAndMatchesType(null, TEST_TYPE1)) + } + + @Test fun isNetworkConnectedAndMatchesType_failure_notAvailable() { + mockNetworkUtil.currentNetwork(TEST_SSID) + val networkInfo = mockNetworkUtil.currentNetworkConnectionStatus(false, true, TEST_TYPE1) + assertFalse(wisefyConnection.isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)) + } + + @Test fun isNetworkConnectedAndMatchesType_failure_notAvailableOrConnected() { + mockNetworkUtil.currentNetwork(TEST_SSID) + val networkInfo = mockNetworkUtil.currentNetworkConnectionStatus(false, false, TEST_TYPE1) + assertFalse(wisefyConnection.isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)) + } + + @Test fun isNetworkConnectedAndMatchesType_failure_notConnected() { + mockNetworkUtil.currentNetwork(TEST_SSID) + val networkInfo = mockNetworkUtil.currentNetworkConnectionStatus(true, false, TEST_TYPE1) + assertFalse(wisefyConnection.isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)) + } + + @Test fun isNetworkConnectedAndMatchesType_failure_nullTypeName() { + mockNetworkUtil.currentNetwork(TEST_SSID) + val networkInfo = mockNetworkUtil.currentNetworkConnectionStatus(true, true, null) + assertFalse(wisefyConnection.isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)) + } + + @Test fun isNetworkConnectedAndMatchesType_failure_differentTypeName() { + mockNetworkUtil.currentNetwork(TEST_SSID) + val networkInfo = mockNetworkUtil.currentNetworkConnectionStatus(true, true, TEST_TYPE2) + assertFalse(wisefyConnection.isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)) + } + + @Test fun isNetworkConnectedAndMatchesType_success() { + mockNetworkUtil.currentNetwork(TEST_SSID) + val networkInfo = mockNetworkUtil.currentNetworkConnectionStatus(true, true, TEST_TYPE1) + assertTrue(wisefyConnection.isNetworkConnectedAndMatchesType(networkInfo, TEST_TYPE1)) + } + + /* + * waitToConnectToSSID tests + */ + + @Test fun waitToConnectToSSID_failure_nullSSIDParam() { + assertFalse(wisefyConnection.waitToConnectToSSID(null, TEST_TIMEOUT)) + } + + @Test fun waitToConnectToSSID_failure_nullConnectionInfo() { + mockNetworkUtil.currentNetwork_null() + assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) + } + + @Test fun waitToConnectToSSID_failure_nullSSID() { + mockNetworkUtil.currentNetwork(null) + assertFalse(wisefyConnection.waitToConnectToSSID(null, TEST_TIMEOUT)) + } + + @Test fun waitToConnectToSSID_failure_differentSSID() { + mockNetworkUtil.currentNetworkConnectionStatus(true, true, TEST_TYPE1) + mockNetworkUtil.currentNetwork(TEST_SSID2) + assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) + } + + @Test fun waitToConnectToSSID_failure_notAvailable() { + mockNetworkUtil.currentNetworkConnectionStatus(false, true, TEST_TYPE1) + mockNetworkUtil.currentNetwork(TEST_SSID) + assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) + } + + @Test fun waitToConnectToSSID_failure_notAvailableOrConnected() { + mockNetworkUtil.currentNetworkConnectionStatus(false, false, TEST_TYPE1) + mockNetworkUtil.currentNetwork(TEST_SSID) + assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) + } + + @Test fun waitToConnectToSSID_failure_notConnected() { + mockNetworkUtil.currentNetworkConnectionStatus(true, false, TEST_TYPE1) + mockNetworkUtil.currentNetwork(TEST_SSID) + assertFalse(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) + } + + @Test fun waitToConnectToSSID_success() { + mockNetworkUtil.currentNetworkConnectionStatus(true, true, TEST_TYPE1) + mockNetworkUtil.currentNetwork(TEST_SSID) + assertTrue(wisefyConnection.waitToConnectToSSID(TEST_SSID, TEST_TIMEOUT)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrechecksTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrechecksTests.kt new file mode 100644 index 00000000..b839cb66 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrechecksTests.kt @@ -0,0 +1,183 @@ +package com.isupatches.wisefy + +import com.isupatches.wisefy.constants.DEFAULT_PRECHECK_RETURN_CODE +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import com.isupatches.wisefy.constants.NETWORK_ALREADY_CONFIGURED + +import org.junit.Assert.assertEquals + + +import org.junit.Test + +/** + * Used to test the WiseFyPrechecks class and functionality pertaining to being able to continue + * with processing logic. + * + * @author Patches + */ +internal class WiseFyPrechecksTests : BaseAndroidJUnit4TestClass() { + + private val wisefyPrechecks: WiseFyPrechecks = WiseFyPrechecksImpl.create(mockWiseFySearch) + + @Test fun addNetworkPrechecks_failure_nullSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.addNetworkPrechecks(null).code) + } + + @Test fun addNetworkPrechecks_failure_networkAlreadySaved() { + mockWiseFySearchUtil.isNetworkASavedConfiguration(true) + assertEquals(NETWORK_ALREADY_CONFIGURED, wisefyPrechecks.addNetworkPrechecks(TEST_SSID).code) + } + + @Test fun addNetworkPrechecks_success() { + mockWiseFySearchUtil.isNetworkASavedConfiguration(false) + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.addNetworkPrechecks(TEST_SSID).code) + } + + @Test fun addNetworkPrechecks_withPassword_failure_nullSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.addNetworkPrechecks(null, WEP_NETWORK_PASSWORD).code) + } + + @Test fun addNetworkPrechecks_withPassword_failure_nullPasswordParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.addNetworkPrechecks(WEP_NETWORK_SSID, null).code) + } + + @Test fun addNetworkPrechecks_withPassword_failure_networkAlreadySaved() { + mockWiseFySearchUtil.isNetworkASavedConfiguration(true) + assertEquals(NETWORK_ALREADY_CONFIGURED, wisefyPrechecks.addNetworkPrechecks(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD).code) + } + + @Test fun addNetworkPrechecks_withPassword_success() { + mockWiseFySearchUtil.isNetworkASavedConfiguration(false) + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.addNetworkPrechecks(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD).code) + } + + @Test fun connectToNetworkPrechecks_failure_nullParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.connectToNetworkPrechecks(null).code) + } + @Test fun connectToNetworkPrechecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.connectToNetworkPrechecks(TEST_SSID).code) + } + + @Test fun disableWifiChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.disableWifiChecks().code) + } + + @Test fun disconnectFromCurrentNetworkChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.disconnectFromCurrentNetworkChecks().code) + } + + @Test fun enableWifiChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.enableWifiChecks().code) + } + + @Test fun getCurrentNetworkChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getCurrentNetworkChecks().code) + } + + @Test fun getIPChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getIPChecks().code) + } + + @Test fun getNearbyAccessPointsChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getNearbyAccessPointsChecks().code) + } + + @Test fun getRSSIChecks_failure_nullRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.getRSSIChecks(null).code) + } + + @Test fun getRSSIChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getRSSIChecks(TEST_SSID).code) + } + + @Test fun getSavedNetworkChecks_failure_nullRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.getSavedNetworkChecks(null).code) + } + + @Test fun getSavedNetworkChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getSavedNetworkChecks(TEST_SSID).code) + } + + @Test fun getSavedNetworksChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getSavedNetworksChecks().code) + } + + @Test fun getSavedNetworksChecks_withRegex_failure_nullRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.getSavedNetworksChecks(null).code) + } + + @Test fun getSavedNetworksChecks_with_regex_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.getSavedNetworksChecks(TEST_SSID).code) + } + + @Test fun isDeviceConnectedToMobileNetworkChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isDeviceConnectedToMobileNetworkChecks().code) + } + + @Test fun isDeviceConnectedToMobileOrWifiNetworkChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isDeviceConnectedToMobileOrWifiNetworkChecks().code) + } + + @Test fun isDeviceConnectedToSSIDChecks_failure_nullSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.isDeviceConnectedToSSIDChecks(null).code) + } + + @Test fun isDeviceConnectedToSSIDChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isDeviceConnectedToSSIDChecks(TEST_SSID).code) + } + + @Test fun isDeviceConnectedToWifiNetworkChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isDeviceConnectedToWifiNetworkChecks().code) + } + @Test fun isDeviceRoamingChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isDeviceRoamingChecks().code) + } + + @Test fun isNetworkSavedChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isNetworkSavedChecks().code) + } + + @Test fun isWifiEnabledChecks() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.isWifiEnabledChecks().code) + } + + @Test fun removeNetworkCheck_failure_nullSSIDToRemoveParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.removeNetworkCheck(null).code) + } + + @Test fun removeNetworkCheck_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.removeNetworkCheck(TEST_SSID).code) + } + + @Test fun searchForAccessPointChecks_failure_nullRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForAccessPointChecks(null).code) + } + + @Test fun searchForAccessPointChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.searchForAccessPointChecks(TEST_SSID).code) + } + + @Test fun searchForAccessPointsChecks_failure_nullRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForAccessPointsChecks(null).code) + } + + @Test fun searchForAccessPointsChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.searchForAccessPointsChecks(TEST_SSID).code) + } + + @Test fun searchForSSIDChecks_failure_nullRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForSSIDChecks(null).code) + } + + @Test fun searchForSSIDChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.searchForSSIDChecks(TEST_SSID).code) + } + + @Test fun searchForSSIDsChecks_failure_nullRegexForSSIDParam() { + assertEquals(MISSING_PARAMETER, wisefyPrechecks.searchForSSIDsChecks(null).code) + } + + @Test fun searchForSSIDsChecks_success() { + assertEquals(DEFAULT_PRECHECK_RETURN_CODE, wisefyPrechecks.searchForSSIDsChecks(TEST_SSID).code) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java deleted file mode 100644 index f3f17a3d..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyPrerequisitesTests.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.isupatches.wisefy; - - -import org.junit.Test; -import static junit.framework.Assert.*; - - -public class WiseFyPrerequisitesTests extends BaseAndroidJUnit4TestClass { - - @Test - public void hasPrerequisites_nullWifiManager() { - WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); - WiseFyPrerequisites.getInstance().setWifiManager(null); - assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); - } - - @Test - public void hasPrerequisites_nullConnectivityManager() { - WiseFyPrerequisites.getInstance().setConnectivityManager(null); - WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); - assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); - } - - @Test - public void hasPrerequisites_noManagers() { - WiseFyPrerequisites.getInstance().setConnectivityManager(null); - WiseFyPrerequisites.getInstance().setWifiManager(null); - assertFalse(WiseFyPrerequisites.getInstance().hasPrerequisites()); - } - - @Test - public void hasPrerequisites_bothManagers() { - WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); - WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); - assertTrue(WiseFyPrerequisites.getInstance().hasPrerequisites()); - } - - @Test - public void connectivityManager_getterAndSetter() { - WiseFyPrerequisites.getInstance().setConnectivityManager(mMockConnectivityManager); - assertEquals(mMockConnectivityManager, WiseFyPrerequisites.getInstance().getConnectivityManager()); - } - - @Test - public void wifiManager_getterAndSetter() { - WiseFyPrerequisites.getInstance().setWifiManager(mMockWiFiManager); - assertEquals(mMockWiFiManager, WiseFyPrerequisites.getInstance().getWifiManager()); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java deleted file mode 100644 index 25a58d7c..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.java +++ /dev/null @@ -1,857 +0,0 @@ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import android.net.wifi.WifiConfiguration; -import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID2; -import static com.isupatches.wisefy.base.TestUtils.TEST_SSID3; -import static com.isupatches.wisefy.base.TestUtils.TEST_TIMEOUT; -import static junit.framework.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -public class WiseFySearchTests extends BaseAndroidJUnit4TestClass { - - - /* - * findAccessPointByRegex tests - */ - - @Test - public void findAccessPointByRegex_failure_nullAccessPoints_takeHighest_false() { - when(mMockWiFiManager.getScanResults()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void findAccessPointByRegex_failure_nullAccessPoints_takeHighest_true() { - when(mMockWiFiManager.getScanResults()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_false() { - when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_true() { - when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void findAccessPointByRegex_failure_nullAccessPoint_takeHighest_false() { - List accessPoints = new ArrayList<>(); - accessPoints.add(null); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void findAccessPointByRegex_failure_nullAccessPoint_takeHighest_true() { - List accessPoints = new ArrayList<>(); - accessPoints.add(null); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void findAccessPointByRegex_failure_nullSSID_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = null; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void findAccessPointByRegex_failure_nullSSID_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = null; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = TEST_SSID2; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = TEST_SSID2; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID2; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID3; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void findAccessPointByRegex_failure_multipleNnonMatchingSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1= mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID2; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID3; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void findAccessPointByRegex_success_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void findAccessPointByRegex_success_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void findAccessPointByRegex_success_multipleSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID2; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void findAccessPointByRegex_success_multipleSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID2; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)); - } - - @Test - public void findAccessPointByRegex_success_multipleSameSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint1, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)); - } - - @Test - public void findAccessPointByRegex_success_multipleSameSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoint2, mWiseFy.mWiseFySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)); - } - - /* - * findAccessPointsMatchingRegex tests - */ - - @Test - public void findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_false() { - when(mMockWiFiManager.getScanResults()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_true() { - when(mMockWiFiManager.getScanResults()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_false() { - when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_true() { - when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_false() { - List accessPoints = new ArrayList<>(); - accessPoints.add(null); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_true() { - List accessPoints = new ArrayList<>(); - accessPoints.add(null); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = null; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = null; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = TEST_SSID2; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint= mock(ScanResult.class); - accessPoint.SSID = TEST_SSID2; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID2; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID3; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_failure_multipleNnonMatchingSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1= mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID2; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID3; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_success_takeHighest_false() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoints, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_success_takeHighest_true() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(accessPoints, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_success_multipleSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID2; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_success_multipleSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID2; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - @Test - public void findAccessPointsMatchingRegex_success_multipleSameSSIDs_takeHighest_false() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - expectedResults.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, false)); - } - - @Test - public void findAccessPointsMatchingRegex_success_multipleSameSSIDs_takeHighest_true() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - expectedResults.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findAccessPointsMatchingRegex(TEST_SSID, true)); - } - - /* - * findSavedNetworkByRegex tests - */ - - @Test - public void findSavedNetworkByRegex_failure_nullSavedNetworkList() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_failure_emptySavedNetworkList() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_failure_nullWifiConfiguration() { - List wifiList = new ArrayList<>(); - wifiList.add(null); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_failure_nullSSID() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = null; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_failure_nonMatchingSSID() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_failure_multipleNonMatchingSSIDs() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); - mWiFiConfiguration1.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration1); - - WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); - mWiFiConfiguration2.SSID = TEST_SSID3; - wifiList.add(mWiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_success() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(mWiFiConfiguration, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworkByRegex_success_multipleSSIDs() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); - mWiFiConfiguration1.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration1); - - WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); - mWiFiConfiguration2.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(mWiFiConfiguration1, mWiseFy.mWiseFySearch.findSavedNetworkByRegex(TEST_SSID)); - } - - /* - * findSavedNetworksMatchingRegex tests - */ - - @Test - public void findSavedNetworksMatchingRegex_failure_nullSavedNetworkList() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_failure_emptySavedNetworkList() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_failure_nullWifiConfiguration() { - List wifiList = new ArrayList<>(); - wifiList.add(null); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_failure_nullSSID() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = null; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_failure_nonMatchingSSID() { - List wifiList = new ArrayList<>(); - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_failure_multipleNonMatchingSSIDs() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); - mWiFiConfiguration1.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration1); - - WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); - mWiFiConfiguration2.SSID = TEST_SSID3; - wifiList.add(mWiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(null, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_success() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(wifiList, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(TEST_SSID)); - } - - @Test - public void findSavedNetworksMatchingRegex_success_multipleSSIDs() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration1 = new WifiConfiguration(); - mWiFiConfiguration1.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration1); - - WifiConfiguration mWiFiConfiguration2 = new WifiConfiguration(); - mWiFiConfiguration2.SSID = TEST_SSID2; - wifiList.add(mWiFiConfiguration2); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(wifiList, mWiseFy.mWiseFySearch.findSavedNetworksMatchingRegex(".*Test.*")); - } - - /* - * findSSIDsMatchingRegex tests - */ - - @Test - public void findSSIDsMatchingRegex_failure_nullAccessPoints() { - when(mMockWiFiManager.getScanResults()).thenReturn(null); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_failure_emptySavedNetworkList() { - when(mMockWiFiManager.getScanResults()).thenReturn(new ArrayList()); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_failure_nullWifiConfiguration() { - List accessPoints = new ArrayList<>(); - accessPoints.add(null); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_failure_nullSSID() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = null; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_failure_nonMatchingSSID() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID2; - accessPoints.add(accessPoint); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_failure_multipleNonMatchingSSIDs() { - List accessPoints = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID2; - accessPoints.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID3; - accessPoints.add(accessPoint2); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(null, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_success() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint = mock(ScanResult.class); - accessPoint.SSID = TEST_SSID; - accessPoints.add(accessPoint); - expectedResults.add(TEST_SSID); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(TEST_SSID)); - } - - @Test - public void findSSIDsMatchingRegex_success_multipleSSIDs() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoints.add(accessPoint1); - expectedResults.add(TEST_SSID); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoints.add(accessPoint2); - expectedResults.add(TEST_SSID); - - when(mMockWiFiManager.getScanResults()).thenReturn(accessPoints); - assertEquals(expectedResults, mWiseFy.mWiseFySearch.findSSIDsMatchingRegex(".*Test.*")); - } - - /* - * isNetworkASavedConfiguration tests - */ - - @Test - public void isNetworkASavedConfiguration_failure() { - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(new ArrayList()); - assertEquals(false, mWiseFy.mWiseFySearch.isNetworkASavedConfiguration(TEST_SSID)); - } - - @Test - public void isNetworkASavedConfiguration_success() { - List wifiList = new ArrayList<>(); - - WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); - mWiFiConfiguration.SSID = TEST_SSID; - wifiList.add(mWiFiConfiguration); - - when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(true, mWiseFy.mWiseFySearch.isNetworkASavedConfiguration(TEST_SSID)); - } - - /* - * removeEntriesWithLowerSignalStrength tests - */ - - @Test - public void removeEntriesWithLowerSignalStrength_differentSSIDs() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID2; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - expectedResults.add(accessPoint2); - - assertEquals(expectedResults, mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); - } - - @Test - public void removeEntriesWithLowerSignalStrength_sameSignalLevels() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -70; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -70; - accessPoints.add(accessPoint2); - - assertEquals(expectedResults, mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); - } - - @Test - public void removeEntriesWithLowerSignalStrength_accessPoint1Higher() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoint1.level = -50; - accessPoints.add(accessPoint1); - expectedResults.add(accessPoint1); - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -70; - accessPoints.add(accessPoint2); - - assertEquals(expectedResults , mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); - } - - @Test - public void removeEntriesWithLowerSignalStrength_accessPoint2Higher() { - List accessPoints = new ArrayList<>(); - List expectedResults = new ArrayList<>(); - - ScanResult accessPoint1 = mock(ScanResult.class); - accessPoint1.SSID = TEST_SSID; - accessPoints.add(accessPoint1); - accessPoint1.level = -70; - - ScanResult accessPoint2 = mock(ScanResult.class); - accessPoint2.SSID = TEST_SSID; - accessPoint2.level = -50; - accessPoints.add(accessPoint2); - expectedResults.add(accessPoint2); - - assertEquals(expectedResults , mWiseFy.mWiseFySearch.removeEntriesWithLowerSignalStrength(accessPoints)); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.kt new file mode 100644 index 00000000..4dc177f5 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFySearchTests.kt @@ -0,0 +1,525 @@ +package com.isupatches.wisefy + +import org.junit.Assert.assertEquals + +import org.junit.Test + +/** + * Used to test the WiseFySearch class and search capabilities. + * + * @see WiseFySearch + * + * @author Patches + */ +@Suppress("LargeClass", "TooManyFunctions") +internal class WiseFySearchTests : BaseAndroidJUnit4TestClass() { + + private val wisefySearch: WiseFySearch = WiseFySearchImpl.create(mockWifiManager) + + /* + * findAccessPointByRegex tests + */ + + @Test fun findAccessPointByRegex_failure_nullAccessPoints_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_nullList() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_failure_nullAccessPoints_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_nullList() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_emptyList() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_failure_emptyAccessPointList_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_emptyList() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun findAccessPointByRegex_failure_nullAccessPoint_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_failure_nullAccessPoint_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun findAccessPointByRegex_failure_nullSSID_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_nullSSID() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_failure_nullSSID_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_nullSSID() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_failure_nonMatchingSSID_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_failure_multipleNonMatchingSSIDs_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() + assertEquals(null, wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun findAccessPointByRegex_success_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_matchingSSID() + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_success_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_matchingSSID() + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_nonRegex_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_nonRegex_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_regex_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_REGEX, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_success_multipleSSIDs_sameRSSI_regex_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_REGEX, TEST_TIMEOUT, true)) + } + + @Test fun findAccessPointByRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(false) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_success_multipleMatchesSSIDs_accessPoint1HasHigherRSSI_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun findAccessPointByRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_false() { + val takeHighest = false + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(takeHighest) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, takeHighest)) + } + + @Test fun findAccessPointByRegex_success_multipleMatchesSSIDs_accessPoint2HasHigherRSSI_takeHighest_true() { + val takeHighest = true + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(takeHighest) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, takeHighest)) + } + + @Test fun findAccessPointByRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(false) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun findAccessPointByRegex_success_multipleMatchesSSIDs_sameRSSI_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(false) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoint(), wisefySearch.findAccessPointByRegex(TEST_SSID, TEST_TIMEOUT, true)) + } + + /* + * findAccessPointsMatchingRegex tests + */ + + @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_nullList() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + } + + @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoints_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_nullList() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + } + + @Test fun findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_emptyList() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + } + + @Test fun findAccessPointsMatchingRegex_failure_emptyAccessPointList_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_emptyList() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + } + + @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + } + + @Test fun findAccessPointsMatchingRegex_failure_nullAccessPoint_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + } + + @Test fun findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_nullSSID() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + } + + @Test fun findAccessPointsMatchingRegex_failure_nullSSID_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_nullSSID() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + } + + @Test fun findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + } + + @Test fun findAccessPointsMatchingRegex_failure_nonMatchingSSID_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + } + + @Test fun findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + } + + @Test fun findAccessPointsMatchingRegex_failure_multipleNonMatchingSSIDs_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() + assertEquals(null, wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + } + + @Test fun findAccessPointsMatchingRegex_success_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_matchingSSID() + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + } + + @Test fun findAccessPointsMatchingRegex_success_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_matchingSSID() + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + } + + @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_nonRegex_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + } + + @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_nonRegex_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + } + + @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_regex_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_REGEX, false)) + } + + @Test fun findAccessPointsMatchingRegex_success_multipleSSIDs_regex_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_REGEX, true)) + } + + @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_false() { + val takeHighest = false + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(takeHighest) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, takeHighest)) + } + + @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI_takeHighest_true() { + val takeHighest = true + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(takeHighest) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, takeHighest)) + } + + @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(false) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + } + + @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + } + + @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_false() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, false)) + } + + @Test fun findAccessPointsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI_takeHighest_true() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.findAccessPointsMatchingRegex(TEST_SSID, true)) + } + + /* + * findSavedNetworkByRegex tests + */ + + @Test fun findSavedNetworkByRegex_failure_nullSavedNetworkList() { + mockNetworkUtil.savedNetworks_nullList() + assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) + } + + @Test fun findSavedNetworkByRegex_failure_emptySavedNetworkList() { + mockNetworkUtil.savedNetworks_emptyList() + assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) + } + + @Test fun findSavedNetworkByRegex_failure_nullWifiConfiguration() { + mockNetworkUtil.savedNetworks_nullSavedNetwork() + assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) + } + + @Test fun findSavedNetworkByRegex_failure_nullSSID() { + mockNetworkUtil.savedNetworks_nullSSID() + assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) + } + + @Test fun findSavedNetworkByRegex_failure_nonMatchingSSID() { + mockNetworkUtil.savedNetworks_nonMatchingSSID() + assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) + } + + @Test fun findSavedNetworkByRegex_failure_multipleNonMatchingSSIDs() { + mockNetworkUtil.savedNetworks_multipleNonMatchingSSIDs() + assertEquals(null, wisefySearch.findSavedNetworkByRegex(TEST_SSID)) + } + + @Test fun findSavedNetworkByRegex_success() { + mockNetworkUtil.savedNetworks_matchingSSID() + assertEquals(mockNetworkUtil.getExpectedSavedNetwork(), wisefySearch.findSavedNetworkByRegex(TEST_SSID)) + } + + @Test fun findSavedNetworkByRegex_success_multipleMatchingSSIDs() { + mockNetworkUtil.savedNetworks_multipleMatchingSSIDs() + assertEquals(mockNetworkUtil.getExpectedSavedNetwork(), wisefySearch.findSavedNetworkByRegex(TEST_SSID)) + } + + @Test fun findSavedNetworkByRegex_success_multipleSSIDs_nonRegex() { + mockNetworkUtil.savedNetworks_multipleSSIDs(false) + assertEquals(mockNetworkUtil.getExpectedSavedNetwork(), wisefySearch.findSavedNetworkByRegex(TEST_SSID)) + } + + @Test fun findSavedNetworkByRegex_success_multipleSSIDs_regex() { + mockNetworkUtil.savedNetworks_multipleSSIDs(true) + assertEquals(mockNetworkUtil.getExpectedSavedNetwork(), wisefySearch.findSavedNetworkByRegex(TEST_REGEX)) + } + + /* + * findSavedNetworksMatchingRegex tests + */ + + @Test fun findSavedNetworksMatchingRegex_failure_nullSavedNetworkList() { + mockNetworkUtil.savedNetworks_nullList() + assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) + } + + @Test fun findSavedNetworksMatchingRegex_failure_emptySavedNetworkList() { + mockNetworkUtil.savedNetworks_emptyList() + assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) + } + + @Test fun findSavedNetworksMatchingRegex_failure_nullWifiConfiguration() { + mockNetworkUtil.savedNetworks_nullSavedNetwork() + assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) + } + + @Test fun findSavedNetworksMatchingRegex_failure_nullSSID() { + mockNetworkUtil.savedNetworks_nullSSID() + assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) + } + + @Test fun findSavedNetworksMatchingRegex_failure_nonMatchingSSID() { + mockNetworkUtil.savedNetworks_nonMatchingSSID() + assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) + } + + @Test fun findSavedNetworksMatchingRegex_failure_multipleNonMatchingSSIDs() { + mockNetworkUtil.savedNetworks_multipleNonMatchingSSIDs() + assertEquals(null, wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) + } + + @Test fun findSavedNetworksMatchingRegex_success() { + mockNetworkUtil.savedNetworks_matchingSSID() + assertEquals(mockNetworkUtil.getExpectedSavedNetworks(), wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) + } + + @Test fun findSavedNetworksMatchingRegex_success_multipleMatchingSSIDs() { + mockNetworkUtil.savedNetworks_multipleMatchingSSIDs() + assertEquals(mockNetworkUtil.getExpectedSavedNetworks(), wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) + } + + @Test fun findSavedNetworksMatchingRegex_success_multipleSSIDs_nonRegex() { + mockNetworkUtil.savedNetworks_multipleSSIDs(false) + assertEquals(mockNetworkUtil.getExpectedSavedNetworks(), wisefySearch.findSavedNetworksMatchingRegex(TEST_SSID)) + } + + @Test fun findSavedNetworksMatchingRegex_success_multipleSSIDs_regex() { + mockNetworkUtil.savedNetworks_multipleSSIDs(true) + assertEquals(mockNetworkUtil.getExpectedSavedNetworks(), wisefySearch.findSavedNetworksMatchingRegex(TEST_REGEX)) + } + + /* + * findSSIDsMatchingRegex tests + */ + + @Test fun findSSIDsMatchingRegex_failure_nullAccessPoints() { + mockNetworkUtil.nearbyAccessPoints_nullList() + assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_failure_emptySavedNetworkList() { + mockNetworkUtil.nearbyAccessPoints_emptyList() + assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_failure_nullAccessPoint() { + mockNetworkUtil.nearbyAccessPoints_nullAccessPoint() + assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_failure_nullSSID() { + mockNetworkUtil.nearbyAccessPoints_nullSSID() + assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_failure_nonMatchingSSID() { + mockNetworkUtil.nearbyAccessPoints_nonMatchingSSID() + assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_failure_multipleNonMatchingSSIDs() { + mockNetworkUtil.nearbyAccessPoints_multipleNonMatchingSSIDs() + assertEquals(null, wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_success() { + mockNetworkUtil.nearbyAccessPoints_matchingSSID() + assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_sameRSSI() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(true) + assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_accessPoint1HasHigherRSSI() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(true) + assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_success_multipleMatchingSSIDs_accessPoint2HasHigherRSSI() { + mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(true) + assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_success_multipleSSIDs_nonRegex() { + mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(false) + assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_SSID)) + } + + @Test fun findSSIDsMatchingRegex_success_multipleSSIDs_regex() { + mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) + assertEquals(mockNetworkUtil.getExpectedSSIDs(), wisefySearch.findSSIDsMatchingRegex(TEST_REGEX)) + } + + /* + * isNetworkASavedConfiguration tests + */ + + @Test fun isNetworkASavedConfiguration_failure_nullSSIDParam() { + mockNetworkUtil.savedNetworks_nullList() + assertEquals(false, wisefySearch.isNetworkASavedConfiguration(null)) + } + + @Test fun isNetworkASavedConfiguration_failure_nullSavedNetworkList() { + mockNetworkUtil.savedNetworks_nullList() + assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) + } + + @Test fun isNetworkASavedConfiguration_failure_emptySavedNetworkList() { + mockNetworkUtil.savedNetworks_emptyList() + assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) + } + + @Test fun isNetworkASavedConfiguration_failure_nullWifiConfiguration() { + mockNetworkUtil.savedNetworks_nullSavedNetwork() + assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) + } + + @Test fun isNetworkASavedConfiguration_failure_nullSSID() { + mockNetworkUtil.savedNetworks_nullSSID() + assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) + } + + @Test fun isNetworkASavedConfiguration_failure_nonMatchingSSID() { + mockNetworkUtil.savedNetworks_nonMatchingSSID() + assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) + } + + @Test fun isNetworkASavedConfiguration_failure_multipleNonMatchingSSIDs() { + mockNetworkUtil.savedNetworks_multipleNonMatchingSSIDs() + assertEquals(false, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) + } + + @Test fun isNetworkASavedConfiguration_success() { + mockNetworkUtil.savedNetworks_matchingSSID() + assertEquals(true, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) + } + + @Test fun isNetworkASavedConfiguration_success_multipleMatchingSSIDs() { + mockNetworkUtil.savedNetworks_multipleMatchingSSIDs() + assertEquals(true, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) + } + + @Test fun isNetworkASavedConfiguration_success_multipleSSIDs_nonRegex() { + mockNetworkUtil.savedNetworks_multipleSSIDs(false) + assertEquals(true, wisefySearch.isNetworkASavedConfiguration(TEST_SSID)) + } + + @Test fun isNetworkASavedConfiguration_success_multipleSSIDs_regex() { + mockNetworkUtil.savedNetworks_multipleSSIDs(true) + assertEquals(true, wisefySearch.isNetworkASavedConfiguration(TEST_REGEX)) + } + + /* + * removeEntriesWithLowerSignalStrength tests + */ + + @Test fun removeEntriesWithLowerSignalStrength_differentSSIDs() { + val accessPoints = mockNetworkUtil.nearbyAccessPoints_multipleSSIDs_sameRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.removeEntriesWithLowerSignalStrength(accessPoints)) + } + + @Test fun removeEntriesWithLowerSignalStrength_sameSignalLevels() { + val accessPoints = mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_sameRSSI(false) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.removeEntriesWithLowerSignalStrength(accessPoints)) + } + + @Test fun removeEntriesWithLowerSignalStrength_accessPoint1Higher() { + val accessPoints = mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint1HasHigherRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.removeEntriesWithLowerSignalStrength(accessPoints)) + } + + @Test fun removeEntriesWithLowerSignalStrength_accessPoint2Higher() { + val accessPoints = mockNetworkUtil.nearbyAccessPoints_multipleMatchingSSIDs_accessPoint2HasHigherRSSI(true) + assertEquals(mockNetworkUtil.getExpectedNearbyAccessPoints(), wisefySearch.removeEntriesWithLowerSignalStrength(accessPoints)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java deleted file mode 100644 index bfa5841a..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/WiseFyTests.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.isupatches.wisefy; - - -import android.support.test.InstrumentationRegistry; -import com.google.android.gms.iid.InstanceID; -import org.junit.Test; -import static org.junit.Assert.*; - - -public class WiseFyTests extends BaseAndroidJUnit4TestClass { - - @Test - public void builder_loggingFalse() { - WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(false).getSmarts(); - assertEquals(false, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); - assertEquals(false, wiseFy.isLoggingEnabled()); - } - - @Test - public void builder_loggingTrue() { - WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(true).getSmarts(); - assertEquals(true, wiseFy.mWiseFyConfiguration.isLoggingEnabled()); - assertEquals(true, wiseFy.isLoggingEnabled()); - } - - @Test - public void calculateBars() { - int result = mWiseFy.calculateBars(-35, 5); - assertEquals(4, result); - } - - @Test - public void compareSignalLevel() { - int result = mWiseFy.compareSignalLevel(-35, -70); - assertEquals(35, result); - } - - @Test - public void getWiseFyLock() { - assertNotNull(mWiseFy.getWiseFyLock()); - } - - @Test - public void olderGcm_IllegalAccessError_notThrown() { - InstanceID instanceID = InstanceID.getInstance(InstrumentationRegistry.getContext()); - assertNotNull(instanceID); - } -} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/base/TestUtils.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/base/TestUtils.java deleted file mode 100644 index 6c832daf..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/base/TestUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.isupatches.wisefy.base; - - -import com.isupatches.wisefy.WiseFy; - - -public class TestUtils { - - public static final String OPEN_NETWORK_SSID = "Open Network"; - - public static final String WEP_NETWORK_SSID = "WEP Network"; - - public static final String WEP_NETWORK_PASSWORD = "12345678"; - - public static final String WPA2_NETWORK_SSID = "WPA2 Network"; - - public static final String WPA2_NETWORK_PASSWORD = "123456"; - - public static final String TEST_SSID = "Test Network"; - - public static final String TEST_SSID2 = "Test Network 2"; - - public static final String TEST_SSID3 = "Test Network 3"; - - public static final int TEST_NETWORK_FREQUENCY_BELOW_5GHZ = WiseFy.MIN_FREQUENCY_5GHZ - 1; - - public static final int TEST_NETWORK_FREQUENCY_ABOVE_5GHZ = WiseFy.MAX_FREQUENCY_5GHZ + 1; - - public static final int TEST_NETWORK_FREQUENCY_24GHZ = 2400; - - public static final int TEST_NETWORK_FREQUENCY_5GHZ = 5000; - - public static final int TEST_RSSI_LEVEL = -60; - - public static final int TEST_TIMEOUT = 1; - - public static final String TEST_TYPE1 = "TYPE 1"; - - public static final String TEST_TYPE2 = "TYPE 2"; -} \ No newline at end of file diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddOpenNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddOpenNetworkTests.kt new file mode 100644 index 00000000..21506a8f --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddOpenNetworkTests.kt @@ -0,0 +1,90 @@ +package com.isupatches.wisefy.main + +import android.net.wifi.WifiConfiguration +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.OPEN_NETWORK_SSID +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.WiseFy.Companion.WIFI_MANAGER_FAILURE +import com.isupatches.wisefy.callbacks.AddNetworkCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals +import org.junit.Test +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to add open networks. + * + * @author Patches + */ +internal class AddOpenNetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.addNetwork_failure() + assertEquals(MISSING_PARAMETER, wiseFy.addOpenNetwork(OPEN_NETWORK_SSID)) + verificationUtil.didNoTryToAddNetwork() + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_failure() + assertEquals(WIFI_MANAGER_FAILURE, wiseFy.addOpenNetwork(OPEN_NETWORK_SSID)) + verificationUtil.triedToAddNetwork() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_success() + assertNotEquals(WIFI_MANAGER_FAILURE, wiseFy.addOpenNetwork(OPEN_NETWORK_SSID)) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.addNetwork_failure() + val mockCallbacks = mock(AddNetworkCallbacks::class.java) + wiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNoTryToAddNetwork() + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.addNetwork_failure() + nullCallbackUtil.callAddOpenNetwork(OPEN_NETWORK_SSID) + verificationUtil.didNoTryToAddNetwork() + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_failure() + val mockCallbacks = mock(AddNetworkCallbacks::class.java) + wiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureAddingNetwork(WIFI_MANAGER_FAILURE) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_failure() + nullCallbackUtil.callAddOpenNetwork(OPEN_NETWORK_SSID) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_success() + val mockCallbacks = mock(AddNetworkCallbacks::class.java) + wiseFy.addOpenNetwork(OPEN_NETWORK_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkAdded(anyInt(), any(WifiConfiguration::class.java)) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_success() + nullCallbackUtil.callAddOpenNetwork(OPEN_NETWORK_SSID) + verificationUtil.triedToAddNetwork() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddWEPNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddWEPNetworkTests.kt new file mode 100644 index 00000000..f65fe927 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddWEPNetworkTests.kt @@ -0,0 +1,91 @@ +package com.isupatches.wisefy.main + +import android.net.wifi.WifiConfiguration +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.WEP_NETWORK_PASSWORD +import com.isupatches.wisefy.WEP_NETWORK_SSID +import com.isupatches.wisefy.WiseFy.Companion.WIFI_MANAGER_FAILURE +import com.isupatches.wisefy.callbacks.AddNetworkCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals +import org.junit.Test +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to add WEP networks. + * + * @author Patches + */ +internal class AddWEPNetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.addNetwork_failure() + assertEquals(MISSING_PARAMETER, wiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)) + verificationUtil.didNoTryToAddNetwork() + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_failure() + assertEquals(WIFI_MANAGER_FAILURE, wiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)) + verificationUtil.triedToAddNetwork() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_success() + assertNotEquals(1, wiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD)) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.addNetwork_failure() + val mockCallbacks = mock(AddNetworkCallbacks::class.java) + wiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNoTryToAddNetwork() + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.addNetwork_failure() + nullCallbackUtil.callAddWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD) + verificationUtil.didNoTryToAddNetwork() + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_failure() + val mockCallbacks = mock(AddNetworkCallbacks::class.java) + wiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureAddingNetwork(WIFI_MANAGER_FAILURE) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_failure() + nullCallbackUtil.callAddWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_success() + val mockCallbacks = mock(AddNetworkCallbacks::class.java) + wiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkAdded(anyInt(), any(WifiConfiguration::class.java)) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_success() + nullCallbackUtil.callAddWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD) + verificationUtil.triedToAddNetwork() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddWPA2NetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddWPA2NetworkTests.kt new file mode 100644 index 00000000..0c6fa3e9 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/AddWPA2NetworkTests.kt @@ -0,0 +1,91 @@ +package com.isupatches.wisefy.main + +import android.net.wifi.WifiConfiguration +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.WPA2_NETWORK_PASSWORD +import com.isupatches.wisefy.WPA2_NETWORK_SSID +import com.isupatches.wisefy.WiseFy.Companion.WIFI_MANAGER_FAILURE +import com.isupatches.wisefy.callbacks.AddNetworkCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals +import org.junit.Test +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to add WPA2 networks. + * + * @author Patches + */ +internal class AddWPA2NetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.addNetwork_failure() + assertEquals(MISSING_PARAMETER, wiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)) + verificationUtil.didNoTryToAddNetwork() + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_failure() + assertEquals(WIFI_MANAGER_FAILURE, wiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)) + verificationUtil.triedToAddNetwork() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_success() + assertNotEquals(WIFI_MANAGER_FAILURE, wiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD)) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.addNetwork_failure() + val mockCallbacks = mock(AddNetworkCallbacks::class.java) + wiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNoTryToAddNetwork() + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.addNetwork_failure() + nullCallbackUtil.callAddWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD) + verificationUtil.didNoTryToAddNetwork() + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_failure() + val mockCallbacks = mock(AddNetworkCallbacks::class.java) + wiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureAddingNetwork(WIFI_MANAGER_FAILURE) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_failure() + nullCallbackUtil.callAddWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_success() + val mockCallbacks = mock(AddNetworkCallbacks::class.java) + wiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkAdded(anyInt(), any(WifiConfiguration::class.java)) + verificationUtil.triedToAddNetwork() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.addNetwork_success() + mockNetworkUtil.addNetwork_success() + nullCallbackUtil.callAddWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD) + verificationUtil.triedToAddNetwork() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/ConnectToNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/ConnectToNetworkTests.kt new file mode 100644 index 00000000..2ce7be4d --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/ConnectToNetworkTests.kt @@ -0,0 +1,119 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.TEST_TIMEOUT +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER + +import org.junit.Assert.assertEquals +import org.junit.Test + +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to connect to a network. + * + * @author Patches + */ +internal class ConnectToNetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.connectToNetwork_failure() + assertEquals(false, wiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT)) + verificationUtil.didNotTryToConnectToNetwork() + } + + @Test fun sync_failure_noSavedNetwork() { + mockWiseFyPrechecksUtil.connectToNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_null() + assertEquals(false, wiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT)) + verificationUtil.didNotTryToConnectToNetwork() + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.connectToNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockWiseFyConnectionUtil.waitToConnectToSSID(false) + assertEquals(false, wiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT)) + verificationUtil.triedToConnectToNetwork() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.connectToNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockWiseFyConnectionUtil.waitToConnectToSSID(true) + assertEquals(true, wiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT)) + verificationUtil.triedToConnectToNetwork() + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.connectToNetwork_failure() + val mockCallbacks = mock(ConnectToNetworkCallbacks::class.java) + wiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToConnectToNetwork() + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.connectToNetwork_success() + mockWiseFyPrechecksUtil.connectToNetwork_failure() + nullCallbackUtil.callConnectToNetwork(TEST_SSID) + verificationUtil.didNotTryToConnectToNetwork() + } + + @Test fun async_failure_noSavedNetwork() { + mockWiseFyPrechecksUtil.connectToNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_null() + val mockCallbacks = mock(ConnectToNetworkCallbacks::class.java) + wiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkNotFoundToConnectTo() + verificationUtil.didNotTryToConnectToNetwork() + } + + @Test fun async_failure_noSavedNetwork_nullCallback() { + mockWiseFyPrechecksUtil.connectToNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_null() + nullCallbackUtil.callConnectToNetwork(TEST_SSID) + verificationUtil.didNotTryToConnectToNetwork() + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.connectToNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockWiseFyConnectionUtil.waitToConnectToSSID(false) + val mockCallbacks = mock(ConnectToNetworkCallbacks::class.java) + wiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureConnectingToNetwork() + verificationUtil.triedToConnectToNetwork() + } + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.connectToNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockWiseFyConnectionUtil.waitToConnectToSSID(false) + nullCallbackUtil.callConnectToNetwork(TEST_SSID) + verificationUtil.triedToConnectToNetwork() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.connectToNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockWiseFyConnectionUtil.waitToConnectToSSID(true) + val mockCallbacks = mock(ConnectToNetworkCallbacks::class.java) + wiseFy.connectToNetwork(TEST_SSID, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).connectedToNetwork() + verificationUtil.triedToConnectToNetwork() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.connectToNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockWiseFyConnectionUtil.waitToConnectToSSID(true) + nullCallbackUtil.callConnectToNetwork(TEST_SSID) + verificationUtil.triedToConnectToNetwork() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/DisableWifiTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/DisableWifiTests.kt new file mode 100644 index 00000000..78efa2b4 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/DisableWifiTests.kt @@ -0,0 +1,87 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.DisableWifiCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER + +import org.junit.Assert.assertEquals +import org.junit.Test + +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to disable a device's wifi. + * + * @author Patches + */ +internal class DisableWifiTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.disableWifi_failure() + assertEquals(false, wiseFy.disableWifi()) + verificationUtil.didNotTryToDisableWifi() + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.disableWifi_success() + mockNetworkUtil.disableWifi_failure() + assertEquals(false, wiseFy.disableWifi()) + verificationUtil.triedToDisableWifi() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.disableWifi_success() + mockNetworkUtil.disableWifi_success() + assertEquals(true, wiseFy.disableWifi()) + verificationUtil.triedToDisableWifi() + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.disableWifi_failure() + val mockCallbacks = mock(DisableWifiCallbacks::class.java) + wiseFy.disableWifi(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToDisableWifi() + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.disableWifi_failure() + nullCallbackUtil.callDisableWifi() + verificationUtil.didNotTryToDisableWifi() + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.disableWifi_success() + mockNetworkUtil.disableWifi_failure() + val mockCallbacks = mock(DisableWifiCallbacks::class.java) + wiseFy.disableWifi(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureDisablingWifi() + verificationUtil.triedToDisableWifi() + } + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.disableWifi_success() + mockNetworkUtil.disableWifi_failure() + nullCallbackUtil.callDisableWifi() + verificationUtil.triedToDisableWifi() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.disableWifi_success() + mockNetworkUtil.disableWifi_success() + val mockCallbacks = mock(DisableWifiCallbacks::class.java) + wiseFy.disableWifi(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wifiDisabled() + verificationUtil.triedToDisableWifi() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.disableWifi_success() + mockNetworkUtil.disableWifi_success() + nullCallbackUtil.callDisableWifi() + verificationUtil.triedToDisableWifi() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/DisconnectFromCurrentNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/DisconnectFromCurrentNetworkTests.kt new file mode 100644 index 00000000..0621f0e2 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/DisconnectFromCurrentNetworkTests.kt @@ -0,0 +1,87 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER + +import org.junit.Assert.assertEquals +import org.junit.Test + +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to disconnect a device from it's current network. + * + * @author Patches + */ +internal class DisconnectFromCurrentNetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_failure() + assertEquals(false, wiseFy.disconnectFromCurrentNetwork()) + verificationUtil.didNotTryToDisconnectFromCurrentNetwork() + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() + mockNetworkUtil.disconnectFromCurrentNetwork_failure() + assertEquals(false, wiseFy.disconnectFromCurrentNetwork()) + verificationUtil.triedToDisconnectFromCurrentNetwork() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() + mockNetworkUtil.disconnectFromCurrentNetwork_success() + assertEquals(true, wiseFy.disconnectFromCurrentNetwork()) + verificationUtil.triedToDisconnectFromCurrentNetwork() + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_failure() + val mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks::class.java) + wiseFy.disconnectFromCurrentNetwork(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToDisconnectFromCurrentNetwork() + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_failure() + nullCallbackUtil.callDisconnectFromCurrentNetwork() + verificationUtil.didNotTryToDisconnectFromCurrentNetwork() + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() + mockNetworkUtil.disconnectFromCurrentNetwork_failure() + val mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks::class.java) + wiseFy.disconnectFromCurrentNetwork(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureDisconnectingFromCurrentNetwork() + verificationUtil.triedToDisconnectFromCurrentNetwork() + } + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() + mockNetworkUtil.disconnectFromCurrentNetwork_failure() + nullCallbackUtil.callDisconnectFromCurrentNetwork() + verificationUtil.triedToDisconnectFromCurrentNetwork() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() + mockNetworkUtil.disconnectFromCurrentNetwork_success() + val mockCallbacks = mock(DisconnectFromCurrentNetworkCallbacks::class.java) + wiseFy.disconnectFromCurrentNetwork(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).disconnectedFromCurrentNetwork() + verificationUtil.triedToDisconnectFromCurrentNetwork() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.disconnectFromCurrentNetwork_success() + mockNetworkUtil.disconnectFromCurrentNetwork_success() + nullCallbackUtil.callDisconnectFromCurrentNetwork() + verificationUtil.triedToDisconnectFromCurrentNetwork() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/EnableWifiTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/EnableWifiTests.kt new file mode 100644 index 00000000..b9afdb57 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/EnableWifiTests.kt @@ -0,0 +1,87 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.EnableWifiCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER + +import org.junit.Assert.assertEquals +import org.junit.Test + +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to enable a device's wifi. + * + * @author Patches + */ +internal class EnableWifiTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.enableWifi_failure() + assertEquals(false, wiseFy.enableWifi()) + verificationUtil.didNotTryToEnableWifi() + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.enableWifi_success() + mockNetworkUtil.enableWifi_failure() + assertEquals(false, wiseFy.enableWifi()) + verificationUtil.triedToEnableWifi() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.enableWifi_success() + mockNetworkUtil.enableWifi_success() + assertEquals(true, wiseFy.enableWifi()) + verificationUtil.triedToEnableWifi() + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.enableWifi_failure() + val mockCallbacks = mock(EnableWifiCallbacks::class.java) + wiseFy.enableWifi(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToEnableWifi() + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.enableWifi_failure() + nullCallbackUtil.callEnableWifi() + verificationUtil.didNotTryToEnableWifi() + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.enableWifi_success() + mockNetworkUtil.enableWifi_failure() + val mockCallbacks = mock(EnableWifiCallbacks::class.java) + wiseFy.enableWifi(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureEnablingWifi() + verificationUtil.triedToEnableWifi() + } + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.enableWifi_success() + mockNetworkUtil.enableWifi_failure() + nullCallbackUtil.callEnableWifi() + verificationUtil.triedToEnableWifi() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.enableWifi_success() + mockNetworkUtil.enableWifi_success() + val mockCallbacks = mock(EnableWifiCallbacks::class.java) + wiseFy.enableWifi(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wifiEnabled() + verificationUtil.triedToEnableWifi() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.enableWifi_success() + mockNetworkUtil.enableWifi_success() + nullCallbackUtil.callEnableWifi() + verificationUtil.triedToEnableWifi() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetCurrentNetworkInfoTest.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetCurrentNetworkInfoTest.kt new file mode 100644 index 00000000..46c46571 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetCurrentNetworkInfoTest.kt @@ -0,0 +1,73 @@ +package com.isupatches.wisefy.main + +import android.net.NetworkInfo + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.GetCurrentNetworkInfoCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull +import org.junit.Assert.fail +import org.junit.Test + +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to retrieve a device's current network information. + * + * @author Patches + */ +internal class GetCurrentNetworkInfoTest : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.getCurrentNetworkInfo_failure() + assertEquals(null, wiseFy.getCurrentNetworkInfo()) + verificationUtil.didNotTryToGetCurrentNetworkInfo() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.getCurrentNetworkInfo_success() + mockNetworkUtil.activeNetwork() + val currentNetworkInfo = wiseFy.getCurrentNetworkInfo() + if (currentNetworkInfo != null) { + assertNotNull(currentNetworkInfo) + verificationUtil.triedToGetCurrentNetworkInfo() + } else { + fail() + } + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.getCurrentNetworkInfo_failure() + val mockCallbacks = mock(GetCurrentNetworkInfoCallbacks::class.java) + wiseFy.getCurrentNetworkInfo(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToGetCurrentNetworkInfo() + } + + @Test fun async_failure_prechecks_nullCallbacks() { + mockWiseFyPrechecksUtil.getCurrentNetworkInfo_failure() + nullCallbackUtil.callGetCurrentNetworkInfo() + verificationUtil.didNotTryToGetCurrentNetworkInfo() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.getCurrentNetworkInfo_success() + mockNetworkUtil.activeNetwork() + val mockCallbacks = mock(GetCurrentNetworkInfoCallbacks::class.java) + wiseFy.getCurrentNetworkInfo(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedCurrentNetworkInfo(any(NetworkInfo::class.java)) + verificationUtil.triedToGetCurrentNetworkInfo() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.getCurrentNetworkInfo_success() + mockNetworkUtil.activeNetwork() + nullCallbackUtil.callGetCurrentNetworkInfo() + verificationUtil.didNotTryToGetCurrentNetworkInfo() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetCurrentNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetCurrentNetworkTests.kt new file mode 100644 index 00000000..afbd69c6 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetCurrentNetworkTests.kt @@ -0,0 +1,69 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Assert.fail +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to retrieve a device's current network. + * + * @author Patches + */ +internal class GetCurrentNetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.getCurrentNetwork_failure() + assertEquals(null, wiseFy.getCurrentNetwork()) + verificationUtil.didNotTryToGetCurrentNetwork() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + mockNetworkUtil.currentNetwork(TEST_SSID) + val currentNetwork = wiseFy.getCurrentNetwork() + if (currentNetwork != null) { + assertEquals(TEST_SSID, currentNetwork.ssid) + verificationUtil.triedToGetCurrentNetwork() + } else { + fail() + } + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.getCurrentNetwork_failure() + val mockCallbacks = mock(GetCurrentNetworkCallbacks::class.java) + wiseFy.getCurrentNetwork(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToGetCurrentNetwork() + } + + @Test fun async_failure_prechecks_nullCallbacks() { + mockWiseFyPrechecksUtil.getCurrentNetwork_failure() + nullCallbackUtil.callGetCurrentNetwork() + verificationUtil.didNotTryToGetCurrentNetwork() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + val currentNetwork = mockNetworkUtil.currentNetwork(TEST_SSID) + val mockCallbacks = mock(GetCurrentNetworkCallbacks::class.java) + wiseFy.getCurrentNetwork(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedCurrentNetwork(currentNetwork) + verificationUtil.triedToGetCurrentNetwork() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + mockNetworkUtil.currentNetwork(TEST_SSID) + nullCallbackUtil.callGetCurrentNetwork() + verificationUtil.didNotTryToGetCurrentNetwork() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetFrequencyTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetFrequencyTests.kt new file mode 100644 index 00000000..c93d649c --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetFrequencyTests.kt @@ -0,0 +1,165 @@ +package com.isupatches.wisefy.main + +import android.net.wifi.WifiInfo +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_NETWORK_FREQUENCY_24GHZ +import com.isupatches.wisefy.VERIFICATION_FAILURE_TIMEOUT +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Assert.fail +import org.junit.Test +import org.mockito.Mockito.after +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to retrieve a network's frequency. + * + * @author Patches + */ +internal class GetFrequencyTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_getFrequency_currentNetwork_failure() { + if (preLollipop()) { + return + } + + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + mockNetworkUtil.currentNetwork_null() + assertEquals(null, wiseFy.getFrequency()) + verificationUtil.triedToGetCurrentNetwork() + } + + @Test fun sync_getFrequency_currentNetwork_success() { + if (preLollipop()) { + return + } + + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + val wifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) + val frequency = wiseFy.getFrequency() + if (frequency != null) { + assertEquals(TEST_NETWORK_FREQUENCY_24GHZ.toLong(), frequency.toLong()) + verificationUtil.triedToGetCurrentNetwork() + verify(wifiInfo, timeout(VERIFICATION_SUCCESS_TIMEOUT)).frequency + } else { + fail() + } + } + + @Test fun async_getFrequency_currentNetwork_failure() { + if (preLollipop()) { + return + } + + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + mockNetworkUtil.currentNetwork_null() + val mockCallbacks = mock(GetFrequencyCallbacks::class.java) + wiseFy.getFrequency(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureGettingFrequency() + verificationUtil.triedToGetCurrentNetwork() + } + + @Test fun async_getFrequency_currentNetwork_failure_nullCallback() { + if (preLollipop()) { + return + } + + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + mockNetworkUtil.currentNetwork_null() + nullCallbackUtil.callGetFrequency() + verificationUtil.triedToGetCurrentNetwork() + } + + @Test fun async_getFrequency_currentNetwork_success() { + if (preLollipop()) { + return + } + + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + val mockWifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) + val mockCallbacks = mock(GetFrequencyCallbacks::class.java) + wiseFy.getFrequency(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ) + verificationUtil.triedToGetCurrentNetwork() + verify(mockWifiInfo, timeout(VERIFICATION_SUCCESS_TIMEOUT)).frequency + } + + @Test fun async_getFrequency_currentNetwork_success_nullCallback() { + if (preLollipop()) { + return + } + + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + nullCallbackUtil.callGetFrequency() + verificationUtil.triedToGetCurrentNetwork() + } + + @Test fun sync_getFrequency_networkProvided_failure() { + if (preLollipop()) { + return + } + + mockNetworkUtil.currentNetwork_null() + assertEquals(null, wiseFy.getFrequency(null as? WifiInfo?)) + } + + @Test fun sync_getFrequency_networkProvided_success() { + if (preLollipop()) { + return + } + + val mockWifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) + val frequency = wiseFy.getFrequency(mockWifiInfo) + if (frequency != null) { + assertEquals(TEST_NETWORK_FREQUENCY_24GHZ.toLong(), frequency.toLong()) + } else { + fail() + } + } + + @Test fun async_getFrequency_networkProvided_failure() { + if (preLollipop()) { + return + } + + mockNetworkUtil.currentNetwork_null() + val mockCallbacks = mock(GetFrequencyCallbacks::class.java) + wiseFy.getFrequency(null, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_getFrequency_networkProvided_failure_nullCallback() { + if (preLollipop()) { + return + } + + mockNetworkUtil.currentNetwork_null() + nullCallbackUtil.callGetFrequency_networkProvided(null) + } + + @Test fun async_getFrequency_networkProvided_success() { + if (preLollipop()) { + return + } + + val mockWifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) + val mockCallbacks = mock(GetFrequencyCallbacks::class.java) + wiseFy.getFrequency(mockWifiInfo, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedFrequency(TEST_NETWORK_FREQUENCY_24GHZ) + verify(mockWifiInfo, timeout(VERIFICATION_SUCCESS_TIMEOUT)).frequency + } + + @Test fun async_getFrequency_networkProvided_success_nullCallback() { + if (preLollipop()) { + return + } + + val mockWifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_24GHZ) + nullCallbackUtil.callGetFrequency_networkProvided(mockWifiInfo) + verify(mockWifiInfo, after(VERIFICATION_FAILURE_TIMEOUT).times(0)).frequency + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetIIPTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetIIPTests.kt new file mode 100644 index 00000000..380e2664 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetIIPTests.kt @@ -0,0 +1,60 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_IP_ADDRESS_STRING +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.GetIPCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to get the IP of a device. + * + * @author Patches + */ +internal class GetIIPTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_getIP_failure_missingPrerequisites() { + mockWiseFyPrechecksUtil.getIP_failure() + assertEquals(null, wiseFy.getIP()) + } + + @Test fun sync_getIP_failure() { + mockWiseFyPrechecksUtil.getIP_success() + mockNetworkUtil.ip_failure() + assertEquals(null, wiseFy.getIP()) + } + + @Test fun sync_getIP_success() { + mockWiseFyPrechecksUtil.getIP_success() + mockNetworkUtil.ip_success() + assertEquals(TEST_IP_ADDRESS_STRING, wiseFy.getIP()) + } + + @Test fun async_getIP_failure_missingPrerequisites() { + mockWiseFyPrechecksUtil.getIP_failure() + val mockCallbacks = mock(GetIPCallbacks::class.java) + wiseFy.getIP(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_getIP_failure() { + mockWiseFyPrechecksUtil.getIP_success() + mockNetworkUtil.ip_failure() + val mockCallbacks = mock(GetIPCallbacks::class.java) + wiseFy.getIP(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureRetrievingIP() + } + + @Test fun async_getIP_success() { + mockWiseFyPrechecksUtil.getIP_success() + mockNetworkUtil.ip_success() + val mockCallbacks = mock(GetIPCallbacks::class.java) + wiseFy.getIP(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedIP(TEST_IP_ADDRESS_STRING) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetNearbyAccessPointsTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetNearbyAccessPointsTests.kt new file mode 100644 index 00000000..674904ab --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetNearbyAccessPointsTests.kt @@ -0,0 +1,107 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to retrieve a list of nearby access points for a device. + * + * @author Patches + */ +internal class GetNearbyAccessPointsTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks_filterDuplicates_false() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() + assertEquals(null, wiseFy.getNearbyAccessPoints(false)) + verificationUtil.didNotTryToGetNearbyAccessPoints() + } + + @Test fun sync_failure_prechecks_filterDuplicates_true() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() + assertEquals(null, wiseFy.getNearbyAccessPoints(true)) + verificationUtil.didNotTryToGetNearbyAccessPoints() + } + + @Test fun sync_success_filterDuplicates_false() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() + val accessPoints = mockNetworkUtil.nearbyAccessPoints() + val nearbyAccessPoints = wiseFy.getNearbyAccessPoints(false) + assertEquals(accessPoints, nearbyAccessPoints) + verificationUtil.triedToGetNearbyAccessPoints() + } + + @Test fun sync_success_filterDuplicates_true() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() + val accessPoints = mockWiseFySearchUtil.removeEntriesWithLowerSignalStrength() + val nearbyAccessPoints = wiseFy.getNearbyAccessPoints(true) + assertEquals(accessPoints, nearbyAccessPoints) + verificationUtil.triedToGetNearbyAccessPoints() + } + + @Test fun async_failure_prechecks_filterDuplicates_false() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() + val mockCallbacks = mock(GetNearbyAccessPointsCallbacks::class.java) + wiseFy.getNearbyAccessPoints(false, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToGetNearbyAccessPoints() + } + + @Test fun async_failure_prechecks_filterDuplicates_false_nullCallback() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() + nullCallbackUtil.callGetNearbyAccessPoints(false) + verificationUtil.didNotTryToGetNearbyAccessPoints() + } + + @Test fun async_failure_prechecks_filterDuplicates_true() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() + val mockCallbacks = mock(GetNearbyAccessPointsCallbacks::class.java) + wiseFy.getNearbyAccessPoints(true, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToGetNearbyAccessPoints() + } + + @Test fun async_failure_prechecks_filterDuplicates_true_nullCallback() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_failure() + nullCallbackUtil.callGetNearbyAccessPoints(true) + verificationUtil.didNotTryToGetNearbyAccessPoints() + } + + @Test fun async_success_filterDuplicates_false() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() + val accessPoints = mockNetworkUtil.nearbyAccessPoints() + val mockCallbacks = mock(GetNearbyAccessPointsCallbacks::class.java) + wiseFy.getNearbyAccessPoints(false, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedNearbyAccessPoints(accessPoints) + verificationUtil.triedToGetNearbyAccessPoints() + } + + @Test fun async_success_filterDuplicates_false_nullCallback() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() + mockNetworkUtil.nearbyAccessPoints() + nullCallbackUtil.callGetNearbyAccessPoints(false) + verificationUtil.didNotTryToGetNearbyAccessPoints() + } + + @Test fun async_success_filterDuplicates_true() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() + val accessPoints = mockWiseFySearchUtil.removeEntriesWithLowerSignalStrength() + val mockCallbacks = mock(GetNearbyAccessPointsCallbacks::class.java) + wiseFy.getNearbyAccessPoints(true, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedNearbyAccessPoints(accessPoints) + verificationUtil.triedToGetNearbyAccessPoints() + } + + @Test fun async_success_filterDuplicates_true_nullCallback() { + mockWiseFyPrechecksUtil.getNearbyAccessPoints_success() + mockWiseFySearchUtil.removeEntriesWithLowerSignalStrength() + nullCallbackUtil.callGetNearbyAccessPoints(true) + verificationUtil.didNotTryToGetNearbyAccessPoints() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetRSSITests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetRSSITests.kt new file mode 100644 index 00000000..1504ac03 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetRSSITests.kt @@ -0,0 +1,149 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_RSSI_LEVEL +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.TEST_TIMEOUT +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.GetRSSICallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Assert.fail +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to retrieve the RSSI for a nearby access point. + * + * @author Patches + */ +internal class GetRSSITests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks_takeHighest_false() { + mockWiseFyPrechecksUtil.getRSSI_failure() + assertEquals(null, wiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT)) + } + + @Test fun sync_failure_prechecks_takeHighest_true() { + mockWiseFyPrechecksUtil.getRSSI_failure() + assertEquals(null, wiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT)) + } + + @Test fun sync_failure_noNetworkFound_takeHighest_false() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + assertEquals(null, wiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT)) + } + + @Test fun sync_failure_noNetworkFound_takeHighest_true() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + assertEquals(null, wiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT)) + } + + @Test fun sync_success_takeHighest_false() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + + val rssi = wiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT) + if (rssi != null) { + assertEquals(TEST_RSSI_LEVEL.toLong(), rssi.toLong()) + } else { + fail() + } + } + + @Test fun sync_success_takeHighest_true() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + + val rssi = wiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT) + if (rssi != null) { + assertEquals(TEST_RSSI_LEVEL.toLong(), rssi.toLong()) + } else { + fail() + } + } + + @Test fun async_failure_prechecks_takeHighest_false() { + mockWiseFyPrechecksUtil.getRSSI_failure() + val mockCallbacks = mock(GetRSSICallbacks::class.java) + wiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_failure_prechecks_takeHighest_false_nullCallback() { + mockWiseFyPrechecksUtil.getRSSI_failure() + nullCallbackUtil.callGetRSSI(false) + } + + @Test fun async_failure_prechecks_takeHighest_true() { + mockWiseFyPrechecksUtil.getRSSI_failure() + val mockCallbacks = mock(GetRSSICallbacks::class.java) + wiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_failure_prechecks_takeHighest_true_nullCallback() { + mockWiseFyPrechecksUtil.getRSSI_failure() + nullCallbackUtil.callGetRSSI(true) + } + + @Test fun async_failure_noNetworkFound_takeHighest_false() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + val mockCallbacks = mock(GetRSSICallbacks::class.java) + wiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkNotFoundToRetrieveRSSI() + } + + @Test fun async_failure_noNetworkFound_takeHighest_false_nullCallback() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + nullCallbackUtil.callGetRSSI(false) + } + + @Test fun async_failure_noNetworkFound_takeHighest_true() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + val mockCallbacks = mock(GetRSSICallbacks::class.java) + wiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkNotFoundToRetrieveRSSI() + } + + @Test fun async_failure_noNetworkFound_takeHighest_true_nullCallback() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + nullCallbackUtil.callGetRSSI(true) + } + + @Test fun async_success_takeHighest_false() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + val mockCallbacks = mock(GetRSSICallbacks::class.java) + wiseFy.getRSSI(TEST_SSID, false, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedRSSI(TEST_RSSI_LEVEL) + } + + @Test fun async_success_takeHighest_false_nullCallback() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + nullCallbackUtil.callGetRSSI(false) + } + + @Test fun async_success_takeHighest_true() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + val mockCallbacks = mock(GetRSSICallbacks::class.java) + wiseFy.getRSSI(TEST_SSID, true, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedRSSI(TEST_RSSI_LEVEL) + } + + @Test fun async_success_takeHighest_true_nullCallback() { + mockWiseFyPrechecksUtil.getRSSI_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + nullCallbackUtil.callGetRSSI(true) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetSavedNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetSavedNetworkTests.kt new file mode 100644 index 00000000..8172ba28 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetSavedNetworkTests.kt @@ -0,0 +1,77 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to retrieve a saved on a device. + * + * @author Patches + */ +internal class GetSavedNetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.getSavedNetwork_failure() + assertEquals(null, wiseFy.getSavedNetwork(TEST_SSID)) + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.getSavedNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_null() + assertEquals(null, wiseFy.getSavedNetwork(TEST_SSID)) + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.getSavedNetwork_success() + val savedNetwork = mockWiseFySearchUtil.findSavedNetworkByRegex_success() + assertEquals(savedNetwork, wiseFy.getSavedNetwork(TEST_SSID)) + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.getSavedNetwork_failure() + val mockCallbacks = mock(GetSavedNetworkCallbacks::class.java) + wiseFy.getSavedNetwork(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.getSavedNetwork_failure() + nullCallbackUtil.callGetSavedNetwork(TEST_SSID) + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.getSavedNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_null() + val mockCallbacks = mock(GetSavedNetworkCallbacks::class.java) + wiseFy.getSavedNetwork(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).savedNetworkNotFound() + } + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.getSavedNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_null() + nullCallbackUtil.callGetSavedNetwork(TEST_SSID) + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.getSavedNetwork_success() + val savedNetwork = mockWiseFySearchUtil.findSavedNetworkByRegex_success() + val mockCallbacks = mock(GetSavedNetworkCallbacks::class.java) + wiseFy.getSavedNetwork(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSavedNetwork(savedNetwork) + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.getSavedNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + nullCallbackUtil.callGetSavedNetwork(TEST_SSID) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetSavedNetworksTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetSavedNetworksTests.kt new file mode 100644 index 00000000..35d0485f --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/GetSavedNetworksTests.kt @@ -0,0 +1,162 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to retrieve a list of saved networks on a device. + * + * @author Patches + */ +internal class GetSavedNetworksTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.getSavedNetworks_failure() + assertEquals(null, wiseFy.getSavedNetworks()) + verificationUtil.didNotTryToGetSavedNetworks() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + val savedNetworks = mockNetworkUtil.savedNetworks() + assertEquals(savedNetworks, wiseFy.getSavedNetworks()) + verificationUtil.triedToGetSavedNetworks() + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.getSavedNetworks_failure() + val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) + wiseFy.getSavedNetworks(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToGetSavedNetworks() + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.getSavedNetworks_failure() + nullCallbackUtil.callGetSavedNetworks() + verificationUtil.didNotTryToGetSavedNetworks() + } + + @Test fun async_failure_nullSavedNetworks() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + mockNetworkUtil.getConfiguredNetworks_null() + val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) + wiseFy.getSavedNetworks(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSavedNetworksFound() + verificationUtil.triedToGetSavedNetworks() + } + + @Test fun async_failure_nullSavedNetworks_nullCallback() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + mockNetworkUtil.getConfiguredNetworks_null() + nullCallbackUtil.callGetSavedNetworks() + verificationUtil.triedToGetSavedNetworks() + } + + @Test fun async_failure_emptyConfiguredNetworks() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + mockNetworkUtil.getConfiguredNetworks_emptyList() + val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) + wiseFy.getSavedNetworks(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSavedNetworksFound() + verificationUtil.triedToGetSavedNetworks() + } + + @Test fun async_failure_emptyConfiguredNetworks_nullCallback() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + mockNetworkUtil.getConfiguredNetworks_emptyList() + nullCallbackUtil.callGetSavedNetworks() + verificationUtil.triedToGetSavedNetworks() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + val savedNetworks = mockNetworkUtil.savedNetworks() + val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) + wiseFy.getSavedNetworks(mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSavedNetworks(savedNetworks) + verificationUtil.triedToGetSavedNetworks() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + mockNetworkUtil.savedNetworks() + nullCallbackUtil.callGetSavedNetworks() + verificationUtil.triedToGetSavedNetworks() + } + + @Test fun sync_failure_prechecks_withRegex() { + mockWiseFyPrechecksUtil.getSavedNetworks_failure() + assertEquals(null, wiseFy.getSavedNetworks(TEST_SSID)) + verificationUtil.didNotTryToGetSavedNetworks() + } + + @Test fun sync_success_withRegex() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + val savedNetwork = mockWiseFySearchUtil.findSavedNetworksMatchingRegex_success() + assertEquals(savedNetwork, wiseFy.getSavedNetworks(TEST_SSID)) + } + + @Test fun async_failure_prechecks_withRegex() { + mockWiseFyPrechecksUtil.getSavedNetworks_failure() + val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) + wiseFy.getSavedNetworks(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_failure_prechecks_withRegex_nullCallback() { + mockWiseFyPrechecksUtil.getSavedNetworks_failure() + nullCallbackUtil.callGetSavedNetworks_withRegex(TEST_SSID) + wiseFy.getSavedNetworks(TEST_SSID, null) + } + + @Test fun async_failure_withRegex_nullSavedNetworks() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + mockWiseFySearchUtil.findSavedNetworksByRegex_null() + val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) + wiseFy.getSavedNetworks(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSavedNetworksFound() + } + + @Test fun async_failure_withRegex_nullSavedNetworks_nullCallback() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + mockWiseFySearchUtil.findSavedNetworksByRegex_null() + nullCallbackUtil.callGetSavedNetworks_withRegex(TEST_SSID) + } + + @Test fun async_failure_withRegex_emptyConfiguredNetworks() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + mockWiseFySearchUtil.findSavedNetworksByRegex_emptyList() + val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) + wiseFy.getSavedNetworks(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSavedNetworksFound() + } + + @Test fun async_failure_withRegex_emptyConfiguredNetworks_nullCallback() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + mockWiseFySearchUtil.findSavedNetworksByRegex_emptyList() + nullCallbackUtil.callGetSavedNetworks_withRegex(TEST_SSID) + } + + @Test fun async_success_withRegex() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + val savedNetworks = mockWiseFySearchUtil.findSavedNetworksMatchingRegex_success() + val mockCallbacks = mock(GetSavedNetworksCallbacks::class.java) + wiseFy.getSavedNetworks(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSavedNetworks(savedNetworks) + } + + @Test fun async_success_withRegex_nullCallbacks() { + mockWiseFyPrechecksUtil.getSavedNetworks_success() + mockWiseFySearchUtil.findSavedNetworksMatchingRegex_success() + nullCallbackUtil.callGetSavedNetworks_withRegex(TEST_SSID) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToMobileNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToMobileNetworkTests.kt new file mode 100644 index 00000000..106b8464 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToMobileNetworkTests.kt @@ -0,0 +1,32 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * Tests the ability to determine if a device is connected to a mobile network. + * + * @author Patches + */ +internal class IsDeviceConnectedToMobileNetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_prechecks() { + mockWiseFyPrechecksUtil.isDeviceConnectedToMobileNetwork_failure() + assertFalse(wiseFy.isDeviceConnectedToMobileNetwork()) + } + + @Test fun failure() { + mockWiseFyPrechecksUtil.isDeviceConnectedToMobileNetwork_success() + mockWiseFyConnectionUtil.isNetworkConnectedAndMatchesType(false) + assertFalse(wiseFy.isDeviceConnectedToMobileNetwork()) + } + + @Test fun success() { + mockWiseFyPrechecksUtil.isDeviceConnectedToMobileNetwork_success() + mockNetworkUtil.activeNetwork() + mockWiseFyConnectionUtil.isNetworkConnectedAndMatchesType(true) + assertTrue(wiseFy.isDeviceConnectedToMobileNetwork()) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToMobileOrWifiNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToMobileOrWifiNetworkTests.kt new file mode 100644 index 00000000..9d563824 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToMobileOrWifiNetworkTests.kt @@ -0,0 +1,32 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * Tests the ability to determine if a device is connected to a mobile or wifi network. + * + * @author Patches + */ +internal class IsDeviceConnectedToMobileOrWifiNetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_missingPrerequisite() { + mockWiseFyPrechecksUtil.isDeviceConnectedToMobileOrWifiNetwork_failure() + assertFalse(wiseFy.isDeviceConnectedToMobileOrWifiNetwork()) + } + + @Test fun failure() { + mockWiseFyPrechecksUtil.isDeviceConnectedToMobileOrWifiNetwork_success() + mockWiseFyConnectionUtil.isNetworkConnected(false) + assertFalse(wiseFy.isDeviceConnectedToMobileOrWifiNetwork()) + } + + @Test fun success() { + mockWiseFyPrechecksUtil.isDeviceConnectedToMobileOrWifiNetwork_success() + mockNetworkUtil.activeNetwork() + mockWiseFyConnectionUtil.isNetworkConnected(true) + assertTrue(wiseFy.isDeviceConnectedToMobileOrWifiNetwork()) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToSSIDTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToSSIDTests.kt new file mode 100644 index 00000000..78f45193 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToSSIDTests.kt @@ -0,0 +1,32 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * Tests the ability to determine if a device is connected to an SSID. + * + * @author Patches + */ +internal class IsDeviceConnectedToSSIDTests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_prechecks() { + mockWiseFyPrechecksUtil.isDeviceConnectedToSSIDChecks_failure() + assertFalse(wiseFy.isDeviceConnectedToSSID(TEST_SSID)) + } + + @Test fun failure() { + mockWiseFyPrechecksUtil.isDeviceConnectedToSSIDChecks_success() + mockWiseFyConnectionUtil.isCurrentNetworkConnectedToSSID(false) + assertFalse(wiseFy.isDeviceConnectedToSSID(TEST_SSID)) + } + + @Test fun success() { + mockWiseFyPrechecksUtil.isDeviceConnectedToSSIDChecks_success() + mockWiseFyConnectionUtil.isCurrentNetworkConnectedToSSID(true) + assertTrue(wiseFy.isDeviceConnectedToSSID(TEST_SSID)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToWifiNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToWifiNetworkTests.kt new file mode 100644 index 00000000..0eff28f4 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceConnectedToWifiNetworkTests.kt @@ -0,0 +1,32 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * Tests the ability to determine if a device is connected to a wifi network. + * + * @author Patches + */ +internal class IsDeviceConnectedToWifiNetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_missingPrerequisite() { + mockWiseFyPrechecksUtil.isDeviceConnectedToWifiNetwork_failure() + assertFalse(wiseFy.isDeviceConnectedToWifiNetwork()) + } + + @Test fun failure() { + mockWiseFyPrechecksUtil.isDeviceConnectedToWifiNetwork_success() + mockWiseFyConnectionUtil.isNetworkConnectedAndMatchesType(false) + assertFalse(wiseFy.isDeviceConnectedToWifiNetwork()) + } + + @Test fun success() { + mockWiseFyPrechecksUtil.isDeviceConnectedToWifiNetwork_success() + mockNetworkUtil.activeNetwork() + mockWiseFyConnectionUtil.isNetworkConnectedAndMatchesType(true) + assertTrue(wiseFy.isDeviceConnectedToWifiNetwork()) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceRoamingTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceRoamingTests.kt new file mode 100644 index 00000000..5975606d --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsDeviceRoamingTests.kt @@ -0,0 +1,37 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * Tests the ability to determine if a device is roaming. + * + * @author Patches + */ +internal class IsDeviceRoamingTests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_missingPrerequisite() { + mockWiseFyPrechecksUtil.isDeviceRoaming_failure() + assertFalse(wiseFy.isDeviceRoaming()) + } + + @Test fun failure_nullActiveNetworkInfo() { + mockWiseFyPrechecksUtil.isDeviceRoaming_success() + mockNetworkUtil.currentNetwork_null() + assertFalse(wiseFy.isDeviceRoaming()) + } + + @Test fun failure() { + mockWiseFyPrechecksUtil.isDeviceRoaming_success() + mockNetworkUtil.isDeviceRoaming(false) + assertFalse(wiseFy.isDeviceRoaming()) + } + + @Test fun success() { + mockWiseFyPrechecksUtil.isDeviceRoaming_success() + mockNetworkUtil.isDeviceRoaming(true) + assertTrue(wiseFy.isDeviceRoaming()) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetwork5gHzTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetwork5gHzTests.kt new file mode 100644 index 00000000..cc9f3d03 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetwork5gHzTests.kt @@ -0,0 +1,92 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_NETWORK_FREQUENCY_5GHZ +import com.isupatches.wisefy.TEST_NETWORK_FREQUENCY_ABOVE_5GHZ +import com.isupatches.wisefy.TEST_NETWORK_FREQUENCY_BELOW_5GHZ + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Tests the ability to determine if a network is 5 gHz. + * + * @author Patches + */ +internal class IsNetwork5gHzTests : BaseAndroidJUnit4TestClass() { + + @Test fun currentNetwork_failure_above5ghz() { + if (preLollipop()) { + return + } + + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ) + assertEquals(false, wiseFy.isNetwork5gHz()) + } + + @Test fun currentNetwork_failure_below5ghz() { + if (preLollipop()) { + return + } + + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_BELOW_5GHZ) + assertEquals(false, wiseFy.isNetwork5gHz()) + } + + @Test fun currentNetwork_failure_null() { + if (preLollipop()) { + return + } + + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + mockNetworkUtil.currentNetwork_null() + assertEquals(false, wiseFy.isNetwork5gHz()) + } + + @Test fun currentNetwork_success() { + if (preLollipop()) { + return + } + + mockWiseFyPrechecksUtil.getCurrentNetwork_success() + mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_5GHZ) + assertEquals(true, wiseFy.isNetwork5gHz()) + } + + @Test fun provideWifiInfo_failure_above5ghz() { + if (preLollipop()) { + return + } + + val network = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_ABOVE_5GHZ) + assertEquals(false, wiseFy.isNetwork5gHz(network)) + } + + @Test fun provideWifiInfo_failure_below5ghz() { + if (preLollipop()) { + return + } + + val network = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_BELOW_5GHZ) + assertEquals(false, wiseFy.isNetwork5gHz(network)) + } + + @Test fun provideWifiInfo_failure_null() { + if (preLollipop()) { + return + } + + assertEquals(false, wiseFy.isNetwork5gHz(null)) + } + + @Test fun provideWifiInfo_success() { + if (preLollipop()) { + return + } + + val mockWifiInfo = mockNetworkUtil.networkWithFrequency(TEST_NETWORK_FREQUENCY_5GHZ) + assertEquals(true, wiseFy.isNetwork5gHz(mockWifiInfo)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkEAPTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkEAPTests.kt new file mode 100644 index 00000000..7252520c --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkEAPTests.kt @@ -0,0 +1,40 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.constants.EAP +import com.isupatches.wisefy.createMockAccessPointWithCapabilities + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Tests the ability to determine if a network has EAP security. + * + * @author Patches + */ +internal class IsNetworkEAPTests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_differentCapability() { + val scanResult = createMockAccessPointWithCapabilities("Other") + assertEquals(false, wiseFy.isNetworkEAP(scanResult)) + } + + @Test fun failure_emptyCapabilities() { + val scanResult = createMockAccessPointWithCapabilities("") + assertEquals(false, wiseFy.isNetworkEAP(scanResult)) + } + + @Test fun failure_nullCapabilities() { + val scanResult = createMockAccessPointWithCapabilities(null) + assertEquals(false, wiseFy.isNetworkEAP(scanResult)) + } + + @Test fun failure_nullScanResult() { + assertEquals(false, wiseFy.isNetworkEAP(null)) + } + + @Test fun success() { + val scanResult = createMockAccessPointWithCapabilities(EAP) + assertEquals(true, wiseFy.isNetworkEAP(scanResult)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkPSKTest.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkPSKTest.kt new file mode 100644 index 00000000..0756974a --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkPSKTest.kt @@ -0,0 +1,40 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.constants.PSK +import com.isupatches.wisefy.createMockAccessPointWithCapabilities + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Tests the ability to determine if a network has PSK security. + * + * @author Patches + */ +internal class IsNetworkPSKTest : BaseAndroidJUnit4TestClass() { + + @Test fun failure_differentCapability() { + val scanResult = createMockAccessPointWithCapabilities("Other") + assertEquals(false, wiseFy.isNetworkPSK(scanResult)) + } + + @Test fun failure_emptyCapabilities() { + val scanResult = createMockAccessPointWithCapabilities("") + assertEquals(false, wiseFy.isNetworkPSK(scanResult)) + } + + @Test fun failure_nullCapabilities() { + val scanResult = createMockAccessPointWithCapabilities(null) + assertEquals(false, wiseFy.isNetworkPSK(scanResult)) + } + + @Test fun failure_nullScanResult() { + assertEquals(false, wiseFy.isNetworkPSK(null)) + } + + @Test fun success() { + val scanResult = createMockAccessPointWithCapabilities(PSK) + assertEquals(true, wiseFy.isNetworkPSK(scanResult)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkSavedTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkSavedTests.kt new file mode 100644 index 00000000..b698dec8 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkSavedTests.kt @@ -0,0 +1,32 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Tests the ability to determine if a network is in a device's list of saved networks. + * + * @author Patches + */ +internal class IsNetworkSavedTests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_missingPrerequisite() { + mockWiseFyPrechecksUtil.isNetworkSaved_failure() + assertEquals(false, wiseFy.isNetworkSaved(TEST_SSID)) + } + + @Test fun failure() { + mockWiseFyPrechecksUtil.isNetworkSaved_success() + mockWiseFySearchUtil.isNetworkASavedConfiguration(false) + assertEquals(false, wiseFy.isNetworkSaved(TEST_SSID)) + } + + @Test fun success() { + mockWiseFyPrechecksUtil.isNetworkSaved_success() + mockWiseFySearchUtil.isNetworkASavedConfiguration(true) + assertEquals(true, wiseFy.isNetworkSaved(TEST_SSID)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkSecureTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkSecureTests.kt new file mode 100644 index 00000000..63506a99 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkSecureTests.kt @@ -0,0 +1,64 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.constants.EAP +import com.isupatches.wisefy.constants.PSK +import com.isupatches.wisefy.constants.WEP +import com.isupatches.wisefy.constants.WPA +import com.isupatches.wisefy.constants.WPA2 +import com.isupatches.wisefy.createMockAccessPointWithCapabilities + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Tests the ability to determine if a network is secure. + * + * @author Patches + */ +internal class IsNetworkSecureTests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_emptyCapabilities() { + val scanResult = createMockAccessPointWithCapabilities("") + assertEquals(false, wiseFy.isNetworkSecure(scanResult)) + } + + @Test fun failure_nullCapabilities() { + val scanResult = createMockAccessPointWithCapabilities(null) + assertEquals(false, wiseFy.isNetworkSecure(scanResult)) + } + + @Test fun failure_nullScanResult() { + assertEquals(false, wiseFy.isNetworkSecure(null)) + } + + @Test fun success_withEAP() { + val scanResult = createMockAccessPointWithCapabilities(EAP) + assertEquals(true, wiseFy.isNetworkSecure(scanResult)) + } + + @Test fun success_withPSK() { + val scanResult = createMockAccessPointWithCapabilities(PSK) + assertEquals(true, wiseFy.isNetworkSecure(scanResult)) + } + + @Test fun success_withWEP() { + val scanResult = createMockAccessPointWithCapabilities(WEP) + assertEquals(true, wiseFy.isNetworkSecure(scanResult)) + } + + @Test fun success_withWPA() { + val scanResult = createMockAccessPointWithCapabilities(WPA) + assertEquals(true, wiseFy.isNetworkSecure(scanResult)) + } + + @Test fun success_withWPA2() { + val scanResult = createMockAccessPointWithCapabilities(WPA2) + assertEquals(true, wiseFy.isNetworkSecure(scanResult)) + } + + @Test fun failure_otherCapabilities() { + val scanResult = createMockAccessPointWithCapabilities("Other") + assertEquals(false, wiseFy.isNetworkSecure(scanResult)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWPA2Test.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWPA2Test.kt new file mode 100644 index 00000000..6f98f4a4 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWPA2Test.kt @@ -0,0 +1,40 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.constants.WPA2 +import com.isupatches.wisefy.createMockAccessPointWithCapabilities + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Tests the ability to determine if a network has WPA2 security. + * + * @author Patches + */ +internal class IsNetworkWPA2Test : BaseAndroidJUnit4TestClass() { + + @Test fun failure_differentCapability() { + val scanResult = createMockAccessPointWithCapabilities("Other") + assertEquals(false, wiseFy.isNetworkWPA2(scanResult)) + } + + @Test fun failure_emptyCapabilities() { + val scanResult = createMockAccessPointWithCapabilities("") + assertEquals(false, wiseFy.isNetworkWPA2(scanResult)) + } + + @Test fun failure_nullCapabilities() { + val scanResult = createMockAccessPointWithCapabilities(null) + assertEquals(false, wiseFy.isNetworkWPA2(scanResult)) + } + + @Test fun failure_nullScanResult() { + assertEquals(false, wiseFy.isNetworkWPA2(null)) + } + + @Test fun success() { + val scanResult = createMockAccessPointWithCapabilities(WPA2) + assertEquals(true, wiseFy.isNetworkWPA2(scanResult)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWPATests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWPATests.kt new file mode 100644 index 00000000..c0132351 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWPATests.kt @@ -0,0 +1,40 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.constants.WPA +import com.isupatches.wisefy.createMockAccessPointWithCapabilities + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Tests the ability to determine if a network has WPA security. + * + * @author Patches + */ +internal class IsNetworkWPATests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_differentCapability() { + val scanResult = createMockAccessPointWithCapabilities("Other") + assertEquals(false, wiseFy.isNetworkWPA(scanResult)) + } + + @Test fun failure_emptyCapabilities() { + val scanResult = createMockAccessPointWithCapabilities("") + assertEquals(false, wiseFy.isNetworkWPA(scanResult)) + } + + @Test fun failure_nullCapabilities() { + val scanResult = createMockAccessPointWithCapabilities(null) + assertEquals(false, wiseFy.isNetworkWPA(scanResult)) + } + + @Test fun failure_nullScanResult() { + assertEquals(false, wiseFy.isNetworkWPA(null)) + } + + @Test fun success() { + val scanResult = createMockAccessPointWithCapabilities(WPA) + assertEquals(true, wiseFy.isNetworkWPA(scanResult)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWepTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWepTests.kt new file mode 100644 index 00000000..e1096810 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsNetworkWepTests.kt @@ -0,0 +1,40 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.constants.WEP +import com.isupatches.wisefy.createMockAccessPointWithCapabilities + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Tests the ability to determine if a network has WEP security. + * + * @author Patches + */ +internal class IsNetworkWepTests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_differentCapability() { + val scanResult = createMockAccessPointWithCapabilities("Other") + assertEquals(false, wiseFy.isNetworkWEP(scanResult)) + } + + @Test fun failure_emptyCapabilities() { + val scanResult = createMockAccessPointWithCapabilities("") + assertEquals(false, wiseFy.isNetworkWEP(scanResult)) + } + + @Test fun failure_nullCapabilities() { + val scanResult = createMockAccessPointWithCapabilities(null) + assertEquals(false, wiseFy.isNetworkWEP(scanResult)) + } + + @Test fun failure_nullScanResult() { + assertEquals(false, wiseFy.isNetworkWEP(null)) + } + + @Test fun success() { + val scanResult = createMockAccessPointWithCapabilities(WEP) + assertEquals(true, wiseFy.isNetworkWEP(scanResult)) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsWifiEnabledTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsWifiEnabledTests.kt new file mode 100644 index 00000000..c883654b --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/IsWifiEnabledTests.kt @@ -0,0 +1,30 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Tests the ability to determine if wifi is enabled on a device. + * + * @author Patches + */ +internal class IsWifiEnabledTests : BaseAndroidJUnit4TestClass() { + + @Test fun failure_prechecks() { + mockWiseFyPrechecksUtil.isWifiEnabled_failure() + assertEquals(false, wiseFy.isWifiEnabled()) + } + + @Test fun failure() { + mockWiseFyPrechecksUtil.isWifiEnabled_success() + mockNetworkUtil.isWifiEnabled(false) + assertEquals(false, wiseFy.isWifiEnabled()) + } + + @Test fun success() { + mockWiseFyPrechecksUtil.isWifiEnabled_success() + mockNetworkUtil.isWifiEnabled(true) + assertEquals(true, wiseFy.isWifiEnabled()) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/RemoveNetworkTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/RemoveNetworkTests.kt new file mode 100644 index 00000000..dda2a679 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/RemoveNetworkTests.kt @@ -0,0 +1,115 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Tests the ability to remove a network from a device's list of saved networks. + * + * @author Patches + */ +internal class RemoveNetworkTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks() { + mockWiseFyPrechecksUtil.removeNetwork_failure() + assertEquals(false, wiseFy.removeNetwork(TEST_SSID)) + verificationUtil.didNotTryToRemoveNetwork() + } + + @Test fun sync_failure_noSavedNetwork() { + mockWiseFyPrechecksUtil.removeNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_null() + assertEquals(false, wiseFy.removeNetwork(TEST_SSID)) + verificationUtil.didNotTryToRemoveNetwork() + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.removeNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockNetworkUtil.removeNetwork(false) + assertEquals(false, wiseFy.removeNetwork(TEST_SSID)) + verificationUtil.triedToRemoveNetwork() + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.removeNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockNetworkUtil.removeNetwork(true) + assertEquals(true, wiseFy.removeNetwork(TEST_SSID)) + verificationUtil.triedToRemoveNetwork() + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.removeNetwork_failure() + val mockCallbacks = mock(RemoveNetworkCallbacks::class.java) + wiseFy.removeNetwork(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + verificationUtil.didNotTryToRemoveNetwork() + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.removeNetwork_failure() + nullCallbackUtil.callRemoveNetwork(TEST_SSID) + verificationUtil.didNotTryToRemoveNetwork() + } + + @Test fun async_failure_noSavedNetwork() { + mockWiseFyPrechecksUtil.removeNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_null() + val mockCallbacks = mock(RemoveNetworkCallbacks::class.java) + wiseFy.removeNetwork(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkNotFoundToRemove() + verificationUtil.didNotTryToRemoveNetwork() + } + + @Test fun async_failure_noSavedNetwork_nullCallback() { + mockWiseFyPrechecksUtil.removeNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_null() + nullCallbackUtil.callRemoveNetwork(TEST_SSID) + verificationUtil.didNotTryToRemoveNetwork() + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.removeNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockNetworkUtil.removeNetwork(false) + val mockCallbacks = mock(RemoveNetworkCallbacks::class.java) + wiseFy.removeNetwork(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).failureRemovingNetwork() + verificationUtil.triedToRemoveNetwork() + } + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.removeNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockNetworkUtil.removeNetwork(false) + nullCallbackUtil.callRemoveNetwork(TEST_SSID) + verificationUtil.triedToRemoveNetwork() + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.removeNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockNetworkUtil.removeNetwork(true) + val mockCallbacks = mock(RemoveNetworkCallbacks::class.java) + wiseFy.removeNetwork(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).networkRemoved() + verificationUtil.triedToRemoveNetwork() + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.removeNetwork_success() + mockWiseFySearchUtil.findSavedNetworkByRegex_success() + mockNetworkUtil.removeNetwork(true) + nullCallbackUtil.callRemoveNetwork(TEST_SSID) + verificationUtil.triedToRemoveNetwork() + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForAccessPointTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForAccessPointTests.kt new file mode 100644 index 00000000..7432c8b7 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForAccessPointTests.kt @@ -0,0 +1,135 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.TEST_TIMEOUT +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Used to test the functionality to search for a set of nearby access points. + * + * @author Patches + */ +internal class SearchForAccessPointTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoint_failure() + assertEquals(null, wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun sync_failure_prechecks_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoint_failure() + assertEquals(null, wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun sync_failure_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + assertEquals(null, wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun sync_failure_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + assertEquals(null, wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun sync_success_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + val accessPoint = mockWiseFySearchUtil.findAccessPointByRegex_success() + assertEquals(accessPoint, wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false)) + } + + @Test fun sync_success_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + val accessPoint = mockWiseFySearchUtil.findAccessPointByRegex_success() + assertEquals(accessPoint, wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true)) + } + + @Test fun async_failure_prechecks_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoint_failure() + val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) + wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_failure_prechecks_filterDuplicates_false_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoint_failure() + nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, false) + } + + @Test fun async_failure_prechecks_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoint_failure() + val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) + wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_failure_prechecks_filterDuplicates_true_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoint_failure() + nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, true) + } + + @Test fun async_failure_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) + wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointNotFound() + } + + @Test fun async_failure_filterDuplicates_false_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, false) + } + + @Test fun async_failure_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) + wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointNotFound() + } + + @Test fun async_failure_filterDuplicates_true_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, true) + } + + @Test fun async_success_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + val accessPoint = mockWiseFySearchUtil.findAccessPointByRegex_success() + val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) + wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, false, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointFound(accessPoint) + } + + @Test fun async_success_filterDuplicates_false_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, false) + } + + @Test fun async_success_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + val accessPoint = mockWiseFySearchUtil.findAccessPointByRegex_success() + val mockCallbacks = mock(SearchForAccessPointCallbacks::class.java) + wiseFy.searchForAccessPoint(TEST_SSID, TEST_TIMEOUT, true, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).accessPointFound(accessPoint) + } + + @Test fun async_success_filterDuplicates_true_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoint_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + nullCallbackUtil.callSearchForAccessPoint(TEST_SSID, true) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForAccessPointsTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForAccessPointsTests.kt new file mode 100644 index 00000000..9fc5885e --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForAccessPointsTests.kt @@ -0,0 +1,135 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Used to test the functionality to search for a nearby access point. + * + * @author Patches + */ +internal class SearchForAccessPointsTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_prechecks_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoints_failure() + assertEquals(null, wiseFy.searchForAccessPoints(TEST_SSID, false)) + } + + @Test fun sync_failure_prechecks_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoints_failure() + assertEquals(null, wiseFy.searchForAccessPoints(TEST_SSID, true)) + } + + @Test fun sync_failure_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() + assertEquals(null, wiseFy.searchForAccessPoints(TEST_SSID, false)) + } + + @Test fun sync_failure_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() + assertEquals(null, wiseFy.searchForAccessPoints(TEST_SSID, true)) + } + + @Test fun sync_success_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + val accessPoints = mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() + assertEquals(accessPoints, wiseFy.searchForAccessPoints(TEST_SSID, false)) + } + + @Test fun sync_success_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + val accessPoints = mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() + assertEquals(accessPoints, wiseFy.searchForAccessPoints(TEST_SSID, true)) + } + + @Test fun async_failure_prechecks_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoints_failure() + val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) + wiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_failure_prechecks_filterDuplicates_false_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoints_failure() + nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, false) + } + + @Test fun async_failure_prechecks_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoints_failure() + val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) + wiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_failure_prechecks_filterDuplicates_true_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoints_failure() + nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, true) + } + + @Test fun async_failure_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() + val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) + wiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noAccessPointsFound() + } + + @Test fun async_failure_filterDuplicates_false_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() + nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, false) + } + + @Test fun async_failure_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() + val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) + wiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noAccessPointsFound() + } + + + @Test fun async_failure_filterDuplicates_true_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + mockWiseFySearchUtil.findAccessPointsMatchingRegex_null() + nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, true) + } + + @Test fun async_success_filterDuplicates_false() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + val accessPoints = mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() + val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) + wiseFy.searchForAccessPoints(TEST_SSID, false, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).foundAccessPoints(accessPoints) + } + + @Test fun async_success_filterDuplicates_false_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() + nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, false) + } + + @Test fun async_success_filterDuplicates_true() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + val accessPoints = mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() + val mockCallbacks = mock(SearchForAccessPointsCallbacks::class.java) + wiseFy.searchForAccessPoints(TEST_SSID, true, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).foundAccessPoints(accessPoints) + } + + @Test fun async_success_filterDuplicates_true_nullCallback() { + mockWiseFyPrechecksUtil.searchForAccessPoints_success() + mockWiseFySearchUtil.findAccessPointsMatchingRegex_success() + nullCallbackUtil.callSearchForAccessPoints(TEST_SSID, true) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForSSIDTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForSSIDTests.kt new file mode 100644 index 00000000..2d310dd6 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForSSIDTests.kt @@ -0,0 +1,79 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.TEST_TIMEOUT +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Used to test the functionality to search for SSIDs nearby. + * + * @author Patches + */ +internal class SearchForSSIDTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_missingPrerequisite() { + mockWiseFyPrechecksUtil.searchForSSID_failure() + assertEquals(null, wiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT)) + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.searchForSSID_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + assertEquals(null, wiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT)) + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.searchForSSID_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + assertEquals(TEST_SSID, wiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT)) + } + + @Test fun async_failure_missingPrerequisite() { + mockWiseFyPrechecksUtil.searchForSSID_failure() + val mockCallbacks = mock(SearchForSSIDCallbacks::class.java) + wiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_failure_missingPrerequisite_nullCallback() { + mockWiseFyPrechecksUtil.searchForSSID_failure() + nullCallbackUtil.callSearchForSSID(TEST_SSID) + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.searchForSSID_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + val mockCallbacks = mock(SearchForSSIDCallbacks::class.java) + wiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).ssidNotFound() + } + + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.searchForSSID_success() + mockWiseFySearchUtil.findAccessPointByRegex_null() + nullCallbackUtil.callSearchForSSID(TEST_SSID) + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.searchForSSID_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + val mockCallbacks = mock(SearchForSSIDCallbacks::class.java) + wiseFy.searchForSSID(TEST_SSID, TEST_TIMEOUT, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).ssidFound(TEST_SSID) + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.searchForSSID_success() + mockWiseFySearchUtil.findAccessPointByRegex_success() + nullCallbackUtil.callSearchForSSID(TEST_SSID) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForSSIDsTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForSSIDsTests.kt new file mode 100644 index 00000000..7b54ff4f --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/main/SearchForSSIDsTests.kt @@ -0,0 +1,78 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.VERIFICATION_SUCCESS_TIMEOUT +import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import org.junit.Assert.assertEquals +import org.junit.Test +import org.mockito.Mockito.mock +import org.mockito.Mockito.timeout +import org.mockito.Mockito.verify + +/** + * Used to test the functionality to search for SSIDs nearby. + * + * @author Patches + */ +internal class SearchForSSIDsTests : BaseAndroidJUnit4TestClass() { + + @Test fun sync_failure_precheck() { + mockWiseFyPrechecksUtil.searchForSSIDs_failure() + assertEquals(null, wiseFy.searchForSSIDs(TEST_SSID)) + } + + @Test fun sync_failure() { + mockWiseFyPrechecksUtil.searchForSSIDs_success() + mockWiseFySearchUtil.findSSIDsMatchingRegex_null() + assertEquals(null, wiseFy.searchForSSIDs(TEST_SSID)) + } + + @Test fun sync_success() { + mockWiseFyPrechecksUtil.searchForSSIDs_success() + val ssids = mockWiseFySearchUtil.findSSIDsMatchingRegex_success() + assertEquals(ssids, wiseFy.searchForSSIDs(TEST_SSID)) + } + + @Test fun async_failure_prechecks() { + mockWiseFyPrechecksUtil.searchForSSIDs_failure() + val mockCallbacks = mock(SearchForSSIDsCallbacks::class.java) + wiseFy.searchForSSIDs(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).wisefyFailure(MISSING_PARAMETER) + } + + @Test fun async_failure_prechecks_nullCallback() { + mockWiseFyPrechecksUtil.searchForSSIDs_failure() + nullCallbackUtil.callSearchForSSIDs(TEST_SSID) + } + + @Test fun async_failure() { + mockWiseFyPrechecksUtil.searchForSSIDs_success() + mockWiseFySearchUtil.findSSIDsMatchingRegex_null() + val mockCallbacks = mock(SearchForSSIDsCallbacks::class.java) + wiseFy.searchForSSIDs(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).noSSIDsFound() + } + + + @Test fun async_failure_nullCallback() { + mockWiseFyPrechecksUtil.searchForSSIDs_success() + mockWiseFySearchUtil.findSSIDsMatchingRegex_null() + nullCallbackUtil.callSearchForSSIDs(TEST_SSID) + } + + @Test fun async_success() { + mockWiseFyPrechecksUtil.searchForSSIDs_success() + val ssids = mockWiseFySearchUtil.findSSIDsMatchingRegex_success() + val mockCallbacks = mock(SearchForSSIDsCallbacks::class.java) + wiseFy.searchForSSIDs(TEST_SSID, mockCallbacks) + verify(mockCallbacks, timeout(VERIFICATION_SUCCESS_TIMEOUT)).retrievedSSIDs(ssids) + } + + @Test fun async_success_nullCallback() { + mockWiseFyPrechecksUtil.searchForSSIDs_success() + mockWiseFySearchUtil.findSSIDsMatchingRegex_success() + nullCallbackUtil.callSearchForSSIDs(TEST_SSID) + } +} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java b/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java deleted file mode 100644 index 041e3edf..00000000 --- a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/BuilderTests.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.isupatches.wisefy.test; - - -import android.support.test.InstrumentationRegistry; -import com.isupatches.wisefy.WiseFy; -import org.junit.Test; -import static org.junit.Assert.assertEquals; - - -public class BuilderTests { - - @Test - public void builder_loggingFalse() { - WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(false).getSmarts(); - assertEquals(false, wiseFy.isLoggingEnabled()); - } - - @Test - public void builder_loggingTrue() { - WiseFy wiseFy = new WiseFy.brains(InstrumentationRegistry.getContext()).logging(true).getSmarts(); - assertEquals(true, wiseFy.isLoggingEnabled()); - } -} diff --git a/wisefy/src/androidTest/java/com/isupatches/wisefy/test/WiseFyTests.kt b/wisefy/src/androidTest/java/com/isupatches/wisefy/test/WiseFyTests.kt new file mode 100644 index 00000000..4b726da4 --- /dev/null +++ b/wisefy/src/androidTest/java/com/isupatches/wisefy/test/WiseFyTests.kt @@ -0,0 +1,57 @@ +package com.isupatches.wisefy.test + +import android.support.test.InstrumentationRegistry + +import com.google.android.gms.iid.InstanceID + +import com.isupatches.wisefy.BaseAndroidJUnit4TestClass +import com.isupatches.wisefy.TEST_NUMBER_OF_BARS +import com.isupatches.wisefy.TEST_RSSI_LEVEL_HIGH +import com.isupatches.wisefy.TEST_RSSI_LEVEL_LOW +import com.isupatches.wisefy.WiseFy + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull +import org.junit.Test + +/** + * Tests that pertain to the builder for WiseFy or general use. + * + * @author Patches + */ +internal class WiseFyTests : BaseAndroidJUnit4TestClass() { + + companion object { + private const val EXPECTED_NUMBER_OF_BARS = 4 + private const val EXPECTED_SIGNAL_RESULT = 35 + } + + @Test fun brains_loggingFalse() { + val wisefy = WiseFy.Brains(InstrumentationRegistry.getContext()).logging(false).getSmarts() + assertEquals(false, wisefy.isLoggingEnabled()) + } + + @Test fun brains_loggingTrue() { + val wisefy = WiseFy.Brains(InstrumentationRegistry.getContext()).logging(true).getSmarts() + assertEquals(true, wisefy.isLoggingEnabled()) + } + + @Test fun calculateBars() { + val result = wiseFy.calculateBars(TEST_RSSI_LEVEL_HIGH, TEST_NUMBER_OF_BARS) + assertEquals(EXPECTED_NUMBER_OF_BARS.toLong(), result.toLong()) + } + + @Test fun compareSignalLevel() { + val result = wiseFy.compareSignalLevel(TEST_RSSI_LEVEL_HIGH, TEST_RSSI_LEVEL_LOW) + assertEquals(EXPECTED_SIGNAL_RESULT.toLong(), result.toLong()) + } + + @Test fun getWiseFyLock() { + assertNotNull(wiseFy.getWiseFyLock()) + } + + @Test fun olderGcm_IllegalAccessError_notThrown() { + val instanceID = InstanceID.getInstance(InstrumentationRegistry.getContext()) + assertNotNull(instanceID) + } +} diff --git a/wisefy/src/commonTest/java/com/isupatches/wisefy/TestUtils.kt b/wisefy/src/commonTest/java/com/isupatches/wisefy/TestUtils.kt new file mode 100644 index 00000000..6c887f04 --- /dev/null +++ b/wisefy/src/commonTest/java/com/isupatches/wisefy/TestUtils.kt @@ -0,0 +1,69 @@ +package com.isupatches.wisefy + +import com.isupatches.wisefy.WiseFy.Companion.MAX_FREQUENCY_5GHZ +import com.isupatches.wisefy.WiseFy.Companion.MIN_FREQUENCY_5GHZ + +internal const val OPEN_NETWORK_SSID = "Open Network" + +internal const val WEP_NETWORK_SSID = "WEP Network" +internal const val WEP_NETWORK_PASSWORD = "12345678" + +internal const val WPA2_NETWORK_SSID = "WPA2 Network" +internal const val WPA2_NETWORK_PASSWORD = "123456" + +internal const val TEST_DELAY = 1 + +internal const val TEST_NUMBER_OF_BARS = 5 + +internal const val TEST_SSID = "Test Network" + +internal const val TEST_NETWORK_FREQUENCY_BELOW_5GHZ = MIN_FREQUENCY_5GHZ - 1 +internal const val TEST_NETWORK_FREQUENCY_ABOVE_5GHZ = MAX_FREQUENCY_5GHZ + 1 + +internal const val TEST_NETWORK_FREQUENCY_24GHZ = 2400 +internal const val TEST_NETWORK_FREQUENCY_5GHZ = 5000 + +internal const val TEST_RSSI_LEVEL = -60 +internal const val TEST_RSSI_LEVEL_LOW = -70 +internal const val TEST_RSSI_LEVEL_HIGH = -35 + +internal const val TEST_TIMEOUT = 1 + +internal const val VERIFICATION_SUCCESS_TIMEOUT = 5000L +internal const val VERIFICATION_FAILURE_TIMEOUT = 3000L + +internal const val TEST_IP_ADDRESS_STRING = "127.0.0.1" + +internal const val TEST_REGEX = ".*Test.*" + +internal const val TEST_TYPE1 = "TYPE 1" +internal const val TEST_TYPE2 = "TYPE 2" + +internal const val TEST_SSID2 = "Test Network 2" +internal const val TEST_SSID3 = "Test Network 3" + +internal val TEST_IP_ADDRESS_INT = getIntVersionOfTestIPAddress() + +private const val BIT_SHIFT_VALUE = 8 + + +/** + * To convert the TEST_IP_ADDRESS_STRING string into an integer value to be used for Inet and + * tests. + * + * @see #TEST_IP_ADDRESS_STRING + * + * @return int - The int value of a given IP + */ +private fun getIntVersionOfTestIPAddress(): Int { + var result = 0 + + // iterate over each octet + for (part in TEST_IP_ADDRESS_STRING.split(".")) { + // Shift the previously parsed bits over by 1 byte + result = result shl BIT_SHIFT_VALUE + // Set the low order bits to the current octet + result = result or part.toInt() + } + return result +} diff --git a/wisefy/src/main/AndroidManifest.xml b/wisefy/src/main/AndroidManifest.xml index 4cd649ff..127f6344 100644 --- a/wisefy/src/main/AndroidManifest.xml +++ b/wisefy/src/main/AndroidManifest.xml @@ -1,12 +1,13 @@ - - - + - - + + - + + + + \ No newline at end of file diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFy.java b/wisefy/src/main/java/com/isupatches/wisefy/WiseFy.java deleted file mode 100644 index 867b91ad..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/WiseFy.java +++ /dev/null @@ -1,2018 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy; - - -import android.annotation.TargetApi; -import android.content.Context; -import android.net.NetworkInfo; -import android.net.wifi.ScanResult; -import android.net.wifi.WifiConfiguration; -import android.net.wifi.WifiInfo; -import android.net.wifi.WifiManager; -import android.os.Build; -import android.os.Handler; -import android.os.Looper; -import android.text.TextUtils; -import android.util.Log; -import com.isupatches.wisefy.annotations.CallingThread; -import com.isupatches.wisefy.annotations.Async; -import com.isupatches.wisefy.annotations.PublicAPI; -import com.isupatches.wisefy.annotations.Sync; -import com.isupatches.wisefy.annotations.WaitsForTimeout; -import com.isupatches.wisefy.annotations.WiseFyThread; -import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks; -import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks; -import com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks; -import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks; -import com.isupatches.wisefy.callbacks.DisableWifiCallbacks; -import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks; -import com.isupatches.wisefy.callbacks.EnableWifiCallbacks; -import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks; -import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks; -import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks; -import com.isupatches.wisefy.callbacks.GetRSSICallbacks; -import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks; -import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks; -import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks; -import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks; -import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks; -import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks; -import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks; -import com.isupatches.wisefy.constants.Capabilities; -import com.isupatches.wisefy.constants.NetworkTypes; -import com.isupatches.wisefy.constants.WiseFyCodes; -import com.isupatches.wisefy.threads.WiseFyHandlerThread; -import com.isupatches.wisefy.util.LogUtil; -import com.isupatches.wisefy.util.ManagerUtil; -import com.isupatches.wisefy.util.WifiConfigurationUtil; -import java.util.List; - - -/** - * Main class for WiseFy that provides a synchronous and asynchronous API to manipulate and query - * for different parts of a device's wifi configuration and status. - * - * @author Patches - * @version 2.0 - * - * Uses the builder pattern for creation - {@link brains} - */ -@PublicAPI -public class WiseFy { - - private static final String TAG = WiseFy.class.getSimpleName(); - - public static final int WIFI_MANAGER_FAILURE = -1; - - public static final int MIN_FREQUENCY_5GHZ = 4900; - - public static final int MAX_FREQUENCY_5GHZ = 5900; - - private WiseFyHandlerThread mWiseFyHandlerThread; - - private Handler mWiseFyHandler; - - WiseFyConnection mWiseFyConnection; - - WiseFyConfiguration mWiseFyConfiguration; - - WiseFyPrerequisites mWiseFyPrerequisites; - - WiseFySearch mWiseFySearch; - - private final WiseFyLock mWiseFyLock = new WiseFyLock(); - - /** - * Private constructor that accepts builder input - */ - private WiseFy(brains brains) { - this.mWiseFyConfiguration = WiseFyConfiguration.getInstance(); - this.mWiseFyConnection = WiseFyConnection.getInstance(); - this.mWiseFyPrerequisites = WiseFyPrerequisites.getInstance(); - this.mWiseFySearch = WiseFySearch.getInstance(); - mWiseFyConfiguration.setLoggingEnabled(brains.loggingEnabled); - mWiseFyPrerequisites.setConnectivityManager(ManagerUtil.getInstance().getConnectivityManager(brains.context)); - mWiseFyPrerequisites.setWifiManager(ManagerUtil.getInstance().getWiFiManager(brains.context)); - } - - /** - * Static class for builder pattern - * - * Implements builder interfaces #{@link Logging} #{@link GetSmarts} - */ - public static class brains implements Logging, GetSmarts { - - private Context context; - - private boolean loggingEnabled; - - /** - * Mandatory - The public constructor for the builder that requires a context - * - * @param context The activity or application context to get a WifiConfiguration and - * ConnectivityManager instance - */ - public brains(Context context) { - this.context = context; - } - - /** - * Mandatory - To build and return a WiseFy instance - * - * *NOTE* Must be called after brains - * - * @see brains - * - * @return WiseFy - The instance created by the builder - */ - @Override - public WiseFy getSmarts() { - return new WiseFy(this); - } - - /** - * Optional - Builder method that enables/disables logging for a WiseWy instance - * - * @param loggingEnabled If logging is enabled or disabled for an instance - * - * @see Logging - * - * @return brains - The builder with updated logging setting - */ - @Override - public brains logging(boolean loggingEnabled) { - this.loggingEnabled = loggingEnabled; - return this; - } - } - - /** - * An interface that enables/disables logging for a WiseFy instance - */ - interface Logging { - brains logging(boolean loggingEnabled); - } - - /** - * An interface that builds a WiseFy instance - */ - interface GetSmarts { - WiseFy getSmarts(); - } - - /** - * To add an open network to the user's configured network list - * - * @param ssid The ssid of the open network you want to add - * - * @see #addNetworkConfiguration(WifiConfiguration) - * @see WifiConfigurationUtil#generateOpenNetworkConfiguration(String) - * @see WiseFyCodes - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#isNetworkASavedConfiguration(String) - * - * @return int - The return code from WifiManager for network creation (-1 for failure) - */ - @Sync - @CallingThread - public int addOpenNetwork(String ssid) { - if (TextUtils.isEmpty(ssid)) { - return WiseFyCodes.MISSING_PARAMETER; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return WiseFyCodes.MISSING_PREREQUISITE; - } - - if (mWiseFySearch.isNetworkASavedConfiguration(ssid)) { - return WiseFyCodes.NETWORK_ALREADY_CONFIGURED; - } - - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Adding open network with SSID %s", ssid)); - } - WifiConfiguration wifiConfiguration = WifiConfigurationUtil.getInstance().generateOpenNetworkConfiguration(ssid); - return addNetworkConfiguration(wifiConfiguration); - } - - /** - * To add an open network to the user's configured network list - * - * @param ssid The ssid of the open network you want to add - * @param callbacks The listener to return results to - * - * @see #addNetworkConfiguration(WifiConfiguration) - * @see #execute(Runnable) - * @see AddOpenNetworkCallbacks - * @see WifiConfigurationUtil#generateOpenNetworkConfiguration(String) - * @see WiseFyCodes - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#isNetworkASavedConfiguration(String) - */ - @Async - @WiseFyThread - public void addOpenNetwork(final String ssid, final AddOpenNetworkCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (TextUtils.isEmpty(ssid)) { - if (callbacks != null) { - callbacks.addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.addOpenNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - if (mWiseFySearch.isNetworkASavedConfiguration(ssid)) { - if (callbacks != null) { - callbacks.addOpenNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); - } - return; - } - - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Adding open network with SSID %s", ssid)); - } - WifiConfiguration wifiConfiguration = WifiConfigurationUtil.getInstance().generateOpenNetworkConfiguration(ssid); - int result = addNetworkConfiguration(wifiConfiguration); - if (callbacks != null) { - if (result != WIFI_MANAGER_FAILURE) { - callbacks.openNetworkAdded(wifiConfiguration); - } else { - callbacks.failureAddingOpenNetwork(result); - } - } - } - } - }; - execute(runnable); - } - - /** - * To add a WEP network to the user's configured network list - * - * @param ssid The ssid of the WEP network you want to add - * @param password The password for the WEP network being added - * - * @see #addNetworkConfiguration(WifiConfiguration) - * @see WifiConfigurationUtil#generateWEPNetworkConfiguration(String, String) - * @see WiseFyCodes - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#isNetworkASavedConfiguration(String) - * - * @return int - The return code from WifiManager for network creation (-1 for failure) - */ - @Sync - @CallingThread - public int addWEPNetwork(String ssid, String password) { - if (TextUtils.isEmpty(ssid) || TextUtils.isEmpty(password)) { - return WiseFyCodes.MISSING_PARAMETER; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return WiseFyCodes.MISSING_PREREQUISITE; - } - - if (mWiseFySearch.isNetworkASavedConfiguration(ssid)) { - return WiseFyCodes.NETWORK_ALREADY_CONFIGURED; - } - - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Adding WEP network with SSID %s", ssid)); - } - WifiConfiguration wifiConfiguration = WifiConfigurationUtil.getInstance().generateWEPNetworkConfiguration(ssid, password); - return addNetworkConfiguration(wifiConfiguration); - } - - /** - * To add a WEP network to the user's configured network list - * - * @param ssid The ssid of the WEP network you want to add - * @param password The password for the WEP network being added - * @param callbacks The listener to return results to - * - * @see #addNetworkConfiguration(WifiConfiguration) - * @see #execute(Runnable) - * @see AddWEPNetworkCallbacks - * @see WifiConfigurationUtil#generateWEPNetworkConfiguration(String, String) - * @see WiseFyCodes - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#isNetworkASavedConfiguration(String) - */ - @Async - @WiseFyThread - public void addWEPNetwork(final String ssid, final String password, final AddWEPNetworkCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - - if (TextUtils.isEmpty(ssid) || TextUtils.isEmpty(password)) { - if (callbacks != null) { - callbacks.addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - if (mWiseFySearch.isNetworkASavedConfiguration(ssid)) { - if (callbacks != null) { - callbacks.addWEPNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); - } - return; - } - - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Adding WEP network with SSID %s", ssid)); - } - WifiConfiguration wifiConfiguration = WifiConfigurationUtil.getInstance().generateWEPNetworkConfiguration(ssid, password); - int result = addNetworkConfiguration(wifiConfiguration); - if (callbacks != null) { - if (result != WIFI_MANAGER_FAILURE) { - callbacks.wepNetworkAdded(wifiConfiguration); - } else { - callbacks.failureAddingWEPNetwork(result); - } - } - } - } - }; - execute(runnable); - } - - /** - * To add a WPA2 network to the user's configured network list - * - * @param ssid The ssid of the WPA2 network you want to add - * @param password The password for the WPA2 network being added - * - * @see #addNetworkConfiguration(WifiConfiguration) - * @see WifiConfigurationUtil#generateWPA2NetworkConfiguration(String, String) - * @see WiseFyCodes - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#isNetworkASavedConfiguration(String) - * - * @return int - The return code from WifiManager for network creation (-1 for failure) - */ - @Sync - @CallingThread - public int addWPA2Network(String ssid, String password) { - if (TextUtils.isEmpty(ssid) || TextUtils.isEmpty(password)) { - return WiseFyCodes.MISSING_PARAMETER; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return WiseFyCodes.MISSING_PREREQUISITE; - } - - if (mWiseFySearch.isNetworkASavedConfiguration(ssid)) { - return WiseFyCodes.NETWORK_ALREADY_CONFIGURED; - } - - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Adding WPA2 network with SSID %s", ssid)); - } - WifiConfiguration wifiConfiguration = WifiConfigurationUtil.getInstance().generateWPA2NetworkConfiguration(ssid, password); - return addNetworkConfiguration(wifiConfiguration); - } - - /** - * To add a WPA2 network to the user's configured network list - * - * @param ssid The ssid of the WPA2 network you want to add - * @param password The password for the WPA2 network being added - * @param callbacks The listener to return results to - * - * @see #addNetworkConfiguration(WifiConfiguration) - * @see #execute(Runnable) - * @see AddWPA2NetworkCallbacks - * @see WifiConfigurationUtil#generateWPA2NetworkConfiguration(String, String) - * @see WiseFyCodes - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#isNetworkASavedConfiguration(String) - */ - @Async - @WiseFyThread - public void addWPA2Network(final String ssid, final String password, final AddWPA2NetworkCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (TextUtils.isEmpty(ssid) || TextUtils.isEmpty(password)) { - if (callbacks != null) { - callbacks.addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.addWPA2NetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - if (mWiseFySearch.isNetworkASavedConfiguration(ssid)) { - if (callbacks != null) { - callbacks.addWPA2NetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED); - } - return; - } - - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Adding WPA2 network with SSID %s", ssid)); - } - WifiConfiguration wifiConfiguration = WifiConfigurationUtil.getInstance().generateWPA2NetworkConfiguration(ssid, password); - int result = addNetworkConfiguration(wifiConfiguration); - if (callbacks != null) { - if (result != WIFI_MANAGER_FAILURE) { - callbacks.wpa2NetworkAdded(wifiConfiguration); - } else { - callbacks.failureAddingWPA2Network(result); - } - } - } - } - }; - execute(runnable); - } - - /** - * To convert an RSSI level for a network to a number of bars - * - * @param rssiLevel The signal strength of the network - * @param targetNumberOfBars How many bars or levels there will be total - * - * @return int - The number of bars for the given RSSI value - */ - @Sync - @CallingThread - public int calculateBars(int rssiLevel, int targetNumberOfBars) { - return WifiManager.calculateSignalLevel(rssiLevel, targetNumberOfBars); - } - - /** - * To compare the signal strength of two networks - * - * @param rssi1 The signal strength of network 1 - * @param rssi2 The signal strength of network 2 - * - * @return int - Returns negative value if the first signal is weaker than the second signal, 0 if the two - * signals have the same strength, and a positive value if the first signal is stronger than the second signal. - */ - @Sync - @CallingThread - public int compareSignalLevel(int rssi1, int rssi2) { - return WifiManager.compareSignalLevel(rssi1, rssi2); - } - - /** - * Used to connect to a network - * - * Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity - * - * @param ssidToConnectTo The ssid to connect/reconnect to - * @param timeoutInMillis The number of milliseconds to continue waiting for the device to connect to the given SSID - * - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyConnection#waitToConnectToSSID(String, int) - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findSavedNetworkByRegex(String) - * - * @return boolean - If the network was successfully reconnected - */ - @Sync - @CallingThread - @WaitsForTimeout - public boolean connectToNetwork(String ssidToConnectTo, int timeoutInMillis) { - if (TextUtils.isEmpty(ssidToConnectTo) || !mWiseFyPrerequisites.hasPrerequisites()) { - return false; - } - - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Waiting %d to connect to network with ssid %s", timeoutInMillis, ssidToConnectTo)); - } - - WifiConfiguration wifiConfiguration = mWiseFySearch.findSavedNetworkByRegex(ssidToConnectTo); - if (wifiConfiguration != null) { - mWiseFyPrerequisites.getWifiManager().disconnect(); - mWiseFyPrerequisites.getWifiManager().enableNetwork(wifiConfiguration.networkId, true); - mWiseFyPrerequisites.getWifiManager().reconnect(); - return mWiseFyConnection.waitToConnectToSSID(ssidToConnectTo, timeoutInMillis); - } - - return false; - } - - /** - * Used to connect to a network - * - * Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity - * - * @param ssidToConnectTo The ssid to connect/reconnect to - * @param timeoutInMillis The number of milliseconds to continue waiting for the device to connect to the given SSID - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see ConnectToNetworkCallbacks - * @see WiseFyCodes - * @see WiseFyConnection#waitToConnectToSSID(String, int) - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findSavedNetworkByRegex(String) - */ - @Async - @WiseFyThread - @WaitsForTimeout - public void connectToNetwork(final String ssidToConnectTo, final int timeoutInMillis, final ConnectToNetworkCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (TextUtils.isEmpty(ssidToConnectTo)) { - if (callbacks != null) { - callbacks.connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.connectToNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Waiting %d to connect to network with ssid %s", timeoutInMillis, ssidToConnectTo)); - } - - WifiConfiguration wifiConfiguration = mWiseFySearch.findSavedNetworkByRegex(ssidToConnectTo); - if (wifiConfiguration != null) { - mWiseFyPrerequisites.getWifiManager().disconnect(); - mWiseFyPrerequisites.getWifiManager().enableNetwork(wifiConfiguration.networkId, true); - mWiseFyPrerequisites.getWifiManager().reconnect(); - boolean connected = mWiseFyConnection.waitToConnectToSSID(ssidToConnectTo, timeoutInMillis); - if (callbacks != null) { - if (connected) { - callbacks.connectedToNetwork(); - } else { - callbacks.failureConnectingToNetwork(); - } - } - return; - } - - if (callbacks != null) { - callbacks.networkNotFoundToConnectTo(); - } - } - } - }; - execute(runnable); - } - - /** - * To disable Wifi on a user's device - * - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return boolean - True if the command succeeded in disabling wifi - */ - @Sync - @CallingThread - public boolean disableWifi() { - return mWiseFyPrerequisites.hasPrerequisites() && mWiseFyPrerequisites.getWifiManager().setWifiEnabled(false); - } - - /** - * To disable Wifi on a user's device - * - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see DisableWifiCallbacks - * @see WiseFyCodes - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - */ - @Async - @WiseFyThread - public void disableWifi(final DisableWifiCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.disableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - boolean result = mWiseFyPrerequisites.getWifiManager().setWifiEnabled(false); - if (callbacks != null) { - if (result) { - callbacks.wifiDisabled(); - } else { - callbacks.failureDisablingWifi(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To disconnect the user from their current network - * - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return boolean - If the command succeeded in disconnecting the device from the current network - */ - @Sync - @CallingThread - public boolean disconnectFromCurrentNetwork() { - return mWiseFyPrerequisites.hasPrerequisites() && mWiseFyPrerequisites.getWifiManager().disconnect(); - } - - /** - * To disconnect the user from their current network - * - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see DisconnectFromCurrentNetworkCallbacks - * @see WiseFyCodes - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - */ - @Async - @WiseFyThread - public void disconnectFromCurrentNetwork(final DisconnectFromCurrentNetworkCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.disconnectFromCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - boolean result = mWiseFyPrerequisites.getWifiManager().disconnect(); - if (callbacks != null) { - if (result) { - callbacks.disconnectedFromCurrentNetwork(); - } else { - callbacks.failureDisconnectingFromCurrentNetwork(); - } - } - } - } - }; - execute(runnable); - } - - /** - * Used to cleanup the thread started by WiseFy - * - * @see WiseFyConfiguration#isLoggingEnabled() - */ - public void dump() { - if (mWiseFyHandlerThread != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - mWiseFyHandlerThread.quitSafely(); - } else { - mWiseFyHandlerThread.quit(); - } - if (mWiseFyHandlerThread.isAlive()) { - if (LogUtil.isLoggable(TAG, Log.WARN, mWiseFyConfiguration.isLoggingEnabled())) { - Log.w(TAG, String.format("WiseFy Thread is still alive. Current status: isAlive(): %b, getState(): %s", mWiseFyHandlerThread.isAlive(), mWiseFyHandlerThread.getState())); - } - mWiseFyHandlerThread.interrupt(); - } - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("WiseFy Thread isAlive(): %b, getState(): %s", mWiseFyHandlerThread.isAlive(), mWiseFyHandlerThread.getState())); - } - mWiseFyHandlerThread = null; - } - mWiseFyHandler = null; - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Cleaned up WiseFy Thread. Thread value: %s, Handler value: %s", mWiseFyHandlerThread, mWiseFyHandler)); - } - } - - /** - * To enable Wifi on a user's device - * - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return boolean - If the command succeeded in enabling wifi - */ - @Sync - @CallingThread - public boolean enableWifi() { - return mWiseFyPrerequisites.hasPrerequisites() && mWiseFyPrerequisites.getWifiManager().setWifiEnabled(true); - } - - /** - * To enable Wifi on a user's device - * - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see EnableWifiCallbacks - * @see WiseFyCodes - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - */ - @Async - @WiseFyThread - public void enableWifi(final EnableWifiCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.enableWifiWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - boolean result = mWiseFyPrerequisites.getWifiManager().setWifiEnabled(true); - if (callbacks != null) { - if (result) { - callbacks.wifiEnabled(); - } else { - callbacks.failureEnablingWifi(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To retrieve the user's current network - * - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return WifiInfo|null - The user's current network information - */ - @Sync - @CallingThread - public WifiInfo getCurrentNetwork() { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return null; - } - return mWiseFyPrerequisites.getWifiManager().getConnectionInfo(); - } - - /** - * To retrieve the user's current network - * - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see GetCurrentNetworkCallbacks - * @see WiseFyCodes - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - */ - @Async - @WiseFyThread - public void getCurrentNetwork(final GetCurrentNetworkCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.getCurrentNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - if (callbacks != null) { - callbacks.retrievedCurrentNetwork(mWiseFyPrerequisites.getWifiManager().getConnectionInfo()); - } - } - } - }; - execute(runnable); - } - - /** - * To retrieve the frequency of the device's current network - * - * @see #getCurrentNetwork() - * - * @return Integer - The frequency of the devices current network or null if no network - */ - @Sync - @CallingThread - @TargetApi(21) - public Integer getFrequency() { - WifiInfo currentNetwork = getCurrentNetwork(); - if (currentNetwork != null) { - return currentNetwork.getFrequency(); - } - return null; - } - - /** - * To retrieve the frequency of the device's current network - * - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see #getCurrentNetwork() - * @see GetFrequencyCallbacks - */ - @Async - @WiseFyThread - @TargetApi(21) - public void getFrequency(final GetFrequencyCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - WifiInfo currentNetwork = getCurrentNetwork(); - if (callbacks != null) { - if (currentNetwork != null) { - callbacks.retrievedFrequency(currentNetwork.getFrequency()); - } else { - callbacks.failureGettingFrequency(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To retrieve the frequency of a network - * - * @param network The network to return the frequency of - * - * @return Integer - The frequency of the devices current network or null if no network - */ - @Sync - @CallingThread - @TargetApi(21) - public Integer getFrequency(WifiInfo network) { - if (network != null) { - return network.getFrequency(); - } - return null; - } - - /** - * To retrieve the frequency of a network - * - * @param network The network to return the frequency of - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see GetFrequencyCallbacks - * @see WiseFyCodes - */ - @Async - @WiseFyThread - @TargetApi(21) - public void getFrequency(final WifiInfo network, final GetFrequencyCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (network != null) { - if (callbacks != null) { - callbacks.retrievedFrequency(network.getFrequency()); - } - } - if (callbacks != null) { - callbacks.getFrequencyWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - } - } - }; - execute(runnable); - } - - /** - * To retrieve a list of nearby access points - * - * *NOTE* Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI (will always take the highest signal strength) - * - * @param filterDuplicates If you want to exclude SSIDs with that same name that have a weaker signal strength - * - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#removeEntriesWithLowerSignalStrength(List) - * - * @return List of ScanResults|null - List of nearby access points - */ - @Sync - @CallingThread - public List getNearbyAccessPoints(boolean filterDuplicates) { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return null; - } - - mWiseFyPrerequisites.getWifiManager().startScan(); - if (filterDuplicates) { - return mWiseFySearch.removeEntriesWithLowerSignalStrength(mWiseFyPrerequisites.getWifiManager().getScanResults()); - } else { - return mWiseFyPrerequisites.getWifiManager().getScanResults(); - } - } - - /** - * To retrieve a list of nearby access points - * - * *NOTE* Setting filterDuplicates to true will not return SSIDs with a weaker signal strength (will always take the highest) - * - * @param filterDuplicates If you want to exclude SSIDs with that same name that have a weaker signal strength - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see GetNearbyAccessPointsCallbacks - * @see WiseFyCodes - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#removeEntriesWithLowerSignalStrength(List) - */ - @Async - @WiseFyThread - public void getNearbyAccessPoints(final boolean filterDuplicates, final GetNearbyAccessPointsCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.getNearbyAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - mWiseFyPrerequisites.getWifiManager().startScan(); - if (callbacks != null) { - if (filterDuplicates) { - callbacks.retrievedNearbyAccessPoints(mWiseFySearch.removeEntriesWithLowerSignalStrength(mWiseFyPrerequisites.getWifiManager().getScanResults())); - } else { - callbacks.retrievedNearbyAccessPoints(mWiseFyPrerequisites.getWifiManager().getScanResults()); - } - } - } - } - }; - execute(runnable); - } - - /** - * To retrieve the RSSI of the first network matching a given regex - * - * *NOTE* Setting takeHighest to true will return the access point with the highest RSSI for the given SSID - * - * @param regexForSSID The regex to be used to search for the ssid - * @param takeHighest Whether to return the access point with the highest RSSI for the given SSID - * @param timeoutInMillis The amount of time to search for a matching SSID - * - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findAccessPointByRegex(String, Integer, boolean) - * - * @return Integer - The RSSI value for the found SSID or null if no matching network found - */ - @Sync - @CallingThread - @WaitsForTimeout - public Integer getRSSI(String regexForSSID, boolean takeHighest, int timeoutInMillis) { - if (TextUtils.isEmpty(regexForSSID) || !mWiseFyPrerequisites.hasPrerequisites()) { - return null; - } - - ScanResult accessPoint = mWiseFySearch.findAccessPointByRegex(regexForSSID, timeoutInMillis, takeHighest); - if (accessPoint != null) { - return accessPoint.level; - } - return null; - } - - /** - * To retrieve the RSSI of the first network matching a given regex - * - * *NOTE* Setting takeHighest to true will return the access point with the highest RSSI for the given SSID - * - * @param regexForSSID The regex to be used to search for the ssid - * @param takeHighest Whether to return the access point with the highest RSSI for the given SSID - * @param timeoutInMillis The amount of time to search for a matching SSID - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see GetRSSICallbacks - * @see WiseFyCodes - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findAccessPointByRegex(String, Integer, boolean) - */ - @Async - @WiseFyThread - @WaitsForTimeout - public void getRSSI(final String regexForSSID, final boolean takeHighest, final int timeoutInMillis, final GetRSSICallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (TextUtils.isEmpty(regexForSSID)) { - if (callbacks != null) { - callbacks.getRSSIWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.getRSSIWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - ScanResult accessPoint = mWiseFySearch.findAccessPointByRegex(regexForSSID, timeoutInMillis, takeHighest); - if (callbacks != null) { - if (accessPoint != null) { - callbacks.retrievedRSSI(accessPoint.level); - } else { - callbacks.networkNotFoundToRetrieveRSSI(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To search for and return a saved WiFiConfiguration given an SSID - * - * @param regexForSSID The ssid to use while searching for saved configuration - * - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findSavedNetworkByRegex(String) - * - * @return WifiConfiguration|null - Saved network that matches the ssid - */ - @Sync - @CallingThread - public WifiConfiguration getSavedNetwork(String regexForSSID) { - if (!mWiseFyPrerequisites.hasPrerequisites() || TextUtils.isEmpty(regexForSSID)) { - return null; - } - return mWiseFySearch.findSavedNetworkByRegex(regexForSSID); - } - - /** - * To search for and return a saved WiFiConfiguration given an SSID - * - * @param regexForSSID The ssid to use while searching for saved configuration - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see GetSavedNetworkCallbacks - * @see WiseFyCodes - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findSavedNetworkByRegex(String) - */ - @Async - @WiseFyThread - public void getSavedNetwork(final String regexForSSID, final GetSavedNetworkCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (TextUtils.isEmpty(regexForSSID)) { - if (callbacks != null) { - callbacks.getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.getSavedNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - WifiConfiguration savedNetwork = mWiseFySearch.findSavedNetworkByRegex(regexForSSID); - if (callbacks != null) { - if (savedNetwork != null) { - callbacks.retrievedSavedNetwork(savedNetwork); - } else { - callbacks.savedNetworkNotFound(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To retrieve a list of saved networks on a user's device - * - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return List of WifiConfiguration|null - List of saved networks on a users device - */ - @Sync - @CallingThread - public List getSavedNetworks() { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return null; - } - return mWiseFyPrerequisites.getWifiManager().getConfiguredNetworks(); - } - - /** - * To retrieve a list of saved networks on a user's device - * - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see GetSavedNetworksCallbacks - * @see WiseFyCodes - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - */ - @Async - @WiseFyThread - public void getSavedNetworks(final GetSavedNetworksCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - List savedNetworks = mWiseFyPrerequisites.getWifiManager().getConfiguredNetworks(); - if (callbacks != null) { - if (savedNetworks != null && savedNetworks.size() > 0) { - callbacks.retrievedSavedNetworks(savedNetworks); - } else { - callbacks.noSavedNetworksFound(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To retrieve a list of saved networks on a user's device that match a given regex - * - * @param regexForSSID The ssid to use while searching for saved configurations - * - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findSavedNetworkByRegex(String) - * - * @return List of WifiConfigurations|null - The list of saved network configurations that match the given regex - */ - @Sync - @CallingThread - public List getSavedNetworks(String regexForSSID) { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return null; - } - return mWiseFySearch.findSavedNetworksMatchingRegex(regexForSSID); - } - - /** - * To retrieve a list of saved networks on a user's device that match a given regex - * - * @param regexForSSID The ssid to use while searching for saved configurations - * @param callbacks The listener to return results to - * - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findSavedNetworkByRegex(String) - */ - @Async - @WiseFyThread - public void getSavedNetworks(final String regexForSSID, final GetSavedNetworksCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.getSavedNetworksWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - if (callbacks != null) { - List savedNetworks = mWiseFySearch.findSavedNetworksMatchingRegex(regexForSSID); - if (savedNetworks != null && savedNetworks.size() > 0) { - callbacks.retrievedSavedNetworks(savedNetworks); - } else { - callbacks.noSavedNetworksFound(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To retrieve the lock in use by WiseFy for synchronization - * - * @see WiseFyLock - * - * @return WiseFyLock - The instance of the lock in use by WiseFy - */ - public WiseFyLock getWiseFyLock() { - return mWiseFyLock; - } - - /** - * To check if the device is connected to a mobile network - * - * @see NetworkTypes - * @see WiseFyConnection#isNetworkConnectedAndMatchesType(NetworkInfo, String) - * @see WiseFyPrerequisites#getConnectivityManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return bool - If the device is currently connected to a mobile network - */ - @Sync - @CallingThread - public boolean isDeviceConnectedToMobileNetwork() { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return false; - } - - NetworkInfo networkInfo = mWiseFyPrerequisites.getConnectivityManager().getActiveNetworkInfo(); - return mWiseFyConnection.isNetworkConnectedAndMatchesType(networkInfo, NetworkTypes.MOBILE); - } - - /** - * To check if the device is connected to a mobile or wifi network - * - * @see WiseFyConnection#isNetworkConnected(NetworkInfo) - * @see WiseFyPrerequisites#getConnectivityManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return bool - If the device is currently connected to a mobile or wifi network - */ - @Sync - @CallingThread - public boolean isDeviceConnectedToMobileOrWifiNetwork() { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return false; - } - - NetworkInfo networkInfo = mWiseFyPrerequisites.getConnectivityManager().getActiveNetworkInfo(); - return mWiseFyConnection.isNetworkConnected(networkInfo); - } - - /** - * To check if the device is connected to a given SSID - * - * @param ssid The SSID to check if the device is attached to - * - * @see WiseFyConnection#isCurrentNetworkConnectedToSSID(String) - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return bool - If the device is currently attached to the given SSID - */ - @Sync - @CallingThread - public boolean isDeviceConnectedToSSID(String ssid) { - return !(TextUtils.isEmpty(ssid) || !mWiseFyPrerequisites.hasPrerequisites()) && mWiseFyConnection.isCurrentNetworkConnectedToSSID(ssid); - } - - /** - * To check if the device is connected to a wifi network - * - * @see NetworkTypes - * @see WiseFyConnection#isNetworkConnectedAndMatchesType(NetworkInfo, String) - * @see WiseFyPrerequisites#getConnectivityManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return bool - If the device is currently connected to a wifi network - */ - @Sync - @CallingThread - public boolean isDeviceConnectedToWifiNetwork() { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return false; - } - - NetworkInfo networkInfo = mWiseFyPrerequisites.getConnectivityManager().getActiveNetworkInfo(); - return mWiseFyConnection.isNetworkConnectedAndMatchesType(networkInfo, NetworkTypes.WIFI); - } - - /** - * To query if the device is roaming - * - * @see WiseFyPrerequisites#getConnectivityManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return boolean - If the current network is roaming - */ - @Sync - @CallingThread - public boolean isDeviceRoaming() { - if (!mWiseFyPrerequisites.hasPrerequisites()) { - return false; - } - - NetworkInfo networkInfo = mWiseFyPrerequisites.getConnectivityManager().getActiveNetworkInfo(); - return networkInfo != null && networkInfo.isRoaming(); - } - - /** - * To query if logging is enabled or disabled for a WiseFy instance - * - * @see WiseFyConfiguration#isLoggingEnabled() - * - * @return boolean - If logging is enabled for the WiseFy instance - */ - @Sync - @CallingThread - public boolean isLoggingEnabled() { - return mWiseFyConfiguration.isLoggingEnabled(); - } - - /** - * To check if the device's current network is 5gHz - * - * @see #getFrequency() - * @see #MIN_FREQUENCY_5GHZ - * @see #MAX_FREQUENCY_5GHZ - * - * @return boolean - If the network is 5gHz - */ - @Sync - @CallingThread - public boolean isNetwork5gHz() { - Integer frequency = getFrequency(); - return frequency != null && frequency > MIN_FREQUENCY_5GHZ && frequency < MAX_FREQUENCY_5GHZ; - } - - /** - * To check if a given network is 5gHz - * - * @param network The network to check if it's 5gHz - * - * @see #getFrequency(WifiInfo) - * @see #MIN_FREQUENCY_5GHZ - * @see #MAX_FREQUENCY_5GHZ - * - * @return boolean - If the network is 5gHz - */ - @Sync - @CallingThread - public boolean isNetwork5gHz(WifiInfo network) { - Integer frequency = getFrequency(network); - return frequency != null && frequency > MIN_FREQUENCY_5GHZ && frequency < MAX_FREQUENCY_5GHZ; - } - - /** - * To check if an SSID is in the list of configured networks - * - * @param ssid The SSID to check and see if it's in the list of configured networks - * - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#isNetworkASavedConfiguration(String) - * - * @return boolean - If the SSID is in the list of configured networks - */ - @Sync - @CallingThread - public boolean isNetworkInConfigurationList(String ssid) { - return mWiseFyPrerequisites.hasPrerequisites() && mWiseFySearch.isNetworkASavedConfiguration(ssid); - } - - /** - * To check and return if a network is a EAP network - * - * @param scanResult The network to check - * - * @see Capabilities - * @see #containsCapability(ScanResult, String) - * - * @return boolean - Whether the network has EAP capabilities listed - */ - @Sync - @CallingThread - public boolean isNetworkEAP(ScanResult scanResult) { - return containsCapability(scanResult, Capabilities.EAP); - } - - /** - * To check and return if a network is a PSK network - * - * @param scanResult The network to check - * - * @see Capabilities - * @see #containsCapability(ScanResult, String) - * - * @return boolean - Whether the network has PSK capabilities listed - */ - @Sync - @CallingThread - public boolean isNetworkPSK(ScanResult scanResult) { - return containsCapability(scanResult, Capabilities.PSK); - } - - /** - * To check and return if a network is secure (WEP/WPA/WPA2 capabilities) - * - * @param scanResult The network to see if it is secure - * - * @see Capabilities - * - * @return boolean - Whether the network is secure - */ - @Sync - @CallingThread - public boolean isNetworkSecure(ScanResult scanResult) { - if (scanResult != null && scanResult.capabilities != null) { - String networkCapabilities = scanResult.capabilities; - String[] securityModes = { Capabilities.EAP, Capabilities.PSK, Capabilities.WEP, Capabilities.WPA, Capabilities.WPA2 }; - for (int i = securityModes.length - 1; i >= 0; i--) { - if (networkCapabilities.contains(securityModes[i])) { - return true; - } - } - } - return false; - } - - /** - * To check and return if a network is a WEP network - * - * @param scanResult The network to check - * - * @see Capabilities - * @see #containsCapability(ScanResult, String) - * - * @return boolean - Whether the network has WEP capabilities listed - */ - @Sync - @CallingThread - public boolean isNetworkWEP(ScanResult scanResult) { - return containsCapability(scanResult, Capabilities.WEP); - } - - /** - * To check and return if a network is a WPA network - * - * @param scanResult The network to check - * - * @see Capabilities - * @see #containsCapability(ScanResult, String) - * - * @return boolean - Whether the network has WPA capabilities listed - */ - @Sync - @CallingThread - public boolean isNetworkWPA(ScanResult scanResult) { - return containsCapability(scanResult, Capabilities.WPA); - } - - /** - * To check and return if a network is a WPA2 network - * - * @param scanResult The network to check - * - * @see Capabilities - * @see #containsCapability(ScanResult, String) - * - * @return boolean - Whether the network has WPA2 capabilities listed - */ - @Sync - @CallingThread - public boolean isNetworkWPA2(ScanResult scanResult) { - return containsCapability(scanResult, Capabilities.WPA2); - } - - /** - * To check if Wifi is enabled on the device or not - * - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFyPrerequisites#hasPrerequisites() - * - * @return boolean - if Wifi is enabled on device - */ - @Sync - @CallingThread - public boolean isWifiEnabled() { - return mWiseFyPrerequisites.hasPrerequisites() && mWiseFyPrerequisites.getWifiManager().isWifiEnabled(); - } - - /** - * To remove a configured network - * - * @param ssidToRemove The ssid of the network you want to remove from the configured network list - * - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findSavedNetworkByRegex(String) - * - * @return boolean - If the command succeeded in removing the network - */ - @Sync - @CallingThread - public boolean removeNetwork(String ssidToRemove) { - if (TextUtils.isEmpty(ssidToRemove) || !mWiseFyPrerequisites.hasPrerequisites()) { - return false; - } - - WifiConfiguration wifiConfiguration = mWiseFySearch.findSavedNetworkByRegex(ssidToRemove); - if (wifiConfiguration != null) { - mWiseFyPrerequisites.getWifiManager().disconnect(); - boolean result = mWiseFyPrerequisites.getWifiManager().removeNetwork(wifiConfiguration.networkId); - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Removing network: %s had result: %b", ssidToRemove, result)); - } - mWiseFyPrerequisites.getWifiManager().reconnect(); - return result; - } else { - if (LogUtil.isLoggable(TAG, Log.WARN, mWiseFyConfiguration.isLoggingEnabled())) { - Log.w(TAG, String.format("SSID to remove: %s was not found in list to remove network", ssidToRemove)); - } - } - return false; - } - - /** - * To remove a configured network - * - * @param ssidToRemove The ssid of the network you want to remove from the configured network list - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see RemoveNetworkCallbacks - * @see WiseFyCodes - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFyPrerequisites#getWifiManager() - * @see WiseFySearch#findSavedNetworkByRegex(String) - */ - @Async - @WiseFyThread - public void removeNetwork(final String ssidToRemove, final RemoveNetworkCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (TextUtils.isEmpty(ssidToRemove)) { - if (callbacks != null) { - callbacks.removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.removeNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - WifiConfiguration wifiConfiguration = mWiseFySearch.findSavedNetworkByRegex(ssidToRemove); - if (wifiConfiguration != null) { - mWiseFyPrerequisites.getWifiManager().disconnect(); - boolean result = mWiseFyPrerequisites.getWifiManager().removeNetwork(wifiConfiguration.networkId); - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Removing network: %s had result: %b", ssidToRemove, result)); - } - mWiseFyPrerequisites.getWifiManager().reconnect(); - if (callbacks != null) { - if (result) { - callbacks.networkRemoved(); - } else { - callbacks.failureRemovingNetwork(); - } - } - } else { - if (LogUtil.isLoggable(TAG, Log.WARN, mWiseFyConfiguration.isLoggingEnabled())) { - Log.w(TAG, String.format("SSID to remove: %s was not found in list to remove network", ssidToRemove)); - } - if (callbacks != null) { - callbacks.networkNotFoundToRemove(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To return the first access point that matches a given regex - * - * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest) - * - * @param regexForSSID The regex to use when iterating through nearby access points - * @param timeoutInMillis The amount of time (in milliseconds) to wait for a matching access point - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength - * - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findAccessPointByRegex(String, Integer, boolean) - * - * @return ScanResult|null - The first access point or access point with the highest signal strength matching the regex - */ - @Sync - @CallingThread - public ScanResult searchForAccessPoint(String regexForSSID, int timeoutInMillis, boolean filterDuplicates) { - if (TextUtils.isEmpty(regexForSSID) || !mWiseFyPrerequisites.hasPrerequisites()) { - return null; - } - - ScanResult scanResult = mWiseFySearch.findAccessPointByRegex(regexForSSID, timeoutInMillis, filterDuplicates); - if (scanResult != null) { - return scanResult; - } - return null; - } - - /** - * To return the first access point that matches a given regex - * - * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest) - * - * @param regexForSSID The regex to use when iterating through nearby access points - * @param timeoutInMillis The amount of time (in milliseconds) to wait for a matching access point - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see SearchForAccessPointCallbacks - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findAccessPointByRegex(String, Integer, boolean) - */ - @Async - @WiseFyThread - public void searchForAccessPoint(final String regexForSSID, final int timeoutInMillis, final boolean filterDuplicates, final SearchForAccessPointCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (TextUtils.isEmpty(regexForSSID)) { - if (callbacks != null) { - callbacks.searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.searchForAccessPointWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - ScanResult scanResult = mWiseFySearch.findAccessPointByRegex(regexForSSID, timeoutInMillis, filterDuplicates); - if (callbacks != null) { - if (scanResult != null) { - callbacks.accessPointFound(scanResult); - } else { - callbacks.accessPointNotFound(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To return nearby access points that match a given regex - * - * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest) - * - * @param regexForSSID The regex to use when iterating through nearby access points - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength - * - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findAccessPointsMatchingRegex(String, boolean) - * - * @return List of ScanResult|null - The list of matching access points or null if none match the given regex - */ - @Sync - @CallingThread - public List searchForAccessPoints(String regexForSSID, boolean filterDuplicates) { - if (TextUtils.isEmpty(regexForSSID) || !mWiseFyPrerequisites.hasPrerequisites()) { - return null; - } - - return mWiseFySearch.findAccessPointsMatchingRegex(regexForSSID, filterDuplicates); - } - - /** - * To return nearby access points that match a given regex - * - * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest) - * - * @param regexForSSID The regex to use when iterating through nearby access points - * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see SearchForAccessPointsCallbacks - * @see WiseFyCodes - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findAccessPointsMatchingRegex(String, boolean) - */ - @Async - @WiseFyThread - public void searchForAccessPoints(final String regexForSSID, final boolean filterDuplicates, final SearchForAccessPointsCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (TextUtils.isEmpty(regexForSSID)) { - if (callbacks != null) { - callbacks.searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.searchForAccessPointsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - List networks = mWiseFySearch.findAccessPointsMatchingRegex(regexForSSID, filterDuplicates); - if (callbacks != null) { - if (networks != null) { - callbacks.foundAccessPoints(networks); - } else { - callbacks.noAccessPointsFound(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To search local networks and return the first one that contains a given ssid - * - * @param regexForSSID The regex to be used to search for the ssid - * @param timeoutInMillis The number of milliseconds to keep searching for the SSID - * - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findAccessPointByRegex(String, Integer, boolean) - * - * @return String|null - The first SSID that contains the search ssid (if any, else null) - */ - @Sync - @CallingThread - @WaitsForTimeout - public String searchForSSID(String regexForSSID, int timeoutInMillis) { - if (TextUtils.isEmpty(regexForSSID) || !mWiseFyPrerequisites.hasPrerequisites()) { - return null; - } - - ScanResult scanResult = mWiseFySearch.findAccessPointByRegex(regexForSSID, timeoutInMillis, false); - if (scanResult != null) { - return scanResult.SSID; - } - return null; - } - - /** - * To search local networks and return the first one that contains a given ssid - * - * @param regexForSSID The regex to be used to search for the ssid - * @param timeoutInMillis The number of milliseconds to keep searching for the SSID - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see SearchForSSIDCallbacks - * @see WiseFyCodes - * @see WiseFySearch#findAccessPointByRegex(String, Integer, boolean) - */ - @Async - @WiseFyThread - @WaitsForTimeout - public void searchForSSID(final String regexForSSID, final int timeoutInMillis, final SearchForSSIDCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (TextUtils.isEmpty(regexForSSID)) { - if (callbacks != null) { - callbacks.searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.searchForSSIDWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - ScanResult scanResult = mWiseFySearch.findAccessPointByRegex(regexForSSID, timeoutInMillis, false); - if (callbacks != null) { - if (scanResult != null) { - callbacks.ssidFound(scanResult.SSID); - } else { - callbacks.ssidNotFound(); - } - } - } - } - }; - execute(runnable); - } - - /** - * To search local networks and return the first one that contains a given ssid - * - * @param regexForSSID The regex to be used to search for the ssid - * - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findSSIDsMatchingRegex(String) - * - * @return String|null - The first SSID that contains the search ssid (if any, else null) - */ - @Sync - @CallingThread - public List searchForSSIDs(String regexForSSID) { - if (TextUtils.isEmpty(regexForSSID) || !mWiseFyPrerequisites.hasPrerequisites()) { - return null; - } - - return mWiseFySearch.findSSIDsMatchingRegex(regexForSSID); - } - - /** - * To search local networks and return the first one that contains a given ssid - * - * @param regexForSSID The regex to be used to search for the ssid - * @param callbacks The listener to return results to - * - * @see #execute(Runnable) - * @see SearchForSSIDCallbacks - * @see WiseFyCodes - * @see WiseFyPrerequisites#hasPrerequisites() - * @see WiseFySearch#findSSIDsMatchingRegex(String) - */ - @Async - @WiseFyThread - public void searchForSSIDs(final String regexForSSID, final SearchForSSIDsCallbacks callbacks) { - Runnable runnable = new Runnable() { - @Override - public void run() { - synchronized (mWiseFyLock) { - if (TextUtils.isEmpty(regexForSSID)) { - if (callbacks != null) { - callbacks.searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PARAMETER); - } - return; - } - - if (!mWiseFyPrerequisites.hasPrerequisites()) { - if (callbacks != null) { - callbacks.searchForSSIDsWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE); - } - return; - } - - List ssids = mWiseFySearch.findSSIDsMatchingRegex(regexForSSID); - if (callbacks != null) { - if (ssids != null) { - callbacks.retrievedSSIDs(ssids); - } else { - callbacks.noSSIDsFound(); - } - } - } - } - }; - execute(runnable); - } - - /* - * HELPERS - */ - - /** - * Used internally to add and save a new wifi configuration - * - * @param wifiConfiguration The network configuration to add - * - * @see WiseFyConfiguration#isLoggingEnabled() - * - * @return int - The return code from WifiManager for network creation (-1 for failure) - */ - private int addNetworkConfiguration(WifiConfiguration wifiConfiguration) { - int result = mWiseFyPrerequisites.getWifiManager().addNetwork(wifiConfiguration); - if (result == WIFI_MANAGER_FAILURE) { - if (LogUtil.isLoggable(TAG, Log.ERROR, mWiseFyConfiguration.isLoggingEnabled())) { - Log.e(TAG, "Failed to add network"); - } - } - return result; - } - - /** - * Used internally to check if a network has a given capability - * - * @param scanResult The network to check - * @param capability The capability to check for - * - * @return boolean - True if the network contains the capability - */ - private boolean containsCapability(ScanResult scanResult, String capability) { - return scanResult != null && scanResult.capabilities != null && scanResult.capabilities.contains(capability); - } - - /** - * A method to execute logic on a background thread - * - * @param runnable The block of code to execute in the background - * - * @see #setupWiseFyThread() - */ - private void execute(Runnable runnable) { - if (mWiseFyHandler == null) { - setupWiseFyThread(); - } - mWiseFyHandler.post(runnable); - } - - /** - * Used internally to setup a WiseFyThread to run background operations - * - * @see #execute(Runnable) - * @see WiseFyHandlerThread - */ - private void setupWiseFyThread() { - mWiseFyHandlerThread = new WiseFyHandlerThread(WiseFyHandlerThread.TAG, mWiseFyConfiguration.isLoggingEnabled()); - mWiseFyHandlerThread.start(); - Looper looper = mWiseFyHandlerThread.getLooper(); - mWiseFyHandler = new Handler(looper); - } -} \ No newline at end of file diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFy.kt b/wisefy/src/main/java/com/isupatches/wisefy/WiseFy.kt new file mode 100644 index 00000000..3e49b7e6 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/WiseFy.kt @@ -0,0 +1,2199 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("WiseFy") +package com.isupatches.wisefy + +import android.Manifest.permission.ACCESS_COARSE_LOCATION +import android.Manifest.permission.ACCESS_NETWORK_STATE +import android.Manifest.permission.ACCESS_WIFI_STATE +import android.Manifest.permission.CHANGE_WIFI_STATE +import android.content.Context +import android.net.ConnectivityManager +import android.net.NetworkInfo +import android.net.wifi.ScanResult +import android.net.wifi.WifiConfiguration +import android.net.wifi.WifiInfo +import android.net.wifi.WifiManager +import android.os.Build +import android.os.Handler +import android.support.annotation.RequiresApi +import android.support.annotation.RequiresPermission + +import com.isupatches.wisefy.annotations.Async +import com.isupatches.wisefy.annotations.CallingThread +import com.isupatches.wisefy.annotations.PublicAPI +import com.isupatches.wisefy.annotations.Sync +import com.isupatches.wisefy.annotations.WaitsForTimeout +import com.isupatches.wisefy.annotations.WiseFyThread +import com.isupatches.wisefy.callbacks.AddNetworkCallbacks +import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks +import com.isupatches.wisefy.callbacks.DisableWifiCallbacks +import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks +import com.isupatches.wisefy.callbacks.EnableWifiCallbacks +import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks +import com.isupatches.wisefy.callbacks.GetCurrentNetworkInfoCallbacks +import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks +import com.isupatches.wisefy.callbacks.GetIPCallbacks +import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks +import com.isupatches.wisefy.callbacks.GetRSSICallbacks +import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks +import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks +import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks +import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks +import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks +import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks +import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks +import com.isupatches.wisefy.constants.Capability +import com.isupatches.wisefy.constants.EAP +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import com.isupatches.wisefy.constants.MOBILE +import com.isupatches.wisefy.constants.PSK +import com.isupatches.wisefy.constants.WEP +import com.isupatches.wisefy.constants.WIFI +import com.isupatches.wisefy.constants.WPA +import com.isupatches.wisefy.constants.WPA2 +import com.isupatches.wisefy.logging.WiseFyLogger +import com.isupatches.wisefy.threads.WiseFyHandlerThread +import com.isupatches.wisefy.utils.generateOpenNetworkConfiguration +import com.isupatches.wisefy.utils.generateWEPNetworkConfiguration +import com.isupatches.wisefy.utils.generateWPA2NetworkConfiguration + +import java.math.BigInteger +import java.net.InetAddress +import java.net.UnknownHostException + +/** + * Main class for WiseFy that provides a synchronous and asynchronous API to manipulate and query + * for different parts of a device's wifi configuration and status. + * + *

Uses the builder pattern for creation - {@link [Brains]}

+ * + * @author Patches + * @since 3.0 + */ +@PublicAPI +@Suppress("LargeClass") +class WiseFy private constructor( + private val connectivityManager: ConnectivityManager, + private val wifiManager: WifiManager, + private val wisefyConnection: WiseFyConnection, + private val wisefyPrechecks: WiseFyPrechecks, + private val wisefySearch: WiseFySearch +) : WiseFyPublicApi { + + companion object { + private val TAG = WiseFy::class.java.simpleName + + /** + * The default error return from [WifiManager] + * + * @see [WifiManager] + * + * @author Patches + * @since 3.0 + */ + const val WIFI_MANAGER_FAILURE: Int = -1 + + /** + * The minimum value possible for a 5gHz network. + * + * @author Patches + * @since 3.0 + */ + const val MIN_FREQUENCY_5GHZ: Int = 4900 + + /** + * The max value possible for a 5gHz network. + * + * @author Patches + * @since 3.0 + */ + const val MAX_FREQUENCY_5GHZ: Int = 5900 + } + + private val wisefyLock = WiseFyLock() + + private var wisefyHandlerThread: WiseFyHandlerThread? = null + private var wisefyHandler: Handler? = null + + /** + * The Builder class for WiseFy. + * + * @author Patches + * @since 3.0 + */ + class Brains(context: Context) { + + private var loggingEnabled: Boolean = false + private var connectivityManager: ConnectivityManager + private var wifiManager: WifiManager + private var wisefyConnection: WiseFyConnection + private var wisefyPrechecks: WiseFyPrechecks + private var wisefySearch: WiseFySearch + + init { + connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager + wisefyConnection = WiseFyConnectionImpl.create(connectivityManager, wifiManager) + wisefySearch = WiseFySearchImpl.create(wifiManager) + wisefyPrechecks = WiseFyPrechecksImpl.create(wisefySearch) + } + + /** + * Used to enable/or disable logging for a WiseFy instance. + * + * @param loggingEnabled If logging should be enabled for the WiseFy instance. + * + * @author Patches + * @since 3.0 + */ + fun logging(loggingEnabled: Boolean): Brains = apply { this.loggingEnabled = loggingEnabled } + + /** + * Used internally to set ConnectivityManager in tests. + * + * @param connectivityManager The custom ConnectivityManager to use (can be a mock) + * + * @see [ConnectivityManager] + * + * @author Patches + * @since 3.0 + */ + internal fun customConnectivityManager(connectivityManager: ConnectivityManager): Brains = apply { + this.connectivityManager = connectivityManager + } + + /** + * Used internally to set WifiManager in tests. + * + * @param wifiManager The custom WifiManager to use (can be a mock) + * + * @see [WifiManager] + * + * @author Patches + * @since 3.0 + */ + internal fun customWifiManager(wifiManager: WifiManager): Brains = apply { + this.wifiManager = wifiManager + } + + /** + * Used internally to set WiseFyConnection in tests. + * + * @param wisefyConnection The custom WiseFyConnection to use (can be a mock or custom interface implementation) + * + * @see [WiseFyConnection] + * + * @author Patches + * @since 3.0 + */ + internal fun customWiseFyConnection(wisefyConnection: WiseFyConnection): Brains = apply { + this.wisefyConnection = wisefyConnection + } + + /** + * Used internally to set WiseFyPrechecks in tests. + * + * @param wisefyPrechecks The custom WiseFyPrechecks to use (can be a mock or custom interface implementation) + * + * @see [WiseFyPrechecks] + * + * @author Patches + * @since 3.0 + */ + internal fun customWiseFyPrechecks(wisefyPrechecks: WiseFyPrechecks): Brains = apply { + this.wisefyPrechecks = wisefyPrechecks + } + + /** + * Used internally to set WiseFySearch in tests. + * + * @param wisefySearch The custom WisefySearch to use (can be a mock or custom interface implementation) + * + * @see [WiseFySearch] + * + * @author Patches + * @since 3.0 + */ + internal fun customWiseFySearch(wisefySearch: WiseFySearch): Brains = apply { + this.wisefySearch = wisefySearch + } + + /** + * Uses a private constructor and returns a WiseFy instance. + * + * @see [WiseFyLogger.configureWiseFyLoggerImplementation] + * + * @author Patches + * @since 3.0 + */ + fun getSmarts(): WiseFy { + WiseFyLogger.configureWiseFyLoggerImplementation(loggingEnabled) + return WiseFy( + connectivityManager = connectivityManager, + wifiManager = wifiManager, + wisefyConnection = wisefyConnection, + wisefyPrechecks = wisefyPrechecks, + wisefySearch = wisefySearch + ) + } + } + + /** + * To add an open network to the user's configured network list. + * + * @param ssid The ssid of the open network you want to add + * + * @return int - The return code from WifiManager for network creation (-1 for failure) + * + * @see [addNetworkConfiguration] + * @see [generateOpenNetworkConfiguration] + * @see [WiseFyPrechecks.addNetworkPrechecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun addOpenNetwork(ssid: String?): Int { + val precheck = wisefyPrechecks.addNetworkPrechecks(ssid) + return if (precheck.failed()) { + precheck.code + } else addNetworkConfiguration(generateOpenNetworkConfiguration(ssid!!)) + } + + /** + * To add an open network to the user's configured network list. + * + * @param ssid The ssid of the open network you want to add + * @param callbacks The listener to return results to + * + * @see [addNetworkConfiguration] + * @see [AddNetworkCallbacks] + * @see [generateOpenNetworkConfiguration] + * @see [runOnWiseFyThread] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.addNetworkPrechecks] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun addOpenNetwork(ssid: String?, callbacks: AddNetworkCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.addNetworkPrechecks(ssid) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val openNetworkConfiguration = generateOpenNetworkConfiguration(ssid!!) + val result = addNetworkConfiguration(openNetworkConfiguration) + if (result != WIFI_MANAGER_FAILURE) { + callbacks?.networkAdded(result, openNetworkConfiguration) + } else { + callbacks?.failureAddingNetwork(result) + } + } + }) + } + + /** + * To add a WEP network to the user's configured network list. + * + * @param ssid The ssid of the WEP network you want to add + * @param password The password for the WEP network being added + * + * @return int - The return code from WifiManager for network creation (-1 for failure) + * + * @see [addNetworkConfiguration] + * @see [generateWEPNetworkConfiguration] + * @see [WiseFyPrechecks.addNetworkPrechecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun addWEPNetwork(ssid: String?, password: String?): Int { + val precheck = wisefyPrechecks.addNetworkPrechecks(ssid, password) + return if (precheck.failed()) { + precheck.code + } else addNetworkConfiguration(generateWEPNetworkConfiguration(ssid!!, password!!)) + } + + /** + * To add a WEP network to the user's configured network list. + * + * @param ssid The ssid of the WEP network you want to add + * @param password The password for the WEP network being added + * @param callbacks The listener to return results to + * + * @see [addNetworkConfiguration] + * @see [AddNetworkCallbacks] + * @see [generateWEPNetworkConfiguration] + * @see [runOnWiseFyThread] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.addNetworkPrechecks] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun addWEPNetwork(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.addNetworkPrechecks(ssid, password) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val wepNetworkConfiguration = generateWEPNetworkConfiguration(ssid!!, password!!) + val result = addNetworkConfiguration(wepNetworkConfiguration) + if (result != WIFI_MANAGER_FAILURE) { + callbacks?.networkAdded(result, wepNetworkConfiguration) + } else { + callbacks?.failureAddingNetwork(result) + } + } + }) + } + + /** + * To add a WPA2 network to the user's configured network list. + * + * @param ssid The ssid of the WPA2 network you want to add + * @param password The password for the WPA2 network being added + * + * @return int - The return code from WifiManager for network creation (-1 for failure) + * + * @see [addNetworkConfiguration] + * @see [generateWPA2NetworkConfiguration] + * @see [WiseFyPrechecks.addNetworkPrechecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun addWPA2Network(ssid: String?, password: String?): Int { + val precheck = wisefyPrechecks.addNetworkPrechecks(ssid, password) + return if (precheck.failed()) { + precheck.code + } else addNetworkConfiguration(generateWPA2NetworkConfiguration(ssid!!, password!!)) + } + + /** + * To add a WPA2 network to the user's configured network list. + * + * @param ssid The ssid of the WPA2 network you want to add + * @param password The password for the WPA2 network being added + * @param callbacks The listener to return results to + * + * @see [addNetworkConfiguration] + * @see [AddNetworkCallbacks] + * @see [generateWPA2NetworkConfiguration] + * @see [runOnWiseFyThread] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.addNetworkPrechecks] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun addWPA2Network(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.addNetworkPrechecks(ssid, password) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val wpa2NetworkConfiguration = generateWPA2NetworkConfiguration(ssid!!, password!!) + val result = addNetworkConfiguration(wpa2NetworkConfiguration) + if (result != WIFI_MANAGER_FAILURE) { + callbacks?.networkAdded(result, wpa2NetworkConfiguration) + } else { + callbacks?.failureAddingNetwork(result) + } + } + }) + } + + /** + * To convert an RSSI level for a network to a number of bars. + * + * @param rssiLevel The signal strength of the network + * @param targetNumberOfBars How many bars or levels there will be total + * + * @return int - The number of bars for the given RSSI value + * + * @see [WifiManager.calculateSignalLevel] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun calculateBars(rssiLevel: Int, targetNumberOfBars: Int): Int = + WifiManager.calculateSignalLevel(rssiLevel, targetNumberOfBars) + + /** + * To compare the signal strength of two networks. + * + * This method will return: + * - Negative value if the first signal is weaker than the second signal + * - 0 if the two signals have the same strength + * - Positive value if the first signal is stronger than the second signal + * + * @param rssi1 The signal strength of network 1 + * @param rssi2 The signal strength of network 2 + * + * @return int - The result of the comparison + * + * @see [WifiManager.compareSignalLevel] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun compareSignalLevel(rssi1: Int, rssi2: Int): Int = WifiManager.compareSignalLevel(rssi1, rssi2) + + /** + * Used to connect to a network. + * + * + * *NOTE* Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity. + * + * @param ssidToConnectTo The ssid to connect/reconnect to + * @param timeoutInMillis The number of milliseconds to continue waiting for the device to connect to the given SSID + * + * @return boolean - If the network was successfully reconnected + * + * @see [connectToNetworkWithId] + * @see [WiseFyConnection.waitToConnectToSSID] + * @see [WiseFyPrechecks.connectToNetworkPrechecks] + * @see [WiseFySearch.findSavedNetworkByRegex] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @WaitsForTimeout + @RequiresPermission(ACCESS_WIFI_STATE) + override fun connectToNetwork(ssidToConnectTo: String?, timeoutInMillis: Int): Boolean { + if (wisefyPrechecks.connectToNetworkPrechecks(ssidToConnectTo).failed()) { + return false + } + + val wifiConfiguration = wisefySearch.findSavedNetworkByRegex(ssidToConnectTo!!) + if (wifiConfiguration != null) { + connectToNetworkWithId(wifiConfiguration.networkId) + return wisefyConnection.waitToConnectToSSID(ssidToConnectTo, timeoutInMillis) + } + + return false + } + + /** + * Used to connect to a network. + * + * Gets a list of saved networks, connects to the given ssid if found, and verifies connectivity. + * + * @param ssidToConnectTo The ssid to connect/reconnect to + * @param timeoutInMillis The number of milliseconds to continue waiting for the device to connect to the given SSID + * @param callbacks The listener to return results to + * + * @see [connectToNetworkWithId] + * @see [ConnectToNetworkCallbacks] + * @see [runOnWiseFyThread] + * @see [WiseFyConnection.waitToConnectToSSID] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.connectToNetworkPrechecks] + * @see [WiseFySearch.findSavedNetworkByRegex] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @WaitsForTimeout + @RequiresPermission(ACCESS_WIFI_STATE) + override fun connectToNetwork( + ssidToConnectTo: String?, + timeoutInMillis: Int, + callbacks: ConnectToNetworkCallbacks? + ) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.connectToNetworkPrechecks(ssidToConnectTo) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val wifiConfiguration = wisefySearch.findSavedNetworkByRegex(ssidToConnectTo!!) + if (wifiConfiguration != null) { + connectToNetworkWithId(wifiConfiguration.networkId) + val connected = wisefyConnection.waitToConnectToSSID(ssidToConnectTo, timeoutInMillis) + if (connected) { + callbacks?.connectedToNetwork() + } else { + callbacks?.failureConnectingToNetwork() + } + } else { + callbacks?.networkNotFoundToConnectTo() + } + } + }) + } + + /** + * To disable Wifi on a user's device. + * + * @return boolean - True if the command succeeded in disabling wifi + * + * @see [WifiManager.setWifiEnabled] + * @see [WiseFyPrechecks.disableWifiChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(CHANGE_WIFI_STATE) + override fun disableWifi(): Boolean = + wisefyPrechecks.disableWifiChecks().passed() && wifiManager.setWifiEnabled(false) + + /** + * To disable Wifi on a user's device. + * + * @param callbacks The listener to return results to + * + * @see [DisableWifiCallbacks] + * @see [runOnWiseFyThread] + * @see [WifiManager.setWifiEnabled] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.disableWifiChecks] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(CHANGE_WIFI_STATE) + override fun disableWifi(callbacks: DisableWifiCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.disableWifiChecks() + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + if (wifiManager.setWifiEnabled(false)) { + callbacks?.wifiDisabled() + } else { + callbacks?.failureDisablingWifi() + } + } + }) + } + + /** + * To disconnect the user from their current network. + * + * @return boolean - If the command succeeded in disconnecting the device from the current network + * + * @see [WifiManager.disconnect] + * @see [WiseFyPrechecks.disconnectFromCurrentNetworkChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun disconnectFromCurrentNetwork(): Boolean = + wisefyPrechecks.disconnectFromCurrentNetworkChecks().passed() && wifiManager.disconnect() + + /** + * To disconnect the user from their current network. + * + * @param callbacks The listener to return results to + * + * @see [DisconnectFromCurrentNetworkCallbacks] + * @see [runOnWiseFyThread] + * @see [WifiManager.disconnect] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.disconnectFromCurrentNetworkChecks + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + override fun disconnectFromCurrentNetwork(callbacks: DisconnectFromCurrentNetworkCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.disconnectFromCurrentNetworkChecks() + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + if (wifiManager.disconnect()) { + callbacks?.disconnectedFromCurrentNetwork() + } else { + callbacks?.failureDisconnectingFromCurrentNetwork() + } + } + }) + } + + /** + * Used to cleanup the thread started by WiseFy. + * + * @see WiseFyHandlerThread + * @see WiseFyLock + * + * @author Patches + * @since 3.0 + */ + override fun dump() { + wisefyHandlerThread?.let { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { + it.quitSafely() + } else { + it.quit() + } + if (it.isAlive) { + WiseFyLogger.warn( + TAG, + "WiseFy Thread is still alive. Current status: isAlive(): %b, getState(): %s", + it.isAlive, + it.state + ) + it.interrupt() + } + WiseFyLogger.debug( + TAG, + "WiseFy Thread isAlive(): %b, getState(): %s", + it.isAlive, + it.state + ) + wisefyHandlerThread = null + } + wisefyHandler = null + WiseFyLogger.debug(TAG, "Cleaned up WiseFy Thread") + } + + /** + * To enable Wifi on a user's device. + * + * @return boolean - If the command succeeded in enabling wifi + * + * @see [WifiManager.setWifiEnabled] + * @see [WiseFyPrechecks.enableWifiChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(CHANGE_WIFI_STATE) + override fun enableWifi(): Boolean = + wisefyPrechecks.enableWifiChecks().passed() && wifiManager.setWifiEnabled(true) + + /** + * To enable Wifi on a user's device. + * + * @param callbacks The listener to return results to + * + * @see [EnableWifiCallbacks] + * @see [runOnWiseFyThread] + * @see [WifiManager.setWifiEnabled] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.enableWifiChecks] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(CHANGE_WIFI_STATE) + override fun enableWifi(callbacks: EnableWifiCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.enableWifiChecks() + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + if (wifiManager.setWifiEnabled(true)) { + callbacks?.wifiEnabled() + } else { + callbacks?.failureEnablingWifi() + } + } + }) + } + + /** + * To retrieve the user's current network. + * + * @return WifiInfo|null - The user's current network information + * + * @throws SecurityException Without necessary permissions granted + * + * @see [WifiInfo] + * @see [WifiManager.getConnectionInfo] + * @see [WiseFyPrechecks.getCurrentNetworkChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(allOf = arrayOf(ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE)) + @Throws(SecurityException::class) + override fun getCurrentNetwork(): WifiInfo? { + return if (wisefyPrechecks.getCurrentNetworkChecks().passed()) { + wifiManager.connectionInfo + } else null + } + + /** + * To retrieve the user's current network. + * + * @param callbacks The listener to return results to + * + * @throws SecurityException Without necessary permissions granted + * + * @see [GetCurrentNetworkCallbacks] + * @see [runOnWiseFyThread] + * @see [WifiInfo] + * @see [WifiManager.getConnectionInfo] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.getCurrentNetworkChecks] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(allOf = arrayOf(ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE)) + override fun getCurrentNetwork(callbacks: GetCurrentNetworkCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.getCurrentNetworkChecks() + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + callbacks?.retrievedCurrentNetwork(wifiManager.connectionInfo) + } + }) + } + + /** + * To retrieve the details of the phones active network. + * + * @return NetworkInfo + * + * @see [ConnectivityManager.getActiveNetworkInfo] + * @see [NetworkInfo] + * @see [WiseFyPrechecks.getCurrentNetworkInfoChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_NETWORK_STATE) + override fun getCurrentNetworkInfo(): NetworkInfo? { + return if (wisefyPrechecks.getCurrentNetworkInfoChecks().passed()) { + connectivityManager.activeNetworkInfo + } else null + } + + /** + * To retrieve the details of the phones active network. + * + * @param callbacks The listener to return results to + * + * @see [ConnectivityManager.getActiveNetworkInfo] + * @see [GetCurrentNetworkInfoCallbacks] + * @see [NetworkInfo] + * @see [runOnWiseFyThread] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.getCurrentNetworkInfoChecks] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_NETWORK_STATE) + override fun getCurrentNetworkInfo(callbacks: GetCurrentNetworkInfoCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.getCurrentNetworkInfoChecks() + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + callbacks?.retrievedCurrentNetworkInfo(connectivityManager.activeNetworkInfo) + } + }) + } + + /** + * To retrieve the frequency of the device's current network. + * + * @return Integer - The frequency of the devices current network or null if no network + * + * @throws SecurityException Without necessary permissions granted + * + * @see [getCurrentNetwork] + * @see [WifiInfo.getFrequency] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + @RequiresPermission(allOf = arrayOf(ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE)) + @Throws(SecurityException::class) + override fun getFrequency(): Int? { + val currentNetwork = getCurrentNetwork() + return currentNetwork?.frequency + } + + /** + * To retrieve the frequency of the device's current network. + * + * @param callbacks The listener to return results to + * + * @throws SecurityException Without necessary permissions granted + * + * @see [getCurrentNetwork] + * @see [GetFrequencyCallbacks] + * @see [runOnWiseFyThread] + * @see [WifiInfo.getFrequency] + * @see [WiseFyLock] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + @RequiresPermission(allOf = arrayOf(ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE)) + @Throws(SecurityException::class) + override fun getFrequency(callbacks: GetFrequencyCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val currentNetwork = getCurrentNetwork() + if (currentNetwork != null) { + callbacks?.retrievedFrequency(currentNetwork.frequency) + } else { + callbacks?.failureGettingFrequency() + } + } + }) + } + + /** + * To retrieve the frequency of a network. + * + * @param network The network to return the frequency of + * + * @return Integer - The frequency of the devices current network or null if no network + * + * @see [WifiInfo.getFrequency] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + override fun getFrequency(network: WifiInfo?): Int? = network?.frequency + + /** + * To retrieve the frequency of a network. + * + * @param network The network to return the frequency of + * @param callbacks The listener to return results to + * + * @see [GetFrequencyCallbacks] + * @see [runOnWiseFyThread] + * @see [WifiInfo.getFrequency] + * @see [WiseFyLock] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + override fun getFrequency(network: WifiInfo?, callbacks: GetFrequencyCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + if (network != null) { + callbacks?.retrievedFrequency(network.frequency) + } else { + callbacks?.wisefyFailure(MISSING_PARAMETER) + } + } + }) + } + + /** + * To retrieve the IPv4 or IPv6 of a device. + * + * @return String - The IPv4 or IPv6 address + * + * @see [InetAddress.getHostAddress] + * @see [WifiInfo.getIpAddress] + * @see [WifiManager.getConnectionInfo] + * @see [WiseFyPrechecks.getIPChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun getIP(): String? { + if (wisefyPrechecks.getIPChecks().failed()) { + return null + } + + val ipAddress = BigInteger.valueOf(wifiManager.connectionInfo.ipAddress.toLong()).toByteArray() + try { + return InetAddress.getByAddress(ipAddress).hostAddress + } catch (uhe: UnknownHostException) { + WiseFyLogger.error(TAG, uhe, "UnknownHostException while gathering IP (sync)") + } + return null + } + + /** + * To retrieve the IPv4 or IPv6 of a device. + * + * @param callbacks The listener to return results to + * + * @see [GetIPCallbacks] + * @see [InetAddress.getHostAddress] + * @see [runOnWiseFyThread] + * @see [WifiInfo.getIpAddress] + * @see [WifiManager.getConnectionInfo] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.getIPChecks] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun getIP(callbacks: GetIPCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.getIPChecks() + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val ipAddress = BigInteger.valueOf(wifiManager.connectionInfo.ipAddress.toLong()).toByteArray() + try { + callbacks?.retrievedIP(InetAddress.getByAddress(ipAddress).hostAddress) + } catch (uhe: UnknownHostException) { + WiseFyLogger.error(TAG, uhe, "UnknownHostException while gathering IP (async)") + callbacks?.failureRetrievingIP() + } + } + }) + } + + /** + * To retrieve a list of nearby access points. + * + * *NOTE* Setting filterDuplicates to true will exclude access points for an SSID that have a weaker RSSI + * (will always take the highest signal strength). + * + * @param filterDuplicates If you want to exclude SSIDs with that same name that have a weaker signal strength + * + * @return List of ScanResults|null - List of nearby access points + * + * @throws SecurityException Without necessary permissions granted + * + * @see [ScanResult] + * @see [WifiManager.getScanResults] + * @see [WifiManager.startScan] + * @see [WiseFyPrechecks.getNearbyAccessPointsChecks] + * @see [WiseFySearch.removeEntriesWithLowerSignalStrength] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(allOf = arrayOf(ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE)) + @Throws(SecurityException::class) + override fun getNearbyAccessPoints(filterDuplicates: Boolean): List? { + if (wisefyPrechecks.getNearbyAccessPointsChecks().failed()) { + return null + } + + wifiManager.startScan() + return if (filterDuplicates) { + wisefySearch.removeEntriesWithLowerSignalStrength(wifiManager.scanResults) + } else { + wifiManager.scanResults + } + } + + /** + * To retrieve a list of nearby access points. + * + * *NOTE* Setting filterDuplicates to true will not return SSIDs with a weaker signal strength (will always take the highest). + * + * @param filterDuplicates If you want to exclude SSIDs with that same name that have a weaker signal strength + * @param callbacks The listener to return results to + * + * @see [GetNearbyAccessPointsCallbacks] + * @see [runOnWiseFyThread] + * @see [WifiManager.getScanResults] + * @see [WifiManager.startScan] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.getNearbyAccessPointsChecks] + * @see [WiseFySearch.removeEntriesWithLowerSignalStrength] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(allOf = arrayOf(ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE)) + override fun getNearbyAccessPoints(filterDuplicates: Boolean, callbacks: GetNearbyAccessPointsCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.getNearbyAccessPointsChecks() + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + wifiManager.startScan() + if (filterDuplicates) { + callbacks?.retrievedNearbyAccessPoints( + wisefySearch.removeEntriesWithLowerSignalStrength(wifiManager.scanResults) + ) + } else { + callbacks?.retrievedNearbyAccessPoints(wifiManager.scanResults) + } + } + }) + } + + /** + * To retrieve the RSSI of the first network matching a given regex. + * + * *NOTE* Setting takeHighest to true will return the access point with the highest RSSI for the given SSID. + * + * @param regexForSSID The regex to be used to search for the ssid + * @param takeHighest Whether to return the access point with the highest RSSI for the given SSID + * @param timeoutInMillis The amount of time to search for a matching SSID + * + * @return Integer - The RSSI value for the found SSID or null if no matching network found + * + * @see [ScanResult.level] + * @see [WiseFyPrechecks.getRSSIChecks] + * @see [WiseFySearch.findAccessPointByRegex] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @WaitsForTimeout + @RequiresPermission(ACCESS_WIFI_STATE) + override fun getRSSI(regexForSSID: String?, takeHighest: Boolean, timeoutInMillis: Int): Int? { + if (wisefyPrechecks.getRSSIChecks(regexForSSID).failed()) { + return null + } + + return wisefySearch.findAccessPointByRegex(regexForSSID!!, timeoutInMillis, takeHighest)?.level + } + + /** + * To retrieve the RSSI of the first network matching a given regex. + * + * *NOTE* Setting takeHighest to true will return the access point with the highest RSSI for the given SSID. + * + * @param regexForSSID The regex to be used to search for the ssid + * @param takeHighest Whether to return the access point with the highest RSSI for the given SSID + * @param timeoutInMillis The amount of time to search for a matching SSID + * @param callbacks The listener to return results to + * + * @see [GetRSSICallbacks] + * @see [runOnWiseFyThread] + * @see [ScanResult.level] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.getRSSIChecks] + * @see [WiseFySearch.findAccessPointByRegex] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @WaitsForTimeout + @RequiresPermission(ACCESS_WIFI_STATE) + override fun getRSSI( + regexForSSID: String?, + takeHighest: Boolean, + timeoutInMillis: Int, + callbacks: GetRSSICallbacks? + ) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.getRSSIChecks(regexForSSID) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val accessPoint = wisefySearch.findAccessPointByRegex(regexForSSID!!, timeoutInMillis, takeHighest) + if (accessPoint != null) { + callbacks?.retrievedRSSI(accessPoint.level) + } else { + callbacks?.networkNotFoundToRetrieveRSSI() + } + } + }) + } + + /** + * To search for and return a saved WiFiConfiguration given an SSID. + * + * @param regexForSSID The ssid to use while searching for saved configuration + * + * @return WifiConfiguration|null - Saved network that matches the ssid + * + * @see [WifiConfiguration] + * @see [WiseFyPrechecks.getSavedNetworkChecks] + * @see [WiseFySearch.findSavedNetworkByRegex] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun getSavedNetwork(regexForSSID: String?): WifiConfiguration? { + return if (wisefyPrechecks.getSavedNetworkChecks(regexForSSID).passed()) { + wisefySearch.findSavedNetworkByRegex(regexForSSID!!) + } else null + } + + /** + * To search for and return a saved WiFiConfiguration given an SSID. + * + * @param regexForSSID The ssid to use while searching for saved configuration + * @param callbacks The listener to return results to + * + * @see [GetSavedNetworkCallbacks] + * @see [runOnWiseFyThread] + * @see [WifiConfiguration] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.getSavedNetworkChecks] + * @see [WiseFySearch.findSavedNetworkByRegex] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun getSavedNetwork(regexForSSID: String?, callbacks: GetSavedNetworkCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.getSavedNetworkChecks(regexForSSID) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val savedNetwork = wisefySearch.findSavedNetworkByRegex(regexForSSID!!) + if (savedNetwork != null) { + callbacks?.retrievedSavedNetwork(savedNetwork) + } else { + callbacks?.savedNetworkNotFound() + } + } + }) + } + + /** + * To retrieve a list of saved networks on a user's device. + * + * @return List of WifiConfiguration|null - List of saved networks on a users device + * + * @see [WifiConfiguration] + * @see [WiseFyPrechecks.getSavedNetworksChecks] + * @see [WiseFySearch.findSavedNetworksMatchingRegex] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun getSavedNetworks(): List? { + return if (wisefyPrechecks.getSavedNetworksChecks().passed()) { + wifiManager.configuredNetworks + } else null + } + + /** + * To retrieve a list of saved networks on a user's device. + * + * @param callbacks The listener to return results to + * + * @see [GetSavedNetworksCallbacks] + * @see [runOnWiseFyThread] + * @see [WifiConfiguration] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.getSavedNetworksChecks] + * @see [WiseFySearch.findSavedNetworksMatchingRegex] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun getSavedNetworks(callbacks: GetSavedNetworksCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.getSavedNetworksChecks() + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val savedNetworks = wifiManager.configuredNetworks + if (savedNetworks != null && !savedNetworks.isEmpty()) { + callbacks?.retrievedSavedNetworks(savedNetworks) + } else { + callbacks?.noSavedNetworksFound() + } + } + }) + } + + /** + * To retrieve a list of saved networks on a user's device that match a given regex. + * + * @param regexForSSID The ssid to use while searching for saved configurations + * + * @return List of WifiConfigurations|null - The list of saved network configurations that match the given regex + * + * @see [WifiConfiguration] + * @see [WiseFyPrechecks.getSavedNetworksChecks] + * @see [WiseFySearch.findSavedNetworksMatchingRegex] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun getSavedNetworks(regexForSSID: String?): List? { + return if (wisefyPrechecks.getSavedNetworksChecks(regexForSSID).passed()) { + wisefySearch.findSavedNetworksMatchingRegex(regexForSSID!!) + } else null + } + + /** + * To retrieve a list of saved networks on a user's device that match a given regex. + * + * @param regexForSSID The ssid to use while searching for saved configurations + * @param callbacks The listener to return results to + * + * @see [GetSavedNetworksCallbacks] + * @see [runOnWiseFyThread] + * @see [WifiConfiguration] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.getSavedNetworksChecks] + * @see [WiseFySearch.findSavedNetworksMatchingRegex] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun getSavedNetworks(regexForSSID: String?, callbacks: GetSavedNetworksCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.getSavedNetworksChecks(regexForSSID) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val savedNetworks = wisefySearch.findSavedNetworksMatchingRegex(regexForSSID!!) + if (savedNetworks != null && !savedNetworks.isEmpty()) { + callbacks?.retrievedSavedNetworks(savedNetworks) + } else { + callbacks?.noSavedNetworksFound() + } + } + }) + } + + /** + * To retrieve the lock in use by WiseFy for synchronization. + * + * @return WiseFyLock - The instance of the lock in use by WiseFy + * + * @see WiseFyLock + * + * @author Patches + * @since 3.0 + */ + override fun getWiseFyLock(): WiseFyLock = wisefyLock + + /** + * To check if the device is connected to a mobile network. + * + * @return bool - If the device is currently connected to a mobile network + * + * @see [ConnectivityManager.getActiveNetworkInfo] + * @see [MOBILE] + * @see [WiseFyConnection.isNetworkConnectedAndMatchesType] + * @see [WiseFyPrechecks.isDeviceConnectedToMobileNetworkChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_NETWORK_STATE) + override fun isDeviceConnectedToMobileNetwork(): Boolean = + wisefyPrechecks.isDeviceConnectedToMobileNetworkChecks().passed() && + wisefyConnection.isNetworkConnectedAndMatchesType(connectivityManager.activeNetworkInfo, MOBILE) + + /** + * To check if the device is connected to a mobile or wifi network. + * + * @return bool - If the device is currently connected to a mobile or wifi network + * + * @see [ConnectivityManager.getActiveNetworkInfo] + * @see [WiseFyConnection.isNetworkConnected] + * @see [WiseFyPrechecks.isDeviceConnectedToMobileOrWifiNetworkChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_NETWORK_STATE) + override fun isDeviceConnectedToMobileOrWifiNetwork(): Boolean = + wisefyPrechecks.isDeviceConnectedToMobileOrWifiNetworkChecks().passed() && + wisefyConnection.isNetworkConnected(connectivityManager.activeNetworkInfo) + + /** + * To check if the device is connected to a given SSID. + * + * @param ssid The SSID to check if the device is attached to + * + * @return bool - If the device is currently attached to the given SSID + * + * @see [WiseFyConnection.isCurrentNetworkConnectedToSSID] + * @see [WiseFyPrechecks.isDeviceConnectedToSSIDChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(allOf = arrayOf(ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE)) + override fun isDeviceConnectedToSSID(ssid: String?): Boolean = + wisefyPrechecks.isDeviceConnectedToSSIDChecks(ssid).passed() && + wisefyConnection.isCurrentNetworkConnectedToSSID(ssid) + + /** + * To check if the device is connected to a wifi network. + * + * @return bool - If the device is currently connected to a wifi network + * + * @see [ConnectivityManager.getActiveNetworkInfo] + * @see [WIFI] + * @see [WiseFyConnection.isNetworkConnectedAndMatchesType] + * @see [WiseFyPrechecks.isDeviceConnectedToWifiNetworkChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_NETWORK_STATE) + override fun isDeviceConnectedToWifiNetwork(): Boolean = + wisefyPrechecks.isDeviceConnectedToWifiNetworkChecks().passed() && + wisefyConnection.isNetworkConnectedAndMatchesType(connectivityManager.activeNetworkInfo, WIFI) + + /** + * To query if the device is roaming. + * + * @return boolean - If the current network is roaming + * + * @see [ConnectivityManager.getActiveNetworkInfo] + * @see [NetworkInfo.isRoaming] + * @see [WiseFyPrechecks.isDeviceRoamingChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_NETWORK_STATE) + override fun isDeviceRoaming(): Boolean { + if (wisefyPrechecks.isDeviceRoamingChecks().failed()) { + return false + } + + val networkInfo = connectivityManager.activeNetworkInfo + return networkInfo != null && networkInfo.isRoaming + } + + /** + * To query if logging is enabled or disabled for a WiseFy instance. + * + * @return boolean - If logging is enabled for the WiseFy instance + * + * @see [WiseFyLogger.isLoggingEnabled] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun isLoggingEnabled(): Boolean = WiseFyLogger.isLoggingEnabled() + + /** + * To check if the device's current network is 5gHz. + * + * @return boolean - If the network is 5gHz + * + * @throws SecurityException Without necessary permissions granted + * + * @see [getFrequency] + * @see [MAX_FREQUENCY_5GHZ] + * @see [MIN_FREQUENCY_5GHZ] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + @RequiresPermission(allOf = arrayOf(ACCESS_COARSE_LOCATION, ACCESS_WIFI_STATE)) + @Throws(SecurityException::class) + override fun isNetwork5gHz(): Boolean { + val frequency = getFrequency() + return frequency != null && frequency > MIN_FREQUENCY_5GHZ && frequency < MAX_FREQUENCY_5GHZ + } + + /** + * To check if a given network is 5gHz. + * + * @param network The network to check if it's 5gHz + * + * @return boolean - If the network is 5gHz + * + * @see [getFrequency] + * @see [MAX_FREQUENCY_5GHZ] + * @see [MIN_FREQUENCY_5GHZ] + * @see [WifiInfo] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + override fun isNetwork5gHz(network: WifiInfo?): Boolean { + val frequency = getFrequency(network) + return frequency != null && frequency > MIN_FREQUENCY_5GHZ && frequency < MAX_FREQUENCY_5GHZ + } + + /** + * To check and return if a network is a EAP network. + * + * @param scanResult The network to check + * + * @return boolean - Whether the network has EAP capabilities listed + * + * @see [containsCapability] + * @see [ScanResult] + * @see [EAP] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun isNetworkEAP(scanResult: ScanResult?): Boolean = containsCapability(scanResult, EAP) + + /** + * To check and return if a network is a PSK network. + * + * @param scanResult The network to check + * + * @return boolean - Whether the network has PSK capabilities listed + * + * @see [containsCapability] + * @see [ScanResult] + * @see [PSK] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun isNetworkPSK(scanResult: ScanResult?): Boolean = containsCapability(scanResult, PSK) + + /** + * To check if an SSID is in the list of configured networks. + * + * @param ssid The SSID to check and see if it's in the list of configured networks + * + * @return boolean - If the SSID is in the list of configured networks + * + * @see [WiseFyPrechecks.isNetworkSavedChecks] + * @see [WiseFySearch.isNetworkASavedConfiguration] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun isNetworkSaved(ssid: String?): Boolean = + wisefyPrechecks.isNetworkSavedChecks().passed() && wisefySearch.isNetworkASavedConfiguration(ssid) + + /** + * To check and return if a network is secure (contains EAP/PSK/WEP/WPA/WPA2 capabilities). + * + * @param scanResult The network to see if it is secure + * + * @return boolean - Whether the network is secure + * + * @see [ScanResult.capabilities] + * @see [EAP] + * @see [PSK] + * @see [WEP] + * @see [WPA] + * @see [WPA2] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun isNetworkSecure(scanResult: ScanResult?): Boolean { + scanResult?.let { + val networkCapabilities: String? = it.capabilities + networkCapabilities?.let { capabilities -> + val securityModes = arrayOf(EAP, PSK, WEP, WPA, WPA2) + for (securityMode in securityModes) { + if (capabilities.contains(securityMode)) { + return true + } + } + } + } + return false + } + + /** + * To check and return if a network is a WEP network. + * + * @param scanResult The network to check + * + * @return boolean - Whether the network has WEP capabilities listed + * + * @see [containsCapability] + * @see [ScanResult] + * @see [WEP] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun isNetworkWEP(scanResult: ScanResult?): Boolean = containsCapability(scanResult, WEP) + + /** + * To check and return if a network is a WPA network. + * + * @param scanResult The network to check + * + * @return boolean - Whether the network has WPA capabilities listed + * + * @see [containsCapability] + * @see [ScanResult] + * @see [WPA] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun isNetworkWPA(scanResult: ScanResult?): Boolean = containsCapability(scanResult, WPA) + + /** + * To check and return if a network is a WPA2 network. + * + * @param scanResult The network to check + * + * @return boolean - Whether the network has WPA2 capabilities listed + * + * @see [containsCapability] + * @see [ScanResult] + * @see [WPA2] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun isNetworkWPA2(scanResult: ScanResult?): Boolean = containsCapability(scanResult, WPA2) + + /** + * To check if Wifi is enabled on the device or not. + * + * @return boolean - if Wifi is enabled on device + * + * @see [WifiManager.isWifiEnabled] + * @see [WiseFyPrechecks.isWifiEnabledChecks] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + override fun isWifiEnabled(): Boolean = wisefyPrechecks.isWifiEnabledChecks().passed() && wifiManager.isWifiEnabled + + /** + * To remove a configured network. + * + * @param ssidToRemove The ssid of the network you want to remove from the configured network list + * + * @return boolean - If the command succeeded in removing the network + * + * @see [removeNetworkConfiguration] + * @see [WifiConfiguration] + * @see [WiseFyPrechecks.removeNetworkCheck] + * @sse [WiseFySearch.findSavedNetworkByRegex] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun removeNetwork(ssidToRemove: String?): Boolean { + if (wisefyPrechecks.removeNetworkCheck(ssidToRemove).failed()) { + return false + } + + val wifiConfiguration = wisefySearch.findSavedNetworkByRegex(ssidToRemove!!) + if (wifiConfiguration != null) { + return removeNetworkConfiguration(wifiConfiguration) + } else { + WiseFyLogger.warn(TAG, "SSID to remove: %s was not found in list to remove network", ssidToRemove) + } + return false + } + + /** + * To remove a configured network. + * + * @param ssidToRemove The ssid of the network you want to remove from the configured network list + * @param callbacks The listener to return results to + * + * @see [RemoveNetworkCallbacks] + * @see [removeNetworkConfiguration] + * @see [runOnWiseFyThread] + * @see [WifiConfiguration] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.removeNetworkCheck] + * @sse [WiseFySearch.findSavedNetworkByRegex] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun removeNetwork(ssidToRemove: String?, callbacks: RemoveNetworkCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.removeNetworkCheck(ssidToRemove) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val wifiConfiguration = wisefySearch.findSavedNetworkByRegex(ssidToRemove!!) + if (wifiConfiguration != null) { + if (removeNetworkConfiguration(wifiConfiguration)) { + callbacks?.networkRemoved() + } else { + callbacks?.failureRemovingNetwork() + } + } else { + callbacks?.networkNotFoundToRemove() + } + } + }) + } + + /** + * To return the first access point that matches a given regex. + * + * + * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest). + * + * @param regexForSSID The regex to use when iterating through nearby access points + * @param timeoutInMillis The amount of time (in milliseconds) to wait for a matching access point + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * + * @return ScanResult|null - The first access point or access point with the highest signal strength matching the regex + * + * @see [ScanResult] + * @see [WiseFyPrechecks.searchForAccessPointChecks] + * @see [WiseFySearch.findAccessPointByRegex] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun searchForAccessPoint( + regexForSSID: String?, + timeoutInMillis: Int, + filterDuplicates: Boolean + ): ScanResult? { + return if (wisefyPrechecks.searchForAccessPointChecks(regexForSSID).passed()) { + wisefySearch.findAccessPointByRegex(regexForSSID!!, timeoutInMillis, filterDuplicates) + } else null + } + + /** + * To return the first access point that matches a given regex. + * + * + * *NOTE* Setting filterDuplicates to true will not return an access point with a weaker signal strength (will always take the highest). + * + * @param regexForSSID The regex to use when iterating through nearby access points + * @param timeoutInMillis The amount of time (in milliseconds) to wait for a matching access point + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * @param callbacks The listener to return results to + * + * @see [runOnWiseFyThread] + * @see [ScanResult] + * @see [SearchForAccessPointCallbacks] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.searchForAccessPointChecks] + * @see [WiseFySearch.findAccessPointByRegex] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun searchForAccessPoint( + regexForSSID: String?, + timeoutInMillis: Int, + filterDuplicates: Boolean, + callbacks: SearchForAccessPointCallbacks? + ) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.searchForAccessPointChecks(regexForSSID) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val scanResult = wisefySearch.findAccessPointByRegex(regexForSSID!!, timeoutInMillis, filterDuplicates) + if (scanResult != null) { + callbacks?.accessPointFound(scanResult) + } else { + callbacks?.accessPointNotFound() + } + } + }) + } + + /** + * To return nearby access points that match a given regex. + * + * + * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest). + * + * @param regexForSSID The regex to use when iterating through nearby access points + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * + * @return List of ScanResult|null - The list of matching access points or null if none match the given regex + * + * @see [ScanResult] + * @see [WiseFyPrechecks.searchForAccessPointsChecks] + * @see [WiseFySearch.findAccessPointsMatchingRegex] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun searchForAccessPoints(regexForSSID: String?, filterDuplicates: Boolean): List? { + return if (wisefyPrechecks.searchForAccessPointsChecks(regexForSSID).passed()) { + wisefySearch.findAccessPointsMatchingRegex(regexForSSID!!, filterDuplicates) + } else null + } + + /** + * To return nearby access points that match a given regex. + * + * + * *NOTE* Setting filterDuplicates to true will not return access points with a weaker signal strength (will always take the highest). + * + * @param regexForSSID The regex to use when iterating through nearby access points + * @param filterDuplicates If you want to exclude access points with the same name that have a weaker signal strength + * @param callbacks The listener to return results to + * + * @see [runOnWiseFyThread] + * @see [ScanResult] + * @see [SearchForAccessPointsCallbacks] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.searchForAccessPointsChecks] + * @see [WiseFySearch.findAccessPointsMatchingRegex] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun searchForAccessPoints( + regexForSSID: String?, + filterDuplicates: Boolean, + callbacks: SearchForAccessPointsCallbacks? + ) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.searchForAccessPointsChecks(regexForSSID) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val networks = wisefySearch.findAccessPointsMatchingRegex(regexForSSID!!, filterDuplicates) + if (networks != null) { + callbacks?.foundAccessPoints(networks) + } else { + callbacks?.noAccessPointsFound() + } + } + }) + } + + /** + * To search local networks and return the first one that contains a given ssid. + * + * @param regexForSSID The regex to be used to search for the ssid + * @param timeoutInMillis The number of milliseconds to keep searching for the SSID + * + * @return String|null - The first SSID that contains the search ssid (if any, else null) + * + * @see [ScanResult.SSID] + * @see [WiseFyPrechecks.searchForSSIDChecks] + * @see [WiseFySearch.findAccessPointByRegex] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @WaitsForTimeout + @RequiresPermission(ACCESS_WIFI_STATE) + override fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int): String? { + if (wisefyPrechecks.searchForSSIDChecks(regexForSSID).failed()) { + return null + } + + val scanResult = wisefySearch.findAccessPointByRegex(regexForSSID!!, timeoutInMillis, false) + return scanResult?.SSID + } + + /** + * To search local networks and return the first one that contains a given ssid. + * + * @param regexForSSID The regex to be used to search for the ssid + * @param timeoutInMillis The number of milliseconds to keep searching for the SSID + * @param callbacks The listener to return results to + * + * @see [runOnWiseFyThread] + * @see [ScanResult.SSID] + * @see [SearchForSSIDCallbacks] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.searchForSSIDChecks] + * @see [WiseFySearch.findAccessPointByRegex] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @WaitsForTimeout + @RequiresPermission(ACCESS_WIFI_STATE) + override fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int, callbacks: SearchForSSIDCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.searchForSSIDChecks(regexForSSID) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val scanResult = wisefySearch.findAccessPointByRegex(regexForSSID!!, timeoutInMillis, false) + if (scanResult != null) { + callbacks?.ssidFound(scanResult.SSID) + } else { + callbacks?.ssidNotFound() + } + } + }) + } + + /** + * To search local networks and return the first one that contains a given ssid. + * + * @param regexForSSID The regex to be used to search for the ssid + * + * @return String|null - The first SSID that contains the search ssid (if any, else null) + * + * @see [WiseFyPrechecks.searchForSSIDsChecks] + * @see [WiseFySearch.findSSIDsMatchingRegex] + * + * @author Patches + * @since 3.0 + */ + @Sync + @CallingThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun searchForSSIDs(regexForSSID: String?): List? { + return if (wisefyPrechecks.searchForSSIDsChecks(regexForSSID).passed()) { + wisefySearch.findSSIDsMatchingRegex(regexForSSID!!) + } else null + } + + /** + * To search local networks and return the first one that contains a given ssid. + * + * @param regexForSSID The regex to be used to search for the ssid + * @param callbacks The listener to return results to + * + * @see [runOnWiseFyThread] + * @see [SearchForSSIDsCallbacks] + * @see [WiseFyLock] + * @see [WiseFyPrechecks.searchForSSIDsChecks] + * @see [WiseFySearch.findSSIDsMatchingRegex] + * + * @author Patches + * @since 3.0 + */ + @Async + @WiseFyThread + @RequiresPermission(ACCESS_WIFI_STATE) + override fun searchForSSIDs(regexForSSID: String?, callbacks: SearchForSSIDsCallbacks?) { + runOnWiseFyThread(Runnable { + synchronized(wisefyLock) { + val precheck = wisefyPrechecks.searchForSSIDsChecks(regexForSSID) + if (precheck.failed()) { + callbacks?.wisefyFailure(precheck.code) + return@Runnable + } + + val ssids = wisefySearch.findSSIDsMatchingRegex(regexForSSID!!) + if (ssids != null && ssids.isNotEmpty()) { + callbacks?.retrievedSSIDs(ssids) + } else { + callbacks?.noSSIDsFound() + } + } + }) + } + + /* + * HELPERS + */ + + /** + * Used internally to add and save a new wifi configuration. + * + * @param wifiConfiguration The network configuration to add + * + * @return boolean - If the network was successfully added + * + * @see [WifiConfiguration.SSID] + * @see [WifiManager.addNetwork] + * + * @author Patches + * @since 3.0 + */ + private fun addNetworkConfiguration(wifiConfiguration: WifiConfiguration): Int { + val result = wifiManager.addNetwork(wifiConfiguration) + WiseFyLogger.debug(TAG, "Adding network with SSID: %s had result: %d", wifiConfiguration.SSID, result) + if (result == WIFI_MANAGER_FAILURE) { + WiseFyLogger.error(TAG, "Error adding network configuration.") + } + return result + } + + /** + * Used internally to check if a network has a given capability. + * + * @param scanResult The network to check + * @param capability The capability to check for + * + * @return boolean - True if the network contains the capability + * + * @see [Capability] + * @see [ScanResult.capabilities] + * + * @author Patches + * @since 3.0 + */ + private fun containsCapability(scanResult: ScanResult?, @Capability capability: String): Boolean = + scanResult?.capabilities != null && scanResult.capabilities.contains(capability) + + /** + * Used internally to connect to a network given it's id. + * + * @param networkId The network id to enable + * + * @see [WifiManager.disconnect] + * @see [WifiManager.enableNetwork] + * @see [WifiManager.reconnect] + * + * @author Patches + * @since 3.0 + */ + private fun connectToNetworkWithId(networkId: Int) { + wifiManager.disconnect() + wifiManager.enableNetwork(networkId, true) + wifiManager.reconnect() + } + + /** + * A method to execute logic on a background thread. + * + * @param runnable The block of code to execute in the background + * + * @see [setupWiseFyThread] + * + * @author Patches + * @since 3.0 + */ + private fun runOnWiseFyThread(runnable: Runnable) { + if (wisefyHandler == null) { + setupWiseFyThread() + } + wisefyHandler?.post(runnable) + } + + /** + * Used internally to remove a network. + * + * @param wifiConfiguration The network to remove + * + * @return bool - true if the network was successfully removed + * + * @see [WifiConfiguration.networkId] + * @see [WifiConfiguration.SSID] + * @see [WifiManager.disconnect] + * @see [WifiManager.removeNetwork] + * @see [WifiManager.reconnect] + * + * @author Patches + * @since 3.0 + */ + private fun removeNetworkConfiguration(wifiConfiguration: WifiConfiguration): Boolean { + wifiManager.disconnect() + val result = wifiManager.removeNetwork(wifiConfiguration.networkId) + WiseFyLogger.debug(TAG, "Removing network with SSID: %s had result: %b", wifiConfiguration.SSID, result) + wifiManager.reconnect() + return result + } + + /** + * Used internally to setup a WiseFyThread to run background operations. + * + * @see [runOnWiseFyThread] + * @see [WiseFyHandlerThread] + * + * @author Patches + * @since 3.0 + */ + private fun setupWiseFyThread() { + wisefyHandlerThread = WiseFyHandlerThread(WiseFyHandlerThread.TAG) + wisefyHandlerThread?.let { + it.start() + val looper = it.looper + wisefyHandler = Handler(looper) + } + } +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyConfiguration.java b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyConfiguration.java deleted file mode 100644 index 0bb91bf7..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyConfiguration.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy; - - -import com.isupatches.wisefy.annotations.Internal; - - -/** - * A class used internally to hold a shared reference to the configuration provided with the - * builder pattern. Right now logging is the only configurable option, but this could potentially - * be expanded. - * - * @author Patches - */ -@Internal -class WiseFyConfiguration { - - private static final WiseFyConfiguration WISEFY_CONFIGURATION = new WiseFyConfiguration(); - - private boolean mLoggingEnabled; - - /** - * Private constructor with no setup - */ - private WiseFyConfiguration() { - } - - /** - * @return instance of WiseFyConfiguration - */ - static WiseFyConfiguration getInstance() { - return WISEFY_CONFIGURATION; - } - - /** - * Used internally to query for if logging has been enabled on this instance of WiseFy - * - * @return boolean - True if logging has been enabled - */ - boolean isLoggingEnabled() { - return mLoggingEnabled; - } - - /** - * Used internally to set the logging configuration - * - * *NOTE* Called upon initialization - */ - void setLoggingEnabled(boolean mLoggingEnabled) { - this.mLoggingEnabled = mLoggingEnabled; - } -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyConnection.java b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyConnection.java deleted file mode 100644 index 7c6bfdda..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyConnection.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy; - - -import android.net.NetworkInfo; -import android.net.wifi.WifiInfo; -import android.util.Log; -import com.isupatches.wisefy.annotations.Internal; -import com.isupatches.wisefy.annotations.WaitsForTimeout; -import com.isupatches.wisefy.util.LogUtil; -import com.isupatches.wisefy.util.SleepUtil; - - -/** - * A class used internally to query and determine different parts of the connection state for a - * device. - * - * @author Patches - */ -@Internal -class WiseFyConnection { - - private static final String TAG = WiseFyConnection.class.getSimpleName(); - - private static final WiseFyConnection WISEFY_CONNECTION = new WiseFyConnection(); - - private WiseFyConfiguration mWiseFyConfiguration; - - WiseFyPrerequisites mWiseFyPrerequisites; - - /** - * Private constructor with no setup - */ - private WiseFyConnection() { - mWiseFyConfiguration = WiseFyConfiguration.getInstance(); - mWiseFyPrerequisites = WiseFyPrerequisites.getInstance(); - } - - /** - * @return instance of WiseFyPrerequisites - */ - static WiseFyConnection getInstance() { - return WISEFY_CONNECTION; - } - - /** - * Used internally to see if the current network is connected to and matches a given ssid - * - * *NOTE* Case insensitive - * - * @param ssid The ssid to check if the device is connected to - * - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#getConnectivityManager() () - * @see WiseFyPrerequisites#getWifiManager() - * - * @return boolean - True if the device is connected to a network - */ - boolean isCurrentNetworkConnectedToSSID(String ssid) { - if (ssid == null) { - return false; - } - - WifiInfo connectionInfo = mWiseFyPrerequisites.getWifiManager().getConnectionInfo(); - if (connectionInfo != null && connectionInfo.getSSID() != null) { - String currentSSID = connectionInfo.getSSID().replaceAll("\"", ""); - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Current SSID: %s, Desired SSID: %s", currentSSID, ssid)); - } - if (currentSSID.equalsIgnoreCase(ssid)) { - if (isNetworkConnected(mWiseFyPrerequisites.getConnectivityManager().getActiveNetworkInfo())) { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, "Network is connected"); - } - return true; - } - } - } - return false; - } - - /** - * Used internally to check if a network is connected - * - * @param networkInfo The network to check - * - * @return boolean - True if the network is both available and connected - */ - boolean isNetworkConnected(NetworkInfo networkInfo) { - return networkInfo != null && networkInfo.isConnected() && networkInfo.isAvailable(); - } - - /** - * Used internally to check if a given network matches a given type and is connected - * - * @param networkInfo The network to check - * @param type The type of network (i.e. Mobile or Wifi) - * - * @see #doesNetworkMatchType(NetworkInfo, String) - * @see #isNetworkConnected(NetworkInfo) - * - * @return boolean - True if the network is both connected and matches the given type of network - */ - boolean isNetworkConnectedAndMatchesType(NetworkInfo networkInfo, String type) { - return isNetworkConnected(networkInfo) && doesNetworkMatchType(networkInfo, type); - } - - /** - * Used internally to check if the device connects to a given SSID within a specified time - * - * @param ssid The ssid to wait for the device to connect to - * @param timeoutInMillis The number of milliseconds to wait - * - * @see #isCurrentNetworkConnectedToSSID(String)} - * @see WiseFyConfiguration#isLoggingEnabled() - * - * @return boolean - Ture if the device is connected to the ssid within the given time - */ - @WaitsForTimeout - boolean waitToConnectToSSID(String ssid, int timeoutInMillis) { - long currentTime; - long endTime = System.currentTimeMillis() + timeoutInMillis; - do { - boolean result = isCurrentNetworkConnectedToSSID(ssid); - if (result) { - return true; - } - SleepUtil.sleep(1000); - currentTime = System.currentTimeMillis(); - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Current time: %d / End time: %d (waitToConnectToSSID)", currentTime, endTime)); - } - } while (currentTime < endTime); - return false; - } - - /** - * Used internally to check to see if a given network matches a specified type (i.e. Mobile or Wifi) - * - * *NOTE* Case insensitive - * - * @param networkInfo The network to check - * @param type The type of network - * - * @return boolean - True if the network matches the given type - */ - private boolean doesNetworkMatchType(NetworkInfo networkInfo, String type) { - return networkInfo != null && networkInfo.getTypeName() != null && networkInfo.getTypeName().equalsIgnoreCase(type); - } -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyConnection.kt b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyConnection.kt new file mode 100644 index 00000000..69cb7f94 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyConnection.kt @@ -0,0 +1,193 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy + +import android.Manifest.permission.ACCESS_NETWORK_STATE +import android.Manifest.permission.ACCESS_WIFI_STATE +import android.net.ConnectivityManager +import android.net.NetworkInfo +import android.net.wifi.WifiManager +import android.support.annotation.RequiresPermission + +import com.isupatches.wisefy.annotations.WaitsForTimeout +import com.isupatches.wisefy.constants.NetworkType +import com.isupatches.wisefy.constants.QUOTE +import com.isupatches.wisefy.logging.WiseFyLogger +import com.isupatches.wisefy.utils.rest + +/** + * A class used internally to query and determine different parts of the connection state for a + * device. + * + * @see [ConnectivityManager] + * @see [WifiManager] + * @see [WiseFyConnection] + * + * @author Patches + * @since 3.0 + */ +internal class WiseFyConnectionImpl private constructor( + private val connectivityManager: ConnectivityManager, + private val wifiManager: WifiManager +) : WiseFyConnection { + + internal companion object { + private val TAG = WiseFyConnection::class.java.simpleName + + fun create(connectivityManager: ConnectivityManager, wifiManager: WifiManager): WiseFyConnection = + WiseFyConnectionImpl(connectivityManager, wifiManager) + } + + /** + * Used internally to see if the current network is connected to and matches a given ssid. + * + * *NOTE* Case insensitive + * + * @param ssid The ssid to check if the device is connected to + * + * @return boolean - True if the device is connected to a network + * + * @see [isNetworkConnected] + * @see [WifiManager.getConnectionInfo] + * + * @author Patches + * @since 3.0 + */ + @RequiresPermission(allOf = arrayOf(ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE)) + override fun isCurrentNetworkConnectedToSSID(ssid: String?): Boolean { + if (ssid.isNullOrEmpty()) { + return false + } + + val connectionInfo = wifiManager.connectionInfo + connectionInfo?.let { + if (!it.ssid.isNullOrEmpty()) { + val currentSSID = it.ssid.replace(QUOTE, "") + WiseFyLogger.debug(TAG, "Current SSID: %s, Desired SSID: %s", currentSSID, ssid ?: "") + if (currentSSID.equals(ssid, ignoreCase = true) && + isNetworkConnected(connectivityManager.activeNetworkInfo) + ) { + WiseFyLogger.debug(TAG, "Network is connected") + return true + } + } + } + return false + } + + /** + * Used internally to check if a network is connected. + * + * @param networkInfo The network to check + * + * @return boolean - True if the network is both available and connected + * + * @see [NetworkInfo] + * + * @author Patches + * @since 3.0 + */ + override fun isNetworkConnected(networkInfo: NetworkInfo?): Boolean { + WiseFyLogger.debug(TAG, "networkInfo: %s", networkInfo ?: "") + return networkInfo != null && networkInfo.isConnected && networkInfo.isAvailable + } + + /** + * Used internally to check if a given network matches a given type and is connected. + * + * @param networkInfo The network to check + * @param type The type of network (i.error. Mobile or Wifi) + * + * @return boolean - True if the network is both connected and matches the given type of network + * + * @see [doesNetworkMatchType] + * @see [isNetworkConnected] + * @see [NetworkInfo] + * + * @author Patches + * @since 3.0 + */ + override fun isNetworkConnectedAndMatchesType(networkInfo: NetworkInfo?, @NetworkType type: String): Boolean = + isNetworkConnected(networkInfo) && doesNetworkMatchType(networkInfo, type) + + /** + * Used internally to check if the device connects to a given SSID within a specified time. + * + * @param ssid The ssid to wait for the device to connect to + * @param timeoutInMillis The number of milliseconds to wait + * + * @return boolean - True if the device is connected to the ssid within the given time + * + * @see [isCurrentNetworkConnectedToSSID] + * + * @author Patches + * @since 3.0 + */ + @WaitsForTimeout + @RequiresPermission(allOf = arrayOf(ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE)) + override fun waitToConnectToSSID(ssid: String?, timeoutInMillis: Int): Boolean { + WiseFyLogger.debug(TAG, "Waiting %d milliseconds to connect to network with ssid %s", timeoutInMillis, ssid ?: "") + var currentTime: Long + val endTime = System.currentTimeMillis() + timeoutInMillis + do { + if (isCurrentNetworkConnectedToSSID(ssid)) { + return true + } + rest() + currentTime = System.currentTimeMillis() + WiseFyLogger.debug(TAG, "Current time: %d, End time: %d (waitToConnectToSSID)", currentTime, endTime) + } while (currentTime < endTime) + return false + } + + /** + * Used internally to check to see if a given network matches a specified type (i.error. Mobile or Wifi) + * + * *NOTE* Case insensitive + * + * @param networkInfo The network to check + * @param type The type of network + * + * @return boolean - True if the network matches the given type + * + * @see [NetworkInfo] + * @see [NetworkType] + * + * @author Patches + * @since 3.0 + */ + private fun doesNetworkMatchType(networkInfo: NetworkInfo?, @NetworkType type: String): Boolean = + type.equals(networkInfo?.typeName, ignoreCase = true) +} + +/** + * An interface with methods that relate to checking device connectivity. + * + * @see [WiseFyConnectionImpl] + * + * @author Patches + * @since 3.0 + */ +internal interface WiseFyConnection { + + fun isCurrentNetworkConnectedToSSID(ssid: String?): Boolean + + fun isNetworkConnected(networkInfo: NetworkInfo?): Boolean + + fun isNetworkConnectedAndMatchesType(networkInfo: NetworkInfo?, @NetworkType type: String): Boolean + + fun waitToConnectToSSID(ssid: String?, timeoutInMillis: Int): Boolean +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.java b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyLock.kt similarity index 71% rename from wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.java rename to wisefy/src/main/java/com/isupatches/wisefy/WiseFyLock.kt index fd0c883b..1fe767ee 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.java +++ b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyLock.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017 Patches Klinefelter + * Copyright 2018 Patches Klinefelter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,10 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.isupatches.wisefy.constants; +package com.isupatches.wisefy - -public class NetworkTypes { - public static final String MOBILE = "MOBILE"; - public static final String WIFI = "WIFI"; -} +/** + * A class used to synchronize logic. + * + * @see [WiseFy.getWiseFyLock] + * + * @author Patches + * @since 3.0 + */ +class WiseFyLock internal constructor() diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrechecks.kt b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrechecks.kt new file mode 100644 index 00000000..b09cad04 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrechecks.kt @@ -0,0 +1,615 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy + +import android.Manifest.permission.ACCESS_WIFI_STATE +import android.support.annotation.RequiresPermission + +import com.isupatches.wisefy.constants.DEFAULT_PRECHECK_RETURN_CODE +import com.isupatches.wisefy.constants.MISSING_PARAMETER +import com.isupatches.wisefy.constants.NETWORK_ALREADY_CONFIGURED +import com.isupatches.wisefy.constants.WiseFyCode + +/** + * A helper class with methods to determine if the necessary requirements are met to preform operations. + * + * @see [WiseFyPrechecks] + * @see [WiseFySearch] + * + * @author Patches + * @since 3.0 + */ +internal class WiseFyPrechecksImpl private constructor( + private val wisefySearch: WiseFySearch +) : WiseFyPrechecks { + + /** + * Used internally to make sure perquisites for adding a network as a saved configuration are met. + * + * @param ssid The ssid param from [com.isupatches.wisefy.WiseFy.addOpenNetwork] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkAddNetworkPrerequisites] + * @see [com.isupatches.wisefy.WiseFy.addOpenNetwork] + * + * @author Patches + * @since 3.0 + */ + @RequiresPermission(ACCESS_WIFI_STATE) + override fun addNetworkPrechecks(ssid: String?): PrecheckResult = + checkAddNetworkPrerequisites(ssid) + + /** + * Used internally to make sure perquisites for adding a network as a saved configuration are met. + * + * @param ssid The ssid param from [com.isupatches.wisefy.WiseFy.addWEPNetwork] or [com.isupatches.wisefy.WiseFy.addWPA2Network] + * @param password The password from [com.isupatches.wisefy.WiseFy.addWEPNetwork] or [com.isupatches.wisefy.WiseFy.addWPA2Network] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkAddNetworkPrerequisites] + * @see [com.isupatches.wisefy.WiseFy.addWEPNetwork] + * @see [com.isupatches.wisefy.WiseFy.addWPA2Network] + * + * @author Patches + * @since 3.0 + */ + @RequiresPermission(ACCESS_WIFI_STATE) + override fun addNetworkPrechecks(ssid: String?, password: String?): PrecheckResult = + checkAddNetworkPrerequisites(ssid, password) + + /** + * Used internally to make sure perquisites for connecting to a network are met. + * + * @param ssidToConnectTo The ssidToConnectTo param from [com.isupatches.wisefy.WiseFy.connectToNetwork] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkForParam] + * @see [com.isupatches.wisefy.WiseFy.connectToNetwork] + * + * @author Patches + * @since 3.0 + */ + override fun connectToNetworkPrechecks(ssidToConnectTo: String?): PrecheckResult = + checkForParam(ssidToConnectTo) + + /** + * Used internally to make sure perquisites for disabling wifi on the device are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.disableWifi] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun disableWifiChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure perquisites for disconnecting a device from it's current network are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.disconnectFromCurrentNetwork] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun disconnectFromCurrentNetworkChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure perquisites for enabling wifi on the device are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.enableWifi] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun enableWifiChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure perquisites for getting the device's current network are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.getCurrentNetworkInfo] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun getCurrentNetworkChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure perquisites for getting the device's current network info are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.getCurrentNetworkInfo] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun getCurrentNetworkInfoChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure perquisites for getting the ip of the device are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.getIP] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun getIPChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure perquisites for getting nearby access points are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.getNearbyAccessPoints] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun getNearbyAccessPointsChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure perquisites for getting the RSSI of a network matching a given regex are met. + * + * @param regexForSSID The regexForSSID param from [com.isupatches.wisefy.WiseFy.getRSSI] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkForParam] + * @see [com.isupatches.wisefy.WiseFy.getRSSI] + * + * @author Patches + * @since 3.0 + */ + override fun getRSSIChecks(regexForSSID: String?): PrecheckResult = + checkForParam(regexForSSID) + + /** + * Used internally to make sure perquisites for getting the saved networks on a device are met. + * + * @param regexForSSID The regexForSSID param from [com.isupatches.wisefy.WiseFy.getSavedNetwork] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkForParam] + * @see [com.isupatches.wisefy.WiseFy.getSavedNetwork] + * + * @author Patches + * @since 3.0 + */ + override fun getSavedNetworkChecks(regexForSSID: String?): PrecheckResult = + checkForParam(regexForSSID) + + /** + * Used internally to make sure perquisites for getting a saved network on a device are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.getSavedNetworks] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun getSavedNetworksChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure perquisites for getting the saved networks on a device are met. + * + * @param regexForSSID The regexForSSID param from [com.isupatches.wisefy.WiseFy.getSavedNetworks] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkForParam] + * @see [com.isupatches.wisefy.WiseFy.getSavedNetworks] + * + * @author Patches + * @since 3.0 + */ + override fun getSavedNetworksChecks(regexForSSID: String?): PrecheckResult = + checkForParam(regexForSSID) + + /** + * Used internally to make sure perquisites for checking if the device is connected to + * a mobile network are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.isDeviceConnectedToMobileNetwork] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun isDeviceConnectedToMobileNetworkChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure perquisites for checking if the device is connected to + * a mobile or wifi network are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.isDeviceConnectedToMobileOrWifiNetwork] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun isDeviceConnectedToMobileOrWifiNetworkChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure perquisites for checking if the device is connected to + * a specific SSID are met. + * + * @param ssid The ssid param from [com.isupatches.wisefy.WiseFy.isDeviceConnectedToSSID] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkForParam] + * @see [com.isupatches.wisefy.WiseFy.isDeviceConnectedToSSID] + * + * @author Patches + * @since 3.0 + */ + override fun isDeviceConnectedToSSIDChecks(ssid: String?): PrecheckResult = + checkForParam(ssid) + + /** + * Used internally to make sure perquisites for checking if the device is connected to + * a wifi network are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.isDeviceConnectedToWifiNetwork] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun isDeviceConnectedToWifiNetworkChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure prerequisites for seeing if a device is roaming are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.isDeviceRoaming] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun isDeviceRoamingChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure prerequisites for seeing if a network is a saved configuration + * are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.isNetworkSaved] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun isNetworkSavedChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure prerequisites for enabling wifi are met. + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] + * + * @see [com.isupatches.wisefy.WiseFy.isWifiEnabled] + * @see [DEFAULT_PRECHECK_RESULT] + * + * @author Patches + * @since 3.0 + */ + override fun isWifiEnabledChecks() = DEFAULT_PRECHECK_RESULT + + /** + * Used internally to make sure prerequisites for removing a network are met. + * + * @param ssidToRemove The regexForSsid param from [com.isupatches.wisefy.WiseFy.removeNetwork] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkForParam] + * @see [com.isupatches.wisefy.WiseFy.removeNetwork] + * + * @author Patches + * @since 3.0 + */ + override fun removeNetworkCheck(ssidToRemove: String?): PrecheckResult = + checkForParam(ssidToRemove) + + /** + * Used internally to make sure prerequisites for searching for an individual access point + * are met. + * + * @param regexForSSID The regexForSsid param from [com.isupatches.wisefy.WiseFy.searchForAccessPoint] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkForParam] + * @see [com.isupatches.wisefy.WiseFy.searchForAccessPoint] + * + * @author Patches + * @since 3.0 + */ + override fun searchForAccessPointChecks(regexForSSID: String?): PrecheckResult = + checkForParam(regexForSSID) + + /** + * Used internally to make sure prerequisites for searching for access points are met. + * + * @param regexForSSID The regexForSsid param from [com.isupatches.wisefy.WiseFy.searchForAccessPoints] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkForParam] + * @see [com.isupatches.wisefy.WiseFy.searchForAccessPoints] + * + * @author Patches + * @since 3.0 + */ + override fun searchForAccessPointsChecks(regexForSSID: String?): PrecheckResult = + checkForParam(regexForSSID) + + /** + * Used internally to make sure prerequisites for searching for an individual SSID are met. + * + * @param regexForSSID The regexForSsid param from [com.isupatches.wisefy.WiseFy.searchForSSID] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkForParam] + * @see [com.isupatches.wisefy.WiseFy.searchForSSID] + * + * @author Patches + * @since 3.0 + */ + override fun searchForSSIDChecks(regexForSSID: String?): PrecheckResult = + checkForParam(regexForSSID) + + /** + * Used internally to make sure prerequisites for searching for SSIDs are met. + * + * @param regexForSSID The regexForSsid param from [com.isupatches.wisefy.WiseFy.searchForSSIDs] + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [checkForParam] + * @see [com.isupatches.wisefy.WiseFy.searchForSSIDs] + * + * @author Patches + * @since 3.0 + */ + override fun searchForSSIDsChecks(regexForSSID: String?): PrecheckResult = + checkForParam(regexForSSID) + + /* + * HELPERS + */ + + /** + * Used internally as an abstracted layer that check if a necessary param is not empty. + * + * @param param The param to check if it's empty + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [DEFAULT_PRECHECK_RESULT] + * @see [MISSING_PARAMETER] + * @see [PrecheckResult] + * + * @author Patches + * @since 3.0 + */ + private fun checkForParam(param: String?): PrecheckResult = + if (param.isNullOrEmpty()) { + PrecheckResult(code = MISSING_PARAMETER) + } else { + DEFAULT_PRECHECK_RESULT + } + + /** + * Used internally as an abstracted layer that checks if all of the prerequisites for adding + * a network are met. i.e. ssid is not null or empty, network is not already saved, etc. + * + * @param ssid The ssid of the network to add + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [DEFAULT_PRECHECK_RESULT] + * @see [MISSING_PARAMETER] + * @see [NETWORK_ALREADY_CONFIGURED] + * @see [PrecheckResult] + * + * @author Patches + * @since 3.0 + */ + private fun checkAddNetworkPrerequisites(ssid: String?): PrecheckResult = + when { + ssid == null -> PrecheckResult(code = MISSING_PARAMETER) + ssid.isEmpty() -> PrecheckResult(code = MISSING_PARAMETER) + wisefySearch.isNetworkASavedConfiguration(ssid) -> { + PrecheckResult(code = NETWORK_ALREADY_CONFIGURED) + } + else -> DEFAULT_PRECHECK_RESULT + } + + /** + * Used internally as an abstracted layer that checks if all of the prerequisites for adding + * a network are met. i.e. ssid and password are not null or empty, network is not already saved, etc. + * + * @param ssid The ssid of the network to add + * @param password The password of the network to add + * + * @return PrecheckResult - [DEFAULT_PRECHECK_RESULT] or a [PrecheckResult] with an error code. + * + * @see [DEFAULT_PRECHECK_RESULT] + * @see [MISSING_PARAMETER] + * @see [NETWORK_ALREADY_CONFIGURED] + * @see [PrecheckResult] + * + * @author Patches + * @since 3.0 + */ + private fun checkAddNetworkPrerequisites(ssid: String?, password: String?): PrecheckResult = + when { + ssid.isNullOrEmpty() || password.isNullOrEmpty() -> { + PrecheckResult(code = MISSING_PARAMETER) + } + wisefySearch.isNetworkASavedConfiguration(ssid) -> { + PrecheckResult(code = NETWORK_ALREADY_CONFIGURED) + } + else -> DEFAULT_PRECHECK_RESULT + } + + internal companion object { + fun create(wisefySearch: WiseFySearch): WiseFyPrechecks = WiseFyPrechecksImpl(wisefySearch) + } +} + +/** + * An interface with methods that relate to checking that prerequisites are met before + * continuing with a WiseFy operation. + * + * @see [WiseFyPrechecksImpl] + * + * @author Patches + * @since 3.0 + */ +internal interface WiseFyPrechecks { + + fun addNetworkPrechecks(ssid: String?): PrecheckResult + + fun addNetworkPrechecks(ssid: String?, password: String?): PrecheckResult + + fun connectToNetworkPrechecks(ssidToConnectTo: String?): PrecheckResult + + fun disableWifiChecks(): PrecheckResult + + fun disconnectFromCurrentNetworkChecks(): PrecheckResult + + fun enableWifiChecks(): PrecheckResult + + fun getCurrentNetworkChecks(): PrecheckResult + + fun getCurrentNetworkInfoChecks(): PrecheckResult + + fun getIPChecks(): PrecheckResult + + fun getNearbyAccessPointsChecks(): PrecheckResult + + fun getRSSIChecks(regexForSSID: String?): PrecheckResult + + fun getSavedNetworkChecks(regexForSSID: String?): PrecheckResult + + fun getSavedNetworksChecks(regexForSSID: String?): PrecheckResult + + fun getSavedNetworksChecks(): PrecheckResult + + fun isDeviceConnectedToMobileNetworkChecks(): PrecheckResult + + fun isDeviceConnectedToMobileOrWifiNetworkChecks(): PrecheckResult + + fun isDeviceConnectedToSSIDChecks(ssid: String?): PrecheckResult + + fun isDeviceConnectedToWifiNetworkChecks(): PrecheckResult + + fun isDeviceRoamingChecks(): PrecheckResult + + fun isNetworkSavedChecks(): PrecheckResult + + fun isWifiEnabledChecks(): PrecheckResult + + fun removeNetworkCheck(ssidToRemove: String?): PrecheckResult + + fun searchForAccessPointChecks(regexForSSID: String?): PrecheckResult + + fun searchForAccessPointsChecks(regexForSSID: String?): PrecheckResult + + fun searchForSSIDChecks(regexForSSID: String?): PrecheckResult + + fun searchForSSIDsChecks(regexForSSID: String?): PrecheckResult +} + +/** + * A return from WiseFyPrechecks that includes a relevant detail code. + * + * @param code The return code from prechecks (i.e. [DEFAULT_PRECHECK_RETURN_CODE] or + * an error code such as [MISSING_PARAMETER]. This code will also be used by the extension + * functions [passed] and [failed]. + * + * @see [failed] + * @see [passed] + * @see [WiseFyCode] + * + * @author Patches + * @since 3.0 + */ +internal data class PrecheckResult(@WiseFyCode val code: Int) + +/** + * An extension function to determine if prerequisites for an operation are NOT met. + * + * @see [PrecheckResult] + * + * @author Patches + * @since 3.0 + */ +internal fun PrecheckResult.failed(): Boolean = code < DEFAULT_PRECHECK_RETURN_CODE + +/** + * An extension function to determine if prerequisites for an operation ARE met. + * + * @see [PrecheckResult] + * + * @author Patches + * @since 3.0 + */ +internal fun PrecheckResult.passed(): Boolean = code >= DEFAULT_PRECHECK_RETURN_CODE + +/** + * A default result to return that denotes a success and that prerequisites for an operation are met. + * + * @see [PrecheckResult] + * + * @author Patches + * @since 3.0 + */ +internal val DEFAULT_PRECHECK_RESULT = PrecheckResult(code = DEFAULT_PRECHECK_RETURN_CODE) diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrerequisites.java b/wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrerequisites.java deleted file mode 100644 index c1c71741..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyPrerequisites.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy; - - -import android.net.ConnectivityManager; -import android.net.wifi.WifiManager; -import android.util.Log; -import com.isupatches.wisefy.annotations.Internal; -import com.isupatches.wisefy.util.LogUtil; - - -/** - * A class used internally as a bridge for other parts of the library to use a shared set of - * prerequisite instances. This contains the WifiManager and ConnectivityManger used throughout - * the library. - * - * @author Patches - */ -@Internal -class WiseFyPrerequisites { - - private static final String TAG = WiseFyPrerequisites.class.getSimpleName(); - - private static final WiseFyPrerequisites WISEFY_PREREQUISITES = new WiseFyPrerequisites(); - - private WiseFyConfiguration mWiseFyConfiguration; - - private ConnectivityManager mConnectivityManager; - - private WifiManager mWifiManager; - - /** - * Private constructor with no setup - */ - private WiseFyPrerequisites() { - mWiseFyConfiguration = WiseFyConfiguration.getInstance(); - } - - /** - * @return instance of WiseFyPrerequisites - */ - static WiseFyPrerequisites getInstance() { - return WISEFY_PREREQUISITES; - } - - /** - * Used internally to verify if the WiseFy instances has the necessary criteria to work - * - * @see WiseFyConfiguration#isLoggingEnabled() - * - * @return boolean - True if all prerequisites are met - */ - boolean hasPrerequisites() { - if (mWifiManager == null) { - if (LogUtil.isLoggable(TAG, Log.ERROR, mWiseFyConfiguration.isLoggingEnabled())) { - Log.e(TAG, "Missing WifiManager"); - } - return false; - } - if (mConnectivityManager == null) { - if (LogUtil.isLoggable(TAG, Log.ERROR, mWiseFyConfiguration.isLoggingEnabled())) { - Log.e(TAG, "Missing ConnectivityManager"); - } - return false; - } - return true; - } - - /** - * Used internally to return a shared ConnectivityManager instance to the rest of the library - * - * @return ConnectivityManager|null - The shared ConnectivityManager instance if any or null - */ - ConnectivityManager getConnectivityManager() { - return mConnectivityManager; - } - - /** - * Used internally to return a shared WifiManager instance to the rest of the library - * - * @return WifiManager|null - The shared WifiManager instance if any or null - */ - WifiManager getWifiManager() { - return mWifiManager; - } - - - /** - * Used internally to set the shared ConnectivityManager instance for the rest of the library - * - * *NOTE* Called upon initialization or in test - */ - void setConnectivityManager(ConnectivityManager mConnectivityManager) { - this.mConnectivityManager = mConnectivityManager; - } - - /** - * Used internally to set the shared WifiManager instance for the rest of the library - * - * *NOTE* Called upon initialization or in test - */ - void setWifiManager(WifiManager mWifiManager) { - this.mWifiManager = mWifiManager; - } -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFySearch.java b/wisefy/src/main/java/com/isupatches/wisefy/WiseFySearch.java deleted file mode 100644 index 0ce4518b..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/WiseFySearch.java +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy; - - -import android.net.wifi.ScanResult; -import android.net.wifi.WifiConfiguration; -import android.net.wifi.WifiManager; -import android.util.Log; -import com.isupatches.wisefy.annotations.Internal; -import com.isupatches.wisefy.annotations.WaitsForTimeout; -import com.isupatches.wisefy.util.LogUtil; -import com.isupatches.wisefy.util.SleepUtil; -import java.util.ArrayList; -import java.util.List; - - -/** - * A class used internally for the purposes of shared query logic. This handles saved networks and - * nearby access points. There is also filtering by regex functionality and some RSSI logic that - * are tied into these queries. - * - * @author Patches - */ -@Internal -class WiseFySearch { - - private static final String TAG = WiseFySearch.class.getSimpleName(); - - private static final WiseFySearch WISEFY_SEARCH = new WiseFySearch(); - - WiseFyPrerequisites mWiseFyPrerequisites; - - private WiseFyConfiguration mWiseFyConfiguration; - - /** - * Private constructor with no setup - */ - private WiseFySearch() { - mWiseFyPrerequisites = WiseFyPrerequisites.getInstance(); - mWiseFyConfiguration = WiseFyConfiguration.getInstance(); - } - - /** - * @return instance of WiseFySearch - */ - static WiseFySearch getInstance() { - return WISEFY_SEARCH; - } - - /** - * Used internally to wait for a given time and return the first ScanResult whose SSID matches a given regex - * - * @param regexForSSID The regex to check the SSID of the network against - * @param timeoutInMillis The amount of time to wait for a match - * @param takeHighest If the method should iterate through and return only the access point with the highest RSSI - * - * @see #hasHighestSignalStrength(List, ScanResult) - * @see SleepUtil#sleep(long) - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#getWifiManager() () - * - * @return ScanResult|null - The first network whose SSID matches a given regex or a network that matches - * the given regex and has the highest RSSI. Returns null if no matching network found. - */ - @WaitsForTimeout - ScanResult findAccessPointByRegex(String regexForSSID, Integer timeoutInMillis, boolean takeHighest) { - int scanPass = 1; - long currentTime; - long endTime = System.currentTimeMillis() + timeoutInMillis; - do { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Scanning SSIDs, pass %d", scanPass)); - } - mWiseFyPrerequisites.getWifiManager().startScan(); - List accessPoints = mWiseFyPrerequisites.getWifiManager().getScanResults(); - if (accessPoints != null && accessPoints.size() > 0) { - for (ScanResult accessPoint : accessPoints) { - if (accessPoint != null && accessPoint.SSID != null && (accessPoint.SSID).matches(regexForSSID)) { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("scanResult.SSID: %s, regex for SSID: %s", accessPoint.SSID, regexForSSID)); - } - if (takeHighest) { - if (hasHighestSignalStrength(accessPoints, accessPoint)) { - return accessPoint; - } - } else { - return accessPoint; - } - } - } - } - - SleepUtil.sleep(1000); - - currentTime = System.currentTimeMillis(); - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("Current time: %d / End time: %d (findAccessPointByRegex)", currentTime, endTime)); - } - scanPass++; - } while (currentTime < endTime); - return null; - } - - /** - * Used internally to return a list of networks whose SSID match the given regex - * - * @param regexForSSID The regex to check the SSID of the network against - * @param takeHighest If the method should iterate through and return only the access point with the highest RSSI - * - * @see #hasHighestSignalStrength(List, ScanResult) - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#getWifiManager() - * - * @return List|null - The list of networks that have an SSID that matches the given regex - */ - List findAccessPointsMatchingRegex(String regexForSSID, boolean takeHighest) { - mWiseFyPrerequisites.getWifiManager().startScan(); - List matchingAccessPoints = new ArrayList<>(); - List accessPoints = mWiseFyPrerequisites.getWifiManager().getScanResults(); - if (accessPoints != null && accessPoints.size() > 0) { - for (ScanResult accessPoint : accessPoints) { - if (accessPoint != null && accessPoint.SSID != null && accessPoint.SSID.matches(regexForSSID)) { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("accessPoint.SSID: %s, regex for SSID: %s", accessPoint.SSID, regexForSSID)); - } - if (takeHighest) { - if (hasHighestSignalStrength(accessPoints, accessPoint)) { - matchingAccessPoints.add(accessPoint); - } - } else { - matchingAccessPoints.add(accessPoint); - } - } - } - } - if (matchingAccessPoints.size() > 0) { - return matchingAccessPoints; - } else { - return null; - } - } - - /** - * Used internally to return the first configuration of s saved networks matching a given regex - * - * @param regexForSSID The regex for the SSID to find in the configured network list - * - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#getWifiManager() - * - * @return WiFiConfiguration|null - The first saved configuration matching the given regex - * or null if no matching network found - */ - WifiConfiguration findSavedNetworkByRegex(String regexForSSID) { - List savedNetworks = mWiseFyPrerequisites.getWifiManager().getConfiguredNetworks(); - if (savedNetworks != null && savedNetworks.size() > 0) { - for (WifiConfiguration savedNetwork : savedNetworks) { - if (savedNetwork != null && savedNetwork.SSID != null) { - String ssidInList = savedNetwork.SSID.replaceAll("\"", ""); - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("SSID in list: %s, SSID: %s", ssidInList, regexForSSID)); - } - if (ssidInList.matches(regexForSSID)) { - return savedNetwork; - } - } - } - } - return null; - } - - /** - * Used internally to return a list of saved networks matching a given regex - * - * @param regexForSSID The regex for the SSIDs to find in the configured network list - * - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#getWifiManager() - * - * @return List|null - The list of saved network configurations matching - * the given regex or null if no matching networks found - */ - List findSavedNetworksMatchingRegex(String regexForSSID) { - List savedNetworks = mWiseFyPrerequisites.getWifiManager().getConfiguredNetworks(); - List matchingSavedNetworks = new ArrayList<>(); - if (savedNetworks != null && savedNetworks.size() > 0) { - for (WifiConfiguration savedNetwork : savedNetworks) { - if (savedNetwork != null && savedNetwork.SSID != null) { - String ssidInList = savedNetwork.SSID.replaceAll("\"", ""); - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("SSID in list: %s, SSID: %s", ssidInList, regexForSSID)); - } - if (ssidInList.matches(regexForSSID)) { - matchingSavedNetworks.add(savedNetwork); - } - } - } - } - if (matchingSavedNetworks.size() > 0) { - return matchingSavedNetworks; - } else { - return null; - } - } - - /** - * Used internally to return a list of SSIDs from saved networks matching a given regex - * - * @param regexForSSID The regex for the SSIDs to find in the configured network list - * - * @see WiseFyConfiguration#isLoggingEnabled() - * @see WiseFyPrerequisites#getWifiManager() - * - * @return List|null - The list of SSIDs of saved network configurations matching - * the given regex or null if no matching networks found - */ - List findSSIDsMatchingRegex(String regexForSSID) { - mWiseFyPrerequisites.getWifiManager().startScan(); - List matchingSSIDs = new ArrayList<>(); - List accessPoints = mWiseFyPrerequisites.getWifiManager().getScanResults(); - if (accessPoints != null && accessPoints.size() > 0) { - for (ScanResult accessPoint : accessPoints) { - if (accessPoint != null && accessPoint.SSID != null) { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("accessPoint.SSID: %s, regex for SSID: %s", accessPoint.SSID, regexForSSID)); - } - if (accessPoint.SSID.matches(regexForSSID)) { - matchingSSIDs.add(accessPoint.SSID); - } - } - } - } - if (matchingSSIDs.size() > 0) { - return matchingSSIDs; - } else { - return null; - } - } - - /** - * Used internally to determine if a network exists as a saved network configuration - * - * @param ssid The ssid to check for in the configured network list - * - * @see WiseFySearch#findSavedNetworkByRegex(String) - * - * @return boolean - True if the ssid was found in the configuration list - */ - boolean isNetworkASavedConfiguration(String ssid) { - WifiConfiguration wifiConfiguration = findSavedNetworkByRegex(ssid); - return wifiConfiguration != null; - } - - /** - * Used internally to build a list of ScanResults (removes duplicates by taking access point with higher RSSI) - * - * *NOTE* Case insensitive - * - * @param accessPoints The list of access points to remove entries with lower signal strength from - * - * @see WiseFyConfiguration#isLoggingEnabled() - * - * @return List - The filtered list of networks - */ - List removeEntriesWithLowerSignalStrength(List accessPoints) { - List accessPointsToReturn = new ArrayList<>(); - - for (ScanResult accessPoint : accessPoints) { - boolean found = false; - for (int i = 0; i < accessPointsToReturn.size(); i++) { - ScanResult scanResult = accessPointsToReturn.get(i); - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("SSID 1: %s, SSID 2: %s", accessPoint.SSID, scanResult.SSID)); - } - if (accessPoint.SSID.equalsIgnoreCase(scanResult.SSID)) { - found = true; - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("RSSI level of access point 1: %d", scanResult.level)); - Log.d(TAG, String.format("RSSI level of access point 2: %d", accessPoint.level)); - Log.d(TAG, String.format("comparison result: %d", WifiManager.compareSignalLevel(accessPoint.level, scanResult.level))); - } - if (WifiManager.compareSignalLevel(accessPoint.level, scanResult.level) > 0) { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, "New result has a higher or same signal strength, swapping"); - } - accessPointsToReturn.set(i, accessPoint); - } - } - } - - if (!found) { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, "Found new wifi network"); - } - accessPointsToReturn.add(accessPoint); - } - } - return accessPointsToReturn; - } - - /* - * Helpers - */ - - /** - * Used internally to determine if the current access point has the highest signal strength - * compared to others that have the same SSID - * - * @param accessPoints A list of access points to compare the current access point to - * @param currentAccessPoint The access point to see if it has the highest signal strength - * - * @see WiseFyConfiguration#isLoggingEnabled() - * - * @return boolean - True if the current access point has the highest signal strength - */ - private boolean hasHighestSignalStrength(List accessPoints, ScanResult currentAccessPoint) { - for (ScanResult accessPoint : accessPoints) { - if (accessPoint.SSID.equalsIgnoreCase(currentAccessPoint.SSID)) { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, String.format("RSSI level of current access point: %d", currentAccessPoint.level)); - Log.d(TAG, String.format("RSSI level of access point in list: %d", accessPoint.level)); - Log.d(TAG, String.format("comparison result: %d", WifiManager.compareSignalLevel(accessPoint.level, currentAccessPoint.level))); - } - if (WifiManager.compareSignalLevel(accessPoint.level, currentAccessPoint.level) > 0) { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mWiseFyConfiguration.isLoggingEnabled())) { - Log.d(TAG, "Stronger signal strength found"); - } - return false; - } - } - } - return true; - } -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFySearch.kt b/wisefy/src/main/java/com/isupatches/wisefy/WiseFySearch.kt new file mode 100644 index 00000000..c7faf4ea --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/WiseFySearch.kt @@ -0,0 +1,431 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy + +import android.Manifest.permission.ACCESS_WIFI_STATE +import android.net.wifi.ScanResult +import android.net.wifi.WifiConfiguration +import android.net.wifi.WifiManager +import android.support.annotation.RequiresPermission + +import com.isupatches.wisefy.annotations.WaitsForTimeout +import com.isupatches.wisefy.constants.QUOTE +import com.isupatches.wisefy.logging.WiseFyLogger +import com.isupatches.wisefy.utils.rest + +import java.util.ArrayList +import java.util.Locale + +/** + * A class used internally for the purposes of shared query logic. This handles saved networks and + * nearby access points. There is also filtering by regex functionality and some RSSI logic that + * are tied into these queries. + * + * @see [WifiManager] + * @see [WiseFySearch] + * + * @author Patches + * @since 3.0 + */ +internal class WiseFySearchImpl private constructor( + private val wifiManager: WifiManager +) : WiseFySearch { + + internal companion object { + private val TAG = WiseFySearch::class.java.simpleName + + fun create(wifiManager: WifiManager): WiseFySearch = WiseFySearchImpl(wifiManager) + } + + /** + * Used internally to wait for a given time and return the first ScanResult whose SSID matches a given regex. + * + * Returns either: + * - The first network whose SSID matches a given regex + * - A network matching the given regex and has the highest RSSI + * + * @param regexForSSID The regex to check the SSID of the network against + * @param timeoutInMillis The amount of time to wait for a match + * @param takeHighest If the method should iterate through and return only the access point with the highest RSSI + * + * @return ScanResult|null - Matching network or null if none found + * + * @see [accessPointMatchesRegex] + * @see [hasHighestSignalStrength] + * @see [rest] + * @see [ScanResult] + * @see [WifiManager.startScan] + * @see [WifiManager.getScanResults] + * + * @author Patches + * @since 3.0 + */ + @WaitsForTimeout + @RequiresPermission(ACCESS_WIFI_STATE) + override fun findAccessPointByRegex(regexForSSID: String, timeoutInMillis: Int, takeHighest: Boolean): ScanResult? { + var scanPass = 1 + var currentTime: Long + val endTime = System.currentTimeMillis() + timeoutInMillis + var accessPointToReturn: ScanResult? = null + do { + currentTime = System.currentTimeMillis() + + WiseFyLogger.debug(TAG, "Scanning SSIDs, pass %d", scanPass) + wifiManager.startScan() + val accessPoints = wifiManager.scanResults + if (accessPoints == null || accessPoints.isEmpty()) { + continue + } + + var found = false + for (accessPoint in accessPoints) { + if (takeHighest) { + if (accessPointMatchesRegex(accessPoint, regexForSSID) && hasHighestSignalStrength( + accessPoints, + accessPoint + ) + ) { + accessPointToReturn = accessPoint + // Need to continue through rest of the list since + // we don't know which one will have the highest + break + } + } else { + if (accessPointMatchesRegex(accessPoint, regexForSSID)) { + accessPointToReturn = accessPoint + found = true + break + } + } + } + + if (found) { + break + } + + rest() + + WiseFyLogger.debug(TAG, "Current time: %d, end time: %d (findAccessPointByRegex)", currentTime, endTime) + scanPass++ + } while (currentTime < endTime) + return accessPointToReturn + } + + /** + * Used internally to return a list of networks whose SSID match the given regex. + * + * @param regexForSSID The regex to check the SSID of the network against + * @param takeHighest If the method should iterate through and return only the access point with the highest RSSI + * + * @return List of ScanResults|null - The list of networks that have an SSID that matches the given regex + * + * @see [accessPointMatchesRegex] + * @see [hasHighestSignalStrength] + * @see [ScanResult] + * @see [WifiManager.startScan] + * @see [WifiManager.getScanResults] + * + * @author Patches + * @since 3.0 + */ + @RequiresPermission(ACCESS_WIFI_STATE) + override fun findAccessPointsMatchingRegex(regexForSSID: String, takeHighest: Boolean): List? { + wifiManager.startScan() + val matchingAccessPoints = ArrayList() + val accessPoints = wifiManager.scanResults + + if (accessPoints == null || accessPoints.isEmpty()) { + return null + } + + for (accessPoint in accessPoints) { + if (accessPointMatchesRegex(accessPoint, regexForSSID)) { + if (takeHighest) { + if (hasHighestSignalStrength(accessPoints, accessPoint)) { + matchingAccessPoints.add(accessPoint) + } + } else { + matchingAccessPoints.add(accessPoint) + } + } + } + + return if (!matchingAccessPoints.isEmpty()) matchingAccessPoints else null + } + + /** + * Used internally to return the first configuration of s saved networks matching a given regex. + * + * @param regexForSSID The regex for the SSID to find in the configured network list + * + * @return WiFiConfiguration|null - The first saved configuration matching the given regex or null if none found + * + * @see [savedNetworkMatchesRegex] + * @see [WifiConfiguration] + * @see [WifiManager.getConfiguredNetworks] + * + * @author Patches + * @since 3.0 + */ + @RequiresPermission(ACCESS_WIFI_STATE) + override fun findSavedNetworkByRegex(regexForSSID: String): WifiConfiguration? { + val savedNetworks = wifiManager.configuredNetworks + if (savedNetworks == null || savedNetworks.isEmpty()) { + return null + } + + for (savedNetwork in savedNetworks) { + if (savedNetworkMatchesRegex(savedNetwork, regexForSSID)) { + return savedNetwork + } + } + return null + } + + /** + * Used internally to return a list of saved networks matching a given regex. + * + * @param regexForSSID The regex for the SSIDs to find in the configured network list + * + * @return List of WifiConfigurations|null - Saved network configurations matching the given regex or null if ' + * none found + * + * @see [savedNetworkMatchesRegex] + * @see [WifiConfiguration] + * @see [WifiManager.getConfiguredNetworks] + * + * @author Patches + * @since 3.0 + */ + @RequiresPermission(ACCESS_WIFI_STATE) + override fun findSavedNetworksMatchingRegex(regexForSSID: String): List? { + val savedNetworks = wifiManager.configuredNetworks + val matchingSavedNetworks = ArrayList() + + if (savedNetworks == null || savedNetworks.isEmpty()) { + return null + } + + for (savedNetwork in savedNetworks) { + if (savedNetworkMatchesRegex(savedNetwork, regexForSSID)) { + matchingSavedNetworks.add(savedNetwork) + } + } + + return if (!matchingSavedNetworks.isEmpty()) matchingSavedNetworks else null + } + + /** + * Used internally to return a list of SSIDs from saved networks matching a given regex. + * + * @param regexForSSID The regex for the SSIDs to find in the configured network list + * + * @return List of Strings|null - SSIDs of saved network configurations matching the + * given regex or null if none found + * + * @see [accessPointMatchesRegex] + * @see [WifiManager.getScanResults] + * @see [WifiManager.startScan] + * + * @author Patches + * @since 3.0 + */ + @RequiresPermission(ACCESS_WIFI_STATE) + override fun findSSIDsMatchingRegex(regexForSSID: String): List? { + wifiManager.startScan() + val matchingSSIDs = ArrayList() + val accessPoints = wifiManager.scanResults + if (accessPoints != null && accessPoints.isNotEmpty()) { + for (accessPoint in accessPoints) { + if (accessPointMatchesRegex(accessPoint, regexForSSID) && !matchingSSIDs.contains(accessPoint.SSID)) { + matchingSSIDs.add(accessPoint.SSID) + } + } + } + + return if (!matchingSSIDs.isEmpty()) matchingSSIDs else null + } + + /** + * Used internally to determine if a network exists as a saved network configuration. + * + * @param ssid The ssid to check for in the configured network list + * + * @return boolean - True if the ssid was found in the configuration list + * + * @see [findSavedNetworkByRegex] + * + * @author Patches + * @since 3.0 + */ + @RequiresPermission(ACCESS_WIFI_STATE) + override fun isNetworkASavedConfiguration(ssid: String?): Boolean = + !ssid.isNullOrEmpty() && findSavedNetworkByRegex(ssid!!) != null + + /** + * Used internally to build a list of ScanResults (removes duplicates by taking access point with higher RSSI). + * + * *NOTE* Case insensitive + * + * @param accessPoints The list of access points to remove entries with lower signal strength from + * + * @return List of ScanResults - The filtered list of networks + * + * @see [ScanResult] + * @see [WifiManager.compareSignalLevel] + * + * @author Patches + * @since 3.0 + */ + override fun removeEntriesWithLowerSignalStrength(accessPoints: List): List { + val accessPointsToReturn = ArrayList() + + for (accessPoint in accessPoints) { + var found = false + for (i in accessPointsToReturn.indices) { + val scanResult = accessPointsToReturn[i] + WiseFyLogger.debug(TAG, "SSID 1: %s, SSID 2: %s", accessPoint.SSID, scanResult.SSID) + if (accessPoint.SSID.equals(scanResult.SSID, ignoreCase = true)) { + found = true + WiseFyLogger.debug(TAG, "RSSI level of access point 1: %d", scanResult.level) + WiseFyLogger.debug(TAG, "RSSI level of access point 2: %d", accessPoint.level) + WiseFyLogger.debug( + TAG, + "comparison result: %d (removeEntriesWithLowerSignalStrength)", + WifiManager.compareSignalLevel(accessPoint.level, scanResult.level) + ) + if (WifiManager.compareSignalLevel(accessPoint.level, scanResult.level) > 0) { + WiseFyLogger.debug(TAG, "New result has a higher or same signal strength, swapping") + accessPointsToReturn[i] = accessPoint + } + } + } + + if (!found) { + WiseFyLogger.debug(TAG, "Found new wifi network") + accessPointsToReturn.add(accessPoint) + } + } + return accessPointsToReturn + } + + /* + * Helpers + */ + + /** + * Used internally to check if a an access point has an SSID that matches a given regex. + * + * @param accessPoint The access point for comparison + * @param regexForSSID The regex for comparison + * + * @return boolean - True if the access point's SSID matches the given regex + * + * @see [ScanResult] + * + * @author Patches + * @since 3.0 + */ + private fun accessPointMatchesRegex(accessPoint: ScanResult?, regexForSSID: String): Boolean { + WiseFyLogger.debug( + TAG, + "accessPoint. SSID: %s, regex for SSID: %s".format(Locale.US, accessPoint?.SSID, regexForSSID) + ) + return accessPoint?.SSID?.matches(regexForSSID.toRegex()) ?: false + } + + /** + * Used internally to determine if the current access point has the highest signal strength + * compared to others that have the same SSID. + * + * *NOTE* Case insensitive + * + * @param accessPoints A list of access points to compare the current access point to + * @param currentAccessPoint The access point to see if it has the highest signal strength + * + * @return boolean - True if the current access point has the highest signal strength + * + * @see [ScanResult] + * @see [WifiManager.compareSignalLevel] + * + * @author Patches + * @since 3.0 + */ + private fun hasHighestSignalStrength(accessPoints: List, currentAccessPoint: ScanResult): Boolean { + for (accessPoint in accessPoints) { + if (accessPoint.SSID.equals(currentAccessPoint.SSID, ignoreCase = true)) { + WiseFyLogger.debug(TAG, "RSSI level of current access point: %d", currentAccessPoint.level) + WiseFyLogger.debug(TAG, "RSSI level of access point in list: %d", accessPoint.level) + WiseFyLogger.debug( + TAG, + "comparison result: %d (hasHighestSignalStrength)", + WifiManager.compareSignalLevel(accessPoint.level, currentAccessPoint.level) + ) + if (WifiManager.compareSignalLevel(accessPoint.level, currentAccessPoint.level) > 0) { + WiseFyLogger.debug(TAG, "Stronger signal strength found") + return false + } + } + } + return true + } + + /** + * Used internally to check if a saved network has an SSID that matches a given regex. + * + * @param savedNetwork The saved network for comparison + * @param regexForSSID The regex for comparison + * + * @return boolean - True if the saved network's SSID matches the given regex + * + * @see [WifiConfiguration] + * + * @author Patches + * @since 3.0 + */ + private fun savedNetworkMatchesRegex(savedNetwork: WifiConfiguration?, regexForSSID: String): Boolean { + if (savedNetwork?.SSID != null) { + val ssidInList = savedNetwork.SSID.replace(QUOTE, "") + return ssidInList.matches(regexForSSID.toRegex()) + } + return false + } +} + +/** + * An interface that helps with searching. + * + * @see [WiseFySearchImpl] + * + * @author Patches + * @since 3.0 + */ +internal interface WiseFySearch { + + fun findAccessPointByRegex(regexForSSID: String, timeoutInMillis: Int, takeHighest: Boolean): ScanResult? + + fun findAccessPointsMatchingRegex(regexForSSID: String, takeHighest: Boolean): List? + + fun findSavedNetworkByRegex(regexForSSID: String): WifiConfiguration? + + fun findSavedNetworksMatchingRegex(regexForSSID: String): List? + + fun findSSIDsMatchingRegex(regexForSSID: String): List? + + fun isNetworkASavedConfiguration(ssid: String?): Boolean + + fun removeEntriesWithLowerSignalStrength(accessPoints: List): List +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WisePublicApi.kt b/wisefy/src/main/java/com/isupatches/wisefy/WisePublicApi.kt new file mode 100644 index 00000000..8246c876 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/WisePublicApi.kt @@ -0,0 +1,313 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy + +import android.net.NetworkInfo +import android.net.wifi.ScanResult +import android.net.wifi.WifiConfiguration +import android.net.wifi.WifiInfo + +import com.isupatches.wisefy.callbacks.AddNetworkCallbacks +import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks +import com.isupatches.wisefy.callbacks.DisableWifiCallbacks +import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks +import com.isupatches.wisefy.callbacks.EnableWifiCallbacks +import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks +import com.isupatches.wisefy.callbacks.GetCurrentNetworkInfoCallbacks +import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks +import com.isupatches.wisefy.callbacks.GetIPCallbacks +import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks +import com.isupatches.wisefy.callbacks.GetRSSICallbacks +import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks +import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks +import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks +import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks +import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks +import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks +import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks + +/** + * The interface that is the public facing API for WiseFy. It is composed of various other sub-apis for separation + * of functionality. + * + * @see [WiseFy] + * @see [AccessPointApi] + * @see [AddNetworkApi] + * @see [ConnectionApi] + * @see [DeviceApi] + * @see [FrequencyApi] + * @see [NetworkInfoApi] + * @see [RemoveNetworkApi] + * @see [SavedNetworkApi] + * @see [SecurityApi] + * @see [SignalStrengthApi] + * @see [WiseFy] + * + * @author Patches + * @since 3.0 + */ +internal interface WiseFyPublicApi : AccessPointApi, AddNetworkApi, ConnectionApi, DeviceApi, FrequencyApi, + NetworkInfoApi, RemoveNetworkApi, SavedNetworkApi, SecurityApi, SignalStrengthApi, WifiApi { + + fun dump() + + fun getWiseFyLock(): WiseFyLock + + fun isLoggingEnabled(): Boolean +} + +/** + * An API for querying for nearby access points and related information. + * + * @author Patches + * @since 3.0 + */ +internal interface AccessPointApi { + + fun getNearbyAccessPoints(filterDuplicates: Boolean): List? + + fun getNearbyAccessPoints(filterDuplicates: Boolean, callbacks: GetNearbyAccessPointsCallbacks?) + + fun getRSSI(regexForSSID: String?, takeHighest: Boolean, timeoutInMillis: Int): Int? + + fun getRSSI( + regexForSSID: String?, + takeHighest: Boolean, + timeoutInMillis: Int, + callbacks: GetRSSICallbacks? + ) + + fun searchForAccessPoint( + regexForSSID: String?, + timeoutInMillis: Int, + filterDuplicates: Boolean + ): ScanResult? + + fun searchForAccessPoint( + regexForSSID: String?, + timeoutInMillis: Int, + filterDuplicates: Boolean, + callbacks: SearchForAccessPointCallbacks? + ) + + fun searchForAccessPoints(regexForSSID: String?, filterDuplicates: Boolean): List? + + fun searchForAccessPoints( + regexForSSID: String?, + filterDuplicates: Boolean, + callbacks: SearchForAccessPointsCallbacks? + ) + + fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int): String? + + fun searchForSSID(regexForSSID: String?, timeoutInMillis: Int, callbacks: SearchForSSIDCallbacks?) + + fun searchForSSIDs(regexForSSID: String?): List? + + fun searchForSSIDs(regexForSSID: String?, callbacks: SearchForSSIDsCallbacks?) +} + +/** + * An API for adding networks as saved configurations on a device. + * + * @author Patches + * @since 3.0 + */ +internal interface AddNetworkApi { + + fun addOpenNetwork(ssid: String?): Int + + fun addOpenNetwork(ssid: String?, callbacks: AddNetworkCallbacks?) + + fun addWEPNetwork(ssid: String?, password: String?): Int + + fun addWEPNetwork(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?) + + fun addWPA2Network(ssid: String?, password: String?): Int + + fun addWPA2Network(ssid: String?, password: String?, callbacks: AddNetworkCallbacks?) +} + +/** + * An API for managing the network connection of a device. + * + * @author Patches + * @since 3.0 + */ +internal interface ConnectionApi { + + fun connectToNetwork(ssidToConnectTo: String?, timeoutInMillis: Int): Boolean + + fun connectToNetwork( + ssidToConnectTo: String?, + timeoutInMillis: Int, + callbacks: ConnectToNetworkCallbacks? + ) + + fun disconnectFromCurrentNetwork(): Boolean + + fun disconnectFromCurrentNetwork(callbacks: DisconnectFromCurrentNetworkCallbacks?) +} + +/** + * An API for querying about the different network statuses of a device. + * + * @author Patches + * @since 3.0 + */ +internal interface DeviceApi { + + fun isDeviceConnectedToMobileNetwork(): Boolean + + fun isDeviceConnectedToMobileOrWifiNetwork(): Boolean + + fun isDeviceConnectedToSSID(ssid: String?): Boolean + + fun isDeviceConnectedToWifiNetwork(): Boolean + + fun isDeviceRoaming(): Boolean +} + +/** + * An API for querying about a network's frequency. + * + * @author Patches + * @since 3.0 + */ +internal interface FrequencyApi { + + fun getFrequency(): Int? + + fun getFrequency(callbacks: GetFrequencyCallbacks?) + + fun getFrequency(network: WifiInfo?): Int? + + fun getFrequency(network: WifiInfo?, callbacks: GetFrequencyCallbacks?) + + fun isNetwork5gHz(): Boolean + + fun isNetwork5gHz(network: WifiInfo?): Boolean +} + +/** + * An API for querying about a device's current network information. + * + * @author Patches + * @since 3.0 + */ +internal interface NetworkInfoApi { + + fun getCurrentNetwork(): WifiInfo? + + fun getCurrentNetwork(callbacks: GetCurrentNetworkCallbacks?) + + fun getCurrentNetworkInfo(): NetworkInfo? + + fun getCurrentNetworkInfo(callbacks: GetCurrentNetworkInfoCallbacks?) + + fun getIP(): String? + + fun getIP(callbacks: GetIPCallbacks?) +} + +/** + * An API for removing a network as a saved configuration. + * + * @author Patches + * @since 3.0 + */ +internal interface RemoveNetworkApi { + + fun removeNetwork(ssidToRemove: String?): Boolean + + fun removeNetwork(ssidToRemove: String?, callbacks: RemoveNetworkCallbacks?) +} + +/** + * An API for querying saved network information on a device. + * + * @author Patches + * @since 3.0 + */ +internal interface SavedNetworkApi { + + fun getSavedNetwork(regexForSSID: String?): WifiConfiguration? + + fun getSavedNetwork(regexForSSID: String?, callbacks: GetSavedNetworkCallbacks?) + + fun getSavedNetworks(): List? + + fun getSavedNetworks(callbacks: GetSavedNetworksCallbacks?) + + fun getSavedNetworks(regexForSSID: String?): List? + + fun getSavedNetworks(regexForSSID: String?, callbacks: GetSavedNetworksCallbacks?) + + fun isNetworkSaved(ssid: String?): Boolean +} + +/** + * An API for querying about a network's security details. + * + * @author Patches + * @since 3.0 + */ +internal interface SecurityApi { + + fun isNetworkEAP(scanResult: ScanResult?): Boolean + + fun isNetworkPSK(scanResult: ScanResult?): Boolean + + fun isNetworkSecure(scanResult: ScanResult?): Boolean + + fun isNetworkWEP(scanResult: ScanResult?): Boolean + + fun isNetworkWPA(scanResult: ScanResult?): Boolean + + fun isNetworkWPA2(scanResult: ScanResult?): Boolean +} + +/** + * An API for functionality relating to signal strength. + * + * @author Patches + * @since 3.0 + */ +internal interface SignalStrengthApi { + + fun calculateBars(rssiLevel: Int, targetNumberOfBars: Int): Int + + fun compareSignalLevel(rssi1: Int, rssi2: Int): Int +} + +/** + * An API for functionality relating to Wifi. + * + * @author Patches + * @since 3.0 + */ +internal interface WifiApi { + + fun disableWifi(): Boolean + + fun disableWifi(callbacks: DisableWifiCallbacks?) + + fun enableWifi(): Boolean + + fun enableWifi(callbacks: EnableWifiCallbacks?) + + fun isWifiEnabled(): Boolean +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddWEPNetworkCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/annotations/Async.kt similarity index 61% rename from wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddWEPNetworkCallbacks.java rename to wisefy/src/main/java/com/isupatches/wisefy/annotations/Async.kt index a66197c7..331a7dc0 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddWEPNetworkCallbacks.java +++ b/wisefy/src/main/java/com/isupatches/wisefy/annotations/Async.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017 Patches Klinefelter + * Copyright 2018 Patches Klinefelter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,14 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.isupatches.wisefy.callbacks; +package com.isupatches.wisefy.annotations +import java.lang.annotation.Inherited -import android.net.wifi.WifiConfiguration; - - -public interface AddWEPNetworkCallbacks { - void addWEPNetworkWiseFyFailure(Integer wisefyReturnCode); - void failureAddingWEPNetwork(Integer wifiManagerReturnCode); - void wepNetworkAdded(WifiConfiguration wepNetwork); -} +/** + * Denotes that a method is asynchronous with callbacks. + * + * @author Patches + * @since 3.0 + */ +@MustBeDocumented +@Target(AnnotationTarget.FUNCTION) +@Inherited +@Retention(AnnotationRetention.RUNTIME) +internal annotation class Async diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddOpenNetworkCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/annotations/CallingThread.kt similarity index 60% rename from wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddOpenNetworkCallbacks.java rename to wisefy/src/main/java/com/isupatches/wisefy/annotations/CallingThread.kt index 07194b37..fbf6e767 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddOpenNetworkCallbacks.java +++ b/wisefy/src/main/java/com/isupatches/wisefy/annotations/CallingThread.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017 Patches Klinefelter + * Copyright 2018 Patches Klinefelter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,14 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.isupatches.wisefy.callbacks; +package com.isupatches.wisefy.annotations +import java.lang.annotation.Inherited -import android.net.wifi.WifiConfiguration; - - -public interface AddOpenNetworkCallbacks { - void addOpenNetworkWiseFyFailure(Integer wisefyReturnCode); - void failureAddingOpenNetwork(Integer wifiManagerReturnCode); - void openNetworkAdded(WifiConfiguration openNetwork); -} +/** + * Denotes that a method is executed on the calling thread. + * + * @author Patches + * @since 3.0 + */ +@MustBeDocumented +@Target(AnnotationTarget.FUNCTION) +@Inherited +@Retention(AnnotationRetention.RUNTIME) +internal annotation class CallingThread diff --git a/wisefy/src/main/java/com/isupatches/wisefy/annotations/Internal.java b/wisefy/src/main/java/com/isupatches/wisefy/annotations/PublicAPI.kt similarity index 63% rename from wisefy/src/main/java/com/isupatches/wisefy/annotations/Internal.java rename to wisefy/src/main/java/com/isupatches/wisefy/annotations/PublicAPI.kt index bc4de8e1..e652b06a 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/annotations/Internal.java +++ b/wisefy/src/main/java/com/isupatches/wisefy/annotations/PublicAPI.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017 Patches Klinefelter + * Copyright 2018 Patches Klinefelter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,18 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.isupatches.wisefy.annotations; +package com.isupatches.wisefy.annotations +import java.lang.annotation.Inherited -import java.lang.annotation.Documented; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - - -@Documented +/** + * Denotes that a class contains methods exposed to end users. + * + * @author Patches + * @since 3.0 + */ +@MustBeDocumented @Inherited -@Retention(RetentionPolicy.RUNTIME) -public @interface Internal { - -} \ No newline at end of file +@Retention(AnnotationRetention.RUNTIME) +internal annotation class PublicAPI diff --git a/wisefy/src/main/java/com/isupatches/wisefy/annotations/PublicAPI.java b/wisefy/src/main/java/com/isupatches/wisefy/annotations/Sync.kt similarity index 63% rename from wisefy/src/main/java/com/isupatches/wisefy/annotations/PublicAPI.java rename to wisefy/src/main/java/com/isupatches/wisefy/annotations/Sync.kt index 95f2b80f..bd699d44 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/annotations/PublicAPI.java +++ b/wisefy/src/main/java/com/isupatches/wisefy/annotations/Sync.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017 Patches Klinefelter + * Copyright 2018 Patches Klinefelter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.isupatches.wisefy.annotations; +package com.isupatches.wisefy.annotations +import java.lang.annotation.Inherited -import java.lang.annotation.Documented; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - - -@Documented +/** + * Denotes that a method is synchronous. + * + * @author Patches + * @since 3.0 + */ +@MustBeDocumented +@Target(AnnotationTarget.FUNCTION) @Inherited -@Retention(RetentionPolicy.RUNTIME) -public @interface PublicAPI { - -} \ No newline at end of file +@Retention(AnnotationRetention.RUNTIME) +internal annotation class Sync diff --git a/wisefy/src/main/java/com/isupatches/wisefy/annotations/WaitsForTimeout.java b/wisefy/src/main/java/com/isupatches/wisefy/annotations/WaitsForTimeout.java deleted file mode 100644 index 90d71a8b..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/annotations/WaitsForTimeout.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.annotations; - - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Documented -@Target(ElementType.METHOD) -@Inherited -@Retention(RetentionPolicy.RUNTIME) -public @interface WaitsForTimeout { - -} - diff --git a/wisefy/src/main/java/com/isupatches/wisefy/annotations/WaitsForTimeout.kt b/wisefy/src/main/java/com/isupatches/wisefy/annotations/WaitsForTimeout.kt new file mode 100644 index 00000000..5e92f98e --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/annotations/WaitsForTimeout.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.annotations + +import java.lang.annotation.Inherited + +/** + * Denotes that a method has logic to wait for a long term operation to complete. + * + * @author Patches + * @since 3.0 + */ +@MustBeDocumented +@Target(AnnotationTarget.FUNCTION) +@Inherited +@Retention(AnnotationRetention.RUNTIME) +internal annotation class WaitsForTimeout diff --git a/wisefy/src/main/java/com/isupatches/wisefy/annotations/WiseFyThread.java b/wisefy/src/main/java/com/isupatches/wisefy/annotations/WiseFyThread.java deleted file mode 100644 index e5b6d2b0..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/annotations/WiseFyThread.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.annotations; - - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Documented -@Target(ElementType.METHOD) -@Inherited -@Retention(RetentionPolicy.RUNTIME) -public @interface WiseFyThread { - -} \ No newline at end of file diff --git a/wisefy/src/main/java/com/isupatches/wisefy/annotations/Sync.java b/wisefy/src/main/java/com/isupatches/wisefy/annotations/WiseFyThread.kt similarity index 57% rename from wisefy/src/main/java/com/isupatches/wisefy/annotations/Sync.java rename to wisefy/src/main/java/com/isupatches/wisefy/annotations/WiseFyThread.kt index 2b5bb033..63a1052f 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/annotations/Sync.java +++ b/wisefy/src/main/java/com/isupatches/wisefy/annotations/WiseFyThread.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017 Patches Klinefelter + * Copyright 2018 Patches Klinefelter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,21 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.isupatches.wisefy.annotations; +package com.isupatches.wisefy.annotations +import java.lang.annotation.Inherited -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Documented -@Target(ElementType.METHOD) +/** + * Denotes that a method is executed on the WiseFyHandler thread. + * + * @see [com.isupatches.wisefy.threads.WiseFyHandlerThread] + * + * @author Patches + * @since 3.0 + */ +@MustBeDocumented +@Target(AnnotationTarget.FUNCTION) @Inherited -@Retention(RetentionPolicy.RUNTIME) -public @interface Sync { - -} +@Retention(AnnotationRetention.RUNTIME) +internal annotation class WiseFyThread diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddNetworkCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddNetworkCallbacks.kt new file mode 100644 index 00000000..c7a31d83 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddNetworkCallbacks.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +import android.net.wifi.WifiConfiguration + +/** + * Callbacks for adding a network as a saved configuration on a device. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.addOpenNetwork] + * @see [com.isupatches.wisefy.WiseFy.addWEPNetwork] + * @see [com.isupatches.wisefy.WiseFy.addWPA2Network] + * + * @author Patches + * @since 3.0 + */ +interface AddNetworkCallbacks : BaseCallback { + + /** + * Called when [android.net.wifi.WifiManager] encounters an error adding a network. + * + * @see [android.net.wifi.WifiManager] + * @see [com.isupatches.wisefy.WiseFy.WIFI_MANAGER_FAILURE] + * + * @author Patches + * @since 3.0 + */ + fun failureAddingNetwork(wifiManagerReturn: Int) + + /** + * Called upon successfully adding a network. + * + * @see [android.net.wifi.WifiConfiguration] + * + * @author Patches + * @since 3.0 + */ + fun networkAdded(newNetworkId: Int, networkConfig: WifiConfiguration) +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddWPA2NetworkCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddWPA2NetworkCallbacks.java deleted file mode 100644 index b57edd3f..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/AddWPA2NetworkCallbacks.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -import android.net.wifi.WifiConfiguration; - - -public interface AddWPA2NetworkCallbacks { - void addWPA2NetworkWiseFyFailure(Integer wisefyReturnCode); - void failureAddingWPA2Network(Integer wifiManagerReturnCode); - void wpa2NetworkAdded(WifiConfiguration wpa2Network); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/BaseCallback.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/BaseCallback.kt new file mode 100644 index 00000000..c516161e --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/BaseCallback.kt @@ -0,0 +1,42 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +import com.isupatches.wisefy.constants.WiseFyCode + +/** + * Callbacks that are applicable to all Async WiseFy operations. + * All Async interfaces should extend this class. + * + * @author Patches + * @since 3.0 + */ +interface BaseCallback { + + /** + * Called when [com.isupatches.wisefy.WiseFyPrechecks] determines that there + * is an issue and an operation cannot be completed. + * + * Example: A null or empty ssid is passed in but is a required parameter. + * + * @see [com.isupatches.wisefy.WiseFyPrechecks] + * @see [com.isupatches.wisefy.constants.WiseFyCode] + * + * @author Patches + * @since 3.0 + */ + fun wisefyFailure(@WiseFyCode wisefyFailureCode: Int) +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.java deleted file mode 100644 index 51ad390a..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -public interface ConnectToNetworkCallbacks { - void connectedToNetwork(); - void connectToNetworkWiseFyFailure(Integer wisefyReturnCode); - void failureConnectingToNetwork(); - void networkNotFoundToConnectTo(); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.kt new file mode 100644 index 00000000..24a231cf --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/ConnectToNetworkCallbacks.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +/** + * Callbacks for attempting to connect to a network. + * + * @see [com.isupatches.wisefy.WiseFy.connectToNetwork] + * + * @author Patches + * @since 3.0 + */ +interface ConnectToNetworkCallbacks : BaseCallback { + + /** + * Called when WiseFy has successfully connected to a network. + * + * @author Patches + * @since 3.0 + */ + fun connectedToNetwork() + + /** + * Called when the network was found, but there was an issue attempting to connect to + * it with [android.net.wifi.WifiManager]. + * + * @see [android.net.wifi.WifiManager] + * + * @author Patches + * @since 3.0 + */ + fun failureConnectingToNetwork() + + /** + * Called when the SSID of the network to connect to cannot be found by [android.net.wifi.WifiManager] + * and WiseFy. + * + * @see [android.net.wifi.WifiManager] + * + * @author Patches + * @since 3.0 + */ + fun networkNotFoundToConnectTo() +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.java deleted file mode 100644 index 643fbc48..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -public interface DisableWifiCallbacks { - void disableWifiWiseFyFailure(Integer wisefyReturnCode); - void failureDisablingWifi(); - void wifiDisabled(); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.kt new file mode 100644 index 00000000..2a361d01 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisableWifiCallbacks.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +/** + * Callbacks for disabling a device's wifi. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.disableWifi] + * + * @author Patches + * @since 3.0 + */ +interface DisableWifiCallbacks : BaseCallback { + + /** + * Called when there is an issue disabling Wifi on the device. + * + * @author Patches + * @since 3.0 + */ + fun failureDisablingWifi() + + /** + * Called when WiseFy has successfully disabled Wifi on the device. + * + * @author Patches + * @since 3.0 + */ + fun wifiDisabled() +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.java deleted file mode 100644 index 24cbc4e7..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -public interface DisconnectFromCurrentNetworkCallbacks { - void disconnectedFromCurrentNetwork(); - void disconnectFromCurrentNetworkWiseFyFailure(Integer wisefyReturnCode); - void failureDisconnectingFromCurrentNetwork(); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.kt new file mode 100644 index 00000000..b09e6130 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/DisconnectFromCurrentNetworkCallbacks.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +/** + * Callbacks for disconnecting a device from it's current network. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.disconnectFromCurrentNetwork] + * + * @author Patches + * @since 3.0 + */ +interface DisconnectFromCurrentNetworkCallbacks : BaseCallback { + + /** + * Called when WiseFy has successfully disconnected from the device's current network. + * + * @author Patches + * @since 3.0 + */ + fun disconnectedFromCurrentNetwork() + + /** + * Called when there is an issue disconnecting the device from it's current network. + * + * @author Patches + * @since 3.0 + */ + fun failureDisconnectingFromCurrentNetwork() +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.java deleted file mode 100644 index 3f7876c6..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -public interface EnableWifiCallbacks { - void enableWifiWiseFyFailure(Integer wisefyReturnCode); - void failureEnablingWifi(); - void wifiEnabled(); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.kt new file mode 100644 index 00000000..578629d1 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/EnableWifiCallbacks.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +/** + * Callbacks for enabling a device's wifi. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.enableWifi] + * + * @author Patches + * @since 3.0 + */ +interface EnableWifiCallbacks : BaseCallback { + + /** + * Called when there is an issue enabling wifi on the device. + * + * @author Patches + * @since 3.0 + */ + fun failureEnablingWifi() + + /** + * Called when WiseFy has successfully enabled wifi on the device. + * + * @author Patches + * @since 3.0 + */ + fun wifiEnabled() +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.java deleted file mode 100644 index 24129b37..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -import android.net.wifi.WifiInfo; - - -public interface GetCurrentNetworkCallbacks { - void getCurrentNetworkWiseFyFailure(Integer wisefyReturnCode); - void retrievedCurrentNetwork(WifiInfo currentNetwork); -} \ No newline at end of file diff --git a/wisefy/src/main/java/com/isupatches/wisefy/util/SleepUtil.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.kt similarity index 53% rename from wisefy/src/main/java/com/isupatches/wisefy/util/SleepUtil.java rename to wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.kt index 10f2edcb..179485ad 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/util/SleepUtil.java +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkCallbacks.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017 Patches Klinefelter + * Copyright 2018 Patches Klinefelter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,30 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.isupatches.wisefy.util; - - -import com.isupatches.wisefy.annotations.Internal; +package com.isupatches.wisefy.callbacks +import android.net.wifi.WifiInfo /** - * A helper class for shared wait logic + * Callbacks for retrieving a device's current network. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.getCurrentNetwork] * * @author Patches + * @since 3.0 */ -@Internal -public class SleepUtil { +interface GetCurrentNetworkCallbacks : BaseCallback { /** - * Used to wait for a given amount of time (in milliseconds) + * Called when WiseFy has successfully retrieved the device's current network. + * + * @see [WifiInfo] * - * @param timeToSleepInMillis The number of milliseconds to sleep + * @author Patches + * @since 3.0 */ - public static void sleep(long timeToSleepInMillis) { - try { - Thread.sleep(timeToSleepInMillis); - } catch (InterruptedException ie) { - // Do nothing - } - } + fun retrievedCurrentNetwork(currentNetwork: WifiInfo) } diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkInfoCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkInfoCallbacks.kt new file mode 100644 index 00000000..c62b0b41 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetCurrentNetworkInfoCallbacks.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +import android.net.NetworkInfo + +/** + * Callbacks for retrieving a device's current network. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.getCurrentNetworkInfo] + * + * @author Patches + * @since 3.0 + */ +interface GetCurrentNetworkInfoCallbacks : BaseCallback { + + /** + * Called when WiseFy has successfully retrieved the device's current network info. + * + * @see [NetworkInfo] + * + * @author Patches + * @since 3.0 + */ + fun retrievedCurrentNetworkInfo(currentNetworkDetails: NetworkInfo) +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.java deleted file mode 100644 index ec10a774..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -public interface GetFrequencyCallbacks { - void failureGettingFrequency(); - void getFrequencyWiseFyFailure(Integer wisefyReturnCode); - void retrievedFrequency(int frequency); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.kt new file mode 100644 index 00000000..1b2ed742 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetFrequencyCallbacks.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +/** + * Callbacks for retrieving the frequency of a network. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.getFrequency] + * + * @author Patches + * @since 3.0 + */ +interface GetFrequencyCallbacks : BaseCallback { + + /** + * Called when there is an issue retrieving the frequency of a network. + * + * i.e. Unable to retrieve current network or no current network + * + * @author Patches + * @since 3.0 + */ + fun failureGettingFrequency() + + /** + * Called when WiseFy has successfully retrieved the frequency of a network. + * + * @author Patches + * @since 3.0 + */ + fun retrievedFrequency(frequency: Int) +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetIPCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetIPCallbacks.kt new file mode 100644 index 00000000..cbfdde62 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetIPCallbacks.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +/** + * Callbacks for retrieving a device's IP. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.getIP] + * + * @author Patches + * @since 3.0 + */ +interface GetIPCallbacks : BaseCallback { + + /** + * Called when there is an issue retrieving the IP of a device. + * + * i.e. No current IP for the device, bad formatting, etc. + * + * @author Patches + * @since 3.0 + */ + fun failureRetrievingIP() + + /** + * Called when WiseFy has successfully retrieved the IP of a device. + * + * @author Patches + * @since 3.0 + */ + fun retrievedIP(ip: String) +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.java deleted file mode 100644 index c0181ec9..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -import android.net.wifi.ScanResult; -import java.util.List; - - -public interface GetNearbyAccessPointsCallbacks { - void getNearbyAccessPointsWiseFyFailure(Integer wisefyReturnCode); - void retrievedNearbyAccessPoints(List nearbyAccessPoints); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.kt new file mode 100644 index 00000000..cddac61f --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetNearbyAccessPointsCallbacks.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +import android.net.wifi.ScanResult + +/** + * Callbacks for retrieving a list of nearby access points. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.getNearbyAccessPoints] + * + * @author Patches + * @since 3.0 + */ +interface GetNearbyAccessPointsCallbacks : BaseCallback { + + /** + * Called when WiseFy has successfully retrieved a list of nearby access points. + * + * @see [ScanResult] + * + * @author Patches + * @since 3.0 + */ + fun retrievedNearbyAccessPoints(nearbyAccessPoints: List<@JvmSuppressWildcards ScanResult>) +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.java deleted file mode 100644 index 54740935..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -public interface GetRSSICallbacks { - void retrievedRSSI(Integer rssi); - void networkNotFoundToRetrieveRSSI(); - void getRSSIWiseFyFailure(Integer wisefyReturnCode); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.kt new file mode 100644 index 00000000..3b395f5b --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetRSSICallbacks.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +/** + * Callbacks for retrieving RSSI level of a nearby access point. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.getRSSI] + * + * @author Patches + * @since 3.0 + */ +interface GetRSSICallbacks : BaseCallback { + + /** + * Called when WiseFy has successfully retrieved the RSSI level of a network. + * + * @author Patches + * @since 3.0 + */ + fun retrievedRSSI(rssi: Int) + + /** + * Called when the network to retrieve the RSSI level of is not found + * in the list of nearby access points. + * + * @author Patches + * @since 3.0 + */ + fun networkNotFoundToRetrieveRSSI() +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.java deleted file mode 100644 index 0630561b..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -import android.net.wifi.WifiConfiguration; - - -public interface GetSavedNetworkCallbacks { - void getSavedNetworkWiseFyFailure(Integer wisefyReturnCode); - void savedNetworkNotFound(); - void retrievedSavedNetwork(WifiConfiguration savedNetwork); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.kt new file mode 100644 index 00000000..afd41bbe --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworkCallbacks.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +import android.net.wifi.WifiConfiguration + +/** + * Callbacks for retrieving a saved network on a device. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.getSavedNetwork] + * + * @author Patches + * @see 3.0 + */ +interface GetSavedNetworkCallbacks : BaseCallback { + + /** + * Called when the given network is not a saved configuration. + * + * @author Patches + * @since 3.0 + */ + fun savedNetworkNotFound() + + /** + * Called when WiseFy has successfully retrieved a matching saved network configuration. + * + * @see [WifiConfiguration] + * + * @author Patches + * @since 3.0 + */ + fun retrievedSavedNetwork(savedNetwork: WifiConfiguration) +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.java deleted file mode 100644 index 420f9c7a..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -import android.net.wifi.WifiConfiguration; -import java.util.List; - - -public interface GetSavedNetworksCallbacks { - void getSavedNetworksWiseFyFailure(Integer wisefyReturnCode); - void noSavedNetworksFound(); - void retrievedSavedNetworks(List savedNetworks); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.kt new file mode 100644 index 00000000..08fc133c --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/GetSavedNetworksCallbacks.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +import android.net.wifi.WifiConfiguration + +/** + * Callbacks for retrieving a list of saved networks on a device. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.getSavedNetworks] + * + * @author Patches + * @since 3.0 + */ +interface GetSavedNetworksCallbacks : BaseCallback { + + /** + * Called when there are no saved network configuration on the device. + * + * @author Patches + * @since 3.0 + */ + fun noSavedNetworksFound() + + /** + * Called when WiseFy has successfully retrieved a list of saved networks. + * + * @see [WifiConfiguration] + * + * @author Patches + * @since 3.0 + */ + fun retrievedSavedNetworks(savedNetworks: List<@JvmSuppressWildcards WifiConfiguration>) +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.java deleted file mode 100644 index f366d6b4..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -public interface RemoveNetworkCallbacks { - void failureRemovingNetwork(); - void networkNotFoundToRemove(); - void networkRemoved(); - void removeNetworkWiseFyFailure(Integer wisefyReturnCode); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.kt new file mode 100644 index 00000000..118f14f5 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/RemoveNetworkCallbacks.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +/** + * Callbacks for removing a saved network on a device. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.removeNetwork] + * + * @author Patches + * @since 3.0 + */ +interface RemoveNetworkCallbacks : BaseCallback { + + /** + * Called when there is an issue removing a saved network configuration with WifiManager. + * + * @author Patches + * @since 3.0 + */ + fun failureRemovingNetwork() + + /** + * Called when the network is not found in the save network configuration list. + * + * This is not necessarily an error as it may have never been stored, + * removed manually, or various other scenarios. + * + * @author Patches + * @since 3.0 + */ + fun networkNotFoundToRemove() + + /** + * Called when WiseFy has successfully removed a network from the + * list of saved network configurations. + * + * @author Patches + * @since 3.0 + */ + fun networkRemoved() +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.java deleted file mode 100644 index 59f90778..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -import android.net.wifi.ScanResult; - - -public interface SearchForAccessPointCallbacks { - void searchForAccessPointWiseFyFailure(Integer wisefyReturnCode); - void accessPointFound(ScanResult accessPoint); - void accessPointNotFound(); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.kt new file mode 100644 index 00000000..bc7dc590 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointCallbacks.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +import android.net.wifi.ScanResult + +/** + * Callbacks for finding a nearby access point on a device. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.searchForAccessPoint] + * + * @author Patches + * @since 3.0 + */ +interface SearchForAccessPointCallbacks : BaseCallback { + + /** + * Called when WiseFy has successfully found a matching access point. + * + * @see [ScanResult] + * + * @author Patches + * @since 3.0 + */ + fun accessPointFound(accessPoint: ScanResult) + + /** + * Called when WiseFy times out trying to find a matching access point. + * + * @author Patches + * @since 3.0 + */ + fun accessPointNotFound() +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.java deleted file mode 100644 index 406753eb..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -import android.net.wifi.ScanResult; -import java.util.List; - - -public interface SearchForAccessPointsCallbacks { - void searchForAccessPointsWiseFyFailure(Integer wisefyReturnCode); - void foundAccessPoints(List accessPoints); - void noAccessPointsFound(); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.kt new file mode 100644 index 00000000..c568643e --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForAccessPointsCallbacks.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +import android.net.wifi.ScanResult + +/** + * Callbacks for finding a list of nearby access points on a device. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.searchForAccessPoints] + * + * @author Patches + * @see 3.0 + */ +interface SearchForAccessPointsCallbacks : BaseCallback { + + /** + * Called when WiseFy has successfully found matching access points. + * + * @see ScanResult + * + * @author Patches + * @since 3.0 + */ + fun foundAccessPoints(accessPoints: List<@JvmSuppressWildcards ScanResult>) + + /** + * Called when WiseFy times out trying to find a matching access points. + * + * @author Patches + * @since 3.0 + */ + fun noAccessPointsFound() +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.java deleted file mode 100644 index 656e0775..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -public interface SearchForSSIDCallbacks { - void searchForSSIDWiseFyFailure(Integer wisefyReturnCode); - void ssidFound(String ssid); - void ssidNotFound(); -} \ No newline at end of file diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.kt new file mode 100644 index 00000000..c12cfb1c --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDCallbacks.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +/** + * Callbacks for finding a nearby SSID on a device. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.searchForSSID] + * + * @author Patches + * @since 3.0 + */ +interface SearchForSSIDCallbacks : BaseCallback { + + /** + * Called when WiseFy has successfully found an access point with a matching SSID. + * + * @author Patches + * @since 3.0 + */ + fun ssidFound(ssid: String) + + /** + * Called when WiseFy times out trying to find an access point with a matching SSID. + * + * @author Patches + * @since 3.0 + */ + fun ssidNotFound() +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.java b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.java deleted file mode 100644 index 545a12e0..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.callbacks; - - -import java.util.List; - - -public interface SearchForSSIDsCallbacks { - void searchForSSIDsWiseFyFailure(Integer wisefyReturnCode); - void retrievedSSIDs(List ssids); - void noSSIDsFound(); -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.kt b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.kt new file mode 100644 index 00000000..5ebc8430 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/callbacks/SearchForSSIDsCallbacks.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.callbacks + +/** + * Callbacks for finding a list of nearby SSIDs on a device. + * + * @see [BaseCallback] + * @see [com.isupatches.wisefy.WiseFy.searchForSSIDs] + * + * @author Patches + * @since 3.0 + */ +interface SearchForSSIDsCallbacks : BaseCallback { + + /** + * Called when WiseFy has successfully found access points with a matching SSID. + * + * @author Patches + * @since 3.0 + */ + fun retrievedSSIDs(ssids: List) + + /** + * Called when WiseFy times out trying to find access points with a matching SSID. + * + * @author Patches + * @since 3.0 + */ + fun noSSIDsFound() +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.java b/wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.java deleted file mode 100644 index 07127e47..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.constants; - - -public class Capabilities { - public static final String EAP = "EAP"; - public static final String PSK = "PSK"; - public static final String WEP = "WEP"; - public static final String WPA = "WPA"; - public static final String WPA2 = "WPA2"; -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.kt b/wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.kt new file mode 100644 index 00000000..a2b80116 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/constants/Capabilities.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("Capabilities") +package com.isupatches.wisefy.constants + +import android.support.annotation.StringDef + +/** + * Constant for EAP security capabilities. + * + * @author Patches + * @since 3.0 + */ +const val EAP: String = "EAP" + +/** + * Constant for PSK security capabilities. + * + * @author Patches + * @since 3.0 + */ +const val PSK: String = "PSK" + +/** + * Constant for WEP security capabilities. + * + * @author Patches + * @since 3.0 + */ +const val WEP: String = "WEP" + +/** + * Constant for WPA security capabilities. + * + * @author Patches + * @since 3.0 + */ +const val WPA: String = "WPA" + +/** + * Constant for WPA2 security capabilities. + * + * @author Patches + * @since 3.0 + */ +const val WPA2: String = "WPA2" + +/** + * Annotation to help avoid crazy strings when working with network security capabilities. + * + * @author Patches + * @since 3.0 + */ +@Retention(AnnotationRetention.SOURCE) +@StringDef(EAP, PSK, WEP, WPA, WPA2) +annotation class Capability diff --git a/wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.kt b/wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.kt new file mode 100644 index 00000000..f995de30 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/constants/NetworkTypes.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("NetworkTypes") +package com.isupatches.wisefy.constants + +import android.support.annotation.StringDef + +/** + * Constant for a mobile network. + * + * @author Patches + * @since 3.0 + */ +const val MOBILE: String = "MOBILE" + +/** + * Constant for a Wifi network. + * + * @author Patches + * @since 3.0 + */ +const val WIFI: String = "WIFI" + +/** + * Annotation to help avoid crazy strings when handling network types. + * + * @author Patches + * @since 3.0 + */ +@Retention(AnnotationRetention.SOURCE) +@StringDef(MOBILE, WIFI) +annotation class NetworkType diff --git a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyLock.java b/wisefy/src/main/java/com/isupatches/wisefy/constants/Symbols.kt similarity index 75% rename from wisefy/src/main/java/com/isupatches/wisefy/WiseFyLock.java rename to wisefy/src/main/java/com/isupatches/wisefy/constants/Symbols.kt index d795030d..1a123f49 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/WiseFyLock.java +++ b/wisefy/src/main/java/com/isupatches/wisefy/constants/Symbols.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017 Patches Klinefelter + * Copyright 2018 Patches Klinefelter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,15 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.isupatches.wisefy; +package com.isupatches.wisefy.constants /** - * A class used to synchronize logic + * Abstracted constant for a quote. * - * @see WiseFy#getWiseFyLock() - * - * @author Patches + * @author Patches + * @since 3.0 */ -class WiseFyLock { - -} +internal const val QUOTE = "\"" diff --git a/wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.java b/wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.java deleted file mode 100644 index b52857f0..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.constants; - - -public class WiseFyCodes { - public static final int MISSING_PARAMETER = -1000; - public static final int MISSING_PREREQUISITE = -1001; - public static final int NETWORK_ALREADY_CONFIGURED = -1002; -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.kt b/wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.kt new file mode 100644 index 00000000..4f09be0c --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/constants/WiseFyCodes.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("WiseFyCodes") +package com.isupatches.wisefy.constants + +import android.support.annotation.IntDef + +/** + * A constant that denotes a successful operation within WiseFy. + * + * @author Patches + * @since 3.0 + */ +const val DEFAULT_PRECHECK_RETURN_CODE: Int = 0 + +/** + * A constant that denotes a parameter was null or empty ("")/ length 0. + * + * @author Patches + * @since 3.0 + */ +const val MISSING_PARAMETER: Int = -1000 + +/** + * A constant that denotes that a network is already a saved configuration. + * + * @author Patches + * @since 3.0 + */ +const val NETWORK_ALREADY_CONFIGURED: Int = -1002 + +/** + * Interface to avoid magic numbers when handling internal WiseFy codes. + * + * @author Patches + * @since 3.0 + */ +@Retention(AnnotationRetention.SOURCE) +@IntDef( + DEFAULT_PRECHECK_RETURN_CODE, + MISSING_PARAMETER, + NETWORK_ALREADY_CONFIGURED +) +annotation class WiseFyCode diff --git a/wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLogger.kt b/wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLogger.kt new file mode 100644 index 00000000..5cab81b7 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLogger.kt @@ -0,0 +1,150 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.logging + +/** + * Logging helper class. + * + * @author Patches + * @since 3.0 + */ +@Suppress("SpreadOperator") +internal object WiseFyLogger { + + private var wisefyLoggerImplementation: WiseFyLoggerImplementation? = null + + /** + * To return if logging is enabled for the WiseFyLoggerImplementation. + * + * @return bool - If logging is enabled for the instance of WiseFy + * + * @see [ensureWiseFyLoggerImplementationExists] + * @see [WiseFyLoggerImplementation.isLoggingEnabled] + * + * @author Patches + * @since 3.0 + */ + fun isLoggingEnabled(): Boolean { + ensureWiseFyLoggerImplementationExists() + return wisefyLoggerImplementation?.isLoggingEnabled ?: false + } + + /** + * Creates and sets the WiseFyLoggerImplementation to use when logging. + * + * @param loggingEnabled - Whether logging should be enabled for the WiseFyLoggerImplementation + * + * @see [WiseFyLoggerImplementation] + * + * @author Patches + * @since 3.0 + */ + fun configureWiseFyLoggerImplementation(loggingEnabled: Boolean) { + wisefyLoggerImplementation = WiseFyLoggerImplementation(loggingEnabled) + } + + /** + * Logs a debug message. + * + * @param tag The tag for the log message + * @param message The message to log (can include placeholders) + * @param args The formatting arguments for the log message + * + * @see [ensureWiseFyLoggerImplementationExists] + * @see [WiseFyLoggerImplementation.debug] + * + * @author Patches + * @since 3.0 + */ + fun debug(tag: String, message: String, vararg args: Any) { + ensureWiseFyLoggerImplementationExists() + wisefyLoggerImplementation?.debug(tag, message, *args) + } + + /** + * Logs an error message. + * + * @param tag The tag for the log message + * @param message The message to log (can include placeholders) + * @param args The formatting arguments for the log message + * + * @see [ensureWiseFyLoggerImplementationExists] + * @see [WiseFyLoggerImplementation.error] + * + * @author Patches + * @since 3.0 + */ + fun error(tag: String, message: String, vararg args: Any) { + ensureWiseFyLoggerImplementationExists() + wisefyLoggerImplementation?.error(tag, message, *args) + } + + /** + * Logs an error message with a throwable. + * + * @param tag The tag for the log message + * @param throwable A throwable to log with the message + * @param message The message to log (can include placeholders) + * @param args The formatting arguments for the log message + * + * @see [ensureWiseFyLoggerImplementationExists] + * @see [WiseFyLoggerImplementation.error] + * + * @author Patches + * @since 3.0 + */ + fun error(tag: String, throwable: Throwable, message: String, vararg args: Any) { + ensureWiseFyLoggerImplementationExists() + wisefyLoggerImplementation?.error(tag, throwable, message, *args) + } + + /** + * Logs a warning message. + * + * @param tag The tag for the log message + * @param message The message to log (can include placeholders) + * @param args The formatting arguments for the log message + * + * @see [ensureWiseFyLoggerImplementationExists] + * @see [WiseFyLoggerImplementation.warn] + * + * @author Patches + * @since 3.0 + */ + fun warn(tag: String, message: String, vararg args: Any) { + ensureWiseFyLoggerImplementationExists() + wisefyLoggerImplementation?.warn(tag, message, *args) + } + + /* + * HELPERS + */ + + /** + * If a WiseFyLoggerImplementation is not already configured or set, it will create + * a new instance with the default value of false for logging enabled. + * + * @see [configureWiseFyLoggerImplementation] + * + * @author Patches + * @since 3.0 + */ + private fun ensureWiseFyLoggerImplementationExists() { + if (wisefyLoggerImplementation == null) { + configureWiseFyLoggerImplementation(false) + } + } +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLoggerImplementation.kt b/wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLoggerImplementation.kt new file mode 100644 index 00000000..021d1efc --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLoggerImplementation.kt @@ -0,0 +1,147 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.logging + +import android.util.Log +import java.util.Locale + +/** + * A class that implements the logging strategy desired for WiseFy. + * + * @see WiseFyLoggingStrategy + * + * @author Patches + * @since 3.0 + */ +@Suppress("SpreadOperator") +internal class WiseFyLoggerImplementation constructor( + internal val isLoggingEnabled: Boolean +) : WiseFyLoggingStrategy { + + companion object { + private const val MAX_TAG_LENGTH = 23 + } + + /** + * Logs a debug message. + * + * @param tag The tag for the log message + * @param message The message to log (can include placeholders) + * @param args The formatting arguments for the log message + * + * @see [isLoggable] + * @see [Log.d] + * + * @author Patches + * @since 3.0 + */ + override fun debug(tag: String, message: String, vararg args: Any) { + if (isLoggable(tag, Log.DEBUG)) { + Log.d(tag, message.format(Locale.US, *args)) + } + } + + /** + * Logs an error message. + * + * @param tag The tag for the log message + * @param message The message to log (can include placeholders) + * @param args The formatting arguments for the log message + * + * @see [isLoggable] + * @see[Log.e] + * + * @author Patches + * @since 3.0 + */ + override fun error(tag: String, message: String, vararg args: Any) { + if (isLoggable(tag, Log.ERROR)) { + Log.e(tag, message.format(Locale.US, *args)) + } + } + + /** + * Logs an error message with a throwable. + * + * @param tag The tag for the log message + * @param throwable A throwable to log with the message + * @param message The message to log (can include placeholders) + * @param args The formatting arguments for the log message + * + * @see [isLoggable] + * @see [Log.e] + * + * @author Patches + * @since 3.0 + */ + override fun error(tag: String, throwable: Throwable, message: String, vararg args: Any) { + if (isLoggable(tag, Log.ERROR)) { + Log.e(tag, message.format(Locale.US, *args), throwable) + } + } + + /** + * Logs a warning message. + * + * @param tag The tag for the log message + * @param message The message to log (can include placeholders) + * @param args The formatting arguments for the log message + * + * @see [isLoggable] + * @see [Log.w] + * + * @author Patches + * @since 3.0 + */ + override fun warn(tag: String, message: String, vararg args: Any) { + if (isLoggable(tag, Log.WARN)) { + Log.w(tag, message.format(Locale.US, *args)) + } + } + + /* + * HELPERS + */ + + /** + * Checks to see given a TAG, log level, and if logging is enabled if logging should occur. + * + * @param tag The tag to be used for the log + * @param level The level of logging (i.error Log.DEBUG, Log.WARN, Log.ERROR, etc) + * + * @return boolean - True if logging should occur based off level and other factors + * + * @see [isLoggingEnabled] + * @see [Log.isLoggable] + * @see [MAX_TAG_LENGTH] + * + * @author Patches + * @since 3.0 + */ + private fun isLoggable(tag: String, level: Int): Boolean { + val loggable: Boolean + var tagToUse = tag + if (isLoggingEnabled) { + loggable = true + } else { + if (tag.length > MAX_TAG_LENGTH) { + tagToUse = tag.substring(0, MAX_TAG_LENGTH - 1) + } + loggable = Log.isLoggable(tagToUse, level) + } + return loggable + } +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLoggingStrategy.kt b/wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLoggingStrategy.kt new file mode 100644 index 00000000..85b14b2d --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/logging/WiseFyLoggingStrategy.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.logging + +/** + * An interface for different logging options for implementation. + * + * @author Patches + * @since 3.0 + */ +internal interface WiseFyLoggingStrategy { + + fun debug(tag: String, message: String, vararg args: Any) + + fun warn(tag: String, message: String, vararg args: Any) + + fun error(tag: String, message: String, vararg args: Any) + + fun error(tag: String, throwable: Throwable, message: String, vararg args: Any) +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/threads/WiseFyHandlerThread.java b/wisefy/src/main/java/com/isupatches/wisefy/threads/WiseFyHandlerThread.java deleted file mode 100644 index 18144257..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/threads/WiseFyHandlerThread.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.threads; - - -import android.os.HandlerThread; -import android.util.Log; -import com.isupatches.wisefy.WiseFy; -import com.isupatches.wisefy.util.LogUtil; - - -/** - * A Thread to use for all WiseFy background processing - * - * *NOTE* Must be cleaned!! {@link WiseFy#dump()} - * - * @author Patches - */ -public class WiseFyHandlerThread extends HandlerThread { - - public static final String TAG = WiseFyHandlerThread.class.getSimpleName(); - - private boolean mLoggingEnabled; - - public WiseFyHandlerThread(String name, boolean loggingEnabled) { - super(name); - this.mLoggingEnabled = loggingEnabled; - } - - @Override - public void start() { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mLoggingEnabled)) { - Log.d(TAG, "start() called on WiseFyHandlerThread"); - } - super.start(); - } - - @Override - public boolean quit() { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mLoggingEnabled)) { - Log.d(TAG, "quit() called on WiseFyHandlerThread"); - } - return super.quit(); - } - - @Override - public boolean quitSafely() { - if (LogUtil.isLoggable(TAG, Log.DEBUG, mLoggingEnabled)) { - Log.d(TAG, "quitSafely() called on WiseFyHandlerThread"); - } - return super.quitSafely(); - } -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/annotations/Async.java b/wisefy/src/main/java/com/isupatches/wisefy/threads/WiseFyHandlerThread.kt similarity index 56% rename from wisefy/src/main/java/com/isupatches/wisefy/annotations/Async.java rename to wisefy/src/main/java/com/isupatches/wisefy/threads/WiseFyHandlerThread.kt index 39b2b939..bef9aad8 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/annotations/Async.java +++ b/wisefy/src/main/java/com/isupatches/wisefy/threads/WiseFyHandlerThread.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017 Patches Klinefelter + * Copyright 2018 Patches Klinefelter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,22 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.isupatches.wisefy.annotations; +package com.isupatches.wisefy.threads +import android.os.HandlerThread -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Documented -@Target(ElementType.METHOD) -@Inherited -@Retention(RetentionPolicy.RUNTIME) -public @interface Async { +/** + * A Thread to use for all WiseFy background processing. + * + * *NOTE* Must be cleaned!! [com.isupatches.wisefy.WiseFy.dump] + * + * @author Patches + * @since 3.0 + */ +class WiseFyHandlerThread(name: String) : HandlerThread(name) { + companion object { + internal val TAG = WiseFyHandlerThread::class.java.simpleName + } } - diff --git a/wisefy/src/main/java/com/isupatches/wisefy/util/LogUtil.java b/wisefy/src/main/java/com/isupatches/wisefy/util/LogUtil.java deleted file mode 100644 index bf0a9ed7..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/util/LogUtil.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.util; - - -import android.util.Log; -import com.isupatches.wisefy.annotations.Internal; - - -/** - * Logging helper class - * - * @author Patches - */ -@Internal -public class LogUtil { - - /** - * Checks to see given a TAG, log level, and if logging is enabled if logging should occur - * - * @param tag The tag to be used for the log - * @param level The level of logging (i.e Log.DEBUG, Log.WARN, Log.ERROR, etc) - * @param loggingEnabled If the instances of WiseFy has logging set to always be enabled - * - * @see Log - * - * @return boolean - True if logging should occur based off level and other factors - */ - public static boolean isLoggable(String tag, int level, boolean loggingEnabled) { - boolean isLoggable; - if(loggingEnabled) { - isLoggable = true; - } else { - if (tag.length() > 23) { - tag = tag.substring(0, 22); - } - isLoggable = Log.isLoggable(tag, level); - } - return isLoggable; - } -} \ No newline at end of file diff --git a/wisefy/src/main/java/com/isupatches/wisefy/util/ManagerUtil.java b/wisefy/src/main/java/com/isupatches/wisefy/util/ManagerUtil.java deleted file mode 100644 index cd8d9492..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/util/ManagerUtil.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.util; - - -import android.content.Context; -import android.net.ConnectivityManager; -import android.net.wifi.WifiManager; -import com.isupatches.wisefy.annotations.Internal; - - -/** - * Manager helper class - * - * @author Patches - */ -@Internal -public class ManagerUtil { - - private static final ManagerUtil MANAGER_UTIL = new ManagerUtil(); - - /** - * Private constructor with no setup - */ - private ManagerUtil() { - } - - /** - * @return instance of ManagerUtil - */ - public static ManagerUtil getInstance() { - return MANAGER_UTIL; - } - - /** - * To get a Connectivity manger instance from an activity's context. - * - * @param context The context to use to retrieve a connectivity manager via getSystemService - * - * @see ConnectivityManager - * - * @return ConnectivityManager|null - */ - public ConnectivityManager getConnectivityManager(Context context) { - if (context != null) { - return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - } - return null; - } - - /** - * To get a WiFi manger instance from an activity's context. - * - * @param context The context to use to retrieve a wifi manager via getSystemService - * - * @see WifiManager - * - * @return WifiManager|null - */ - public WifiManager getWiFiManager(Context context) { - if (context != null) { - return (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); - } - return null; - } -} \ No newline at end of file diff --git a/wisefy/src/main/java/com/isupatches/wisefy/util/SSIDUtil.java b/wisefy/src/main/java/com/isupatches/wisefy/util/SSIDUtil.java deleted file mode 100644 index 179548b7..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/util/SSIDUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.util; - - -import android.os.Build; -import com.isupatches.wisefy.annotations.Internal; - - -/** - * A helper class to manipulate the string value for SSIDs - * - * @author Patches - */ -@Internal -class SSIDUtil { - - private static final SSIDUtil SSID_UTIL = new SSIDUtil(); - - /** - * Private constructor with no setup - */ - private SSIDUtil() { - } - - /** - * @return instance of SSIDUtil - */ - static SSIDUtil getInstance() { - return SSID_UTIL; - } - - /** - * Used internally to convert an SSID into a format for KitKat and below if needed - * - * @param ssid The SSID to alter - * - * @return String - The converted SSID value - */ - String convertSSIDForConfig(String ssid) { - // On devices with version Kitkat and below, We need to send SSID name - // with double quotes. On devices with version Lollipop, We need to send - // SSID name without double quotes - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - return ssid; - } else { - return "\"" + ssid + "\""; - } - } -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/util/WifiConfigurationUtil.java b/wisefy/src/main/java/com/isupatches/wisefy/util/WifiConfigurationUtil.java deleted file mode 100644 index 31dff6cc..00000000 --- a/wisefy/src/main/java/com/isupatches/wisefy/util/WifiConfigurationUtil.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2017 Patches Klinefelter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.isupatches.wisefy.util; - - -import android.net.wifi.WifiConfiguration; -import com.isupatches.wisefy.annotations.Internal; - - -/** - * A helper class to generate WifiConfigurations - * - * @author Patches - */ -@Internal -public class WifiConfigurationUtil { - - private static final WifiConfigurationUtil WIFI_CONFIGURATION_UTIL = new WifiConfigurationUtil(); - - private SSIDUtil mSSIDUtil = SSIDUtil.getInstance(); - - /** - * Private constructor with no setup - */ - private WifiConfigurationUtil() { - } - - /** - * @return instance of WifiConfigurationUtil - */ - public static WifiConfigurationUtil getInstance() { - return WIFI_CONFIGURATION_UTIL; - } - - /** - * To generate a configuration for an open network - * - * @param ssid The ssid for the open network's configuration - * - * @return WifiConfiguration - The open network configuration - */ - public WifiConfiguration generateOpenNetworkConfiguration(String ssid) { - WifiConfiguration wifiConfiguration = new WifiConfiguration(); - wifiConfiguration.SSID = mSSIDUtil.convertSSIDForConfig(ssid); - wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); - wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN); - wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA); - wifiConfiguration.allowedAuthAlgorithms.clear(); - wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); - wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); - wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); - wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); - wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); - wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); - return wifiConfiguration; - } - - /** - * To generate a configuration for a WEP network - * - * @param ssid The ssid for the WEP network's configuration - * @param password The password for the WEP network's configuration - * - * @return WifiConfiguration - The WEP network configuration - */ - public WifiConfiguration generateWEPNetworkConfiguration(String ssid, String password) { - WifiConfiguration wifiConfiguration = new WifiConfiguration(); - wifiConfiguration.SSID = mSSIDUtil.convertSSIDForConfig(ssid); - wifiConfiguration.wepKeys[0] = "\"" + password + "\""; - wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); - wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN); - wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA); - wifiConfiguration.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); - wifiConfiguration.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); - wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); - wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); - wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); - wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); - return wifiConfiguration; - } - - /** - * To generate a configuration for a WPA2 network - * - * @param ssid The ssid for the WPA2 network's configuration - * @param password The password for the WPA2 network's configuration - * - * @return WifiConfiguration - The WPA2 network configuration - */ - public WifiConfiguration generateWPA2NetworkConfiguration(String ssid, String password) { - WifiConfiguration wifiConfiguration = new WifiConfiguration(); - wifiConfiguration.SSID = mSSIDUtil.convertSSIDForConfig(ssid); - wifiConfiguration.preSharedKey = "\"" + password + "\""; - wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN); - wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); - wifiConfiguration.status = WifiConfiguration.Status.ENABLED; - wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); - wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); - wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); - wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); - wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN); - wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA); - - wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); - wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); - return wifiConfiguration; - } -} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/utils/SleepUtil.kt b/wisefy/src/main/java/com/isupatches/wisefy/utils/SleepUtil.kt new file mode 100644 index 00000000..53f0bdeb --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/utils/SleepUtil.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.utils + +private const val BASE_DELAY = 1000 + +/** + * To sleep the calling thread for a set amount of time. + * + * @see [BASE_DELAY] + * @see [sleep] + * + * @author Patches + * @since 3.0 + */ +internal fun rest() { + sleep(BASE_DELAY.toLong()) +} + +/** + * Used to wait for a given amount of time (in milliseconds). + * + * @param timeToSleepInMillis The number of milliseconds to sleep + * + * @author Patches + * @since 3.0 + */ +private fun sleep(timeToSleepInMillis: Long) { + try { + Thread.sleep(timeToSleepInMillis) + } catch (ie: InterruptedException) { + // Do nothing + } +} diff --git a/wisefy/src/main/java/com/isupatches/wisefy/annotations/CallingThread.java b/wisefy/src/main/java/com/isupatches/wisefy/utils/StringUtil.kt similarity index 54% rename from wisefy/src/main/java/com/isupatches/wisefy/annotations/CallingThread.java rename to wisefy/src/main/java/com/isupatches/wisefy/utils/StringUtil.kt index fac6eaa4..40fde76c 100644 --- a/wisefy/src/main/java/com/isupatches/wisefy/annotations/CallingThread.java +++ b/wisefy/src/main/java/com/isupatches/wisefy/utils/StringUtil.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017 Patches Klinefelter + * Copyright 2018 Patches Klinefelter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,21 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.isupatches.wisefy.annotations; +package com.isupatches.wisefy.utils +import com.isupatches.wisefy.constants.QUOTE +import java.util.Locale -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Documented -@Target(ElementType.METHOD) -@Inherited -@Retention(RetentionPolicy.RUNTIME) -public @interface CallingThread { - -} +/** + * Used internally to convert an SSID into an acceptable format to create a WifiConfiguration. + * + * @param ssid The SSID to format + * + * @return String - The formatted SSID value + * + * @author Patches + * @since 3.0 + */ +internal fun convertSSIDForConfig(ssid: String): String = "%s%s%s".format(Locale.US, QUOTE, ssid, QUOTE) diff --git a/wisefy/src/main/java/com/isupatches/wisefy/utils/WifiConfigurationUtil.kt b/wisefy/src/main/java/com/isupatches/wisefy/utils/WifiConfigurationUtil.kt new file mode 100644 index 00000000..6f34c734 --- /dev/null +++ b/wisefy/src/main/java/com/isupatches/wisefy/utils/WifiConfigurationUtil.kt @@ -0,0 +1,112 @@ +/* + * Copyright 2018 Patches Klinefelter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.isupatches.wisefy.utils + +import android.net.wifi.WifiConfiguration + +import com.isupatches.wisefy.constants.QUOTE + +/** + * To generate a configuration for an open network. + * + * @param ssid The ssid for the open network's configuration + * + * @return WifiConfiguration - The open network configuration + * + * @see [com.isupatches.wisefy.WiseFy.addOpenNetwork] + * @see [WifiConfiguration] + * + * @author Patches + * @since 3.0 + */ +internal fun generateOpenNetworkConfiguration(ssid: String): WifiConfiguration { + val wifiConfiguration = WifiConfiguration() + wifiConfiguration.SSID = convertSSIDForConfig(ssid) + wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE) + wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN) + wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA) + wifiConfiguration.allowedAuthAlgorithms.clear() + wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP) + wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP) + wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40) + wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104) + wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP) + wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP) + return wifiConfiguration +} + +/** + * To generate a configuration for a WEP network. + * + * @param ssid The ssid for the WEP network's configuration + * @param password The password for the WEP network's configuration + * + * @return WifiConfiguration - The WEP network configuration + * + * @see [com.isupatches.wisefy.WiseFy.addWEPNetwork] + * @see [WifiConfiguration] + * + * @author Patches + * @since 3.0 + */ +internal fun generateWEPNetworkConfiguration(ssid: String, password: String): WifiConfiguration { + val wifiConfiguration = WifiConfiguration() + wifiConfiguration.SSID = convertSSIDForConfig(ssid) + wifiConfiguration.wepKeys[0] = QUOTE + password + QUOTE + wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE) + wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN) + wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA) + wifiConfiguration.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN) + wifiConfiguration.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED) + wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP) + wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP) + wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40) + wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104) + return wifiConfiguration +} + +/** + * To generate a configuration for a WPA2 network. + * + * @param ssid The ssid for the WPA2 network's configuration + * @param password The password for the WPA2 network's configuration + * + * @return WifiConfiguration - The WPA2 network configuration + * + * @see [com.isupatches.wisefy.WiseFy.addWPA2Network] + * @see [WifiConfiguration] + * + * @author Patches + * @since 3.0 + */ +internal fun generateWPA2NetworkConfiguration(ssid: String, password: String): WifiConfiguration { + val wifiConfiguration = WifiConfiguration() + wifiConfiguration.SSID = convertSSIDForConfig(ssid) + wifiConfiguration.preSharedKey = QUOTE + password + QUOTE + wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN) + wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK) + wifiConfiguration.status = WifiConfiguration.Status.ENABLED + wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP) + wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP) + wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP) + wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP) + wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN) + wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA) + + wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP) + wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP) + return wifiConfiguration +} diff --git a/wisefy/src/main/res/values/colors.xml b/wisefy/src/main/res/values/colors.xml deleted file mode 100644 index 045e125f..00000000 --- a/wisefy/src/main/res/values/colors.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/wisefy/src/main/res/values/strings.xml b/wisefy/src/main/res/values/strings.xml deleted file mode 100644 index 045e125f..00000000 --- a/wisefy/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/wisefy/src/test/java/com/isupatches/wisefy/main/PublicApiVisibilityTests.kt b/wisefy/src/test/java/com/isupatches/wisefy/main/PublicApiVisibilityTests.kt new file mode 100644 index 00000000..eef79203 --- /dev/null +++ b/wisefy/src/test/java/com/isupatches/wisefy/main/PublicApiVisibilityTests.kt @@ -0,0 +1,553 @@ +package com.isupatches.wisefy.main + +import com.isupatches.wisefy.WiseFy.Companion.WIFI_MANAGER_FAILURE +import org.junit.Assert.assertEquals + +import org.mockito.ArgumentMatchers.any +import org.mockito.ArgumentMatchers.anyBoolean +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.ArgumentMatchers.anyString +import org.mockito.Mockito.mock +import org.mockito.Mockito.verify + +import android.net.wifi.ScanResult +import android.net.wifi.WifiConfiguration +import android.net.wifi.WifiInfo +import com.isupatches.wisefy.OPEN_NETWORK_SSID +import com.isupatches.wisefy.TEST_DELAY +import com.isupatches.wisefy.TEST_NUMBER_OF_BARS +import com.isupatches.wisefy.TEST_RSSI_LEVEL +import com.isupatches.wisefy.TEST_RSSI_LEVEL_HIGH +import com.isupatches.wisefy.TEST_RSSI_LEVEL_LOW +import com.isupatches.wisefy.TEST_SSID +import com.isupatches.wisefy.WEP_NETWORK_PASSWORD +import com.isupatches.wisefy.WEP_NETWORK_SSID +import com.isupatches.wisefy.WPA2_NETWORK_PASSWORD +import com.isupatches.wisefy.WPA2_NETWORK_SSID + +import com.isupatches.wisefy.WiseFyPublicApi +import com.isupatches.wisefy.callbacks.AddNetworkCallbacks +import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks +import com.isupatches.wisefy.callbacks.DisableWifiCallbacks +import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks +import com.isupatches.wisefy.callbacks.EnableWifiCallbacks +import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks +import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks +import com.isupatches.wisefy.callbacks.GetIPCallbacks +import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks +import com.isupatches.wisefy.callbacks.GetRSSICallbacks +import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks +import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks +import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks +import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks +import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks +import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks +import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks + +import org.junit.Test + +/** + * Used to test the visibility of the public API. + * + * @author Patches + */ +@Suppress("LargeClass","UndocumentedPublicFunction") +class PublicApiVisibilityTests { + + private val wisefy = mock(WiseFyPublicApi::class.java) + + private val savedNetworksCallbacks = MyGetSavedNetworksCallbacks() + + @Test fun addOpenNetwork_apis() { + wisefy.addOpenNetwork(OPEN_NETWORK_SSID) + verify(wisefy).addOpenNetwork(anyString()) + wisefy.addOpenNetwork(OPEN_NETWORK_SSID, object : AddNetworkCallbacks { + override fun failureAddingNetwork(wifiManagerReturn: Int) { + + } + + override fun networkAdded(newNetworkId: Int, networkConfig: WifiConfiguration) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + }) + verify(wisefy).addOpenNetwork(anyString(), any(AddNetworkCallbacks::class.java)) + } + + @Test fun addWEPNetwork_apis() { + wisefy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD) + verify(wisefy).addWEPNetwork(anyString(), anyString()) + wisefy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, object : AddNetworkCallbacks { + override fun failureAddingNetwork(wifiManagerReturn: Int) { + + } + + override fun networkAdded(newNetworkId: Int, networkConfig: WifiConfiguration) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + }) + verify(wisefy).addWEPNetwork(anyString(), anyString(), any(AddNetworkCallbacks::class.java)) + } + + @Test fun addWPA2Network_apis() { + wisefy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD) + verify(wisefy).addWPA2Network(anyString(), anyString()) + wisefy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD, object : AddNetworkCallbacks { + override fun failureAddingNetwork(wifiManagerReturn: Int) { + + } + + override fun networkAdded(newNetworkId: Int, networkConfig: WifiConfiguration) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + }) + verify(wisefy).addWPA2Network(anyString(), anyString(), any(AddNetworkCallbacks::class.java)) + } + + @Test fun compareSignalLevel_api() { + wisefy.compareSignalLevel(TEST_RSSI_LEVEL_LOW, TEST_RSSI_LEVEL_HIGH) + verify(wisefy).compareSignalLevel(anyInt(), anyInt()) + } + + @Test fun calculateBars_api() { + wisefy.calculateBars(TEST_RSSI_LEVEL, TEST_NUMBER_OF_BARS) + verify(wisefy).calculateBars(anyInt(), anyInt()) + } + + @Test fun connectToNetwork_apis() { + wisefy.connectToNetwork(TEST_SSID, TEST_DELAY) + verify(wisefy).connectToNetwork(anyString(), anyInt()) + wisefy.connectToNetwork(TEST_SSID, TEST_DELAY, object : ConnectToNetworkCallbacks { + override fun connectedToNetwork() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun failureConnectingToNetwork() { + + } + + override fun networkNotFoundToConnectTo() { + + } + }) + verify(wisefy).connectToNetwork(anyString(), anyInt(), any(ConnectToNetworkCallbacks::class.java)) + } + + @Test fun disableWifi_apis() { + wisefy.disableWifi() + verify(wisefy).disableWifi() + wisefy.disableWifi(object : DisableWifiCallbacks { + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun failureDisablingWifi() { + + } + + override fun wifiDisabled() { + + } + }) + verify(wisefy).disableWifi(any(DisableWifiCallbacks::class.java)) + } + + @Test fun disconnectFromCurrentNetwork_apis() { + wisefy.disconnectFromCurrentNetwork() + verify(wisefy).disconnectFromCurrentNetwork() + wisefy.disconnectFromCurrentNetwork(object : DisconnectFromCurrentNetworkCallbacks { + override fun disconnectedFromCurrentNetwork() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun failureDisconnectingFromCurrentNetwork() { + + } + }) + verify(wisefy).disconnectFromCurrentNetwork(any(DisconnectFromCurrentNetworkCallbacks::class.java)) + } + + @Test fun enableWifi_apis() { + wisefy.enableWifi() + verify(wisefy).enableWifi() + wisefy.enableWifi(object : EnableWifiCallbacks { + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun failureEnablingWifi() { + + } + + override fun wifiEnabled() { + + } + }) + verify(wisefy).enableWifi(any(EnableWifiCallbacks::class.java)) + } + + @Test fun getCurrentNetwork_apis() { + wisefy.getCurrentNetwork() + verify(wisefy).getCurrentNetwork() + wisefy.getCurrentNetwork(object : GetCurrentNetworkCallbacks { + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun retrievedCurrentNetwork(currentNetwork: WifiInfo) { + + } + }) + verify(wisefy).getCurrentNetwork(any(GetCurrentNetworkCallbacks::class.java)) + } + + @Test fun getFrequency_apis() { + wisefy.getFrequency() + verify(wisefy).getFrequency() + wisefy.getFrequency(object : GetFrequencyCallbacks { + override fun failureGettingFrequency() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun retrievedFrequency(frequency: Int) { + + } + }) + verify(wisefy).getFrequency(any(GetFrequencyCallbacks::class.java)) + + wisefy.getFrequency(mock(WifiInfo::class.java)) + verify(wisefy).getFrequency(any(WifiInfo::class.java)) + wisefy.getFrequency(mock(WifiInfo::class.java), object : GetFrequencyCallbacks { + override fun failureGettingFrequency() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun retrievedFrequency(frequency: Int) { + + } + }) + verify(wisefy).getFrequency(any(WifiInfo::class.java), any(GetFrequencyCallbacks::class.java)) + } + + @Test fun getIP_apis() { + wisefy.getIP() + verify(wisefy).getIP() + wisefy.getIP(object : GetIPCallbacks { + override fun failureRetrievingIP() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun retrievedIP(ip: String) { + + } + }) + verify(wisefy).getIP(any(GetIPCallbacks::class.java)) + } + + + @Test fun getNearbyAccessPoints_apis() { + wisefy.getNearbyAccessPoints(true) + verify(wisefy).getNearbyAccessPoints(anyBoolean()) + wisefy.getNearbyAccessPoints(true, object : GetNearbyAccessPointsCallbacks { + override fun retrievedNearbyAccessPoints(nearbyAccessPoints: List) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + }) + verify(wisefy).getNearbyAccessPoints(anyBoolean(), any(GetNearbyAccessPointsCallbacks::class.java)) + } + + @Test fun getRSSI_apis() { + wisefy.getRSSI(TEST_SSID, true, TEST_DELAY) + verify(wisefy).getRSSI(anyString(), anyBoolean(), anyInt()) + wisefy.getRSSI(TEST_SSID, true, TEST_DELAY, object : GetRSSICallbacks { + override fun retrievedRSSI(rssi: Int) { + + } + + override fun networkNotFoundToRetrieveRSSI() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + }) + verify(wisefy).getRSSI(anyString(), anyBoolean(), anyInt(), any(GetRSSICallbacks::class.java)) + } + + @Test fun getSavedNetwork_apis() { + wisefy.getSavedNetwork(TEST_SSID) + verify(wisefy).getSavedNetwork(anyString()) + wisefy.getSavedNetwork(TEST_SSID, object : GetSavedNetworkCallbacks { + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun savedNetworkNotFound() { + + } + + override fun retrievedSavedNetwork(savedNetwork: WifiConfiguration) { + + } + }) + verify(wisefy).getSavedNetwork(anyString(), any(GetSavedNetworkCallbacks::class.java)) + } + + @Test fun getSavedNetworks_apis() { + wisefy.getSavedNetworks() + verify(wisefy).getSavedNetworks() + wisefy.getSavedNetworks(savedNetworksCallbacks) + verify(wisefy).getSavedNetworks(any(GetSavedNetworksCallbacks::class.java)) + + wisefy.getSavedNetworks(TEST_SSID) + verify(wisefy).getSavedNetworks(anyString()) + wisefy.getSavedNetworks(TEST_SSID, savedNetworksCallbacks) + verify(wisefy).getSavedNetworks(anyString(), any(GetSavedNetworksCallbacks::class.java)) + } + + @Test fun getWiseFyLock_api() { + wisefy.getWiseFyLock() + verify(wisefy).getWiseFyLock() + } + + @Test fun isDeviceConnectedToMobileNetwork_apis() { + wisefy.isDeviceConnectedToMobileNetwork() + verify(wisefy).isDeviceConnectedToMobileNetwork() + } + + @Test fun isDeviceConnectedToMobileOrWifiNetwork_apis() { + wisefy.isDeviceConnectedToMobileOrWifiNetwork() + verify(wisefy).isDeviceConnectedToMobileOrWifiNetwork() + } + + @Test fun isDeviceConnectedToSSID_apis() { + wisefy.isDeviceConnectedToSSID(TEST_SSID) + verify(wisefy).isDeviceConnectedToSSID(anyString()) + } + + @Test fun isDeviceConnectedToWifiNetwork_apis() { + wisefy.isDeviceConnectedToWifiNetwork() + verify(wisefy).isDeviceConnectedToWifiNetwork() + } + + @Test fun isDeviceRoaming_apis() { + wisefy.isDeviceRoaming() + verify(wisefy).isDeviceRoaming() + } + + @Test fun isLoggingEnabled_api() { + wisefy.isLoggingEnabled() + verify(wisefy).isLoggingEnabled() + } + + @Test fun isNetwork5gHz_apis() { + wisefy.isNetwork5gHz() + verify(wisefy).isNetwork5gHz() + + wisefy.isNetwork5gHz(mock(WifiInfo::class.java)) + verify(wisefy).isNetwork5gHz(any(WifiInfo::class.java)) + } + + @Test fun isNetworkEAP_api() { + wisefy.isNetworkEAP(mock(ScanResult::class.java)) + verify(wisefy).isNetworkEAP(any(ScanResult::class.java)) + } + + @Test fun isNetworkPSK_api() { + wisefy.isNetworkPSK(mock(ScanResult::class.java)) + verify(wisefy).isNetworkPSK(any(ScanResult::class.java)) + } + + @Test fun isNetworkSaved_api() { + wisefy.isNetworkSaved(TEST_SSID) + verify(wisefy).isNetworkSaved(anyString()) + } + + @Test fun isNetworkSecure_api() { + wisefy.isNetworkSecure(mock(ScanResult::class.java)) + verify(wisefy).isNetworkSecure(any(ScanResult::class.java)) + } + + @Test fun isNetworkWEP_api() { + wisefy.isNetworkWEP(mock(ScanResult::class.java)) + verify(wisefy).isNetworkWEP(any(ScanResult::class.java)) + } + + @Test + fun isNetworkWPA_api() { + wisefy.isNetworkWPA(mock(ScanResult::class.java)) + verify(wisefy).isNetworkWPA(any(ScanResult::class.java)) + } + + @Test fun isNetworkWPA2_api() { + wisefy.isNetworkWPA2(mock(ScanResult::class.java)) + verify(wisefy).isNetworkWPA2(any(ScanResult::class.java)) + } + + @Test fun isWifiEnabled_api() { + wisefy.isWifiEnabled() + verify(wisefy).isWifiEnabled() + } + + @Test fun removeNetwork_api() { + wisefy.removeNetwork(TEST_SSID) + verify(wisefy).removeNetwork(anyString()) + + wisefy.removeNetwork(TEST_SSID, object : RemoveNetworkCallbacks { + override fun failureRemovingNetwork() { + + } + + override fun networkNotFoundToRemove() { + + } + + override fun networkRemoved() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + }) + verify(wisefy).removeNetwork(anyString(), any(RemoveNetworkCallbacks::class.java)) + } + + + @Test fun searchForAccessPoint_api() { + wisefy.searchForAccessPoint(TEST_SSID, TEST_DELAY, true) + verify(wisefy).searchForAccessPoint(anyString(), anyInt(), anyBoolean()) + + wisefy.searchForAccessPoint(TEST_SSID, TEST_DELAY, true, object : SearchForAccessPointCallbacks { + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun accessPointFound(accessPoint: ScanResult) { + + } + + override fun accessPointNotFound() { + + } + }) + verify(wisefy).searchForAccessPoint(anyString(), anyInt(), anyBoolean(), any(SearchForAccessPointCallbacks::class.java)) + } + + @Test fun searchForAccessPoints_api() { + wisefy.searchForAccessPoints(TEST_SSID, true) + verify(wisefy).searchForAccessPoints(anyString(), anyBoolean()) + + wisefy.searchForAccessPoints(TEST_SSID, true, object : SearchForAccessPointsCallbacks { + override fun foundAccessPoints(accessPoints: List) { + + } + + override fun noAccessPointsFound() { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + }) + verify(wisefy).searchForAccessPoints(anyString(), anyBoolean(), any(SearchForAccessPointsCallbacks::class.java)) + } + + @Test fun searchForSSID_api() { + wisefy.searchForSSID(TEST_SSID, TEST_DELAY) + verify(wisefy).searchForSSID(anyString(), anyInt()) + + wisefy.searchForSSID(TEST_SSID, TEST_DELAY, object : SearchForSSIDCallbacks { + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun ssidFound(ssid: String) { + + } + + override fun ssidNotFound() { + + } + }) + verify(wisefy).searchForSSID(anyString(), anyInt(), any(SearchForSSIDCallbacks::class.java)) + } + + @Test fun searchForSSIDs_api() { + wisefy.searchForSSIDs(TEST_SSID) + verify(wisefy).searchForSSIDs(anyString()) + + wisefy.searchForSSIDs(TEST_SSID, object : SearchForSSIDsCallbacks { + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + + override fun retrievedSSIDs(ssids: List) { + + } + + override fun noSSIDsFound() { + + } + }) + verify(wisefy).searchForSSIDs(anyString(), any(SearchForSSIDsCallbacks::class.java)) + } + + @Test fun wifiManagerFailure_value() { + assertEquals(WIFI_MANAGER_FAILURE.toLong(), -1) + } + + private class MyGetSavedNetworksCallbacks : GetSavedNetworksCallbacks { + override fun noSavedNetworksFound() { + + } + + override fun retrievedSavedNetworks(savedNetworks: List) { + + } + + override fun wisefyFailure(wisefyFailureCode: Int) { + + } + } +} diff --git a/wisefy/src/test/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java b/wisefy/src/test/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java deleted file mode 100644 index 3c90a219..00000000 --- a/wisefy/src/test/java/com/isupatches/wisefy/test/PublicApiVisibilityTests.java +++ /dev/null @@ -1,616 +0,0 @@ -package com.isupatches.wisefy.test; - - -import android.net.wifi.ScanResult; -import android.net.wifi.WifiConfiguration; -import android.net.wifi.WifiInfo; -import com.isupatches.wisefy.WiseFy; -import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks; -import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks; -import com.isupatches.wisefy.callbacks.AddWPA2NetworkCallbacks; -import com.isupatches.wisefy.callbacks.ConnectToNetworkCallbacks; -import com.isupatches.wisefy.callbacks.DisableWifiCallbacks; -import com.isupatches.wisefy.callbacks.DisconnectFromCurrentNetworkCallbacks; -import com.isupatches.wisefy.callbacks.EnableWifiCallbacks; -import com.isupatches.wisefy.callbacks.GetCurrentNetworkCallbacks; -import com.isupatches.wisefy.callbacks.GetFrequencyCallbacks; -import com.isupatches.wisefy.callbacks.GetNearbyAccessPointsCallbacks; -import com.isupatches.wisefy.callbacks.GetRSSICallbacks; -import com.isupatches.wisefy.callbacks.GetSavedNetworkCallbacks; -import com.isupatches.wisefy.callbacks.GetSavedNetworksCallbacks; -import com.isupatches.wisefy.callbacks.RemoveNetworkCallbacks; -import com.isupatches.wisefy.callbacks.SearchForAccessPointCallbacks; -import com.isupatches.wisefy.callbacks.SearchForAccessPointsCallbacks; -import com.isupatches.wisefy.callbacks.SearchForSSIDCallbacks; -import com.isupatches.wisefy.callbacks.SearchForSSIDsCallbacks; -import org.junit.Before; -import org.junit.Test; -import java.util.List; -import static junit.framework.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - - -public class PublicApiVisibilityTests { - - private WiseFy mWiseFy; - - @Before - public void setUp() { - mWiseFy = mock(WiseFy.class); - } - - @Test - public void addOpenNetwork_apis() { - mWiseFy.addOpenNetwork("TEST"); - verify(mWiseFy).addOpenNetwork(anyString()); - mWiseFy.addOpenNetwork("TEST", new AddOpenNetworkCallbacks() { - @Override - public void addOpenNetworkWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void failureAddingOpenNetwork(Integer wifiManagerReturnCode) { - - } - - @Override - public void openNetworkAdded(WifiConfiguration openNetwork) { - - } - }); - verify(mWiseFy).addOpenNetwork(anyString(), any(AddOpenNetworkCallbacks.class)); - } - - @Test - public void addWEPNetwork_apis() { - mWiseFy.addWEPNetwork("WEP Network", "123456"); - verify(mWiseFy).addWEPNetwork(anyString(), anyString()); - mWiseFy.addWEPNetwork("WEP Network", "123456", new AddWEPNetworkCallbacks() { - @Override - public void addWEPNetworkWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void failureAddingWEPNetwork(Integer wifiManagerReturnCode) { - - } - - @Override - public void wepNetworkAdded(WifiConfiguration wepNetwork) { - - } - }); - verify(mWiseFy).addWEPNetwork(anyString(), anyString(), any(AddWEPNetworkCallbacks.class)); - } - - @Test - public void addWPA2Network_apis() { - mWiseFy.addWPA2Network("WPA2 Network", "12345678"); - verify(mWiseFy).addWPA2Network(anyString(), anyString()); - mWiseFy.addWPA2Network("WPA2 Network", "12345678", new AddWPA2NetworkCallbacks() { - @Override - public void addWPA2NetworkWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void failureAddingWPA2Network(Integer wifiManagerReturnCode) { - - } - - @Override - public void wpa2NetworkAdded(WifiConfiguration wpa2Network) { - - } - }); - verify(mWiseFy).addWPA2Network(anyString(), anyString(), any(AddWPA2NetworkCallbacks.class)); - } - - @Test - public void compareSignalLevel_api() { - mWiseFy.compareSignalLevel(-50, -65); - verify(mWiseFy).compareSignalLevel(anyInt(), anyInt()); - } - - @Test - public void calculateBars_api() { - mWiseFy.calculateBars(-50, 5); - verify(mWiseFy).calculateBars(anyInt(), anyInt()); - } - - @Test - public void connectToNetwork_apis() { - mWiseFy.connectToNetwork("SSID to connect to", 3000); - verify(mWiseFy).connectToNetwork(anyString(), anyInt()); - mWiseFy.connectToNetwork("SSID to connect", 3000, new ConnectToNetworkCallbacks() { - @Override - public void connectedToNetwork() { - - } - - @Override - public void connectToNetworkWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void failureConnectingToNetwork() { - - } - - @Override - public void networkNotFoundToConnectTo() { - - } - }); - verify(mWiseFy).connectToNetwork(anyString(), anyInt(), any(ConnectToNetworkCallbacks.class)); - } - - @Test - public void disableWifi_apis() { - mWiseFy.disableWifi(); - verify(mWiseFy).disableWifi(); - mWiseFy.disableWifi(new DisableWifiCallbacks() { - @Override - public void disableWifiWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void failureDisablingWifi() { - - } - - @Override - public void wifiDisabled() { - - } - }); - verify(mWiseFy).disableWifi(any(DisableWifiCallbacks.class)); - } - - @Test - public void disconnectFromCurrentNetwork_apis() { - mWiseFy.disconnectFromCurrentNetwork(); - verify(mWiseFy).disconnectFromCurrentNetwork(); - mWiseFy.disconnectFromCurrentNetwork(new DisconnectFromCurrentNetworkCallbacks() { - @Override - public void disconnectedFromCurrentNetwork() { - - } - - @Override - public void disconnectFromCurrentNetworkWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void failureDisconnectingFromCurrentNetwork() { - - } - }); - verify(mWiseFy).disconnectFromCurrentNetwork(any(DisconnectFromCurrentNetworkCallbacks.class)); - } - - @Test - public void enableWifi_apis() { - mWiseFy.enableWifi(); - verify(mWiseFy).enableWifi(); - mWiseFy.enableWifi(new EnableWifiCallbacks() { - @Override - public void enableWifiWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void failureEnablingWifi() { - - } - - @Override - public void wifiEnabled() { - - } - }); - verify(mWiseFy).enableWifi(any(EnableWifiCallbacks.class)); - } - - @Test - public void getCurrentNetwork_apis() { - mWiseFy.getCurrentNetwork(); - verify(mWiseFy).getCurrentNetwork(); - mWiseFy.getCurrentNetwork(new GetCurrentNetworkCallbacks() { - @Override - public void getCurrentNetworkWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void retrievedCurrentNetwork(WifiInfo currentNetwork) { - - } - }); - verify(mWiseFy).getCurrentNetwork(any(GetCurrentNetworkCallbacks.class)); - } - - @Test - public void getFrequency_apis() { - mWiseFy.getFrequency(); - verify(mWiseFy).getFrequency(); - mWiseFy.getFrequency(new GetFrequencyCallbacks() { - @Override - public void failureGettingFrequency() { - - } - - @Override - public void getFrequencyWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void retrievedFrequency(int frequency) { - - } - }); - verify(mWiseFy).getFrequency(any(GetFrequencyCallbacks.class)); - - mWiseFy.getFrequency(mock(WifiInfo.class)); - verify(mWiseFy).getFrequency(any(WifiInfo.class)); - mWiseFy.getFrequency(mock(WifiInfo.class), new GetFrequencyCallbacks() { - @Override - public void failureGettingFrequency() { - - } - - @Override - public void getFrequencyWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void retrievedFrequency(int frequency) { - - } - }); - verify(mWiseFy).getFrequency(any(WifiInfo.class), any(GetFrequencyCallbacks.class)); - } - - @Test - public void getNearbyAccessPoints_apis() { - mWiseFy.getNearbyAccessPoints(true); - verify(mWiseFy).getNearbyAccessPoints(anyBoolean()); - mWiseFy.getNearbyAccessPoints(true, new GetNearbyAccessPointsCallbacks() { - @Override - public void getNearbyAccessPointsWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void retrievedNearbyAccessPoints(List nearbyAccessPoints) { - - } - }); - verify(mWiseFy).getNearbyAccessPoints(anyBoolean(), any(GetNearbyAccessPointsCallbacks.class)); - } - - @Test - public void getRSSI_apis() { - mWiseFy.getRSSI("SSID", true, 1000); - verify(mWiseFy).getRSSI(anyString(), anyBoolean(), anyInt()); - mWiseFy.getRSSI("SSID", true, 1000, new GetRSSICallbacks() { - @Override - public void retrievedRSSI(Integer rssi) { - - } - - @Override - public void networkNotFoundToRetrieveRSSI() { - - } - - @Override - public void getRSSIWiseFyFailure(Integer wisefyReturnCode) { - - } - }); - verify(mWiseFy).getRSSI(anyString(), anyBoolean(), anyInt(), any(GetRSSICallbacks.class)); - } - - @Test - public void getSavedNetwork_apis() { - mWiseFy.getSavedNetwork("SSID"); - verify(mWiseFy).getSavedNetwork(anyString()); - mWiseFy.getSavedNetwork("SSID", new GetSavedNetworkCallbacks() { - @Override - public void getSavedNetworkWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void savedNetworkNotFound() { - - } - - @Override - public void retrievedSavedNetwork(WifiConfiguration savedNetwork) { - - } - }); - verify(mWiseFy).getSavedNetwork(anyString(), any(GetSavedNetworkCallbacks.class)); - } - - @Test - public void getSavedNetworks_apis() { - mWiseFy.getSavedNetworks(); - verify(mWiseFy).getSavedNetworks(); - mWiseFy.getSavedNetworks(new GetSavedNetworksCallbacks() { - @Override - public void getSavedNetworksWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void noSavedNetworksFound() { - - } - - @Override - public void retrievedSavedNetworks(List savedNetworks) { - - } - }); - verify(mWiseFy).getSavedNetworks(any(GetSavedNetworksCallbacks.class)); - - mWiseFy.getSavedNetworks("SSID"); - verify(mWiseFy).getSavedNetworks(anyString()); - mWiseFy.getSavedNetworks("SSID", new GetSavedNetworksCallbacks() { - @Override - public void getSavedNetworksWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void noSavedNetworksFound() { - - } - - @Override - public void retrievedSavedNetworks(List savedNetworks) { - - } - }); - verify(mWiseFy).getSavedNetworks(anyString(), any(GetSavedNetworksCallbacks.class)); - } - - @Test - public void getWiseFyLock_api() { - mWiseFy.getWiseFyLock(); - verify(mWiseFy).getWiseFyLock(); - } - - @Test - public void isDeviceConnectedToMobileNetwork_apis() { - mWiseFy.isDeviceConnectedToMobileNetwork(); - verify(mWiseFy).isDeviceConnectedToMobileNetwork(); - } - - @Test - public void isDeviceConnectedToMobileOrWifiNetwork_apis() { - mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(); - verify(mWiseFy).isDeviceConnectedToMobileOrWifiNetwork(); - } - - @Test - public void isDeviceConnectedToSSID_apis() { - mWiseFy.isDeviceConnectedToSSID("SSID"); - verify(mWiseFy).isDeviceConnectedToSSID(anyString()); - } - - @Test - public void isDeviceConnectedToWifiNetwork_apis() { - mWiseFy.isDeviceConnectedToWifiNetwork(); - verify(mWiseFy).isDeviceConnectedToWifiNetwork(); - } - - @Test - public void isDeviceRoaming_apis() { - mWiseFy.isDeviceRoaming(); - verify(mWiseFy).isDeviceRoaming(); - } - - @Test - public void isNetwork5gHz_apis() { - mWiseFy.isNetwork5gHz(); - verify(mWiseFy).isNetwork5gHz(); - - mWiseFy.isNetwork5gHz(mock(WifiInfo.class)); - verify(mWiseFy).isNetwork5gHz(any(WifiInfo.class)); - } - - @Test - public void isNetworkInConfigurationList_api() { - mWiseFy.isNetworkInConfigurationList("SSID"); - verify(mWiseFy).isNetworkInConfigurationList(anyString()); - } - - @Test - public void isNetworkEAP_api() { - mWiseFy.isNetworkEAP(mock(ScanResult.class)); - verify(mWiseFy).isNetworkEAP(any(ScanResult.class)); - } - - @Test - public void isNetworkPSK_api() { - mWiseFy.isNetworkPSK(mock(ScanResult.class)); - verify(mWiseFy).isNetworkPSK(any(ScanResult.class)); - } - - @Test - public void iisNetworkSecure_api() { - mWiseFy.isNetworkSecure(mock(ScanResult.class)); - verify(mWiseFy).isNetworkSecure(any(ScanResult.class)); - } - - @Test - public void isNetworkWEP_api() { - mWiseFy.isNetworkWEP(mock(ScanResult.class)); - verify(mWiseFy).isNetworkWEP(any(ScanResult.class)); - } - - @Test - public void isNetworkWPA_api() { - mWiseFy.isNetworkWPA(mock(ScanResult.class)); - verify(mWiseFy).isNetworkWPA(any(ScanResult.class)); - } - - @Test - public void isNetworkWPA2_api() { - mWiseFy.isNetworkWPA2(mock(ScanResult.class)); - verify(mWiseFy).isNetworkWPA2(any(ScanResult.class)); - } - - @Test - public void isWifiEnabled_api() { - mWiseFy.isWifiEnabled(); - verify(mWiseFy).isWifiEnabled(); - } - - @Test - public void removeNetwork_api() { - mWiseFy.removeNetwork("SSID"); - verify(mWiseFy).removeNetwork(anyString()); - - mWiseFy.removeNetwork("SSID", new RemoveNetworkCallbacks() { - @Override - public void failureRemovingNetwork() { - - } - - @Override - public void networkNotFoundToRemove() { - - } - - @Override - public void networkRemoved() { - - } - - @Override - public void removeNetworkWiseFyFailure(Integer wisefyReturnCode) { - - } - }); - verify(mWiseFy).removeNetwork(anyString(), any(RemoveNetworkCallbacks.class)); - } - - - @Test - public void searchForAccessPoint_api() { - mWiseFy.searchForAccessPoint("SSID", 1000, true); - verify(mWiseFy).searchForAccessPoint(anyString(), anyInt(), anyBoolean()); - - mWiseFy.searchForAccessPoint("SSID", 1000, true, new SearchForAccessPointCallbacks() { - @Override - public void searchForAccessPointWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void accessPointFound(ScanResult accessPoint) { - - } - - @Override - public void accessPointNotFound() { - - } - }); - verify(mWiseFy).searchForAccessPoint(anyString(), anyInt(), anyBoolean(), any(SearchForAccessPointCallbacks.class)); - } - - @Test - public void searchForAccessPoints_api() { - mWiseFy.searchForAccessPoints("SSID", true); - verify(mWiseFy).searchForAccessPoints(anyString(), anyBoolean()); - - mWiseFy.searchForAccessPoints("SSID", true, new SearchForAccessPointsCallbacks() { - @Override - public void searchForAccessPointsWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void foundAccessPoints(List accessPoints) { - - } - - @Override - public void noAccessPointsFound() { - - } - }); - verify(mWiseFy).searchForAccessPoints(anyString(), anyBoolean(), any(SearchForAccessPointsCallbacks.class)); - } - - @Test - public void searchForSSID_api() { - mWiseFy.searchForSSID("SSID", 1000); - verify(mWiseFy).searchForSSID(anyString(), anyInt()); - - mWiseFy.searchForSSID("SSID", 1000, new SearchForSSIDCallbacks() { - @Override - public void searchForSSIDWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void ssidFound(String ssid) { - - } - - @Override - public void ssidNotFound() { - - } - }); - verify(mWiseFy).searchForSSID(anyString(), anyInt(), any(SearchForSSIDCallbacks.class)); - } - - @Test - public void searchForSSIDs_api() { - mWiseFy.searchForSSIDs("SSID"); - verify(mWiseFy).searchForSSIDs(anyString()); - - mWiseFy.searchForSSIDs("SSID", new SearchForSSIDsCallbacks() { - @Override - public void searchForSSIDsWiseFyFailure(Integer wisefyReturnCode) { - - } - - @Override - public void retrievedSSIDs(List ssids) { - - } - - @Override - public void noSSIDsFound() { - - } - }); - verify(mWiseFy).searchForSSIDs(anyString(), any(SearchForSSIDsCallbacks.class)); - } - - @Test - public void wifiManagerFailure_value() { - assertEquals(WiseFy.WIFI_MANAGER_FAILURE, -1); - } -}