diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-04-13 19:22:50 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-13 19:22:50 +0000 |
commit | 3b95536f3a8856424f20b422eab91355e97b3cc0 (patch) | |
tree | 2f3414a4a06947b170d5d4328b9b7be8b3e899b1 | |
parent | b496914f4fe3e4def90464b703593b03dafa1d43 (diff) | |
parent | 33f77f08365873040980424649a9fe257cde7b1c (diff) |
Merge "[WifiTrackerLib] Use WifiInfo RSSI for connected entry" into rvc-dev
5 files changed, 46 insertions, 13 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/BaseWifiTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/BaseWifiTracker.java index 2c749ad2e..bc551c20d 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/BaseWifiTracker.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/BaseWifiTracker.java @@ -109,6 +109,8 @@ public class BaseWifiTracker implements LifecycleObserver { handleConfiguredNetworksChangedAction(intent); } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) { handleNetworkStateChangedAction(intent); + } else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) { + handleRssiChangedAction(); } } }; @@ -199,6 +201,7 @@ public class BaseWifiTracker implements LifecycleObserver { filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); filter.addAction(WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); + filter.addAction(WifiManager.RSSI_CHANGED_ACTION); mContext.registerReceiver(mBroadcastReceiver, filter, /* broadcastPermission */ null, mWorkerHandler); mConnectivityManager.registerNetworkCallback(mNetworkRequest, mNetworkCallback, @@ -279,6 +282,14 @@ public class BaseWifiTracker implements LifecycleObserver { } /** + * Handle receiving the WifiManager.RSSI_CHANGED_ACTION broadcast + */ + @WorkerThread + protected void handleRssiChangedAction() { + // Do nothing. + } + + /** * Handle link property changes for the current connected Wifi network. */ @WorkerThread diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java index a5b489a72..22d200fc2 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java @@ -119,6 +119,13 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker { @WorkerThread @Override + protected void handleRssiChangedAction() { + mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), + mConnectivityManager.getActiveNetworkInfo()); + } + + @WorkerThread + @Override protected void handleNetworkStateChangedAction(@NonNull Intent intent) { checkNotNull(intent, "Intent cannot be null!"); mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java index 68f58ddc3..65560d60f 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java @@ -132,6 +132,13 @@ class StandardNetworkDetailsTracker extends NetworkDetailsTracker { @WorkerThread @Override + protected void handleRssiChangedAction() { + mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), + mConnectivityManager.getActiveNetworkInfo()); + } + + @WorkerThread + @Override protected void handleLinkPropertiesChanged(@Nullable LinkProperties linkProperties) { if (mChosenEntry.getConnectedState() == CONNECTED_STATE_CONNECTED) { mChosenEntry.updateLinkProperties(linkProperties); diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java index a6c322656..f6c3a2b2e 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java @@ -643,14 +643,16 @@ public class StandardWifiEntry extends WifiEntry { } final ScanResult bestScanResult = getBestScanResultByLevel(scanResults); - if (bestScanResult == null) { - mLevel = WIFI_LEVEL_UNREACHABLE; - } else { - mLevel = mWifiManager.calculateSignalLevel(bestScanResult.level); + if (bestScanResult != null) { updateEapType(bestScanResult); updatePskType(bestScanResult); } + if (getConnectedState() == CONNECTED_STATE_DISCONNECTED) { + mLevel = bestScanResult != null + ? mWifiManager.calculateSignalLevel(bestScanResult.level) + : WIFI_LEVEL_UNREACHABLE; + } notifyOnUpdated(); } diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java index c08b47cd1..86845c7b4 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java @@ -187,10 +187,6 @@ public class WifiPickerTracker extends BaseWifiTracker { final WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); final NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo(); updateConnectionInfo(wifiInfo, networkInfo); - // Create a StandardWifiEntry for the current connection if there are no scan results yet. - conditionallyCreateConnectedStandardWifiEntry(wifiInfo, networkInfo); - conditionallyCreateConnectedSuggestedWifiEntry(wifiInfo, networkInfo); - conditionallyCreateConnectedPasspointWifiEntry(wifiInfo, networkInfo); handleLinkPropertiesChanged(mConnectivityManager.getLinkProperties( mWifiManager.getCurrentNetwork())); notifyOnNumSavedNetworksChanged(); @@ -222,7 +218,7 @@ public class WifiPickerTracker extends BaseWifiTracker { final WifiConfiguration config = (WifiConfiguration) intent.getExtra(WifiManager.EXTRA_WIFI_CONFIGURATION); - if (config != null && !config.isPasspoint() && !config.fromWifiNetworkSuggestion) { + if (config != null && !config.isEphemeral() && !config.isPasspoint()) { updateStandardWifiEntryConfig( config, (Integer) intent.getExtra(WifiManager.EXTRA_CHANGE_REASON)); } else { @@ -250,15 +246,21 @@ public class WifiPickerTracker extends BaseWifiTracker { final NetworkInfo networkInfo = (NetworkInfo) intent.getExtra(WifiManager.EXTRA_NETWORK_INFO); updateConnectionInfo(wifiInfo, networkInfo); - // Create a StandardWifiEntry for the current connection if there are no scan results yet. - conditionallyCreateConnectedStandardWifiEntry(wifiInfo, networkInfo); - conditionallyCreateConnectedSuggestedWifiEntry(wifiInfo, networkInfo); - conditionallyCreateConnectedPasspointWifiEntry(wifiInfo, networkInfo); updateWifiEntries(); } @WorkerThread @Override + protected void handleRssiChangedAction() { + if (mConnectedWifiEntry != null) { + final WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); + final NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo(); + mConnectedWifiEntry.updateConnectionInfo(wifiInfo, networkInfo); + } + } + + @WorkerThread + @Override protected void handleLinkPropertiesChanged(@Nullable LinkProperties linkProperties) { if (mConnectedWifiEntry != null && mConnectedWifiEntry.getConnectedState() == CONNECTED_STATE_CONNECTED) { @@ -641,6 +643,10 @@ public class WifiPickerTracker extends BaseWifiTracker { for (WifiEntry entry : mOsuWifiEntryCache.values()) { entry.updateConnectionInfo(wifiInfo, networkInfo); } + // Create a StandardWifiEntry for the current connection if there are no scan results yet. + conditionallyCreateConnectedStandardWifiEntry(wifiInfo, networkInfo); + conditionallyCreateConnectedSuggestedWifiEntry(wifiInfo, networkInfo); + conditionallyCreateConnectedPasspointWifiEntry(wifiInfo, networkInfo); } /** |