From a45ca74497012a1c0c0ae4531983e42cecfe8092 Mon Sep 17 00:00:00 2001 From: Peter Fong Date: Wed, 26 Jun 2019 09:19:09 -0700 Subject: updated to use target sdk version to check if shell permission is needed --- .../android/mobly/snippet/bundled/WifiManagerSnippet.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main/java/com/google') 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); } } } -- cgit v1.2.3