summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2019-12-09 21:54:33 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-12-09 21:54:33 +0000
commitcdaf27dae9b472d3e01f7268c8ef398746e99bd4 (patch)
tree319b0d7344391577b288fb23317592208216f5ce
parent158c3f29da578d4a61ee9c04c65b91438f0802f3 (diff)
parent6dcd883acd0ff4d6314a5f58885abb55ba9e4cbf (diff)
Merge changes from topic "wificond_phase1"
* changes: [WIFI][MAINLINE] Transition WificondControl interfaces: SoftApListener [WIFI][MAINLINE] Transition WificondControl interfaces: SendMgmtFrameCallback [WIFI][MAINLINE] Transition WificondControl interfaces: SignalPollResult, TxPacketCounters [WIFI][MAINLINE] Convert ScanType usage to a single WifiScanner API
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java6
-rw-r--r--service/java/com/android/server/wifi/HostapdHal.java16
-rw-r--r--service/java/com/android/server/wifi/LinkProbeManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java15
-rw-r--r--service/java/com/android/server/wifi/WifiNative.java156
-rw-r--r--service/java/com/android/server/wifi/WifiShellCommand.java2
-rw-r--r--service/java/com/android/server/wifi/WificondControl.java153
-rw-r--r--service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java40
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java36
-rw-r--r--tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java12
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java20
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java21
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WificondControlTest.java33
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java8
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java2
17 files changed, 259 insertions, 271 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 474b094cf..1c02ac73d 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -2233,7 +2233,7 @@ public class ClientModeImpl extends StateMachine {
* Fetch RSSI, linkspeed, and frequency on current connection
*/
private void fetchRssiLinkSpeedAndFrequencyNative() {
- WifiNative.SignalPollResult pollResult = mWifiNative.signalPoll(mInterfaceName);
+ WificondControl.SignalPollResult pollResult = mWifiNative.signalPoll(mInterfaceName);
if (pollResult == null) {
return;
}
@@ -4458,7 +4458,7 @@ public class ClientModeImpl extends StateMachine {
break;
case CMD_PKT_CNT_FETCH:
callbackIdentifier = message.arg2;
- WifiNative.TxPacketCounters counters =
+ WificondControl.TxPacketCounters counters =
mWifiNative.getTxPacketCounters(mInterfaceName);
if (counters != null) {
sendTxPacketCountListenerSuccess(
@@ -5624,7 +5624,7 @@ public class ClientModeImpl extends StateMachine {
* Sends a link probe.
*/
@VisibleForTesting
- public void probeLink(WifiNative.SendMgmtFrameCallback callback, int mcs) {
+ public void probeLink(WificondControl.SendMgmtFrameCallback callback, int mcs) {
mWifiNative.probeLink(mInterfaceName, MacAddress.fromString(mWifiInfo.getBSSID()),
callback, mcs);
}
diff --git a/service/java/com/android/server/wifi/HostapdHal.java b/service/java/com/android/server/wifi/HostapdHal.java
index 04841c8cc..e1e4556ea 100644
--- a/service/java/com/android/server/wifi/HostapdHal.java
+++ b/service/java/com/android/server/wifi/HostapdHal.java
@@ -67,7 +67,7 @@ public class HostapdHal {
// Hostapd HAL interface objects
private IServiceManager mIServiceManager = null;
private IHostapd mIHostapd;
- private HashMap<String, WifiNative.SoftApListener> mSoftApListeners = new HashMap<>();
+ private HashMap<String, Runnable> mSoftApFailureListeners = new HashMap<>();
private HostapdDeathEventHandler mDeathEventHandler;
private ServiceManagerDeathRecipient mServiceManagerDeathRecipient;
private HostapdDeathRecipient mHostapdDeathRecipient;
@@ -315,11 +315,11 @@ public class HostapdHal {
*
* @param ifaceName Name of the interface.
* @param config Configuration to use for the AP.
- * @param listener Callback for AP events.
+ * @param onFailureListener A runnable to be triggered on failure.
* @return true on success, false otherwise.
*/
public boolean addAccessPoint(@NonNull String ifaceName, @NonNull SoftApConfiguration config,
- @NonNull WifiNative.SoftApListener listener) {
+ @NonNull Runnable onFailureListener) {
synchronized (mLock) {
final String methodStr = "addAccessPoint";
IHostapd.IfaceParams ifaceParams = new IHostapd.IfaceParams();
@@ -392,7 +392,7 @@ public class HostapdHal {
if (!checkStatusAndLogFailure(status, methodStr)) {
return false;
}
- mSoftApListeners.put(ifaceName, listener);
+ mSoftApFailureListeners.put(ifaceName, onFailureListener);
return true;
} catch (RemoteException e) {
handleRemoteException(e, methodStr);
@@ -416,7 +416,7 @@ public class HostapdHal {
if (!checkStatusAndLogFailure(status, methodStr)) {
return false;
}
- mSoftApListeners.remove(ifaceName);
+ mSoftApFailureListeners.remove(ifaceName);
return true;
} catch (RemoteException e) {
handleRemoteException(e, methodStr);
@@ -699,9 +699,9 @@ public class HostapdHal {
@Override
public void onFailure(String ifaceName) {
Log.w(TAG, "Failure on iface " + ifaceName);
- WifiNative.SoftApListener listener = mSoftApListeners.get(ifaceName);
- if (listener != null) {
- listener.onFailure();
+ Runnable onFailureListener = mSoftApFailureListeners.get(ifaceName);
+ if (onFailureListener != null) {
+ onFailureListener.run();
}
}
}
diff --git a/service/java/com/android/server/wifi/LinkProbeManager.java b/service/java/com/android/server/wifi/LinkProbeManager.java
index 82c1cda0c..3ecd20203 100644
--- a/service/java/com/android/server/wifi/LinkProbeManager.java
+++ b/service/java/com/android/server/wifi/LinkProbeManager.java
@@ -252,7 +252,7 @@ public class LinkProbeManager {
mWifiNative.probeLink(
interfaceName,
MacAddress.fromString(wifiInfo.getBSSID()),
- new WifiNative.SendMgmtFrameCallback() {
+ new WificondControl.SendMgmtFrameCallback() {
@Override
public void onAck(int elapsedTimeMs) {
if (mVerboseLoggingEnabled) {
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 999b00cbb..a94521aea 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -3392,15 +3392,16 @@ public class WifiMetrics {
}
}
- private static int linkProbeFailureReasonToProto(@WifiNative.SendMgmtFrameError int reason) {
+ private static int linkProbeFailureReasonToProto(
+ @WificondControl.SendMgmtFrameError int reason) {
switch (reason) {
- case WifiNative.SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED:
+ case WificondControl.SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED:
return LinkProbeStats.LINK_PROBE_FAILURE_REASON_MCS_UNSUPPORTED;
- case WifiNative.SEND_MGMT_FRAME_ERROR_NO_ACK:
+ case WificondControl.SEND_MGMT_FRAME_ERROR_NO_ACK:
return LinkProbeStats.LINK_PROBE_FAILURE_REASON_NO_ACK;
- case WifiNative.SEND_MGMT_FRAME_ERROR_TIMEOUT:
+ case WificondControl.SEND_MGMT_FRAME_ERROR_TIMEOUT:
return LinkProbeStats.LINK_PROBE_FAILURE_REASON_TIMEOUT;
- case WifiNative.SEND_MGMT_FRAME_ERROR_ALREADY_STARTED:
+ case WificondControl.SEND_MGMT_FRAME_ERROR_ALREADY_STARTED:
return LinkProbeStats.LINK_PROBE_FAILURE_REASON_ALREADY_STARTED;
default:
return LinkProbeStats.LINK_PROBE_FAILURE_REASON_UNKNOWN;
@@ -4733,10 +4734,10 @@ public class WifiMetrics {
* {@link WifiInfo#txSuccess}).
* @param rssi The Rx RSSI at {@code startTimestampMs}.
* @param linkSpeed The Tx link speed in Mbps at {@code startTimestampMs}.
- * @param reason The error code for the failure. See {@link WifiNative.SendMgmtFrameError}.
+ * @param reason The error code for the failure. See {@link WificondControl.SendMgmtFrameError}.
*/
public void logLinkProbeFailure(long timeSinceLastTxSuccessMs,
- int rssi, int linkSpeed, @WifiNative.SendMgmtFrameError int reason) {
+ int rssi, int linkSpeed, @WificondControl.SendMgmtFrameError int reason) {
synchronized (mLock) {
mProbeStatusSinceLastUpdate =
android.net.wifi.WifiUsabilityStatsEntry.PROBE_STATUS_FAILURE;
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 3dfd63bf9..f5a52a6ae 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -39,7 +39,6 @@ import com.android.internal.util.HexDump;
import com.android.server.net.BaseNetworkObserver;
import com.android.server.wifi.util.FrameParser;
import com.android.server.wifi.util.NativeUtil;
-import com.android.server.wifi.wificond.NativeWifiClient;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -115,6 +114,13 @@ public class WifiNative {
mWifiVendorHal.enableVerboseLogging(mVerboseLoggingEnabled);
}
+ /**
+ * Callbacks for SoftAp interface.
+ */
+ public interface SoftApListener extends WificondControl.SoftApListener {
+ // dummy for now - provide a shell so that clients don't use a WificondControl-specific API.
+ }
+
/********************************************************
* Interface management related methods.
********************************************************/
@@ -1310,29 +1316,6 @@ public class WifiNative {
/********************************************************
* Wificond operations
********************************************************/
- /**
- * Result of a signal poll.
- */
- public static class SignalPollResult {
- // RSSI value in dBM.
- public int currentRssi;
- //Transmission bit rate in Mbps.
- public int txBitrate;
- // Association frequency in MHz.
- public int associationFrequency;
- //Last received packet bit rate in Mbps.
- public int rxBitrate;
- }
-
- /**
- * WiFi interface transimission counters.
- */
- public static class TxPacketCounters {
- // Number of successfully transmitted packets.
- public int txSucceeded;
- // Number of tramsmission failures.
- public int txFailed;
- }
/**
* Callback to notify wificond death.
@@ -1351,7 +1334,7 @@ public class WifiNative {
* Returns an SignalPollResult object.
* Returns null on failure.
*/
- public SignalPollResult signalPoll(@NonNull String ifaceName) {
+ public WificondControl.SignalPollResult signalPoll(@NonNull String ifaceName) {
return mWificondControl.signalPoll(ifaceName);
}
@@ -1361,7 +1344,7 @@ public class WifiNative {
* Returns an TxPacketCounters object.
* Returns null on failure.
*/
- public TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) {
+ public WificondControl.TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) {
return mWificondControl.getTxPacketCounters(ifaceName);
}
@@ -1385,14 +1368,14 @@ public class WifiNative {
/**
* Start a scan using wificond for the given parameters.
* @param ifaceName Name of the interface.
- * @param scanType Type of scan to perform. One of {@link ScanSettings#SCAN_TYPE_LOW_LATENCY},
- * {@link ScanSettings#SCAN_TYPE_LOW_POWER} or {@link ScanSettings#SCAN_TYPE_HIGH_ACCURACY}.
+ * @param scanType Type of scan to perform. One of {@link WifiScanner#SCAN_TYPE_LOW_LATENCY},
+ * {@link WifiScanner#SCAN_TYPE_LOW_POWER} or {@link WifiScanner#SCAN_TYPE_HIGH_ACCURACY}.
* @param freqs list of frequencies to scan for, if null scan all supported channels.
* @param hiddenNetworkSSIDs List of hidden networks to be scanned for.
* @return Returns true on success.
*/
public boolean scan(
- @NonNull String ifaceName, int scanType, Set<Integer> freqs,
+ @NonNull String ifaceName, @WifiScanner.ScanType int scanType, Set<Integer> freqs,
List<String> hiddenNetworkSSIDs) {
return mWificondControl.scan(ifaceName, scanType, freqs, hiddenNetworkSSIDs);
}
@@ -1438,73 +1421,6 @@ public class WifiNative {
}
/**
- * Callback to notify the results of a
- * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()} call.
- * Note: no callbacks will be triggered if the iface dies while sending a frame.
- */
- public interface SendMgmtFrameCallback {
- /**
- * Called when the management frame was successfully sent and ACKed by the recipient.
- * @param elapsedTimeMs The elapsed time between when the management frame was sent and when
- * the ACK was processed, in milliseconds, as measured by wificond.
- * This includes the time that the send frame spent queuing before it
- * was sent, any firmware retries, and the time the received ACK spent
- * queuing before it was processed.
- */
- void onAck(int elapsedTimeMs);
-
- /**
- * Called when the send failed.
- * @param reason The error code for the failure.
- */
- void onFailure(@SendMgmtFrameError int reason);
- }
-
- @Retention(RetentionPolicy.SOURCE)
- @IntDef(prefix = {"SEND_MGMT_FRAME_ERROR_"},
- value = {SEND_MGMT_FRAME_ERROR_UNKNOWN,
- SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED,
- SEND_MGMT_FRAME_ERROR_NO_ACK,
- SEND_MGMT_FRAME_ERROR_TIMEOUT,
- SEND_MGMT_FRAME_ERROR_ALREADY_STARTED})
- public @interface SendMgmtFrameError {}
-
- // Send management frame error codes
-
- /**
- * Unknown error occurred during call to
- * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}.
- */
- public static final int SEND_MGMT_FRAME_ERROR_UNKNOWN = 1;
-
- /**
- * Specifying the MCS rate in
- * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()} is not
- * supported by this device.
- */
- public static final int SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED = 2;
-
- /**
- * Driver reported that no ACK was received for the frame transmitted using
- * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}.
- */
- public static final int SEND_MGMT_FRAME_ERROR_NO_ACK = 3;
-
- /**
- * Error code for when the driver fails to report on the status of the frame sent by
- * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}
- * after {@link WificondControl#SEND_MGMT_FRAME_TIMEOUT_MS} milliseconds.
- */
- public static final int SEND_MGMT_FRAME_ERROR_TIMEOUT = 4;
-
- /**
- * An existing call to
- * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}
- * is in progress. Another frame cannot be sent until the first call completes.
- */
- public static final int SEND_MGMT_FRAME_ERROR_ALREADY_STARTED = 5;
-
- /**
* Sends an arbitrary 802.11 management frame on the current channel.
*
* @param ifaceName Name of the interface.
@@ -1515,11 +1431,11 @@ public class WifiNative {
* @param mcs The MCS index that the frame will be sent at. If mcs < 0, the driver will select
* the rate automatically. If the device does not support sending the frame at a
* specified MCS rate, the transmission will be aborted and
- * {@link SendMgmtFrameCallback#onFailure(int)} will be called with reason
- * {@link #SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED}.
+ * {@link WificondControl.SendMgmtFrameCallback#onFailure(int)} will be called
+ * with reason {@link WificondControl#SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED}.
*/
public void sendMgmtFrame(@NonNull String ifaceName, @NonNull byte[] frame,
- @NonNull SendMgmtFrameCallback callback, int mcs) {
+ @NonNull WificondControl.SendMgmtFrameCallback callback, int mcs) {
mWificondControl.sendMgmtFrame(ifaceName, frame, callback, mcs);
}
@@ -1534,11 +1450,11 @@ public class WifiNative {
* @param mcs The MCS index that this probe will be sent at. If mcs < 0, the driver will select
* the rate automatically. If the device does not support sending the frame at a
* specified MCS rate, the transmission will be aborted and
- * {@link SendMgmtFrameCallback#onFailure(int)} will be called with reason
- * {@link #SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED}.
+ * {@link WificondControl.SendMgmtFrameCallback#onFailure(int)} will be called
+ * with reason {@link WificondControl#SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED}.
*/
public void probeLink(@NonNull String ifaceName, @NonNull MacAddress receiverMac,
- @NonNull SendMgmtFrameCallback callback, int mcs) {
+ @NonNull WificondControl.SendMgmtFrameCallback callback, int mcs) {
if (callback == null) {
Log.e(TAG, "callback cannot be null!");
return;
@@ -1546,14 +1462,14 @@ public class WifiNative {
if (receiverMac == null) {
Log.e(TAG, "Receiver MAC address cannot be null!");
- callback.onFailure(SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ callback.onFailure(WificondControl.SEND_MGMT_FRAME_ERROR_UNKNOWN);
return;
}
String senderMacStr = getMacAddress(ifaceName);
if (senderMacStr == null) {
Log.e(TAG, "Failed to get this device's MAC Address");
- callback.onFailure(SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ callback.onFailure(WificondControl.SEND_MGMT_FRAME_ERROR_UNKNOWN);
return;
}
@@ -1612,26 +1528,6 @@ public class WifiNative {
return frame.array();
}
- /**
- * Callbacks for SoftAp interface.
- */
- public interface SoftApListener {
- /**
- * Invoked when there is some fatal failure in the lower layers.
- */
- void onFailure();
-
- /**
- * Invoked when the associated stations changes.
- */
- void onConnectedClientsChanged(List<NativeWifiClient> clients);
-
- /**
- * Invoked when the channel switch event happens.
- */
- void onSoftApChannelSwitched(int frequency, int bandwidth);
- }
-
private static final int CONNECT_TO_HOSTAPD_RETRY_INTERVAL_MS = 100;
private static final int CONNECT_TO_HOSTAPD_RETRY_TIMES = 50;
/**
@@ -1679,7 +1575,7 @@ public class WifiNative {
Log.e(TAG, "Failed to register ap listener");
return false;
}
- if (!mHostapdHal.addAccessPoint(ifaceName, config, listener)) {
+ if (!mHostapdHal.addAccessPoint(ifaceName, config, () -> listener.onFailure())) {
Log.e(TAG, "Failed to add acccess point");
mWifiMetrics.incrementNumSetupSoftApInterfaceFailureDueToHostapd();
return false;
@@ -2542,16 +2438,12 @@ public class WifiNative {
}
}
- public static final int SCAN_TYPE_LOW_LATENCY = 0;
- public static final int SCAN_TYPE_LOW_POWER = 1;
- public static final int SCAN_TYPE_HIGH_ACCURACY = 2;
-
public static class ScanSettings {
/**
- * Type of scan to perform. One of {@link ScanSettings#SCAN_TYPE_LOW_LATENCY},
- * {@link ScanSettings#SCAN_TYPE_LOW_POWER} or {@link ScanSettings#SCAN_TYPE_HIGH_ACCURACY}.
+ * Type of scan to perform. One of {@link WifiScanner#SCAN_TYPE_LOW_LATENCY},
+ * {@link WifiScanner#SCAN_TYPE_LOW_POWER} or {@link WifiScanner#SCAN_TYPE_HIGH_ACCURACY}.
*/
- public int scanType;
+ public @WifiScanner.ScanType int scanType;
public int base_period_ms;
public int max_ap_per_scan;
public int report_threshold_percent;
diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java
index e686cc70c..275681ae0 100644
--- a/service/java/com/android/server/wifi/WifiShellCommand.java
+++ b/service/java/com/android/server/wifi/WifiShellCommand.java
@@ -306,7 +306,7 @@ public class WifiShellCommand extends ShellCommand {
private int sendLinkProbe(PrintWriter pw) throws InterruptedException {
ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<>(1);
- mClientModeImpl.probeLink(new WifiNative.SendMgmtFrameCallback() {
+ mClientModeImpl.probeLink(new WificondControl.SendMgmtFrameCallback() {
@Override
public void onAck(int elapsedTimeMs) {
queue.offer("Link probe succeeded after " + elapsedTimeMs + " ms");
diff --git a/service/java/com/android/server/wifi/WificondControl.java b/service/java/com/android/server/wifi/WificondControl.java
index 7a4e9e698..487a53723 100644
--- a/service/java/com/android/server/wifi/WificondControl.java
+++ b/service/java/com/android/server/wifi/WificondControl.java
@@ -18,6 +18,7 @@ package com.android.server.wifi;
import static android.net.wifi.WifiManager.WIFI_FEATURE_OWE;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.app.AlarmManager;
import android.net.wifi.IApInterface;
@@ -37,8 +38,6 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
-import com.android.server.wifi.WifiNative.SendMgmtFrameCallback;
-import com.android.server.wifi.WifiNative.SoftApListener;
import com.android.server.wifi.hotspot2.NetworkDetail;
import com.android.server.wifi.util.InformationElementUtil;
import com.android.server.wifi.util.NativeUtil;
@@ -52,6 +51,8 @@ import com.android.server.wifi.wificond.PnoSettings;
import com.android.server.wifi.wificond.RadioChainInfo;
import com.android.server.wifi.wificond.SingleScanSettings;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -71,7 +72,7 @@ public class WificondControl implements IBinder.DeathRecipient {
* The {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}
* timeout, in milliseconds, after which
* {@link SendMgmtFrameCallback#onFailure(int)} will be called with reason
- * {@link WifiNative#SEND_MGMT_FRAME_ERROR_TIMEOUT}.
+ * {@link #SEND_MGMT_FRAME_ERROR_TIMEOUT}.
*/
public static final int SEND_MGMT_FRAME_TIMEOUT_MS = 1000;
@@ -129,6 +130,118 @@ public class WificondControl implements IBinder.DeathRecipient {
}
}
+ /**
+ * Result of a signal poll.
+ */
+ public static class SignalPollResult {
+ // RSSI value in dBM.
+ public int currentRssi;
+ //Transmission bit rate in Mbps.
+ public int txBitrate;
+ // Association frequency in MHz.
+ public int associationFrequency;
+ //Last received packet bit rate in Mbps.
+ public int rxBitrate;
+ }
+
+ /**
+ * WiFi interface transimission counters.
+ */
+ public static class TxPacketCounters {
+ // Number of successfully transmitted packets.
+ public int txSucceeded;
+ // Number of tramsmission failures.
+ public int txFailed;
+ }
+
+ /**
+ * Callbacks for SoftAp interface.
+ */
+ public interface SoftApListener {
+ /**
+ * Invoked when there is some fatal failure in the lower layers.
+ */
+ void onFailure();
+
+ /**
+ * Invoked when the associated stations changes.
+ */
+ void onConnectedClientsChanged(List<NativeWifiClient> clients);
+
+ /**
+ * Invoked when the channel switch event happens.
+ */
+ void onSoftApChannelSwitched(int frequency, int bandwidth);
+ }
+
+ /**
+ * Callback to notify the results of a
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()} call.
+ * Note: no callbacks will be triggered if the iface dies while sending a frame.
+ */
+ public interface SendMgmtFrameCallback {
+ /**
+ * Called when the management frame was successfully sent and ACKed by the recipient.
+ * @param elapsedTimeMs The elapsed time between when the management frame was sent and when
+ * the ACK was processed, in milliseconds, as measured by wificond.
+ * This includes the time that the send frame spent queuing before it
+ * was sent, any firmware retries, and the time the received ACK spent
+ * queuing before it was processed.
+ */
+ void onAck(int elapsedTimeMs);
+
+ /**
+ * Called when the send failed.
+ * @param reason The error code for the failure.
+ */
+ void onFailure(@SendMgmtFrameError int reason);
+ }
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"SEND_MGMT_FRAME_ERROR_"},
+ value = {SEND_MGMT_FRAME_ERROR_UNKNOWN,
+ SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED,
+ SEND_MGMT_FRAME_ERROR_NO_ACK,
+ SEND_MGMT_FRAME_ERROR_TIMEOUT,
+ SEND_MGMT_FRAME_ERROR_ALREADY_STARTED})
+ public @interface SendMgmtFrameError {}
+
+ // Send management frame error codes
+
+ /**
+ * Unknown error occurred during call to
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}.
+ */
+ public static final int SEND_MGMT_FRAME_ERROR_UNKNOWN = 1;
+
+ /**
+ * Specifying the MCS rate in
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()} is not
+ * supported by this device.
+ */
+ public static final int SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED = 2;
+
+ /**
+ * Driver reported that no ACK was received for the frame transmitted using
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}.
+ */
+ public static final int SEND_MGMT_FRAME_ERROR_NO_ACK = 3;
+
+ /**
+ * Error code for when the driver fails to report on the status of the frame sent by
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}
+ * after {@link WificondControl#SEND_MGMT_FRAME_TIMEOUT_MS} milliseconds.
+ */
+ public static final int SEND_MGMT_FRAME_ERROR_TIMEOUT = 4;
+
+ /**
+ * An existing call to
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}
+ * is in progress. Another frame cannot be sent until the first call completes.
+ */
+ public static final int SEND_MGMT_FRAME_ERROR_ALREADY_STARTED = 5;
+
+
WificondControl(WifiInjector wifiInjector, WifiMonitor wifiMonitor,
CarrierNetworkConfig carrierNetworkConfig, AlarmManager alarmManager, Handler handler,
Clock clock) {
@@ -215,7 +328,7 @@ public class WificondControl implements IBinder.DeathRecipient {
if (mVerboseLoggingEnabled) {
Log.e(TAG, "Timed out waiting for ACK");
}
- mCallback.onFailure(WifiNative.SEND_MGMT_FRAME_ERROR_TIMEOUT);
+ mCallback.onFailure(SEND_MGMT_FRAME_ERROR_TIMEOUT);
});
mWasCalled = false;
@@ -505,7 +618,7 @@ public class WificondControl implements IBinder.DeathRecipient {
* Returns an SignalPollResult object.
* Returns null on failure.
*/
- public WifiNative.SignalPollResult signalPoll(@NonNull String ifaceName) {
+ public SignalPollResult signalPoll(@NonNull String ifaceName) {
IClientInterface iface = getClientInterface(ifaceName);
if (iface == null) {
Log.e(TAG, "No valid wificond client interface handler");
@@ -523,7 +636,7 @@ public class WificondControl implements IBinder.DeathRecipient {
Log.e(TAG, "Failed to do signal polling due to remote exception");
return null;
}
- WifiNative.SignalPollResult pollResult = new WifiNative.SignalPollResult();
+ SignalPollResult pollResult = new SignalPollResult();
pollResult.currentRssi = resultArray[0];
pollResult.txBitrate = resultArray[1];
pollResult.associationFrequency = resultArray[2];
@@ -537,7 +650,7 @@ public class WificondControl implements IBinder.DeathRecipient {
* Returns an TxPacketCounters object.
* Returns null on failure.
*/
- public WifiNative.TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) {
+ public TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) {
IClientInterface iface = getClientInterface(ifaceName);
if (iface == null) {
Log.e(TAG, "No valid wificond client interface handler");
@@ -555,7 +668,7 @@ public class WificondControl implements IBinder.DeathRecipient {
Log.e(TAG, "Failed to do signal polling due to remote exception");
return null;
}
- WifiNative.TxPacketCounters counters = new WifiNative.TxPacketCounters();
+ TxPacketCounters counters = new TxPacketCounters();
counters.txSucceeded = resultArray[0];
counters.txFailed = resultArray[1];
return counters;
@@ -656,13 +769,13 @@ public class WificondControl implements IBinder.DeathRecipient {
/**
* Return scan type for the parcelable {@link SingleScanSettings}
*/
- private static int getScanType(int scanType) {
+ private static int getScanType(@WifiScanner.ScanType int scanType) {
switch (scanType) {
- case WifiNative.SCAN_TYPE_LOW_LATENCY:
+ case WifiScanner.SCAN_TYPE_LOW_LATENCY:
return IWifiScannerImpl.SCAN_TYPE_LOW_SPAN;
- case WifiNative.SCAN_TYPE_LOW_POWER:
+ case WifiScanner.SCAN_TYPE_LOW_POWER:
return IWifiScannerImpl.SCAN_TYPE_LOW_POWER;
- case WifiNative.SCAN_TYPE_HIGH_ACCURACY:
+ case WifiScanner.SCAN_TYPE_HIGH_ACCURACY:
return IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY;
default:
throw new IllegalArgumentException("Invalid scan type " + scanType);
@@ -677,10 +790,8 @@ public class WificondControl implements IBinder.DeathRecipient {
* @param hiddenNetworkSSIDs List of hidden networks to be scanned for.
* @return Returns true on success.
*/
- public boolean scan(@NonNull String ifaceName,
- int scanType,
- Set<Integer> freqs,
- List<String> hiddenNetworkSSIDs) {
+ public boolean scan(@NonNull String ifaceName, @WifiScanner.ScanType int scanType,
+ Set<Integer> freqs, List<String> hiddenNetworkSSIDs) {
IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName);
if (scannerImpl == null) {
Log.e(TAG, "No valid wificond scanner interface handler");
@@ -883,7 +994,7 @@ public class WificondControl implements IBinder.DeathRecipient {
}
/**
- * See {@link WifiNative#sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int)}
+ * See {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int)}
*/
public void sendMgmtFrame(@NonNull String ifaceName, @NonNull byte[] frame,
@NonNull SendMgmtFrameCallback callback, int mcs) {
@@ -895,7 +1006,7 @@ public class WificondControl implements IBinder.DeathRecipient {
if (frame == null) {
Log.e(TAG, "frame cannot be null!");
- callback.onFailure(WifiNative.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ callback.onFailure(SEND_MGMT_FRAME_ERROR_UNKNOWN);
return;
}
@@ -903,13 +1014,13 @@ public class WificondControl implements IBinder.DeathRecipient {
IClientInterface clientInterface = getClientInterface(ifaceName);
if (clientInterface == null) {
Log.e(TAG, "No valid wificond client interface handler");
- callback.onFailure(WifiNative.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ callback.onFailure(SEND_MGMT_FRAME_ERROR_UNKNOWN);
return;
}
if (!mSendMgmtFrameInProgress.compareAndSet(false, true)) {
Log.e(TAG, "An existing management frame transmission is in progress!");
- callback.onFailure(WifiNative.SEND_MGMT_FRAME_ERROR_ALREADY_STARTED);
+ callback.onFailure(SEND_MGMT_FRAME_ERROR_ALREADY_STARTED);
return;
}
@@ -920,7 +1031,7 @@ public class WificondControl implements IBinder.DeathRecipient {
Log.e(TAG, "Exception while starting link probe: " + e);
// Call sendMgmtFrameEvent.OnFailure() instead of callback.onFailure() so that
// sendMgmtFrameEvent can clean up internal state, such as cancelling the timer.
- sendMgmtFrameEvent.OnFailure(WifiNative.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ sendMgmtFrameEvent.OnFailure(SEND_MGMT_FRAME_ERROR_UNKNOWN);
}
}
diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
index e5f2b332d..f6345ec12 100644
--- a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
+++ b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
@@ -1012,10 +1012,10 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
}
}
- boolean validateScanType(int type) {
- return type == WifiScanner.SCAN_TYPE_LOW_LATENCY
+ boolean validateScanType(@WifiScanner.ScanType int type) {
+ return (type == WifiScanner.SCAN_TYPE_LOW_LATENCY
|| type == WifiScanner.SCAN_TYPE_LOW_POWER
- || type == WifiScanner.SCAN_TYPE_HIGH_ACCURACY;
+ || type == WifiScanner.SCAN_TYPE_HIGH_ACCURACY);
}
boolean validateScanRequest(ClientInfo ci, int handler, ScanSettings settings) {
@@ -1050,30 +1050,15 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
return true;
}
- int getNativeScanType(int type) {
- switch(type) {
- case WifiScanner.SCAN_TYPE_LOW_LATENCY:
- return WifiNative.SCAN_TYPE_LOW_LATENCY;
- case WifiScanner.SCAN_TYPE_LOW_POWER:
- return WifiNative.SCAN_TYPE_LOW_POWER;
- case WifiScanner.SCAN_TYPE_HIGH_ACCURACY:
- return WifiNative.SCAN_TYPE_HIGH_ACCURACY;
- default:
- // This should never happen becuase we've validated the incoming type in
- // |validateScanType|.
- throw new IllegalArgumentException("Invalid scan type " + type);
- }
- }
-
// We can coalesce a LOW_POWER/LOW_LATENCY scan request into an ongoing HIGH_ACCURACY
// scan request. But, we can't coalesce a HIGH_ACCURACY scan request into an ongoing
// LOW_POWER/LOW_LATENCY scan request.
boolean activeScanTypeSatisfies(int requestScanType) {
switch(mActiveScanSettings.scanType) {
- case WifiNative.SCAN_TYPE_LOW_LATENCY:
- case WifiNative.SCAN_TYPE_LOW_POWER:
- return requestScanType != WifiNative.SCAN_TYPE_HIGH_ACCURACY;
- case WifiNative.SCAN_TYPE_HIGH_ACCURACY:
+ case WifiScanner.SCAN_TYPE_LOW_LATENCY:
+ case WifiScanner.SCAN_TYPE_LOW_POWER:
+ return requestScanType != WifiScanner.SCAN_TYPE_HIGH_ACCURACY;
+ case WifiScanner.SCAN_TYPE_HIGH_ACCURACY:
return true;
default:
// This should never happen becuase we've validated the incoming type in
@@ -1087,10 +1072,10 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
// scan type should be HIGH_ACCURACY.
int mergeScanTypes(int existingScanType, int newScanType) {
switch(existingScanType) {
- case WifiNative.SCAN_TYPE_LOW_LATENCY:
- case WifiNative.SCAN_TYPE_LOW_POWER:
+ case WifiScanner.SCAN_TYPE_LOW_LATENCY:
+ case WifiScanner.SCAN_TYPE_LOW_POWER:
return newScanType;
- case WifiNative.SCAN_TYPE_HIGH_ACCURACY:
+ case WifiScanner.SCAN_TYPE_HIGH_ACCURACY:
return existingScanType;
default:
// This should never happen becuase we've validated the incoming type in
@@ -1104,7 +1089,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
return false;
}
- if (!activeScanTypeSatisfies(getNativeScanType(settings.type))) {
+ if (!activeScanTypeSatisfies(settings.type)) {
return false;
}
@@ -1177,8 +1162,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
ChannelCollection channels = mChannelHelper.createChannelCollection();
List<WifiNative.HiddenNetwork> hiddenNetworkList = new ArrayList<>();
for (RequestInfo<ScanSettings> entry : mPendingScans) {
- settings.scanType =
- mergeScanTypes(settings.scanType, getNativeScanType(entry.settings.type));
+ settings.scanType = mergeScanTypes(settings.scanType, entry.settings.type);
channels.addChannels(entry.settings);
for (ScanSettings.HiddenNetwork srcNetwork : entry.settings.hiddenNetworks) {
WifiNative.HiddenNetwork hiddenNetwork = new WifiNative.HiddenNetwork();
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 726582d66..c753166ac 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -2562,7 +2562,7 @@ public class ClientModeImplTest extends WifiBaseTest {
WifiLinkLayerStats llStats = new WifiLinkLayerStats();
llStats.txmpdu_be = 1000;
llStats.rxmpdu_bk = 2000;
- WifiNative.SignalPollResult signalPollResult = new WifiNative.SignalPollResult();
+ WificondControl.SignalPollResult signalPollResult = new WificondControl.SignalPollResult();
signalPollResult.currentRssi = -42;
signalPollResult.txBitrate = 65;
signalPollResult.associationFrequency = sFreq;
diff --git a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java
index 49c6123a1..6fdffa26f 100644
--- a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java
@@ -64,7 +64,7 @@ public class HostapdHalTest extends WifiBaseTest {
private @Mock IServiceManager mServiceManagerMock;
private @Mock IHostapd mIHostapdMock;
private @Mock WifiNative.HostapdDeathEventHandler mHostapdHalDeathHandler;
- private @Mock WifiNative.SoftApListener mSoftApListener;
+ private @Mock WificondControl.SoftApListener mSoftApListener;
private android.hardware.wifi.hostapd.V1_1.IHostapd mIHostapdMockV1_1;
private IHostapdCallback mIHostapdCallback;
private MockResources mResources;
@@ -229,7 +229,8 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setBand(SoftApConfiguration.BAND_2GHZ);
assertTrue(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMock).addAccessPoint(any(), any());
assertEquals(IFACE_NAME, mIfaceParamsCaptor.getValue().ifaceName);
@@ -262,7 +263,8 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setBand(SoftApConfiguration.BAND_5GHZ);
assertTrue(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMock).addAccessPoint(any(), any());
assertEquals(IFACE_NAME, mIfaceParamsCaptor.getValue().ifaceName);
@@ -296,7 +298,8 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setBand(SoftApConfiguration.BAND_5GHZ);
assertTrue(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMock).addAccessPoint(any(), any());
assertEquals(IFACE_NAME, mIfaceParamsCaptor.getValue().ifaceName);
@@ -334,7 +337,8 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setBand(SoftApConfiguration.BAND_2GHZ);
assertTrue(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMock).addAccessPoint(any(), any());
assertEquals(IFACE_NAME, mIfaceParamsCaptor.getValue().ifaceName);
@@ -372,7 +376,8 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setBand(SoftApConfiguration.BAND_2GHZ);
assertTrue(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMock).addAccessPoint(any(), any());
assertEquals(IFACE_NAME, mIfaceParamsCaptor.getValue().ifaceName);
@@ -409,7 +414,8 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setBand(SoftApConfiguration.BAND_ANY);
assertTrue(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMock).addAccessPoint(any(), any());
assertEquals(IFACE_NAME, mIfaceParamsCaptor.getValue().ifaceName);
@@ -447,7 +453,8 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setBand(SoftApConfiguration.BAND_ANY);
assertTrue(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMock).addAccessPoint(any(), any());
assertEquals(IFACE_NAME, mIfaceParamsCaptor.getValue().ifaceName);
@@ -511,9 +518,9 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setWpa2Passphrase(NETWORK_PSK);
configurationBuilder.setBand(SoftApConfiguration.BAND_ANY);
-
assertTrue(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMockV1_1).addAccessPoint_1_1(any(), any());
assertEquals(IFACE_NAME, mIfaceParamsCaptorV1_1.getValue().V1_0.ifaceName);
@@ -548,7 +555,8 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setBand(SoftApConfiguration.BAND_2GHZ);
assertFalse(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMock).addAccessPoint(any(), any());
}
@@ -566,7 +574,8 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setChannel(6);
assertFalse(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMock).addAccessPoint(any(), any());
}
@@ -623,7 +632,8 @@ public class HostapdHalTest extends WifiBaseTest {
configurationBuilder.setBand(SoftApConfiguration.BAND_2GHZ);
assertTrue(mHostapdHal.addAccessPoint(IFACE_NAME,
- configurationBuilder.build(), mSoftApListener));
+ configurationBuilder.build(),
+ () -> mSoftApListener.onFailure()));
verify(mIHostapdMockV1_1).addAccessPoint_1_1(any(), any());
// Trigger on failure.
diff --git a/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java b/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java
index 74396a02e..0d46220bb 100644
--- a/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/LinkProbeManagerTest.java
@@ -134,8 +134,8 @@ public class LinkProbeManagerTest extends WifiBaseTest {
mTimeMs += timeDelta;
when(mClock.getElapsedSinceBootMillis()).thenReturn(mTimeMs);
mLinkProbeManager.updateConnectionStats(mWifiInfo, TEST_IFACE_NAME);
- ArgumentCaptor<WifiNative.SendMgmtFrameCallback> callbackCaptor =
- ArgumentCaptor.forClass(WifiNative.SendMgmtFrameCallback.class);
+ ArgumentCaptor<WificondControl.SendMgmtFrameCallback> callbackCaptor =
+ ArgumentCaptor.forClass(WificondControl.SendMgmtFrameCallback.class);
verify(mWifiNative).probeLink(eq(TEST_IFACE_NAME), any(), callbackCaptor.capture(),
anyInt());
ArgumentCaptor<String> experimentIdCaptor = ArgumentCaptor.forClass(String.class);
@@ -177,14 +177,14 @@ public class LinkProbeManagerTest extends WifiBaseTest {
mTimeMs += timeDelta;
when(mClock.getElapsedSinceBootMillis()).thenReturn(mTimeMs);
mLinkProbeManager.updateConnectionStats(mWifiInfo, TEST_IFACE_NAME);
- ArgumentCaptor<WifiNative.SendMgmtFrameCallback> callbackCaptor =
- ArgumentCaptor.forClass(WifiNative.SendMgmtFrameCallback.class);
+ ArgumentCaptor<WificondControl.SendMgmtFrameCallback> callbackCaptor =
+ ArgumentCaptor.forClass(WificondControl.SendMgmtFrameCallback.class);
verify(mWifiNative).probeLink(eq(TEST_IFACE_NAME), any(), callbackCaptor.capture(),
anyInt());
- callbackCaptor.getValue().onFailure(WifiNative.SEND_MGMT_FRAME_ERROR_NO_ACK);
+ callbackCaptor.getValue().onFailure(WificondControl.SEND_MGMT_FRAME_ERROR_NO_ACK);
verify(mWifiMetrics).logLinkProbeFailure(timeDelta, rssi, linkSpeed,
- WifiNative.SEND_MGMT_FRAME_ERROR_NO_ACK);
+ WificondControl.SEND_MGMT_FRAME_ERROR_NO_ACK);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java b/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java
index 6f7dfbb0b..5a49da5e3 100644
--- a/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java
+++ b/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java
@@ -98,7 +98,7 @@ public class ScanTestUtil {
public static class NativeScanSettingsBuilder {
private final WifiNative.ScanSettings mSettings = new WifiNative.ScanSettings();
public NativeScanSettingsBuilder() {
- mSettings.scanType = WifiNative.SCAN_TYPE_LOW_LATENCY;
+ mSettings.scanType = WifiScanner.SCAN_TYPE_LOW_LATENCY;
mSettings.buckets = new WifiNative.BucketSettings[0];
mSettings.num_buckets = 0;
mSettings.report_threshold_percent = 100;
@@ -183,20 +183,6 @@ public class ScanTestUtil {
}
- private static int getNativeScanType(int type) {
- switch(type) {
- case WifiScanner.SCAN_TYPE_LOW_LATENCY:
- return WifiNative.SCAN_TYPE_LOW_LATENCY;
- case WifiScanner.SCAN_TYPE_LOW_POWER:
- return WifiNative.SCAN_TYPE_LOW_POWER;
- case WifiScanner.SCAN_TYPE_HIGH_ACCURACY:
- return WifiNative.SCAN_TYPE_HIGH_ACCURACY;
- default:
- fail();
- return -1;
- }
- }
-
/**
* Compute the expected native scan settings that are expected for the given
* WifiScanner.ScanSettings.
@@ -209,7 +195,7 @@ public class ScanTestUtil {
.withMaxApPerScan(0)
.withMaxPercentToCache(0)
.withMaxScansToCache(0)
- .withType(getNativeScanType(requestSettings.type));
+ .withType(requestSettings.type);
if (requestSettings.band == WifiScanner.WIFI_BAND_UNSPECIFIED) {
builder.addBucketWithChannels(0, reportEvents, requestSettings.channels);
} else {
@@ -225,7 +211,7 @@ public class ScanTestUtil {
public static WifiNative.ScanSettings createSingleScanNativeSettingsForChannels(
int reportEvents, WifiScanner.ChannelSpec... channels) {
return createSingleScanNativeSettingsForChannels(
- WifiNative.SCAN_TYPE_LOW_LATENCY, reportEvents, channels);
+ WifiScanner.SCAN_TYPE_LOW_LATENCY, reportEvents, channels);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index 4ee6c79a4..ec136ed3b 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -3411,13 +3411,13 @@ public class WifiMetricsTest extends WifiBaseTest {
public void testLogLinkProbeMetrics() throws Exception {
mWifiMetrics.logLinkProbeSuccess(10000, -75, 50, 5);
mWifiMetrics.logLinkProbeFailure(30000, -80, 10,
- WifiNative.SEND_MGMT_FRAME_ERROR_NO_ACK);
+ WificondControl.SEND_MGMT_FRAME_ERROR_NO_ACK);
mWifiMetrics.logLinkProbeSuccess(3000, -71, 160, 12);
mWifiMetrics.logLinkProbeFailure(40000, -80, 6,
- WifiNative.SEND_MGMT_FRAME_ERROR_NO_ACK);
+ WificondControl.SEND_MGMT_FRAME_ERROR_NO_ACK);
mWifiMetrics.logLinkProbeSuccess(5000, -73, 160, 10);
mWifiMetrics.logLinkProbeFailure(2000, -78, 6,
- WifiNative.SEND_MGMT_FRAME_ERROR_TIMEOUT);
+ WificondControl.SEND_MGMT_FRAME_ERROR_TIMEOUT);
dumpProtoAndDeserialize();
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
index 1660c23cb..c13a5fc90 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java
@@ -26,12 +26,13 @@ import static org.mockito.Mockito.*;
import android.net.MacAddress;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiScanner;
import android.os.Handler;
import android.os.INetworkManagementService;
import androidx.test.filters.SmallTest;
-import com.android.server.wifi.WifiNative.SendMgmtFrameCallback;
+import com.android.server.wifi.WificondControl.SendMgmtFrameCallback;
import org.junit.Before;
import org.junit.Test;
@@ -113,15 +114,15 @@ public class WifiNativeTest extends WifiBaseTest {
new FateMapping(WifiLoggerHal.RX_PKT_FATE_DRV_DROP_OTHER, "driver dropped (other)"),
new FateMapping((byte) 42, "42")
};
- private static final WifiNative.SignalPollResult SIGNAL_POLL_RESULT =
- new WifiNative.SignalPollResult() {{
+ private static final WificondControl.SignalPollResult SIGNAL_POLL_RESULT =
+ new WificondControl.SignalPollResult() {{
currentRssi = -60;
txBitrate = 12;
associationFrequency = 5240;
rxBitrate = 6;
}};
- private static final WifiNative.TxPacketCounters PACKET_COUNTERS_RESULT =
- new WifiNative.TxPacketCounters() {{
+ private static final WificondControl.TxPacketCounters PACKET_COUNTERS_RESULT =
+ new WificondControl.TxPacketCounters() {{
txSucceeded = 2000;
txFailed = 120;
}};
@@ -517,7 +518,7 @@ public class WifiNativeTest extends WifiBaseTest {
when(mWificondControl.signalPoll(WIFI_IFACE_NAME))
.thenReturn(SIGNAL_POLL_RESULT);
- WifiNative.SignalPollResult pollResult = mWifiNative.signalPoll(WIFI_IFACE_NAME);
+ WificondControl.SignalPollResult pollResult = mWifiNative.signalPoll(WIFI_IFACE_NAME);
assertEquals(SIGNAL_POLL_RESULT.currentRssi, pollResult.currentRssi);
assertEquals(SIGNAL_POLL_RESULT.txBitrate, pollResult.txBitrate);
assertEquals(SIGNAL_POLL_RESULT.associationFrequency, pollResult.associationFrequency);
@@ -543,10 +544,10 @@ public class WifiNativeTest extends WifiBaseTest {
*/
@Test
public void testScan() throws Exception {
- mWifiNative.scan(WIFI_IFACE_NAME, WifiNative.SCAN_TYPE_HIGH_ACCURACY, SCAN_FREQ_SET,
+ mWifiNative.scan(WIFI_IFACE_NAME, WifiScanner.SCAN_TYPE_HIGH_ACCURACY, SCAN_FREQ_SET,
SCAN_HIDDEN_NETWORK_SSID_SET);
verify(mWificondControl).scan(
- WIFI_IFACE_NAME, WifiNative.SCAN_TYPE_HIGH_ACCURACY,
+ WIFI_IFACE_NAME, WifiScanner.SCAN_TYPE_HIGH_ACCURACY,
SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_SET);
}
@@ -739,7 +740,7 @@ public class WifiNativeTest extends WifiBaseTest {
mWifiNative.probeLink(WIFI_IFACE_NAME, MacAddress.fromString(TEST_BSSID_STR),
mSendMgmtFrameCallback, TEST_MCS_RATE);
- verify(mSendMgmtFrameCallback).onFailure(WifiNative.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ verify(mSendMgmtFrameCallback).onFailure(WificondControl.SEND_MGMT_FRAME_ERROR_UNKNOWN);
verify(mWificondControl, never()).sendMgmtFrame(any(), any(), any(), anyInt());
}
@@ -752,7 +753,7 @@ public class WifiNativeTest extends WifiBaseTest {
mWifiNative.probeLink(WIFI_IFACE_NAME, null, mSendMgmtFrameCallback, TEST_MCS_RATE);
- verify(mSendMgmtFrameCallback).onFailure(WifiNative.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ verify(mSendMgmtFrameCallback).onFailure(WificondControl.SEND_MGMT_FRAME_ERROR_UNKNOWN);
verify(mWificondControl, never()).sendMgmtFrame(any(), any(), any(), anyInt());
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java
index aa988af11..5a0d91488 100644
--- a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java
@@ -58,7 +58,7 @@ import android.os.test.TestLooper;
import androidx.test.filters.SmallTest;
-import com.android.server.wifi.WifiNative.SendMgmtFrameCallback;
+import com.android.server.wifi.WificondControl.SendMgmtFrameCallback;
import com.android.server.wifi.util.NativeUtil;
import com.android.server.wifi.wificond.ChannelSettings;
import com.android.server.wifi.wificond.HiddenNetwork;
@@ -99,7 +99,7 @@ public class WificondControlTest extends WifiBaseTest {
@Mock private IWifiScannerImpl mWifiScannerImpl;
@Mock private CarrierNetworkConfig mCarrierNetworkConfig;
@Mock private IApInterface mApInterface;
- @Mock private WifiNative.SoftApListener mSoftApListener;
+ @Mock private WificondControl.SoftApListener mSoftApListener;
@Mock private AlarmManager mAlarmManager;
@Mock private Clock mClock;
@Mock private SendMgmtFrameCallback mSendMgmtFrameCallback;
@@ -341,7 +341,7 @@ public class WificondControlTest extends WifiBaseTest {
verify(mClientInterface, never()).signalPoll();
assertFalse(mWificondControl.scan(
- TEST_INTERFACE_NAME, WifiNative.SCAN_TYPE_LOW_LATENCY,
+ TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_LATENCY,
SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST));
verify(mWifiScannerImpl, never()).scan(any());
}
@@ -727,7 +727,7 @@ public class WificondControlTest extends WifiBaseTest {
public void testScan() throws Exception {
when(mWifiScannerImpl.scan(any(SingleScanSettings.class))).thenReturn(true);
assertTrue(mWificondControl.scan(
- TEST_INTERFACE_NAME, WifiNative.SCAN_TYPE_LOW_POWER,
+ TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_POWER,
SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST));
verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
IWifiScannerImpl.SCAN_TYPE_LOW_POWER,
@@ -747,7 +747,7 @@ public class WificondControlTest extends WifiBaseTest {
hiddenSsidWithDup.get(hiddenSsidWithDup.size() - 1));
// Pass the List with duplicate elements into scan()
assertTrue(mWificondControl.scan(
- TEST_INTERFACE_NAME, WifiNative.SCAN_TYPE_LOW_POWER,
+ TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_POWER,
SCAN_FREQ_SET, hiddenSsidWithDup));
// But the argument passed down should have the duplicate removed.
verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
@@ -762,7 +762,7 @@ public class WificondControlTest extends WifiBaseTest {
public void testScanNullParameters() throws Exception {
when(mWifiScannerImpl.scan(any(SingleScanSettings.class))).thenReturn(true);
assertTrue(mWificondControl.scan(
- TEST_INTERFACE_NAME, WifiNative.SCAN_TYPE_HIGH_ACCURACY, null, null));
+ TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_HIGH_ACCURACY, null, null));
verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY, null, null)));
}
@@ -774,7 +774,7 @@ public class WificondControlTest extends WifiBaseTest {
public void testScanFailure() throws Exception {
when(mWifiScannerImpl.scan(any(SingleScanSettings.class))).thenReturn(false);
assertFalse(mWificondControl.scan(
- TEST_INTERFACE_NAME, WifiNative.SCAN_TYPE_LOW_LATENCY,
+ TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_LATENCY,
SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST));
verify(mWifiScannerImpl).scan(any(SingleScanSettings.class));
}
@@ -1018,7 +1018,7 @@ public class WificondControlTest extends WifiBaseTest {
any(), eq(TEST_MCS_RATE));
mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME, cb2, TEST_MCS_RATE);
- verify(cb2).onFailure(WifiNative.SEND_MGMT_FRAME_ERROR_ALREADY_STARTED);
+ verify(cb2).onFailure(WificondControl.SEND_MGMT_FRAME_ERROR_ALREADY_STARTED);
// verify SendMgmtFrame() still was only called once i.e. not called again
verify(mClientInterface, times(1))
.SendMgmtFrame(any(), any(), anyInt());
@@ -1050,7 +1050,8 @@ public class WificondControlTest extends WifiBaseTest {
verify(cb).onFailure(anyInt());
verify(mAlarmManager).cancel(eq(alarmListenerCaptor.getValue()));
- sendMgmtFrameEventCaptor.getValue().OnFailure(WifiNative.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ sendMgmtFrameEventCaptor.getValue().OnFailure(
+ WificondControl.SEND_MGMT_FRAME_ERROR_UNKNOWN);
mLooper.dispatchAll();
handlerCaptor.getValue().post(() -> alarmListenerCaptor.getValue().onAlarm());
@@ -1109,10 +1110,11 @@ public class WificondControlTest extends WifiBaseTest {
alarmListenerCaptor.capture(), handlerCaptor.capture());
mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME, cb, TEST_MCS_RATE);
- sendMgmtFrameEventCaptor.getValue().OnFailure(WifiNative.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ sendMgmtFrameEventCaptor.getValue().OnFailure(
+ WificondControl.SEND_MGMT_FRAME_ERROR_UNKNOWN);
mLooper.dispatchAll();
verify(cb, never()).onAck(anyInt());
- verify(cb).onFailure(eq(WifiNative.SEND_MGMT_FRAME_ERROR_UNKNOWN));
+ verify(cb).onFailure(WificondControl.SEND_MGMT_FRAME_ERROR_UNKNOWN);
verify(mAlarmManager).cancel(eq(alarmListenerCaptor.getValue()));
// verify that even if timeout is triggered afterwards, SendMgmtFrameCallback is not
@@ -1144,7 +1146,7 @@ public class WificondControlTest extends WifiBaseTest {
handlerCaptor.getValue().post(() -> alarmListenerCaptor.getValue().onAlarm());
mLooper.dispatchAll();
verify(cb, never()).onAck(anyInt());
- verify(cb).onFailure(eq(WifiNative.SEND_MGMT_FRAME_ERROR_TIMEOUT));
+ verify(cb).onFailure(WificondControl.SEND_MGMT_FRAME_ERROR_TIMEOUT);
// verify that even if onAck() callback is triggered after timeout,
// SendMgmtFrameCallback is not triggered again
@@ -1215,7 +1217,7 @@ public class WificondControlTest extends WifiBaseTest {
sendMgmtFrameEventCaptor.getValue().OnAck(TEST_SEND_MGMT_FRAME_ELAPSED_TIME_MS);
mLooper.dispatchAll();
verify(mSendMgmtFrameCallback, never()).onAck(anyInt());
- verify(mSendMgmtFrameCallback).onFailure(eq(WifiNative.SEND_MGMT_FRAME_ERROR_TIMEOUT));
+ verify(mSendMgmtFrameCallback).onFailure(WificondControl.SEND_MGMT_FRAME_ERROR_TIMEOUT);
}
/**
@@ -1240,9 +1242,10 @@ public class WificondControlTest extends WifiBaseTest {
// triggering onAlarm() ourselves during the test, manually post onto handler
handlerCaptor.getValue().post(() -> alarmListenerCaptor.getValue().onAlarm());
// OnFailure posts to the handler
- sendMgmtFrameEventCaptor.getValue().OnFailure(WifiNative.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ sendMgmtFrameEventCaptor.getValue().OnFailure(
+ WificondControl.SEND_MGMT_FRAME_ERROR_UNKNOWN);
mLooper.dispatchAll();
- verify(mSendMgmtFrameCallback).onFailure(eq(WifiNative.SEND_MGMT_FRAME_ERROR_TIMEOUT));
+ verify(mSendMgmtFrameCallback).onFailure(WificondControl.SEND_MGMT_FRAME_ERROR_TIMEOUT);
}
private void assertRadioChainInfosEqual(
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java
index 9b24b14a4..10f475c96 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java
@@ -142,7 +142,7 @@ public abstract class BaseWifiScannerImplTest extends WifiBaseTest {
@Test
public void singleScanSuccessWithChannelsAndHighAccuracyType() {
WifiNative.ScanSettings settings = new NativeScanSettingsBuilder()
- .withType(WifiNative.SCAN_TYPE_HIGH_ACCURACY)
+ .withType(WifiScanner.SCAN_TYPE_HIGH_ACCURACY)
.withBasePeriod(10000)
.withMaxApPerScan(10)
.addBucketWithChannels(20000, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN, 5650)
@@ -368,7 +368,7 @@ public abstract class BaseWifiScannerImplTest extends WifiBaseTest {
WifiScanner.WIFI_BAND_24_GHZ)
.build();
WifiNative.ScanSettings settings2 = new NativeScanSettingsBuilder()
- .withType(WifiNative.SCAN_TYPE_LOW_POWER)
+ .withType(WifiScanner.SCAN_TYPE_LOW_POWER)
.withBasePeriod(10000)
.withMaxApPerScan(10)
.addBucketWithBand(10000, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN,
@@ -384,7 +384,7 @@ public abstract class BaseWifiScannerImplTest extends WifiBaseTest {
// start first scan
assertTrue(mScanner.startSingleScan(settings, eventHandler));
- expectSuccessfulSingleScan(order, WifiNative.SCAN_TYPE_LOW_LATENCY, eventHandler,
+ expectSuccessfulSingleScan(order, WifiScanner.SCAN_TYPE_LOW_LATENCY, eventHandler,
expectedBandScanFreqs(WifiScanner.WIFI_BAND_24_GHZ),
new ArrayList<String>(),
ScanResults.create(0, WifiScanner.WIFI_BAND_24_GHZ,
@@ -393,7 +393,7 @@ public abstract class BaseWifiScannerImplTest extends WifiBaseTest {
// start second scan
assertTrue(mScanner.startSingleScan(settings2, eventHandler));
- expectSuccessfulSingleScan(order, WifiNative.SCAN_TYPE_LOW_POWER, eventHandler,
+ expectSuccessfulSingleScan(order, WifiScanner.SCAN_TYPE_LOW_POWER, eventHandler,
expectedBandScanFreqs(WifiScanner.WIFI_BAND_BOTH_WITH_DFS),
new ArrayList<String>(),
ScanResults.create(0, WifiScanner.WIFI_BAND_BOTH_WITH_DFS,
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
index 2aa364168..89b1e8bac 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
@@ -1423,7 +1423,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 5150, 5150, 5150, 5150);
WifiNative.ScanSettings nativeSettings2and3 = createSingleScanNativeSettingsForChannels(
- WifiNative.SCAN_TYPE_HIGH_ACCURACY, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN,
+ WifiScanner.SCAN_TYPE_HIGH_ACCURACY, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN,
channelsToSpec(2450, 5175, 5150));
ScanResults results2and3 =
ScanResults.merge(WifiScanner.WIFI_BAND_UNSPECIFIED, results2, results3);