mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-26 08:22:05 +08:00
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
This commit is contained in:
+11
-3
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user