Check connectivity after entering or leaving doze mode.

This commit is contained in:
akwizgran
2018-08-02 11:55:40 +01:00
parent 2535445831
commit dcd6fda046

View File

@@ -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 {
} }
} }
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) {