Android DOZE mode GCM Priority

感情迁移 提交于 2019-12-08 20:01:35

I tested non-priority GCM message delivery using an emulator running API 23 and observed the documented behavior: When the emulated device was in Doze mode, the message was not delivered. A few seconds after exiting Doze mode, the message was received.

My test app was built using Goggle Play Services 8.3.0. The emulator image for API 23 includes an older version of Play Services, which resulted in a warning when the app initialized to update to 8.3.0. I don't know how to do that on an emulator. The app successfully registered for and received messages, so I continued with the test.

I put the emulated device into Doze mode with:

$ adb shell dumpsys deviceidle enable

and repeated:

$ adb shell dumpsys deviceidle step

I sent messages using curl, following the instructions provided here. Message receipt was confirmed by observing logcat output.

The deviceidle step command produced states: IDLE_PENDING, SENSING, IDLE_MAINTENANCE, and IDLE. For all but IDLE, messages were received immediately. The message sent while in IDLE was not received. After waiting about a minute, deviceidle step was used to enter IDLE_MAINTENACE state. Within a few seconds, the held message was delivered.

Two suggestions:

  1. If you are not building with Play Services 8.3.0, update to that version.
  2. Use curl and the instructions linked above for sending test messages to see if that produces different behavior than your server code.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!