aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Fong <k2fong@hotmail.com>2019-06-26 09:19:09 -0700
committerPeter Fong <k2fong@hotmail.com>2019-06-26 09:19:09 -0700
commita45ca74497012a1c0c0ae4531983e42cecfe8092 (patch)
treeddf4cdf98e5ce7bfef10b860d959af410f43983e
parentaa30a18786c6d46caa3eee47b2558053e88842de (diff)
downloadmobly-bundled-snippets-a45ca74497012a1c0c0ae4531983e42cecfe8092.tar.gz
updated to use target sdk version to check if shell permission is needed
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java10
1 files changed, 5 insertions, 5 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 1cb1680..f14f379 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
@@ -69,7 +69,7 @@ public class WifiManagerSnippet implements Snippet {
mWifiManager =
(WifiManager)
mContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
- if (Build.VERSION.SDK_INT >= 29) {
+ if (mContext.getApplicationContext().getApplicationInfo().targetSdkVersion >= 29) {
UiAutomation uia = InstrumentationRegistry.getInstrumentation().getUiAutomation();
uia.adoptShellPermissionIdentity();
try {
@@ -77,10 +77,10 @@ public class WifiManagerSnippet implements Snippet {
Method destroyMethod = cls.getDeclaredMethod("destroy");
destroyMethod.invoke(uia);
} catch (NoSuchMethodException
- | IllegalAccessException
- | ClassNotFoundException
- | InvocationTargetException e) {
- throw new WifiManagerSnippetException("Failed to cleaup Ui Automation", e);
+ | IllegalAccessException
+ | ClassNotFoundException
+ | InvocationTargetException e) {
+ throw new WifiManagerSnippetException("Failed to cleaup Ui Automation", e);
}
}
}