【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

 

转载于:https://www.cnblogs.com/zhuwei0901-yanwu/p/9451746.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值