From bdb6ea7c3958cb29dbe80c6f9f5f8bdda9390022 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 12:20:34 -0500 Subject: [PATCH 01/50] Builder pattern updates, javadocs, new package name, updated README, and travis config close #16 close #20 close #21 close #22 close #23 close #24 --- README.md | 54 +- app/.travis.yml | 5 + app/build.gradle | 65 +- app/proguard-rules.pro | 2 +- .../wisefy/WiseFyTest.java | 392 ++++----- .../isupatches/wisefy/base/BaseTestClass.java | 13 + .../wisefy/base}/TestActivity.java | 2 +- .../wisefy/base}/TestUtils.java | 2 +- .../wisefy/util/GetManagerUtilTest.java | 5 +- .../com/metova/wisefy/base/BaseTestClass.java | 23 - app/src/main/AndroidManifest.xml | 4 +- .../java/com/isupatches/wisefy/WiseFy.java | 724 +++++++++++++++ .../wisefy/util/GetManagerUtil.java | 21 +- .../wisefy/util/LogUtil.java | 5 +- .../wisefy/util/SSIDUtil.java | 3 +- .../main/java/com/metova/wisefy/WiseFy.java | 759 ---------------- build.gradle | 6 +- javadoc/allclasses-frame.html | 23 + javadoc/allclasses-noframe.html | 23 + .../isupatches/wisefy/WiseFy.generator.html | 327 +++++++ javadoc/com/isupatches/wisefy/WiseFy.html | 821 ++++++++++++++++++ .../com/isupatches/wisefy/package-frame.html | 21 + .../isupatches/wisefy/package-summary.html | 146 ++++ .../com/isupatches/wisefy/package-tree.html | 136 +++ .../wisefy/util/GetManagerUtil.html | 289 ++++++ .../com/isupatches/wisefy/util/LogUtil.html | 290 +++++++ .../com/isupatches/wisefy/util/SSIDUtil.html | 252 ++++++ .../isupatches/wisefy/util/package-frame.html | 22 + .../wisefy/util/package-summary.html | 148 ++++ .../isupatches/wisefy/util/package-tree.html | 137 +++ .../com/metova/wisefy/WiseFy.generator.html | 327 +++++++ javadoc/com/metova/wisefy/WiseFy.html | 821 ++++++++++++++++++ javadoc/com/metova/wisefy/package-frame.html | 21 + .../com/metova/wisefy/package-summary.html | 145 ++++ javadoc/com/metova/wisefy/package-tree.html | 135 +++ .../metova/wisefy/util/GetManagerUtil.html | 289 ++++++ javadoc/com/metova/wisefy/util/LogUtil.html | 290 +++++++ javadoc/com/metova/wisefy/util/SSIDUtil.html | 252 ++++++ .../com/metova/wisefy/util/package-frame.html | 22 + .../metova/wisefy/util/package-summary.html | 147 ++++ .../com/metova/wisefy/util/package-tree.html | 136 +++ javadoc/constant-values.html | 158 ++++ javadoc/deprecated-list.html | 122 +++ javadoc/help-doc.html | 223 +++++ javadoc/index-all.html | 339 ++++++++ javadoc/index.html | 74 ++ javadoc/overview-frame.html | 22 + javadoc/overview-summary.html | 140 +++ javadoc/overview-tree.html | 140 +++ javadoc/package-list | 2 + javadoc/script.js | 30 + javadoc/stylesheet.css | 574 ++++++++++++ 52 files changed, 8087 insertions(+), 1042 deletions(-) create mode 100644 app/.travis.yml rename app/src/androidTest/java/com/{metova => isupatches}/wisefy/WiseFyTest.java (71%) create mode 100644 app/src/androidTest/java/com/isupatches/wisefy/base/BaseTestClass.java rename app/src/androidTest/java/com/{metova/wisefy/util => isupatches/wisefy/base}/TestActivity.java (68%) rename app/src/androidTest/java/com/{metova/wisefy/util => isupatches/wisefy/base}/TestUtils.java (96%) rename app/src/androidTest/java/com/{metova => isupatches}/wisefy/util/GetManagerUtilTest.java (90%) delete mode 100644 app/src/androidTest/java/com/metova/wisefy/base/BaseTestClass.java create mode 100644 app/src/main/java/com/isupatches/wisefy/WiseFy.java rename app/src/main/java/com/{metova => isupatches}/wisefy/util/GetManagerUtil.java (58%) rename app/src/main/java/com/{metova => isupatches}/wisefy/util/LogUtil.java (90%) rename app/src/main/java/com/{metova => isupatches}/wisefy/util/SSIDUtil.java (95%) delete mode 100644 app/src/main/java/com/metova/wisefy/WiseFy.java create mode 100644 javadoc/allclasses-frame.html create mode 100644 javadoc/allclasses-noframe.html create mode 100644 javadoc/com/isupatches/wisefy/WiseFy.generator.html create mode 100644 javadoc/com/isupatches/wisefy/WiseFy.html create mode 100644 javadoc/com/isupatches/wisefy/package-frame.html create mode 100644 javadoc/com/isupatches/wisefy/package-summary.html create mode 100644 javadoc/com/isupatches/wisefy/package-tree.html create mode 100644 javadoc/com/isupatches/wisefy/util/GetManagerUtil.html create mode 100644 javadoc/com/isupatches/wisefy/util/LogUtil.html create mode 100644 javadoc/com/isupatches/wisefy/util/SSIDUtil.html create mode 100644 javadoc/com/isupatches/wisefy/util/package-frame.html create mode 100644 javadoc/com/isupatches/wisefy/util/package-summary.html create mode 100644 javadoc/com/isupatches/wisefy/util/package-tree.html create mode 100644 javadoc/com/metova/wisefy/WiseFy.generator.html create mode 100644 javadoc/com/metova/wisefy/WiseFy.html create mode 100644 javadoc/com/metova/wisefy/package-frame.html create mode 100644 javadoc/com/metova/wisefy/package-summary.html create mode 100644 javadoc/com/metova/wisefy/package-tree.html create mode 100644 javadoc/com/metova/wisefy/util/GetManagerUtil.html create mode 100644 javadoc/com/metova/wisefy/util/LogUtil.html create mode 100644 javadoc/com/metova/wisefy/util/SSIDUtil.html create mode 100644 javadoc/com/metova/wisefy/util/package-frame.html create mode 100644 javadoc/com/metova/wisefy/util/package-summary.html create mode 100644 javadoc/com/metova/wisefy/util/package-tree.html create mode 100644 javadoc/constant-values.html create mode 100644 javadoc/deprecated-list.html create mode 100644 javadoc/help-doc.html create mode 100644 javadoc/index-all.html create mode 100644 javadoc/index.html create mode 100644 javadoc/overview-frame.html create mode 100644 javadoc/overview-summary.html create mode 100644 javadoc/overview-tree.html create mode 100644 javadoc/package-list create mode 100644 javadoc/script.js create mode 100644 javadoc/stylesheet.css diff --git a/README.md b/README.md index c830400e..1287a48e 100644 --- a/README.md +++ b/README.md @@ -10,34 +10,35 @@ WiseFy now supports the builder pattern so cool functionality can be added later To grab a default instance: ```java -WiseFy mWiseFy = new WiseFy.getSmarts().initiateHamsters(); +WiseFy mWiseFy = new WiseFy.generator().withContext(getActivity()).getSmarts(); ``` To grab an instance with logging enabled: ```java -WiseFy mWiseFy = new WiseFy.getSmarts().withLogging(true).initiateHamsters(); +WiseFy mWiseFy = new WiseFy.generator().withContext(getActivity()).logging(true).getSmarts(); ``` +**IMPORTANT!** Please make sure you call withContext for WiseFy to work properly ## Commands To add an open network: ```java -int addedSuccessfully = mWiseFy.addOpenNetwork(getActivity(), "Open Network"); +int addedSuccessfully = mWiseFy.addOpenNetwork("Open Network"); ``` To add a WEP network: ```java -int addedSuccessfully = mWiseFy.addWEPNetwork(getActivity(), "WEP Network", "123456"); +int addedSuccessfully = mWiseFy.addWEPNetwork("WEP Network", "123456"); ``` To add a WPA2 network: ```java -int addedSuccessfully = mWiseFy.addWPA2Network(getActivity(), "WPA2 Network", "12345678"); +int addedSuccessfully = mWiseFy.addWPA2Network("WPA2 Network", "12345678"); ``` To calculate number of bars given a networks signal strength and total number of bars: @@ -55,74 +56,74 @@ int result = mWiseFy.compareSignalLevel(-35, -70); To connect to a network given an SSID: ```java -boolean connectedSuccessfully = mWiseFy.connectToNetwork(getActivity(), "SSID To Reconnect To", 3000); +boolean connectedSuccessfully = mWiseFy.connectToNetwork("SSID To Reconnect To", 3000); ``` To disable wifi: ```java -boolean disabledWifiSuccessfully = mWiseFy.disableWifi(getActivity()); +boolean disabledWifiSuccessfully = mWiseFy.disableWifi(); ``` To disconnect from current network: ```java -boolean disconnectedSuccessfully = mWiseFy.disconnectFromCurrentNetwork(getActivity()); +boolean disconnectedSuccessfully = mWiseFy.disconnectFromCurrentNetwork(); ``` To enable wifi: ```java -boolean wifiEnabled = mWiseFy.enableWiFi(getActivity()); +boolean wifiEnabled = mWiseFy.enableWiFi(); ``` To get current network: ```java -WifiInfo currentNetwork = mWiseFy.getCurrentNetwork(getActivity()); +WifiInfo currentNetwork = mWiseFy.getCurrentNetwork(); ``` To get nearby access points:

Setting filterDuplicates to true will not return SSIDs with a weaker signal strength (will always take the highest) ```java -List nearbyAccessPoints = mWiseFy.getNearbyAccessPoints(getActivity(), true); +List nearbyAccessPoints = mWiseFy.getNearbyAccessPoints(true); ``` To get the networks whose configuration is already stored: ```java -List savedNetworks = mWiseFy.getSavedNetworks(getActivity()); +List savedNetworks = mWiseFy.getSavedNetworks(); ``` To check and see if the device is connected to a mobile network: ```java -boolean isConnected = mWiseFy.isDeviceConnectedToMobileNetwork(getActivity()); +boolean isConnected = mWiseFy.isDeviceConnectedToMobileNetwork(); ``` To check and see if the device is connected to a mobile or wifi network: ```java -boolean isConnected = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(getActivity()); +boolean isConnected = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(); ``` To check and see if the device is connected to a given SSID: ```java -boolean isConnected = mWiseFy.isDeviceConnectedToSSID(getActivity(), "SSID"); +boolean isConnected = mWiseFy.isDeviceConnectedToSSID("SSID"); ``` To check and see if the device is connected to a wifi network: ```java -boolean isConnected = mWiseFy.isDeviceConnectedToWifiNetwork(getActivity(), "SSID"); +boolean isConnected = mWiseFy.isDeviceConnectedToWifiNetwork("SSID"); ``` To check and see if a given SSID is in the devices set of configured networks: ```java -boolean isConfigured = mWiseFy.isNetworkInConfigurationList(getActivity(), "SSID"); +boolean isConfigured = mWiseFy.isNetworkInConfigurationList("SSID"); ``` To check and see if a network is secure (WEP/PSK/EAP capabilities): @@ -134,17 +135,30 @@ boolean isSecure = mWiseFy.isNetworkSecure(scanResult); To check and see if Wifi is enabled on a device: ```java -boolean wifiEnabled = mWiseFy.isWifiEnabled(getActivity()); +boolean wifiEnabled = mWiseFy.isWifiEnabled(); ``` To remove a configured network: ```java -boolean removedSuccessfully = mWiseFy.removeNetwork(getActivity(), "SSID To Remove"); +boolean removedSuccessfully = mWiseFy.removeNetwork("SSID To Remove"); ``` To search for an SSID given a search string: ```java -String ssid = mWiseFy.searchForSSID(getActivity(), "SSID To Search For", 3000); +String ssid = mWiseFy.searchForSSID("SSID To Search For", 3000); ``` + +## License ## +Copyright 2016 + +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. \ No newline at end of file diff --git a/app/.travis.yml b/app/.travis.yml new file mode 100644 index 00000000..dd1fa7dd --- /dev/null +++ b/app/.travis.yml @@ -0,0 +1,5 @@ +language: android +android: + components: + - build-tools-24.0.3 + - android-24 \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index a6ebbbf5..5d536ac0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,10 @@ apply plugin: 'com.android.library' apply plugin: 'jacoco' apply plugin: 'com.getkeepsafe.dexcount' +apply plugin: "com.github.dcendents.android-maven" + +group = 'com.isupatches' +version = '1.0.4' def coverageSourceDirs = [ '../app/src/main/java' @@ -59,8 +63,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 24 - versionCode 4 - versionName "1.0.3" + versionCode 5 + versionName version testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' } @@ -89,4 +93,59 @@ dependencies { androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2' testCompile 'junit:junit:4.12' -} \ No newline at end of file +} + +install { + repositories.mavenInstaller { + pom { + project { + artifactId 'wisefy' + packaging 'aar' + + name 'WiseFy' + url 'https://github.com/isuPatches/WiseFy' + + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id 'isuPatches' + name 'Sarah Klinefelter' + email 'isuPatches@yahoo.com' + } + } + scm { + connection 'https://github.com/isuPatches/WiseFy.git' + developerConnection 'https://github.com/isuPatches/WiseFy.git' + url 'https://github.com/isuPatches/WiseFy' + } + } + } + } +} + +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' +} + +task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + destinationDir = file("../javadoc/") + failOnError false +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives javadocJar + archives sourcesJar +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 54956cf9..163e5472 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -14,4 +14,4 @@ -verbose --keep class com.metova.** { *; } \ No newline at end of file +-keep class com.isupatches.** { *; } \ No newline at end of file diff --git a/app/src/androidTest/java/com/metova/wisefy/WiseFyTest.java b/app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java similarity index 71% rename from app/src/androidTest/java/com/metova/wisefy/WiseFyTest.java rename to app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java index 92c216fb..a9774320 100644 --- a/app/src/androidTest/java/com/metova/wisefy/WiseFyTest.java +++ b/app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java @@ -1,7 +1,6 @@ -package com.metova.wisefy; +package com.isupatches.wisefy; -import android.app.Activity; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -10,15 +9,14 @@ import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.support.test.rule.ActivityTestRule; -import com.metova.wisefy.base.BaseTestClass; -import com.metova.wisefy.util.GetManagerUtil; -import com.metova.wisefy.util.TestActivity; +import com.isupatches.wisefy.base.BaseTestClass; +import com.isupatches.wisefy.base.TestActivity; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import java.util.ArrayList; import java.util.List; -import static com.metova.wisefy.util.TestUtils.*; +import static com.isupatches.wisefy.base.TestUtils.*; import static org.junit.Assert.*; import static org.mockito.Mockito.*; @@ -30,11 +28,9 @@ public class WiseFyTest extends BaseTestClass { private ConnectivityManager mMockConnectivityManager; - private GetManagerUtil mMockGetManagerUtil; - private WifiManager mMockWiFiManager; - private WiseFy mWiseFy = new WiseFy.getSmarts().initiateHamsters(); + private WiseFy mWiseFy; public WiseFyTest() { super(TestActivity.class); @@ -44,133 +40,119 @@ public WiseFyTest() { public void setUp() { mMockWiFiManager = mock(WifiManager.class); mMockConnectivityManager = mock(ConnectivityManager.class); - mMockGetManagerUtil = mock(GetManagerUtil.class); - - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(mMockWiFiManager); - when(mMockGetManagerUtil.getConnectivityManager(any(Activity.class))).thenReturn(mMockConnectivityManager); - - mWiseFy.mGetManagerUtil = mMockGetManagerUtil; mActivityTestRule.launchActivity(new Intent()); + + mWiseFy = new WiseFy.generator().withContext(mActivityTestRule.getActivity()).getSmarts(); } @Test - public void testAddOpenNetwork() { - int result = mWiseFy.addOpenNetwork(mActivityTestRule.getActivity(), OPEN_NETWORK_SSID); + public void testAddOpenNetworkSuccess() { + setManagers(); + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + int result = mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID); assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, result); } @Test - public void testAddOpenNetworkFailureToAdd() { + public void testAddOpenNetworkFailure() { + setManagers(); when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - int result = mWiseFy.addOpenNetwork(mActivityTestRule.getActivity(), OPEN_NETWORK_SSID); + int result = mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID); assertEquals(WiseFy.WIFI_MANAGER_FAILURE, result); } @Test - public void testAddOpenNetworkNullActivity() { - int result = mWiseFy.addOpenNetwork(null, OPEN_NETWORK_SSID); - assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); - } - - @Test - public void testAddOpenNetworkNullPassword() { - int result = mWiseFy.addOpenNetwork(mActivityTestRule.getActivity(), null); + public void testAddOpenNetworkNullSSID() { + int result = mWiseFy.addOpenNetwork(null); assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); } @Test public void testAddOpenNetworkNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - int result = mWiseFy.addOpenNetwork(mActivityTestRule.getActivity(), OPEN_NETWORK_SSID); + setManagersToNull(); + int result = mWiseFy.addOpenNetwork(OPEN_NETWORK_SSID); assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); } @Test - public void testAddWEPNetwork() { - int result = mWiseFy.addWEPNetwork(mActivityTestRule.getActivity(), WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD); + public void testAddWEPNetworkSuccess() { + setManagers(); + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + int result = mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD); assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, result); } @Test - public void testAddWEPNetworkFailureToAdd() { + public void testAddWEPNetworkFailure() { + setManagers(); when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - int result = mWiseFy.addWEPNetwork(mActivityTestRule.getActivity(), WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD); + int result = mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD); assertEquals(WiseFy.WIFI_MANAGER_FAILURE, result); } @Test - public void testAddWEPNetworkNullActivity() { - int result = mWiseFy.addWEPNetwork(null, WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD); + public void testAddWEPNetworkNullPassword() { + int result = mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null); assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); } @Test public void testAddWEPNetworkNullSSID() { - int result = mWiseFy.addWEPNetwork(mActivityTestRule.getActivity(), null, WEP_NETWORK_PASSWORD); - assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); - } - - @Test - public void testAddWEPNetworkNullPassword() { - int result = mWiseFy.addWEPNetwork(mActivityTestRule.getActivity(), WEP_NETWORK_SSID, null); + int result = mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD); assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); } @Test public void testAddWEPNetworkNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - int result = mWiseFy.addWEPNetwork(mActivityTestRule.getActivity(), WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD); + setManagersToNull(); + int result = mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD); assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); } @Test - public void testAddWPA2Network() { - int result = mWiseFy.addWPA2Network(mActivityTestRule.getActivity(), WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD); + public void testAddWPA2NetworkSuccess() { + setManagers(); + when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0); + int result = mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD); assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, result); } @Test - public void testAddWPA2NetworkFailureToAdd() { + public void testAddWPA2NetworkFailure() { when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE); - int result = mWiseFy.addWPA2Network(mActivityTestRule.getActivity(), WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD); + int result = mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD); assertEquals(WiseFy.WIFI_MANAGER_FAILURE, result); } @Test - public void testAddWPA2NetworkNullActivity() { - int result = mWiseFy.addWPA2Network(null, WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD); + public void testAddWPA2NetworkNullPassword() { + int result = mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, null); assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); } @Test public void testAddWPA2NetworkNullSSID() { - int result = mWiseFy.addWPA2Network(mActivityTestRule.getActivity(), null, WPA2_NETWORK_PASSWORD); - assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); - } - - @Test - public void testAddWPA2NetworkNullPassword() { - int result = mWiseFy.addWPA2Network(mActivityTestRule.getActivity(), WPA2_NETWORK_SSID, null); + int result = mWiseFy.addWPA2Network(null, WPA2_NETWORK_PASSWORD); assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); } @Test public void testAddWPA2NetworkNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - int result = mWiseFy.addWPA2Network(mActivityTestRule.getActivity(), WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD); + setManagersToNull(); + int result = mWiseFy.addWPA2Network(WPA2_NETWORK_SSID, WPA2_NETWORK_PASSWORD); assertEquals(WiseFy.WISE_MANAGER_FAILURE, result); } @Test public void testBuilderWithLoggingFalse() { - WiseFy wiseFy = new WiseFy.getSmarts().withLogging(false).initiateHamsters(); + WiseFy wiseFy = new WiseFy.generator().logging(false).getSmarts(); assertEquals(false, wiseFy.isLoggingEnabled()); } @Test public void testBuilderWithLoggingTrue() { - WiseFy wiseFy = new WiseFy.getSmarts().withLogging(true).initiateHamsters(); + WiseFy wiseFy = new WiseFy.generator().logging(true).getSmarts(); assertEquals(true, wiseFy.isLoggingEnabled()); } @@ -188,12 +170,14 @@ public void testCompareSignalLevel() { @Test public void testConnectToNetworkFailureNoList() { - boolean result = mWiseFy.connectToNetwork(mActivityTestRule.getActivity(), TEST_SSID, 1); + setManagers(); + boolean result = mWiseFy.connectToNetwork(TEST_SSID, 1); assertEquals(false, result); } @Test public void testConnectToNetworkFailureNotAvailable() { + setManagers(); List wifiList = new ArrayList<>(); WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); mWiFiConfiguration.SSID = TEST_SSID; @@ -211,12 +195,13 @@ public void testConnectToNetworkFailureNotAvailable() { when(mockNetworkInfo.isAvailable()).thenReturn(false); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.connectToNetwork(mActivityTestRule.getActivity(), TEST_SSID, 1); + boolean result = mWiseFy.connectToNetwork(TEST_SSID, 1); assertEquals(false, result); } @Test public void testConnectToNetworkFailureNotConnected() { + setManagers(); List wifiList = new ArrayList<>(); WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); mWiFiConfiguration.SSID = TEST_SSID; @@ -234,25 +219,20 @@ public void testConnectToNetworkFailureNotConnected() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(false); - boolean result = mWiseFy.connectToNetwork(mActivityTestRule.getActivity(), TEST_SSID, 1); - assertEquals(false, result); - } - - @Test - public void testConnectToNetworkFailureNullActivity() { - boolean result = mWiseFy.connectToNetwork(null, TEST_SSID, 1); + boolean result = mWiseFy.connectToNetwork(TEST_SSID, 1); assertEquals(false, result); } @Test public void testConnectToNetworkFailureNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - boolean result = mWiseFy.connectToNetwork(null, TEST_SSID, 1); + setManagersToNull(); + boolean result = mWiseFy.connectToNetwork(TEST_SSID, 1); assertEquals(false, result); } @Test public void testConnectToNetworkSuccess() { + setManagers(); List wifiList = new ArrayList<>(); WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); mWiFiConfiguration.SSID = TEST_SSID; @@ -270,98 +250,104 @@ public void testConnectToNetworkSuccess() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.connectToNetwork(mActivityTestRule.getActivity(), TEST_SSID, 1); + boolean result = mWiseFy.connectToNetwork(TEST_SSID, 1); assertEquals(true, result); } @Test public void testDisableWifiFailure() { + setManagers(); when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - boolean result = mWiseFy.disableWifi(mActivityTestRule.getActivity()); + boolean result = mWiseFy.disableWifi(); verify(mMockWiFiManager).setWifiEnabled(false); assertEquals(true, result); } @Test - public void testDisableWifiNullActivity() { - boolean result = mWiseFy.disableWifi(null); + public void testDisableWifiNullWifiManager() { + setManagersToNull(); + boolean result = mWiseFy.disableWifi(); assertEquals(false, result); } @Test public void testDisableWifiSuccess() { + setManagers(); when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - boolean result = mWiseFy.disableWifi(mActivityTestRule.getActivity()); + boolean result = mWiseFy.disableWifi(); verify(mMockWiFiManager).setWifiEnabled(false); assertEquals(true, result); } @Test public void testDisconnectFromCurrentNetworkFailure() { + setManagers(); when(mMockWiFiManager.disconnect()).thenReturn(false); - boolean result = mWiseFy.disconnectFromCurrentNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.disconnectFromCurrentNetwork(); verify(mMockWiFiManager).disconnect(); assertEquals(false, result); } @Test - public void testDisconnectFromCurrentNetworkNullActivity() { - boolean result = mWiseFy.disconnectFromCurrentNetwork(null); + public void testDisconnectFromCurrentNetworkNullWifiManager() { + setManagersToNull(); + boolean result = mWiseFy.disconnectFromCurrentNetwork(); assertEquals(false, result); } @Test public void testDisconnectFromCurrentNetworkSuccess() { + setManagers(); when(mMockWiFiManager.disconnect()).thenReturn(true); - boolean result = mWiseFy.disconnectFromCurrentNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.disconnectFromCurrentNetwork(); verify(mMockWiFiManager).disconnect(); assertEquals(true, result); } @Test public void testEnableWiFiFailure() { + setManagers(); when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(false); - boolean result = mWiseFy.enableWifi(mActivityTestRule.getActivity()); + boolean result = mWiseFy.enableWifi(); verify(mMockWiFiManager).setWifiEnabled(true); assertEquals(false, result); } @Test - public void testEnableWiFiNullActivity() { - boolean result = mWiseFy.enableWifi(null); + public void testEnableWiFiNullWifiManager() { + setManagersToNull(); + boolean result = mWiseFy.enableWifi(); assertEquals(false, result); } @Test public void testEnableWiFiSuccess() { + setManagers(); when(mMockWiFiManager.setWifiEnabled(anyBoolean())).thenReturn(true); - boolean result = mWiseFy.enableWifi(mActivityTestRule.getActivity()); + boolean result = mWiseFy.enableWifi(); verify(mMockWiFiManager).setWifiEnabled(true); assertEquals(true, result); } @Test public void testGetCurrentNetwork() { + setManagers(); WifiInfo mockWifiInfo = mock(WifiInfo.class); when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - assertEquals(TEST_SSID, mWiseFy.getCurrentNetwork(mActivityTestRule.getActivity()).getSSID()); - } - - @Test - public void testGetCurrentNetworkNullActivity() { - assertEquals(null, mWiseFy.getCurrentNetwork(null)); + assertEquals(TEST_SSID, mWiseFy.getCurrentNetwork().getSSID()); } @Test public void testGetCurrentNetworkNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - assertEquals(null, mWiseFy.getCurrentNetwork(mActivityTestRule.getActivity())); + setManagersToNull(); + assertEquals(null, mWiseFy.getCurrentNetwork()); } @Test public void testGetNearbyAccessPoints() { + setManagers(); List scanResults = new ArrayList<>(); ScanResult scanResult1 = mock(ScanResult.class); scanResult1.SSID = TEST_SSID; @@ -372,7 +358,7 @@ public void testGetNearbyAccessPoints() { when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - List results = mWiseFy.getNearbyAccessPoints(mActivityTestRule.getActivity(), false); + List results = mWiseFy.getNearbyAccessPoints(false); assertEquals(scanResults, results); assertEquals(2, results.size()); @@ -380,6 +366,7 @@ public void testGetNearbyAccessPoints() { @Test public void testGetNearbyAccessPointsFilterDuplicatesDifferent() { + setManagers(); List scanResults = new ArrayList<>(); ScanResult scanResult1 = mock(ScanResult.class); scanResult1.SSID = TEST_SSID; @@ -390,7 +377,7 @@ public void testGetNearbyAccessPointsFilterDuplicatesDifferent() { when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - List results = mWiseFy.getNearbyAccessPoints(mActivityTestRule.getActivity(), true); + List results = mWiseFy.getNearbyAccessPoints(true); assertEquals(scanResults, results); assertEquals(2, results.size()); @@ -398,6 +385,7 @@ public void testGetNearbyAccessPointsFilterDuplicatesDifferent() { @Test public void testGetNearbyAccessPointsFilterDuplicatesHigher() { + setManagers(); List scanResults = new ArrayList<>(); ScanResult scanResult1 = mock(ScanResult.class); scanResult1.SSID = TEST_SSID; @@ -413,7 +401,7 @@ public void testGetNearbyAccessPointsFilterDuplicatesHigher() { when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - List results = mWiseFy.getNearbyAccessPoints(mActivityTestRule.getActivity(), true); + List results = mWiseFy.getNearbyAccessPoints(true); assertEquals(expectedScanResults, results); assertEquals(1, results.size()); @@ -421,6 +409,7 @@ public void testGetNearbyAccessPointsFilterDuplicatesHigher() { @Test public void testGetNearbyAccessPointsFilterDuplicatesLower() { + setManagers(); List scanResults = new ArrayList<>(); ScanResult scanResult1 = mock(ScanResult.class); scanResult1.SSID = TEST_SSID; @@ -436,49 +425,40 @@ public void testGetNearbyAccessPointsFilterDuplicatesLower() { when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - List results = mWiseFy.getNearbyAccessPoints(mActivityTestRule.getActivity(), true); + List results = mWiseFy.getNearbyAccessPoints(true); assertEquals(expectedScanResults, results); assertEquals(1, results.size()); } - @Test - public void testGetNearbyAccessPointsNullActivity() { - List results = mWiseFy.getNearbyAccessPoints(null, true); - assertEquals(null, results); - } - @Test public void testGetNearbyAccessPointsNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - List results = mWiseFy.getNearbyAccessPoints(mActivityTestRule.getActivity(), true); + setManagersToNull(); + List results = mWiseFy.getNearbyAccessPoints(true); assertEquals(null, results); } @Test public void testGetSavedNetworks() { + setManagers(); List wifiList = new ArrayList<>(); WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); mWiFiConfiguration.SSID = TEST_SSID; wifiList.add(mWiFiConfiguration); when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(wifiList, mWiseFy.getSavedNetworks(mActivityTestRule.getActivity())); - } - - @Test - public void testGetSavedNetworksNullActivity() { - assertEquals(null, mWiseFy.getSavedNetworks(null)); + assertEquals(wifiList, mWiseFy.getSavedNetworks()); } @Test public void testGetSavedNetworksNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - assertEquals(null, mWiseFy.getSavedNetworks(mActivityTestRule.getActivity())); + setManagersToNull(); + assertEquals(null, mWiseFy.getSavedNetworks()); } @Test public void testIsDeviceConnectedToMobileNetworkFailureSuccess() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("MOBILE"); @@ -486,12 +466,13 @@ public void testIsDeviceConnectedToMobileNetworkFailureSuccess() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(); assertEquals(true, result); } @Test public void testIsDeviceConnectedToMobileNetworkFailureNotAvailable() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("MOBILE"); @@ -499,12 +480,13 @@ public void testIsDeviceConnectedToMobileNetworkFailureNotAvailable() { when(mockNetworkInfo.isAvailable()).thenReturn(false); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToMobileNetworkFailureNotConnected() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("MOBILE"); @@ -512,12 +494,13 @@ public void testIsDeviceConnectedToMobileNetworkFailureNotConnected() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(false); - boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToMobileNetworkFailureWrongType() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("WRONG TYPE"); @@ -525,25 +508,20 @@ public void testIsDeviceConnectedToMobileNetworkFailureWrongType() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(null); - assertEquals(false, result); - } - - @Test - public void testIsDeviceConnectedToMobileNetworkNullActivity() { - boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(null); + boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToMobileNetworkNullConfigurationManager() { - when(mMockGetManagerUtil.getConnectivityManager(any(Activity.class))).thenReturn(null); - boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(mActivityTestRule.getActivity()); + setManagersToNull(); + boolean result = mWiseFy.isDeviceConnectedToMobileNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToMobileOrWifiNetworkFailureSuccessMobile() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("MOBILE"); @@ -551,12 +529,13 @@ public void testIsDeviceConnectedToMobileOrWifiNetworkFailureSuccessMobile() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(); assertEquals(true, result); } @Test public void testIsDeviceConnectedToMobileOrWifiNetworkFailureSuccessWifi() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("WIFI"); @@ -564,12 +543,13 @@ public void testIsDeviceConnectedToMobileOrWifiNetworkFailureSuccessWifi() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(); assertEquals(true, result); } @Test public void testIsDeviceConnectedToMobileOrWifiNetworkFailureNotAvailableMobile() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("MOBILE"); @@ -577,12 +557,13 @@ public void testIsDeviceConnectedToMobileOrWifiNetworkFailureNotAvailableMobile( when(mockNetworkInfo.isAvailable()).thenReturn(false); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToMobileOrWifiNetworkFailureNotAvailableWifi() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("WIFI"); @@ -590,12 +571,13 @@ public void testIsDeviceConnectedToMobileOrWifiNetworkFailureNotAvailableWifi() when(mockNetworkInfo.isAvailable()).thenReturn(false); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToMobileOrWifiNetworkFailureNotConnectedMobile() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("MOBILE"); @@ -603,12 +585,13 @@ public void testIsDeviceConnectedToMobileOrWifiNetworkFailureNotConnectedMobile( when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(false); - boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToMobileOrWifiNetworkFailureNotConnectedWifi() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("WIFI"); @@ -616,38 +599,20 @@ public void testIsDeviceConnectedToMobileOrWifiNetworkFailureNotConnectedWifi() when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(false); - boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(mActivityTestRule.getActivity()); - assertEquals(false, result); - } - - @Test - public void testIsDeviceConnectedToMobileOrWifiNetworkFailureWrongType() { - NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); - when(mockNetworkInfo.getTypeName()).thenReturn("WRONG TYPE"); - - when(mMockConnectivityManager.getActiveNetworkInfo()).thenReturn(mockNetworkInfo); - when(mockNetworkInfo.isAvailable()).thenReturn(true); - when(mockNetworkInfo.isConnected()).thenReturn(true); - - boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(null); - assertEquals(false, result); - } - - @Test - public void testIsDeviceConnectedToMobileWifiNetworkNullActivity() { - boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(null); + boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToMobileOrWifiNetworkNullConfigurationManager() { - when(mMockGetManagerUtil.getConnectivityManager(any(Activity.class))).thenReturn(null); - boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(mActivityTestRule.getActivity()); + setManagersToNull(); + boolean result = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToSSID() { + setManagers(); List wifiList = new ArrayList<>(); WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); mWiFiConfiguration.SSID = TEST_SSID; @@ -665,12 +630,13 @@ public void testIsDeviceConnectedToSSID() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToSSID(mActivityTestRule.getActivity(), TEST_SSID); + boolean result = mWiseFy.isDeviceConnectedToSSID(TEST_SSID); assertEquals(true, result); } @Test public void testIsDeviceConnectedToSSIDFailureOtherSSID() { + setManagers(); List wifiList = new ArrayList<>(); WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); mWiFiConfiguration.SSID = TEST_SSID2; @@ -688,12 +654,13 @@ public void testIsDeviceConnectedToSSIDFailureOtherSSID() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToSSID(mActivityTestRule.getActivity(), TEST_SSID); + boolean result = mWiseFy.isDeviceConnectedToSSID(TEST_SSID); assertEquals(false, result); } @Test public void testIsDeviceConnectedToSSIDFailureNotAvailable() { + setManagers(); List wifiList = new ArrayList<>(); WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); mWiFiConfiguration.SSID = TEST_SSID; @@ -711,12 +678,13 @@ public void testIsDeviceConnectedToSSIDFailureNotAvailable() { when(mockNetworkInfo.isAvailable()).thenReturn(false); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToSSID(mActivityTestRule.getActivity(), TEST_SSID); + boolean result = mWiseFy.isDeviceConnectedToSSID(TEST_SSID); assertEquals(false, result); } @Test public void testIsDeviceConnectedToSSIDFailureNotConnected() { + setManagers(); List wifiList = new ArrayList<>(); WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); mWiFiConfiguration.SSID = TEST_SSID; @@ -734,25 +702,20 @@ public void testIsDeviceConnectedToSSIDFailureNotConnected() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(false); - boolean result = mWiseFy.isDeviceConnectedToSSID(mActivityTestRule.getActivity(), TEST_SSID); - assertEquals(false, result); - } - - @Test - public void testIsDeviceConnectedToSSIDFailureNullActivity() { - boolean result = mWiseFy.isDeviceConnectedToSSID(null, TEST_SSID); + boolean result = mWiseFy.isDeviceConnectedToSSID(TEST_SSID); assertEquals(false, result); } @Test public void testIsDeviceConnectedToSSIDFailureNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - boolean result = mWiseFy.isDeviceConnectedToSSID(mActivityTestRule.getActivity(), TEST_SSID); + setManagersToNull(); + boolean result = mWiseFy.isDeviceConnectedToSSID(TEST_SSID); assertEquals(false, result); } @Test public void testIsDeviceConnectedToWifiNetworkFailureSuccess() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("WIFI"); @@ -760,12 +723,13 @@ public void testIsDeviceConnectedToWifiNetworkFailureSuccess() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(); assertEquals(true, result); } @Test public void testIsDeviceConnectedToWifiNetworkFailureNotAvailable() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("WIFI"); @@ -773,12 +737,13 @@ public void testIsDeviceConnectedToWifiNetworkFailureNotAvailable() { when(mockNetworkInfo.isAvailable()).thenReturn(false); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToWifiNetworkFailureNotConnected() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("WIFI"); @@ -786,12 +751,13 @@ public void testIsDeviceConnectedToWifiNetworkFailureNotConnected() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(false); - boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(mActivityTestRule.getActivity()); + boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToWifiNetworkFailureWrongType() { + setManagers(); NetworkInfo mockNetworkInfo = mock(NetworkInfo.class); when(mockNetworkInfo.getTypeName()).thenReturn("WRONG TYPE"); @@ -799,54 +765,46 @@ public void testIsDeviceConnectedToWifiNetworkFailureWrongType() { when(mockNetworkInfo.isAvailable()).thenReturn(true); when(mockNetworkInfo.isConnected()).thenReturn(true); - boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(null); - assertEquals(false, result); - } - - @Test - public void testIsDeviceConnectedToWifiNetworkNullActivity() { - boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(null); + boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(); assertEquals(false, result); } @Test public void testIsDeviceConnectedToWifiNetworkNullConfigurationManager() { - when(mMockGetManagerUtil.getConnectivityManager(any(Activity.class))).thenReturn(null); - boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(mActivityTestRule.getActivity()); + setManagersToNull(); + boolean result = mWiseFy.isDeviceConnectedToWifiNetwork(); assertEquals(false, result); } @Test public void testIsNetworkInConfigurationListFailure() { - assertEquals(false, mWiseFy.isNetworkInConfigurationList(mActivityTestRule.getActivity(), TEST_SSID)); + setManagers(); + assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); } @Test public void testIsNetworkInConfigurationListFailureNoNetworks() { + setManagers(); List wifiList = new ArrayList<>(); when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(mActivityTestRule.getActivity(), TEST_SSID)); + assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); } @Test public void testIsNetworkInConfigurationListSuccess() { + setManagers(); List wifiList = new ArrayList<>(); WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); mWiFiConfiguration.SSID = TEST_SSID; wifiList.add(mWiFiConfiguration); when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); - assertEquals(true, mWiseFy.isNetworkInConfigurationList(mActivityTestRule.getActivity(), TEST_SSID)); - } - - @Test - public void testIsNetworkInConfigurationNullActivity() { - assertEquals(false, mWiseFy.isNetworkInConfigurationList(null, TEST_SSID)); + assertEquals(true, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); } @Test public void testIsNetworkInConfigurationNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - assertEquals(false, mWiseFy.isNetworkInConfigurationList(mActivityTestRule.getActivity(), TEST_SSID)); + setManagersToNull(); + assertEquals(false, mWiseFy.isNetworkInConfigurationList(TEST_SSID)); } @Test @@ -885,61 +843,56 @@ public void testIsNetworkSecureNullCapabilities() { @Test public void testIsWifiEnabledFailure() { + setManagers(); when(mMockWiFiManager.isWifiEnabled()).thenReturn(false); - assertEquals(false, mWiseFy.isWifiEnabled(mActivityTestRule.getActivity())); + assertEquals(false, mWiseFy.isWifiEnabled()); } @Test public void testIsWifiEnabledSuccess() { + setManagers(); when(mMockWiFiManager.isWifiEnabled()).thenReturn(true); - assertEquals(true, mWiseFy.isWifiEnabled(mActivityTestRule.getActivity())); - } - - @Test - public void testIsWifiEnabledNullActivity() { - assertEquals(false, mWiseFy.isWifiEnabled(null)); + assertEquals(true, mWiseFy.isWifiEnabled()); } @Test public void testIsWifiEnabledNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - assertEquals(false, mWiseFy.isWifiEnabled(mActivityTestRule.getActivity())); + setManagersToNull(); + assertEquals(false, mWiseFy.isWifiEnabled()); } @Test public void testRemoveNetworkFailure() { + setManagers(); when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(getTestWifiConfiguration()); when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); - boolean result = mWiseFy.removeNetwork(mActivityTestRule.getActivity(), TEST_SSID); + boolean result = mWiseFy.removeNetwork(TEST_SSID); assertEquals(false, result); } @Test public void testRemoveNetworkFailureNotInList() { + setManagers(); List wifiList = new ArrayList<>(); when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(false); - boolean result = mWiseFy.removeNetwork(mActivityTestRule.getActivity(), TEST_SSID); + boolean result = mWiseFy.removeNetwork(TEST_SSID); assertEquals(false, result); } - @Test - public void testRemoveNetworkNullActivity() { - boolean result = mWiseFy.removeNetwork(null, TEST_SSID); - assertEquals(false, result); - } @Test public void testRemoveNetworkNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - boolean result = mWiseFy.removeNetwork(null, TEST_SSID); + setManagersToNull(); + boolean result = mWiseFy.removeNetwork(TEST_SSID); assertEquals(false, result); } @Test public void testRemoveNetworkSuccess() { + setManagers(); List wifiList = new ArrayList<>(); WifiConfiguration mWiFiConfiguration = new WifiConfiguration(); mWiFiConfiguration.SSID = TEST_SSID; @@ -947,32 +900,29 @@ public void testRemoveNetworkSuccess() { when(mMockWiFiManager.getConfiguredNetworks()).thenReturn(wifiList); when(mMockWiFiManager.removeNetwork(anyInt())).thenReturn(true); - boolean result = mWiseFy.removeNetwork(mActivityTestRule.getActivity(), TEST_SSID); + boolean result = mWiseFy.removeNetwork(TEST_SSID); assertEquals(true, result); } @Test public void testSearchSSIDNFailure() { + setManagers(); WifiInfo mockWifiInfo = mock(WifiInfo.class); when(mockWifiInfo.getSSID()).thenReturn(TEST_SSID); when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); - assertEquals(null, mWiseFy.searchForSSID(mActivityTestRule.getActivity(), TEST_SSID, 1)); - } - - @Test - public void testSearchSSIDNullActivity() { - assertEquals(null, mWiseFy.searchForSSID(null, TEST_SSID, 1)); + assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, 1)); } @Test public void testSearchSSIDNullWifiManager() { - when(mMockGetManagerUtil.getWiFiManager(any(Activity.class))).thenReturn(null); - assertEquals(null, mWiseFy.searchForSSID(null, TEST_SSID, 1)); + setManagersToNull(); + assertEquals(null, mWiseFy.searchForSSID(TEST_SSID, 1)); } @Test public void testSearchSSIDSuccess() { + setManagers(); List scanResults = new ArrayList<>(); ScanResult scanResult = mock(ScanResult.class); scanResult.SSID = TEST_SSID; @@ -983,6 +933,20 @@ public void testSearchSSIDSuccess() { when(mMockWiFiManager.getConnectionInfo()).thenReturn(mockWifiInfo); when(mMockWiFiManager.getScanResults()).thenReturn(scanResults); - assertEquals(TEST_SSID, mWiseFy.searchForSSID(mActivityTestRule.getActivity(), TEST_SSID, 1)); + assertEquals(TEST_SSID, mWiseFy.searchForSSID(TEST_SSID, 1)); + } + + /** + * HELPERS + */ + + private void setManagers() { + mWiseFy.mWifiManager = mMockWiFiManager; + mWiseFy.mConnectivityManager = mMockConnectivityManager; + } + + private void setManagersToNull() { + mWiseFy.mWifiManager = null; + mWiseFy.mConnectivityManager = null; } } \ No newline at end of file diff --git a/app/src/androidTest/java/com/isupatches/wisefy/base/BaseTestClass.java b/app/src/androidTest/java/com/isupatches/wisefy/base/BaseTestClass.java new file mode 100644 index 00000000..e5d4a654 --- /dev/null +++ b/app/src/androidTest/java/com/isupatches/wisefy/base/BaseTestClass.java @@ -0,0 +1,13 @@ +package com.isupatches.wisefy.base; + + +import android.app.Activity; +import android.support.test.rule.ActivityTestRule; + + +public abstract class BaseTestClass extends ActivityTestRule { + + public BaseTestClass(Class activityClass) { + super(activityClass); + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/metova/wisefy/util/TestActivity.java b/app/src/androidTest/java/com/isupatches/wisefy/base/TestActivity.java similarity index 68% rename from app/src/androidTest/java/com/metova/wisefy/util/TestActivity.java rename to app/src/androidTest/java/com/isupatches/wisefy/base/TestActivity.java index f93047ea..813c4c5e 100644 --- a/app/src/androidTest/java/com/metova/wisefy/util/TestActivity.java +++ b/app/src/androidTest/java/com/isupatches/wisefy/base/TestActivity.java @@ -1,4 +1,4 @@ -package com.metova.wisefy.util; +package com.isupatches.wisefy.base; import android.app.Activity; diff --git a/app/src/androidTest/java/com/metova/wisefy/util/TestUtils.java b/app/src/androidTest/java/com/isupatches/wisefy/base/TestUtils.java similarity index 96% rename from app/src/androidTest/java/com/metova/wisefy/util/TestUtils.java rename to app/src/androidTest/java/com/isupatches/wisefy/base/TestUtils.java index 4250840a..3ddb26a4 100644 --- a/app/src/androidTest/java/com/metova/wisefy/util/TestUtils.java +++ b/app/src/androidTest/java/com/isupatches/wisefy/base/TestUtils.java @@ -1,4 +1,4 @@ -package com.metova.wisefy.util; +package com.isupatches.wisefy.base; import android.net.wifi.WifiConfiguration; diff --git a/app/src/androidTest/java/com/metova/wisefy/util/GetManagerUtilTest.java b/app/src/androidTest/java/com/isupatches/wisefy/util/GetManagerUtilTest.java similarity index 90% rename from app/src/androidTest/java/com/metova/wisefy/util/GetManagerUtilTest.java rename to app/src/androidTest/java/com/isupatches/wisefy/util/GetManagerUtilTest.java index d38e140a..6e841ba8 100644 --- a/app/src/androidTest/java/com/metova/wisefy/util/GetManagerUtilTest.java +++ b/app/src/androidTest/java/com/isupatches/wisefy/util/GetManagerUtilTest.java @@ -1,10 +1,11 @@ -package com.metova.wisefy.util; +package com.isupatches.wisefy.util; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; import android.support.test.rule.ActivityTestRule; -import com.metova.wisefy.base.BaseTestClass; +import com.isupatches.wisefy.base.BaseTestClass; +import com.isupatches.wisefy.base.TestActivity; import org.junit.Rule; import org.junit.Test; import static junit.framework.Assert.*; diff --git a/app/src/androidTest/java/com/metova/wisefy/base/BaseTestClass.java b/app/src/androidTest/java/com/metova/wisefy/base/BaseTestClass.java deleted file mode 100644 index 6ef3498a..00000000 --- a/app/src/androidTest/java/com/metova/wisefy/base/BaseTestClass.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.metova.wisefy.base; - - -import android.app.Activity; -import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.rule.ActivityTestRule; - - -public abstract class BaseTestClass extends ActivityTestRule { - - private Context targetContext = InstrumentationRegistry.getTargetContext(); - - - public BaseTestClass(Class activityClass) { - super(activityClass); - } - - - public Context getTargetContext() { - return targetContext; - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 673cb207..27cb118f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.isupatches.wisefy"> @@ -15,7 +15,7 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> - + diff --git a/app/src/main/java/com/isupatches/wisefy/WiseFy.java b/app/src/main/java/com/isupatches/wisefy/WiseFy.java new file mode 100644 index 00000000..35db6856 --- /dev/null +++ b/app/src/main/java/com/isupatches/wisefy/WiseFy.java @@ -0,0 +1,724 @@ +package com.isupatches.wisefy; + + +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.text.TextUtils; +import com.isupatches.wisefy.util.GetManagerUtil; +import com.isupatches.wisefy.util.LogUtil; +import com.isupatches.wisefy.util.SSIDUtil; +import java.util.ArrayList; +import java.util.List; + + +public class WiseFy { + + private static final String TAG = WiseFy.class.getSimpleName(); + + public static final int WISE_MANAGER_FAILURE = -1000; + + public static final int WIFI_MANAGER_FAILURE = -1; + + private LogUtil mLogUtil = LogUtil.getInstance(); + + private SSIDUtil mSSIDUtil = SSIDUtil.getInstance(); + + public ConnectivityManager mConnectivityManager; + + public WifiManager mWifiManager; + + private boolean mLoggingEnabled; + + /** + * Private constructor that accepts builder input + */ + private WiseFy(generator generator) { + this.mLoggingEnabled = generator.loggingEnabled; + this.mConnectivityManager = GetManagerUtil.getInstance().getConnectivityManager(generator.context); + this.mWifiManager = GetManagerUtil.getInstance().getWiFiManager(generator.context); + } + + /** + * Internal static class for builder pattern + */ + public static class generator implements GetSmarts, WithContext { + + private Context context; + + private boolean loggingEnabled; + + /** + * Mandatory - The context to get a WiFi and Connectivity manager + * + * @param context - The activity or application context + * {@link WithContext} + * + * @return generator - The builder with updated context + */ + public GetSmarts withContext(Context context) { + this.context = context; + return this; + } + + /** + * Non-mandatory - To enable/disable logging for the WiseFy instance + * + * @param loggingEnabled - If logging is enabled or disabled + * {@link GetSmarts} + * + * @return generator - The builder with updated logging setting + */ + public generator logging(boolean loggingEnabled) { + this.loggingEnabled = loggingEnabled; + return this; + } + + /** + * Mandatory - To build and return a WiseFy instance + * + * @return WiseFy - The instance created by the builder + */ + public WiseFy getSmarts() { + return new WiseFy(this); + } + } + + interface GetSmarts { + WiseFy getSmarts(); + } + + interface WithContext { + GetSmarts withContext(Context context); + generator logging(boolean loggingEnabled); + } + + /** + * 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) + */ + public int addOpenNetwork(String ssid) { + if (TextUtils.isEmpty(ssid)) { + mLogUtil.e(TAG, "Breaking due to empty SSID", mLoggingEnabled); + return WISE_MANAGER_FAILURE; + } + if (mWifiManager != null) { + boolean ssidAlreadyConfigured = checkIfNetworkInConfigurationList(ssid); + + if (!ssidAlreadyConfigured) { + mLogUtil.d(TAG, "Adding open network with SSID " + ssid, mLoggingEnabled); + + WifiConfiguration wifiConfig = new WifiConfiguration(); + + wifiConfig.SSID = mSSIDUtil.convertSSIDForConfig(ssid); + wifiConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); + wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN); + wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA); + wifiConfig.allowedAuthAlgorithms.clear(); + wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); + wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); + wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); + wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); + wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); + wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); + + return addNetwork(wifiConfig); + } + } else { + mLogUtil.e(TAG, "No mWifiManager to connect to add open network", mLoggingEnabled); + } + return WISE_MANAGER_FAILURE; + } + + /** + * 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) + */ + public int addWEPNetwork(String ssid, String password) { + if (TextUtils.isEmpty(ssid) || TextUtils.isEmpty(password)) { + mLogUtil.w(TAG, "Breaking due to missing ssid or password. ssid: " + ssid + ", password: " + password, mLoggingEnabled); + return WISE_MANAGER_FAILURE; + } + if (mWifiManager != null) { + boolean ssidAlreadyConfigured = checkIfNetworkInConfigurationList(ssid); + + if (!ssidAlreadyConfigured) { + mLogUtil.d(TAG, "Adding WEP network with SSID " + ssid, mLoggingEnabled); + + WifiConfiguration wifiConfig = new WifiConfiguration(); + wifiConfig.SSID = mSSIDUtil.convertSSIDForConfig(ssid); + wifiConfig.wepKeys[0] = "\"" + password + "\""; + wifiConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); + wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN); + wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA); + wifiConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); + wifiConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); + wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); + wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); + wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); + wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); + + return addNetwork(wifiConfig); + } + } else { + mLogUtil.e(TAG, "No mWifiManager to connect to add WEP network", mLoggingEnabled); + } + return WISE_MANAGER_FAILURE; + } + + /** + * 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) + */ + public int addWPA2Network(String ssid, String password) { + if (TextUtils.isEmpty(ssid) || TextUtils.isEmpty(password)) { + mLogUtil.w(TAG, "Breaking due to missing ssid or password. ssid: " + ssid + ", password: " + password, mLoggingEnabled); + return WISE_MANAGER_FAILURE; + } + if (mWifiManager != null) { + boolean ssidAlreadyConfigured = checkIfNetworkInConfigurationList(ssid); + + if (!ssidAlreadyConfigured) { + mLogUtil.d(TAG, "Adding WPA2 network with SSID " + ssid, mLoggingEnabled); + + WifiConfiguration wifiConfig = new WifiConfiguration(); + wifiConfig.SSID = mSSIDUtil.convertSSIDForConfig(ssid); + wifiConfig.preSharedKey = "\"" + password + "\""; + wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN); + wifiConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); + wifiConfig.status = WifiConfiguration.Status.ENABLED; + wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); + wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); + wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); + wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); + wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN); + wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA); + + wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); + wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); + + return addNetwork(wifiConfig); + } + } else { + mLogUtil.e(TAG, "No mWifiManager to connect to add WPA2 network", mLoggingEnabled); + } + return WISE_MANAGER_FAILURE; + } + + /** + * 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 + */ + 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. + */ + 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/reconnects to the given ssid, and then calls waitToConnectToSSID to verify 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 + */ + public boolean connectToNetwork(String ssidToConnectTo, int timeoutInMillis) { + mLogUtil.d(TAG, "Connecting to network: " + ssidToConnectTo, mLoggingEnabled); + if (mWifiManager != null) { + List list = mWifiManager.getConfiguredNetworks(); + if (list != null) { + for (int i = 0; i < list.size(); i++) { + WifiConfiguration wifiConfiguration = list.get(i); + if (wifiConfiguration != null && wifiConfiguration.SSID != null) { + String ssidInList = wifiConfiguration.SSID.replaceAll("\"", ""); + + mLogUtil.d(TAG, "Configured WiFi Network {index:" + i + ", ssidInList:" + ssidInList + "}", mLoggingEnabled); + if (ssidInList.equals(ssidToConnectTo)) { + mLogUtil.d(TAG, "ssidToReconnectTo: " + ssidToConnectTo + " matches ssidInList:" + ssidInList, mLoggingEnabled); + mWifiManager.disconnect(); + mWifiManager.enableNetwork(wifiConfiguration.networkId, true); + mWifiManager.reconnect(); + return waitToConnectToSSID(ssidToConnectTo, timeoutInMillis); + } + } + } + } + mLogUtil.w(TAG, "ssidToReconnectTo: " + ssidToConnectTo + " was not found in list to connect to", mLoggingEnabled); + } else { + mLogUtil.e(TAG, "No mWifiManager to connect to network. SSID: " + ssidToConnectTo, mLoggingEnabled); + } + return false; + } + + /** + * To disable Wifi on a user's device + * + * @return boolean - If the command succeeded in disabling wifi + */ + public boolean disableWifi() { + mLogUtil.d(TAG, "Disabling WiFi", mLoggingEnabled); + if (mWifiManager != null) { + return mWifiManager.setWifiEnabled(false); + } else { + mLogUtil.e(TAG, "No mWifiManager to disable Wifi", mLoggingEnabled); + } + return false; + } + + /** + * To disconnect the user from their current network + * + * @return boolean - If the command succeeded in disconnecting the device from the current network + */ + public boolean disconnectFromCurrentNetwork() { + mLogUtil.d(TAG, "Disconnecting from current network", mLoggingEnabled); + if (mWifiManager != null) { + return mWifiManager.disconnect(); + } else { + mLogUtil.e(TAG, "No mWifiManager to disconnect from current network", mLoggingEnabled); + } + return false; + } + + /** + * To enable Wifi on a user's device + * + * @return boolean - If the command succeeded in enabling wifi + */ + public boolean enableWifi() { + mLogUtil.d(TAG, "Enabling WiFi", mLoggingEnabled); + if (mWifiManager != null) { + return mWifiManager.setWifiEnabled(true); + } else { + mLogUtil.e(TAG, "No mWifiManager to enable wifi", mLoggingEnabled); + } + return false; + } + + /** + * To retrieve the user's current network + * + * @return WifiInfo|null - The user's current network information + */ + public WifiInfo getCurrentNetwork() { + if (mWifiManager != null) { + return mWifiManager.getConnectionInfo(); + } else { + mLogUtil.e(TAG, "No mWifiManager to get current network", mLoggingEnabled); + } + return null; + } + + /** + * 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 + * + * @return List of ScanResults|null - List of nearby access points + */ + public List getNearbyAccessPoints(boolean filterDuplicates) { + if (mWifiManager != null) { + mWifiManager.startScan(); + if (!filterDuplicates) { + return mWifiManager.getScanResults(); + } else { + List scanResults = mWifiManager.getScanResults(); + List scanResultsToReturn = new ArrayList<>(); + + for (ScanResult newScanResult : scanResults) { + boolean found = false; + for (int i = 0; i < scanResultsToReturn.size(); i++) { + ScanResult scanResult = scanResultsToReturn.get(i); + mLogUtil.d(TAG, "SSID 1: " + newScanResult.SSID + ". SSID 2: " + scanResult.SSID, mLoggingEnabled); + if (newScanResult.SSID.equalsIgnoreCase(scanResult.SSID)) { + found = true; + mLogUtil.d(TAG, "SSID did match", mLoggingEnabled); + + mLogUtil.d(TAG, "Current level: " + scanResult.level, mLoggingEnabled); + mLogUtil.d(TAG, "New level: " + newScanResult.level, mLoggingEnabled); + mLogUtil.d(TAG, "comparison result: " + WifiManager.compareSignalLevel(newScanResult.level, scanResult.level), mLoggingEnabled); + + if (WifiManager.compareSignalLevel(newScanResult.level, scanResult.level) > 0) { + mLogUtil.d(TAG, "New result has a higher signal strength, swapping", mLoggingEnabled); + scanResultsToReturn.set(i, newScanResult); + } + } else { + mLogUtil.d(TAG, "SSID did not match", mLoggingEnabled); + } + } + + if (!found) { + mLogUtil.d(TAG, "Found new wifi network", mLoggingEnabled); + scanResultsToReturn.add(newScanResult); + } + } + return scanResultsToReturn; + } + } else { + mLogUtil.e(TAG, "No mWifiManager to get nearby access points", mLoggingEnabled); + } + return null; + } + + /** + * 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 + */ + public List getSavedNetworks() { + if (mWifiManager != null) { + return mWifiManager.getConfiguredNetworks(); + } else { + mLogUtil.e(TAG, "No mWifiManager to get saved networks", mLoggingEnabled); + } + return null; + } + + /** + * To check if the device is connected to a mobile network + * + * @return bool - If the device is currently connected to a mobile network + */ + public boolean isDeviceConnectedToMobileNetwork() { + if (mConnectivityManager != null) { + NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo(); + if (networkInfo != null && networkInfo.getTypeName().equalsIgnoreCase("MOBILE")) { + if (networkInfo.isConnected() && networkInfo.isAvailable()) { + return true; + } + } + } else { + mLogUtil.e(TAG, "No mConnectivityManager check if device is connected to mobile network", mLoggingEnabled); + } + return false; + } + + /** + * 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 + */ + public boolean isDeviceConnectedToMobileOrWifiNetwork() { + if (mConnectivityManager != null) { + NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo(); + if (networkInfo.isConnected() && networkInfo.isAvailable()) { + return true; + } + } else { + mLogUtil.e(TAG, "No mConnectivityManager check if device is connected to mobile or wifi network", mLoggingEnabled); + } + return false; + } + + /** + * To check if the device is connected to a given SSID + * + * Used by connectToNetwork + * + * @param ssid - The SSID to check if the device is attached to + * + * @return bool - If the device is currently attached to the given SSID + */ + public boolean isDeviceConnectedToSSID(String ssid) { + if (mWifiManager != null) { + WifiInfo connectionInfo = mWifiManager.getConnectionInfo(); + if (connectionInfo != null && connectionInfo.getSSID() != null) { + String currentSSID = connectionInfo.getSSID().replaceAll("\"", ""); + mLogUtil.d(TAG, "Current SSID: " + currentSSID, mLoggingEnabled); + + if (currentSSID.equals(ssid)) { + mLogUtil.d(TAG, "Correct SSID", mLoggingEnabled); + if (mConnectivityManager != null + && mConnectivityManager.getActiveNetworkInfo() != null + && mConnectivityManager.getActiveNetworkInfo().isAvailable() + && mConnectivityManager.getActiveNetworkInfo().isConnected()) { + mLogUtil.d(TAG, "Network is connected", mLoggingEnabled); + return true; + } + } + } + } else { + mLogUtil.e(TAG, "No mWifiManager check if device is connected to SSID: " + ssid, mLoggingEnabled); + } + return false; + } + + /** + * To check if the device is connected to a wifi network + * + * @return bool - If the device is currently connected to a wifi network + */ + public boolean isDeviceConnectedToWifiNetwork() { + if (mConnectivityManager != null) { + NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo(); + if (networkInfo != null && networkInfo.getTypeName().equalsIgnoreCase("WIFI")) { + if (networkInfo.isConnected() && networkInfo.isAvailable()) { + return true; + } + } + } else { + mLogUtil.e(TAG, "No mConnectivityManager check if device is connected to wifi network", mLoggingEnabled); + } + return false; + } + + /** + * 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 + */ + public boolean isNetworkInConfigurationList(String ssid) { + if(mWifiManager != null) { + return checkIfNetworkInConfigurationList(ssid); + } else { + mLogUtil.e(TAG, "No mWifiManager to check if network is in the configuration list", mLoggingEnabled); + } + return false; + } + + /** + * To check and return if a network is secure (WEP/PSK/EAP capabilities) + * + * @param scanResult - The network to see if it is secure + * + * @return boolean - Whether the network is secure + */ + public boolean isNetworkSecure(ScanResult scanResult) { + boolean isSecure = false; + if (scanResult != null && scanResult.capabilities != null) { + if (scanResult.capabilities.contains("WEP") || scanResult.capabilities.contains("PSK") || scanResult.capabilities.contains("EAP")) { + isSecure = true; + } + } + return isSecure; + } + + /** + * To check if Wifi is enabled on the device or not + * + * @return boolean - if Wifi is enabled on device + */ + public boolean isWifiEnabled() { + if (mWifiManager != null) { + return mWifiManager.isWifiEnabled(); + } else { + mLogUtil.e(TAG, "No mWifiManager to check if wifi is enabled", mLoggingEnabled); + } + return false; + } + + /** + * 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 + */ + public boolean removeNetwork(String ssidToRemove) { + if (mWifiManager != null) { + List list = mWifiManager.getConfiguredNetworks(); + if (list != null) { + for (int i = 0; i < list.size(); i++) { + WifiConfiguration wifiConfiguration = list.get(i); + if (wifiConfiguration != null && wifiConfiguration.SSID != null) { + String ssidInList = wifiConfiguration.SSID.replaceAll("\"", ""); + + mLogUtil.d(TAG, "Configured WiFi Network {index:" + i + ", ssidInList:" + ssidInList + "}", mLoggingEnabled); + if (ssidInList.equals(ssidToRemove)) { + mLogUtil.d(TAG, "Removing network: " + ssidToRemove, mLoggingEnabled); + mWifiManager.disconnect(); + boolean result = mWifiManager.removeNetwork(wifiConfiguration.networkId); + if (result) { + mLogUtil.d(TAG, "Successfully removed network", mLoggingEnabled); + mWifiManager.saveConfiguration(); + } else { + mLogUtil.d(TAG, "Failed to remove network", mLoggingEnabled); + } + mWifiManager.reconnect(); + return result; + } + } + } + } + mLogUtil.w(TAG, "SSID to remove: " + ssidToRemove + " was not found in list to remove network", mLoggingEnabled); + } else { + mLogUtil.e(TAG, "No mWifiManager to remove network. SSID: " + ssidToRemove, mLoggingEnabled); + } + return false; + } + + /** + * To search local networks and return the first one that contains a given ssid (non-case sensitive) + * + * @param ssidToSearchFor - The ssid to search for + * @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) + */ + public String searchForSSID(String ssidToSearchFor, int timeoutInMillis) { + if (mWifiManager != null) { + int scanPass = 1; + long currentTime; + long endTime = System.currentTimeMillis() + timeoutInMillis; + LogUtil.getInstance().d(TAG, "End time (searchForSSID): " + endTime, mLoggingEnabled); + do { + mLogUtil.d(TAG, "Scanning SSIDs, pass " + scanPass, mLoggingEnabled); + mWifiManager.startScan(); + List networks = mWifiManager.getScanResults(); + for (ScanResult scanResult : networks) { + mLogUtil.d(TAG, "scanResult.SSID: " + scanResult.SSID, mLoggingEnabled); + if (scanResult.SSID != null && (scanResult.SSID.toUpperCase().contains(ssidToSearchFor.toUpperCase()))) { + mLogUtil.d(TAG, "Found match, SSID: " + scanResult.SSID, mLoggingEnabled); + return scanResult.SSID; + } + } + + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + // Do nothing + } + currentTime = System.currentTimeMillis(); + LogUtil.getInstance().d(TAG, "Current time (searchForSSID): " + endTime, mLoggingEnabled); + scanPass++; + } while(currentTime < endTime); + } else { + mLogUtil.e(TAG, "No mWifiManager to search for network. SSID: " + ssidToSearchFor, mLoggingEnabled); + } + return null; + } + + /** + * To query if logging is enabled or disabled for a WiseFy instance + * + * @return boolean - If logging is enabled for the WiseFy instance + */ + public boolean isLoggingEnabled() { + return mLoggingEnabled; + } + + /** + * HELPERS + */ + + /** + * Used internally by addOpenNetwork, addWEPNetwork, and addWPA2Network to add and save a new wifi configuration + * + * @param wifiConfig - The network to configuration to add + * + * {@link #addOpenNetwork(String)} + * {@link #addWEPNetwork(String, String)} + * {@link #addWPA2Network(String, String)} + * + * @return int - The return code from WifiManager for network creation (-1 for failure) + */ + private int addNetwork(WifiConfiguration wifiConfig) { + int result = mWifiManager.addNetwork(wifiConfig); + if (result != WIFI_MANAGER_FAILURE) { + mLogUtil.d(TAG, "Successfully added network", mLoggingEnabled); + mWifiManager.saveConfiguration(); + } else { + mLogUtil.e(TAG, "Failed to add network", mLoggingEnabled); + } + return result; + } + + /** + * Used internally by addOpenNetwork, addWEPNetwork, addWPA2Network, and + * isNetworkInConfigurationList to see if an ssid is already saved (CASE SENSITIVE!) + * + * @param ssid - The ssid to check for in the configured network list + * + * {@link #addOpenNetwork(String)} + * {@link #addWEPNetwork(String, String)} + * {@link #addWPA2Network(String, String)} + * {@link #isNetworkInConfigurationList(String)} + * + * @return boolean - If the ssid was found in the configuration list + */ + private boolean checkIfNetworkInConfigurationList(String ssid) { + List list = mWifiManager.getConfiguredNetworks(); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + WifiConfiguration wifiConfiguration = list.get(i); + if (wifiConfiguration != null && wifiConfiguration.SSID != null) { + String ssidInList = wifiConfiguration.SSID.replaceAll("\"", ""); + mLogUtil.d(TAG, "SSID in list: " + ssidInList + ", SSID: " + ssid, mLoggingEnabled); + if (ssidInList.equals(ssid)) { + mLogUtil.d(TAG, "Found SSID in list", mLoggingEnabled); + return true; + } + } + } + } else { + mLogUtil.w(TAG, "Found 0 configured networks", mLoggingEnabled); + } + return false; + } + + /** + * Used internally by connectToNetwork to check if the device connects to + * a given SSID within a specified time (timeout is in millis) + * + * @param ssid - The ssid to wait for the device to connect to + * @param timeoutInMillis - The number of milliseconds to wait + * + * @return boolean - If the device is connected to the ssid in the given time + */ + private boolean waitToConnectToSSID(String ssid, int timeoutInMillis) { + long currentTime; + long endTime = System.currentTimeMillis() + timeoutInMillis; + LogUtil.getInstance().d(TAG, "End time (waitToConnectToSSID): " + endTime, mLoggingEnabled); + do { + boolean result = isDeviceConnectedToSSID(ssid); + if (result) { + return result; + } + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + // Do nothing + } + currentTime = System.currentTimeMillis(); + LogUtil.getInstance().d(TAG, "Current time (waitToConnectToSSID): " + endTime, mLoggingEnabled); + } while(currentTime < endTime); + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/metova/wisefy/util/GetManagerUtil.java b/app/src/main/java/com/isupatches/wisefy/util/GetManagerUtil.java similarity index 58% rename from app/src/main/java/com/metova/wisefy/util/GetManagerUtil.java rename to app/src/main/java/com/isupatches/wisefy/util/GetManagerUtil.java index 7187fb09..3e4f8d58 100644 --- a/app/src/main/java/com/metova/wisefy/util/GetManagerUtil.java +++ b/app/src/main/java/com/isupatches/wisefy/util/GetManagerUtil.java @@ -1,11 +1,10 @@ -package com.metova.wisefy.util; +package com.isupatches.wisefy.util; -import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; -import com.metova.wisefy.WiseFy; +import com.isupatches.wisefy.WiseFy; public class GetManagerUtil { @@ -31,12 +30,12 @@ public static GetManagerUtil getInstance() { * @see ConnectivityManager * @see WiseFy * - * @param activity - The activity to use as context to retrieve a connectivity manager via getSystemService + * @param context - The context to use to retrieve a connectivity manager via getSystemService * @return ConnectivityManager|null */ - public ConnectivityManager getConnectivityManager(Activity activity) { - if(activity != null) { - return (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE); + public ConnectivityManager getConnectivityManager(Context context) { + if(context != null) { + return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); } else { return null; } @@ -48,12 +47,12 @@ public ConnectivityManager getConnectivityManager(Activity activity) { * @see WifiManager * @see WiseFy * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService + * @param context - The context to use to retrieve a wifi manager via getSystemService * @return WifiManager|null */ - public WifiManager getWiFiManager(Activity activity) { - if(activity != null) { - return (WifiManager) activity.getSystemService(Context.WIFI_SERVICE); + public WifiManager getWiFiManager(Context context) { + if(context != null) { + return (WifiManager) context.getSystemService(Context.WIFI_SERVICE); } else { return null; } diff --git a/app/src/main/java/com/metova/wisefy/util/LogUtil.java b/app/src/main/java/com/isupatches/wisefy/util/LogUtil.java similarity index 90% rename from app/src/main/java/com/metova/wisefy/util/LogUtil.java rename to app/src/main/java/com/isupatches/wisefy/util/LogUtil.java index 08f1cb20..2448a563 100644 --- a/app/src/main/java/com/metova/wisefy/util/LogUtil.java +++ b/app/src/main/java/com/isupatches/wisefy/util/LogUtil.java @@ -1,8 +1,7 @@ -package com.metova.wisefy.util; +package com.isupatches.wisefy.util; import android.util.Log; -import com.metova.wisefy.BuildConfig; public class LogUtil { @@ -42,7 +41,7 @@ public void e (String tag, String message, boolean loggingEnabled) { private boolean isLoggable(String tag, int level, boolean loggingEnabled) { boolean isLoggable; - if(BuildConfig.DEBUG || loggingEnabled) { + if(loggingEnabled) { isLoggable = true; } else { if (tag.length() > 23) { diff --git a/app/src/main/java/com/metova/wisefy/util/SSIDUtil.java b/app/src/main/java/com/isupatches/wisefy/util/SSIDUtil.java similarity index 95% rename from app/src/main/java/com/metova/wisefy/util/SSIDUtil.java rename to app/src/main/java/com/isupatches/wisefy/util/SSIDUtil.java index a4b64832..6af98b10 100644 --- a/app/src/main/java/com/metova/wisefy/util/SSIDUtil.java +++ b/app/src/main/java/com/isupatches/wisefy/util/SSIDUtil.java @@ -1,8 +1,9 @@ -package com.metova.wisefy.util; +package com.isupatches.wisefy.util; import android.os.Build; + public class SSIDUtil { private static final SSIDUtil SSID_UTIL = new SSIDUtil(); diff --git a/app/src/main/java/com/metova/wisefy/WiseFy.java b/app/src/main/java/com/metova/wisefy/WiseFy.java deleted file mode 100644 index 49a259d4..00000000 --- a/app/src/main/java/com/metova/wisefy/WiseFy.java +++ /dev/null @@ -1,759 +0,0 @@ -package com.metova.wisefy; - - -import android.app.Activity; -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.support.annotation.VisibleForTesting; -import android.text.TextUtils; -import com.metova.wisefy.util.GetManagerUtil; -import com.metova.wisefy.util.LogUtil; -import com.metova.wisefy.util.SSIDUtil; -import java.util.ArrayList; -import java.util.List; - - -public class WiseFy { - - private static final String TAG = WiseFy.class.getSimpleName(); - - @VisibleForTesting - public GetManagerUtil mGetManagerUtil = GetManagerUtil.getInstance(); - - public static final int WISE_MANAGER_FAILURE = -1000; - - public static final int WIFI_MANAGER_FAILURE = -1; - - private LogUtil mLogUtil = LogUtil.getInstance(); - - private SSIDUtil mSSIDUtil = SSIDUtil.getInstance(); - - private boolean loggingEnabled; - - /** - * Private constructor that accepts builder input - */ - private WiseFy(getSmarts getSmarts) { - this.loggingEnabled = getSmarts.loggingEnabled; - } - - /** - * Internal static class for builder pattern - */ - public static class getSmarts { - private boolean loggingEnabled; - - public getSmarts() { - } - - /** - * To enable/disable logging for the WiseFy instance - * - * @param loggingEnabled - If logging is enabled or disabled - * - * @return getSmarts - The builder with updated logging setting - */ - public getSmarts withLogging(boolean loggingEnabled) { - this.loggingEnabled = loggingEnabled; - return this; - } - - /** - * To build and return a WiseFy instance - * - * @return WiseFy - The instance created by the builder - */ - public WiseFy initiateHamsters() { - return new WiseFy(this); - } - } - - /** - * To add an open network to the user's configured network list - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * @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) - */ - public int addOpenNetwork(Activity activity, String ssid) { - if (TextUtils.isEmpty(ssid) || activity == null || activity.isFinishing()) { - mLogUtil.w(TAG, "Breaking due to missing ssid or activity. ssid: " + ssid, loggingEnabled); - return WISE_MANAGER_FAILURE; - } - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - boolean ssidAlreadyConfigured = isNetworkInConfigurationList(wifiManager, ssid); - - if (!ssidAlreadyConfigured) { - mLogUtil.d(TAG, "Adding open network with SSID " + ssid, loggingEnabled); - - WifiConfiguration wifiConfig = new WifiConfiguration(); - - wifiConfig.SSID = mSSIDUtil.convertSSIDForConfig(ssid); - wifiConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); - wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN); - wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA); - wifiConfig.allowedAuthAlgorithms.clear(); - wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); - wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); - wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); - wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); - wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); - wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); - - return addNetwork(wifiManager, wifiConfig); - } - } - return WISE_MANAGER_FAILURE; - } - - /** - * To add a WEP network to the user's configured network list - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * @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) - */ - public int addWEPNetwork(Activity activity, String ssid, String password) { - if (TextUtils.isEmpty(ssid) || TextUtils.isEmpty(password) || activity == null || activity.isFinishing()) { - mLogUtil.w(TAG, "Breaking due to missing ssid, password, or activity. ssid: " + ssid + ", password: " + password, loggingEnabled); - return WISE_MANAGER_FAILURE; - } - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - boolean ssidAlreadyConfigured = isNetworkInConfigurationList(wifiManager, ssid); - - if (!ssidAlreadyConfigured) { - mLogUtil.d(TAG, "Adding WEP network with SSID " + ssid, loggingEnabled); - - WifiConfiguration wifiConfig = new WifiConfiguration(); - wifiConfig.SSID = mSSIDUtil.convertSSIDForConfig(ssid); - wifiConfig.wepKeys[0] = "\"" + password + "\""; - wifiConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); - wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN); - wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA); - wifiConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); - wifiConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); - wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); - wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); - wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); - wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); - - return addNetwork(wifiManager, wifiConfig); - } - } - return WISE_MANAGER_FAILURE; - } - - /** - * To add a WPA2 network to the user's configured network list - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * @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) - */ - public int addWPA2Network(Activity activity, String ssid, String password) { - if (TextUtils.isEmpty(ssid) || TextUtils.isEmpty(password) || activity == null || activity.isFinishing()) { - mLogUtil.w(TAG, "Breaking due to missing ssid, password, or activity. ssid: " + ssid + ", password: " + password, loggingEnabled); - return WISE_MANAGER_FAILURE; - } - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - boolean ssidAlreadyConfigured = isNetworkInConfigurationList(wifiManager, ssid); - - if (!ssidAlreadyConfigured) { - mLogUtil.d(TAG, "Adding WPA2 network with SSID " + ssid, loggingEnabled); - - WifiConfiguration wifiConfig = new WifiConfiguration(); - wifiConfig.SSID = mSSIDUtil.convertSSIDForConfig(ssid); - wifiConfig.preSharedKey = "\"" + password + "\""; - wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN); - wifiConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); - wifiConfig.status = WifiConfiguration.Status.ENABLED; - wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); - wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); - wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); - wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); - wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN); - wifiConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA); - - wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); - wifiConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); - - return addNetwork(wifiManager, wifiConfig); - } - } - return WISE_MANAGER_FAILURE; - } - - /** - * 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 - */ - 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 <0 if the first signal is weaker than the second signal, 0 if the two - * signals have the same strength, and >0 if the first signal is stronger than the second signal. - */ - 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/reconnects to the given ssid, and then calls waitToConnectToSSID to verify connectivity - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * @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 - */ - public boolean connectToNetwork(Activity activity, String ssidToConnectTo, int timeoutInMillis) { - if (activity != null && !activity.isFinishing()) { - mLogUtil.d(TAG, "Connecting to network: " + ssidToConnectTo, loggingEnabled); - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - List list = wifiManager.getConfiguredNetworks(); - if (list != null) { - for (int i = 0; i < list.size(); i++) { - WifiConfiguration wifiConfiguration = list.get(i); - if (wifiConfiguration != null && wifiConfiguration.SSID != null) { - String ssidInList = wifiConfiguration.SSID.replaceAll("\"", ""); - - mLogUtil.d(TAG, "Configured WiFi Network {index:" + i + ", ssidInList:" + ssidInList + "}", loggingEnabled); - if (ssidInList.equals(ssidToConnectTo)) { - mLogUtil.d(TAG, "ssidToReconnectTo: " + ssidToConnectTo + " matches ssidInList:" + ssidInList, loggingEnabled); - wifiManager.disconnect(); - wifiManager.enableNetwork(wifiConfiguration.networkId, true); - wifiManager.reconnect(); - return waitToConnectToSSID(activity, ssidToConnectTo, timeoutInMillis); - } - } - } - } - - } - mLogUtil.w(TAG, "ssidToReconnectTo: " + ssidToConnectTo + " was not found in list to reconnect to", loggingEnabled); - } else { - mLogUtil.w(TAG, "No activity to reconnect to network", loggingEnabled); - } - return false; - } - - /** - * To disable Wifi on a user's device - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * - * @return boolean - If the command succeeded in disabling wifi - */ - public boolean disableWifi(Activity activity) { - if (activity != null && !activity.isFinishing()) { - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - return wifiManager.setWifiEnabled(false); - } - } else { - mLogUtil.w(TAG, "No activity to disable Wifi", loggingEnabled); - } - return false; - } - - /** - * To disconnect the user from their current network - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * - * @return boolean - If the command succeeded in disconnecting the device from the current network - */ - public boolean disconnectFromCurrentNetwork(Activity activity) { - if (activity != null && !activity.isFinishing()) { - mLogUtil.d(TAG, "Disconnecting from current network", loggingEnabled); - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - return wifiManager.disconnect(); - } - } else { - mLogUtil.w(TAG, "No activity to disconnect from current network", loggingEnabled); - } - return false; - } - - /** - * To enable Wifi on a user's device - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * - * @return boolean - If the command succeeded in enabling wifi - */ - public boolean enableWifi(Activity activity) { - if (activity != null && !activity.isFinishing()) { - mLogUtil.d(TAG, "Enabling WiFi", loggingEnabled); - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - return wifiManager.setWifiEnabled(true); - } - } else { - mLogUtil.w(TAG, "No activity to enable Wifi", loggingEnabled); - } - return false; - } - - /** - * To retrieve the user's current network - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * - * @return WifiInfo|null - The user's current network information - */ - public WifiInfo getCurrentNetwork(Activity activity) { - if (activity != null && !activity.isFinishing()) { - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - return wifiManager.getConnectionInfo(); - } - } else { - mLogUtil.w(TAG, "No activity to get current network", loggingEnabled); - } - return null; - } - - /** - * 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 activity - The activity to use as context to retrieve a wifi manager via getSystemService - * @param filterDuplicates - If you want to exclude SSIDs with that same name that have a weaker signal strength - * - * @return List|null - List of nearby access points - */ - public List getNearbyAccessPoints(Activity activity, boolean filterDuplicates) { - if (activity != null && !activity.isFinishing()) { - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - wifiManager.startScan(); - if (!filterDuplicates) { - return wifiManager.getScanResults(); - } else { - List scanResults = wifiManager.getScanResults(); - List scanResultsToReturn = new ArrayList<>(); - - for (ScanResult newScanResult : scanResults) { - boolean found = false; - for (int i = 0; i < scanResultsToReturn.size(); i++) { - ScanResult scanResult = scanResultsToReturn.get(i); - mLogUtil.d(TAG, "SSID 1: " + newScanResult.SSID + ". SSID 2: " + scanResult.SSID, loggingEnabled); - if (newScanResult.SSID.equalsIgnoreCase(scanResult.SSID)) { - found = true; - mLogUtil.d(TAG, "SSID did match", loggingEnabled); - - mLogUtil.d(TAG, "Current level: " + scanResult.level, loggingEnabled); - mLogUtil.d(TAG, "New level: " + newScanResult.level, loggingEnabled); - mLogUtil.d(TAG, "comparison result: " + WifiManager.compareSignalLevel(newScanResult.level, scanResult.level), loggingEnabled); - - if (WifiManager.compareSignalLevel(newScanResult.level, scanResult.level) > 0) { - mLogUtil.d(TAG, "New result has a higher signal strength, swapping", loggingEnabled); - scanResultsToReturn.set(i, newScanResult); - } - } else { - mLogUtil.d(TAG, "SSID did not match", loggingEnabled); - } - } - - if (!found) { - mLogUtil.d(TAG, "Found new wifi network", loggingEnabled); - scanResultsToReturn.add(newScanResult); - } - } - return scanResultsToReturn; - } - } - } else { - mLogUtil.w(TAG, "No activity to get nearby access points", loggingEnabled); - - } - return null; - } - - /** - * To retrieve a list of saved networks on a user's device - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * - * @return List|null - List of saved networks on a users device - */ - public List getSavedNetworks(Activity activity) { - if (activity != null && !activity.isFinishing()) { - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - return wifiManager.getConfiguredNetworks(); - } - } else { - mLogUtil.w(TAG, "No activity to get saved networks", loggingEnabled); - } - return null; - } - - /** - * To check if the device is connected to a mobile network - * - * @param activity - The activity to use as context to retrieve a wifi manager and a connectivity manager via getSystemService - * - * @return bool - If the device is currently connected to a mobile network - */ - public boolean isDeviceConnectedToMobileNetwork(Activity activity) { - if (activity != null && !activity.isFinishing()) { - ConnectivityManager connectivityManager = mGetManagerUtil.getConnectivityManager(activity); - if (connectivityManager != null) { - NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); - if (networkInfo != null && networkInfo.getTypeName().equalsIgnoreCase("MOBILE")) { - if (networkInfo.isConnected() && networkInfo.isAvailable()) { - return true; - } - } - } - } - return false; - } - - /** - * To check if the device is connected to a mobile or wifi network - * - * @param activity - The activity to use as context to retrieve a wifi manager and a connectivity manager via getSystemService - * - * @return bool - If the device is currently connected to a mobile or wifi network - */ - public boolean isDeviceConnectedToMobileOrWifiNetwork(Activity activity) { - if (activity != null && !activity.isFinishing()) { - ConnectivityManager connectivityManager = mGetManagerUtil.getConnectivityManager(activity); - if (connectivityManager != null) { - NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); - if (networkInfo.isConnected() && networkInfo.isAvailable()) { - return true; - } - } - } - return false; - } - - /** - * To check if the device is connected to a given SSID - * - * Used by connectToNetwork - * - * @param activity - The activity to use as context to retrieve a wifi manager and a connectivity manager via getSystemService - * @param ssid - The SSID to check if the device is attached to - * - * @return bool - If the device is currently attached to the given SSID - */ - public boolean isDeviceConnectedToSSID(Activity activity, String ssid) { - if (activity == null || activity.isFinishing()) { - mLogUtil.w(TAG, "Breaking due to no activity", loggingEnabled); - return false; - } - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - WifiInfo connectionInfo = wifiManager.getConnectionInfo(); - if (connectionInfo != null && connectionInfo.getSSID() != null) { - String currentSSID = connectionInfo.getSSID().replaceAll("\"", ""); - mLogUtil.d(TAG, "Current SSID: " + currentSSID, loggingEnabled); - - if (currentSSID.equals(ssid)) { - mLogUtil.d(TAG, "Correct SSID", loggingEnabled); - ConnectivityManager connectivityManager = mGetManagerUtil.getConnectivityManager(activity); - if (connectivityManager != null - && connectivityManager.getActiveNetworkInfo() != null - && connectivityManager.getActiveNetworkInfo().isAvailable() - && connectivityManager.getActiveNetworkInfo().isConnected()) { - mLogUtil.d(TAG, "Network is connected", loggingEnabled); - return true; - } - } - } - } - return false; - } - - /** - * To check if the device is connected to a wifi network - * - * @param activity - The activity to use as context to retrieve a wifi manager and a connectivity manager via getSystemService - * - * @return bool - If the device is currently connected to a wifi network - */ - public boolean isDeviceConnectedToWifiNetwork(Activity activity) { - if (activity != null && !activity.isFinishing()) { - ConnectivityManager connectivityManager = mGetManagerUtil.getConnectivityManager(activity); - if (connectivityManager != null) { - NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); - if (networkInfo != null && networkInfo.getTypeName().equalsIgnoreCase("WIFI")) { - if (networkInfo.isConnected() && networkInfo.isAvailable()) { - return true; - } - } - } - } - return false; - } - - /** - * To check if an SSID is in the list of configured networks - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * - * @return boolean - If the SSID is in the list of configured networks - */ - public boolean isNetworkInConfigurationList(Activity activity, String ssid) { - if (activity != null && !activity.isFinishing()) { - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if(wifiManager != null) { - return isNetworkInConfigurationList(wifiManager, ssid); - } - } else { - mLogUtil.w(TAG, "No activity to check if network is in configuration list", loggingEnabled); - } - return false; - } - - /** - * To check and return if a network is secure (WEP/PSK/EAP capabilities) - * - * @param scanResult - The network to see if it is secure - * - * @return boolean - Whether the network is secure - */ - public boolean isNetworkSecure(ScanResult scanResult) { - boolean isSecure = false; - if (scanResult != null && scanResult.capabilities != null) { - if (scanResult.capabilities.contains("WEP") || scanResult.capabilities.contains("PSK") || scanResult.capabilities.contains("EAP")) { - isSecure = true; - } - } - return isSecure; - } - - /** - * To check if Wifi is enabled on the device or not - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * - * @return boolean - if Wifi is enabled on device - */ - public boolean isWifiEnabled(Activity activity) { - if (activity != null && !activity.isFinishing()) { - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - return wifiManager.isWifiEnabled(); - } - } else { - mLogUtil.w(TAG, "No activity to check if wifi is enabled", loggingEnabled); - } - return false; - } - - /** - * To remove a configured network - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * @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 - */ - public boolean removeNetwork(Activity activity, String ssidToRemove) { - if (activity != null && !activity.isFinishing()) { - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - List list = wifiManager.getConfiguredNetworks(); - if (list != null) { - for (int i = 0; i < list.size(); i++) { - WifiConfiguration wifiConfiguration = list.get(i); - if (wifiConfiguration != null && wifiConfiguration.SSID != null) { - String ssidInList = wifiConfiguration.SSID.replaceAll("\"", ""); - - mLogUtil.d(TAG, "Configured WiFi Network {index:" + i + ", ssidInList:" + ssidInList + "}", loggingEnabled); - if (ssidInList.equals(ssidToRemove)) { - mLogUtil.d(TAG, "Removing network: " + ssidToRemove, loggingEnabled); - wifiManager.disconnect(); - boolean result = wifiManager.removeNetwork(wifiConfiguration.networkId); - if (result) { - mLogUtil.d(TAG, "Successfully removed network", loggingEnabled); - wifiManager.saveConfiguration(); - } else { - mLogUtil.d(TAG, "Failed to remove network", loggingEnabled); - } - wifiManager.reconnect(); - return result; - } - } - } - } - - } - mLogUtil.w(TAG, "SSID to remove: " + ssidToRemove + " was not found in list to remove network", loggingEnabled); - } else { - mLogUtil.w(TAG, "No activity to remove network", loggingEnabled); - } - return false; - } - - /** - * To search local networks and return the first one that contains a given ssid (non-case sensitive) - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * @param ssidToSearchFor - The ssid to search for - * @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) - */ - public String searchForSSID(Activity activity, String ssidToSearchFor, int timeoutInMillis) { - if (activity != null && !activity.isFinishing()) { - WifiManager wifiManager = mGetManagerUtil.getWiFiManager(activity); - if (wifiManager != null) { - int scanPass = 1; - long currentTime; - long endTime = System.currentTimeMillis() + timeoutInMillis; - LogUtil.getInstance().d(TAG, "End time (searchForSSID): " + endTime, loggingEnabled); - do { - mLogUtil.d(TAG, "Scanning SSIDs, pass " + scanPass, loggingEnabled); - wifiManager.startScan(); - List networks = wifiManager.getScanResults(); - for (ScanResult scanResult : networks) { - mLogUtil.d(TAG, "scanResult.SSID: " + scanResult.SSID, loggingEnabled); - if (scanResult.SSID != null && (scanResult.SSID.toUpperCase().contains(ssidToSearchFor.toUpperCase()))) { - mLogUtil.d(TAG, "Found match, SSID: " + scanResult.SSID, loggingEnabled); - return scanResult.SSID; - } - } - - try { - Thread.sleep(1000); - } catch (InterruptedException ie) { - // Do nothing - } - currentTime = System.currentTimeMillis(); - LogUtil.getInstance().d(TAG, "Current time (searchForSSID): " + endTime, loggingEnabled); - scanPass++; - } while(currentTime < endTime); - } - } else { - mLogUtil.w(TAG, "No activity to search for SSID", loggingEnabled); - } - return null; - } - - /** - * To query if logging is enabled or disabled for a WiseFy instance - * - * @return boolean - If logging is enabled for the WiseFy instance - */ - @VisibleForTesting - public boolean isLoggingEnabled() { - return loggingEnabled; - } - - /** - * HELPERS - */ - - /** - * Used internally by addOpenNetwork, addWEPNetwork, and addWPA2Network to add and save a new wifi configuration - * - * @param wifiManager - A wifi manager instance to add the network - * @param wifiConfig - The network to configuration to add - * - * @return int - The return code from WifiManager for network creation (-1 for failure) - */ - private int addNetwork(WifiManager wifiManager, WifiConfiguration wifiConfig) { - int result = wifiManager.addNetwork(wifiConfig); - if (result != WIFI_MANAGER_FAILURE) { - mLogUtil.d(TAG, "Successfully added network", loggingEnabled); - wifiManager.saveConfiguration(); - } else { - mLogUtil.e(TAG, "Failed to add network", loggingEnabled); - } - return result; - } - - /** - * Used internally by addOpenNetwork, addWEPNetwork, addWPA2Network, and - * isNetworkInConfigurationList to see if an ssid is already saved (CASE SENSITIVE!) - * - * @param wifiManager - A wifi manager instance to search for the ssid - * @param ssid - The ssid to check for in the configured network list - * - * @return boolean - If the ssid was found in the configuration list - */ - private boolean isNetworkInConfigurationList(WifiManager wifiManager, String ssid) { - List list = wifiManager.getConfiguredNetworks(); - if (list != null && list.size() > 0) { - for (int i = 0; i < list.size(); i++) { - WifiConfiguration wifiConfiguration = list.get(i); - if (wifiConfiguration != null && wifiConfiguration.SSID != null) { - String ssidInList = wifiConfiguration.SSID.replaceAll("\"", ""); - mLogUtil.d(TAG, "SSID in list: " + ssidInList + ", SSID: " + ssid, loggingEnabled); - if (ssidInList.equals(ssid)) { - mLogUtil.d(TAG, "Found SSID in list", loggingEnabled); - return true; - } - } - } - } else { - mLogUtil.w(TAG, "Found 0 configured networks", loggingEnabled); - } - return false; - } - - /** - * Used internally by connectToNetwork to check if the device connects to - * a given SSID within a specified time (timeout is in millis) - * - * @param activity - The activity to use as context to retrieve a wifi manager via getSystemService - * @param ssid - The ssid to wait for the device to connect to - * @param timeoutInMillis - The number of milliseconds to wait - * - * @return boolean - If the device is connected to the ssid in the given time - */ - private boolean waitToConnectToSSID(Activity activity, String ssid, int timeoutInMillis) { - long currentTime; - long endTime = System.currentTimeMillis() + timeoutInMillis; - LogUtil.getInstance().d(TAG, "End time (waitToConnectToSSID): " + endTime, loggingEnabled); - do { - boolean result = isDeviceConnectedToSSID(activity, ssid); - if (result) { - return result; - } - try { - Thread.sleep(1000); - } catch (InterruptedException ie) { - // Do nothing - } - currentTime = System.currentTimeMillis(); - LogUtil.getInstance().d(TAG, "Current time (waitToConnectToSSID): " + endTime, loggingEnabled); - } while(currentTime < endTime); - return false; - } -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index c0fee68a..c6d8b627 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,14 @@ buildscript { repositories { jcenter() + maven { + url "https://plugins.gradle.org/m2/" + } } dependencies { - classpath 'com.android.tools.build:gradle:2.2.1' + classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.6' + classpath "com.github.dcendents:android-maven-gradle-plugin:1.5" classpath "org.jacoco:org.jacoco.core:0.7.7.201606060606" classpath "org.jacoco:org.jacoco.agent:0.7.7.201606060606" classpath "org.jacoco:org.jacoco.report:0.7.7.201606060606" diff --git a/javadoc/allclasses-frame.html b/javadoc/allclasses-frame.html new file mode 100644 index 00000000..224afb9a --- /dev/null +++ b/javadoc/allclasses-frame.html @@ -0,0 +1,23 @@ + + + + + +All Classes (app 1.0.4 API) + + + + + +

All Classes

+ + + diff --git a/javadoc/allclasses-noframe.html b/javadoc/allclasses-noframe.html new file mode 100644 index 00000000..abac2f59 --- /dev/null +++ b/javadoc/allclasses-noframe.html @@ -0,0 +1,23 @@ + + + + + +All Classes (app 1.0.4 API) + + + + + +

All Classes

+ + + diff --git a/javadoc/com/isupatches/wisefy/WiseFy.generator.html b/javadoc/com/isupatches/wisefy/WiseFy.generator.html new file mode 100644 index 00000000..09fe1b87 --- /dev/null +++ b/javadoc/com/isupatches/wisefy/WiseFy.generator.html @@ -0,0 +1,327 @@ + + + + + +WiseFy.generator (app 1.0.4 API) + + + + + + + + + + + + +
+
com.isupatches.wisefy
+

Class WiseFy.generator

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.isupatches.wisefy.WiseFy.generator
    • +
    +
  • +
+
+
    +
  • +
    +
    Enclosing class:
    +
    WiseFy
    +
    +
    +
    +
    public static class WiseFy.generator
    +extends java.lang.Object
    +
    Internal static class for builder pattern
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      generator() 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      WiseFygetSmarts() +
      Mandatory - To build and return a WiseFy instance
      +
      WiseFy.generatorlogging(boolean loggingEnabled) +
      Non-mandatory - To enable/disable logging for the WiseFy instance
      +
      com.isupatches.wisefy.WiseFy.GetSmartswithContext(android.content.Context context) +
      Mandatory - The context to get a WiFi and Connectivity manager
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

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

      Constructor Detail

      + + + +
        +
      • +

        generator

        +
        public generator()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        withContext

        +
        public com.isupatches.wisefy.WiseFy.GetSmarts withContext(android.content.Context context)
        +
        Mandatory - The context to get a WiFi and Connectivity manager
        +
        +
        Parameters:
        +
        context - - The activity or application context + WithContext
        +
        Returns:
        +
        generator - The builder with updated context
        +
        +
      • +
      + + + +
        +
      • +

        logging

        +
        public WiseFy.generator logging(boolean loggingEnabled)
        +
        Non-mandatory - To enable/disable logging for the WiseFy instance
        +
        +
        Parameters:
        +
        loggingEnabled - - If logging is enabled or disabled + GetSmarts
        +
        Returns:
        +
        generator - The builder with updated logging setting
        +
        +
      • +
      + + + +
        +
      • +

        getSmarts

        +
        public WiseFy getSmarts()
        +
        Mandatory - To build and return a WiseFy instance
        +
        +
        Returns:
        +
        WiseFy - The instance created by the builder
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/com/isupatches/wisefy/WiseFy.html b/javadoc/com/isupatches/wisefy/WiseFy.html new file mode 100644 index 00000000..e70b57dc --- /dev/null +++ b/javadoc/com/isupatches/wisefy/WiseFy.html @@ -0,0 +1,821 @@ + + + + + +WiseFy (app 1.0.4 API) + + + + + + + + + + + + +
+
com.isupatches.wisefy
+

Class WiseFy

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.isupatches.wisefy.WiseFy
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class WiseFy
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Nested Class Summary

      + + + + + + + + + + +
      Nested Classes 
      Modifier and TypeClass and Description
      static class WiseFy.generator +
      Internal static class for builder pattern
      +
      +
    • +
    + + + +
      +
    • + + +

      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
      +
      intaddWEPNetwork(java.lang.String ssid, + java.lang.String password) +
      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
      +
      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/reconnects to the given ssid, and then calls waitToConnectToSSID to verify connectivity
      +
      booleandisableWifi() +
      To disable Wifi on a user's device
      +
      booleandisconnectFromCurrentNetwork() +
      To disconnect the user from their current network
      +
      booleanenableWifi() +
      To enable Wifi on a user's device
      +
      android.net.wifi.WifiInfogetCurrentNetwork() +
      To retrieve the user's current 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 not return SSIDs with a weaker signal strength (will always take the highest)
      +
      java.util.List<android.net.wifi.WifiConfiguration>getSavedNetworks() +
      To retrieve a list of saved networks on a user's device
      +
      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 + + Used by connectToNetwork
      +
      booleanisDeviceConnectedToWifiNetwork() +
      To check if the device is connected to a wifi network
      +
      booleanisLoggingEnabled() +
      To query if logging is enabled or disabled for a WiseFy instance
      +
      booleanisNetworkInConfigurationList(java.lang.String ssid) +
      To check if an SSID is in the list of configured networks
      +
      booleanisNetworkSecure(android.net.wifi.ScanResult scanResult) +
      To check and return if a network is secure (WEP/PSK/EAP capabilities)
      +
      booleanisWifiEnabled() +
      To check if Wifi is enabled on the device or not
      +
      booleanremoveNetwork(java.lang.String ssidToRemove) +
      To remove a configured network
      +
      java.lang.StringsearchForSSID(java.lang.String ssidToSearchFor, + int timeoutInMillis) +
      To search local networks and return the first one that contains a given ssid (non-case sensitive)
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

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

      Field Detail

      + + + +
        +
      • +

        WISE_MANAGER_FAILURE

        +
        public static final int WISE_MANAGER_FAILURE
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        WIFI_MANAGER_FAILURE

        +
        public static final int WIFI_MANAGER_FAILURE
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        mConnectivityManager

        +
        public android.net.ConnectivityManager mConnectivityManager
        +
      • +
      + + + +
        +
      • +

        mWifiManager

        +
        public android.net.wifi.WifiManager mWifiManager
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        addOpenNetwork

        +
        public int addOpenNetwork(java.lang.String ssid)
        +
        To add an open network to the user's configured network list
        +
        +
        Parameters:
        +
        ssid - - The ssid of the open network you want to add
        +
        Returns:
        +
        int - The return code from WifiManager for network creation (-1 for failure)
        +
        +
      • +
      + + + +
        +
      • +

        addWEPNetwork

        +
        public int addWEPNetwork(java.lang.String ssid,
        +                         java.lang.String password)
        +
        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
        +
        Returns:
        +
        int - The return code from WifiManager for network creation (-1 for failure)
        +
        +
      • +
      + + + +
        +
      • +

        addWPA2Network

        +
        public int addWPA2Network(java.lang.String ssid,
        +                          java.lang.String password)
        +
        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
        +
        Returns:
        +
        int - The return code from WifiManager for network creation (-1 for failure)
        +
        +
      • +
      + + + +
        +
      • +

        calculateBars

        +
        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

        +
        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

        +
        public boolean connectToNetwork(java.lang.String ssidToConnectTo,
        +                                int timeoutInMillis)
        +
        Used to connect to a network + + Gets a list of saved networks, connects/reconnects to the given ssid, and then calls waitToConnectToSSID to verify 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
        +
        +
      • +
      + + + +
        +
      • +

        disableWifi

        +
        public boolean disableWifi()
        +
        To disable Wifi on a user's device
        +
        +
        Returns:
        +
        boolean - If the command succeeded in disabling wifi
        +
        +
      • +
      + + + +
        +
      • +

        disconnectFromCurrentNetwork

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        enableWifi

        +
        public boolean enableWifi()
        +
        To enable Wifi on a user's device
        +
        +
        Returns:
        +
        boolean - If the command succeeded in enabling wifi
        +
        +
      • +
      + + + +
        +
      • +

        getCurrentNetwork

        +
        public android.net.wifi.WifiInfo getCurrentNetwork()
        +
        To retrieve the user's current network
        +
        +
        Returns:
        +
        WifiInfo|null - The user's current network information
        +
        +
      • +
      + + + +
        +
      • +

        getNearbyAccessPoints

        +
        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 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
        +
        Returns:
        +
        List of ScanResults|null - List of nearby access points
        +
        +
      • +
      + + + +
        +
      • +

        getSavedNetworks

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        isDeviceConnectedToMobileNetwork

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        isDeviceConnectedToMobileOrWifiNetwork

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        isDeviceConnectedToSSID

        +
        public boolean isDeviceConnectedToSSID(java.lang.String ssid)
        +
        To check if the device is connected to a given SSID + + Used by connectToNetwork
        +
        +
        Parameters:
        +
        ssid - - The SSID to check if the device is attached to
        +
        Returns:
        +
        bool - If the device is currently attached to the given SSID
        +
        +
      • +
      + + + +
        +
      • +

        isDeviceConnectedToWifiNetwork

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        isNetworkInConfigurationList

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        isNetworkSecure

        +
        public boolean isNetworkSecure(android.net.wifi.ScanResult scanResult)
        +
        To check and return if a network is secure (WEP/PSK/EAP capabilities)
        +
        +
        Parameters:
        +
        scanResult - - The network to see if it is secure
        +
        Returns:
        +
        boolean - Whether the network is secure
        +
        +
      • +
      + + + +
        +
      • +

        isWifiEnabled

        +
        public boolean isWifiEnabled()
        +
        To check if Wifi is enabled on the device or not
        +
        +
        Returns:
        +
        boolean - if Wifi is enabled on device
        +
        +
      • +
      + + + +
        +
      • +

        removeNetwork

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        searchForSSID

        +
        public java.lang.String searchForSSID(java.lang.String ssidToSearchFor,
        +                                      int timeoutInMillis)
        +
        To search local networks and return the first one that contains a given ssid (non-case sensitive)
        +
        +
        Parameters:
        +
        ssidToSearchFor - - The ssid to search for
        +
        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)
        +
        +
      • +
      + + + +
        +
      • +

        isLoggingEnabled

        +
        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
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/com/isupatches/wisefy/package-frame.html b/javadoc/com/isupatches/wisefy/package-frame.html new file mode 100644 index 00000000..fbb09079 --- /dev/null +++ b/javadoc/com/isupatches/wisefy/package-frame.html @@ -0,0 +1,21 @@ + + + + + +com.isupatches.wisefy (app 1.0.4 API) + + + + + +

com.isupatches.wisefy

+
+

Classes

+ +
+ + diff --git a/javadoc/com/isupatches/wisefy/package-summary.html b/javadoc/com/isupatches/wisefy/package-summary.html new file mode 100644 index 00000000..51262cdb --- /dev/null +++ b/javadoc/com/isupatches/wisefy/package-summary.html @@ -0,0 +1,146 @@ + + + + + +com.isupatches.wisefy (app 1.0.4 API) + + + + + + + + + + + +
+

Package com.isupatches.wisefy

+
+
+
    +
  • + + + + + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    WiseFy 
    WiseFy.generator +
    Internal static class for builder pattern
    +
    +
  • +
+
+ + + + + + diff --git a/javadoc/com/isupatches/wisefy/package-tree.html b/javadoc/com/isupatches/wisefy/package-tree.html new file mode 100644 index 00000000..f4b195b7 --- /dev/null +++ b/javadoc/com/isupatches/wisefy/package-tree.html @@ -0,0 +1,136 @@ + + + + + +com.isupatches.wisefy Class Hierarchy (app 1.0.4 API) + + + + + + + + + + + +
+

Hierarchy For Package com.isupatches.wisefy

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ + + + + + diff --git a/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html b/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html new file mode 100644 index 00000000..5ee56b2b --- /dev/null +++ b/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html @@ -0,0 +1,289 @@ + + + + + +GetManagerUtil (app 1.0.4 API) + + + + + + + + + + + + +
+
com.isupatches.wisefy.util
+

Class GetManagerUtil

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.isupatches.wisefy.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 new file mode 100644 index 00000000..4fceabc8 --- /dev/null +++ b/javadoc/com/isupatches/wisefy/util/LogUtil.html @@ -0,0 +1,290 @@ + + + + + +LogUtil (app 1.0.4 API) + + + + + + + + + + + + +
+
com.isupatches.wisefy.util
+

Class LogUtil

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.isupatches.wisefy.util.LogUtil
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class LogUtil
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      voidd(java.lang.String tag, + java.lang.String message, + boolean loggingEnabled) 
      voide(java.lang.String tag, + java.lang.String message, + boolean loggingEnabled) 
      static LogUtilgetInstance() 
      voidw(java.lang.String tag, + java.lang.String message, + boolean loggingEnabled) 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

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

      Method Detail

      + + + +
        +
      • +

        getInstance

        +
        public static LogUtil getInstance()
        +
        +
        Returns:
        +
        instance of LogUtil
        +
        +
      • +
      + + + +
        +
      • +

        d

        +
        public void d(java.lang.String tag,
        +              java.lang.String message,
        +              boolean loggingEnabled)
        +
      • +
      + + + +
        +
      • +

        w

        +
        public void w(java.lang.String tag,
        +              java.lang.String message,
        +              boolean loggingEnabled)
        +
      • +
      + + + +
        +
      • +

        e

        +
        public void e(java.lang.String tag,
        +              java.lang.String message,
        +              boolean loggingEnabled)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/com/isupatches/wisefy/util/SSIDUtil.html b/javadoc/com/isupatches/wisefy/util/SSIDUtil.html new file mode 100644 index 00000000..1f312a55 --- /dev/null +++ b/javadoc/com/isupatches/wisefy/util/SSIDUtil.html @@ -0,0 +1,252 @@ + + + + + +SSIDUtil (app 1.0.4 API) + + + + + + + + + + + + +
+
com.isupatches.wisefy.util
+

Class SSIDUtil

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.isupatches.wisefy.util.SSIDUtil
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class SSIDUtil
    +extends java.lang.Object
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getInstance

        +
        public static SSIDUtil getInstance()
        +
        +
        Returns:
        +
        instance of SSIDUtil
        +
        +
      • +
      + + + +
        +
      • +

        convertSSIDForConfig

        +
        public java.lang.String convertSSIDForConfig(java.lang.String ssid)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/com/isupatches/wisefy/util/package-frame.html b/javadoc/com/isupatches/wisefy/util/package-frame.html new file mode 100644 index 00000000..a282b641 --- /dev/null +++ b/javadoc/com/isupatches/wisefy/util/package-frame.html @@ -0,0 +1,22 @@ + + + + + +com.isupatches.wisefy.util (app 1.0.4 API) + + + + + +

com.isupatches.wisefy.util

+
+

Classes

+ +
+ + diff --git a/javadoc/com/isupatches/wisefy/util/package-summary.html b/javadoc/com/isupatches/wisefy/util/package-summary.html new file mode 100644 index 00000000..f19c4115 --- /dev/null +++ b/javadoc/com/isupatches/wisefy/util/package-summary.html @@ -0,0 +1,148 @@ + + + + + +com.isupatches.wisefy.util (app 1.0.4 API) + + + + + + + + + + + +
+

Package com.isupatches.wisefy.util

+
+
+ +
+ + + + + + diff --git a/javadoc/com/isupatches/wisefy/util/package-tree.html b/javadoc/com/isupatches/wisefy/util/package-tree.html new file mode 100644 index 00000000..715df538 --- /dev/null +++ b/javadoc/com/isupatches/wisefy/util/package-tree.html @@ -0,0 +1,137 @@ + + + + + +com.isupatches.wisefy.util Class Hierarchy (app 1.0.4 API) + + + + + + + + + + + +
+

Hierarchy For Package com.isupatches.wisefy.util

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ + + + + + diff --git a/javadoc/com/metova/wisefy/WiseFy.generator.html b/javadoc/com/metova/wisefy/WiseFy.generator.html new file mode 100644 index 00000000..a4206792 --- /dev/null +++ b/javadoc/com/metova/wisefy/WiseFy.generator.html @@ -0,0 +1,327 @@ + + + + + +WiseFy.generator (app 1.0.4 API) + + + + + + + + + + + + +
+
com.isupatches.wisefy
+

Class WiseFy.generator

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.isupatches.wisefy.WiseFy.generator
    • +
    +
  • +
+
+
    +
  • +
    +
    Enclosing class:
    +
    WiseFy
    +
    +
    +
    +
    public static class WiseFy.generator
    +extends java.lang.Object
    +
    Internal static class for builder pattern
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      generator() 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      WiseFygetSmarts() +
      Mandatory - To build and return a WiseFy instance
      +
      WiseFy.generatorlogging(boolean loggingEnabled) +
      Non-mandatory - To enable/disable logging for the WiseFy instance
      +
      com.isupatches.wisefy.WiseFy.GetSmartswithContext(android.content.Context context) +
      Mandatory - The context to get a WiFi and Connectivity manager
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

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

      Constructor Detail

      + + + +
        +
      • +

        generator

        +
        public generator()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        withContext

        +
        public com.isupatches.wisefy.WiseFy.GetSmarts withContext(android.content.Context context)
        +
        Mandatory - The context to get a WiFi and Connectivity manager
        +
        +
        Parameters:
        +
        context - - The activity or application context + WithContext
        +
        Returns:
        +
        generator - The builder with updated context
        +
        +
      • +
      + + + +
        +
      • +

        logging

        +
        public WiseFy.generator logging(boolean loggingEnabled)
        +
        Non-mandatory - To enable/disable logging for the WiseFy instance
        +
        +
        Parameters:
        +
        loggingEnabled - - If logging is enabled or disabled + GetSmarts
        +
        Returns:
        +
        generator - The builder with updated logging setting
        +
        +
      • +
      + + + +
        +
      • +

        getSmarts

        +
        public WiseFy getSmarts()
        +
        Mandatory - To build and return a WiseFy instance
        +
        +
        Returns:
        +
        WiseFy - The instance created by the builder
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/com/metova/wisefy/WiseFy.html b/javadoc/com/metova/wisefy/WiseFy.html new file mode 100644 index 00000000..de5c397d --- /dev/null +++ b/javadoc/com/metova/wisefy/WiseFy.html @@ -0,0 +1,821 @@ + + + + + +WiseFy (app 1.0.4 API) + + + + + + + + + + + + +
+
com.isupatches.wisefy
+

Class WiseFy

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.isupatches.wisefy.WiseFy
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class WiseFy
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Nested Class Summary

      + + + + + + + + + + +
      Nested Classes 
      Modifier and TypeClass and Description
      static class WiseFy.generator +
      Internal static class for builder pattern
      +
      +
    • +
    + + + +
      +
    • + + +

      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
      +
      intaddWEPNetwork(java.lang.String ssid, + java.lang.String password) +
      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
      +
      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/reconnects to the given ssid, and then calls waitToConnectToSSID to verify connectivity
      +
      booleandisableWifi() +
      To disable Wifi on a user's device
      +
      booleandisconnectFromCurrentNetwork() +
      To disconnect the user from their current network
      +
      booleanenableWifi() +
      To enable Wifi on a user's device
      +
      android.net.wifi.WifiInfogetCurrentNetwork() +
      To retrieve the user's current 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 not return SSIDs with a weaker signal strength (will always take the highest)
      +
      java.util.List<android.net.wifi.WifiConfiguration>getSavedNetworks() +
      To retrieve a list of saved networks on a user's device
      +
      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 + + Used by connectToNetwork
      +
      booleanisDeviceConnectedToWifiNetwork() +
      To check if the device is connected to a wifi network
      +
      booleanisLoggingEnabled() +
      To query if logging is enabled or disabled for a WiseFy instance
      +
      booleanisNetworkInConfigurationList(java.lang.String ssid) +
      To check if an SSID is in the list of configured networks
      +
      booleanisNetworkSecure(android.net.wifi.ScanResult scanResult) +
      To check and return if a network is secure (WEP/PSK/EAP capabilities)
      +
      booleanisWifiEnabled() +
      To check if Wifi is enabled on the device or not
      +
      booleanremoveNetwork(java.lang.String ssidToRemove) +
      To remove a configured network
      +
      java.lang.StringsearchForSSID(java.lang.String ssidToSearchFor, + int timeoutInMillis) +
      To search local networks and return the first one that contains a given ssid (non-case sensitive)
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

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

      Field Detail

      + + + +
        +
      • +

        WISE_MANAGER_FAILURE

        +
        public static final int WISE_MANAGER_FAILURE
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        WIFI_MANAGER_FAILURE

        +
        public static final int WIFI_MANAGER_FAILURE
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        mConnectivityManager

        +
        public android.net.ConnectivityManager mConnectivityManager
        +
      • +
      + + + +
        +
      • +

        mWifiManager

        +
        public android.net.wifi.WifiManager mWifiManager
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        addOpenNetwork

        +
        public int addOpenNetwork(java.lang.String ssid)
        +
        To add an open network to the user's configured network list
        +
        +
        Parameters:
        +
        ssid - - The ssid of the open network you want to add
        +
        Returns:
        +
        int - The return code from WifiManager for network creation (-1 for failure)
        +
        +
      • +
      + + + +
        +
      • +

        addWEPNetwork

        +
        public int addWEPNetwork(java.lang.String ssid,
        +                         java.lang.String password)
        +
        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
        +
        Returns:
        +
        int - The return code from WifiManager for network creation (-1 for failure)
        +
        +
      • +
      + + + +
        +
      • +

        addWPA2Network

        +
        public int addWPA2Network(java.lang.String ssid,
        +                          java.lang.String password)
        +
        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
        +
        Returns:
        +
        int - The return code from WifiManager for network creation (-1 for failure)
        +
        +
      • +
      + + + +
        +
      • +

        calculateBars

        +
        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

        +
        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

        +
        public boolean connectToNetwork(java.lang.String ssidToConnectTo,
        +                                int timeoutInMillis)
        +
        Used to connect to a network + + Gets a list of saved networks, connects/reconnects to the given ssid, and then calls waitToConnectToSSID to verify 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
        +
        +
      • +
      + + + +
        +
      • +

        disableWifi

        +
        public boolean disableWifi()
        +
        To disable Wifi on a user's device
        +
        +
        Returns:
        +
        boolean - If the command succeeded in disabling wifi
        +
        +
      • +
      + + + +
        +
      • +

        disconnectFromCurrentNetwork

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        enableWifi

        +
        public boolean enableWifi()
        +
        To enable Wifi on a user's device
        +
        +
        Returns:
        +
        boolean - If the command succeeded in enabling wifi
        +
        +
      • +
      + + + +
        +
      • +

        getCurrentNetwork

        +
        public android.net.wifi.WifiInfo getCurrentNetwork()
        +
        To retrieve the user's current network
        +
        +
        Returns:
        +
        WifiInfo|null - The user's current network information
        +
        +
      • +
      + + + +
        +
      • +

        getNearbyAccessPoints

        +
        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 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
        +
        Returns:
        +
        List of ScanResults|null - List of nearby access points
        +
        +
      • +
      + + + +
        +
      • +

        getSavedNetworks

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        isDeviceConnectedToMobileNetwork

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        isDeviceConnectedToMobileOrWifiNetwork

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        isDeviceConnectedToSSID

        +
        public boolean isDeviceConnectedToSSID(java.lang.String ssid)
        +
        To check if the device is connected to a given SSID + + Used by connectToNetwork
        +
        +
        Parameters:
        +
        ssid - - The SSID to check if the device is attached to
        +
        Returns:
        +
        bool - If the device is currently attached to the given SSID
        +
        +
      • +
      + + + +
        +
      • +

        isDeviceConnectedToWifiNetwork

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        isNetworkInConfigurationList

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        isNetworkSecure

        +
        public boolean isNetworkSecure(android.net.wifi.ScanResult scanResult)
        +
        To check and return if a network is secure (WEP/PSK/EAP capabilities)
        +
        +
        Parameters:
        +
        scanResult - - The network to see if it is secure
        +
        Returns:
        +
        boolean - Whether the network is secure
        +
        +
      • +
      + + + +
        +
      • +

        isWifiEnabled

        +
        public boolean isWifiEnabled()
        +
        To check if Wifi is enabled on the device or not
        +
        +
        Returns:
        +
        boolean - if Wifi is enabled on device
        +
        +
      • +
      + + + +
        +
      • +

        removeNetwork

        +
        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
        +
        +
      • +
      + + + +
        +
      • +

        searchForSSID

        +
        public java.lang.String searchForSSID(java.lang.String ssidToSearchFor,
        +                                      int timeoutInMillis)
        +
        To search local networks and return the first one that contains a given ssid (non-case sensitive)
        +
        +
        Parameters:
        +
        ssidToSearchFor - - The ssid to search for
        +
        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)
        +
        +
      • +
      + + + +
        +
      • +

        isLoggingEnabled

        +
        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
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/com/metova/wisefy/package-frame.html b/javadoc/com/metova/wisefy/package-frame.html new file mode 100644 index 00000000..193d7b98 --- /dev/null +++ b/javadoc/com/metova/wisefy/package-frame.html @@ -0,0 +1,21 @@ + + + + + +com.isupatches.wisefy (app 1.0.4 API) + + + + + +

com.isupatches.wisefy

+
+

Classes

+ +
+ + diff --git a/javadoc/com/metova/wisefy/package-summary.html b/javadoc/com/metova/wisefy/package-summary.html new file mode 100644 index 00000000..174eb4e8 --- /dev/null +++ b/javadoc/com/metova/wisefy/package-summary.html @@ -0,0 +1,145 @@ + + + + + +com.isupatches.wisefy (app 1.0.4 API) + + + + + + + + + + + +
+

Package com.isupatches.wisefy

+
+
+
    +
  • + + + + + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    WiseFy 
    WiseFy.generator +
    Internal static class for builder pattern
    +
    +
  • +
+
+ + + + + + diff --git a/javadoc/com/metova/wisefy/package-tree.html b/javadoc/com/metova/wisefy/package-tree.html new file mode 100644 index 00000000..e33d8528 --- /dev/null +++ b/javadoc/com/metova/wisefy/package-tree.html @@ -0,0 +1,135 @@ + + + + + +com.isupatches.wisefy Class Hierarchy (app 1.0.4 API) + + + + + + + + + + + +
+

Hierarchy For Package com.isupatches.wisefy

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ + + + + + diff --git a/javadoc/com/metova/wisefy/util/GetManagerUtil.html b/javadoc/com/metova/wisefy/util/GetManagerUtil.html new file mode 100644 index 00000000..c12e5c29 --- /dev/null +++ b/javadoc/com/metova/wisefy/util/GetManagerUtil.html @@ -0,0 +1,289 @@ + + + + + +GetManagerUtil (app 1.0.4 API) + + + + + + + + + + + + +
+
com.isupatches.wisefy.util
+

Class GetManagerUtil

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.isupatches.wisefy.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/metova/wisefy/util/LogUtil.html b/javadoc/com/metova/wisefy/util/LogUtil.html new file mode 100644 index 00000000..0f91f021 --- /dev/null +++ b/javadoc/com/metova/wisefy/util/LogUtil.html @@ -0,0 +1,290 @@ + + + + + +LogUtil (app 1.0.4 API) + + + + + + + + + + + + +
+
com.isupatches.wisefy.util
+

Class LogUtil

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.isupatches.wisefy.util.LogUtil
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class LogUtil
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      voidd(java.lang.String tag, + java.lang.String message, + boolean loggingEnabled) 
      voide(java.lang.String tag, + java.lang.String message, + boolean loggingEnabled) 
      static LogUtilgetInstance() 
      voidw(java.lang.String tag, + java.lang.String message, + boolean loggingEnabled) 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

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

      Method Detail

      + + + +
        +
      • +

        getInstance

        +
        public static LogUtil getInstance()
        +
        +
        Returns:
        +
        instance of LogUtil
        +
        +
      • +
      + + + +
        +
      • +

        d

        +
        public void d(java.lang.String tag,
        +              java.lang.String message,
        +              boolean loggingEnabled)
        +
      • +
      + + + +
        +
      • +

        w

        +
        public void w(java.lang.String tag,
        +              java.lang.String message,
        +              boolean loggingEnabled)
        +
      • +
      + + + +
        +
      • +

        e

        +
        public void e(java.lang.String tag,
        +              java.lang.String message,
        +              boolean loggingEnabled)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/com/metova/wisefy/util/SSIDUtil.html b/javadoc/com/metova/wisefy/util/SSIDUtil.html new file mode 100644 index 00000000..d1e6c91a --- /dev/null +++ b/javadoc/com/metova/wisefy/util/SSIDUtil.html @@ -0,0 +1,252 @@ + + + + + +SSIDUtil (app 1.0.4 API) + + + + + + + + + + + + +
+
com.isupatches.wisefy.util
+

Class SSIDUtil

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.isupatches.wisefy.util.SSIDUtil
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class SSIDUtil
    +extends java.lang.Object
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getInstance

        +
        public static SSIDUtil getInstance()
        +
        +
        Returns:
        +
        instance of SSIDUtil
        +
        +
      • +
      + + + +
        +
      • +

        convertSSIDForConfig

        +
        public java.lang.String convertSSIDForConfig(java.lang.String ssid)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/javadoc/com/metova/wisefy/util/package-frame.html b/javadoc/com/metova/wisefy/util/package-frame.html new file mode 100644 index 00000000..e78be43c --- /dev/null +++ b/javadoc/com/metova/wisefy/util/package-frame.html @@ -0,0 +1,22 @@ + + + + + +com.isupatches.wisefy.util (app 1.0.4 API) + + + + + +

com.isupatches.wisefy.util

+
+

Classes

+ +
+ + diff --git a/javadoc/com/metova/wisefy/util/package-summary.html b/javadoc/com/metova/wisefy/util/package-summary.html new file mode 100644 index 00000000..eac7a11a --- /dev/null +++ b/javadoc/com/metova/wisefy/util/package-summary.html @@ -0,0 +1,147 @@ + + + + + +com.isupatches.wisefy.util (app 1.0.4 API) + + + + + + + + + + + +
+

Package com.isupatches.wisefy.util

+
+
+ +
+ + + + + + diff --git a/javadoc/com/metova/wisefy/util/package-tree.html b/javadoc/com/metova/wisefy/util/package-tree.html new file mode 100644 index 00000000..2d56cf74 --- /dev/null +++ b/javadoc/com/metova/wisefy/util/package-tree.html @@ -0,0 +1,136 @@ + + + + + +com.isupatches.wisefy.util Class Hierarchy (app 1.0.4 API) + + + + + + + + + + + +
+

Hierarchy For Package com.isupatches.wisefy.util

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ + + + + + diff --git a/javadoc/constant-values.html b/javadoc/constant-values.html new file mode 100644 index 00000000..86cd2c3e --- /dev/null +++ b/javadoc/constant-values.html @@ -0,0 +1,158 @@ + + + + + +Constant Field Values (app 1.0.4 API) + + + + + + + + + + + +
+

Constant Field Values

+

Contents

+ +
+
+ + +

com.isupatches.*

+ +
+ + + + + + diff --git a/javadoc/deprecated-list.html b/javadoc/deprecated-list.html new file mode 100644 index 00000000..b0650931 --- /dev/null +++ b/javadoc/deprecated-list.html @@ -0,0 +1,122 @@ + + + + + +Deprecated List (app 1.0.4 API) + + + + + + + + +
+ + + + + + + +
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/help-doc.html b/javadoc/help-doc.html new file mode 100644 index 00000000..d0ad8f37 --- /dev/null +++ b/javadoc/help-doc.html @@ -0,0 +1,223 @@ + + + + + +API Help (app 1.0.4 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 new file mode 100644 index 00000000..a0119ffa --- /dev/null +++ b/javadoc/index-all.html @@ -0,0 +1,339 @@ + + + + + +Index (app 1.0.4 API) + + + + + + + + +
+ + + + + + + +
+ + +
A C D E G I L M R S W  + + +

A

+
+
addOpenNetwork(String) - Method in class com.isupatches.wisefy.WiseFy
+
+
To add an open network to the user's configured network list
+
+
addWEPNetwork(String, String) - Method in class com.isupatches.wisefy.WiseFy
+
+
To add a WEP network to the user's configured network list
+
+
addWPA2Network(String, String) - Method in class com.isupatches.wisefy.WiseFy
+
+
To add a WPA2 network to the user's configured network list
+
+
+ + + +

C

+
+
calculateBars(int, int) - Method in class com.isupatches.wisefy.WiseFy
+
+
To convert an RSSI level for a network to a number of bars
+
+
com.isupatches.wisefy - package com.isupatches.wisefy
+
 
+
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
+
+
connectToNetwork(String, int) - Method in class com.isupatches.wisefy.WiseFy
+
+
Used to connect to a network + + Gets a list of saved networks, connects/reconnects to the given ssid, and then calls waitToConnectToSSID to verify connectivity
+
+
convertSSIDForConfig(String) - Method in class com.isupatches.wisefy.util.SSIDUtil
+
 
+
+ + + +

D

+
+
d(String, String, boolean) - Method in class com.isupatches.wisefy.util.LogUtil
+
 
+
disableWifi() - Method in class com.isupatches.wisefy.WiseFy
+
+
To disable Wifi on a user's device
+
+
disconnectFromCurrentNetwork() - Method in class com.isupatches.wisefy.WiseFy
+
+
To disconnect the user from their current network
+
+
+ + + +

E

+
+
e(String, String, boolean) - Method in class com.isupatches.wisefy.util.LogUtil
+
 
+
enableWifi() - Method in class com.isupatches.wisefy.WiseFy
+
+
To enable Wifi on a user's device
+
+
+ + + +

G

+
+
generator() - Constructor for class com.isupatches.wisefy.WiseFy.generator
+
 
+
getConnectivityManager(Context) - Method in class com.isupatches.wisefy.util.GetManagerUtil
+
+
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
+
+
getInstance() - Static method in class com.isupatches.wisefy.util.GetManagerUtil
+
 
+
getInstance() - Static method in class com.isupatches.wisefy.util.LogUtil
+
 
+
getInstance() - Static method in class com.isupatches.wisefy.util.SSIDUtil
+
 
+
GetManagerUtil - Class in com.isupatches.wisefy.util
+
 
+
getNearbyAccessPoints(boolean) - 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)
+
+
getSavedNetworks() - Method in class com.isupatches.wisefy.WiseFy
+
+
To retrieve a list of saved networks on a user's device
+
+
getSmarts() - Method in class com.isupatches.wisefy.WiseFy.generator
+
+
Mandatory - To build and return a WiseFy instance
+
+
getWiFiManager(Context) - Method in class com.isupatches.wisefy.util.GetManagerUtil
+
+
To get a WiFi manger instance from an activity's context.
+
+
+ + + +

I

+
+
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 + + Used by connectToNetwork
+
+
isDeviceConnectedToWifiNetwork() - Method in class com.isupatches.wisefy.WiseFy
+
+
To check if the device is connected to a wifi network
+
+
isLoggingEnabled() - Method in class com.isupatches.wisefy.WiseFy
+
+
To query if logging is enabled or disabled for a WiseFy instance
+
+
isNetworkInConfigurationList(String) - Method in class com.isupatches.wisefy.WiseFy
+
+
To check if an SSID is in the list of configured networks
+
+
isNetworkSecure(ScanResult) - Method in class com.isupatches.wisefy.WiseFy
+
+
To check and return if a network is secure (WEP/PSK/EAP capabilities)
+
+
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.generator
+
+
Non-mandatory - To enable/disable logging for the WiseFy instance
+
+
LogUtil - Class in com.isupatches.wisefy.util
+
 
+
+ + + +

M

+
+
mConnectivityManager - Variable in class com.isupatches.wisefy.WiseFy
+
 
+
mWifiManager - Variable in class com.isupatches.wisefy.WiseFy
+
 
+
+ + + +

R

+
+
removeNetwork(String) - Method in class com.isupatches.wisefy.WiseFy
+
+
To remove a configured network
+
+
+ + + +

S

+
+
searchForSSID(String, int) - Method in class com.isupatches.wisefy.WiseFy
+
+
To search local networks and return the first one that contains a given ssid (non-case sensitive)
+
+
SSIDUtil - Class in com.isupatches.wisefy.util
+
 
+
+ + + +

W

+
+
w(String, String, boolean) - Method in class com.isupatches.wisefy.util.LogUtil
+
 
+
WIFI_MANAGER_FAILURE - Static variable in class com.isupatches.wisefy.WiseFy
+
 
+
WISE_MANAGER_FAILURE - Static variable in class com.isupatches.wisefy.WiseFy
+
 
+
WiseFy - Class in com.isupatches.wisefy
+
 
+
WiseFy.generator - Class in com.isupatches.wisefy
+
+
Internal static class for builder pattern
+
+
withContext(Context) - Method in class com.isupatches.wisefy.WiseFy.generator
+
+
Mandatory - The context to get a WiFi and Connectivity manager
+
+
+A C D E G I L M R S W 
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/index.html b/javadoc/index.html new file mode 100644 index 00000000..a92a8ded --- /dev/null +++ b/javadoc/index.html @@ -0,0 +1,74 @@ + + + + + +app 1.0.4 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 new file mode 100644 index 00000000..1f183387 --- /dev/null +++ b/javadoc/overview-frame.html @@ -0,0 +1,22 @@ + + + + + +Overview List (app 1.0.4 API) + + + + + + + +

 

+ + diff --git a/javadoc/overview-summary.html b/javadoc/overview-summary.html new file mode 100644 index 00000000..33187ddc --- /dev/null +++ b/javadoc/overview-summary.html @@ -0,0 +1,140 @@ + + + + + +Overview (app 1.0.4 API) + + + + + + + + +
+ + + + + + + +
+ + +
+

app 1.0.4 API

+
+
+ + + + + + + + + + + + + + + + +
Packages 
PackageDescription
com.isupatches.wisefy 
com.isupatches.wisefy.util 
+
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/overview-tree.html b/javadoc/overview-tree.html new file mode 100644 index 00000000..3ed22c93 --- /dev/null +++ b/javadoc/overview-tree.html @@ -0,0 +1,140 @@ + + + + + +Class Hierarchy (app 1.0.4 API) + + + + + + + + +
+ + + + + + + +
+ + +
+

Hierarchy For All Packages

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/javadoc/package-list b/javadoc/package-list new file mode 100644 index 00000000..b0c97570 --- /dev/null +++ b/javadoc/package-list @@ -0,0 +1,2 @@ +com.isupatches.wisefy +com.isupatches.wisefy.util diff --git a/javadoc/script.js b/javadoc/script.js new file mode 100644 index 00000000..b3463569 --- /dev/null +++ b/javadoc/script.js @@ -0,0 +1,30 @@ +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/stylesheet.css b/javadoc/stylesheet.css new file mode 100644 index 00000000..98055b22 --- /dev/null +++ b/javadoc/stylesheet.css @@ -0,0 +1,574 @@ +/* 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; +} From e04ab71ee15ac0193d528eb94f21a8a655c72724 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 12:26:39 -0500 Subject: [PATCH 02/50] Add Travis badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1287a48e..a5829ab8 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ Util library used as a wrapper around WiFi and Connectivity manager for Android >
*Developed by Patches 04/24/2016 - present*

+[![Build Status](https://travis-ci.org/isuPatches/WiseFy.svg?branch=master)](https://travis-ci.org/isuPatches/WiseFy) + ## Getting An Instance WiseFy now supports the builder pattern so cool functionality can be added later! From 816f72fcac20311ebf5a62a0b35952750de72b5e Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 12:27:46 -0500 Subject: [PATCH 03/50] Move travis.yml --- app/.travis.yml => .travis.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/.travis.yml => .travis.yml (100%) diff --git a/app/.travis.yml b/.travis.yml similarity index 100% rename from app/.travis.yml rename to .travis.yml From 95829f1ff7a69eed20b71fbafef5e680f01ab9b0 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 12:32:16 -0500 Subject: [PATCH 04/50] travis.yml updates --- .travis.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dd1fa7dd..49d7534e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,16 @@ language: android +jdk: + - oraclejdk7 + - oraclejdk8 android: components: - build-tools-24.0.3 - - android-24 \ No newline at end of file + - android-24 + +before_install: + - export JAVA7_HOME=/usr/lib/jvm/java-7-oracle + - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle + - export JAVA_HOME=$JAVA7_HOME + +script: + - ./gradlew clean jacocoDebugTestReport \ No newline at end of file From 9164d2cd463923ba132e0fd3db662a79de5a09c5 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 12:37:02 -0500 Subject: [PATCH 05/50] Trying another update --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 49d7534e..8fa0c3ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,10 @@ jdk: - oraclejdk8 android: components: + - tools - build-tools-24.0.3 - android-24 + - extra-android-m2repository before_install: - export JAVA7_HOME=/usr/lib/jvm/java-7-oracle From 7b34b0d529de9c7026f7f8604dfe6eac9eee9593 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 13:19:04 -0500 Subject: [PATCH 06/50] Another test --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8fa0c3ef..d0cb7f4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,11 @@ jdk: - oraclejdk8 android: components: - - tools + - platform-tools - build-tools-24.0.3 - android-24 - extra-android-m2repository + - sys-img-armeabi-v7a-android-24 before_install: - export JAVA7_HOME=/usr/lib/jvm/java-7-oracle From d9bc598ed20f37c97d25586d790d7da9618d1c91 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 13:24:16 -0500 Subject: [PATCH 07/50] Another attempt --- .travis.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d0cb7f4d..9cef9f56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,18 @@ language: android jdk: - - oraclejdk7 - oraclejdk8 android: components: - - platform-tools + - tools # to get the new `repository-11.xml` + - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943) + - platform-tool - build-tools-24.0.3 - android-24 - extra-android-m2repository - - sys-img-armeabi-v7a-android-24 before_install: - - export JAVA7_HOME=/usr/lib/jvm/java-7-oracle - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle - - export JAVA_HOME=$JAVA7_HOME + - export JAVA_HOME=$JAVA8_HOME script: - ./gradlew clean jacocoDebugTestReport \ No newline at end of file From acc2615abb18deb4d959701e3a6d9d39baf7754d Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 13:34:28 -0500 Subject: [PATCH 08/50] Emulator --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 9cef9f56..fe8750c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ android: - build-tools-24.0.3 - android-24 - extra-android-m2repository + - sys-img-armeabi-v7a-android-24 before_install: - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle From eb6e5e9ac68884f37de6ae2be620556e4fe766dd Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 13:47:02 -0500 Subject: [PATCH 09/50] Wait for emulator --- .travis.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe8750c6..a4929f24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,11 +9,16 @@ android: - build-tools-24.0.3 - android-24 - extra-android-m2repository - - sys-img-armeabi-v7a-android-24 before_install: - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle - export JAVA_HOME=$JAVA8_HOME script: - - ./gradlew clean jacocoDebugTestReport \ No newline at end of file + - ./gradlew clean jacocoDebugTestReport + +before_script: + - echo no | android create avd --force -n test -t android-24 --abi armeabi-v7a + - emulator -avd test -no-skin -no-audio -no-window & + - android-wait-for-emulator + - adb shell input keyevent 82 & \ No newline at end of file From 4b6e3a020af842d44953eceeb5145b6017f37922 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 13:56:12 -0500 Subject: [PATCH 10/50] Add abi --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a4929f24..23408a9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ android: - build-tools-24.0.3 - android-24 - extra-android-m2repository + - sys-img-armeabi-v7a-addon-google_apis-google-24 before_install: - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle From c000de375e4f2863cce68db849fdc371ca09eea5 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 14:05:23 -0500 Subject: [PATCH 11/50] :( --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 23408a9f..d976489a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ android: - build-tools-24.0.3 - android-24 - extra-android-m2repository - - sys-img-armeabi-v7a-addon-google_apis-google-24 + - sys-img-armeabi-v7a-google_apis-24 before_install: - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle From fe7f01311d6bab0b26fb411447e55408e9819650 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 14:21:34 -0500 Subject: [PATCH 12/50] Add tag, move to ENV variables --- .travis.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d976489a..a9ffaeba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,9 @@ +env: + global: + - ANDROID_API_LEVEL=24 + - ANDROID_BUILD_TOOLS_VERSION=24.0.3 + - ANDROID_ABI=armeabi-v7a + - ANDROID_TAG=google_apis language: android jdk: - oraclejdk8 @@ -6,10 +12,10 @@ android: - tools # to get the new `repository-11.xml` - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943) - platform-tool - - build-tools-24.0.3 - - android-24 + - build-tools-$ANDROID_BUILD_TOOLS_VERSION + - android-$ANDROID_API_LEVEL - extra-android-m2repository - - sys-img-armeabi-v7a-google_apis-24 + - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL before_install: - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle @@ -19,7 +25,7 @@ script: - ./gradlew clean jacocoDebugTestReport before_script: - - echo no | android create avd --force -n test -t android-24 --abi armeabi-v7a + - echo no | android create avd --force -n test -t android-$ANDROID_API_LEVEL --abi $ANDROID_ABI - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & \ No newline at end of file From 204f753393c2101c08748bd24b1e4ebf06b19717 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 14:32:31 -0500 Subject: [PATCH 13/50] Forgot to add tag --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a9ffaeba..995d747f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ env: - ANDROID_API_LEVEL=24 - ANDROID_BUILD_TOOLS_VERSION=24.0.3 - ANDROID_ABI=armeabi-v7a - - ANDROID_TAG=google_apis + - ANDROID_TAG=patches-emulator-tag language: android jdk: - oraclejdk8 @@ -25,7 +25,7 @@ script: - ./gradlew clean jacocoDebugTestReport before_script: - - echo no | android create avd --force -n test -t android-$ANDROID_API_LEVEL --abi $ANDROID_ABI + - echo no | android create avd --force -n test -t android-$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & \ No newline at end of file From 035eaa75a5c0a3276926b5b58713499dd2f0216a Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 14:42:28 -0500 Subject: [PATCH 14/50] One day travis ci will work with me --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 995d747f..6b177717 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ env: - ANDROID_API_LEVEL=24 - ANDROID_BUILD_TOOLS_VERSION=24.0.3 - ANDROID_ABI=armeabi-v7a - - ANDROID_TAG=patches-emulator-tag + - ANDROID_TAG=google_apis language: android jdk: - oraclejdk8 From ca88ab0ef050795d259aa893a23d5c164d781c8c Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 17:56:28 -0500 Subject: [PATCH 15/50] Update travis.yml --- .travis.yml | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6b177717..35c19b32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,45 @@ +language: android +jdk: oraclejdk8 +# Use the Travis Container-Based Infrastructure +sudo: false + +cache: + directories: + - ${TRAVIS_BUILD_DIR}/gradle/caches/ + - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ + env: global: - ANDROID_API_LEVEL=24 - ANDROID_BUILD_TOOLS_VERSION=24.0.3 - ANDROID_ABI=armeabi-v7a - ANDROID_TAG=google_apis -language: android -jdk: - - oraclejdk8 + - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) + android: components: - tools # to get the new `repository-11.xml` - - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943) - - platform-tool + - platform-tools + - tools # to install Android SDK tools 25.1.x - build-tools-$ANDROID_BUILD_TOOLS_VERSION - android-$ANDROID_API_LEVEL + # For Google APIs + - addon-google_apis-google-$ANDROID_API_LEVEL + # Google Play Services + - extra-google-google_play_services + # Support library + - extra-android-support + # Latest artifacts in local repository + - extra-google-m2repository - extra-android-m2repository + # Specify at least one system image - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL -before_install: - - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle - - export JAVA_HOME=$JAVA8_HOME - -script: - - ./gradlew clean jacocoDebugTestReport - before_script: - - echo no | android create avd --force -n test -t android-$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG - - emulator -avd test -no-skin -no-audio -no-window & + # Create and start emulator + - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG + - emulator -avd test -no-skin -no-window & - android-wait-for-emulator - - adb shell input keyevent 82 & \ No newline at end of file + +script: + - ./gradlew clean jacocoDebugTestReport \ No newline at end of file From cb5526001046099374991ade4585f1132cef110d Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 18:28:56 -0500 Subject: [PATCH 16/50] Another test --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 35c19b32..e5efe4a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,7 @@ before_script: - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG - emulator -avd test -no-skin -no-window & - android-wait-for-emulator + - adb shell input keyevent 82 & script: - ./gradlew clean jacocoDebugTestReport \ No newline at end of file From 7b7e36d4bc75f2231b1e8f58d7e37c8d173afd05 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 19:10:13 -0500 Subject: [PATCH 17/50] Trying to bump down build tools --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index e5efe4a8..de4f9fc3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: android jdk: oraclejdk8 -# Use the Travis Container-Based Infrastructure -sudo: false cache: directories: @@ -11,7 +9,7 @@ cache: env: global: - ANDROID_API_LEVEL=24 - - ANDROID_BUILD_TOOLS_VERSION=24.0.3 + - ANDROID_BUILD_TOOLS_VERSION=23.0.3 - ANDROID_ABI=armeabi-v7a - ANDROID_TAG=google_apis - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) @@ -40,7 +38,6 @@ before_script: - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG - emulator -avd test -no-skin -no-window & - android-wait-for-emulator - - adb shell input keyevent 82 & script: - ./gradlew clean jacocoDebugTestReport \ No newline at end of file From 8a0c52c8c4a3435545e0aa5104df3b9366fe5a1f Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 19:29:03 -0500 Subject: [PATCH 18/50] Increment again --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index de4f9fc3..99c82893 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ cache: env: global: - ANDROID_API_LEVEL=24 - - ANDROID_BUILD_TOOLS_VERSION=23.0.3 + - ANDROID_BUILD_TOOLS_VERSION=24.0.3 - ANDROID_ABI=armeabi-v7a - ANDROID_TAG=google_apis - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) From 7d53c231da354faf2ef3562eee3ca0a6800a6c80 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 19:50:01 -0500 Subject: [PATCH 19/50] Another attempt --- .travis.yml | 42 ++++++------------------------------------ app/build.gradle | 2 +- 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index 99c82893..24904754 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,43 +1,13 @@ language: android -jdk: oraclejdk8 - -cache: - directories: - - ${TRAVIS_BUILD_DIR}/gradle/caches/ - - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ - -env: - global: - - ANDROID_API_LEVEL=24 - - ANDROID_BUILD_TOOLS_VERSION=24.0.3 - - ANDROID_ABI=armeabi-v7a - - ANDROID_TAG=google_apis - - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) - +jdk: + - oraclejdk8 android: components: - tools # to get the new `repository-11.xml` + - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943) - platform-tools - - tools # to install Android SDK tools 25.1.x - - build-tools-$ANDROID_BUILD_TOOLS_VERSION - - android-$ANDROID_API_LEVEL - # For Google APIs - - addon-google_apis-google-$ANDROID_API_LEVEL - # Google Play Services - - extra-google-google_play_services - # Support library - - extra-android-support - # Latest artifacts in local repository + - build-tools-24.0.2 + - android-24 - extra-google-m2repository - - extra-android-m2repository - # Specify at least one system image - - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL - -before_script: - # Create and start emulator - - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG - - emulator -avd test -no-skin -no-window & - - android-wait-for-emulator - script: - - ./gradlew clean jacocoDebugTestReport \ No newline at end of file + - ./gradlew build connectedCheck \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 5d536ac0..01d5fd61 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -58,7 +58,7 @@ android { } compileSdkVersion 24 - buildToolsVersion "24.0.3" + buildToolsVersion "24.0.2" defaultConfig { minSdkVersion 16 From ad81e789526d6355e2e9ffe1d6ab16503d1bb975 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 19:59:50 -0500 Subject: [PATCH 20/50] Yet another attempt --- .travis.yml | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 24904754..a6227a5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,36 @@ language: android -jdk: - - oraclejdk8 +sudo: required +jdk: oraclejdk8 + +cache: + directories: + - ${TRAVIS_BUILD_DIR}/gradle/caches/ + - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ + +env: + global: + - ANDROID_API_LEVEL=24 + - ANDROID_BUILD_TOOLS_VERSION=24.0.3 + - ANDROID_ABI=armeabi-v7a + - ANDROID_TAG=google_apis + - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) + android: components: - tools # to get the new `repository-11.xml` - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943) - platform-tools - - build-tools-24.0.2 - - android-24 + - build-tools-$ANDROID_BUILD_TOOLS_VERSION + - android-$ANDROID_API_LEVEL - extra-google-m2repository + - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL + +before_script: + # Create and start emulator + - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG + - emulator -avd test -no-skin -no-window & + - android-wait-for-emulator + - adb shell input keyevent 82 & + script: - - ./gradlew build connectedCheck \ No newline at end of file + - ./gradlew clean jacocoDebugTestReport \ No newline at end of file From f87264db901d40b992408dcd1c005ec60b1a74d3 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 20:11:14 -0500 Subject: [PATCH 21/50] Bump --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 01d5fd61..5d536ac0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -58,7 +58,7 @@ android { } compileSdkVersion 24 - buildToolsVersion "24.0.2" + buildToolsVersion "24.0.3" defaultConfig { minSdkVersion 16 From fe3ad453bb3edfefd8a2f2960894dbd1cba44f5f Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 20:25:15 -0500 Subject: [PATCH 22/50] Support libs? --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a6227a5e..213cd67c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ android: - platform-tools - build-tools-$ANDROID_BUILD_TOOLS_VERSION - android-$ANDROID_API_LEVEL - - extra-google-m2repository + - extra-android-m2repository - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL before_script: From df6ead8e07adf0fcc1d64657c968927fb3876f9f Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 20:55:09 -0500 Subject: [PATCH 23/50] Another try --- .travis.yml | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 213cd67c..e39a2398 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,34 +3,38 @@ sudo: required jdk: oraclejdk8 cache: - directories: - - ${TRAVIS_BUILD_DIR}/gradle/caches/ - - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ + directories: + - ${TRAVIS_BUILD_DIR}/gradle/caches/ + - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ env: - global: - - ANDROID_API_LEVEL=24 - - ANDROID_BUILD_TOOLS_VERSION=24.0.3 - - ANDROID_ABI=armeabi-v7a - - ANDROID_TAG=google_apis - - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) + global: + - ANDROID_API_LEVEL=24 + - ANDROID_BUILD_TOOLS_VERSION=24.0.3 + - ANDROID_ABI=armeabi-v7a + - ANDROID_TAG=google_apis + - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) android: - components: - - tools # to get the new `repository-11.xml` - - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943) - - platform-tools - - build-tools-$ANDROID_BUILD_TOOLS_VERSION - - android-$ANDROID_API_LEVEL - - extra-android-m2repository - - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL + components: + - tools # to get the new `repository-11.xml` + - platform-tools + - tools # to install Android SDK tools 25.1.x + - build-tools-$ANDROID_BUILD_TOOLS_VERSION + - android-$ANDROID_API_LEVEL + # Support library + - extra-android-support + # Latest artifacts in local repository + - extra-android-m2repository + # Specify at least one system image + - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL before_script: - # Create and start emulator - - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG - - emulator -avd test -no-skin -no-window & - - android-wait-for-emulator - - adb shell input keyevent 82 & + # Create and start emulator + - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG + - emulator -avd test -no-skin -no-window & + - android-wait-for-emulator + - adb shell input keyevent 82 & script: - - ./gradlew clean jacocoDebugTestReport \ No newline at end of file + - ./gradlew clean jacocoDebugTestReport \ No newline at end of file From c4d1abc12d482e31920148328a87bd1d9ddd7781 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 20:56:11 -0500 Subject: [PATCH 24/50] Spaces --- .travis.yml | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index e39a2398..e477d3f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,38 +3,38 @@ sudo: required jdk: oraclejdk8 cache: - directories: - - ${TRAVIS_BUILD_DIR}/gradle/caches/ - - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ + directories: + - ${TRAVIS_BUILD_DIR}/gradle/caches/ + - ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/ env: - global: - - ANDROID_API_LEVEL=24 - - ANDROID_BUILD_TOOLS_VERSION=24.0.3 - - ANDROID_ABI=armeabi-v7a - - ANDROID_TAG=google_apis - - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) + global: + - ANDROID_API_LEVEL=24 + - ANDROID_BUILD_TOOLS_VERSION=24.0.3 + - ANDROID_ABI=armeabi-v7a + - ANDROID_TAG=google_apis + - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) android: - components: - - tools # to get the new `repository-11.xml` - - platform-tools - - tools # to install Android SDK tools 25.1.x - - build-tools-$ANDROID_BUILD_TOOLS_VERSION - - android-$ANDROID_API_LEVEL - # Support library - - extra-android-support - # Latest artifacts in local repository - - extra-android-m2repository - # Specify at least one system image - - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL + components: + - tools # to get the new `repository-11.xml` + - platform-tools + - tools # to install Android SDK tools 25.1.x + - build-tools-$ANDROID_BUILD_TOOLS_VERSION + - android-$ANDROID_API_LEVEL + # Support library + - extra-android-support + # Latest artifacts in local repository + - extra-android-m2repository + # Specify at least one system image + - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL before_script: - # Create and start emulator - - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG - - emulator -avd test -no-skin -no-window & - - android-wait-for-emulator - - adb shell input keyevent 82 & + # Create and start emulator + - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG + - emulator -avd test -no-skin -no-window & + - android-wait-for-emulator + - adb shell input keyevent 82 & script: - - ./gradlew clean jacocoDebugTestReport \ No newline at end of file + - ./gradlew clean jacocoDebugTestReport \ No newline at end of file From 196ca252e3903a3957831bdb156e00fdebe77d8d Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 21:40:28 -0500 Subject: [PATCH 25/50] Update --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e477d3f1..4fbc82ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,9 +22,14 @@ android: - tools # to install Android SDK tools 25.1.x - build-tools-$ANDROID_BUILD_TOOLS_VERSION - android-$ANDROID_API_LEVEL + # For Google APIs + - addon-google_apis-google-$ANDROID_API_LEVEL + # Google Play Services + - extra-google-google_play_services # Support library - extra-android-support # Latest artifacts in local repository + - extra-google-m2repository - extra-android-m2repository # Specify at least one system image - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL @@ -34,7 +39,6 @@ before_script: - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG - emulator -avd test -no-skin -no-window & - android-wait-for-emulator - - adb shell input keyevent 82 & script: - ./gradlew clean jacocoDebugTestReport \ No newline at end of file From b0a73d81fb16d6580da73559c63fdf30f77a9a70 Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sun, 23 Oct 2016 22:49:29 -0500 Subject: [PATCH 26/50] More crazy experiments --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4fbc82ca..fdc4ef95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,6 @@ android: - android-$ANDROID_API_LEVEL # For Google APIs - addon-google_apis-google-$ANDROID_API_LEVEL - # Google Play Services - - extra-google-google_play_services # Support library - extra-android-support # Latest artifacts in local repository @@ -35,10 +33,11 @@ android: - sys-img-armeabi-v7a-google_apis-$ANDROID_API_LEVEL before_script: - # Create and start emulator - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG - emulator -avd test -no-skin -no-window & - android-wait-for-emulator + - adb wait-for-device + - ./gradlew connectedCheck script: - - ./gradlew clean jacocoDebugTestReport \ No newline at end of file + - ./gradlew clean jacocoDebugTestReport --debug --stacktrace \ No newline at end of file From 2a0f5f81a9d918a13fbf260c161e9384544a644b Mon Sep 17 00:00:00 2001 From: isuPatches Date: Mon, 24 Oct 2016 00:00:49 -0500 Subject: [PATCH 27/50] Enforce context through builder constructor close #25 --- README.md | 4 +- .../com/isupatches/wisefy/WiseFyTest.java | 6 +- .../java/com/isupatches/wisefy/WiseFy.java | 87 +++-- javadoc/allclasses-frame.html | 4 +- javadoc/allclasses-noframe.html | 4 +- javadoc/com/isupatches/wisefy/WiseFy.html | 15 +- .../isupatches/wisefy/WiseFy.withContext.html | 316 ++++++++++++++++++ .../com/isupatches/wisefy/package-frame.html | 4 +- .../isupatches/wisefy/package-summary.html | 14 +- .../com/isupatches/wisefy/package-tree.html | 4 +- .../wisefy/util/GetManagerUtil.html | 2 +- .../com/isupatches/wisefy/util/LogUtil.html | 2 +- .../com/isupatches/wisefy/util/SSIDUtil.html | 2 +- .../isupatches/wisefy/util/package-frame.html | 2 +- .../wisefy/util/package-summary.html | 2 +- .../isupatches/wisefy/util/package-tree.html | 2 +- javadoc/constant-values.html | 2 +- javadoc/deprecated-list.html | 2 +- javadoc/help-doc.html | 2 +- javadoc/index-all.html | 26 +- javadoc/index.html | 2 +- javadoc/overview-frame.html | 2 +- javadoc/overview-summary.html | 2 +- javadoc/overview-tree.html | 4 +- 24 files changed, 436 insertions(+), 76 deletions(-) create mode 100644 javadoc/com/isupatches/wisefy/WiseFy.withContext.html diff --git a/README.md b/README.md index a5829ab8..504764ed 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ WiseFy now supports the builder pattern so cool functionality can be added later To grab a default instance: ```java -WiseFy mWiseFy = new WiseFy.generator().withContext(getActivity()).getSmarts(); +WiseFy mWiseFy = new WiseFy.withContext(getActivity()).getSmarts(); ``` To grab an instance with logging enabled: ```java -WiseFy mWiseFy = new WiseFy.generator().withContext(getActivity()).logging(true).getSmarts(); +WiseFy mWiseFy = new WiseFy.withContext(getActivity()).logging(true).getSmarts(); ``` **IMPORTANT!** Please make sure you call withContext for WiseFy to work properly diff --git a/app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java b/app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java index a9774320..e5526ee0 100644 --- a/app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java +++ b/app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java @@ -43,7 +43,7 @@ public void setUp() { mActivityTestRule.launchActivity(new Intent()); - mWiseFy = new WiseFy.generator().withContext(mActivityTestRule.getActivity()).getSmarts(); + mWiseFy = new WiseFy.withContext(mActivityTestRule.getActivity()).getSmarts(); } @Test @@ -146,13 +146,13 @@ public void testAddWPA2NetworkNullWifiManager() { @Test public void testBuilderWithLoggingFalse() { - WiseFy wiseFy = new WiseFy.generator().logging(false).getSmarts(); + WiseFy wiseFy = new WiseFy.withContext(mActivityTestRule.getActivity()).logging(false).getSmarts(); assertEquals(false, wiseFy.isLoggingEnabled()); } @Test public void testBuilderWithLoggingTrue() { - WiseFy wiseFy = new WiseFy.generator().logging(true).getSmarts(); + WiseFy wiseFy = new WiseFy.withContext(mActivityTestRule.getActivity()).logging(true).getSmarts(); assertEquals(true, wiseFy.isLoggingEnabled()); } diff --git a/app/src/main/java/com/isupatches/wisefy/WiseFy.java b/app/src/main/java/com/isupatches/wisefy/WiseFy.java index 35db6856..dd89936e 100644 --- a/app/src/main/java/com/isupatches/wisefy/WiseFy.java +++ b/app/src/main/java/com/isupatches/wisefy/WiseFy.java @@ -1,3 +1,19 @@ +/** + * Copyright 2016 by 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; @@ -16,6 +32,11 @@ import java.util.List; +/** + * Main class to manipulate and query network settings on an Android device + * + * Uses the builder pattern for creation - {@link withContext} + */ public class WiseFy { private static final String TAG = WiseFy.class.getSimpleName(); @@ -37,64 +58,72 @@ public class WiseFy { /** * Private constructor that accepts builder input */ - private WiseFy(generator generator) { - this.mLoggingEnabled = generator.loggingEnabled; - this.mConnectivityManager = GetManagerUtil.getInstance().getConnectivityManager(generator.context); - this.mWifiManager = GetManagerUtil.getInstance().getWiFiManager(generator.context); + private WiseFy(withContext withContext) { + this.mLoggingEnabled = withContext.loggingEnabled; + this.mConnectivityManager = GetManagerUtil.getInstance().getConnectivityManager(withContext.context); + this.mWifiManager = GetManagerUtil.getInstance().getWiFiManager(withContext.context); } /** - * Internal static class for builder pattern + * Static class for builder pattern + * + * Implements builder interfaces #{@link Logging} #{@link GetSmarts} */ - public static class generator implements GetSmarts, WithContext { + public static class withContext implements Logging, GetSmarts { private Context context; private boolean loggingEnabled; /** - * Mandatory - The context to get a WiFi and Connectivity manager + * Mandatory - The public constructor for the builder that requires a context * - * @param context - The activity or application context - * {@link WithContext} + * @param context - The activity or application context to get a WifiConfiguration and + * ConnectivityManager instance * - * @return generator - The builder with updated context + * {@link #WiseFy(withContext)} */ - public GetSmarts withContext(Context context) { + public withContext(Context context) { this.context = context; - return this; } /** - * Non-mandatory - To enable/disable logging for the WiseFy instance - * - * @param loggingEnabled - If logging is enabled or disabled - * {@link GetSmarts} + * Mandatory - To build and return a WiseFy instance * - * @return generator - The builder with updated logging setting + * @return WiseFy - The instance created by the builder */ - public generator logging(boolean loggingEnabled) { - this.loggingEnabled = loggingEnabled; - return this; + @Override + public WiseFy getSmarts() { + return new WiseFy(this); } /** - * Mandatory - To build and return a WiseFy instance + * Optional - Builder method that enables/disables logging for a WiseWy instance * - * @return WiseFy - The instance created by the builder + * @param loggingEnabled - If logging is enabled or disabled for an instance + * {@link Logging} + * + * @return withContext - The builder with updated logging setting */ - public WiseFy getSmarts() { - return new WiseFy(this); + @Override + public withContext logging(boolean loggingEnabled) { + this.loggingEnabled = loggingEnabled; + return this; } } - interface GetSmarts { - WiseFy getSmarts(); + /** + * An interface that enables/disables logging for a WiseFy instance + */ + interface Logging { + withContext logging(boolean loggingEnabled); } - interface WithContext { - GetSmarts withContext(Context context); - generator logging(boolean loggingEnabled); + /** + * An interface that builds a WiseFy instance + */ + interface GetSmarts { + WiseFy getSmarts(); } /** diff --git a/javadoc/allclasses-frame.html b/javadoc/allclasses-frame.html index 224afb9a..ae44ff45 100644 --- a/javadoc/allclasses-frame.html +++ b/javadoc/allclasses-frame.html @@ -2,7 +2,7 @@ - + All Classes (app 1.0.4 API) @@ -16,7 +16,7 @@

All Classes

  • LogUtil
  • SSIDUtil
  • WiseFy
  • -
  • WiseFy.generator
  • +
  • WiseFy.withContext
  • diff --git a/javadoc/allclasses-noframe.html b/javadoc/allclasses-noframe.html index abac2f59..8a4d7ba2 100644 --- a/javadoc/allclasses-noframe.html +++ b/javadoc/allclasses-noframe.html @@ -2,7 +2,7 @@ - + All Classes (app 1.0.4 API) @@ -16,7 +16,7 @@

    All Classes

  • LogUtil
  • SSIDUtil
  • WiseFy
  • -
  • WiseFy.generator
  • +
  • WiseFy.withContext
  • diff --git a/javadoc/com/isupatches/wisefy/WiseFy.html b/javadoc/com/isupatches/wisefy/WiseFy.html index e70b57dc..5018198a 100644 --- a/javadoc/com/isupatches/wisefy/WiseFy.html +++ b/javadoc/com/isupatches/wisefy/WiseFy.html @@ -2,7 +2,7 @@ - + WiseFy (app 1.0.4 API) @@ -49,7 +49,7 @@ @@ -130,8 +133,10 @@

    Nested Class Summary

    static class  -WiseFy.generator -
    Internal static class for builder pattern
    +WiseFy.withContext +
    Static class for builder pattern + + Implements builder interfaces #Logging #GetSmarts
    @@ -777,7 +782,7 @@

    isLoggingEnabled

    diff --git a/javadoc/com/isupatches/wisefy/package-summary.html b/javadoc/com/isupatches/wisefy/package-summary.html index 51262cdb..da9d8465 100644 --- a/javadoc/com/isupatches/wisefy/package-summary.html +++ b/javadoc/com/isupatches/wisefy/package-summary.html @@ -2,7 +2,7 @@ - + com.isupatches.wisefy (app 1.0.4 API) @@ -83,12 +83,18 @@

    Package com.isupatches.wisefy

    WiseFy -  + +
    Main class to manipulate and query network settings on an Android device + + Uses the builder pattern for creation - WiseFy.withContext
    + -WiseFy.generator +WiseFy.withContext -
    Internal static class for builder pattern
    +
    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 index f4b195b7..5a0fd1d7 100644 --- a/javadoc/com/isupatches/wisefy/package-tree.html +++ b/javadoc/com/isupatches/wisefy/package-tree.html @@ -2,7 +2,7 @@ - + com.isupatches.wisefy Class Hierarchy (app 1.0.4 API) @@ -81,7 +81,7 @@

    Class Hierarchy

  • java.lang.Object
  • diff --git a/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html b/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html index 5ee56b2b..f67ebc0f 100644 --- a/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html +++ b/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html @@ -2,7 +2,7 @@ - + GetManagerUtil (app 1.0.4 API) diff --git a/javadoc/com/isupatches/wisefy/util/LogUtil.html b/javadoc/com/isupatches/wisefy/util/LogUtil.html index 4fceabc8..8b545713 100644 --- a/javadoc/com/isupatches/wisefy/util/LogUtil.html +++ b/javadoc/com/isupatches/wisefy/util/LogUtil.html @@ -2,7 +2,7 @@ - + LogUtil (app 1.0.4 API) diff --git a/javadoc/com/isupatches/wisefy/util/SSIDUtil.html b/javadoc/com/isupatches/wisefy/util/SSIDUtil.html index 1f312a55..81007827 100644 --- a/javadoc/com/isupatches/wisefy/util/SSIDUtil.html +++ b/javadoc/com/isupatches/wisefy/util/SSIDUtil.html @@ -2,7 +2,7 @@ - + SSIDUtil (app 1.0.4 API) diff --git a/javadoc/com/isupatches/wisefy/util/package-frame.html b/javadoc/com/isupatches/wisefy/util/package-frame.html index a282b641..950cdd39 100644 --- a/javadoc/com/isupatches/wisefy/util/package-frame.html +++ b/javadoc/com/isupatches/wisefy/util/package-frame.html @@ -2,7 +2,7 @@ - + com.isupatches.wisefy.util (app 1.0.4 API) diff --git a/javadoc/com/isupatches/wisefy/util/package-summary.html b/javadoc/com/isupatches/wisefy/util/package-summary.html index f19c4115..c25450e0 100644 --- a/javadoc/com/isupatches/wisefy/util/package-summary.html +++ b/javadoc/com/isupatches/wisefy/util/package-summary.html @@ -2,7 +2,7 @@ - + com.isupatches.wisefy.util (app 1.0.4 API) diff --git a/javadoc/com/isupatches/wisefy/util/package-tree.html b/javadoc/com/isupatches/wisefy/util/package-tree.html index 715df538..6842dd49 100644 --- a/javadoc/com/isupatches/wisefy/util/package-tree.html +++ b/javadoc/com/isupatches/wisefy/util/package-tree.html @@ -2,7 +2,7 @@ - + com.isupatches.wisefy.util Class Hierarchy (app 1.0.4 API) diff --git a/javadoc/constant-values.html b/javadoc/constant-values.html index 86cd2c3e..c7537ad5 100644 --- a/javadoc/constant-values.html +++ b/javadoc/constant-values.html @@ -2,7 +2,7 @@ - + Constant Field Values (app 1.0.4 API) diff --git a/javadoc/deprecated-list.html b/javadoc/deprecated-list.html index b0650931..c3703044 100644 --- a/javadoc/deprecated-list.html +++ b/javadoc/deprecated-list.html @@ -2,7 +2,7 @@ - + Deprecated List (app 1.0.4 API) diff --git a/javadoc/help-doc.html b/javadoc/help-doc.html index d0ad8f37..43240a03 100644 --- a/javadoc/help-doc.html +++ b/javadoc/help-doc.html @@ -2,7 +2,7 @@ - + API Help (app 1.0.4 API) diff --git a/javadoc/index-all.html b/javadoc/index-all.html index a0119ffa..17920809 100644 --- a/javadoc/index-all.html +++ b/javadoc/index-all.html @@ -2,7 +2,7 @@ - + Index (app 1.0.4 API) @@ -145,8 +145,6 @@

    E

    G

    -
    generator() - Constructor for class com.isupatches.wisefy.WiseFy.generator
    -
     
    getConnectivityManager(Context) - Method in class com.isupatches.wisefy.util.GetManagerUtil
    To get a Connectivity manger instance from an activity's context.
    @@ -173,7 +171,7 @@

    G

    To retrieve a list of saved networks on a user's device
    -
    getSmarts() - Method in class com.isupatches.wisefy.WiseFy.generator
    +
    getSmarts() - Method in class com.isupatches.wisefy.WiseFy.withContext
    Mandatory - To build and return a WiseFy instance
    @@ -227,9 +225,9 @@

    I

    L

    -
    logging(boolean) - Method in class com.isupatches.wisefy.WiseFy.generator
    +
    logging(boolean) - Method in class com.isupatches.wisefy.WiseFy.withContext
    -
    Non-mandatory - To enable/disable logging for the WiseFy instance
    +
    Optional - Builder method that enables/disables logging for a WiseWy instance
    LogUtil - Class in com.isupatches.wisefy.util
     
    @@ -278,14 +276,20 @@

    W

    WISE_MANAGER_FAILURE - Static variable in class com.isupatches.wisefy.WiseFy
     
    WiseFy - Class in com.isupatches.wisefy
    -
     
    -
    WiseFy.generator - Class in com.isupatches.wisefy
    -
    Internal static class for builder pattern
    +
    Main class to manipulate and query network settings on an Android device + + Uses the builder pattern for creation - WiseFy.withContext
    +
    +
    WiseFy.withContext - Class in com.isupatches.wisefy
    +
    +
    Static class for builder pattern + + Implements builder interfaces #Logging #GetSmarts
    -
    withContext(Context) - Method in class com.isupatches.wisefy.WiseFy.generator
    +
    withContext(Context) - Constructor for class com.isupatches.wisefy.WiseFy.withContext
    -
    Mandatory - The context to get a WiFi and Connectivity manager
    +
    Mandatory - The public constructor for the builder that requires a context
    A C D E G I L M R S W  diff --git a/javadoc/index.html b/javadoc/index.html index a92a8ded..f8a47f95 100644 --- a/javadoc/index.html +++ b/javadoc/index.html @@ -2,7 +2,7 @@ - + app 1.0.4 API diff --git a/javadoc/allclasses-noframe.html b/javadoc/allclasses-noframe.html index 8a4d7ba2..daa1be58 100644 --- a/javadoc/allclasses-noframe.html +++ b/javadoc/allclasses-noframe.html @@ -2,9 +2,9 @@ - + All Classes (app 1.0.4 API) - + diff --git a/javadoc/com/isupatches/wisefy/WiseFy.html b/javadoc/com/isupatches/wisefy/WiseFy.html index 5018198a..481db33e 100644 --- a/javadoc/com/isupatches/wisefy/WiseFy.html +++ b/javadoc/com/isupatches/wisefy/WiseFy.html @@ -2,9 +2,9 @@ - + WiseFy (app 1.0.4 API) - + diff --git a/javadoc/com/isupatches/wisefy/WiseFy.withContext.html b/javadoc/com/isupatches/wisefy/WiseFy.withContext.html index 8b42003b..0d73e571 100644 --- a/javadoc/com/isupatches/wisefy/WiseFy.withContext.html +++ b/javadoc/com/isupatches/wisefy/WiseFy.withContext.html @@ -2,9 +2,9 @@ - + WiseFy.withContext (app 1.0.4 API) - + @@ -157,7 +157,10 @@

    Method Summary

    WiseFy getSmarts() -
    Mandatory - To build and return a WiseFy instance
    +
    Mandatory - To build and return a WiseFy instance + + Must be called after withContext + #withContext(Context)
    @@ -199,9 +202,7 @@

    withContext

    Parameters:
    context - - The activity or application context to get a WifiConfiguration and - ConnectivityManager instance - - #WiseFy(withContext)
    + ConnectivityManager instance
    @@ -220,7 +221,10 @@

    Method Detail

  • getSmarts

    public WiseFy getSmarts()
    -
    Mandatory - To build and return a WiseFy instance
    +
    Mandatory - To build and return a WiseFy instance + + Must be called after withContext + #withContext(Context)
    Returns:
    WiseFy - The instance created by the builder
    diff --git a/javadoc/com/isupatches/wisefy/package-frame.html b/javadoc/com/isupatches/wisefy/package-frame.html index 35fa5fc5..be76153a 100644 --- a/javadoc/com/isupatches/wisefy/package-frame.html +++ b/javadoc/com/isupatches/wisefy/package-frame.html @@ -2,9 +2,9 @@ - + com.isupatches.wisefy (app 1.0.4 API) - + diff --git a/javadoc/com/isupatches/wisefy/package-summary.html b/javadoc/com/isupatches/wisefy/package-summary.html index da9d8465..3296033f 100644 --- a/javadoc/com/isupatches/wisefy/package-summary.html +++ b/javadoc/com/isupatches/wisefy/package-summary.html @@ -2,9 +2,9 @@ - + com.isupatches.wisefy (app 1.0.4 API) - + diff --git a/javadoc/com/isupatches/wisefy/package-tree.html b/javadoc/com/isupatches/wisefy/package-tree.html index 5a0fd1d7..7739ef46 100644 --- a/javadoc/com/isupatches/wisefy/package-tree.html +++ b/javadoc/com/isupatches/wisefy/package-tree.html @@ -2,9 +2,9 @@ - + com.isupatches.wisefy Class Hierarchy (app 1.0.4 API) - + diff --git a/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html b/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html index f67ebc0f..3b7c95e1 100644 --- a/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html +++ b/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html @@ -2,9 +2,9 @@ - + GetManagerUtil (app 1.0.4 API) - + diff --git a/javadoc/com/isupatches/wisefy/util/LogUtil.html b/javadoc/com/isupatches/wisefy/util/LogUtil.html index 8b545713..97a79ad6 100644 --- a/javadoc/com/isupatches/wisefy/util/LogUtil.html +++ b/javadoc/com/isupatches/wisefy/util/LogUtil.html @@ -2,9 +2,9 @@ - + LogUtil (app 1.0.4 API) - + diff --git a/javadoc/com/isupatches/wisefy/util/SSIDUtil.html b/javadoc/com/isupatches/wisefy/util/SSIDUtil.html index 81007827..b67b07d2 100644 --- a/javadoc/com/isupatches/wisefy/util/SSIDUtil.html +++ b/javadoc/com/isupatches/wisefy/util/SSIDUtil.html @@ -2,9 +2,9 @@ - + SSIDUtil (app 1.0.4 API) - + diff --git a/javadoc/com/isupatches/wisefy/util/package-frame.html b/javadoc/com/isupatches/wisefy/util/package-frame.html index 950cdd39..bf8afb3f 100644 --- a/javadoc/com/isupatches/wisefy/util/package-frame.html +++ b/javadoc/com/isupatches/wisefy/util/package-frame.html @@ -2,9 +2,9 @@ - + com.isupatches.wisefy.util (app 1.0.4 API) - + diff --git a/javadoc/com/isupatches/wisefy/util/package-summary.html b/javadoc/com/isupatches/wisefy/util/package-summary.html index c25450e0..047c7c1b 100644 --- a/javadoc/com/isupatches/wisefy/util/package-summary.html +++ b/javadoc/com/isupatches/wisefy/util/package-summary.html @@ -2,9 +2,9 @@ - + com.isupatches.wisefy.util (app 1.0.4 API) - + diff --git a/javadoc/com/isupatches/wisefy/util/package-tree.html b/javadoc/com/isupatches/wisefy/util/package-tree.html index 6842dd49..4e51ac69 100644 --- a/javadoc/com/isupatches/wisefy/util/package-tree.html +++ b/javadoc/com/isupatches/wisefy/util/package-tree.html @@ -2,9 +2,9 @@ - + com.isupatches.wisefy.util Class Hierarchy (app 1.0.4 API) - + diff --git a/javadoc/constant-values.html b/javadoc/constant-values.html index c7537ad5..ecf9c4df 100644 --- a/javadoc/constant-values.html +++ b/javadoc/constant-values.html @@ -2,9 +2,9 @@ - + Constant Field Values (app 1.0.4 API) - + diff --git a/javadoc/deprecated-list.html b/javadoc/deprecated-list.html index c3703044..547cdffb 100644 --- a/javadoc/deprecated-list.html +++ b/javadoc/deprecated-list.html @@ -2,9 +2,9 @@ - + Deprecated List (app 1.0.4 API) - + diff --git a/javadoc/help-doc.html b/javadoc/help-doc.html index 43240a03..4b671312 100644 --- a/javadoc/help-doc.html +++ b/javadoc/help-doc.html @@ -2,9 +2,9 @@ - + API Help (app 1.0.4 API) - + diff --git a/javadoc/index-all.html b/javadoc/index-all.html index 17920809..5eb6e966 100644 --- a/javadoc/index-all.html +++ b/javadoc/index-all.html @@ -2,9 +2,9 @@ - + Index (app 1.0.4 API) - + @@ -173,7 +173,10 @@

    G

    getSmarts() - Method in class com.isupatches.wisefy.WiseFy.withContext
    -
    Mandatory - To build and return a WiseFy instance
    +
    Mandatory - To build and return a WiseFy instance + + Must be called after withContext + #withContext(Context)
    getWiFiManager(Context) - Method in class com.isupatches.wisefy.util.GetManagerUtil
    diff --git a/javadoc/index.html b/javadoc/index.html index f8a47f95..3c65afdc 100644 --- a/javadoc/index.html +++ b/javadoc/index.html @@ -2,7 +2,7 @@ - + app 1.0.4 API diff --git a/javadoc/overview-summary.html b/javadoc/overview-summary.html index f6511a0c..37697032 100644 --- a/javadoc/overview-summary.html +++ b/javadoc/overview-summary.html @@ -2,9 +2,9 @@ - + Overview (app 1.0.4 API) - + diff --git a/javadoc/overview-tree.html b/javadoc/overview-tree.html index 87c7f84a..3d6557eb 100644 --- a/javadoc/overview-tree.html +++ b/javadoc/overview-tree.html @@ -2,9 +2,9 @@ - + Class Hierarchy (app 1.0.4 API) - +