diff options
20 files changed, 161 insertions, 155 deletions
diff --git a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java index 9a88bdf5c..2921729ca 100644 --- a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java +++ b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java @@ -18,7 +18,7 @@ package com.android.server.wifi; import android.annotation.IntDef; import android.annotation.NonNull; -import android.net.wifi.WifiSsid; +import android.net.wifi.WifiManager; import android.util.ArrayMap; import android.util.LocalLog; import android.util.Log; @@ -169,7 +169,7 @@ public class BssidBlocklistMonitor { */ public boolean handleBssidConnectionFailure(String bssid, String ssid, @BssidBlocklistMonitorFailureReason int reasonCode) { - if (bssid == null || ssid == null || WifiSsid.NONE.equals(ssid) + if (bssid == null || ssid == null || WifiManager.UNKNOWN_SSID.equals(ssid) || bssid.equals(ClientModeImpl.SUPPLICANT_BSSID_ANY) || reasonCode < 0 || reasonCode >= NUMBER_REASON_CODES) { Log.e(TAG, "Invalid input: BSSID=" + bssid + ", SSID=" + ssid diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index aeb345ef1..dfd92d3e2 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -69,7 +69,6 @@ import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.net.wifi.WifiManager.DeviceMobilityState; import android.net.wifi.WifiNetworkAgentSpecifier; -import android.net.wifi.WifiSsid; import android.net.wifi.hotspot2.IProvisioningCallback; import android.net.wifi.hotspot2.OsuProvider; import android.net.wifi.p2p.IWifiP2pManager; @@ -1911,18 +1910,18 @@ public class ClientModeImpl extends StateMachine { } sb.append(" rssi=").append(mWifiInfo.getRssi()); sb.append(" f=").append(mWifiInfo.getFrequency()); - sb.append(" sc=").append(mWifiInfo.score); + sb.append(" sc=").append(mWifiInfo.getScore()); sb.append(" link=").append(mWifiInfo.getLinkSpeed()); - sb.append(String.format(" tx=%.1f,", mWifiInfo.txSuccessRate)); - sb.append(String.format(" %.1f,", mWifiInfo.txRetriesRate)); - sb.append(String.format(" %.1f ", mWifiInfo.txBadRate)); - sb.append(String.format(" rx=%.1f", mWifiInfo.rxSuccessRate)); + sb.append(String.format(" tx=%.1f,", mWifiInfo.getTxSuccessRate())); + sb.append(String.format(" %.1f,", mWifiInfo.getTxRetriesRate())); + sb.append(String.format(" %.1f ", mWifiInfo.getTxBadRate())); + sb.append(String.format(" rx=%.1f", mWifiInfo.getRxSuccessRate())); sb.append(String.format(" bcn=%d", mRunningBeaconCount)); report = reportOnTime(); if (report != null) { sb.append(" ").append(report); } - sb.append(String.format(" score=%d", mWifiInfo.score)); + sb.append(String.format(" score=%d", mWifiInfo.getScore())); break; case CMD_START_CONNECT: sb.append(" "); @@ -2329,10 +2328,10 @@ public class ClientModeImpl extends StateMachine { // Polling has completed, hence we won't have a score anymore private void cleanWifiScore() { - mWifiInfo.txBadRate = 0; - mWifiInfo.txSuccessRate = 0; - mWifiInfo.txRetriesRate = 0; - mWifiInfo.rxSuccessRate = 0; + mWifiInfo.setTxBadRate(0); + mWifiInfo.setTxSuccessRate(0); + mWifiInfo.setTxRetriesRate(0); + mWifiInfo.setRxSuccessRate(0); mWifiScoreReport.reset(); mLastLinkLayerStats = null; } @@ -2507,7 +2506,7 @@ public class ClientModeImpl extends StateMachine { mWifiInfo.setTrusted(config.trusted); mWifiInfo.setOsuAp(config.osu); if (config.fromWifiNetworkSpecifier || config.fromWifiNetworkSuggestion) { - mWifiInfo.setNetworkSuggestionOrSpecifierPackageName(config.creatorName); + mWifiInfo.setAppPackageName(config.creatorName); } // Set meteredHint if scan result says network is expensive @@ -2737,7 +2736,7 @@ public class ClientModeImpl extends StateMachine { level2FailureCode, connectivityFailureCode); String bssid = mLastBssid == null ? mTargetRoamBSSID : mLastBssid; String ssid = mWifiInfo.getSSID(); - if (WifiSsid.NONE.equals(ssid)) { + if (WifiManager.UNKNOWN_SSID.equals(ssid)) { ssid = getTargetSsid(); } int bssidBlocklistMonitorReason = convertToBssidBlocklistMonitorFailureReason( @@ -4056,7 +4055,7 @@ public class ClientModeImpl extends StateMachine { result.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); } - if (!mWifiInfo.getSSID().equals(WifiSsid.NONE)) { + if (!mWifiInfo.getSSID().equals(WifiManager.UNKNOWN_SSID)) { result.setSSID(mWifiInfo.getSSID()); } else { result.setSSID(null); @@ -4123,7 +4122,8 @@ public class ClientModeImpl extends StateMachine { // Ignore if we're not the current networkAgent. if (this != mNetworkAgent) return; if (mVerboseLoggingEnabled) { - log("WifiNetworkAgent -> Wifi unwanted score " + Integer.toString(mWifiInfo.score)); + log("WifiNetworkAgent -> Wifi unwanted score " + Integer.toString( + mWifiInfo.getScore())); } unwantedNetwork(NETWORK_STATUS_UNWANTED_DISCONNECT); } @@ -4136,13 +4136,13 @@ public class ClientModeImpl extends StateMachine { if (status == NetworkAgent.INVALID_NETWORK) { if (mVerboseLoggingEnabled) { log("WifiNetworkAgent -> Wifi networkStatus invalid, score=" - + Integer.toString(mWifiInfo.score)); + + Integer.toString(mWifiInfo.getScore())); } unwantedNetwork(NETWORK_STATUS_UNWANTED_VALIDATION_FAILED); } else if (status == NetworkAgent.VALID_NETWORK) { if (mVerboseLoggingEnabled) { log("WifiNetworkAgent -> Wifi networkStatus valid, score= " - + Integer.toString(mWifiInfo.score)); + + Integer.toString(mWifiInfo.getScore())); } mWifiMetrics.logStaEvent(StaEvent.TYPE_NETWORK_AGENT_VALID_NETWORK); doNetworkStatus(status); diff --git a/service/java/com/android/server/wifi/ExtendedWifiInfo.java b/service/java/com/android/server/wifi/ExtendedWifiInfo.java index 93c508288..4aa355286 100644 --- a/service/java/com/android/server/wifi/ExtendedWifiInfo.java +++ b/service/java/com/android/server/wifi/ExtendedWifiInfo.java @@ -78,23 +78,23 @@ public class ExtendedWifiInfo extends WifiInfo { double lastSampleWeight = Math.exp(-1.0 * timeDelta / FILTER_TIME_CONSTANT); double currentSampleWeight = 1.0 - lastSampleWeight; - txBadRate = txBadRate * lastSampleWeight + setTxBadRate(getTxBadRate() * lastSampleWeight + (txbad - txBad) * 1000.0 / timeDelta - * currentSampleWeight; - txSuccessRate = txSuccessRate * lastSampleWeight + * currentSampleWeight); + setTxSuccessRate(getTxSuccessRate() * lastSampleWeight + (txgood - txSuccess) * 1000.0 / timeDelta - * currentSampleWeight; - rxSuccessRate = rxSuccessRate * lastSampleWeight + * currentSampleWeight); + setRxSuccessRate(getRxSuccessRate() * lastSampleWeight + (rxgood - rxSuccess) * 1000.0 / timeDelta - * currentSampleWeight; - txRetriesRate = txRetriesRate * lastSampleWeight + * currentSampleWeight); + setTxRetriesRate(getTxRetriesRate() * lastSampleWeight + (txretries - txRetries) * 1000.0 / timeDelta - * currentSampleWeight; + * currentSampleWeight); } else { - txBadRate = 0; - txSuccessRate = 0; - rxSuccessRate = 0; - txRetriesRate = 0; + setTxBadRate(0); + setTxSuccessRate(0); + setRxSuccessRate(0); + setTxRetriesRate(0); mLastSource = source; } txBad = txbad; diff --git a/service/java/com/android/server/wifi/VelocityBasedConnectedScore.java b/service/java/com/android/server/wifi/VelocityBasedConnectedScore.java index 71f18fc7e..34201cd3a 100644 --- a/service/java/com/android/server/wifi/VelocityBasedConnectedScore.java +++ b/service/java/com/android/server/wifi/VelocityBasedConnectedScore.java @@ -150,12 +150,12 @@ public class VelocityBasedConnectedScore extends ConnectedScore { if (mThresholdAdjustment < -7) return; if (mFilteredRssi >= getAdjustedRssiThreshold() + 2.0) return; if (Math.abs(mEstimatedRateOfRssiChange) >= 0.2) return; - double txSuccessPps = wifiInfo.txSuccessRate; - double rxSuccessPps = wifiInfo.rxSuccessRate; + double txSuccessPps = wifiInfo.getTxSuccessRate(); + double rxSuccessPps = wifiInfo.getRxSuccessRate(); if (txSuccessPps < mMinimumPpsForMeasuringSuccess) return; if (rxSuccessPps < mMinimumPpsForMeasuringSuccess) return; - double txBadPps = wifiInfo.txBadRate; - double txRetriesPps = wifiInfo.txRetriesRate; + double txBadPps = wifiInfo.getTxBadRate(); + double txRetriesPps = wifiInfo.getTxRetriesRate(); double probabilityOfSuccessfulTx = txSuccessPps / (txSuccessPps + txBadPps + txRetriesPps); if (probabilityOfSuccessfulTx > 0.2) { // May want this amount to vary with how close to threshold we are diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java index f74ec3f99..b51c2ff59 100644 --- a/service/java/com/android/server/wifi/WifiConnectivityManager.java +++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java @@ -821,8 +821,8 @@ public class WifiConnectivityManager { boolean isScanNeeded = true; boolean isFullBandScan = true; - boolean isTrafficOverThreshold = mWifiInfo.txSuccessRate > mFullScanMaxTxRate - || mWifiInfo.rxSuccessRate > mFullScanMaxRxRate; + boolean isTrafficOverThreshold = mWifiInfo.getTxSuccessRate() > mFullScanMaxTxRate + || mWifiInfo.getRxSuccessRate() > mFullScanMaxRxRate; // If the WiFi traffic is heavy, only partial scan is proposed. if (mWifiState == WIFI_STATE_CONNECTED && isTrafficOverThreshold) { diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java index f111a4cfc..63acb6682 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSelector.java +++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java @@ -235,8 +235,8 @@ public class WifiNetworkSelector { int currentRssi = wifiInfo.getRssi(); boolean hasQualifiedRssi = currentRssi > mScoringParams.getSufficientRssi(wifiInfo.getFrequency()); - boolean hasActiveStream = (wifiInfo.txSuccessRate > mStayOnNetworkMinimumTxRate) - || (wifiInfo.rxSuccessRate > mStayOnNetworkMinimumRxRate); + boolean hasActiveStream = (wifiInfo.getTxSuccessRate() > mStayOnNetworkMinimumTxRate) + || (wifiInfo.getRxSuccessRate() > mStayOnNetworkMinimumRxRate); if (hasQualifiedRssi && hasActiveStream) { localLog("Stay on current network because of good RSSI and ongoing traffic"); return true; @@ -700,7 +700,7 @@ public class WifiNetworkSelector { // Filter out unwanted networks. mFilteredNetworks = filterScanResults(scanDetails, bssidBlacklist, - connected && wifiInfo.score >= WIFI_POOR_SCORE, currentBssid); + connected && wifiInfo.getScore() >= WIFI_POOR_SCORE, currentBssid); if (mFilteredNetworks.size() == 0) { return null; } diff --git a/service/java/com/android/server/wifi/WifiScoreCard.java b/service/java/com/android/server/wifi/WifiScoreCard.java index 22bd1b1ba..87d9c3403 100644 --- a/service/java/com/android/server/wifi/WifiScoreCard.java +++ b/service/java/com/android/server/wifi/WifiScoreCard.java @@ -23,7 +23,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.net.MacAddress; import android.net.wifi.SupplicantState; -import android.net.wifi.WifiSsid; +import android.net.wifi.WifiManager; import android.util.ArrayMap; import android.util.Base64; import android.util.Log; @@ -541,7 +541,7 @@ public class WifiScoreCard { // TODO should be private, but WifiCandidates needs it @NonNull PerBssid lookupBssid(String ssid, String bssid) { MacAddress mac; - if (ssid == null || WifiSsid.NONE.equals(ssid) || bssid == null) { + if (ssid == null || WifiManager.UNKNOWN_SSID.equals(ssid) || bssid == null) { return mDummyPerBssid; } try { diff --git a/service/java/com/android/server/wifi/WifiScoreReport.java b/service/java/com/android/server/wifi/WifiScoreReport.java index 63321b343..401f10648 100644 --- a/service/java/com/android/server/wifi/WifiScoreReport.java +++ b/service/java/com/android/server/wifi/WifiScoreReport.java @@ -114,14 +114,15 @@ public class WifiScoreReport { score = s2; - if (wifiInfo.score > ConnectedScore.WIFI_TRANSITION_SCORE + if (wifiInfo.getScore() > ConnectedScore.WIFI_TRANSITION_SCORE && score <= ConnectedScore.WIFI_TRANSITION_SCORE - && wifiInfo.txSuccessRate >= mScoringParams.getYippeeSkippyPacketsPerSecond() - && wifiInfo.rxSuccessRate >= mScoringParams.getYippeeSkippyPacketsPerSecond()) { + && wifiInfo.getTxSuccessRate() >= mScoringParams.getYippeeSkippyPacketsPerSecond() + && wifiInfo.getRxSuccessRate() >= mScoringParams.getYippeeSkippyPacketsPerSecond() + ) { score = ConnectedScore.WIFI_TRANSITION_SCORE + 1; } - if (wifiInfo.score > ConnectedScore.WIFI_TRANSITION_SCORE + if (wifiInfo.getScore() > ConnectedScore.WIFI_TRANSITION_SCORE && score <= ConnectedScore.WIFI_TRANSITION_SCORE) { // We don't want to trigger a downward breach unless the rssi is // below the entry threshold. There is noise in the measured rssi, and @@ -135,16 +136,16 @@ public class WifiScoreReport { } } - if (wifiInfo.score >= ConnectedScore.WIFI_TRANSITION_SCORE + if (wifiInfo.getScore() >= ConnectedScore.WIFI_TRANSITION_SCORE && score < ConnectedScore.WIFI_TRANSITION_SCORE) { mLastDownwardBreachTimeMillis = millis; - } else if (wifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE + } else if (wifiInfo.getScore() < ConnectedScore.WIFI_TRANSITION_SCORE && score >= ConnectedScore.WIFI_TRANSITION_SCORE) { // Staying at below transition score for a certain period of time // to prevent going back to wifi network again in a short time. long elapsedMillis = millis - mLastDownwardBreachTimeMillis; if (elapsedMillis < MIN_TIME_TO_KEEP_BELOW_TRANSITION_SCORE_MILLIS) { - score = wifiInfo.score; + score = wifiInfo.getScore(); } } @@ -159,11 +160,11 @@ public class WifiScoreReport { logLinkMetrics(wifiInfo, millis, netId, s1, s2, score); //report score - if (score != wifiInfo.score) { + if (score != wifiInfo.getScore()) { if (mVerboseLoggingEnabled) { Log.d(TAG, "report new wifi score " + score); } - wifiInfo.score = score; + wifiInfo.setScore(score); if (networkAgent != null) { networkAgent.sendNetworkScore(score); } @@ -251,10 +252,10 @@ public class WifiScoreReport { int freq = wifiInfo.getFrequency(); int txLinkSpeed = wifiInfo.getLinkSpeed(); int rxLinkSpeed = wifiInfo.getRxLinkSpeedMbps(); - double txSuccessRate = wifiInfo.txSuccessRate; - double txRetriesRate = wifiInfo.txRetriesRate; - double txBadRate = wifiInfo.txBadRate; - double rxSuccessRate = wifiInfo.rxSuccessRate; + double txSuccessRate = wifiInfo.getTxSuccessRate(); + double txRetriesRate = wifiInfo.getTxRetriesRate(); + double txBadRate = wifiInfo.getTxBadRate(); + double rxSuccessRate = wifiInfo.getRxSuccessRate(); String s; try { String timestamp = new SimpleDateFormat("MM-dd HH:mm:ss.SSS").format(new Date(now)); diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java index 0d5f9043e..f9eab6f90 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java @@ -37,6 +37,7 @@ import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiEnterpriseConfig; import android.net.wifi.WifiManager; +import android.net.wifi.WifiSsid; import android.net.wifi.hotspot2.IProvisioningCallback; import android.net.wifi.hotspot2.OsuProvider; import android.net.wifi.hotspot2.PasspointConfiguration; @@ -794,7 +795,7 @@ public class PasspointManager { // Set null for OSU-SSID in the class because OSU-SSID is a factor for hotspot // operator rather than service provider, which means it can be different for // each hotspot operators. - OsuProvider provider = new OsuProvider(null, info.getFriendlyNames(), + OsuProvider provider = new OsuProvider((WifiSsid) null, info.getFriendlyNames(), info.getServiceDescription(), info.getServerUri(), info.getNetworkAccessIdentifier(), info.getMethodList(), null); List<ScanResult> matchingScanResults = osuProviders.get(provider); diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java index a01117fae..f6b8772c6 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java @@ -23,6 +23,7 @@ import android.content.Intent; import android.net.Network; import android.net.wifi.ScanResult; import android.net.wifi.WifiManager; +import android.net.wifi.WifiSsid; import android.net.wifi.hotspot2.IProvisioningCallback; import android.net.wifi.hotspot2.OsuProvider; import android.net.wifi.hotspot2.PasspointConfiguration; @@ -1019,7 +1020,8 @@ public class PasspointProvisioner { Constants.ANQPElementType.HSOSUProviders); if (element == null) continue; for (OsuProviderInfo info : element.getProviders()) { - OsuProvider candidate = new OsuProvider(null, info.getFriendlyNames(), + OsuProvider candidate = new OsuProvider( + (WifiSsid) null, info.getFriendlyNames(), info.getServiceDescription(), info.getServerUri(), info.getNetworkAccessIdentifier(), info.getMethodList(), null); if (candidate.equals(osuProvider)) { diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 6f59ac264..b59ee2a2a 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -2203,7 +2203,7 @@ public class ClientModeImplTest extends WifiBaseTest { wifiInfo = mCmi.getWifiInfo(); assertNull(wifiInfo.getBSSID()); - assertEquals(WifiSsid.NONE, wifiInfo.getSSID()); + assertEquals(WifiManager.UNKNOWN_SSID, wifiInfo.getSSID()); assertEquals(WifiConfiguration.INVALID_NETWORK_ID, wifiInfo.getNetworkId()); assertEquals(SupplicantState.DISCONNECTED, wifiInfo.getSupplicantState()); } @@ -3767,7 +3767,7 @@ public class ClientModeImplTest extends WifiBaseTest { assertTrue(mCmi.getWifiInfo().isEphemeral()); assertTrue(mCmi.getWifiInfo().isTrusted()); assertEquals(OP_PACKAGE_NAME, - mCmi.getWifiInfo().getNetworkSuggestionOrSpecifierPackageName()); + mCmi.getWifiInfo().getAppPackageName()); } /** @@ -3784,7 +3784,7 @@ public class ClientModeImplTest extends WifiBaseTest { assertTrue(mCmi.getWifiInfo().isEphemeral()); assertTrue(mCmi.getWifiInfo().isTrusted()); assertEquals(OP_PACKAGE_NAME, - mCmi.getWifiInfo().getNetworkSuggestionOrSpecifierPackageName()); + mCmi.getWifiInfo().getAppPackageName()); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java b/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java index ae8c8c0d5..214e80947 100644 --- a/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/VelocityBasedConnectedScoreTest.java @@ -114,9 +114,9 @@ public class VelocityBasedConnectedScoreTest extends WifiBaseTest { public void allowLowRssiIfErrorRateIsLowAndSomeDataIsMoving() throws Exception { mWifiInfo.setRssi(mRssiExitThreshold2GHz - 2); mWifiInfo.setLinkSpeed(6); // Mbps - mWifiInfo.txSuccessRate = 2.1; // proportional to pps - mWifiInfo.txBadRate = .5; - mWifiInfo.rxSuccessRate = 2.1; + mWifiInfo.setTxSuccessRate(2.1); // proportional to pps + mWifiInfo.setTxBadRate(.5); + mWifiInfo.setRxSuccessRate(2.1); for (int i = 0; i < 10; i++) { mVelocityBasedConnectedScore.updateUsingWifiInfo(mWifiInfo, mClock.getWallClockMillis()); @@ -140,9 +140,9 @@ public class VelocityBasedConnectedScoreTest extends WifiBaseTest { public void disallowLowRssiIfDataIsNotMoving() throws Exception { mWifiInfo.setRssi(mRssiExitThreshold2GHz - 1); mWifiInfo.setLinkSpeed(6); // Mbps - mWifiInfo.txSuccessRate = .1; // proportional to pps - mWifiInfo.txBadRate = 0; - mWifiInfo.rxSuccessRate = .1; + mWifiInfo.setTxSuccessRate(.1); // proportional to pps + mWifiInfo.setTxBadRate(0); + mWifiInfo.setRxSuccessRate(.1); for (int i = 0; i < 10; i++) { mVelocityBasedConnectedScore.updateUsingWifiInfo(mWifiInfo, mClock.getWallClockMillis()); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index e77cce9cb..be78461ee 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -1029,8 +1029,8 @@ public class WifiConnectivityManagerTest extends WifiBaseTest { */ @Test public void checkSingleScanSettingsWhenConnectedWithLowDataRate() { - mWifiInfo.txSuccessRate = 0; - mWifiInfo.rxSuccessRate = 0; + mWifiInfo.setTxSuccessRate(0); + mWifiInfo.setRxSuccessRate(0); final HashSet<Integer> channelList = new HashSet<>(); channelList.add(1); @@ -1069,8 +1069,8 @@ public class WifiConnectivityManagerTest extends WifiBaseTest { */ @Test public void checkPartialScanRequestedWithHighDataRateWithoutFwRoaming() { - mWifiInfo.txSuccessRate = mFullScanMaxTxPacketRate * 2; - mWifiInfo.rxSuccessRate = mFullScanMaxRxPacketRate * 2; + mWifiInfo.setTxSuccessRate(mFullScanMaxTxPacketRate * 2); + mWifiInfo.setRxSuccessRate(mFullScanMaxRxPacketRate * 2); final HashSet<Integer> channelList = new HashSet<>(); channelList.add(1); @@ -1114,8 +1114,8 @@ public class WifiConnectivityManagerTest extends WifiBaseTest { */ @Test public void checkPartialScanSkippedWithHighDataRateWithFwRoaming() { - mWifiInfo.txSuccessRate = mFullScanMaxTxPacketRate * 2; - mWifiInfo.rxSuccessRate = mFullScanMaxRxPacketRate * 2; + mWifiInfo.setTxSuccessRate(mFullScanMaxTxPacketRate * 2); + mWifiInfo.setRxSuccessRate(mFullScanMaxRxPacketRate * 2); long currentTimeStamp = CURRENT_SYSTEM_TIME_MS; when(mClock.getElapsedSinceBootMillis()).thenReturn(currentTimeStamp); @@ -1158,8 +1158,8 @@ public class WifiConnectivityManagerTest extends WifiBaseTest { */ @Test public void checkSingleScanSettingsWhenConnectedWithHighDataRateNotInCache() { - mWifiInfo.txSuccessRate = mFullScanMaxTxPacketRate * 2; - mWifiInfo.rxSuccessRate = mFullScanMaxRxPacketRate * 2; + mWifiInfo.setTxSuccessRate(mFullScanMaxTxPacketRate * 2); + mWifiInfo.setRxSuccessRate(mFullScanMaxRxPacketRate * 2); final HashSet<Integer> channelList = new HashSet<>(); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java index d551680e4..2d6bb5a3c 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiLinkLayerStatsTest.java @@ -100,10 +100,10 @@ public class WifiLinkLayerStatsTest extends WifiBaseTest { mWifiInfo.updatePacketRates(mWifiLinkLayerStats, mWifiLinkLayerStats.timeStampInMs); } // assertEquals(double, double, double) takes a tolerance as the third argument - assertEquals((double) txg, mWifiInfo.txSuccessRate, txg * 0.02); - assertEquals((double) txr, mWifiInfo.txRetriesRate, txr * 0.02); - assertEquals((double) txb, mWifiInfo.txBadRate, txb * 0.02); - assertEquals((double) rxg, mWifiInfo.rxSuccessRate, rxg * 0.02); + assertEquals((double) txg, mWifiInfo.getTxSuccessRate(), txg * 0.02); + assertEquals((double) txr, mWifiInfo.getTxRetriesRate(), txr * 0.02); + assertEquals((double) txb, mWifiInfo.getTxBadRate(), txb * 0.02); + assertEquals((double) rxg, mWifiInfo.getRxSuccessRate(), rxg * 0.02); assertEquals(mWifiInfo.txSuccess, n * txg); assertEquals(mWifiInfo.txRetries, n * txr); @@ -119,11 +119,11 @@ public class WifiLinkLayerStatsTest extends WifiBaseTest { bumpCounters(mWifiLinkLayerStats, 999999999, 999999999, 999999999, 99999999); mWifiLinkLayerStats.timeStampInMs = 999999999; mWifiInfo.updatePacketRates(mWifiLinkLayerStats, mWifiLinkLayerStats.timeStampInMs); - assertEquals(0.0, mWifiInfo.txSuccessRate, 0.0001); + assertEquals(0.0, mWifiInfo.getTxSuccessRate(), 0.0001); bumpCounters(mWifiLinkLayerStats, 1, 1, 1, 1); mWifiLinkLayerStats.timeStampInMs += 1; mWifiInfo.updatePacketRates(mWifiLinkLayerStats, mWifiLinkLayerStats.timeStampInMs); - assertEquals(0.33, mWifiInfo.txSuccessRate, 0.01); + assertEquals(0.33, mWifiInfo.getTxSuccessRate(), 0.01); } /** @@ -135,33 +135,35 @@ public class WifiLinkLayerStatsTest extends WifiBaseTest { bumpCounters(mWifiLinkLayerStats, 999, 999, 999, 999); mWifiLinkLayerStats.timeStampInMs = 999999999; mWifiInfo.updatePacketRates(mWifiLinkLayerStats, mWifiLinkLayerStats.timeStampInMs); - assertEquals(0.0, mWifiInfo.txSuccessRate, 0.0001); - assertEquals(0.0, mWifiInfo.rxSuccessRate, 0.0001); + assertEquals(0.0, mWifiInfo.getTxSuccessRate(), 0.0001); + assertEquals(0.0, mWifiInfo.getRxSuccessRate(), 0.0001); bumpCounters(mWifiLinkLayerStats, 1_000_000_000, 777000, 66600, 1_000_100_000); mWifiLinkLayerStats.timeStampInMs += 10_000; mWifiInfo.updatePacketRates(mWifiLinkLayerStats, mWifiLinkLayerStats.timeStampInMs); - assertTrue("" + mWifiInfo + " " + mWifiLinkLayerStats, mWifiInfo.txSuccessRate > 0.95e+8); - assertTrue("" + mWifiInfo + " " + mWifiLinkLayerStats, mWifiInfo.rxSuccessRate > 0.95e+8); + assertTrue("" + mWifiInfo + " " + mWifiLinkLayerStats, + mWifiInfo.getTxSuccessRate() > 0.95e+8); + assertTrue("" + mWifiInfo + " " + mWifiLinkLayerStats, + mWifiInfo.getRxSuccessRate() > 0.95e+8); // Now update with traffic counters mWifiLinkLayerStats.timeStampInMs += 10_000; mWifiInfo.updatePacketRates(2_000_000_000L, 2_000_000_000L, mWifiLinkLayerStats.timeStampInMs); // Despite the increase, the rates should be zero after the change in source - assertEquals(0.0, mWifiInfo.txSuccessRate, 0.0001); - assertEquals(0.0, mWifiInfo.rxSuccessRate, 0.0001); + assertEquals(0.0, mWifiInfo.getTxSuccessRate(), 0.0001); + assertEquals(0.0, mWifiInfo.getRxSuccessRate(), 0.0001); assertEquals(0, mWifiInfo.txBad); assertEquals(0, mWifiInfo.txRetries); // Make sure that updates from this source work, too mWifiLinkLayerStats.timeStampInMs += 10_000; mWifiInfo.updatePacketRates(3_000_000_000L, 3_000_000_000L, mWifiLinkLayerStats.timeStampInMs); - assertTrue(mWifiInfo.txSuccessRate > 0.95e+8); - assertTrue(mWifiInfo.rxSuccessRate > 0.95e+8); + assertTrue(mWifiInfo.getTxSuccessRate() > 0.95e+8); + assertTrue(mWifiInfo.getRxSuccessRate() > 0.95e+8); // Switch back to using link layer stats mWifiLinkLayerStats.timeStampInMs += 10_000; bumpCounters(mWifiLinkLayerStats, 1_000_000_000, 777000, 66600, 1_000_100_000); mWifiInfo.updatePacketRates(mWifiLinkLayerStats, mWifiLinkLayerStats.timeStampInMs); - assertEquals(0.0, mWifiInfo.txSuccessRate, 0.0001); - assertEquals(0.0, mWifiInfo.rxSuccessRate, 0.0001); + assertEquals(0.0, mWifiInfo.getTxSuccessRate(), 0.0001); + assertEquals(0.0, mWifiInfo.getRxSuccessRate(), 0.0001); } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java index d9abbed12..77d4cdeb7 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java @@ -848,8 +848,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi2G + 1); // No streaming traffic. - mWifiInfo.txSuccessRate = 0.0; - mWifiInfo.rxSuccessRate = 0.0; + mWifiInfo.setTxSuccessRate(0.0); + mWifiInfo.setRxSuccessRate(0.0); // Do not perform selection on 2GHz if current network is good and no 5GHz available testStayOrTryToSwitch( @@ -875,8 +875,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi2G + 1); // No streaming traffic. - mWifiInfo.txSuccessRate = 0.0; - mWifiInfo.rxSuccessRate = 0.0; + mWifiInfo.setTxSuccessRate(0.0); + mWifiInfo.setRxSuccessRate(0.0); // When on 2GHz, even with "good" signal strength, run selection if 5GHz available testStayOrTryToSwitch( @@ -905,8 +905,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi5G - 1); // No streaming traffic. - mWifiInfo.txSuccessRate = 0.0; - mWifiInfo.rxSuccessRate = 0.0; + mWifiInfo.setTxSuccessRate(0.0); + mWifiInfo.setRxSuccessRate(0.0); // Run Selection when the current 5Ghz network has low RSSI. testStayOrTryToSwitch( @@ -930,8 +930,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi5G + 1); // No streaming traffic. - mWifiInfo.txSuccessRate = 0.0; - mWifiInfo.rxSuccessRate = 0.0; + mWifiInfo.setTxSuccessRate(0.0); + mWifiInfo.setRxSuccessRate(0.0); // Connected to a high quality 5Ghz network, so the other result is irrelevant testStayOrTryToSwitch( @@ -954,8 +954,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi2G + 1); // No streaming traffic. - mWifiInfo.txSuccessRate = 0.0; - mWifiInfo.rxSuccessRate = 0.0; + mWifiInfo.setTxSuccessRate(0.0); + mWifiInfo.setRxSuccessRate(0.0); testStayOrTryToSwitch( // Parameters for network1: @@ -987,8 +987,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi2G + 1); // No streaming traffic. - mWifiInfo.txSuccessRate = 0.0; - mWifiInfo.rxSuccessRate = 0.0; + mWifiInfo.setTxSuccessRate(0.0); + mWifiInfo.setRxSuccessRate(0.0); testStayOrTryToSwitch( // Parameters for network1: @@ -1015,8 +1015,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi2G - 1); // No streaming traffic. - mWifiInfo.txSuccessRate = 0.0; - mWifiInfo.rxSuccessRate = 0.0; + mWifiInfo.setTxSuccessRate(0.0); + mWifiInfo.setRxSuccessRate(0.0); testStayOrTryToSwitch( mThresholdQualifiedRssi2G + 1 /* rssi before connected */, @@ -1037,8 +1037,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi2G + 1); // Streaming traffic - mWifiInfo.txSuccessRate = ((double) (mStayOnNetworkMinimumTxRate + 1)); - mWifiInfo.rxSuccessRate = 0.0; + when(mWifiInfo.getTxSuccessRate()).thenReturn(mStayOnNetworkMinimumTxRate + 1.0); + when(mWifiInfo.getRxSuccessRate()).thenReturn(0.0); testStayOrTryToSwitch( mThresholdQualifiedRssi2G + 1 /* rssi before connected */, @@ -1059,8 +1059,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi2G + 1); // Streaming traffic - mWifiInfo.txSuccessRate = 0.0; - mWifiInfo.rxSuccessRate = ((double) (mStayOnNetworkMinimumRxRate + 1)); + when(mWifiInfo.getTxSuccessRate()).thenReturn(0.0); + when(mWifiInfo.getRxSuccessRate()).thenReturn(mStayOnNetworkMinimumRxRate + 1.0); testStayOrTryToSwitch( mThresholdQualifiedRssi2G + 1 /* rssi before connected */, @@ -1081,8 +1081,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi5G + 1); // Streaming traffic - mWifiInfo.txSuccessRate = ((double) (mStayOnNetworkMinimumTxRate + 1)); - mWifiInfo.rxSuccessRate = 0.0; + when(mWifiInfo.getTxSuccessRate()).thenReturn(mStayOnNetworkMinimumTxRate + 1.0); + when(mWifiInfo.getRxSuccessRate()).thenReturn(0.0); testStayOrTryToSwitch( mThresholdQualifiedRssi5G + 1 /* rssi before connected */, @@ -1103,8 +1103,8 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { // Rssi after connected. when(mWifiInfo.getRssi()).thenReturn(mThresholdQualifiedRssi5G + 1); // Streaming traffic - mWifiInfo.txSuccessRate = 0.0; - mWifiInfo.rxSuccessRate = ((double) (mStayOnNetworkMinimumRxRate + 1)); + when(mWifiInfo.getTxSuccessRate()).thenReturn(0.0); + when(mWifiInfo.getRxSuccessRate()).thenReturn(mStayOnNetworkMinimumRxRate + 1.0); testStayOrTryToSwitch( mThresholdQualifiedRssi5G + 1 /* rssi before connected */, diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java index f80201bac..c85b9f49c 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java @@ -190,12 +190,12 @@ public class WifiScoreReportTest extends WifiBaseTest { public void allowLowRssiIfDataIsMoving() throws Exception { mWifiInfo.setRssi(-80); mWifiInfo.setLinkSpeed(6); // Mbps - mWifiInfo.txSuccessRate = 5.1; // proportional to pps - mWifiInfo.rxSuccessRate = 5.1; + mWifiInfo.setTxSuccessRate(5.1); // proportional to pps + mWifiInfo.setRxSuccessRate(5.1); for (int i = 0; i < 10; i++) { mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); } - int score = mWifiInfo.score; + int score = mWifiInfo.getScore(); assertTrue(score > ConnectedScore.WIFI_TRANSITION_SCORE); } @@ -213,12 +213,12 @@ public class WifiScoreReportTest extends WifiBaseTest { mWifiInfo.setLinkSpeed(6); // Mbps mWifiInfo.setFrequency(5220); mWifiScoreReport.enableVerboseLogging(true); - mWifiInfo.txSuccessRate = 0.1; - mWifiInfo.rxSuccessRate = 0.1; + mWifiInfo.setTxSuccessRate(0.1); + mWifiInfo.setRxSuccessRate(0.1); for (int i = 0; i < 10; i++) { mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); } - int score = mWifiInfo.score; + int score = mWifiInfo.getScore(); assertTrue(score < ConnectedScore.WIFI_TRANSITION_SCORE); verify(mNetworkAgent, atLeast(1)).sendNetworkScore(score); } @@ -234,9 +234,9 @@ public class WifiScoreReportTest extends WifiBaseTest { mWifiInfo.setRssi(rssi); oops += " " + mClock.mWallClockMillis + "," + rssi; mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); - oops += ":" + mWifiInfo.score; + oops += ":" + mWifiInfo.getScore(); } - int score = mWifiInfo.score; + int score = mWifiInfo.getScore(); verify(mNetworkAgent, atLeast(1)).sendNetworkScore(score); assertTrue(oops, score < ConnectedScore.WIFI_TRANSITION_SCORE); } @@ -253,16 +253,16 @@ public class WifiScoreReportTest extends WifiBaseTest { mWifiInfo.setLinkSpeed(6); // Mbps mWifiInfo.setFrequency(5220); mWifiScoreReport.enableVerboseLogging(true); - mWifiInfo.txSuccessRate = 0.1; - mWifiInfo.rxSuccessRate = 0.1; + mWifiInfo.setTxSuccessRate(0.1); + mWifiInfo.setRxSuccessRate(0.1); assertTrue(mScoringParams.update("rssi5=-83:-80:-66:-55")); for (int r = -30; r >= -100; r -= 1) { int rssi = Math.max(r, -80); mWifiInfo.setRssi(rssi); oops += " " + mClock.mWallClockMillis + "," + rssi; mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); - oops += ":" + mWifiInfo.score; - if (mWifiInfo.score < minScore) minScore = mWifiInfo.score; + oops += ":" + mWifiInfo.getScore(); + if (mWifiInfo.getScore() < minScore) minScore = mWifiInfo.getScore(); } assertTrue(oops, minScore > ConnectedScore.WIFI_TRANSITION_SCORE); } @@ -276,24 +276,24 @@ public class WifiScoreReportTest extends WifiBaseTest { */ @Test public void allowTerribleRssiIfDataIsMovingWell() throws Exception { - mWifiInfo.txSuccessRate = mScoringParams.getYippeeSkippyPacketsPerSecond() + 0.1; - mWifiInfo.rxSuccessRate = mScoringParams.getYippeeSkippyPacketsPerSecond() + 0.1; - assertTrue(mWifiInfo.txSuccessRate > 10); + mWifiInfo.setTxSuccessRate(mScoringParams.getYippeeSkippyPacketsPerSecond() + 0.1); + mWifiInfo.setRxSuccessRate(mScoringParams.getYippeeSkippyPacketsPerSecond() + 0.1); + assertTrue(mWifiInfo.getTxSuccessRate() > 10); mWifiInfo.setFrequency(5220); for (int r = -30; r >= -120; r -= 2) { mWifiInfo.setRssi(r); mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); - assertTrue(mWifiInfo.score > ConnectedScore.WIFI_TRANSITION_SCORE); + assertTrue(mWifiInfo.getScore() > ConnectedScore.WIFI_TRANSITION_SCORE); } // If the throughput dips, we should let go - mWifiInfo.rxSuccessRate = mScoringParams.getYippeeSkippyPacketsPerSecond() - 0.1; + mWifiInfo.setRxSuccessRate(mScoringParams.getYippeeSkippyPacketsPerSecond() - 0.1); mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); - assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE); + assertTrue(mWifiInfo.getScore() < ConnectedScore.WIFI_TRANSITION_SCORE); // And even if throughput improves again, once we have decided to let go, disregard // the good rates. - mWifiInfo.rxSuccessRate = mScoringParams.getYippeeSkippyPacketsPerSecond() + 0.1; + mWifiInfo.setRxSuccessRate(mScoringParams.getYippeeSkippyPacketsPerSecond() + 0.1); mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); - assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE); + assertTrue(mWifiInfo.getScore() < ConnectedScore.WIFI_TRANSITION_SCORE); } /** @@ -327,10 +327,10 @@ public class WifiScoreReportTest extends WifiBaseTest { mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); boolean ask = mWifiScoreReport.shouldCheckIpLayer(); if (ask) { - assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE); + assertTrue(mWifiInfo.getScore() < ConnectedScore.WIFI_TRANSITION_SCORE); assertTrue(oops, mClock.mWallClockMillis >= lastAskedMillis + 5000); lastAskedMillis = mClock.mWallClockMillis; - oops += " " + lastAskedMillis + ":" + mWifiInfo.score; + oops += " " + lastAskedMillis + ":" + mWifiInfo.getScore(); mWifiScoreReport.noteIpCheck(); asks++; } @@ -355,10 +355,10 @@ public class WifiScoreReportTest extends WifiBaseTest { mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); boolean ask = mWifiScoreReport.shouldCheckIpLayer(); if (ask) { - assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE); + assertTrue(mWifiInfo.getScore() < ConnectedScore.WIFI_TRANSITION_SCORE); assertTrue(oops, mClock.mWallClockMillis >= lastAskedMillis + 5000); lastAskedMillis = mClock.mWallClockMillis; - oops += " " + lastAskedMillis + ":" + mWifiInfo.score; + oops += " " + lastAskedMillis + ":" + mWifiInfo.getScore(); mWifiScoreReport.noteIpCheck(); asks++; } @@ -400,10 +400,10 @@ public class WifiScoreReportTest extends WifiBaseTest { mWifiInfo.setRssi(-65 + i); mWifiInfo.setLinkSpeed(300); mWifiInfo.setFrequency(5220); - mWifiInfo.txSuccessRate = 0.1 + i; - mWifiInfo.txRetriesRate = 0.2 + i; - mWifiInfo.txBadRate = 0.01 * i; - mWifiInfo.rxSuccessRate = 0.3 + i; + mWifiInfo.setTxSuccessRate(0.1 + i); + mWifiInfo.setTxRetriesRate(0.2 + i); + mWifiInfo.setTxBadRate(0.01 * i); + mWifiInfo.setRxSuccessRate(0.3 + i); mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); } setupToGenerateAReportWhenPrintlnIsCalled(); @@ -422,10 +422,10 @@ public class WifiScoreReportTest extends WifiBaseTest { mWifiInfo.setRssi(-65 + i % 20); mWifiInfo.setLinkSpeed(300); mWifiInfo.setFrequency(5220); - mWifiInfo.txSuccessRate = 0.1 + i % 100; - mWifiInfo.txRetriesRate = 0.2 + i % 100; - mWifiInfo.txBadRate = 0.0001 * i; - mWifiInfo.rxSuccessRate = 0.3 + i % 200; + mWifiInfo.setTxSuccessRate(0.1 + i % 100); + mWifiInfo.setTxRetriesRate(0.2 + i % 100); + mWifiInfo.setTxBadRate(0.0001 * i); + mWifiInfo.setRxSuccessRate(0.3 + i % 200); mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); } mWifiScoreReport.dump(null, mPrintWriter, null); @@ -445,7 +445,7 @@ public class WifiScoreReportTest extends WifiBaseTest { mWifiInfo.setRssi(rssi); mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); } - assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE); + assertTrue(mWifiInfo.getScore() < ConnectedScore.WIFI_TRANSITION_SCORE); // Then, set high RSSI value to exceed the transition score mWifiInfo.setRssi(-50); @@ -453,11 +453,11 @@ public class WifiScoreReportTest extends WifiBaseTest { for (int i = 0; i < 8; i++) { mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); } - assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE); + assertTrue(mWifiInfo.getScore() < ConnectedScore.WIFI_TRANSITION_SCORE); // 9 seconds elapse mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); - assertTrue(mWifiInfo.score > ConnectedScore.WIFI_TRANSITION_SCORE); + assertTrue(mWifiInfo.getScore() > ConnectedScore.WIFI_TRANSITION_SCORE); } /** @@ -474,13 +474,13 @@ public class WifiScoreReportTest extends WifiBaseTest { mWifiInfo.setRssi(rssi); mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); } - assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE); + assertTrue(mWifiInfo.getScore() < ConnectedScore.WIFI_TRANSITION_SCORE); // Then, set high RSSI value to exceed the transition score mWifiInfo.setRssi(-50); // Reset the internal timer so that no need to wait for 9 seconds mWifiScoreReport.reset(); mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); - assertTrue(mWifiInfo.score > ConnectedScore.WIFI_TRANSITION_SCORE); + assertTrue(mWifiInfo.getScore() > ConnectedScore.WIFI_TRANSITION_SCORE); } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 782a8db57..9224d69b5 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -1251,7 +1251,7 @@ public class WifiServiceImplTest extends WifiBaseTest { WifiInfo connectionInfo = mWifiServiceImpl.getConnectionInfo(TEST_PACKAGE, TEST_FEATURE_ID); - assertEquals(WifiSsid.NONE, connectionInfo.getSSID()); + assertEquals(WifiManager.UNKNOWN_SSID, connectionInfo.getSSID()); assertEquals(WifiInfo.DEFAULT_MAC_ADDRESS, connectionInfo.getBSSID()); assertEquals(WifiConfiguration.INVALID_NETWORK_ID, connectionInfo.getNetworkId()); } @@ -1269,7 +1269,7 @@ public class WifiServiceImplTest extends WifiBaseTest { WifiInfo connectionInfo = mWifiServiceImpl.getConnectionInfo(TEST_PACKAGE, TEST_FEATURE_ID); - assertEquals(WifiSsid.NONE, connectionInfo.getSSID()); + assertEquals(WifiManager.UNKNOWN_SSID, connectionInfo.getSSID()); assertEquals(WifiInfo.DEFAULT_MAC_ADDRESS, connectionInfo.getBSSID()); assertEquals(WifiConfiguration.INVALID_NETWORK_ID, connectionInfo.getNetworkId()); } diff --git a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java index dadab98d6..5af9b6918 100644 --- a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java @@ -629,7 +629,7 @@ public class WificondControlTest extends WifiBaseTest { /** * Verifies that scan result's carrier network info {@link ScanResult#isCarrierAp} and - * {@link ScanResult#getCarrierApEapType} is set appropriated based on the carrier network + * {@link ScanResult#carrierApEapType} is set appropriated based on the carrier network * config. * * @throws Exception diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java index ccfb1f0d1..58c84af1c 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java @@ -1217,7 +1217,7 @@ public class PasspointManagerTest extends WifiBaseTest { friendlyNames.forEach(e -> friendlyNameMap.put(e.getLanguage(), e.getText())); expectedOsuProvidersForDomainId.add(new OsuProvider( - null, friendlyNameMap, serviceDescription, + (WifiSsid) null, friendlyNameMap, serviceDescription, serverUri, nai, methodList, null)); // add All OSU Providers for AP1. @@ -1229,7 +1229,7 @@ public class PasspointManagerTest extends WifiBaseTest { providerInfoListOfAp2.add(new OsuProviderInfo( friendlyNames, serverUri, methodList, null, nai, serviceDescriptions)); expectedOsuProvidersForDomainId2.add(new OsuProvider( - null, friendlyNameMap, serviceDescription, + (WifiSsid) null, friendlyNameMap, serviceDescription, serverUri, nai, methodList, null)); } diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java index e101aa9b0..e7bc1950f 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java @@ -509,7 +509,7 @@ public class PasspointProvisionerTest extends WifiBaseTest { } }).when(mPasspointManager).getANQPElements(any(ScanResult.class)); OsuProviderInfo info = OsuProviderInfoTestUtil.TEST_OSU_PROVIDER_INFO; - mOsuProvider = new OsuProvider(null, info.getFriendlyNames(), + mOsuProvider = new OsuProvider((WifiSsid) null, info.getFriendlyNames(), info.getServiceDescription(), info.getServerUri(), info.getNetworkAccessIdentifier(), info.getMethodList(), null); |