From fec0d88ea2860ef5b595d6f04481cec963350a1d Mon Sep 17 00:00:00 2001 From: Alexander Dorokhine Date: Tue, 2 May 2017 18:54:35 -0700 Subject: Fix issues related to WifiManagerSnippet. (#44) * Removed version code check; it was incorrect and doesn't seem to be necessary. * Missing permission needed to be able to call setWifiApEnabled. --- .../mobly/snippet/bundled/WifiManagerSnippet.java | 23 +--------------------- .../snippet/bundled/utils/ApiVersionException.java | 8 -------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 src/main/java/com/google/android/mobly/snippet/bundled/utils/ApiVersionException.java (limited to 'src/main/java/com') diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java index ea75b5a..bc57ab0 100644 --- a/src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java +++ b/src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java @@ -23,11 +23,9 @@ import android.content.IntentFilter; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiManager; -import android.os.Build; import android.support.annotation.Nullable; import android.support.test.InstrumentationRegistry; import com.google.android.mobly.snippet.Snippet; -import com.google.android.mobly.snippet.bundled.utils.ApiVersionException; import com.google.android.mobly.snippet.bundled.utils.JsonDeserializer; import com.google.android.mobly.snippet.bundled.utils.JsonSerializer; import com.google.android.mobly.snippet.bundled.utils.Utils; @@ -51,7 +49,6 @@ public class WifiManagerSnippet implements Snippet { private final WifiManager mWifiManager; private final Context mContext; - private static final String TAG = "WifiManagerSnippet"; private final JsonSerializer mJsonSerializer = new JsonSerializer(); private volatile boolean mIsScanResultAvailable = false; @@ -244,16 +241,8 @@ public class WifiManagerSnippet implements Snippet { return mJsonSerializer.toJson(mWifiManager.getDhcpInfo()); } - private void verifyApiVersionForSoftAp() throws ApiVersionException { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { - throw new ApiVersionException( - "Soft AP APIs are not supported in Android versions >= N."); - } - } - @Rpc(description = "Check whether Wi-Fi Soft AP (hotspot) is enabled.") public boolean wifiIsApEnabled() throws Throwable { - verifyApiVersionForSoftAp(); try { return (boolean) mWifiManager @@ -268,14 +257,11 @@ public class WifiManagerSnippet implements Snippet { /** * Enable Wi-Fi Soft AP (hotspot). * - *

Does not work for release N. - * * @param configuration The same format as the param wifiNetworkConfig param for wifiConnect. * @throws Throwable */ @Rpc(description = "Enable Wi-Fi Soft AP (hotspot).") public void wifiEnableSoftAp(@Nullable JSONObject configuration) throws Throwable { - verifyApiVersionForSoftAp(); // If no configuration is provided, the existing configuration would be used. WifiConfiguration wifiConfiguration = null; if (configuration != null) { @@ -308,16 +294,9 @@ public class WifiManagerSnippet implements Snippet { } } - /** - * Disables Wi-Fi Soft AP (hotspot). - * - *

Does not work for release N. - * - * @throws Throwable - */ + /** Disables Wi-Fi Soft AP (hotspot). */ @Rpc(description = "Disable Wi-Fi Soft AP (hotspot).") public void wifiDisableSoftAp() throws Throwable { - verifyApiVersionForSoftAp(); boolean success; try { success = diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/utils/ApiVersionException.java b/src/main/java/com/google/android/mobly/snippet/bundled/utils/ApiVersionException.java deleted file mode 100644 index 68f2a55..0000000 --- a/src/main/java/com/google/android/mobly/snippet/bundled/utils/ApiVersionException.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.google.android.mobly.snippet.bundled.utils; - -/** Raised for when an Rpc call is not supported by the Android version used. */ -public class ApiVersionException extends Exception { - public ApiVersionException(String message) { - super(message); - } -} -- cgit v1.2.3