diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-06-11 21:06:12 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-11 21:06:12 +0000 |
commit | b94df9a0348bda50e11195df1f6829d618260999 (patch) | |
tree | 0ea50c1e84ee25b24f14c5e1895bc89b0c26f514 /libs | |
parent | 36c7a3388161f25c71c1aa9cd02c9461dc6850fb (diff) | |
parent | 7299eb5412ffb60baf945d470276083e4654bab3 (diff) |
Merge "[WifiTrackerLib] Cache NetworkInfo from NETWORK_STATE_CHANGED" into rvc-dev am: 6b92c5ac8d am: 7299eb5412
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/net/wifi/+/11813174
Change-Id: Ide1724c157c06e43023f131285271df5b997bbca
Diffstat (limited to 'libs')
3 files changed, 21 insertions, 19 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java index 9bd2a5905..e2d7acc8e 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java @@ -26,6 +26,7 @@ import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.LinkProperties; +import android.net.Network; import android.net.NetworkInfo; import android.net.NetworkScoreManager; import android.net.wifi.ScanResult; @@ -57,6 +58,7 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker { private final PasspointWifiEntry mChosenEntry; private OsuWifiEntry mOsuWifiEntry; + private NetworkInfo mCurrentNetworkInfo; PasspointNetworkDetailsTracker(@NonNull Lifecycle lifecycle, @NonNull Context context, @@ -104,8 +106,9 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker { conditionallyUpdateScanResults(true /* lastScanSucceeded */); conditionallyUpdateConfig(); final WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); - final NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo(); - mChosenEntry.updateConnectionInfo(wifiInfo, networkInfo); + final Network currentNetwork = mWifiManager.getCurrentNetwork(); + mCurrentNetworkInfo = mConnectivityManager.getNetworkInfo(currentNetwork); + mChosenEntry.updateConnectionInfo(wifiInfo, mCurrentNetworkInfo); handleLinkPropertiesChanged(mConnectivityManager.getLinkProperties( mWifiManager.getCurrentNetwork())); } @@ -141,16 +144,15 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker { @WorkerThread @Override protected void handleRssiChangedAction() { - mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), - mConnectivityManager.getActiveNetworkInfo()); + mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), mCurrentNetworkInfo); } @WorkerThread @Override protected void handleNetworkStateChangedAction(@NonNull Intent intent) { checkNotNull(intent, "Intent cannot be null!"); - mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), - (NetworkInfo) intent.getExtra(WifiManager.EXTRA_NETWORK_INFO)); + mCurrentNetworkInfo = (NetworkInfo) intent.getExtra(WifiManager.EXTRA_NETWORK_INFO); + mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), mCurrentNetworkInfo); } @WorkerThread diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java index b89c8ab9b..3ef1b4727 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java @@ -31,6 +31,7 @@ import android.net.ConnectivityManager; import android.net.LinkProperties; import android.net.Network; import android.net.NetworkCapabilities; +import android.net.NetworkInfo; import android.net.NetworkScoreManager; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; @@ -55,6 +56,7 @@ class StandardNetworkDetailsTracker extends NetworkDetailsTracker { private final StandardWifiEntry mChosenEntry; private final boolean mIsNetworkRequest; + private NetworkInfo mCurrentNetworkInfo; StandardNetworkDetailsTracker(@NonNull Lifecycle lifecycle, @NonNull Context context, @@ -84,8 +86,8 @@ class StandardNetworkDetailsTracker extends NetworkDetailsTracker { conditionallyUpdateConfig(); final WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); final Network currentNetwork = mWifiManager.getCurrentNetwork(); - mChosenEntry.updateConnectionInfo(wifiInfo, mConnectivityManager - .getNetworkInfo(currentNetwork)); + mCurrentNetworkInfo = mConnectivityManager.getNetworkInfo(currentNetwork); + mChosenEntry.updateConnectionInfo(wifiInfo, mCurrentNetworkInfo); handleLinkPropertiesChanged(mConnectivityManager.getLinkProperties(currentNetwork)); } @@ -134,15 +136,14 @@ class StandardNetworkDetailsTracker extends NetworkDetailsTracker { @Override protected void handleNetworkStateChangedAction(@NonNull Intent intent) { checkNotNull(intent, "Intent cannot be null!"); - mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), - mConnectivityManager.getNetworkInfo(mWifiManager.getCurrentNetwork())); + mCurrentNetworkInfo = (NetworkInfo) intent.getExtra(WifiManager.EXTRA_NETWORK_INFO); + mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), mCurrentNetworkInfo); } @WorkerThread @Override protected void handleRssiChangedAction() { - mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), - mConnectivityManager.getNetworkInfo(mWifiManager.getCurrentNetwork())); + mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(), mCurrentNetworkInfo); } @WorkerThread diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java index 2b433bb76..bb3a2246a 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java @@ -96,6 +96,7 @@ public class WifiPickerTracker extends BaseWifiTracker { // NetworkRequestEntry representing a network that was connected through the NetworkRequest API private NetworkRequestEntry mNetworkRequestEntry; + private NetworkInfo mCurrentNetworkInfo; // Cache containing saved WifiConfigurations mapped by StandardWifiEntry key private final Map<String, WifiConfiguration> mWifiConfigCache = new HashMap<>(); // Cache containing suggested WifiConfigurations mapped by StandardWifiEntry key @@ -192,7 +193,8 @@ public class WifiPickerTracker extends BaseWifiTracker { conditionallyUpdateScanResults(true /* lastScanSucceeded */); final WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); final Network currentNetwork = mWifiManager.getCurrentNetwork(); - updateConnectionInfo(wifiInfo, mConnectivityManager.getNetworkInfo(currentNetwork)); + mCurrentNetworkInfo = mConnectivityManager.getNetworkInfo(currentNetwork); + updateConnectionInfo(wifiInfo, mCurrentNetworkInfo); handleLinkPropertiesChanged(mConnectivityManager.getLinkProperties(currentNetwork)); notifyOnNumSavedNetworksChanged(); notifyOnNumSavedSubscriptionsChanged(); @@ -245,9 +247,8 @@ public class WifiPickerTracker extends BaseWifiTracker { protected void handleNetworkStateChangedAction(@NonNull Intent intent) { checkNotNull(intent, "Intent cannot be null!"); final WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); - final NetworkInfo networkInfo = - (NetworkInfo) intent.getExtra(WifiManager.EXTRA_NETWORK_INFO); - updateConnectionInfo(wifiInfo, networkInfo); + mCurrentNetworkInfo = (NetworkInfo) intent.getExtra(WifiManager.EXTRA_NETWORK_INFO); + updateConnectionInfo(wifiInfo, mCurrentNetworkInfo); updateWifiEntries(); } @@ -256,9 +257,7 @@ public class WifiPickerTracker extends BaseWifiTracker { protected void handleRssiChangedAction() { if (mConnectedWifiEntry != null) { final WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); - final NetworkInfo networkInfo = mConnectivityManager.getNetworkInfo( - mWifiManager.getCurrentNetwork()); - mConnectedWifiEntry.updateConnectionInfo(wifiInfo, networkInfo); + mConnectedWifiEntry.updateConnectionInfo(wifiInfo, mCurrentNetworkInfo); } } |