4

I slightly modified this app :https://github.com/commonsguy/cw-omnibus/tree/master/JobScheduler

It set alarms using setExactAndAllowWhileIdle and schedules an alarm to go off every 1 minute and log it.

According to Doze documentation, if this app is running while the phone is in Doze mode, only one alarm should be going off per 15 minutes. I'm not seeing that behavior .

On a a nexus 5 running Android M. After starting the app and the whole alarm scheduling process, I put the phone into Doze using the provided abd commands...

adb shell dumpsys battery unplug adb shell dumpsys deviceidle step adb shell dumpsys deviceidle -h

...From the log, I have seen around 30 minutes of alarms going off once per minute, then finally they are 15 minutes apart for about an hour. Then back to once per minute, and then back to 15 minutes apart. The phone was completely undisturbed during the test.

Does anyone know why this is? I was under the impression that the phone would immediately be in Doze mode after those adb commands , and that the alarms would be going off 15 minutes apart from the start.

Thanks for your help.

4

2 回答 2

1

一方面,相关的 adb 命令文档不完整,正如您在ISSUE 2930的链接中所指出的那样。

以下命令仅打印使用信息:

adb shell dumpsys deviceidle -h

以下命令将显示当前状态,包括进入 IDLE 的先决条件(已启用、未移动、未充电、屏幕关闭):

adb shell dumpsys deviceidle

  Settings:
    ...
  Whitelist (except idle) system apps:
    ...
  Whitelist (except idle) all app ids:
    ...
  mEnabled=true
  mForceIdle=false
  mSigMotionSensor=null
  mCurDisplay=...
  mScreenOn=false
  mCharging=false
  mSigMotionActive=false
  mState=INACTIVE

这表明您是否需要进行更多设置。例如,似乎需要在模拟器的电源按钮上轻按 2 或 3 次才能获得mScreenOn=false.

以下命令逐步进入 IDLE 模式,但ISSUE 2930解释说您需要多次进入 INACTIVE、IDLE_PENDING、SENSING,然后是 IDLE:

adb shell dumpsys deviceidle step

以下命令将强制它进入空闲状态:

adb shell dumpsys deviceidle force-idle

顺便说一句,Doze 和 App Standby的开发人员文档最近得到了改进。

于 2015-10-05T05:43:49.523 回答
1

setExactAndAllowWhileIdle当设备处于空闲模式时,速率限制是不同的。我猜你的手机需要 30 分钟才能通过 Doze 进入空闲模式,此时你将被限制为setExactAndAllowWhileIdle每 15 分钟打一次电话。

在打盹模式下,您的手机将在长达 10 分钟的空闲维护期间定期唤醒。在这 10 分钟内,它将从空闲模式唤醒,您的速率限制将调整为每分钟一次。维护时段结束后,您会看到它恢复到每 15 分钟一次。

空闲维护窗口在文档中进行了描述:http: //developer.android.com/training/monitoring-device-state/doze-standby.html#understand_doze

于 2015-10-13T19:32:16.437 回答