aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorAlexander Dorokhine <adorokhine@google.com>2017-05-02 18:54:35 -0700
committerGitHub <noreply@github.com>2017-05-02 18:54:35 -0700
commitfec0d88ea2860ef5b595d6f04481cec963350a1d (patch)
tree7be31e6b1529c3b74d7ed8f35387a24f46c1ceb1 /src/main/java/com
parent5858a6ece2d8368f6074cd05759490ed008bd4e9 (diff)
downloadmobly-bundled-snippets-fec0d88ea2860ef5b595d6f04481cec963350a1d.tar.gz
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.
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java23
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/utils/ApiVersionException.java8
2 files changed, 1 insertions, 30 deletions
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).
*
- * <p>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).
- *
- * <p>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);
- }
-}