summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorQuang Luong <qal@google.com>2020-04-10 17:54:18 -0700
committerQuang Luong <qal@google.com>2020-04-13 10:55:09 -0700
commit33f77f08365873040980424649a9fe257cde7b1c (patch)
treed3a1008abf7e63f3352d546f639e9808a2fb8bdf /libs
parentedbd063552857947211a0cae78ffc57ce707f8dd (diff)
[WifiTrackerLib] Use WifiInfo RSSI for connected entry
Use the rssi from WifiInfo instead of relying on the scan result rssi if we're connected. This fixes connected entries disappearing due to missed scans, since the rssi from WifiInfo will prevent the entry from being marked as unreachable. Bug: 152623244 Bug: 151344151 Test: manually verify RSSI is being updated in wifi picker Change-Id: Iefe282b1a9d9ec5fc5706e9095a65b9c7dd5fe12
Diffstat (limited to 'libs')
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/BaseWifiTracker.java11
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java7
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java7
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java10
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java24
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 5f8d44ddd..e6680a917 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
@@ -627,14 +627,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);
}
/**