From ae81d49fcac0421cc8d5a10730359e7d1e723aec Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sat, 30 Apr 2016 14:23:43 -0500 Subject: [PATCH 1/2] Adding isWifiEnabled functionality --- .../java/com/metova/wisefy/WiseFyTest.java | 32 ++++++++++++++++++- .../main/java/com/metova/wisefy/WiseFy.java | 18 +++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/app/src/androidTest/java/com/metova/wisefy/WiseFyTest.java b/app/src/androidTest/java/com/metova/wisefy/WiseFyTest.java index 6d909b4f..fa947bf0 100644 --- a/app/src/androidTest/java/com/metova/wisefy/WiseFyTest.java +++ b/app/src/androidTest/java/com/metova/wisefy/WiseFyTest.java @@ -13,7 +13,6 @@ import com.metova.wisefy.util.GetManagerUtil; import com.metova.wisefy.util.TestActivity; import com.robotium.solo.Condition; -import org.mockito.Mockito; import java.util.ArrayList; import java.util.List; import static org.mockito.Mockito.*; @@ -257,6 +256,37 @@ public void testIsSecureNullCapabilities() { assertEquals(false, WiseFy.getSmarts().isSecure(scanResult)); } + public void testIsWiFiEnabledFalse() { + final WifiManager wifiManager = getLiveWiFiManager(getActivity()); + wifiManager.setWifiEnabled(false); + assertTrue(getSolo().waitForCondition(new Condition() { + @Override + public boolean isSatisfied() { + return !wifiManager.isWifiEnabled(); + } + }, 3000)); + assertEquals(false, WiseFy.getSmarts().isWifiEnabled(getActivity())); + wifiManager.setWifiEnabled(true); + assertTrue(getSolo().waitForCondition(new Condition() { + @Override + public boolean isSatisfied() { + return wifiManager.isWifiEnabled(); + } + }, 3000)); + } + + public void testIsWifiEnabledTrue() { + final WifiManager wifiManager = getLiveWiFiManager(getActivity()); + wifiManager.setWifiEnabled(true); + assertTrue(getSolo().waitForCondition(new Condition() { + @Override + public boolean isSatisfied() { + return wifiManager.isWifiEnabled(); + } + }, 3000)); + assertEquals(true, WiseFy.getSmarts().isWifiEnabled(getActivity())); + } + public void testReconnectToNetworkSuccess() { WiseFy.getSmarts().mGetManagerUtil = mMockGetManagerUtil; List wifiList = new ArrayList<>(); diff --git a/app/src/main/java/com/metova/wisefy/WiseFy.java b/app/src/main/java/com/metova/wisefy/WiseFy.java index e96dccdf..411d8c50 100644 --- a/app/src/main/java/com/metova/wisefy/WiseFy.java +++ b/app/src/main/java/com/metova/wisefy/WiseFy.java @@ -483,6 +483,24 @@ public boolean isSecure(ScanResult scanResult) { 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) { + boolean isWifiEnabled = false; + if(activity != null) { + WifiManager wifiManager = GetManagerUtil.getInstance().getWiFiManager(activity); + isWifiEnabled = wifiManager.isWifiEnabled(); + } else { + LogUtil.w(TAG, "No activity to get wifi config"); + } + return isWifiEnabled; + } + /** * Used to reconnect to a network * From 12bb210b2aa6513b0140a2e6de7594f0e1d0e64f Mon Sep 17 00:00:00 2001 From: isuPatches Date: Sat, 30 Apr 2016 14:27:52 -0500 Subject: [PATCH 2/2] Increment versionName and versionCode for release --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c97d4f54..f089ecbf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,8 +52,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 23 - versionCode 2 - versionName "1.0.1" + versionCode 3 + versionName "1.0.2" } buildTypes {