Merge "Always use SSID average for SpeedLabel." into oc-mr1-dev

This commit is contained in:
TreeHugger Robot
2017-09-05 21:44:30 +00:00
committed by Android (Google) Code Review
2 changed files with 5 additions and 68 deletions

View File

@@ -496,23 +496,6 @@ public class AccessPoint implements Comparable<AccessPoint> {
int oldSpeed = mSpeed;
mSpeed = generateAverageSpeedForSsid();
// set speed to the connected ScanResult if the AccessPoint is the active network
if (isActive() && mInfo != null) {
TimestampedScoredNetwork timedScore = mScoredNetworkCache.get(mInfo.getBSSID());
if (timedScore != null) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Set score using specific access point curve for connected AP: "
+ getSsidStr());
}
// TODO(b/63073866): Map using getLevel rather than specific rssi value so score
// doesn't change without a visible wifi bar change.
int speed = timedScore.getScore().calculateBadge(mInfo.getRssi());
if (speed != Speed.NONE) {
mSpeed = speed;
}
}
}
boolean changed = oldSpeed != mSpeed;
if(WifiTracker.sVerboseLogging && changed) {
Log.i(TAG, String.format("%s: Set speed to %d", ssid, mSpeed));
@@ -531,6 +514,10 @@ public class AccessPoint implements Comparable<AccessPoint> {
getSsidStr(), mScoredNetworkCache));
}
// TODO(b/63073866): If flickering issues persist, consider mapping using getLevel rather
// than specific rssi value so score doesn't change without a visible wifi bar change. This
// issue is likely to be more evident for the active AP whose RSSI value is not half-lifed.
int count = 0;
int totalSpeed = 0;
for (TimestampedScoredNetwork timedScore : mScoredNetworkCache.values()) {

View File

@@ -416,56 +416,6 @@ public class AccessPointTest {
.isEqualTo(mContext.getString(R.string.speed_label_slow));
}
@Test
public void testSpeedLabel_isDerivedFromConnectedBssidWhenScoreAvailable() {
int rssi = -55;
String bssid = "00:00:00:00:00:00";
int networkId = 123;
WifiInfo info = new WifiInfo();
info.setRssi(rssi);
info.setSSID(WifiSsid.createFromAsciiEncoded(TEST_SSID));
info.setBSSID(bssid);
info.setNetworkId(networkId);
ArrayList<ScanResult> scanResults = new ArrayList<>();
ScanResult scanResultUnconnected = createScanResult(TEST_SSID, "11:11:11:11:11:11", rssi);
scanResults.add(scanResultUnconnected);
ScanResult scanResultConnected = createScanResult(TEST_SSID, bssid, rssi);
scanResults.add(scanResultConnected);
AccessPoint ap =
new TestAccessPointBuilder(mContext)
.setActive(true)
.setNetworkId(networkId)
.setSsid(TEST_SSID)
.setScanResultCache(scanResults)
.setWifiInfo(info)
.build();
when(mockWifiNetworkScoreCache.getScoredNetwork(scanResultUnconnected))
.thenReturn(buildScoredNetworkWithMockBadgeCurve());
when(mockBadgeCurve.lookupScore(anyInt())).thenReturn((byte) Speed.SLOW);
int connectedSpeed = Speed.VERY_FAST;
RssiCurve connectedBadgeCurve = mock(RssiCurve.class);
Bundle attr1 = new Bundle();
attr1.putParcelable(ScoredNetwork.ATTRIBUTES_KEY_BADGING_CURVE, connectedBadgeCurve);
ScoredNetwork connectedScore = new ScoredNetwork(
NetworkKey.createFromScanResult(scanResultConnected),
connectedBadgeCurve,
false /* meteredHint */,
attr1);
when(mockWifiNetworkScoreCache.getScoredNetwork(scanResultConnected))
.thenReturn(connectedScore);
when(connectedBadgeCurve.lookupScore(anyInt())).thenReturn((byte) connectedSpeed);
ap.update(mockWifiNetworkScoreCache, true /* scoringUiEnabled */);
assertThat(ap.getSpeed()).isEqualTo(connectedSpeed);
}
@Test
public void testSummaryString_showsSpeedLabel() {
AccessPoint ap = createAccessPointWithScanResultCache();
@@ -940,7 +890,7 @@ public class AccessPointTest {
}
@Test
public void testSpeedLabelUsesFallbackScoreWhenConnectedAccessPointScoreUnavailable() {
public void testSpeedLabelFallbackScoreIgnoresNullCurves() {
int rssi = -55;
String bssid = "00:00:00:00:00:00";
int networkId = 123;