如何查看使用ADB监控的地理围栏列表?

Bil*_*ote 8 android adb geofencing fusedlocationproviderapi

我正在调试一个位置感知应用程序,我想得到一个当前正由系统监控的Geofences列表 - 即使我只能看到我自己的软件包的Geofences.代码使用的是GoogleApiClient,因此使用了FusedLocation.

我试过adb shell dumpsys location哪个有"Geofences:"的输出部分,但它总是空的.我假设这是遗留位置/地理围栏/邻近.

我也尝试过只adb shell dumpsys搜索该文件以获取地理围栏,但我一无所获.

这两个命令都是在启动应用程序并成功添加要监视的栅栏后运行的.可以在此处找到实现的示例:https://github.com/androidfu/GeofenceExample

gor*_*lue 1

我找到了一种从这个论坛找到活动地理围栏的方法。

使用

adb shell service dumpsys activity service com.google.android.gms/com.google.android.location.internal.GoogleLocationManagerService
Run Code Online (Sandbox Code Playgroud)

由于地理围栏是由 Google 的 Play Services API 处理的,因此您可以从此服务中找到活动的地理围栏。

您可能感兴趣的输出的某些部分:

查看注册的地理围栏,按包分组:

Geofencer State:
Registered geofences:
Active Geofences:
    Package: com.google.android.gms  Tag: geotimezone, count: 4
        Geofence[CIRCLE id:time-zone-00e3f64-2 transitions:1 0.000000, 00.332665 10001260m, resp=900s, dwell=-1ms, @-1] it=5, d=UNKNOWN ? com.google.android.gms
        Geofence[CIRCLE id:time-zone-00e3f64-3 transitions:1 00.170901, 00.000000 10001260m, resp=900s, dwell=-1ms, @-1] it=5, d=UNKNOWN ? com.google.android.gms
        Geofence[CIRCLE id:time-zone-00e3f64-1 transitions:1 -00.209155, -00.000000 10001260m, resp=900s, dwell=-1ms, @-1] it=5, d=UNKNOWN ? com.google.android.gms
        Geofence[CIRCLE id:time-zone-00e3f64-0 transitions:1 0.000000, -161.714795 10001260m, resp=900s, dwell=-1ms, @-1] it=5, d=UNKNOWN ? com.google.android.gms
...
Run Code Online (Sandbox Code Playgroud)

计数器(某些地理围栏活动被注册的次数):

Counters:
  locationRequests: 2
  locationReceived: 0
  sentinelFenceUpdatesNonChre: 0
  sentinelFenceUpdatesChre: 0
  geofenceCountMaximum: 8

  com.google.android.gms:geotimezone:
    addGeofenceRequests: 1
    removeGeofenceRequests: 0
    geofenceEnters: 0
    geofenceExits: 0
    geofenceDwells: 0
    geofenceCountMaximum: 4
    transition/initial(1/5): 8

Run Code Online (Sandbox Code Playgroud)

这个特定活动的输出还有很多内容sysdump,但我只是提取了在我看来与调试具有地理围栏功能的应用程序最相关的内容。

如果这对您很重要,您也可以过滤您想要的内容dumpsys ... | grep