[英]How to enable/disable GPS location services on Android 9 via ADB commands (not rooted device)
I'm doing automation for Android and for some tests I need to disable/enable location services from code.我正在为 Android 做自动化,对于一些测试,我需要从代码中禁用/启用位置服务。 I tried such commands:我试过这样的命令:
adb shell settings put secure location_providers_allowed -gps
adb shell settings put secure location_mode 0
but nothing seems to be working on Android 7...9.但在 Android 7...9 上似乎没有任何效果。
Is there any way to do that in one command?有没有办法在一个命令中做到这一点?
Thank you谢谢
Enable: adb shell settings put secure location_mode 3启用:adb shell settings put secure location_mode 3
Disable: adb shell settings put secure location_mode 0禁用:adb shell settings put secure location_mode 0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.