adb shell cmd location(系统服务:location)

1 需求

  • 系统服务:location
    • 查询位置服务状态
      • adb shell cmd location is-location-enabled
    • 开启或关闭 位置服务
      • adb shell cmd location set-location-enabled true

  • 系统服务:settings
    •  
      • adb shell settings get secure location_providers_allowed
    •  
      • adb shell settings put secure location_providers_allowed +gps
    •  
      • adb shell settings put secure location_providers_allowed -gps

2 语法

/frameworks/base/services/core/java/com/android/server/location/LocationShellCommand.java 

Location service commands:
  help or -h
    Print this help text.
  is-location-enabled [--user <USER_ID>]
    Gets the master location switch enabled state. If no user is specified,
    the current user is assumed.
  set-location-enabled true|false [--user <USER_ID>]
    Sets the master location switch enabled state. If no user is specified,
    the current user is assumed.
  providers
    The providers command is followed by a subcommand, as listed below:

    add-test-provider <PROVIDER> [--requiresNetwork] [--requiresSatellite]
      [--requiresCell] [--hasMonetaryCost] [--supportsAltitude]
      [--supportsSpeed] [--supportsBearing]
      [--powerRequirement <POWER_REQUIREMENT>]
      [--extraAttributionTags <TAG>,<TAG>,...]
      Add the given test provider. Requires MOCK_LOCATION permissions which
      can be enabled by running "adb shell appops set <uid>
      android:mock_location allow". There are optional flags that can be
      used to configure the provider properties and additional arguments. If
      no flags are included, then default values will be used.
    remove-test-provider <PROVIDER>
      Remove the given test provider.
    set-test-provider-enabled <PROVIDER> true|false
      Sets the given test provider enabled state.
    set-test-provider-location <PROVIDER> --location <LATITUDE>,<LONGITUDE>
      [--accuracy <ACCURACY>] [--time <TIME>]
      Set location for given test provider. Accuracy and time are optional.
    send-extra-command <PROVIDER> <COMMAND>
      Sends the given extra command to the given provider.

      Common commands that may be supported by the gps provider, depending on
      hardware and software configurations:
        delete_aiding_data - requests deletion of any predictive aiding data
        force_time_injection - requests NTP time injection
        force_psds_injection - requests predictive aiding data injection
        request_power_stats - requests GNSS power stats update

3 示例


4 参考资料

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值