openatx / uiautomator2

Android Uiautomator2 Python Wrapper
MIT License
6.48k stars 1.38k forks source link

feat:添加“自动授权应用权限”方法,指定包名后自动赋予被测应用运行时所需权限,不再出现运行时权限弹窗,避免对用例执行的干扰 #977

Closed caofengbin closed 4 months ago

caofengbin commented 4 months ago

Android端6.0之后的系统,部分敏感权限系统强制要求运行时动态授权,会对用例执行产生干扰,需要自己处理。

参考Appium的启动参数autoGrantPermissions的实现原理,补齐相关能力。

appium-adb中的实现方式

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 7.14286% with 26 lines in your changes are missing coverage. Please review.

Project coverage is 24.68%. Comparing base (64c6f2b) to head (c11fd22). Report is 1 commits behind head on master.

Files Patch % Lines
uiautomator2/__init__.py 7.14% 26 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #977 +/- ## ========================================== + Coverage 24.39% 24.68% +0.28% ========================================== Files 19 19 Lines 2820 2832 +12 Branches 430 435 +5 ========================================== + Hits 688 699 +11 - Misses 2106 2108 +2 + Partials 26 25 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codeskyblue commented 4 months ago

还是需要调整一下。

这个sdk版本是根据系统的版本来的,而不是根据sdk里面写的版本。

具体可以参考 https://developer.android.com/tools/adb#pm image

https://stackoverflow.com/questions/16410167/how-do-i-use-adb-grant-or-adb-revoke

caofengbin commented 4 months ago

还是需要调整一下。

这个sdk版本是根据系统的版本来的,而不是根据sdk里面写的版本。

具体可以参考 https://developer.android.com/tools/adb#pm image

https://stackoverflow.com/questions/16410167/how-do-i-use-adb-grant-or-adb-revoke

已经修改为通过adb shell getprop ro.build.version.sdk的方式拿到系统版本号,再做判断