Speedup android permissions (#2331)

* get android permissions before setiing them

* cleanup

* add newline

* make code nicer

* simplify code

* str()

* utf-8 and nicer exception handling
pull/2324/head
grekiki 5 years ago committed by GitHub
parent f10497a75d
commit 8a952cec33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      common/apk.py

@ -34,9 +34,17 @@ def start_offroad():
threading.Thread(target=f).start()
def set_package_permissions():
pm_grant("ai.comma.plus.offroad", "android.permission.ACCESS_FINE_LOCATION")
pm_grant("ai.comma.plus.offroad", "android.permission.READ_PHONE_STATE")
pm_grant("ai.comma.plus.offroad", "android.permission.READ_EXTERNAL_STORAGE")
try:
output = subprocess.check_output(['dumpsys', 'package', 'ai.comma.plus.offroad'], encoding="utf-8")
given_permissions = output.split("runtime permissions")[1]
except Exception:
given_permissions = ""
wanted_permissions = ["ACCESS_FINE_LOCATION", "READ_PHONE_STATE", "READ_EXTERNAL_STORAGE"]
for permission in wanted_permissions:
if permission not in given_permissions:
pm_grant("ai.comma.plus.offroad", "android.permission."+permission)
appops_set("ai.comma.plus.offroad", "SU", "allow")
appops_set("ai.comma.plus.offroad", "WIFI_SCAN", "allow")

Loading…
Cancel
Save