打ze/待机功能如何影响位置更新? [英] How does Doze/Standby feature affect location updates?

查看:83
本文介绍了打ze/待机功能如何影响位置更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道持有部分唤醒锁的白名单应用程序在设备处于打ze状态或待机状态时是否可以接收位置更新吗?

Android文档( http://developer.android.com/training/monitoring-device-state/doze-standby.html )仅声明CPU和网络已延迟,并且未提及对位置更新的任何影响(例如,来自LocationManager).基于此,位置更新似乎不受Doze/Standby的影响,因此,如果某个应用持有部分唤醒锁(以保持CPU运行),则该应用应该能够接收位置更新.

我已经实现了这一点并对其进行了测试,结果发现,即使应用程序具有部分唤醒锁并被列入白名单,它似乎也不会在Doze中接收位置更新.有趣的是,当我将设备放在带有唤醒锁的应用程序上过夜时,早上的电池几乎没电了,但是当重复使用没有唤醒锁的应用程序时,早上的电池几乎已满了.因此,看来该应用程序一直在运行,但是没有收到位置更新.

一些额外的背景信息:该应用程序用于车队跟踪,因此我们试图确定是否有某个应用程序可以运行后台服务,以便在依靠电池供电时可靠地接收位置更新.

谢谢!-汤姆B.

解决方案

是的,这似乎是打ze睡模式下的另一个未记录的限制,例如我的 https://code提交有关所有这方面的错误报告..google.com/p/android/issues/list

Does anyone know if a whitelisted app that is holding a partial wake-lock can receive location updates while the device is in Doze or the app is in Standby?

The Android docs (http://developer.android.com/training/monitoring-device-state/doze-standby.html) only state that CPU and network are deferred and do not mention any affect on location updates (i.e. from the LocationManager). Based on this, it would seem that location updates are not affected by Doze/Standby, so if an app is holding a partial wake-lock (to keep the CPU running) then the app should be able to receive location updates.

I've implemented this and tested it and found that an app does not appear to receive location updates in Doze even though it has a partial wake-lock and is whitelisted. Interestingly, when I left the device on my desk overnight running the app with the wake-lock, the battery was nearly empty in the morning, but when repeating with the app without the wake-lock, the battery was nearly full in the morning. So it does appear that the app was running the whole time, but was not receiving location updates.

A little extra background: The app is used for fleet tracking, so we're trying to figure out if there is anyway for an app to have a background service running that reliably receives location updates when running on battery power.

Thanks! -Tom B.

解决方案

Yes, this seems to be another undocumented restriction in Doze mode, as my test logs also show. My guess was that some hardware features like GPS are generally turned off in Doze, but maybe it's the LocationManager being disabled altogether.

As this might just be a severe lack of documentation, the battery drain you mention should definitely not happen in Doze, as that's exactly what Doze is meaning to prevent in the first place.

You may want to file a bug report about all this at https://code.google.com/p/android/issues/list

这篇关于打ze/待机功能如何影响位置更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆