LoginSignup
12

More than 5 years have passed since last update.

Android MのDozeにおける状態遷移

Posted at

Android M で adb shell dumpsys deviceidle を実行すると表示される Settings や mState の意味がよくわからなかったので、DeviceIdleController.java のソースコードを読んでまとめてみました。

※ Android Nではさらに Light/Deep Dozeなるものができたらしいですが、そちらはまだ調べてません。

adb shell dumpsys deviceidle の実行結果

SO-02G(Android 6.0.1)での実行結果(抜粋)

$ adb shell dumpsys deviceidle
  Settings:
    inactive_to=+30m0s0ms
    sensing_to=+4m0s0ms
    locating_to=+30s0ms
    location_accuracy=20.0m
    motion_inactive_to=+10m0s0ms
    idle_after_inactive_to=+30m0s0ms
    idle_pending_to=+5m0s0ms
    max_idle_pending_to=+10m0s0ms
    idle_pending_factor=2.0
    idle_to=+60m0s0ms
    max_idle_to=+6h0m0s0ms
    idle_factor=2.0
    min_time_to_alarm=+60m0s0ms
    max_temp_app_whitelist_duration=+5m0s0ms
    mms_temp_app_whitelist_duration=+60s0ms
    sms_temp_app_whitelist_duration=+20s0ms
  mState=INACTIVE

mStateの意味

state description
STATE_ACTIVE Device is currently active.
STATE_INACTIVE Device is inactve (screen off, no motion) and we are waiting to for idle.
STATE_IDLE_PENDING Device is past the initial inactive period, and waiting for the next idle period.
STATE_SENSING Device is currently sensing motion.
STATE_LOCATING Device is currently finding location (and may still be sensing).
STATE_IDLE Device is in the idle state, trying to stay asleep as much as possible.
STATE_IDLE_MAINTENANCE Device is in the idle state, but temporarily out of idle to do regular maintenance.

状態遷移

state machine diagram

State Machine Diagram.png

time chart

time.png

Dozeの流れ

IDLE状態になる

  • 画面消灯か充電ケーブルが外されたことを契機に、30分間待つ (STATE_INACTIVE)
  • さらに30分間、端末が静止しっぱなしであることを待つ (STATE_IDLE_PENDING)
  • より精度の高く電池を消費するモーションセンサーと位置情報測位により、静止状態を判断 (STATE_SENSING, STATE_LOCATING)
  • 以上をもって、1時間のDozeに突入 (STATE_IDLE)
  • 一時的に、5分間だけ起きる (STATE_IDLE_MAINTENANCE)
  • 以降、DozeとMainteの時間は倍々に伸びていく
    • Doze時間の上限は6時間、Mainte時間の上限は10分

1時間放置しておいたら居眠りしちゃうけど、1時間後にちょっとだけ起きる。その後は、2時間、4時間、6時間と居眠りの時間が長くなっていく。

IDLE状態から抜ける

  • 画面点灯/充電開始されると、一気に STATE_ACTIVE へ
    • 再度、1時間静止しないと STATE_IDLE へは戻れない
  • 画面消灯&バッテリー駆動のまま端末が動かされると、 STATE_INACTIVE で10分だけ待つ
    • 初期状態では30分のところを10分のみ
    • ちょっとした移動などによる振動での起床では、IDLEへ戻りやすい
  • 目覚まし時計では、一気に STATE_ACTIVE へ
    • AlarmManager.setAlarmClock() も同様。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12