diff options
author | Stephen Chen <stewchen@google.com> | 2017-07-18 11:43:39 -0700 |
---|---|---|
committer | Stephen Chen <stewchen@google.com> | 2017-07-24 11:08:23 -0700 |
commit | 0f41a6a3df4a2cedcad60324d91e1fffc968cfbb (patch) | |
tree | 6a985556e65e357a9d4701dfeb016a1a0e4331db /service | |
parent | 3f8483262cf59572d0c0b3c42e72d8ce65a096ff (diff) |
ONA: Track screen state in WifiNotificationController.
The Open Networks Available notification should not be shown when the
screen is off.
Bug: 38460614
Bug: 37357441
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: I445f95a624009f492c3abd8a9f815706e221ea44
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiConnectivityManager.java | 2 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiNotificationController.java | 17 |
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 |