summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2018-01-31 00:51:50 -0800
committerRebecca Silberstein <silberst@google.com>2018-02-20 17:25:48 -0800
commit73dd0f219113f68ca1451b3a6ca48642f7775c82 (patch)
tree211b37cd30ea5dd38531709fe97604d4b5a6c990
parent9a50fce0dd19fa80a37c2f851772811f823685bd (diff)
WifiStateMachine: remove scan related code
Now that we have ScanRequestProxy hooked up with WifiServiceImpl, we no longer need scan request/result handling in WSM. Bug: 31444878 Bug: 31445200 Bug: 70359905 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: Wifi Integration tests Change-Id: I63ab7efe1f43310faf92c927c31bdcfa6d8bb7da
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java414
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java64
2 files changed, 9 insertions, 469 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 783f59510..fe181877d 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -61,14 +61,11 @@ import android.net.dhcp.DhcpClient;
import android.net.ip.IpClient;
import android.net.wifi.RssiPacketCountInfo;
import android.net.wifi.ScanResult;
-import android.net.wifi.ScanSettings;
import android.net.wifi.SupplicantState;
-import android.net.wifi.WifiChannel;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
-import android.net.wifi.WifiScanner;
import android.net.wifi.WifiSsid;
import android.net.wifi.hotspot2.IProvisioningCallback;
import android.net.wifi.hotspot2.OsuProvider;
@@ -110,7 +107,6 @@ import com.android.server.wifi.hotspot2.AnqpEvent;
import com.android.server.wifi.hotspot2.IconEvent;
import com.android.server.wifi.hotspot2.NetworkDetail;
import com.android.server.wifi.hotspot2.PasspointManager;
-import com.android.server.wifi.hotspot2.Utils;
import com.android.server.wifi.hotspot2.WnmData;
import com.android.server.wifi.nano.WifiMetricsProto;
import com.android.server.wifi.nano.WifiMetricsProto.StaEvent;
@@ -133,10 +129,7 @@ import java.net.Inet6Address;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
-import java.util.Queue;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -225,15 +218,6 @@ public class WifiStateMachine extends StateMachine {
private final McastLockManagerFilterController mMcastLockManagerFilterController;
- /* Scan results handling */
- private List<ScanDetail> mScanResults = new ArrayList<>();
- private final Object mScanResultsLock = new Object();
-
- // For debug, number of known scan results that were found as part of last scan result event,
- // as well the number of scans results returned by the supplicant with that message
- private int mNumScanResultsKnown;
- private int mNumScanResultsReturned;
-
private boolean mScreenOn = false;
private String mInterfaceName;
@@ -312,21 +296,10 @@ public class WifiStateMachine extends StateMachine {
* In SCAN_ONLY_WIFI_OFF_MODE, the STA can only scan for access points with wifi toggle being off
*/
private int mOperationalMode = DISABLED_MODE;
- private boolean mIsScanOngoing = false;
- private boolean mIsFullScanOngoing = false;
// variable indicating we are expecting a mode switch - do not attempt recovery for failures
private boolean mModeChange = false;
- private final Queue<Message> mBufferedScanMsg = new LinkedList<>();
- private static final int UNKNOWN_SCAN_SOURCE = -1;
- private static final int ADD_OR_UPDATE_SOURCE = -3;
-
- private static final int SCAN_REQUEST_BUFFER_MAX_SIZE = 10;
- private static final String CUSTOMIZED_SCAN_SETTING = "customized_scan_settings";
- private static final String CUSTOMIZED_SCAN_WORKSOURCE = "customized_scan_worksource";
- private static final String SCAN_REQUEST_TIME = "scan_request_time";
-
private boolean mBluetoothConnectionActive = false;
private PowerManager.WakeLock mSuspendWakeLock;
@@ -467,8 +440,6 @@ public class WifiStateMachine extends StateMachine {
// Used to initiate a connection with WifiP2pService
private AsyncChannel mWifiP2pChannel;
- private WifiScanner mWifiScanner;
-
@GuardedBy("mWifiReqCountLock")
private int mConnectionReqCount = 0;
private WifiNetworkFactory mNetworkFactory;
@@ -530,8 +501,6 @@ public class WifiStateMachine extends StateMachine {
/* Get Link Layer Stats thru HAL */
static final int CMD_GET_LINK_LAYER_STATS = BASE + 63;
/* Supplicant commands after driver start*/
- /* Initiate a scan */
- static final int CMD_START_SCAN = BASE + 71;
/* Set operational mode. CONNECT, SCAN ONLY, SCAN_ONLY with Wi-Fi off mode */
static final int CMD_SET_OPERATIONAL_MODE = BASE + 72;
/* Disconnect from a network */
@@ -1097,8 +1066,6 @@ public class WifiStateMachine extends StateMachine {
getHandler());
mWifiMonitor.registerHandler(mInterfaceName, WifiMonitor.RX_HS20_ANQP_ICON_EVENT,
getHandler());
- mWifiMonitor.registerHandler(mInterfaceName, WifiMonitor.SCAN_FAILED_EVENT, getHandler());
- mWifiMonitor.registerHandler(mInterfaceName, WifiMonitor.SCAN_RESULTS_EVENT, getHandler());
mWifiMonitor.registerHandler(mInterfaceName, WifiMonitor.SUP_CONNECTION_EVENT, getHandler());
mWifiMonitor.registerHandler(mInterfaceName, WifiMonitor.SUP_DISCONNECTION_EVENT,
getHandler());
@@ -1333,25 +1300,6 @@ public class WifiStateMachine extends StateMachine {
return new Messenger(getHandler());
}
- /**
- * Initiate a wifi scan. If workSource is not null, blame is given to it, otherwise blame is
- * given to callingUid.
- *
- * @param callingUid The uid initiating the wifi scan. Blame will be given here unless
- * workSource is specified.
- * @param workSource If not null, blame is given to workSource.
- * @param settings Scan settings, see {@link ScanSettings}.
- * TODO(b/70359905): Remove this method & it's dependencies since it's not used anymore.
- */
- public void startScan(int callingUid, int scanCounter,
- ScanSettings settings, WorkSource workSource) {
- Bundle bundle = new Bundle();
- bundle.putParcelable(CUSTOMIZED_SCAN_SETTING, settings);
- bundle.putParcelable(CUSTOMIZED_SCAN_WORKSOURCE, workSource);
- bundle.putLong(SCAN_REQUEST_TIME, mClock.getWallClockMillis());
- sendMessage(CMD_START_SCAN, callingUid, scanCounter, bundle);
- }
-
private long mDisconnectedTimeStamp = 0;
public long getDisconnectedTimeMilli() {
@@ -1524,132 +1472,6 @@ public class WifiStateMachine extends StateMachine {
return mWifiNative.stopRssiMonitoring(mInterfaceName);
}
- private void handleScanRequest(Message message) {
- ScanSettings settings = null;
- WorkSource workSource = null;
-
- // unbundle parameters
- Bundle bundle = (Bundle) message.obj;
-
- if (bundle != null) {
- settings = bundle.getParcelable(CUSTOMIZED_SCAN_SETTING);
- workSource = bundle.getParcelable(CUSTOMIZED_SCAN_WORKSOURCE);
- }
-
- Set<Integer> freqs = null;
- if (settings != null && settings.channelSet != null) {
- freqs = new HashSet<>();
- for (WifiChannel channel : settings.channelSet) {
- freqs.add(channel.freqMHz);
- }
- }
-
- // Retrieve the list of hidden network SSIDs to scan for.
- List<WifiScanner.ScanSettings.HiddenNetwork> hiddenNetworks =
- mWifiConfigManager.retrieveHiddenNetworkList();
-
- // call wifi native to start the scan
- if (startScanNative(freqs, hiddenNetworks, workSource)) {
- // a full scan covers everything, clearing scan request buffer
- if (freqs == null)
- mBufferedScanMsg.clear();
- messageHandlingStatus = MESSAGE_HANDLING_STATUS_OK;
- return;
- }
-
- // if reach here, scan request is rejected
-
- if (!mIsScanOngoing) {
- // if rejection is NOT due to ongoing scan (e.g. bad scan parameters),
-
- // discard this request and pop up the next one
- if (mBufferedScanMsg.size() > 0) {
- sendMessage(mBufferedScanMsg.remove());
- }
- messageHandlingStatus = MESSAGE_HANDLING_STATUS_DISCARD;
- } else if (!mIsFullScanOngoing) {
- // if rejection is due to an ongoing scan, and the ongoing one is NOT a full scan,
- // buffer the scan request to make sure specified channels will be scanned eventually
- if (freqs == null)
- mBufferedScanMsg.clear();
- if (mBufferedScanMsg.size() < SCAN_REQUEST_BUFFER_MAX_SIZE) {
- Message msg = obtainMessage(CMD_START_SCAN,
- message.arg1, message.arg2, bundle);
- mBufferedScanMsg.add(msg);
- } else {
- // if too many requests in buffer, combine them into a single full scan
- bundle = new Bundle();
- bundle.putParcelable(CUSTOMIZED_SCAN_SETTING, null);
- bundle.putParcelable(CUSTOMIZED_SCAN_WORKSOURCE, workSource);
- Message msg = obtainMessage(CMD_START_SCAN, message.arg1, message.arg2, bundle);
- mBufferedScanMsg.clear();
- mBufferedScanMsg.add(msg);
- }
- messageHandlingStatus = MESSAGE_HANDLING_STATUS_LOOPED;
- } else {
- // mIsScanOngoing and mIsFullScanOngoing
- messageHandlingStatus = MESSAGE_HANDLING_STATUS_FAIL;
- }
- }
-
-
- // TODO this is a temporary measure to bridge between WifiScanner and WifiStateMachine until
- // scan functionality is refactored out of WifiStateMachine.
- /**
- * return true iff scan request is accepted
- */
- private boolean startScanNative(final Set<Integer> freqs,
- List<WifiScanner.ScanSettings.HiddenNetwork> hiddenNetworkList,
- WorkSource workSource) {
- if (mWifiScanner == null) {
- Log.e(TAG, "startScanNative is called when mWifiScanner is null");
- return false;
- }
- WifiScanner.ScanSettings settings = new WifiScanner.ScanSettings();
- if (freqs == null) {
- settings.band = WifiScanner.WIFI_BAND_BOTH_WITH_DFS;
- } else {
- settings.band = WifiScanner.WIFI_BAND_UNSPECIFIED;
- int index = 0;
- settings.channels = new WifiScanner.ChannelSpec[freqs.size()];
- for (Integer freq : freqs) {
- settings.channels[index++] = new WifiScanner.ChannelSpec(freq);
- }
- }
- settings.reportEvents = WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN
- | WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT;
-
- settings.hiddenNetworks =
- hiddenNetworkList.toArray(
- new WifiScanner.ScanSettings.HiddenNetwork[hiddenNetworkList.size()]);
-
- WifiScanner.ScanListener nativeScanListener = new WifiScanner.ScanListener() {
- // ignore all events since WifiStateMachine is registered for the supplicant events
- @Override
- public void onSuccess() {
- }
- @Override
- public void onFailure(int reason, String description) {
- mIsScanOngoing = false;
- mIsFullScanOngoing = false;
- }
- @Override
- public void onResults(WifiScanner.ScanData[] results) {
- }
- @Override
- public void onFullResult(ScanResult fullScanResult) {
- }
- @Override
- public void onPeriodChanged(int periodInMs) {
- }
- };
- mWifiScanner.startScan(settings, nativeScanListener, workSource);
- mIsScanOngoing = true;
- mIsFullScanOngoing = (freqs == null);
- lastScanFreqs = freqs;
- return true;
- }
-
/**
* TODO: doc
*/
@@ -1805,19 +1627,6 @@ public class WifiStateMachine extends StateMachine {
return mMcastLockManagerFilterController;
}
- /**
- * TODO: doc
- */
- public List<ScanResult> syncGetScanResultsList() {
- synchronized (mScanResultsLock) {
- List<ScanResult> scanList = new ArrayList<>();
- for (ScanDetail result : mScanResults) {
- scanList.add(new ScanResult(result.getScanResult()));
- }
- return scanList;
- }
- }
-
public boolean syncQueryPasspointIcon(AsyncChannel channel, long bssid, String fileName) {
Bundle bundle = new Bundle();
bundle.putLong(EXTRA_OSU_ICON_QUERY_BSSID, bssid);
@@ -2301,42 +2110,6 @@ public class WifiStateMachine extends StateMachine {
sb.append(" rt=").append(mClock.getUptimeSinceBootMillis());
sb.append("/").append(mClock.getElapsedSinceBootMillis());
switch (msg.what) {
- case CMD_START_SCAN:
- now = mClock.getWallClockMillis();
- sb.append(" ");
- sb.append(Integer.toString(msg.arg1));
- sb.append(" ");
- sb.append(Integer.toString(msg.arg2));
- sb.append(" ic=");
- sb.append(Integer.toString(sScanAlarmIntentCount));
- if (msg.obj != null) {
- Bundle bundle = (Bundle) msg.obj;
- Long request = bundle.getLong(SCAN_REQUEST_TIME, 0);
- if (request != 0) {
- sb.append(" proc(ms):").append(now - request);
- }
- }
- if (mIsScanOngoing) sb.append(" onGoing");
- if (mIsFullScanOngoing) sb.append(" full");
- sb.append(" rssi=").append(mWifiInfo.getRssi());
- sb.append(" f=").append(mWifiInfo.getFrequency());
- sb.append(" sc=").append(mWifiInfo.score);
- 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));
- if (lastScanFreqs != null) {
- sb.append(" list=");
- for(int freq : lastScanFreqs) {
- sb.append(freq).append(",");
- }
- }
- report = reportOnTime();
- if (report != null) {
- sb.append(" ").append(report);
- }
- break;
case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
sb.append(" ");
sb.append(Integer.toString(msg.arg1));
@@ -2414,27 +2187,6 @@ public class WifiStateMachine extends StateMachine {
}
sb.append(" blacklist=" + Boolean.toString(didBlackListBSSID));
break;
- case WifiMonitor.SCAN_RESULTS_EVENT:
- sb.append(" ");
- sb.append(Integer.toString(msg.arg1));
- sb.append(" ");
- sb.append(Integer.toString(msg.arg2));
- if (mScanResults != null) {
- sb.append(" found=");
- sb.append(mScanResults.size());
- }
- sb.append(" known=").append(mNumScanResultsKnown);
- sb.append(" got=").append(mNumScanResultsReturned);
- sb.append(String.format(" bcn=%d", mRunningBeaconCount));
- sb.append(String.format(" con=%d", mConnectionReqCount));
- sb.append(String.format(" untrustedcn=%d", mUntrustedReqCount));
- key = mWifiConfigManager.getLastSelectedNetworkConfigKey();
- if (key != null) {
- sb.append(" last=").append(key);
- }
- break;
- case WifiMonitor.SCAN_FAILED_EVENT:
- break;
case WifiMonitor.NETWORK_CONNECTION_EVENT:
sb.append(" ");
sb.append(Integer.toString(msg.arg1));
@@ -2888,35 +2640,6 @@ public class WifiStateMachine extends StateMachine {
if (mVerboseLoggingEnabled) log("setWifiApState: " + syncGetWifiApStateByName());
}
- private void setScanResults() {
- mNumScanResultsKnown = 0;
- mNumScanResultsReturned = 0;
-
- ArrayList<ScanDetail> scanResults = mWifiNative.getScanResults(mInterfaceName);
-
- if (scanResults.isEmpty()) {
- mScanResults = new ArrayList<>();
- return;
- }
-
- // TODO(b/31065385): mWifiConfigManager.trimANQPCache(false);
-
- boolean connected = mLastBssid != null;
- long activeBssid = 0L;
- if (connected) {
- try {
- activeBssid = Utils.parseMac(mLastBssid);
- } catch (IllegalArgumentException iae) {
- connected = false;
- }
- }
-
- synchronized (mScanResultsLock) {
- mScanResults = scanResults;
- mNumScanResultsReturned = mScanResults.size();
- }
- }
-
/*
* Fetch RSSI, linkspeed, and frequency on current connection
*/
@@ -3846,10 +3569,6 @@ public class WifiStateMachine extends StateMachine {
case CMD_SCREEN_STATE_CHANGED:
handleScreenStateChanged(message.arg1 != 0);
break;
- /* Discard */
- case CMD_START_SCAN:
- messageHandlingStatus = MESSAGE_HANDLING_STATUS_DISCARD;
- break;
case CMD_START_SUPPLICANT:
case CMD_STOP_SUPPLICANT:
case CMD_DRIVER_START_TIMED_OUT:
@@ -3864,8 +3583,6 @@ public class WifiStateMachine extends StateMachine {
case WifiMonitor.SUP_DISCONNECTION_EVENT:
case WifiMonitor.NETWORK_CONNECTION_EVENT:
case WifiMonitor.NETWORK_DISCONNECTION_EVENT:
- case WifiMonitor.SCAN_RESULTS_EVENT:
- case WifiMonitor.SCAN_FAILED_EVENT:
case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
case WifiMonitor.AUTHENTICATION_FAILURE_EVENT:
case WifiMonitor.ASSOCIATION_REJECTION_EVENT:
@@ -4198,12 +3915,6 @@ public class WifiStateMachine extends StateMachine {
setRandomMacOui();
mCountryCode.setReadyForChange(true);
- // We can't do this in the constructor because WifiStateMachine is created before the
- // wifi scanning service is initialized
- if (mWifiScanner == null) {
- mWifiScanner = mWifiInjector.getWifiScanner();
- }
-
if (mWifiConnectivityManager == null) {
synchronized (mWifiReqCountLock) {
mWifiConnectivityManager =
@@ -4282,21 +3993,6 @@ public class WifiStateMachine extends StateMachine {
sendMessage(CMD_START_SUPPLICANT);
transitionTo(mInitialState);
break;
- case CMD_START_SCAN:
- // TODO: remove scan request path (b/31445200)
- handleScanRequest(message);
- break;
- case WifiMonitor.SCAN_RESULTS_EVENT:
- case WifiMonitor.SCAN_FAILED_EVENT:
- // TODO: remove handing of SCAN_RESULTS_EVENT and SCAN_FAILED_EVENT when scan
- // results are retrieved from WifiScanner (b/31444878)
- maybeRegisterNetworkFactory(); // Make sure our NetworkFactory is registered
- setScanResults();
- mIsScanOngoing = false;
- mIsFullScanOngoing = false;
- if (mBufferedScanMsg.size() > 0)
- sendMessage(mBufferedScanMsg.remove());
- break;
case CMD_TARGET_BSSID:
// Trying to associate to this BSSID
if (message.obj != null) {
@@ -4401,9 +4097,6 @@ public class WifiStateMachine extends StateMachine {
mIsRunning = false;
updateBatteryWorkSource(null);
- mScanResults = new ArrayList<>();
-
- mBufferedScanMsg.clear();
mNetworkInfo.setIsAvailable(false);
if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo);
@@ -4427,37 +4120,16 @@ public class WifiStateMachine extends StateMachine {
public boolean processMessage(Message message) {
logStateAndMessage(message, this);
- switch(message.what) {
- case CMD_SET_OPERATIONAL_MODE:
- int operationMode = message.arg1;
- if (operationMode == SCAN_ONLY_MODE
- || operationMode == SCAN_ONLY_WITH_WIFI_OFF_MODE) {
- // nothing to do, stay here...
- return HANDLED;
- }
- return NOT_HANDLED;
-
- /*
- if (message.arg1 == CONNECT_MODE) {
- mOperationalMode = CONNECT_MODE;
- setWifiState(WIFI_STATE_ENABLING);
- transitionTo(mDisconnectedState);
- } else if (message.arg1 == DISABLED_MODE) {
- transitionTo(mSupplicantStoppingState);
- }
- // Nothing to do
- break;
- */
- // Handle scan. All the connection related commands are
- // handled only in ConnectModeState
- case CMD_START_SCAN:
- // TODO b/31445200: as mentioned elsewhere, this needs to be moved out of WSM
- handleScanRequest(message);
- break;
- default:
- return NOT_HANDLED;
+ if (message.what == CMD_SET_OPERATIONAL_MODE) {
+ int operationMode = message.arg1;
+ if (operationMode == SCAN_ONLY_MODE
+ || operationMode == SCAN_ONLY_WITH_WIFI_OFF_MODE) {
+ // nothing to do, stay here...
+ return HANDLED;
+ }
+ return NOT_HANDLED;
}
- return HANDLED;
+ return NOT_HANDLED;
}
}
@@ -4499,12 +4171,6 @@ public class WifiStateMachine extends StateMachine {
case WifiMonitor.SUP_DISCONNECTION_EVENT:
s = "SUP_DISCONNECTION_EVENT";
break;
- case WifiMonitor.SCAN_RESULTS_EVENT:
- s = "SCAN_RESULTS_EVENT";
- break;
- case WifiMonitor.SCAN_FAILED_EVENT:
- s = "SCAN_FAILED_EVENT";
- break;
case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
s = "SUPPLICANT_STATE_CHANGE_EVENT";
break;
@@ -5420,48 +5086,6 @@ public class WifiStateMachine extends StateMachine {
return prefix + imsi + "@wlan.mnc" + mnc + ".mcc" + mcc + ".3gppnetwork.org";
}
- boolean startScanForConfiguration(WifiConfiguration config) {
- if (config == null)
- return false;
-
- // We are still seeing a fairly high power consumption triggered by autojoin scans
- // Hence do partial scans only for PSK configuration that are roamable since the
- // primary purpose of the partial scans is roaming.
- // Full badn scans with exponential backoff for the purpose or extended roaming and
- // network switching are performed unconditionally.
- ScanDetailCache scanDetailCache =
- mWifiConfigManager.getScanDetailCacheForNetwork(config.networkId);
- if (scanDetailCache == null
- || !config.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_PSK)
- || scanDetailCache.size() > 6) {
- //return true but to not trigger the scan
- return true;
- }
- Set<Integer> freqs =
- mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(
- config.networkId, ONE_HOUR_MILLI, mWifiInfo.getFrequency());
- if (freqs != null && freqs.size() != 0) {
- //if (mVerboseLoggingEnabled) {
- logd("starting scan for " + config.configKey() + " with " + freqs);
- //}
- List<WifiScanner.ScanSettings.HiddenNetwork> hiddenNetworks = new ArrayList<>();
- if (config.hiddenSSID) {
- hiddenNetworks.add(new WifiScanner.ScanSettings.HiddenNetwork(config.SSID));
- }
- // Call wifi native to start the scan
- if (startScanNative(freqs, hiddenNetworks, WIFI_WORK_SOURCE)) {
- messageHandlingStatus = MESSAGE_HANDLING_STATUS_OK;
- } else {
- // used for debug only, mark scan as failed
- messageHandlingStatus = MESSAGE_HANDLING_STATUS_HANDLING_ERROR;
- }
- return true;
- } else {
- if (mVerboseLoggingEnabled) logd("no channels for " + config.configKey());
- return false;
- }
- }
-
class L2ConnectedState extends State {
class RssiEventHandler implements WifiNative.WifiRssiEventHandler {
@Override
@@ -5814,11 +5438,6 @@ public class WifiStateMachine extends StateMachine {
messageHandlingStatus = MESSAGE_HANDLING_STATUS_DEFERRED;
deferMessage(message);
break;
- /* Defer scan request since we should not switch to other channels at DHCP */
- case CMD_START_SCAN:
- messageHandlingStatus = MESSAGE_HANDLING_STATUS_DEFERRED;
- deferMessage(message);
- break;
default:
return NOT_HANDLED;
}
@@ -6003,9 +5622,6 @@ public class WifiStateMachine extends StateMachine {
transitionTo(mDisconnectedState);
}
break;
- case CMD_START_SCAN:
- deferMessage(message);
- break;
default:
return NOT_HANDLED;
}
@@ -6232,9 +5848,6 @@ public class WifiStateMachine extends StateMachine {
public boolean processMessage(Message message) {
logStateAndMessage(message, this);
switch (message.what) {
- case CMD_START_SCAN:
- deferMessage(message);
- return HANDLED;
case CMD_DISCONNECT:
if (mVerboseLoggingEnabled) log("Ignore CMD_DISCONNECT when already disconnecting.");
break;
@@ -6313,15 +5926,6 @@ public class WifiStateMachine extends StateMachine {
/* ConnectModeState does the rest of the handling */
ret = NOT_HANDLED;
break;
- case CMD_START_SCAN:
- if (!checkOrDeferScanAllowed(message)) {
- // The scan request was rescheduled
- messageHandlingStatus = MESSAGE_HANDLING_STATUS_REFUSED;
- return HANDLED;
- }
-
- ret = NOT_HANDLED;
- break;
case WifiP2pServiceImpl.P2P_CONNECTION_CHANGED:
NetworkInfo info = (NetworkInfo) message.obj;
mP2pConnected.set(info.isConnected());
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 7aeccbef6..29f8b4847 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -108,9 +108,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.function.Consumer;
@@ -921,68 +919,6 @@ public class WifiStateMachineTest {
return null;
}
- private void verifyScan(int band, int reportEvents, Set<String> hiddenNetworkSSIDSet) {
- ArgumentCaptor<WifiScanner.ScanSettings> scanSettingsCaptor =
- ArgumentCaptor.forClass(WifiScanner.ScanSettings.class);
- ArgumentCaptor<WifiScanner.ScanListener> scanListenerCaptor =
- ArgumentCaptor.forClass(WifiScanner.ScanListener.class);
- verify(mWifiScanner).startScan(scanSettingsCaptor.capture(), scanListenerCaptor.capture(),
- eq(null));
- WifiScanner.ScanSettings actualSettings = scanSettingsCaptor.getValue();
- assertEquals("band", band, actualSettings.band);
- assertEquals("reportEvents", reportEvents, actualSettings.reportEvents);
-
- if (hiddenNetworkSSIDSet == null) {
- hiddenNetworkSSIDSet = new HashSet<>();
- }
- Set<String> actualHiddenNetworkSSIDSet = new HashSet<>();
- if (actualSettings.hiddenNetworks != null) {
- for (int i = 0; i < actualSettings.hiddenNetworks.length; ++i) {
- actualHiddenNetworkSSIDSet.add(actualSettings.hiddenNetworks[i].ssid);
- }
- }
- assertEquals("hidden networks", hiddenNetworkSSIDSet, actualHiddenNetworkSSIDSet);
-
- when(mWifiNative.getScanResults(WIFI_IFACE_NAME)).thenReturn(getMockScanResults());
- mWsm.sendMessage(WifiMonitor.SCAN_RESULTS_EVENT);
-
- mLooper.dispatchAll();
-
- List<ScanResult> reportedResults = mWsm.syncGetScanResultsList();
- assertEquals(8, reportedResults.size());
- }
-
- @Test
- public void scan() throws Exception {
- initializeAndAddNetworkAndVerifySuccess();
-
- mWsm.startScan(-1, 0, null, null);
- mLooper.dispatchAll();
-
- verifyScan(WifiScanner.WIFI_BAND_BOTH_WITH_DFS,
- WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN
- | WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT, null);
- }
-
- @Test
- public void scanWithHiddenNetwork() throws Exception {
- initializeAndAddNetworkAndVerifySuccess(true);
-
- Set<String> hiddenNetworkSet = new HashSet<>();
- hiddenNetworkSet.add(sSSID);
- List<WifiScanner.ScanSettings.HiddenNetwork> hiddenNetworkList = new ArrayList<>();
- hiddenNetworkList.add(new WifiScanner.ScanSettings.HiddenNetwork(sSSID));
- when(mWifiConfigManager.retrieveHiddenNetworkList()).thenReturn(hiddenNetworkList);
-
- mWsm.startScan(-1, 0, null, null);
- mLooper.dispatchAll();
-
- verifyScan(WifiScanner.WIFI_BAND_BOTH_WITH_DFS,
- WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN
- | WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT,
- hiddenNetworkSet);
- }
-
private void setupAndStartConnectSequence(WifiConfiguration config) throws Exception {
when(mWifiConfigManager.enableNetwork(eq(config.networkId), eq(true), anyInt()))
.thenReturn(true);