summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xapi/system-current.txt8
-rw-r--r--api/system-lint-baseline.txt4
-rw-r--r--wifi/java/android/net/wifi/wificond/NativeScanResult.java27
-rw-r--r--wifi/java/android/net/wifi/wificond/PnoSettings.java15
-rw-r--r--wifi/java/android/net/wifi/wificond/WifiCondManager.java103
-rw-r--r--wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java3
-rw-r--r--wifi/tests/src/android/net/wifi/wificond/WifiCondManagerTest.java5
7 files changed, 97 insertions, 68 deletions
diff --git a/api/system-current.txt b/api/system-current.txt
index 0d73b9e84d2c..cb6b216aff31 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -8198,7 +8198,7 @@ package android.net.wifi.wificond {
ctor public NativeScanResult();
method public int describeContents();
method @NonNull public byte[] getBssid();
- method @NonNull public java.util.BitSet getCapabilities();
+ method @NonNull public int getCapabilities();
method public int getFrequencyMhz();
method @NonNull public byte[] getInformationElements();
method @NonNull public java.util.List<android.net.wifi.wificond.RadioChainInfo> getRadioChainInfos();
@@ -8234,12 +8234,12 @@ package android.net.wifi.wificond {
public final class PnoSettings implements android.os.Parcelable {
ctor public PnoSettings();
method public int describeContents();
- method public int getIntervalMillis();
+ method public long getIntervalMillis();
method public int getMin2gRssiDbm();
method public int getMin5gRssiDbm();
method public int getMin6gRssiDbm();
method @NonNull public java.util.List<android.net.wifi.wificond.PnoNetwork> getPnoNetworks();
- method public void setIntervalMillis(int);
+ method public void setIntervalMillis(long);
method public void setMin2gRssiDbm(int);
method public void setMin5gRssiDbm(int);
method public void setMin6gRssiDbm(int);
@@ -8264,10 +8264,10 @@ package android.net.wifi.wificond {
method @Nullable public android.net.wifi.wificond.DeviceWiphyCapabilities getDeviceWiphyCapabilities(@NonNull String);
method @NonNull public java.util.List<android.net.wifi.wificond.NativeScanResult> getScanResults(@NonNull String, int);
method @Nullable public android.net.wifi.wificond.WifiCondManager.TxPacketCounters getTxPacketCounters(@NonNull String);
- method public boolean initialize(@NonNull Runnable);
method @Nullable public static android.net.wifi.wificond.WifiCondManager.OemSecurityType parseOemSecurityTypeElement(int, int, @NonNull byte[]);
method public boolean registerApCallback(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.wificond.WifiCondManager.SoftApCallback);
method public void sendMgmtFrame(@NonNull String, @NonNull byte[], int, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.wificond.WifiCondManager.SendMgmtFrameCallback);
+ method public void setOnServiceDeadCallback(@NonNull Runnable);
method public boolean setupInterfaceForClientMode(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.wificond.WifiCondManager.ScanEventCallback, @NonNull android.net.wifi.wificond.WifiCondManager.ScanEventCallback);
method public boolean setupInterfaceForSoftApMode(@NonNull String);
method @Nullable public android.net.wifi.wificond.WifiCondManager.SignalPollResult signalPoll(@NonNull String);
diff --git a/api/system-lint-baseline.txt b/api/system-lint-baseline.txt
index a57e178879fa..0caee6bebbda 100644
--- a/api/system-lint-baseline.txt
+++ b/api/system-lint-baseline.txt
@@ -64,10 +64,6 @@ GenericException: android.service.autofill.augmented.FillWindow#finalize():
-HeavyBitSet: android.net.wifi.wificond.NativeScanResult#getCapabilities():
-
-
-
IntentBuilderName: android.content.Context#registerReceiverForAllUsers(android.content.BroadcastReceiver, android.content.IntentFilter, String, android.os.Handler):
Methods creating an Intent should be named `create<Foo>Intent()`, was `registerReceiverForAllUsers`
diff --git a/wifi/java/android/net/wifi/wificond/NativeScanResult.java b/wifi/java/android/net/wifi/wificond/NativeScanResult.java
index 85251e8b1d42..7cc617d61b00 100644
--- a/wifi/java/android/net/wifi/wificond/NativeScanResult.java
+++ b/wifi/java/android/net/wifi/wificond/NativeScanResult.java
@@ -24,7 +24,6 @@ import android.os.Parcelable;
import com.android.internal.annotations.VisibleForTesting;
import java.util.ArrayList;
-import java.util.BitSet;
import java.util.List;
/**
@@ -34,8 +33,6 @@ import java.util.List;
*/
@SystemApi
public final class NativeScanResult implements Parcelable {
- private static final int CAPABILITY_SIZE = 16;
-
/** @hide */
@VisibleForTesting
public byte[] ssid;
@@ -56,7 +53,7 @@ public final class NativeScanResult implements Parcelable {
public long tsf;
/** @hide */
@VisibleForTesting
- public BitSet capability;
+ public int capability;
/** @hide */
@VisibleForTesting
public boolean associated;
@@ -134,7 +131,7 @@ public final class NativeScanResult implements Parcelable {
* Returns the capabilities of the AP repseresented by this scan result as advertised in the
* received probe response or beacon.
*
- * This is a bit mask describing the capabilities of a BSS. See IEEE Std 802.11: 8.4.1.4:
+ * This is a bit mask describing the capabilities of a BSS. See IEEE Std 802.11: 9.4.1.4:
* Bit 0 - ESS
* Bit 1 - IBSS
* Bit 2 - CF Pollable
@@ -143,7 +140,7 @@ public final class NativeScanResult implements Parcelable {
* Bit 5 - Short Preamble
* Bit 6 - PBCC
* Bit 7 - Channel Agility
- * Bit 8 - Spectrum Mgmt
+ * Bit 8 - Spectrum Management
* Bit 9 - QoS
* Bit 10 - Short Slot Time
* Bit 11 - APSD
@@ -154,7 +151,7 @@ public final class NativeScanResult implements Parcelable {
*
* @return a bit mask of capabilities.
*/
- @NonNull public BitSet getCapabilities() {
+ @NonNull public int getCapabilities() {
return capability;
}
@@ -188,13 +185,7 @@ public final class NativeScanResult implements Parcelable {
out.writeInt(frequency);
out.writeInt(signalMbm);
out.writeLong(tsf);
- int capabilityInt = 0;
- for (int i = 0; i < CAPABILITY_SIZE; i++) {
- if (capability.get(i)) {
- capabilityInt |= 1 << i;
- }
- }
- out.writeInt(capabilityInt);
+ out.writeInt(capability);
out.writeInt(associated ? 1 : 0);
out.writeTypedList(radioChainInfos);
}
@@ -220,13 +211,7 @@ public final class NativeScanResult implements Parcelable {
result.frequency = in.readInt();
result.signalMbm = in.readInt();
result.tsf = in.readLong();
- int capabilityInt = in.readInt();
- result.capability = new BitSet(CAPABILITY_SIZE);
- for (int i = 0; i < CAPABILITY_SIZE; i++) {
- if ((capabilityInt & (1 << i)) != 0) {
- result.capability.set(i);
- }
- }
+ result.capability = in.readInt();
result.associated = (in.readInt() != 0);
result.radioChainInfos = new ArrayList<>();
in.readTypedList(result.radioChainInfos, RadioChainInfo.CREATOR);
diff --git a/wifi/java/android/net/wifi/wificond/PnoSettings.java b/wifi/java/android/net/wifi/wificond/PnoSettings.java
index 57c9ca5fd302..533d37d3a23a 100644
--- a/wifi/java/android/net/wifi/wificond/PnoSettings.java
+++ b/wifi/java/android/net/wifi/wificond/PnoSettings.java
@@ -16,6 +16,7 @@
package android.net.wifi.wificond;
+import android.annotation.DurationMillisLong;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
@@ -33,7 +34,7 @@ import java.util.Objects;
*/
@SystemApi
public final class PnoSettings implements Parcelable {
- private int mIntervalMs;
+ private long mIntervalMs;
private int mMin2gRssi;
private int mMin5gRssi;
private int mMin6gRssi;
@@ -47,17 +48,17 @@ public final class PnoSettings implements Parcelable {
*
* @return An interval in milliseconds.
*/
- public int getIntervalMillis() {
+ public @DurationMillisLong long getIntervalMillis() {
return mIntervalMs;
}
/**
* Set the requested PNO scan interval in milliseconds.
*
- * @param intervalMs An interval in milliseconds.
+ * @param intervalMillis An interval in milliseconds.
*/
- public void setIntervalMillis(int intervalMs) {
- this.mIntervalMs = intervalMs;
+ public void setIntervalMillis(@DurationMillisLong long intervalMillis) {
+ this.mIntervalMs = intervalMillis;
}
/**
@@ -176,7 +177,7 @@ public final class PnoSettings implements Parcelable {
**/
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
- out.writeInt(mIntervalMs);
+ out.writeLong(mIntervalMs);
out.writeInt(mMin2gRssi);
out.writeInt(mMin5gRssi);
out.writeInt(mMin6gRssi);
@@ -189,7 +190,7 @@ public final class PnoSettings implements Parcelable {
@Override
public PnoSettings createFromParcel(Parcel in) {
PnoSettings result = new PnoSettings();
- result.mIntervalMs = in.readInt();
+ result.mIntervalMs = in.readLong();
result.mMin2gRssi = in.readInt();
result.mMin5gRssi = in.readInt();
result.mMin6gRssi = in.readInt();
diff --git a/wifi/java/android/net/wifi/wificond/WifiCondManager.java b/wifi/java/android/net/wifi/wificond/WifiCondManager.java
index 43aa1b64efbc..7a31a5afab05 100644
--- a/wifi/java/android/net/wifi/wificond/WifiCondManager.java
+++ b/wifi/java/android/net/wifi/wificond/WifiCondManager.java
@@ -496,22 +496,17 @@ public class WifiCondManager {
}
/**
- * Initializes WifiCondManager & registers a death notification for the WifiCondManager which
- * acts as a proxy for the wificond daemon (i.e. the death listener will be called when and if
- * the wificond daemon dies).
- *
- * Note: This method clears any existing state in wificond daemon.
+ * Register a death notification for the WifiCondManager which acts as a proxy for the
+ * wificond daemon (i.e. the death listener will be called when and if the wificond daemon
+ * dies).
*
* @param deathEventHandler A {@link Runnable} to be called whenever the wificond daemon dies.
- * @return Returns true on success.
*/
- public boolean initialize(@NonNull Runnable deathEventHandler) {
+ public void setOnServiceDeadCallback(@NonNull Runnable deathEventHandler) {
if (mDeathEventHandler != null) {
Log.e(TAG, "Death handler already present");
}
mDeathEventHandler = deathEventHandler;
- tearDownInterfaces();
- return true;
}
/**
@@ -603,11 +598,12 @@ public class WifiCondManager {
}
/**
- * Tear down a specific client (STA) interface, initially configured using
+ * Tear down a specific client (STA) interface configured using
* {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}.
*
* @param ifaceName Name of the interface to tear down.
- * @return Returns true on success.
+ * @return Returns true on success, false on failure (e.g. when called before an interface was
+ * set up).
*/
public boolean tearDownClientInterface(@NonNull String ifaceName) {
if (getClientInterface(ifaceName) == null) {
@@ -681,11 +677,12 @@ public class WifiCondManager {
}
/**
- * Tear down a Soft AP interface initially configured using
+ * Tear down a Soft AP interface configured using
* {@link #setupInterfaceForSoftApMode(String)}.
*
* @param ifaceName Name of the interface to tear down.
- * @return Returns true on success.
+ * @return Returns true on success, false on failure (e.g. when called before an interface was
+ * set up).
*/
public boolean tearDownSoftApInterface(@NonNull String ifaceName) {
if (getApInterface(ifaceName) == null) {
@@ -750,9 +747,13 @@ public class WifiCondManager {
/**
* Request signal polling.
*
- * @param ifaceName Name of the interface on which to poll.
+ * @param ifaceName Name of the interface on which to poll. The interface must have been
+ * already set up using
+ *{@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @return A {@link SignalPollResult} object containing interface statistics, or a null on
- * error.
+ * error (e.g. the interface hasn't been set up yet).
*/
@Nullable public SignalPollResult signalPoll(@NonNull String ifaceName) {
IClientInterface iface = getClientInterface(ifaceName);
@@ -776,10 +777,14 @@ public class WifiCondManager {
}
/**
- * Get current transmit (Tx) packet counters of the specified interface.
+ * Get current transmit (Tx) packet counters of the specified interface. The interface must
+ * have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
*
* @param ifaceName Name of the interface.
- * @return {@link TxPacketCounters} of the current interface or null on error.
+ * @return {@link TxPacketCounters} of the current interface or null on error (e.g. when
+ * called before the interface has been set up).
*/
@Nullable public TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) {
IClientInterface iface = getClientInterface(ifaceName);
@@ -813,10 +818,15 @@ public class WifiCondManager {
* be done using {@link #startScan(String, int, Set, List)} or
* {@link #startPnoScan(String, PnoSettings, Executor, PnoScanRequestCallback)}.
*
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @param ifaceName Name of the interface.
* @param scanType The type of scan result to be returned, can be
* {@link #SCAN_TYPE_SINGLE_SCAN} or {@link #SCAN_TYPE_PNO_SCAN}.
- * @return Returns an array of {@link NativeScanResult} or an empty array on failure.
+ * @return Returns an array of {@link NativeScanResult} or an empty array on failure (e.g. when
+ * called before the interface has been set up).
*/
@NonNull public List<NativeScanResult> getScanResults(@NonNull String ifaceName,
@ScanResultType int scanType) {
@@ -869,13 +879,19 @@ public class WifiCondManager {
* The latest scans can be obtained using {@link #getScanResults(String, int)} and using a
* {@link #SCAN_TYPE_SINGLE_SCAN} for the {@code scanType}.
*
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @param ifaceName Name of the interface on which to initiate the scan.
* @param scanType Type of scan to perform, can be any of
* {@link WifiScanner#SCAN_TYPE_HIGH_ACCURACY}, {@link WifiScanner#SCAN_TYPE_LOW_POWER}, or
* {@link WifiScanner#SCAN_TYPE_LOW_LATENCY}.
* @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.
+ * @param hiddenNetworkSSIDs List of hidden networks to be scanned for, a null indicates that
+ * no hidden frequencies will be scanned for.
+ * @return Returns true on success, false on failure (e.g. when called before the interface
+ * has been set up).
*/
public boolean startScan(@NonNull String ifaceName, @WifiAnnotations.ScanType int scanType,
@Nullable Set<Integer> freqs, @Nullable List<byte[]> hiddenNetworkSSIDs) {
@@ -931,11 +947,16 @@ public class WifiCondManager {
* The latest PNO scans can be obtained using {@link #getScanResults(String, int)} with the
* {@code scanType} set to {@link #SCAN_TYPE_PNO_SCAN}.
*
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @param ifaceName Name of the interface on which to request a PNO.
* @param pnoSettings PNO scan configuration.
* @param executor The Executor on which to execute the callback.
* @param callback Callback for the results of the offload request.
- * @return true on success.
+ * @return true on success, false on failure (e.g. when called before the interface has been set
+ * up).
*/
public boolean startPnoScan(@NonNull String ifaceName, @NonNull PnoSettings pnoSettings,
@NonNull @CallbackExecutor Executor executor,
@@ -969,8 +990,13 @@ public class WifiCondManager {
* Stop PNO scan configured with
* {@link #startPnoScan(String, PnoSettings, Executor, PnoScanRequestCallback)}.
*
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @param ifaceName Name of the interface on which the PNO scan was configured.
- * @return true on success.
+ * @return true on success, false on failure (e.g. when called before the interface has been
+ * set up).
*/
public boolean stopPnoScan(@NonNull String ifaceName) {
IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName);
@@ -987,7 +1013,13 @@ public class WifiCondManager {
}
/**
- * Abort ongoing single scan started with {@link #startScan(String, int, Set, List)}.
+ * Abort ongoing single scan started with {@link #startScan(String, int, Set, List)}. No failure
+ * callback, e.g. {@link ScanEventCallback#onScanFailed()}, is triggered by this operation.
+ *
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}. If the interface has not been set up then
+ * this method has no impact.
*
* @param ifaceName Name of the interface on which the scan was started.
*/
@@ -1055,7 +1087,14 @@ public class WifiCondManager {
}
/**
- * Get the device phy capabilities for a given interface
+ * Get the device phy capabilities for a given interface.
+ *
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
+ * @return DeviceWiphyCapabilities or null on error (e.g. when called on an interface which has
+ * not been set up).
*/
@Nullable public DeviceWiphyCapabilities getDeviceWiphyCapabilities(@NonNull String ifaceName) {
if (mWificond == null) {
@@ -1071,13 +1110,19 @@ public class WifiCondManager {
}
/**
- * Register the provided callback handler for SoftAp events. Note that the Soft AP itself is
- * configured using {@link #setupInterfaceForSoftApMode(String)}.
+ * Register the provided callback handler for SoftAp events. The interface must first be created
+ * using {@link #setupInterfaceForSoftApMode(String)}. The callback registration is valid until
+ * the interface is deleted using {@link #tearDownSoftApInterface(String)} (no deregistration
+ * method is provided).
+ * <p>
+ * Note that only one callback can be registered at a time - any registration overrides previous
+ * registrations.
*
* @param ifaceName Name of the interface on which to register the callback.
* @param executor The Executor on which to execute the callbacks.
* @param callback Callback for AP events.
- * @return true on success, false otherwise.
+ * @return true on success, false on failure (e.g. when called on an interface which has not
+ * been set up).
*/
public boolean registerApCallback(@NonNull String ifaceName,
@NonNull @CallbackExecutor Executor executor,
@@ -1113,6 +1158,10 @@ public class WifiCondManager {
* Send a management frame on the specified interface at the specified rate. Useful for probing
* the link with arbitrary frames.
*
+ * Note: The interface must have been already set up using
+ * {@link #setupInterfaceForClientMode(String, Executor, ScanEventCallback, ScanEventCallback)}
+ * or {@link #setupInterfaceForSoftApMode(String)}.
+ *
* @param ifaceName The interface on which to send the frame.
* @param frame The raw byte array of the management frame to tramit.
* @param mcs The MCS (modulation and coding scheme), i.e. rate, at which to transmit the
diff --git a/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java b/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java
index 06f12f7f37ea..0df170f8786c 100644
--- a/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java
+++ b/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java
@@ -28,7 +28,6 @@ import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.BitSet;
/**
* Unit tests for {@link android.net.wifi.wificond.NativeScanResult}.
@@ -46,7 +45,7 @@ public class NativeScanResultTest {
private static final int TEST_FREQUENCY = 2456;
private static final int TEST_SIGNAL_MBM = -45;
private static final long TEST_TSF = 34455441;
- private static final BitSet TEST_CAPABILITY = new BitSet(16) {{ set(2); set(5); }};
+ private static final int TEST_CAPABILITY = (0x1 << 2) | (0x1 << 5);
private static final boolean TEST_ASSOCIATED = true;
private static final int[] RADIO_CHAIN_IDS = { 0, 1 };
private static final int[] RADIO_CHAIN_LEVELS = { -56, -65 };
diff --git a/wifi/tests/src/android/net/wifi/wificond/WifiCondManagerTest.java b/wifi/tests/src/android/net/wifi/wificond/WifiCondManagerTest.java
index 5ba02a779663..32105be6ae4c 100644
--- a/wifi/tests/src/android/net/wifi/wificond/WifiCondManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/wificond/WifiCondManagerTest.java
@@ -720,8 +720,7 @@ public class WifiCondManagerTest {
@Test
public void testRegisterDeathHandler() throws Exception {
Runnable deathHandler = mock(Runnable.class);
- assertTrue(mWificondControl.initialize(deathHandler));
- verify(mWificond).tearDownInterfaces();
+ mWificondControl.setOnServiceDeadCallback(deathHandler);
mWificondControl.binderDied();
mLooper.dispatchAll();
verify(deathHandler).run();
@@ -734,7 +733,7 @@ public class WifiCondManagerTest {
@Test
public void testDeathHandling() throws Exception {
Runnable deathHandler = mock(Runnable.class);
- assertTrue(mWificondControl.initialize(deathHandler));
+ mWificondControl.setOnServiceDeadCallback(deathHandler);
testSetupInterfaceForClientMode();