将辅助数据注入 GPS
我正在尝试开发一个使用 GPS 的应用程序,我想向 GPS 注入 XTRA 数据和时间参考,以便更快地修复。我的代码如下:
Bundle bundle = new Bundle();
boolean xtraInjection=locationmanager.sendExtraCommand(LocationManager.GPS_PROVIDER,"force_xtra_injection",bundle);
boolean timeInjection=locationmanager.sendExtraCommand(LocationManager.GPS_PROVIDER,"force_time_injection",bundle);
无论互联网连接打开还是关闭(没有蜂窝网络,也没有wifi),xtraInjection 和 timeInjection 布尔值始终为真。所以,我无法检测辅助信息是否良好 注入GPS。
启用 wifi 连接后,将出现下一条日志消息(如果 wifi 关闭,则不会出现错误消息):
I/app ( 627): timeInjection:true
....
D/GpsLocationProvider( 96): NTP server returned: 1306322421969 (WedMay 25 13:20:21 GMT+02:00 2011) reference: 338139 certainty: 77 systemtime offset: 7162
D/lib_locapi( 96): loc_eng_inject_time, uncertainty = 77
相反,没有与 XTRA 数据相关的日志消息。如果XTRA数据仍然有效,系统不会请求它?如何查看是否注入成功?
为了进行这些测试,我还尝试删除辅助数据,但我知道这做得不好:
我的代码:
boolean reset=locationmanager.sendExtraCommand(LocationManager.GPS_PROVIDER, "delete_aiding_data", null);
日志:
I/app ( 627): reset:false
D/lib_locapi( 96): loc_eng_ioctl for aiding data deletion returned 0, 1 for success
我也尝试过使用 GPS 状态应用程序,注入和删除的结果相同。
简而言之,我不知道问题是出在我的代码中还是驱动程序实现中。除了logcat之外还有什么方法可以获得这些问题的更多信息呢? (我无法root我的设备)。
先感谢您
I am trying to develop an application which uses GPS and I would like to inject XTRA data and time reference to the GPS in order to get a faster fix. My code is the following one:
Bundle bundle = new Bundle();
boolean xtraInjection=locationmanager.sendExtraCommand(LocationManager.GPS_PROVIDER,"force_xtra_injection",bundle);
boolean timeInjection=locationmanager.sendExtraCommand(LocationManager.GPS_PROVIDER,"force_time_injection",bundle);
No matter whether internet connection is on or off (no cellular neither wifi) the xtraInjection and timeInjection booleans are always true. So, I not able to detect if the assistance information is well
injected into the GPS.
When the wifi connection is enabled, the next log message appears (no error message if wifi is down):
I/app ( 627): timeInjection:true
....
D/GpsLocationProvider( 96): NTP server returned: 1306322421969 (WedMay 25 13:20:21 GMT+02:00 2011) reference: 338139 certainty: 77 systemtime offset: 7162
D/lib_locapi( 96): loc_eng_inject_time, uncertainty = 77
In contrast, there is no log message related with XTRA data. If the XTRA data is still valid, the system does not request for it? How can I see if it is injected successfully?
To make these tests I have also tried deleting assistance data but I know that this is not well done:
My code:
boolean reset=locationmanager.sendExtraCommand(LocationManager.GPS_PROVIDER, "delete_aiding_data", null);
log:
I/app ( 627): reset:false
D/lib_locapi( 96): loc_eng_ioctl for aiding data deletion returned 0, 1 for success
I have also tried with GPS STATUS application and the results are the same for both, inject and delete.
In short, I do not know whether the problem is in my code or is something in the driver implementation. There is any way to obtain more information about these problems apart from logcat? (I can not root my device).
Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看
frameworks/base/services/java/com/android/server/location/GpsLocationProvider.java
,您会发现这些命令将始终返回 true。您应该这样做的原因很少,不应该这样做的原因也有几个:
If you look at
frameworks/base/services/java/com/android/server/location/GpsLocationProvider.java
, you'll find that these commands will always return true.There is very little reason why you should be doing this, and a few reasons why you shouldn't: