Dozy Android

I’ve just spent a good couple of hours sorting out a problem with my new phone, which has no good reason to exist. In fairness to Sony, it’s nothing to do with them: the issue sits squarely with Google and yet another "improvement" to Android which turns out to be nothing of the sort.

A watch-based alarm doesn’t work very well for me – my hearing is just not good enough. Seeking to reduce the amount of gadgets I carry, I have therefore for many years relied on phones and their PDA predecessors to fulfil the function of alarm clock, especially when I’m travelling. It’s not a difficult role, and I have not had to complain about it. Until now.

In my normal weekly cycle I don’t have much need for a clock as I wake naturally at about the right time each day. This makes the operation of such a function even more critical, as it has to be absolutely reliable on days which are exceptions, and I don’t get much opportunity to do much advance "testing" of what I assume is something that should "just work". However, I do have the alarm set every day when I’m working away from the home, and although I couldn’t be absolutely sure I was coming to suspect that it wasn’t going off at the right time. The first couple of times I assumed "user error": incorrect settings, volume too low etc., but I had eventually eliminated those, and confirmed the behaviour: the alarm didn’t go off at the programmed time. It went off after I had woken up and clicked the button to wake up my phone’s screen.

This is about as useful as a chocolate fireguard, and about as welcome as a fart in a spacesuit.

A bit of Googling confirmed that the problem is quite widespread. I’ve read stories of people with new phones being late for work or missing important appointments. Others describe a similar problem with other programs including not getting notified promptly of night-time messages or similar: potentially quite a problem for those "on call". Fortunately I caught the problem before it caused me any trouble, but that might not have been the case, as I have an upcoming trip with about 8 flights and several other dawn starts.

The web is full of useless "solutions" like factory resetting the phone, but after eliminating those, I tracked down the cause of the problem. With Android 6 ("Marshmallow"), Google introduced something called "Doze" mode. This is a deep sleep mode which kicks in if the device is at rest, screen off, and no significant ongoing activity like an active data transfer. You know, like it tends to be at night. In this state, the system not only slows down processing, but also suspends the bulk of normal background activity. This includes, for no articulated good reason, suspending timers and related event triggers. So your alarm application doesn’t know what time it is, and doesn’t fire. Your messaging app doesn’t know when to poll for incoming events. Simple, core functions of your smartphone just cease to work.

Allegedly, if you change the code of your alarm or other app to use a "different kind" of timer, that should work, but after testing four or five I concluded that this is just not true, certainly on my phone. In any case, I usually just use the stock Android "clock" app, and surely they would have remembered to update that, wouldn’t they? You can also nominally turn off Doze for selected applications, but as far as I can see it makes bugger all difference.

It turns out that the root problem is that in at least some Android 6 implementations, Doze mode actually disables the underlying operating system events on which the other timers are based. It doesn’t matter how sexy your alarm app is, or whether Doze knows about it or not, if the underlying timers are blocked!

There’s a heap of advice on the web about how to disable Doze for individual apps (tried that, doesn’t work), but not about how to disable it completely. I’d tried all sorts of settings without success. However I finally found a useful little app called Disable Doze, which does what it says on the tin, and turns Doze off completely. Allegedly (according to Google) this would result in my phone discharging its battery at a terrifying  rate and ending up doing a Galaxy Note 7 impersonation, but I can confirm that with Doze off in light use my phone is still only consuming about 10% battery per day. The only noticeable effect so far is that alarms and notifications work again.

My worry is that until Google acknowledge their mistakes, they may come up with another "improvement" which disables this fix. I don’t know what tests Google perform in this area, but they are clearly inadequate. This really is a "0 out of 10" effort, a true "breaking change".

However for now things are looking good, and hopefully this blog will help alert others to the problem and the fix.

Leave a Reply

Your email address will not be published. Required fields are marked *