{"action":"created","issue":{"url":"https://api.github.com/repos/k9mail/k-9/issues/857","repository_url":"https://api.github.com/repos/k9mail/k-9","labels_url":"https://api.github.com/repos/k9mail/k-9/issues/857/labels{/name}","comments_url":"https://api.github.com/repos/k9mail/k-9/issues/857/comments","events_url":"https://api.github.com/repos/k9mail/k-9/issues/857/events","html_url":"https://github.com/k9mail/k-9/issues/857","id":112928212,"number":857,"title":"Figure out how to deal with Doze (Android 6.0)","user":{"login":"cketti","id":218061,"avatar_url":"https://avatars.githubusercontent.com/u/218061?v=3","gravatar_id":"","url":"https://api.github.com/users/cketti","html_url":"https://github.com/cketti","followers_url":"https://api.github.com/users/cketti/followers","following_url":"https://api.github.com/users/cketti/following{/other_user}","gists_url":"https://api.github.com/users/cketti/gists{/gist_id}","starred_url":"https://api.github.com/users/cketti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cketti/subscriptions","organizations_url":"https://api.github.com/users/cketti/orgs","repos_url":"https://api.github.com/users/cketti/repos","events_url":"https://api.github.com/users/cketti/events{/privacy}","received_events_url":"https://api.github.com/users/cketti/received_events","type":"User","site_admin":false},"labels":[{"id":187334276,"url":"https://api.github.com/repos/k9mail/k-9/labels/enhancement","name":"enhancement","color":"c7def8","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/k9mail/k-9/milestones/8","html_url":"https://github.com/k9mail/k-9/milestone/8","labels_url":"https://api.github.com/repos/k9mail/k-9/milestones/8/labels","id":1656218,"number":8,"title":"Mail synchronization","description":"Issues relating to mail sync","creator":{"login":"philipwhiuk","id":1316415,"avatar_url":"https://avatars.githubusercontent.com/u/1316415?v=3","gravatar_id":"","url":"https://api.github.com/users/philipwhiuk","html_url":"https://github.com/philipwhiuk","followers_url":"https://api.github.com/users/philipwhiuk/followers","following_url":"https://api.github.com/users/philipwhiuk/following{/other_user}","gists_url":"https://api.github.com/users/philipwhiuk/gists{/gist_id}","starred_url":"https://api.github.com/users/philipwhiuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philipwhiuk/subscriptions","organizations_url":"https://api.github.com/users/philipwhiuk/orgs","repos_url":"https://api.github.com/users/philipwhiuk/repos","events_url":"https://api.github.com/users/philipwhiuk/events{/privacy}","received_events_url":"https://api.github.com/users/philipwhiuk/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":4,"state":"open","created_at":"2016-03-20T21:54:37Z","updated_at":"2016-12-08T23:18:59Z","due_on":null,"closed_at":null},"comments":40,"created_at":"2015-10-23T02:09:21Z","updated_at":"2017-01-01T00:04:14Z","closed_at":null,"body":"> Doze reduces battery consumption by deferring background CPU and network activity for apps when the device is unused for long periods of time.\n\nLearn more about it here: [Optimizing for Doze and App Standby](http://developer.android.com/training/monitoring-device-state/doze-standby.html)\n\nAs far as I can tell we have these options:\n1. Embrace Doze. When the device tells us to go to sleep we do.\n2. Fight Doze. Use the new API to schedule checks for new mail (can't be more frequent than every 15 minutes)\n3. Evade Doze. Foreground services (think music player) prevent the device from entering Doze. This requires displaying an ongoing notification.\n\nAs far as I can tell users can't disable Doze in settings. They have, however, the option to put apps on a whitelist.\n\n> An app that is whitelisted can use the network and hold partial wake locks during Doze and App Standby. However, other restrictions still apply to the whitelisted app, just as they do to other apps. For example, the whitelisted app’s jobs and syncs are deferred, and its regular AlarmManager alarms do not fire.\n\nSo the interval between mail checks still has to be at least 15 minutes. But there is a chance that Push might work during Doze. Keeping a connection open doesn't require alarms.\n\nMy goal is to first collect all options we have and then decide on the best way forward. Please let me know if you can think of any other options and I will add them to this post. Also, if you have a special use-case regarding mail checks that you think should be supported by K-9 Mail let us know.\n\n**Update (2015-11-10):** It looks like the only way for an app to prevent the device from entering Doze is to keep the screen on. So option 3 is not something that's feasible for us.\n\n**Update (2015-11-20):** Using a foreground service is possible but tricky due to a bug in Android. See https://commonsware.com/blog/2015/11/18/another-doze-edge-case-foreground.html\n"},"comment":{"url":"https://api.github.com/repos/k9mail/k-9/issues/comments/269886738","html_url":"https://github.com/k9mail/k-9/issues/857#issuecomment-269886738","issue_url":"https://api.github.com/repos/k9mail/k-9/issues/857","id":269886738,"user":{"login":"sidamos","id":873537,"avatar_url":"https://avatars.githubusercontent.com/u/873537?v=3","gravatar_id":"","url":"https://api.github.com/users/sidamos","html_url":"https://github.com/sidamos","followers_url":"https://api.github.com/users/sidamos/followers","following_url":"https://api.github.com/users/sidamos/following{/other_user}","gists_url":"https://api.github.com/users/sidamos/gists{/gist_id}","starred_url":"https://api.github.com/users/sidamos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidamos/subscriptions","organizations_url":"https://api.github.com/users/sidamos/orgs","repos_url":"https://api.github.com/users/sidamos/repos","events_url":"https://api.github.com/users/sidamos/events{/privacy}","received_events_url":"https://api.github.com/users/sidamos/received_events","type":"User","site_admin":false},"created_at":"2017-01-01T00:04:14Z","updated_at":"2017-01-01T00:04:14Z","body":"The implementation of K9 5.2 RC regarding enabling using the new AlarmManager API to be able to fetch mails despite active Doze mode is not optimal.\r\nIt relies on disabling (whitelisting) battery optimization (standby mode) for K9. But that itself has nothing to do with Doze from an Android OS standpoint. So, K9 is just reusing that settings screen for something else.\r\nProblem is, some Android 6.0 implementations do not have this particular settings screen, for example MIUI. I guess, MIUI does not use that \"standby\" mode of Android 6.0, because they have their own ways of battery optimization. It however makes use of Doze mode.\r\nAfter fresh install of K9 5.2, battery optimization of K9 is enabled despite android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS. I checked that by opening the battery optimization screen via a Nova Launcher Activity shortcut. Because of that, K9 does not fetch mails at specified intervals during Doze.\r\nSo, the better thing for K9 would be IMHO to have that setting inside K9 owns preferences screens. It makes more sense."}}
{"actor":{"display_login":"sidamos"}}