Skip to content
Snippets Groups Projects
Verified Commit dcd6fda0 authored by akwizgran's avatar akwizgran
Browse files

Check connectivity after entering or leaving doze mode.

parent 25354458
No related branches found
No related tags found
1 merge request!874Factor network management code out of plugins
...@@ -114,8 +114,7 @@ class AndroidNetworkManager implements NetworkManager, Service { ...@@ -114,8 +114,7 @@ class AndroidNetworkManager implements NetworkManager, Service {
String action = i.getAction(); String action = i.getAction();
if (LOG.isLoggable(INFO)) LOG.info("Received broadcast " + action); if (LOG.isLoggable(INFO)) LOG.info("Received broadcast " + action);
updateConnectionStatus(); updateConnectionStatus();
// TODO: Also schedule update after idle mode changes if (isSleepOrDozeEvent(i)) {
if (isSleepEvent(i)) {
scheduleConnectionStatusUpdate(1, MINUTES); scheduleConnectionStatusUpdate(1, MINUTES);
} else if (isApEnabledEvent(i)) { } else if (isApEnabledEvent(i)) {
// The state change may be broadcast before the AP address is // The state change may be broadcast before the AP address is
...@@ -125,9 +124,13 @@ class AndroidNetworkManager implements NetworkManager, Service { ...@@ -125,9 +124,13 @@ class AndroidNetworkManager implements NetworkManager, Service {
} }
} }
private boolean isSleepEvent(Intent i) { private boolean isSleepOrDozeEvent(Intent i) {
return ACTION_SCREEN_ON.equals(i.getAction()) || String action = i.getAction();
ACTION_SCREEN_OFF.equals(i.getAction()); boolean isSleep = ACTION_SCREEN_ON.equals(action) ||
ACTION_SCREEN_OFF.equals(action);
boolean isDoze = SDK_INT >= 23 &&
ACTION_DEVICE_IDLE_MODE_CHANGED.equals(action);
return isSleep || isDoze;
} }
private boolean isApEnabledEvent(Intent i) { private boolean isApEnabledEvent(Intent i) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment