summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNingyuan Wang <nywang@google.com>2017-08-14 12:58:54 -0700
committerNingyuan Wang <nywang@google.com>2017-08-14 14:26:07 -0700
commit47678c136b1f88be3d04d89aa5898e77fa1862a3 (patch)
treea38bfc1ab09abe385fb39bd34d641dcdbb290f8a
parentff14f546b406ead034c70d09381c6dadb9a0062d (diff)
ScanDetailCache cleanup
This renames get() to getScanResult() to provide better consistency with names of other methods. This also adds @NonNull annotation for a few other methods. Bug: 64541323 Test: compile, unit tests Change-Id: I7e61559390dd82f59b07ebfe2ae69ee9bb5152d2
-rw-r--r--service/java/com/android/server/wifi/ScanDetailCache.java7
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java6
5 files changed, 13 insertions, 12 deletions
diff --git a/service/java/com/android/server/wifi/ScanDetailCache.java b/service/java/com/android/server/wifi/ScanDetailCache.java
index 3b69a641b..abb6ad8b0 100644
--- a/service/java/com/android/server/wifi/ScanDetailCache.java
+++ b/service/java/com/android/server/wifi/ScanDetailCache.java
@@ -16,6 +16,7 @@
package com.android.server.wifi;
+import android.annotation.NonNull;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.os.SystemClock;
@@ -73,7 +74,7 @@ public class ScanDetailCache {
* @param bssid provided BSSID
* @return {@code null} if no match ScanResult is found.
*/
- public ScanResult get(String bssid) {
+ public ScanResult getScanResult(String bssid) {
ScanDetail scanDetail = getScanDetail(bssid);
return scanDetail == null ? null : scanDetail.getScanResult();
}
@@ -84,11 +85,11 @@ public class ScanDetailCache {
* @param bssid provided BSSID
* @return {@code null} if no match ScanDetail is found.
*/
- public ScanDetail getScanDetail(String bssid) {
+ public ScanDetail getScanDetail(@NonNull String bssid) {
return mMap.get(bssid);
}
- void remove(String bssid) {
+ void remove(@NonNull String bssid) {
mMap.remove(bssid);
}
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 981733d97..a7dc6a720 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -1927,7 +1927,7 @@ public class WifiConfigManager {
}
// Adding a new BSSID
- ScanResult result = scanDetailCache.get(scanResult.BSSID);
+ ScanResult result = scanDetailCache.getScanResult(scanResult.BSSID);
if (result != null) {
// transfer the black list status
scanResult.blackListTimestamp = result.blackListTimestamp;
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index ce9c09432..2769629e7 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -4861,7 +4861,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
return null;
}
- return scanDetailCache.get(BSSID);
+ return scanDetailCache.getScanResult(BSSID);
}
String getCurrentBSSID() {
@@ -5419,7 +5419,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
ScanDetailCache scanDetailCache =
mWifiConfigManager.getScanDetailCacheForNetwork(config.networkId);
if (scanDetailCache != null && mLastBssid != null) {
- ScanResult scanResult = scanDetailCache.get(mLastBssid);
+ ScanResult scanResult = scanDetailCache.getScanResult(mLastBssid);
if (scanResult != null) {
mWifiInfo.setFrequency(scanResult.frequency);
}
@@ -5972,7 +5972,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
ScanDetailCache scanDetailCache = mWifiConfigManager
.getScanDetailCacheForNetwork(config.networkId);
if (scanDetailCache != null) {
- ScanResult scanResult = scanDetailCache.get(mLastBssid);
+ ScanResult scanResult = scanDetailCache.getScanResult(mLastBssid);
if (scanResult != null) {
mWifiInfo.setFrequency(scanResult.frequency);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 7509c18b3..761c06716 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -1144,7 +1144,7 @@ public class WifiConfigManagerTest {
ScanDetailCache retrievedScanDetailCache =
mWifiConfigManager.getScanDetailCacheForNetwork(result.getNetworkId());
assertEquals(1, retrievedScanDetailCache.size());
- ScanResult retrievedScanResult = retrievedScanDetailCache.get(scanResult.BSSID);
+ ScanResult retrievedScanResult = retrievedScanDetailCache.getScanResult(scanResult.BSSID);
ScanTestUtil.assertScanResultEquals(scanResult, retrievedScanResult);
}
@@ -3971,7 +3971,7 @@ public class WifiConfigManagerTest {
ScanDetailCache retrievedScanDetailCache =
mWifiConfigManager.getScanDetailCacheForNetwork(network.networkId);
assertEquals(1, retrievedScanDetailCache.size());
- ScanResult retrievedScanResult = retrievedScanDetailCache.get(scanResult.BSSID);
+ ScanResult retrievedScanResult = retrievedScanDetailCache.getScanResult(scanResult.BSSID);
ScanTestUtil.assertScanResultEquals(scanResult, retrievedScanResult);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 5d5a5a6aa..5d74279a6 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -969,7 +969,7 @@ public class WifiStateMachineTest {
when(mScanDetailCache.getScanDetail(sBSSID)).thenReturn(
getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq));
- when(mScanDetailCache.get(sBSSID)).thenReturn(
+ when(mScanDetailCache.getScanResult(sBSSID)).thenReturn(
getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq).getScanResult());
mWsm.sendMessage(WifiMonitor.NETWORK_CONNECTION_EVENT, 0, 0, sBSSID);
@@ -1759,7 +1759,7 @@ public class WifiStateMachineTest {
.thenReturn(mScanDetailCache);
when(mScanDetailCache.getScanDetail(sBSSID1)).thenReturn(
getGoogleGuestScanDetail(TEST_RSSI, sBSSID1, sFreq1));
- when(mScanDetailCache.get(sBSSID1)).thenReturn(
+ when(mScanDetailCache.getScanResult(sBSSID1)).thenReturn(
getGoogleGuestScanDetail(TEST_RSSI, sBSSID1, sFreq1).getScanResult());
// This simulates the behavior of roaming to network with |sBSSID1|, |sFreq1|.
@@ -1787,7 +1787,7 @@ public class WifiStateMachineTest {
.thenReturn(mScanDetailCache);
when(mScanDetailCache.getScanDetail(sBSSID1)).thenReturn(
getGoogleGuestScanDetail(TEST_RSSI, sBSSID1, sFreq1));
- when(mScanDetailCache.get(sBSSID1)).thenReturn(
+ when(mScanDetailCache.getScanResult(sBSSID1)).thenReturn(
getGoogleGuestScanDetail(TEST_RSSI, sBSSID1, sFreq1).getScanResult());
// This simulates the behavior of roaming to network with |sBSSID1|, |sFreq1|.