In order to fulfill the basic functions of our service, the user hereby agrees to allow Xiaomi to collect, process and use personal information which shall include but not be limited to written threads, pictures, comments, replies in the Mi Community, and relevant data types listed in Xiaomi's Private Policy. By selecting "Agree", you agree to Xiaomi's Private Policy and Content Policy .
Agree

Tips & Tricks

[Tutorial] MIUI 8 (M) : Doze Explained & Answered

2016-08-06 17:51:13
16374 14
Edited by R0user at 2016-09-06 03:50 PM



Ever since the advent of MIUI over Marshmallow, there has always been Questions regarding the fate of most talked about feature of Marshmallow:
"Doze!"

  • Is Doze stripped down from MIUI 8?
  • Is it working down the hood?
  • If not, when will it come?

with the advent of MIUI 8 (Marshmallow), It will rise only stronger.

Here we will try answering the same, for once & all, together.
Before we go & discuss about it's presence on MIUI 8 (M), let's dive into Doze First.

DOZE MODE


Doze, as just a term, was used in Kitkat (API 20) for wear later for primary devices with Lollipop, for a mere meaning a "display state" - A new low power screen-on mode for showing non-interactive static content temporarily.

"Doze Mode" introduced with Android Marshmallow holds a different meaning.
It's a forced-idle state of OS where little or no background processing is allowed, specifically when user isn't actively interacting with the device.

Q. We already have a Deep Sleep mode for our processor, how Doze differs?

- Deep Sleep is a state of Processor with very low power consumption, while Doze mode is a state, let's say, of an OS. The more time processor be in Deep sleep state while doing nothing, less power will be spent.

The system & so the apps in it, can hold the processor in the Active state to do something by the use of "wakelock". Even when the screen is off "Partial wakelock" can stop CPU going into the Deep Sleep state, so it might not even enter or for just a fraction of time; wasting energy. This is where Android 6.0 Marshmallow (API 23) came with the answer - Doze mode. It works as a guard in between the apps and cpu, by deferring Background CPU and Network Activity for apps when device is unused for longer periods of time & smartly batching the requests and processing together only at regular interval of time. All this, when it detects that you're not using the phone "actively" (by using the motion sensors)

Understanding DOZE

If a user leaves a device unplugged and stationary for a period of time, with the screen off, the device enters Doze mode. In Doze mode, the system attempts to conserve battery by restricting apps' access to network and CPU-intensive services. It also prevents apps from accessing the network and defers their jobs, syncs, and standard alarms.

Periodically, the system exits Doze for a brief time to let apps complete their deferred activities. During this maintenance window, the system runs all pending syncs, jobs, and alarms, and lets apps access the network.



At the conclusion of each maintenance window, the system again enters Doze, suspending network access and deferring jobs, syncs, and alarms. Over time, the system schedules maintenance windows less and less frequently, helping to reduce battery consumption in cases of longer-term inactivity when the device is not connected to a charger.

As soon as the user wakes the device by moving it, turning on the screen, or connecting a charger, the system exits Doze and all apps return to normal activity.

Doze Restrictions

The following restrictions apply to apps while in Doze:

  • Network access is suspended.
  • The system ignores wake locks.
  • Standard AlarmManager alarms are deferred to the next maintenance window (special alarms fucntions for doze are there)
  • Alarms set with setAlarmClock() continue to fire normally - the system exits Doze shortly before those alarms fire.
  • The system does not perform Wi-Fi scans.
  • The system does not allow sync adapters to run.
  • The system does not allow JobScheduler to run.

Doze Requirements

Doze support requires the following:

  • Device implements the significant motion detector (SMD) APIs in the Sensor HAL. Devices that do not implement these APIs cannot support Doze.
  • Device has a cloud messaging service, such as Google Cloud Messaging (GCM). This enables the device to know when to wake from Doze.

For MI3, testing shows this



"Deviceidlecontroller" - The Warrior Behind

DeviceIdleController is the primary driver of Doze - Let's refer it to device idle mode instead of doze mode since that better fits the code. Going through the official documentation gives the commands to manually enter into doze mode.

$ adb shell dumpsys battery unplug
$ adb shell dumpsys deviceidle step

dumpsys is a binary that interacts with system services. deviceidle is a new system service

we are checking with the MI3W, Lets scan the device services for deviceidle service presence.


As you can see, the service actually exists.
(I'm assuming you already know how to be in debugging via ADB)

This new service is registered at all times to listen for the following system events, which can trigger it into (and out of) this new idle mode:

  • Screen on/off
  • Charging status
  • Significant motion detect

DeviceIdleController maintains a state machine that contains different states. we can manually drive into each state like below & check the behaviour of system.



after entering into the IDLE , it wll only switch back & forth between IDLE & IDLE_MAINTENANCE
Press power button once & you will be stepped to ACTIVE state, whenever you want.


Note:
- Remember, we are manually driving into the doze(idle) mode.
- The device needs to be locked via power button to switch to different states, otherwise only "Active" you will see.
- After execution of "battery unplug" , "adb shell dumpsys battery reset" is necessary at the end of test or you will not see USB charging.
- You can also use "adb shell dumpsys deviceidle force-idle" too skipping both the commands directly.

Manual Testing

Let's leave it to the IDLE state for about 15 Minutes and check for BBS graphs.


Yes, surely It works manually.

MIUI 8 (M) & Doze In Real World Scenarios

In Real world scenarios, Doze doesn't fire that fast, it fires only after predefined time (after above mentioned 3 conditions are met)
Leaving the phone on baterry, unplugged & untouched - Here are the results.



Conclusion

MIUI 8 (M) users, Yes DOZE will work in the background (as long as your device meets the requirements)
For MI3W, yes Doze is definitely working in the background of MIUI 8.

Signing off,
R0user



Rate

Number of participants 6 Experience +42 Pack Reason

View Rating Log

2016-08-06 17:51:13
Favorites8 RateRate
Wow finally we can see the most talked feature of Android M working on MIUI. Thanks for the share bro.
2016-08-06 18:03:11
Proud Mi Fan
Very good thread, thanks for explaining in detail about doze feature, am sure many of us have got clear idea about doze feature  of miui8 now
2016-08-06 18:14:01
One of the best written thread. You explained everything in detail. Kudos for writing such original thread.
2016-08-06 18:24:48

Rookie Bunny

322988076 | from mobile

#4

For those wondering. Root or not (some work for non root but very easy) . Simply download ForceDoze on play store and your battery will thank you.
2016-08-06 18:45:58
Wow.. very good work..
No one goes this deep.. Its been a while I see a post without copy pasting ss & details from Internet. You explained with actual examples.
Keep up ur good work R0user

2016-08-07 13:37:24
Really very useful for educational purposes also it helps to know more about Android system... Thanks for sharing this awesome article
2016-08-07 14:15:21
MI FC BHUBANESWAR PRESIDENT
Thanks for this advanced info. Great indeed !
2016-08-27 14:55:52

Rookie Bunny

Samuel Thomas | from Redmi Note 3

#8

is it compatible wid Redmi note 3 running Android 6.0 on top of MIUI 8
2016-12-19 13:18:55

Admin

R0user Author |

#9

Samuel Thomas replied at 2016-12-19 01:18 PM
is it compatible wid Redmi note 3 running Android 6.0 on top of MIUI 8

Yes, have checked it. It is there
2016-12-19 15:47:41

Rookie Bunny

Samuel Thomas | from Redmi Note 3

#10

R0user
Yes, have checked it. It is there

But the thing is, in nighttime upto 10% battery juice lost....
2016-12-19 16:51:51
please sign in to reply.
Sign In Sign Up
Beta Tester
MIUI 8
Power At Last
AP2 Livestream
2016 Diwali with Mi
3 Days Check-In
7 Days Check-In
21 Days Check-In
40 Days Check-In
70 Days Check-In
100 Days Check-In
Shake!!Shake!!
Lucky Draw No.
500K Members
2016 Christmas
Mi Explorers
2016 #ThrowbackwithMiComm
1 million members
Xiaomi 7th Birthday
Fitness Guru
June-100 replies in a month
Тема мая 2017
1st Anniversary
Columnist
71st Independence Day
MIUI 9
MIUI 7th Anniversary
2 million registered members
Mi A1 Review Contest
Newbie Member
Diwali
Twitter Medal
Android O Tester
Mi Apps
Christmas 2017
2018 New Year Medal
ThrowBackWithMiCommunity
MIUI Instagram
MIUI Beta Tester
Mi Community Updater
STAR Bug Hunter
5-Star Motivator
MIUI 10
MIUI Subscriber
MIUI 8th Anniversary
5 Million Registered Users
Mi Music: 20 FREE Downloads
Ringtones Mania
App Review Team
10 Million Downloads
2019
Throwback With Mi 2018
Xiaomi's 9th Birthday
9 Years of MIUI

Copyright©2016-2019 Xiaomi.com, All Rights Reserved
Content Policy
Quick Reply To Top Return to the list