Wednesday, October 16, 2019

adb - Is it possible to enable Location Services via Shell?


Is it possible to enable Location Services(GPS or Google NetworkLocation) via ADB or Terminal Emulator? I'm on a rooted Phone.



Extra Points: Is it also possible to change other system-related settings?



Answer




Is it possible to enable Location Services(GPS or Google NetworkLocation) via ADB or Terminal Emulator?



The command is:


adb shell settings put secure location_providers_allowed gps

where,




  • settings would makes changes into settings.db (part of com.android.providers.settings)

  • put is to update key location_providers_allowed with value gps in table secure.


The aforesaid command wouldn't enable Google's Location Service. In order to enable it as well, issue the command:


adb shell settings put secure location_providers_allowed gps,network

You would be shown a popup to agree for Location Services. In my Android 4.2.1, I have to agree through GUI or input keyevent every time I enable the service from scratch.


                                                                    IMG: 4.2.1


However, in my Android 5.0 I can save the settings in the dialog and the command execution makes the things done perfectly from the next time.


                                                                    IMG: 5.0



Some devices like Lollipop ones have three Locations modes, and the relevant values to be passed in the aforesaid command would be:



  • High accuracy: gps,wifi,network or gps,network (if you don't want Wi-Fi enabled)

  • Battery saving: wifi,network or network only

  • Device only: gps


To disable Location mode


adb shell settings put secure location_providers_allowed ' '





Is it also possible to change other system-related settings?



See :



But I already gave a big idea using settings put.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...