【GPS】settings数据库查看location(GPS)设置模式的命令

App层
Android平台中,GPS的开启和关闭主要在设置中:
其模式有三种:
1.High accruacy 高精度
使用GPS,Networks,Wi-Fi和Bluetooth进行定位,
准确度最好,但比较费电
2.Battery saving
使用Wi-Fi, Bluetooth和Networks进行定位,
速度快,省电,但是精度较差。
3.Device only
只使用GPS进行定位

 

当Location为“ON”,

Mode为“High accruacy”或者“Device Only”时,

settings数据库location_providers_allowed字段将被修改为“network,gps”或者“gps”(修改字段的代码LocationSettings.java中)。

 

1. 从settings数据库查看location的设置模式:

  adb shell settings get secure location_providers_allowed

利用上述命令得到的结果分析如下:

  1) 关闭gps     结果: 空
  2) 开启gps
            高精度 结果:   network,gps
            网络定位:     network
            gps:             gps  

向settings数据库写值改变UI中Location的模式:

  (1)【假如:location状态为高精度---> network,gps】

    adb shell settings put secure location_providers_allowed -network     --> gps

  (2) 【假如:location状态为高精度---> network,gps】

    adb shell settings put secure location_providers_allowed -gps            --> 网络定位(network)

    (3) 【假如:location状态为高精度---> network,gps】

    adb shell settings put secure location_providers_allowed -network

       adb shell settings put secure location_providers_allowed -gps

                                  --> Location会执行关闭操作

      (4) 在关闭location状态下,执行

    adb shell settings put secure location_providers_allowed +network  -> Location打开并且模式为网络定位

    adb shell settings put secure location_providers_allowed +gps   -> Location打开并且模式为gps

  (5) 当location状态为network时,执行

    adb shell settings put secure location_providers_allowed +gps    -> 高精度

    (6) 当location状态为gps时,执行

    adb shell settings put secure location_providers_allowed +network   -> 高精度

 

2. 从settings数据库查看location是否使用[辅助]网络定位network:

  adb shell settings get global assisted_gps_enabled   [使用服务器来辅助GPS(取消选中可降低网络使用率)]

  1) 关闭gps     结果: 0
  2) 开启gps
            高精度 结果: network,gps  --> 1
            网络定位:   network    --> 1
            gps:            gps        --> 0

  向settings数据库写值:

  adb shell settings put global assisted_gps_enabled 0

  adb shell settings put global assisted_gps_enabled 1

 

posted @ 2018-08-09 21:02  演武_zhuwei  阅读(4454)  评论(0编辑  收藏  举报