1

For DOZE mode test, I am developing a sample GCM App on Android 6.0.

As it's said, In DOZE mode the device would not wakeup for normal priority GCM. I wanted to check this.

As per the documentation (https://developers.google.com/cloud-messaging/concept-options#setting-the-priority-of-a-message)

Normal priority. This is the default priority for message delivery. Normal priority messages won't open network connections on a sleeping device, and their delivery may be delayed to conserve battery. For less time-sensitive messages, such as notifications of new email or other data to sync, choose normal delivery priority.

I tested my app with some server code from this link. https://stackoverflow.com/a/22169411/4242382

The message I send from server is like this:

$msg = array
(
    'message'       => 'here is a message. message',
    'title'         => 'This is a title. title',
    'subtitle'      => 'This is a subtitle. subtitle',
    'tickerText'    => 'Ticker text here...Ticker text here...Ticker text here',
    'vibrate'   => 1,
    'sound'     => 1
);

As you see there is no priority set, so while in DOZE mode I should not get this immediately. But still the device receives the GCM message immediately.

Method of test

  1. Run the GCM based app
  2. Induce the DOZE mode by issuing commands from adb shell (link) $ adb shell dumpsys battery unplug $ adb shell dumpsys deviceidle step
  3. Send a message from Server (phpfiddle)

Expected behavior : There is no immediate delivery for normal priority GCM Observed behavior : There is an immediate delivery of message

Does the DOZE mode work as per documentation ? I don't see it happening, anybody facing the same?

Community
  • 1
  • 1
veera
  • 69
  • 8
  • How are you confirming that your device is in Doze mode? Are you using [these adb commands](http://developer.android.com/training/monitoring-device-state/doze-standby.html#testing_doze)? – Bob Snyder Nov 30 '15 at 14:44
  • Can you please update your question to contain the adb commands you used? It's best to have all code in your question so it'll still be understandable should the linked resource disappear. – Simon MᶜKenzie Dec 01 '15 at 04:46
  • Are you definitely seeing `IDLE` after you run `adb shell dumpsys deviceidle step`? – Simon MᶜKenzie Dec 01 '15 at 04:53
  • yes, following is the output from **adb shell dumpsys deviceidle** 'mState=IDLE' – veera Dec 01 '15 at 05:32
  • yes @qblx I confirm using the adb commands – veera Dec 01 '15 at 05:45
  • The same problem is [described here](http://stackoverflow.com/questions/33515388/doze-mode-and-gcm-notifications). – Bob Snyder Dec 03 '15 at 06:06
  • If you feel like experimenting, try setting `delay_while_idle` to true. It is an [optional message parameter](https://developers.google.com/cloud-messaging/http-server-ref#downstream-http-messages-json). – Bob Snyder Dec 03 '15 at 07:02

1 Answers1

2

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.
Bob Snyder
  • 37,759
  • 6
  • 111
  • 158
  • 1
    Hi, yes my problem is solved now. Thanks for your suggesstions, I had the latest Play Services library. But the issue was with `adb shell dumpsys deviceidle enable`. I did not do this. As per the documentation, I thought unplug and step are sufficient. Anyway now with this my issue is solved. Thanks a lot. – veera Dec 04 '15 at 10:38
  • 1
    This [AOSP issue](https://code.google.com/p/android-developer-preview/issues/detail?id=2930) discusses the problems with the `dumpsys deviceidle` command. In one of the comments, a Google engineer notes that newer builds support `dumpsys deviceidle force-idle`. That works with the emulator and seems like the simplest way to enter Doze mode. – Bob Snyder Dec 04 '15 at 15:28