Wednesday, May 25, 2016

How to detect GPS status through adb shell?


I need to detect GPS status through adb shell. I have tried dumpsys location command but the output of this command is not changed when the GPS is enabled/disabled.




Answer



You can use this command:


adb shell settings get secure location_providers_allowed

Possible outcomes:



  • returns nothing, implying the GPS is switched off.

  • gps,wifi,network or gps,network -- High accuracy mode

  • wifi,network or network only -- Battery saving mode

  • gps -- Device only



No comments:

Post a Comment