diff options
author | Randy Pan <zpan@google.com> | 2017-04-04 21:40:17 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-04-04 21:40:17 +0000 |
commit | 87160e59e366f16e94cc8aeebe5c7eafde0bbee2 (patch) | |
tree | ff4c33d85903fdd504a086a27b041be8cef5b1af /service | |
parent | 2ca15f4ac6f4f88bbc76f329ab38d52a62a204aa (diff) | |
parent | 19c1d955a4784f12c49714662569c022b51707e6 (diff) |
Merge "Update PNO scan network list upon network update" into oc-dev
am: 19c1d955a4
Change-Id: Ida0575357ccb478f7e88a96a9eed4457698e2465
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigManager.java | 25 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiConnectivityManager.java | 15 |
2 files changed, 40 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index f5789ab9f..47d43aa24 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -147,6 +147,17 @@ public class WifiConfigManager { Integer.MAX_VALUE // threshold for DISABLED_BY_USER_SWITCH }; /** + * Interface for other modules to listen to the saved network updated + * events. + */ + public interface OnSavedNetworkUpdateListener { + /** + * Invoked on saved network being enabled, disabled, blacklisted or + * un-blacklisted. + */ + void onSavedNetworkUpdate(); + } + /** * Max size of scan details to cache in {@link #mScanDetailCaches}. */ @VisibleForTesting @@ -298,6 +309,9 @@ public class WifiConfigManager { private final NetworkListStoreData mNetworkListStoreData; private final DeletedEphemeralSsidsStoreData mDeletedEphemeralSsidsStoreData; + // Store the saved network update listener. + private OnSavedNetworkUpdateListener mListener = null; + /** * Create new instance of WifiConfigManager. */ @@ -1012,6 +1026,7 @@ public class WifiConfigManager { // Unless the added network is ephemeral or Passpoint, persist the network update/addition. if (!config.ephemeral && !config.isPasspoint()) { saveToStore(true); + if (mListener != null) mListener.onSavedNetworkUpdate(); } return result; } @@ -1076,6 +1091,7 @@ public class WifiConfigManager { // Unless the removed network is ephemeral or Passpoint, persist the network removal. if (!config.ephemeral && !config.isPasspoint()) { saveToStore(true); + if (mListener != null) mListener.onSavedNetworkUpdate(); } return true; } @@ -1145,6 +1161,7 @@ public class WifiConfigManager { // Clear out all the disable reason counters. status.clearDisableReasonCounter(); + if (mListener != null) mListener.onSavedNetworkUpdate(); } /** @@ -1169,6 +1186,7 @@ public class WifiConfigManager { status.setDisableTime( NetworkSelectionStatus.INVALID_NETWORK_SELECTION_DISABLE_TIMESTAMP); status.setNetworkSelectionDisableReason(disableReason); + if (mListener != null) mListener.onSavedNetworkUpdate(); } /** @@ -2765,4 +2783,11 @@ public class WifiConfigManager { } return false; } + + /** + * Set the saved network update event listener + */ + public void setOnSavedNetworkUpdateListener(OnSavedNetworkUpdateListener listener) { + mListener = listener; + } } diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java index bb03488e7..bd00b3f5b 100644 --- a/service/java/com/android/server/wifi/WifiConnectivityManager.java +++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java @@ -490,6 +490,18 @@ public class WifiConnectivityManager { private final PnoScanListener mPnoScanListener = new PnoScanListener(); + private class OnSavedNetworkUpdateListener implements + WifiConfigManager.OnSavedNetworkUpdateListener { + public void onSavedNetworkUpdate() { + // Update the PNO scan network list when screen is off. Here we + // rely on startConnectivityScan() to perform all the checks and clean up. + if (!mScreenOn) { + localLog("Saved networks updated"); + startConnectivityScan(false); + } + } + } + /** * WifiConnectivityManager constructor */ @@ -563,6 +575,9 @@ public class WifiConnectivityManager { // Register for all single scan results mScanner.registerScanListener(mAllSingleScanListener); + // Listen to WifiConfigManager network update events + mConfigManager.setOnSavedNetworkUpdateListener(new OnSavedNetworkUpdateListener()); + mWifiConnectivityManagerEnabled = enable; localLog("ConnectivityScanManager initialized and " |