summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-07-25 18:05:57 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-07-25 18:05:57 +0000
commit425676edcb8853bd5aff996a0be6974b06246e46 (patch)
tree4b262dbd7d8131888767812410ef0b71446e2c6b /service
parent6db34c0303b84c1c212a8f013ec90b257fb96052 (diff)
parent0f41a6a3df4a2cedcad60324d91e1fffc968cfbb (diff)
Merge "ONA: Track screen state in WifiNotificationController." into oc-dr1-dev
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiConnectivityManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiNotificationController.java17
2 files changed, 17 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java
index 13863c9bf..4a729e0c5 100644
--- a/service/java/com/android/server/wifi/WifiConnectivityManager.java
+++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java
@@ -1034,6 +1034,8 @@ public class WifiConnectivityManager {
mScreenOn = screenOn;
+ mWifiNotificationController.handleScreenStateChanged(screenOn);
+
startConnectivityScan(SCAN_ON_SCHEDULE);
}
diff --git a/service/java/com/android/server/wifi/WifiNotificationController.java b/service/java/com/android/server/wifi/WifiNotificationController.java
index 3558a8546..797fd438b 100644
--- a/service/java/com/android/server/wifi/WifiNotificationController.java
+++ b/service/java/com/android/server/wifi/WifiNotificationController.java
@@ -77,7 +77,8 @@ public class WifiNotificationController {
* notification is not showing.
*/
private boolean mNotificationShown;
- /** Wi-Fi connection state from {@link WifiConnectivityManager} */
+ /** Whether the screen is on or not. */
+ private boolean mScreenOn;
private final Context mContext;
private FrameworkFacade mFrameworkFacade;
@@ -90,6 +91,8 @@ public class WifiNotificationController {
mFrameworkFacade = framework;
mNotificationBuilder = builder;
+ mScreenOn = false;
+
// Setting is in seconds
NOTIFICATION_REPEAT_DELAY_MS = mFrameworkFacade.getIntegerSetting(context,
Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000L;
@@ -130,13 +133,23 @@ public class WifiNotificationController {
clearPendingNotification(false /* resetRepeatDelay */);
return;
}
- if (mNotificationShown) {
+
+ // Do not show or update the notification if screen is off. We want to avoid a race that
+ // could occur between a user picking a network in settings and a network candidate picked
+ // through network selection, which will happen because screen on triggers a new
+ // connectivity scan.
+ if (mNotificationShown || !mScreenOn) {
return;
}
setNotificationVisible(true, availableNetworks.size(), false, 0);
}
+ /** Handles screen state changes. */
+ public void handleScreenStateChanged(boolean screenOn) {
+ mScreenOn = screenOn;
+ }
+
/**
* Display or don't display a notification that there are open Wi-Fi networks.
* @param visible {@code true} if notification should be visible, {@code false} otherwise