Merge "Implement config flags."
diff --git a/cas/1.0/default/Android.bp b/cas/1.0/default/Android.bp
index 6da5cc4..544162b 100644
--- a/cas/1.0/default/Android.bp
+++ b/cas/1.0/default/Android.bp
@@ -12,12 +12,6 @@
"TypeConvert.cpp",
],
- product_variables: {
- treble: {
- cflags: ["-DUSE_VNDBINDER"],
- },
- },
-
compile_multilib: "32",
init_rc: ["android.hardware.cas@1.0-service.rc"],
diff --git a/cas/1.0/default/CasImpl.cpp b/cas/1.0/default/CasImpl.cpp
index 9d1f4a3..2ac1c4f 100644
--- a/cas/1.0/default/CasImpl.cpp
+++ b/cas/1.0/default/CasImpl.cpp
@@ -103,6 +103,7 @@
status_t err = INVALID_OPERATION;
if (holder != NULL) {
err = holder->get()->openSession(&sessionId);
+ holder.clear();
}
_hidl_cb(toStatus(err), sessionId);
diff --git a/cas/1.0/default/service.cpp b/cas/1.0/default/service.cpp
index 3f1df5a..04a8ad9 100644
--- a/cas/1.0/default/service.cpp
+++ b/cas/1.0/default/service.cpp
@@ -31,11 +31,9 @@
int main() {
ALOGD("android.hardware.cas@1.0-service starting...");
-#ifdef USE_VNDBINDER
// The CAS HAL may communicate to other vendor components via
// /dev/vndbinder
android::ProcessState::initWithDriver("/dev/vndbinder");
-#endif // USE_VNDBINDER
configureRpcThreadpool(8, true /* callerWillJoin */);
diff --git a/compatibility_matrix.27.xml b/compatibility_matrix.1.xml
similarity index 83%
copy from compatibility_matrix.27.xml
copy to compatibility_matrix.1.xml
index 80001f7..6ba87c0 100644
--- a/compatibility_matrix.27.xml
+++ b/compatibility_matrix.1.xml
@@ -1,4 +1,4 @@
-<compatibility-matrix version="1.0" type="framework">
+<compatibility-matrix version="1.0" type="framework" level="1">
<hal format="hidl" optional="false">
<name>android.hardware.audio</name>
<version>2.0</version>
@@ -57,7 +57,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.broadcastradio</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IBroadcastRadioFactory</name>
<instance>default</instance>
@@ -71,14 +71,6 @@
<instance>legacy/0</instance>
</interface>
</hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.cas</name>
- <version>1.0</version>
- <interface>
- <name>IMediaCasService</name>
- <instance>default</instance>
- </interface>
- </hal>
<hal format="hidl" optional="false">
<name>android.hardware.configstore</name>
<version>1.0</version>
@@ -164,14 +156,6 @@
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.health</name>
- <version>2.0</version>
- <interface>
- <name>IHealth</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.ir</name>
<version>1.0</version>
</hal>
@@ -220,16 +204,8 @@
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.oemlock</name>
- <version>1.0</version>
- <interface>
- <name>IOemLock</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.power</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IPower</name>
<instance>default</instance>
@@ -237,7 +213,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.radio</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IRadio</name>
<instance>slot1</instance>
@@ -280,24 +256,8 @@
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.tetheroffload.config</name>
- <version>1.0</version>
- <interface>
- <name>IOffloadConfig</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.tetheroffload.control</name>
- <version>1.0</version>
- <interface>
- <name>IOffloadControl</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.thermal</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IThermal</name>
<instance>default</instance>
@@ -321,7 +281,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.usb</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IUsb</name>
<instance>default</instance>
@@ -329,7 +289,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.vibrator</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IVibrator</name>
<instance>default</instance>
@@ -344,30 +304,14 @@
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.weaver</name>
- <version>1.0</version>
- <interface>
- <name>IWeaver</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.wifi</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IWifi</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.wifi.offload</name>
- <version>1.0</version>
- <interface>
- <name>IOffload</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.wifi.supplicant</name>
<version>1.0</version>
<interface>
diff --git a/compatibility_matrix.27.xml b/compatibility_matrix.2.xml
similarity index 97%
rename from compatibility_matrix.27.xml
rename to compatibility_matrix.2.xml
index 80001f7..ea8dde8 100644
--- a/compatibility_matrix.27.xml
+++ b/compatibility_matrix.2.xml
@@ -1,4 +1,4 @@
-<compatibility-matrix version="1.0" type="framework">
+<compatibility-matrix version="1.0" type="framework" level="2">
<hal format="hidl" optional="false">
<name>android.hardware.audio</name>
<version>2.0</version>
@@ -164,14 +164,6 @@
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.health</name>
- <version>2.0</version>
- <interface>
- <name>IHealth</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.ir</name>
<version>1.0</version>
</hal>
diff --git a/compatibility_matrix.26.xml b/compatibility_matrix.26.xml
deleted file mode 100644
index 940588f..0000000
--- a/compatibility_matrix.26.xml
+++ /dev/null
@@ -1,378 +0,0 @@
-<compatibility-matrix version="1.0" type="framework">
- <hal format="hidl" optional="false">
- <name>android.hardware.audio</name>
- <version>2.0</version>
- <interface>
- <name>IDevicesFactory</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="false">
- <name>android.hardware.audio.effect</name>
- <version>2.0</version>
- <interface>
- <name>IEffectsFactory</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.automotive.evs</name>
- <version>1.0</version>
- <interface>
- <name>IEvsEnumerator</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.automotive.vehicle</name>
- <version>2.0</version>
- <interface>
- <name>IVehicle</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.biometrics.fingerprint</name>
- <version>2.1</version>
- <interface>
- <name>IBiometricsFingerprint</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.bluetooth</name>
- <version>1.0</version>
- <interface>
- <name>IBluetoothHci</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.boot</name>
- <version>1.0</version>
- <interface>
- <name>IBootControl</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.broadcastradio</name>
- <version>1.0-1</version>
- <interface>
- <name>IBroadcastRadioFactory</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.camera.provider</name>
- <version>2.4</version>
- <interface>
- <name>ICameraProvider</name>
- <instance>legacy/0</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.cas</name>
- <version>1.0</version>
- <interface>
- <name>IMediaCasService</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="false">
- <name>android.hardware.configstore</name>
- <version>1.0-1</version>
- <interface>
- <name>ISurfaceFlingerConfigs</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.contexthub</name>
- <version>1.0</version>
- <interface>
- <name>IContexthub</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="false">
- <name>android.hardware.drm</name>
- <version>1.0</version>
- <interface>
- <name>ICryptoFactory</name>
- <instance>default</instance>
- </interface>
- <interface>
- <name>IDrmFactory</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.dumpstate</name>
- <version>1.0</version>
- <interface>
- <name>IDumpstateDevice</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="false">
- <name>android.hardware.gatekeeper</name>
- <version>1.0</version>
- <interface>
- <name>IGatekeeper</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.gnss</name>
- <version>1.0</version>
- <interface>
- <name>IGnss</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="false">
- <name>android.hardware.graphics.allocator</name>
- <version>2.0</version>
- <interface>
- <name>IAllocator</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="false">
- <name>android.hardware.graphics.composer</name>
- <version>2.1</version>
- <interface>
- <name>IComposer</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="false">
- <name>android.hardware.graphics.mapper</name>
- <version>2.0</version>
- <interface>
- <name>IMapper</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.health</name>
- <version>1.0</version>
- <interface>
- <name>IHealth</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.health</name>
- <version>2.0</version>
- <interface>
- <name>IHealth</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.ir</name>
- <version>1.0</version>
- </hal>
- <hal format="hidl" optional="false">
- <name>android.hardware.keymaster</name>
- <version>3.0</version>
- <interface>
- <name>IKeymasterDevice</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.light</name>
- <version>2.0</version>
- <interface>
- <name>ILight</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="false">
- <name>android.hardware.media.omx</name>
- <version>1.0</version>
- <interface>
- <name>IOmx</name>
- <instance>default</instance>
- </interface>
- <interface>
- <name>IOmxStore</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.memtrack</name>
- <version>1.0</version>
- <interface>
- <name>IMemtrack</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.nfc</name>
- <version>1.0</version>
- <interface>
- <name>INfc</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.oemlock</name>
- <version>1.0</version>
- <interface>
- <name>IOemLock</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.power</name>
- <version>1.0-1</version>
- <interface>
- <name>IPower</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.radio</name>
- <version>1.0-1</version>
- <interface>
- <name>IRadio</name>
- <instance>slot1</instance>
- </interface>
- <interface>
- <name>ISap</name>
- <instance>slot1</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.radio.deprecated</name>
- <version>1.0</version>
- <interface>
- <name>IOemHook</name>
- <instance>slot1</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.renderscript</name>
- <version>1.0</version>
- <interface>
- <name>IDevice</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.sensors</name>
- <version>1.0</version>
- <interface>
- <name>ISensors</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.soundtrigger</name>
- <version>2.0</version>
- <interface>
- <name>ISoundTriggerHw</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.tetheroffload.config</name>
- <version>1.0</version>
- <interface>
- <name>IOffloadConfig</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.tetheroffload.control</name>
- <version>1.0</version>
- <interface>
- <name>IOffloadControl</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.thermal</name>
- <version>1.0-1</version>
- <interface>
- <name>IThermal</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.tv.cec</name>
- <version>1.0</version>
- <interface>
- <name>IHdmiCec</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.tv.input</name>
- <version>1.0</version>
- <interface>
- <name>ITvInput</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.usb</name>
- <version>1.0-1</version>
- <interface>
- <name>IUsb</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.vibrator</name>
- <version>1.0-1</version>
- <interface>
- <name>IVibrator</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.vr</name>
- <version>1.0</version>
- <interface>
- <name>IVr</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.weaver</name>
- <version>1.0</version>
- <interface>
- <name>IWeaver</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.wifi</name>
- <version>1.0-1</version>
- <interface>
- <name>IWifi</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.wifi.offload</name>
- <version>1.0</version>
- <interface>
- <name>IOffload</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.wifi.supplicant</name>
- <version>1.0</version>
- <interface>
- <name>ISupplicant</name>
- <instance>default</instance>
- </interface>
- </hal>
-</compatibility-matrix>
diff --git a/compatibility_matrix.current.xml b/compatibility_matrix.current.xml
index 5a2563c..5b033e7 100644
--- a/compatibility_matrix.current.xml
+++ b/compatibility_matrix.current.xml
@@ -1,4 +1,4 @@
-<compatibility-matrix version="1.0" type="framework">
+<compatibility-matrix version="1.0" type="framework" level="3">
<hal format="hidl" optional="false">
<name>android.hardware.audio</name>
<version>2.0</version>
diff --git a/compatibility_matrix.legacy.xml b/compatibility_matrix.legacy.xml
index d562fd0..6792598 100644
--- a/compatibility_matrix.legacy.xml
+++ b/compatibility_matrix.legacy.xml
@@ -1,4 +1,4 @@
-<compatibility-matrix version="1.0" type="framework">
+<compatibility-matrix version="1.0" type="framework" level="legacy">
<hal format="hidl" optional="false">
<name>android.hardware.audio</name>
<version>2.0</version>
@@ -57,7 +57,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.broadcastradio</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IBroadcastRadioFactory</name>
<instance>default</instance>
@@ -71,17 +71,9 @@
<instance>legacy/0</instance>
</interface>
</hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.cas</name>
- <version>1.0</version>
- <interface>
- <name>IMediaCasService</name>
- <instance>default</instance>
- </interface>
- </hal>
<hal format="hidl" optional="false">
<name>android.hardware.configstore</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>ISurfaceFlingerConfigs</name>
<instance>default</instance>
@@ -164,14 +156,6 @@
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.health</name>
- <version>2.0</version>
- <interface>
- <name>IHealth</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.ir</name>
<version>1.0</version>
</hal>
@@ -220,16 +204,8 @@
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.oemlock</name>
- <version>1.0</version>
- <interface>
- <name>IOemLock</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.power</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IPower</name>
<instance>default</instance>
@@ -237,7 +213,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.radio</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IRadio</name>
<instance>slot1</instance>
@@ -280,24 +256,8 @@
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.tetheroffload.config</name>
- <version>1.0</version>
- <interface>
- <name>IOffloadConfig</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.tetheroffload.control</name>
- <version>1.0</version>
- <interface>
- <name>IOffloadControl</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.thermal</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IThermal</name>
<instance>default</instance>
@@ -321,7 +281,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.usb</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IUsb</name>
<instance>default</instance>
@@ -329,7 +289,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.vibrator</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IVibrator</name>
<instance>default</instance>
@@ -344,30 +304,14 @@
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.weaver</name>
- <version>1.0</version>
- <interface>
- <name>IWeaver</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.wifi</name>
- <version>1.0-1</version>
+ <version>1.0</version>
<interface>
<name>IWifi</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="true">
- <name>android.hardware.wifi.offload</name>
- <version>1.0</version>
- <interface>
- <name>IOffload</name>
- <instance>default</instance>
- </interface>
- </hal>
- <hal format="hidl" optional="true">
<name>android.hardware.wifi.supplicant</name>
<version>1.0</version>
<interface>
diff --git a/health/2.0/default/Android.bp b/health/2.0/default/Android.bp
new file mode 100644
index 0000000..8eb02e0
--- /dev/null
+++ b/health/2.0/default/Android.bp
@@ -0,0 +1,28 @@
+cc_library_static {
+ name: "android.hardware.health@2.0-impl",
+ vendor_available: true,
+ srcs: [
+ "Health.cpp",
+ "healthd_common.cpp",
+ ],
+
+ cflags: ["-DHEALTHD_USE_HEALTH_2_0"],
+
+ export_include_dirs: ["include"],
+
+ shared_libs: [
+ "libbase",
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "android.hardware.health@2.0",
+ ],
+
+ static_libs: [
+ "libbatterymonitor",
+ "android.hardware.health@1.0-convert",
+ ],
+}
diff --git a/health/2.0/default/Health.cpp b/health/2.0/default/Health.cpp
new file mode 100644
index 0000000..4710c90
--- /dev/null
+++ b/health/2.0/default/Health.cpp
@@ -0,0 +1,183 @@
+#define LOG_TAG "android.hardware.health@2.0-impl"
+#include <android-base/logging.h>
+
+#include <health2/Health.h>
+
+#include <hidl/HidlTransportSupport.h>
+
+extern void healthd_battery_update_internal(bool);
+
+namespace android {
+namespace hardware {
+namespace health {
+namespace V2_0 {
+namespace implementation {
+
+sp<Health> Health::instance_;
+
+Health::Health(struct healthd_config* c) {
+ // TODO(b/69268160): remove when libhealthd is removed.
+ healthd_board_init(c);
+ battery_monitor_ = std::make_unique<BatteryMonitor>();
+ battery_monitor_->init(c);
+}
+
+// Methods from IHealth follow.
+Return<Result> Health::registerCallback(const sp<IHealthInfoCallback>& callback) {
+ if (callback == nullptr) {
+ return Result::SUCCESS;
+ }
+
+ {
+ std::lock_guard<std::mutex> _lock(callbacks_lock_);
+ callbacks_.push_back(callback);
+ // unlock
+ }
+
+ auto linkRet = callback->linkToDeath(this, 0u /* cookie */);
+ if (!linkRet.withDefault(false)) {
+ LOG(WARNING) << __func__ << "Cannot link to death: "
+ << (linkRet.isOk() ? "linkToDeath returns false" : linkRet.description());
+ // ignore the error
+ }
+
+ return update();
+}
+
+bool Health::unregisterCallbackInternal(const sp<IBase>& callback) {
+ if (callback == nullptr) return false;
+
+ bool removed = false;
+ std::lock_guard<std::mutex> _lock(callbacks_lock_);
+ for (auto it = callbacks_.begin(); it != callbacks_.end();) {
+ if (interfacesEqual(*it, callback)) {
+ it = callbacks_.erase(it);
+ removed = true;
+ } else {
+ ++it;
+ }
+ }
+ (void)callback->unlinkToDeath(this).isOk(); // ignore errors
+ return removed;
+}
+
+Return<Result> Health::unregisterCallback(const sp<IHealthInfoCallback>& callback) {
+ return unregisterCallbackInternal(callback) ? Result::SUCCESS : Result::NOT_FOUND;
+}
+
+template <typename T>
+void getProperty(const std::unique_ptr<BatteryMonitor>& monitor, int id, T defaultValue,
+ const std::function<void(Result, T)>& callback) {
+ struct BatteryProperty prop;
+ T ret = defaultValue;
+ Result result = Result::SUCCESS;
+ status_t err = monitor->getProperty(static_cast<int>(id), &prop);
+ if (err != OK) {
+ LOG(DEBUG) << "getProperty(" << id << ")"
+ << " fails: (" << err << ") " << strerror(-err);
+ } else {
+ ret = static_cast<T>(prop.valueInt64);
+ }
+ switch (err) {
+ case OK:
+ result = Result::SUCCESS;
+ break;
+ case NAME_NOT_FOUND:
+ result = Result::NOT_SUPPORTED;
+ break;
+ default:
+ result = Result::UNKNOWN;
+ break;
+ }
+ callback(result, static_cast<T>(ret));
+}
+
+Return<void> Health::getChargeCounter(getChargeCounter_cb _hidl_cb) {
+ getProperty(battery_monitor_, BATTERY_PROP_CHARGE_COUNTER, INT32_MIN, _hidl_cb);
+ return Void();
+}
+
+Return<void> Health::getCurrentNow(getCurrentNow_cb _hidl_cb) {
+ getProperty(battery_monitor_, BATTERY_PROP_CURRENT_NOW, INT32_MIN, _hidl_cb);
+ return Void();
+}
+
+Return<void> Health::getCurrentAverage(getCurrentAverage_cb _hidl_cb) {
+ getProperty(battery_monitor_, BATTERY_PROP_CURRENT_AVG, INT32_MIN, _hidl_cb);
+ return Void();
+}
+
+Return<void> Health::getCapacity(getCapacity_cb _hidl_cb) {
+ getProperty(battery_monitor_, BATTERY_PROP_CAPACITY, INT32_MIN, _hidl_cb);
+ return Void();
+}
+
+Return<void> Health::getEnergyCounter(getEnergyCounter_cb _hidl_cb) {
+ getProperty(battery_monitor_, BATTERY_PROP_ENERGY_COUNTER, INT64_MIN, _hidl_cb);
+ return Void();
+}
+
+Return<void> Health::getChargeStatus(getChargeStatus_cb _hidl_cb) {
+ getProperty(battery_monitor_, BATTERY_PROP_BATTERY_STATUS, BatteryStatus::UNKNOWN, _hidl_cb);
+ return Void();
+}
+
+Return<Result> Health::update() {
+ if (!healthd_mode_ops || !healthd_mode_ops->battery_update) {
+ LOG(WARNING) << "health@2.0: update: not initialized. "
+ << "update() should not be called in charger / recovery.";
+ return Result::UNKNOWN;
+ }
+
+ // Retrieve all information and call healthd_mode_ops->battery_update, which calls
+ // notifyListeners.
+ bool chargerOnline = battery_monitor_->update();
+
+ // adjust uevent / wakealarm periods
+ healthd_battery_update_internal(chargerOnline);
+
+ return Result::SUCCESS;
+}
+
+void Health::notifyListeners(const HealthInfo& info) {
+ std::lock_guard<std::mutex> _lock(callbacks_lock_);
+ for (auto it = callbacks_.begin(); it != callbacks_.end();) {
+ auto ret = (*it)->healthInfoChanged(info);
+ if (!ret.isOk() && ret.isDeadObject()) {
+ it = callbacks_.erase(it);
+ } else {
+ ++it;
+ }
+ }
+}
+
+Return<void> Health::debug(const hidl_handle& handle, const hidl_vec<hidl_string>&) {
+ if (handle != nullptr && handle->numFds >= 1) {
+ int fd = handle->data[0];
+ battery_monitor_->dumpState(fd);
+ fsync(fd);
+ }
+ return Void();
+}
+
+void Health::serviceDied(uint64_t /* cookie */, const wp<IBase>& who) {
+ (void)unregisterCallbackInternal(who.promote());
+}
+
+sp<IHealth> Health::initInstance(struct healthd_config* c) {
+ if (instance_ == nullptr) {
+ instance_ = new Health(c);
+ }
+ return instance_;
+}
+
+sp<Health> Health::getImplementation() {
+ CHECK(instance_ != nullptr);
+ return instance_;
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace health
+} // namespace hardware
+} // namespace android
diff --git a/health/2.0/default/healthd_common.cpp b/health/2.0/default/healthd_common.cpp
new file mode 100644
index 0000000..8ff409d
--- /dev/null
+++ b/health/2.0/default/healthd_common.cpp
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "android.hardware.health@2.0-impl"
+#define KLOG_LEVEL 6
+
+#include <healthd/BatteryMonitor.h>
+#include <healthd/healthd.h>
+
+#include <batteryservice/BatteryService.h>
+#include <cutils/klog.h>
+#include <cutils/uevent.h>
+#include <errno.h>
+#include <libgen.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/epoll.h>
+#include <sys/timerfd.h>
+#include <unistd.h>
+#include <utils/Errors.h>
+
+#include <health2/Health.h>
+
+using namespace android;
+
+// Periodic chores fast interval in seconds
+#define DEFAULT_PERIODIC_CHORES_INTERVAL_FAST (60 * 1)
+// Periodic chores fast interval in seconds
+#define DEFAULT_PERIODIC_CHORES_INTERVAL_SLOW (60 * 10)
+
+static struct healthd_config healthd_config = {
+ .periodic_chores_interval_fast = DEFAULT_PERIODIC_CHORES_INTERVAL_FAST,
+ .periodic_chores_interval_slow = DEFAULT_PERIODIC_CHORES_INTERVAL_SLOW,
+ .batteryStatusPath = String8(String8::kEmptyString),
+ .batteryHealthPath = String8(String8::kEmptyString),
+ .batteryPresentPath = String8(String8::kEmptyString),
+ .batteryCapacityPath = String8(String8::kEmptyString),
+ .batteryVoltagePath = String8(String8::kEmptyString),
+ .batteryTemperaturePath = String8(String8::kEmptyString),
+ .batteryTechnologyPath = String8(String8::kEmptyString),
+ .batteryCurrentNowPath = String8(String8::kEmptyString),
+ .batteryCurrentAvgPath = String8(String8::kEmptyString),
+ .batteryChargeCounterPath = String8(String8::kEmptyString),
+ .batteryFullChargePath = String8(String8::kEmptyString),
+ .batteryCycleCountPath = String8(String8::kEmptyString),
+ .energyCounter = NULL,
+ .boot_min_cap = 0,
+ .screen_on = NULL,
+};
+
+static int eventct;
+static int epollfd;
+
+#define POWER_SUPPLY_SUBSYSTEM "power_supply"
+
+// epoll_create() parameter is actually unused
+#define MAX_EPOLL_EVENTS 40
+static int uevent_fd;
+static int wakealarm_fd;
+
+// -1 for no epoll timeout
+static int awake_poll_interval = -1;
+
+static int wakealarm_wake_interval = DEFAULT_PERIODIC_CHORES_INTERVAL_FAST;
+
+using ::android::hardware::health::V2_0::implementation::Health;
+
+struct healthd_mode_ops* healthd_mode_ops = nullptr;
+
+int healthd_register_event(int fd, void (*handler)(uint32_t), EventWakeup wakeup) {
+ struct epoll_event ev;
+
+ ev.events = EPOLLIN;
+
+ if (wakeup == EVENT_WAKEUP_FD) ev.events |= EPOLLWAKEUP;
+
+ ev.data.ptr = (void*)handler;
+ if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev) == -1) {
+ KLOG_ERROR(LOG_TAG, "epoll_ctl failed; errno=%d\n", errno);
+ return -1;
+ }
+
+ eventct++;
+ return 0;
+}
+
+static void wakealarm_set_interval(int interval) {
+ struct itimerspec itval;
+
+ if (wakealarm_fd == -1) return;
+
+ wakealarm_wake_interval = interval;
+
+ if (interval == -1) interval = 0;
+
+ itval.it_interval.tv_sec = interval;
+ itval.it_interval.tv_nsec = 0;
+ itval.it_value.tv_sec = interval;
+ itval.it_value.tv_nsec = 0;
+
+ if (timerfd_settime(wakealarm_fd, 0, &itval, NULL) == -1)
+ KLOG_ERROR(LOG_TAG, "wakealarm_set_interval: timerfd_settime failed\n");
+}
+
+void healthd_battery_update_internal(bool charger_online) {
+ // Fast wake interval when on charger (watch for overheat);
+ // slow wake interval when on battery (watch for drained battery).
+
+ int new_wake_interval = charger_online ? healthd_config.periodic_chores_interval_fast
+ : healthd_config.periodic_chores_interval_slow;
+
+ if (new_wake_interval != wakealarm_wake_interval) wakealarm_set_interval(new_wake_interval);
+
+ // During awake periods poll at fast rate. If wake alarm is set at fast
+ // rate then just use the alarm; if wake alarm is set at slow rate then
+ // poll at fast rate while awake and let alarm wake up at slow rate when
+ // asleep.
+
+ if (healthd_config.periodic_chores_interval_fast == -1)
+ awake_poll_interval = -1;
+ else
+ awake_poll_interval = new_wake_interval == healthd_config.periodic_chores_interval_fast
+ ? -1
+ : healthd_config.periodic_chores_interval_fast * 1000;
+}
+
+static void healthd_battery_update(void) {
+ Health::getImplementation()->update();
+}
+
+static void periodic_chores() {
+ healthd_battery_update();
+}
+
+#define UEVENT_MSG_LEN 2048
+static void uevent_event(uint32_t /*epevents*/) {
+ char msg[UEVENT_MSG_LEN + 2];
+ char* cp;
+ int n;
+
+ n = uevent_kernel_multicast_recv(uevent_fd, msg, UEVENT_MSG_LEN);
+ if (n <= 0) return;
+ if (n >= UEVENT_MSG_LEN) /* overflow -- discard */
+ return;
+
+ msg[n] = '\0';
+ msg[n + 1] = '\0';
+ cp = msg;
+
+ while (*cp) {
+ if (!strcmp(cp, "SUBSYSTEM=" POWER_SUPPLY_SUBSYSTEM)) {
+ healthd_battery_update();
+ break;
+ }
+
+ /* advance to after the next \0 */
+ while (*cp++)
+ ;
+ }
+}
+
+static void uevent_init(void) {
+ uevent_fd = uevent_open_socket(64 * 1024, true);
+
+ if (uevent_fd < 0) {
+ KLOG_ERROR(LOG_TAG, "uevent_init: uevent_open_socket failed\n");
+ return;
+ }
+
+ fcntl(uevent_fd, F_SETFL, O_NONBLOCK);
+ if (healthd_register_event(uevent_fd, uevent_event, EVENT_WAKEUP_FD))
+ KLOG_ERROR(LOG_TAG, "register for uevent events failed\n");
+}
+
+static void wakealarm_event(uint32_t /*epevents*/) {
+ unsigned long long wakeups;
+
+ if (read(wakealarm_fd, &wakeups, sizeof(wakeups)) == -1) {
+ KLOG_ERROR(LOG_TAG, "wakealarm_event: read wakealarm fd failed\n");
+ return;
+ }
+
+ periodic_chores();
+}
+
+static void wakealarm_init(void) {
+ wakealarm_fd = timerfd_create(CLOCK_BOOTTIME_ALARM, TFD_NONBLOCK);
+ if (wakealarm_fd == -1) {
+ KLOG_ERROR(LOG_TAG, "wakealarm_init: timerfd_create failed\n");
+ return;
+ }
+
+ if (healthd_register_event(wakealarm_fd, wakealarm_event, EVENT_WAKEUP_FD))
+ KLOG_ERROR(LOG_TAG, "Registration of wakealarm event failed\n");
+
+ wakealarm_set_interval(healthd_config.periodic_chores_interval_fast);
+}
+
+static void healthd_mainloop(void) {
+ int nevents = 0;
+ while (1) {
+ struct epoll_event events[eventct];
+ int timeout = awake_poll_interval;
+ int mode_timeout;
+
+ /* Don't wait for first timer timeout to run periodic chores */
+ if (!nevents) periodic_chores();
+
+ healthd_mode_ops->heartbeat();
+
+ mode_timeout = healthd_mode_ops->preparetowait();
+ if (timeout < 0 || (mode_timeout > 0 && mode_timeout < timeout)) timeout = mode_timeout;
+ nevents = epoll_wait(epollfd, events, eventct, timeout);
+ if (nevents == -1) {
+ if (errno == EINTR) continue;
+ KLOG_ERROR(LOG_TAG, "healthd_mainloop: epoll_wait failed\n");
+ break;
+ }
+
+ for (int n = 0; n < nevents; ++n) {
+ if (events[n].data.ptr) (*(void (*)(int))events[n].data.ptr)(events[n].events);
+ }
+ }
+
+ return;
+}
+
+static int healthd_init() {
+ epollfd = epoll_create(MAX_EPOLL_EVENTS);
+ if (epollfd == -1) {
+ KLOG_ERROR(LOG_TAG, "epoll_create failed; errno=%d\n", errno);
+ return -1;
+ }
+
+ healthd_mode_ops->init(&healthd_config);
+ wakealarm_init();
+ uevent_init();
+
+ return 0;
+}
+
+int healthd_main() {
+ int ret;
+
+ klog_set_level(KLOG_LEVEL);
+
+ if (!healthd_mode_ops) {
+ KLOG_ERROR("healthd ops not set, exiting\n");
+ exit(1);
+ }
+
+ ret = healthd_init();
+ if (ret) {
+ KLOG_ERROR("Initialization failed, exiting\n");
+ exit(2);
+ }
+
+ healthd_mainloop();
+ KLOG_ERROR("Main loop terminated, exiting\n");
+ return 3;
+}
diff --git a/health/2.0/default/include/health2/Health.h b/health/2.0/default/include/health2/Health.h
new file mode 100644
index 0000000..ab42ae7
--- /dev/null
+++ b/health/2.0/default/include/health2/Health.h
@@ -0,0 +1,69 @@
+#ifndef ANDROID_HARDWARE_HEALTH_V2_0_HEALTH_H
+#define ANDROID_HARDWARE_HEALTH_V2_0_HEALTH_H
+
+#include <memory>
+#include <vector>
+
+#include <android/hardware/health/1.0/types.h>
+#include <android/hardware/health/2.0/IHealth.h>
+#include <healthd/BatteryMonitor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace health {
+namespace V2_0 {
+namespace implementation {
+
+using V1_0::BatteryStatus;
+using V1_0::HealthInfo;
+
+using ::android::hidl::base::V1_0::IBase;
+
+struct Health : public IHealth, hidl_death_recipient {
+ public:
+ static sp<IHealth> initInstance(struct healthd_config* c);
+ // Should only be called by implementation itself (-impl, -service).
+ // Clients should not call this function. Instead, initInstance() initializes and returns the
+ // global instance that has fewer functions.
+ // TODO(b/62229583): clean up and hide these functions after update() logic is simplified.
+ static sp<Health> getImplementation();
+
+ Health(struct healthd_config* c);
+
+ // TODO(b/62229583): clean up and hide these functions after update() logic is simplified.
+ void notifyListeners(const HealthInfo& info);
+
+ // Methods from IHealth follow.
+ Return<Result> registerCallback(const sp<IHealthInfoCallback>& callback) override;
+ Return<Result> unregisterCallback(const sp<IHealthInfoCallback>& callback) override;
+ Return<Result> update() override;
+ Return<void> getChargeCounter(getChargeCounter_cb _hidl_cb) override;
+ Return<void> getCurrentNow(getCurrentNow_cb _hidl_cb) override;
+ Return<void> getCurrentAverage(getCurrentAverage_cb _hidl_cb) override;
+ Return<void> getCapacity(getCapacity_cb _hidl_cb) override;
+ Return<void> getEnergyCounter(getEnergyCounter_cb _hidl_cb) override;
+ Return<void> getChargeStatus(getChargeStatus_cb _hidl_cb) override;
+
+ // Methods from ::android::hidl::base::V1_0::IBase follow.
+ Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override;
+
+ void serviceDied(uint64_t cookie, const wp<IBase>& /* who */) override;
+
+ private:
+ static sp<Health> instance_;
+
+ std::mutex callbacks_lock_;
+ std::vector<sp<IHealthInfoCallback>> callbacks_;
+ std::unique_ptr<BatteryMonitor> battery_monitor_;
+
+ bool unregisterCallbackInternal(const sp<IBase>& cb);
+};
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace health
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_HEALTH_V2_0_HEALTH_H
diff --git a/radio/1.2/types.hal b/radio/1.2/types.hal
index 6b57ae3..52af575 100644
--- a/radio/1.2/types.hal
+++ b/radio/1.2/types.hal
@@ -35,7 +35,7 @@
import @1.1::ScanType;
enum RadioConst : @1.0::RadioConst {
- RADIO_ACCESS_SPEFICIER_MAX_SIZE = 8,
+ RADIO_ACCESS_SPECIFIER_MAX_SIZE = 8,
};
/**
@@ -74,7 +74,7 @@
/**
* Networks with bands/channels to scan
* Maximum length of the vector is
- * RadioConst:RADIO_ACCESS_SPEFICIER_MAX_SIZE
+ * RadioConst:RADIO_ACCESS_SPECIFIER_MAX_SIZE
*/
vec<RadioAccessSpecifier> specifiers;
@@ -220,4 +220,4 @@
* Valid only if type = tdscdma and size = 1 else must be empty.
*/
vec<CellInfoTdscdma> tdscdma;
-};
\ No newline at end of file
+};
diff --git a/tests/bar/1.0/default/Bar.cpp b/tests/bar/1.0/default/Bar.cpp
index 6a8a360..4614428 100644
--- a/tests/bar/1.0/default/Bar.cpp
+++ b/tests/bar/1.0/default/Bar.cpp
@@ -19,6 +19,11 @@
}
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
+Return<void> Bar::convertToBoolIfSmall(Discriminator d, const hidl_vec<Union>& u,
+ convertToBoolIfSmall_cb _hidl_cb) {
+ return mFoo->convertToBoolIfSmall(d, u, _hidl_cb);
+}
+
Return<void> Bar::doThis(float param) {
return mFoo->doThis(param);
}
diff --git a/tests/bar/1.0/default/Bar.h b/tests/bar/1.0/default/Bar.h
index b276823..acb976f 100644
--- a/tests/bar/1.0/default/Bar.h
+++ b/tests/bar/1.0/default/Bar.h
@@ -31,6 +31,8 @@
Bar();
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
+ virtual Return<void> convertToBoolIfSmall(Discriminator d, const hidl_vec<Union>& u,
+ convertToBoolIfSmall_cb _hidl_cb) override;
virtual Return<void> doThis(float param) override;
virtual Return<int32_t> doThatAndReturnSomething(int64_t param) override;
virtual Return<double> doQuiteABit(int32_t a, int64_t b, float c, double d) override;
diff --git a/tests/foo/1.0/IFoo.hal b/tests/foo/1.0/IFoo.hal
index c1ce7b0..4a930a2 100644
--- a/tests/foo/1.0/IFoo.hal
+++ b/tests/foo/1.0/IFoo.hal
@@ -122,6 +122,19 @@
bitfield<BitField> bf;
};
+ enum Discriminator : uint8_t {
+ BOOL,
+ INT,
+ };
+ union Union {
+ bool boolValue;
+ int64_t intValue;
+ };
+ struct ContainsUnion {
+ Discriminator discriminator;
+ Union value;
+ };
+
typedef int32_t[5][6][7] multidimArrayOne;
typedef multidimArrayOne[8][9][10] multidimArrayTwo;
typedef multidimArrayTwo[2][3][4] multidimArrayThree;
@@ -144,6 +157,16 @@
InnerTestEnumTypedef foo;
};
+ /**
+ * If d is INT, converts all values to bools which are small enough (0 or 1).
+ * If d is BOOL, should leave all values as BOOLs.
+ *
+ * @param d discriminator for all values in u
+ * @param u values to be expanded
+ * @return c must have same length as u unless there is an error in which case it will be empty.
+ */
+ convertToBoolIfSmall(Discriminator d, vec<Union> u) generates (vec<ContainsUnion> c);
+
doThis(float param);
doThatAndReturnSomething(int64_t param) generates (int32_t result);
doQuiteABit(int32_t a, int64_t b, float c, double d) generates (double something);
diff --git a/tests/foo/1.0/default/Foo.cpp b/tests/foo/1.0/default/Foo.cpp
index a860ce7..a31ab9f 100644
--- a/tests/foo/1.0/default/Foo.cpp
+++ b/tests/foo/1.0/default/Foo.cpp
@@ -15,6 +15,30 @@
namespace implementation {
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
+Return<void> Foo::convertToBoolIfSmall(Discriminator d, const hidl_vec<Union>& u,
+ convertToBoolIfSmall_cb _hidl_cb) {
+ hidl_vec<ContainsUnion> res(u.size());
+ for (size_t i = 0; i < u.size(); i++) {
+ ContainsUnion& outValue = res[i];
+
+ if (d == Discriminator::BOOL) {
+ outValue.discriminator = Discriminator::BOOL;
+ outValue.value.boolValue = u[i].boolValue;
+ } else {
+ uint64_t value = u[i].intValue;
+ if (value == 0 || value == 1) {
+ outValue.discriminator = Discriminator::BOOL;
+ outValue.value.boolValue = static_cast<bool>(value);
+ } else {
+ outValue.discriminator = Discriminator::INT;
+ outValue.value.intValue = value;
+ }
+ }
+ }
+ _hidl_cb(res);
+ return Void();
+}
+
Return<void> Foo::doThis(float param) {
LOG(INFO) << "SERVER(Foo) doThis(" << param << ")";
diff --git a/tests/foo/1.0/default/Foo.h b/tests/foo/1.0/default/Foo.h
index 4558a73..7dd672b 100644
--- a/tests/foo/1.0/default/Foo.h
+++ b/tests/foo/1.0/default/Foo.h
@@ -22,9 +22,14 @@
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
+using ContainsUnion = ::android::hardware::tests::foo::V1_0::IFoo::ContainsUnion;
+using Discriminator = ::android::hardware::tests::foo::V1_0::IFoo::Discriminator;
+using Union = ::android::hardware::tests::foo::V1_0::IFoo::Union;
struct Foo : public IFoo {
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
+ virtual Return<void> convertToBoolIfSmall(Discriminator d, const hidl_vec<Union>& u,
+ convertToBoolIfSmall_cb _hidl_cb) override;
virtual Return<void> doThis(float param) override;
virtual Return<int32_t> doThatAndReturnSomething(int64_t param) override;
virtual Return<double> doQuiteABit(int32_t a, int64_t b, float c, double d) override;
diff --git a/wifi/1.2/default/Android.mk b/wifi/1.2/default/Android.mk
index b242cfc..95414bc 100644
--- a/wifi/1.2/default/Android.mk
+++ b/wifi/1.2/default/Android.mk
@@ -13,21 +13,27 @@
# limitations under the License.
LOCAL_PATH := $(call my-dir)
+###
+### android.hardware.wifi static library
+###
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.wifi@1.0-service
+LOCAL_MODULE := android.hardware.wifi@1.0-service-lib
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_PROPRIETARY_MODULE := true
LOCAL_CPPFLAGS := -Wall -Werror -Wextra
ifdef WIFI_HIDL_FEATURE_AWARE
LOCAL_CPPFLAGS += -DWIFI_HIDL_FEATURE_AWARE
endif
+ifdef WIFI_HIDL_FEATURE_DUAL_INTERFACE
+LOCAL_CPPFLAGS += -DWIFI_HIDL_FEATURE_DUAL_INTERFACE
+endif
LOCAL_SRC_FILES := \
hidl_struct_util.cpp \
hidl_sync_util.cpp \
- service.cpp \
wifi.cpp \
wifi_ap_iface.cpp \
wifi_chip.cpp \
+ wifi_feature_flags.cpp \
wifi_legacy_hal.cpp \
wifi_legacy_hal_stubs.cpp \
wifi_mode_controller.cpp \
@@ -49,5 +55,64 @@
android.hardware.wifi@1.0 \
android.hardware.wifi@1.1 \
android.hardware.wifi@1.2
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
+include $(BUILD_STATIC_LIBRARY)
+
+###
+### android.hardware.wifi daemon
+###
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.wifi@1.0-service
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_PROPRIETARY_MODULE := true
+LOCAL_CPPFLAGS := -Wall -Werror -Wextra
+LOCAL_SRC_FILES := \
+ service.cpp
+LOCAL_SHARED_LIBRARIES := \
+ libbase \
+ libcutils \
+ libhidlbase \
+ libhidltransport \
+ liblog \
+ libnl \
+ libutils \
+ libwifi-hal \
+ libwifi-system-iface \
+ android.hardware.wifi@1.0 \
+ android.hardware.wifi@1.1 \
+ android.hardware.wifi@1.2
+LOCAL_STATIC_LIBRARIES := \
+ android.hardware.wifi@1.0-service-lib
LOCAL_INIT_RC := android.hardware.wifi@1.0-service.rc
include $(BUILD_EXECUTABLE)
+
+###
+### android.hardware.wifi unit tests.
+###
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.wifi@1.0-service-tests
+LOCAL_PROPRIETARY_MODULE := true
+LOCAL_SRC_FILES := \
+ tests/main.cpp \
+ tests/mock_wifi_feature_flags.cpp \
+ tests/mock_wifi_legacy_hal.cpp \
+ tests/mock_wifi_mode_controller.cpp \
+ tests/wifi_chip_unit_tests.cpp
+LOCAL_STATIC_LIBRARIES := \
+ libgmock \
+ libgtest \
+ android.hardware.wifi@1.0-service-lib
+LOCAL_SHARED_LIBRARIES := \
+ libbase \
+ libcutils \
+ libhidlbase \
+ libhidltransport \
+ liblog \
+ libnl \
+ libutils \
+ libwifi-hal \
+ libwifi-system-iface \
+ android.hardware.wifi@1.0 \
+ android.hardware.wifi@1.1 \
+ android.hardware.wifi@1.2
+include $(BUILD_NATIVE_TEST)
diff --git a/wifi/1.2/default/hidl_struct_util.cpp b/wifi/1.2/default/hidl_struct_util.cpp
index 1359498..5d48109 100644
--- a/wifi/1.2/default/hidl_struct_util.cpp
+++ b/wifi/1.2/default/hidl_struct_util.cpp
@@ -1250,10 +1250,10 @@
hidl_request.baseConfigs.rangingIntervalMsec;
legacy_request->ranging_cfg.config_ranging_indications =
hidl_request.baseConfigs.configRangingIndications;
- legacy_request->ranging_cfg.distance_ingress_cm =
- hidl_request.baseConfigs.distanceIngressCm;
- legacy_request->ranging_cfg.distance_egress_cm =
- hidl_request.baseConfigs.distanceEgressCm;
+ legacy_request->ranging_cfg.distance_ingress_mm =
+ hidl_request.baseConfigs.distanceIngressCm * 10;
+ legacy_request->ranging_cfg.distance_egress_mm =
+ hidl_request.baseConfigs.distanceEgressCm * 10;
legacy_request->ranging_auto_response =
hidl_request.baseConfigs.rangingRequired
? legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE
@@ -1402,10 +1402,10 @@
hidl_request.baseConfigs.rangingIntervalMsec;
legacy_request->ranging_cfg.config_ranging_indications =
hidl_request.baseConfigs.configRangingIndications;
- legacy_request->ranging_cfg.distance_ingress_cm =
- hidl_request.baseConfigs.distanceIngressCm;
- legacy_request->ranging_cfg.distance_egress_cm =
- hidl_request.baseConfigs.distanceEgressCm;
+ legacy_request->ranging_cfg.distance_ingress_mm =
+ hidl_request.baseConfigs.distanceIngressCm * 10;
+ legacy_request->ranging_cfg.distance_egress_mm =
+ hidl_request.baseConfigs.distanceEgressCm * 10;
legacy_request->ranging_auto_response =
hidl_request.baseConfigs.rangingRequired
? legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE
@@ -1847,7 +1847,7 @@
hidl_ind->peerRequiresRanging = legacy_ind.peer_sdea_params.ranging_state ==
legacy_hal::NAN_RANGING_ENABLE;
hidl_ind->rangingMeasurementInCm =
- legacy_ind.range_info.range_measurement_cm;
+ legacy_ind.range_info.range_measurement_mm / 10;
hidl_ind->rangingIndicationType = legacy_ind.range_info.ranging_event_type;
return true;
diff --git a/wifi/1.2/default/service.cpp b/wifi/1.2/default/service.cpp
index 6297cf2..01d22bd 100644
--- a/wifi/1.2/default/service.cpp
+++ b/wifi/1.2/default/service.cpp
@@ -20,9 +20,17 @@
#include <utils/StrongPointer.h>
#include "wifi.h"
+#include "wifi_feature_flags.h"
+#include "wifi_legacy_hal.h"
+#include "wifi_mode_controller.h"
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
+using android::hardware::wifi::V1_2::implementation::feature_flags::
+ WifiFeatureFlags;
+using android::hardware::wifi::V1_2::implementation::legacy_hal::WifiLegacyHal;
+using android::hardware::wifi::V1_2::implementation::mode_controller::
+ WifiModeController;
int main(int /*argc*/, char** argv) {
android::base::InitLogging(
@@ -33,7 +41,10 @@
// Setup hwbinder service
android::sp<android::hardware::wifi::V1_2::IWifi> service =
- new android::hardware::wifi::V1_2::implementation::Wifi();
+ new android::hardware::wifi::V1_2::implementation::Wifi(
+ std::make_shared<WifiLegacyHal>(),
+ std::make_shared<WifiModeController>(),
+ std::make_shared<WifiFeatureFlags>());
CHECK_EQ(service->registerAsService(), android::NO_ERROR)
<< "Failed to register wifi HAL";
diff --git a/wifi/1.2/default/tests/main.cpp b/wifi/1.2/default/tests/main.cpp
new file mode 100644
index 0000000..9aac837
--- /dev/null
+++ b/wifi/1.2/default/tests/main.cpp
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <android-base/logging.h>
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::InitGoogleMock(&argc, argv);
+ // Force ourselves to always log to stderr
+ android::base::InitLogging(argv, android::base::StderrLogger);
+ return RUN_ALL_TESTS();
+}
diff --git a/wifi/1.2/default/tests/mock_wifi_feature_flags.cpp b/wifi/1.2/default/tests/mock_wifi_feature_flags.cpp
new file mode 100644
index 0000000..8d0b192
--- /dev/null
+++ b/wifi/1.2/default/tests/mock_wifi_feature_flags.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gmock/gmock.h>
+
+#include "mock_wifi_feature_flags.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_2 {
+namespace implementation {
+namespace feature_flags {
+
+MockWifiFeatureFlags::MockWifiFeatureFlags() {}
+
+} // namespace feature_flags
+} // namespace implementation
+} // namespace V1_2
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.2/default/tests/mock_wifi_feature_flags.h b/wifi/1.2/default/tests/mock_wifi_feature_flags.h
new file mode 100644
index 0000000..8cf1d4b
--- /dev/null
+++ b/wifi/1.2/default/tests/mock_wifi_feature_flags.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MOCK_WIFI_FEATURE_FLAGS_H_
+#define MOCK_WIFI_FEATURE_FLAGS_H_
+
+#include <gmock/gmock.h>
+
+#include "wifi_feature_flags.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_2 {
+namespace implementation {
+namespace feature_flags {
+
+class MockWifiFeatureFlags : public WifiFeatureFlags {
+ public:
+ MockWifiFeatureFlags();
+
+ MOCK_METHOD0(isAwareSupported, bool());
+ MOCK_METHOD0(isDualInterfaceSupported, bool());
+};
+
+} // namespace feature_flags
+} // namespace implementation
+} // namespace V1_2
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // MOCK_WIFI_FEATURE_FLAGS_H_
diff --git a/wifi/1.2/default/tests/mock_wifi_legacy_hal.cpp b/wifi/1.2/default/tests/mock_wifi_legacy_hal.cpp
new file mode 100644
index 0000000..8381dde
--- /dev/null
+++ b/wifi/1.2/default/tests/mock_wifi_legacy_hal.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/logging.h>
+#include <android-base/macros.h>
+#include <gmock/gmock.h>
+
+#undef NAN // This is weird, NAN is defined in bionic/libc/include/math.h:38
+#include "mock_wifi_legacy_hal.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_2 {
+namespace implementation {
+namespace legacy_hal {
+
+MockWifiLegacyHal::MockWifiLegacyHal() : WifiLegacyHal() {}
+} // namespace legacy_hal
+} // namespace implementation
+} // namespace V1_2
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.2/default/tests/mock_wifi_legacy_hal.h b/wifi/1.2/default/tests/mock_wifi_legacy_hal.h
new file mode 100644
index 0000000..8e1696e
--- /dev/null
+++ b/wifi/1.2/default/tests/mock_wifi_legacy_hal.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MOCK_WIFI_LEGACY_HAL_H_
+#define MOCK_WIFI_LEGACY_HAL_H_
+
+#include <gmock/gmock.h>
+
+#include "wifi_legacy_hal.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_2 {
+namespace implementation {
+namespace legacy_hal {
+
+class MockWifiLegacyHal : public WifiLegacyHal {
+ public:
+ MockWifiLegacyHal();
+ MOCK_METHOD0(initialize, wifi_error());
+ MOCK_METHOD0(start, wifi_error());
+ MOCK_METHOD2(stop, wifi_error(std::unique_lock<std::recursive_mutex>*,
+ const std::function<void()>&));
+ MOCK_METHOD2(setDfsFlag, wifi_error(const std::string&, bool));
+ MOCK_METHOD2(nanRegisterCallbackHandlers,
+ wifi_error(const std::string&, const NanCallbackHandlers&));
+ MOCK_METHOD2(nanDisableRequest,
+ wifi_error(const std::string&, transaction_id));
+ MOCK_METHOD3(nanDataInterfaceDelete,
+ wifi_error(const std::string&, transaction_id,
+ const std::string&));
+};
+} // namespace legacy_hal
+} // namespace implementation
+} // namespace V1_2
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // MOCK_WIFI_LEGACY_HAL_H_
diff --git a/wifi/1.2/default/tests/mock_wifi_mode_controller.cpp b/wifi/1.2/default/tests/mock_wifi_mode_controller.cpp
new file mode 100644
index 0000000..461a581
--- /dev/null
+++ b/wifi/1.2/default/tests/mock_wifi_mode_controller.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/logging.h>
+#include <android-base/macros.h>
+#include <gmock/gmock.h>
+
+#undef NAN // This is weird, NAN is defined in bionic/libc/include/math.h:38
+#include "mock_wifi_mode_controller.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_2 {
+namespace implementation {
+namespace mode_controller {
+
+MockWifiModeController::MockWifiModeController() : WifiModeController() {}
+} // namespace mode_controller
+} // namespace implementation
+} // namespace V1_2
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.2/default/tests/mock_wifi_mode_controller.h b/wifi/1.2/default/tests/mock_wifi_mode_controller.h
new file mode 100644
index 0000000..50c3e35
--- /dev/null
+++ b/wifi/1.2/default/tests/mock_wifi_mode_controller.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MOCK_WIFI_MODE_CONTROLLER_H_
+#define MOCK_WIFI_MODE_CONTROLLER_H_
+
+#include <gmock/gmock.h>
+
+#include "wifi_mode_controller.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_2 {
+namespace implementation {
+namespace mode_controller {
+
+class MockWifiModeController : public WifiModeController {
+ public:
+ MockWifiModeController();
+ MOCK_METHOD0(initialize, bool());
+ MOCK_METHOD1(changeFirmwareMode, bool(IfaceType));
+ MOCK_METHOD1(isFirmwareModeChangeNeeded, bool(IfaceType));
+ MOCK_METHOD0(deinitialize, bool());
+};
+} // namespace mode_controller
+} // namespace implementation
+} // namespace V1_2
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // MOCK_WIFI_MODE_CONTROLLER_H_
diff --git a/wifi/1.2/default/tests/runtests.sh b/wifi/1.2/default/tests/runtests.sh
new file mode 100755
index 0000000..966a6a7
--- /dev/null
+++ b/wifi/1.2/default/tests/runtests.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+
+# Copyright(C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0(the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http:// www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if [ -z $ANDROID_BUILD_TOP ]; then
+ echo "You need to source and lunch before you can use this script"
+ exit 1
+fi
+
+echo "Running tests"
+set -e # fail early
+
+#NOTE We can't actually run these commands, since they rely on functions added by
+#build / envsetup.sh to the bash shell environment.
+echo "+ mmma -j32 $ANDROID_BUILD_TOP/"
+make -j32 -C $ANDROID_BUILD_TOP -f build/core/main.mk \
+ MODULES-IN-hardware-interfaces-wifi-1.2-default
+
+set -x # print commands
+
+adb wait-for-device
+adb root
+adb wait-for-device
+
+#'disable-verity' will appear in 'adb remount' output if
+#dm - verity is enabled and needs to be disabled.
+if adb remount | grep 'disable-verity'; then
+ adb disable-verity
+ adb reboot
+ adb wait-for-device
+ adb root
+ adb wait-for-device
+ adb remount
+fi
+
+adb sync
+
+adb shell /data/nativetest/vendor/android.hardware.wifi@1.0-service-tests/android.hardware.wifi@1.0-service-tests
diff --git a/wifi/1.2/default/tests/wifi_chip_unit_tests.cpp b/wifi/1.2/default/tests/wifi_chip_unit_tests.cpp
new file mode 100644
index 0000000..f73869b
--- /dev/null
+++ b/wifi/1.2/default/tests/wifi_chip_unit_tests.cpp
@@ -0,0 +1,547 @@
+/*
+ * Copyright (C) 2017, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/logging.h>
+#include <android-base/macros.h>
+#include <gmock/gmock.h>
+
+#undef NAN // This is weird, NAN is defined in bionic/libc/include/math.h:38
+#include "wifi_chip.h"
+
+#include "mock_wifi_feature_flags.h"
+#include "mock_wifi_legacy_hal.h"
+#include "mock_wifi_mode_controller.h"
+
+using testing::NiceMock;
+using testing::Return;
+using testing::Test;
+
+namespace {
+using android::hardware::wifi::V1_0::ChipId;
+
+constexpr ChipId kFakeChipId = 5;
+} // namespace
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_2 {
+namespace implementation {
+
+class WifiChipTest : public Test {
+ protected:
+ void setupV1IfaceCombination() {
+ EXPECT_CALL(*feature_flags_, isAwareSupported())
+ .WillRepeatedly(testing::Return(false));
+ EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
+ .WillRepeatedly(testing::Return(false));
+ }
+
+ void setupV1_AwareIfaceCombination() {
+ EXPECT_CALL(*feature_flags_, isAwareSupported())
+ .WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
+ .WillRepeatedly(testing::Return(false));
+ }
+
+ void setupV2_AwareIfaceCombination() {
+ EXPECT_CALL(*feature_flags_, isAwareSupported())
+ .WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
+ .WillRepeatedly(testing::Return(true));
+ }
+
+ void assertNumberOfModes(uint32_t num_modes) {
+ chip_->getAvailableModes(
+ [num_modes](const WifiStatus& status,
+ const std::vector<WifiChip::ChipMode>& modes) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ // V2_Aware has 1 mode of operation.
+ ASSERT_EQ(num_modes, modes.size());
+ });
+ }
+
+ void findModeAndConfigureForIfaceType(const IfaceType& type) {
+ // This should be aligned with kInvalidModeId in wifi_chip.cpp.
+ ChipModeId mode_id = UINT32_MAX;
+ chip_->getAvailableModes(
+ [&mode_id, &type](const WifiStatus& status,
+ const std::vector<WifiChip::ChipMode>& modes) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ for (const auto& mode : modes) {
+ for (const auto& combination : mode.availableCombinations) {
+ for (const auto& limit : combination.limits) {
+ if (limit.types.end() !=
+ std::find(limit.types.begin(),
+ limit.types.end(), type)) {
+ mode_id = mode.id;
+ }
+ }
+ }
+ }
+ });
+ ASSERT_NE(UINT32_MAX, mode_id);
+
+ chip_->configureChip(mode_id, [](const WifiStatus& status) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ });
+ }
+
+ // Returns an empty string on error.
+ std::string createIface(const IfaceType& type) {
+ std::string iface_name;
+ if (type == IfaceType::AP) {
+ chip_->createApIface([&iface_name](const WifiStatus& status,
+ const sp<IWifiApIface>& iface) {
+ if (WifiStatusCode::SUCCESS == status.code) {
+ ASSERT_NE(iface.get(), nullptr);
+ iface->getName([&iface_name](const WifiStatus& status,
+ const hidl_string& name) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ iface_name = name.c_str();
+ });
+ }
+ });
+ } else if (type == IfaceType::NAN) {
+ chip_->createNanIface(
+ [&iface_name](const WifiStatus& status,
+ const sp<IWifiNanIface>& iface) {
+ if (WifiStatusCode::SUCCESS == status.code) {
+ ASSERT_NE(iface.get(), nullptr);
+ iface->getName([&iface_name](const WifiStatus& status,
+ const hidl_string& name) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ iface_name = name.c_str();
+ });
+ }
+ });
+ } else if (type == IfaceType::P2P) {
+ chip_->createP2pIface(
+ [&iface_name](const WifiStatus& status,
+ const sp<IWifiP2pIface>& iface) {
+ if (WifiStatusCode::SUCCESS == status.code) {
+ ASSERT_NE(iface.get(), nullptr);
+ iface->getName([&iface_name](const WifiStatus& status,
+ const hidl_string& name) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ iface_name = name.c_str();
+ });
+ }
+ });
+ } else if (type == IfaceType::STA) {
+ chip_->createStaIface(
+ [&iface_name](const WifiStatus& status,
+ const sp<IWifiStaIface>& iface) {
+ if (WifiStatusCode::SUCCESS == status.code) {
+ ASSERT_NE(iface.get(), nullptr);
+ iface->getName([&iface_name](const WifiStatus& status,
+ const hidl_string& name) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ iface_name = name.c_str();
+ });
+ }
+ });
+ }
+ return iface_name;
+ }
+
+ void removeIface(const IfaceType& type, const std::string& iface_name) {
+ if (type == IfaceType::AP) {
+ chip_->removeApIface(iface_name, [](const WifiStatus& status) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ });
+ } else if (type == IfaceType::NAN) {
+ chip_->removeNanIface(iface_name, [](const WifiStatus& status) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ });
+ } else if (type == IfaceType::P2P) {
+ chip_->removeP2pIface(iface_name, [](const WifiStatus& status) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ });
+ } else if (type == IfaceType::STA) {
+ chip_->removeStaIface(iface_name, [](const WifiStatus& status) {
+ ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
+ });
+ }
+ }
+
+ public:
+ void SetUp() override {
+ chip_ = new WifiChip(chip_id_, legacy_hal_, mode_controller_,
+ feature_flags_);
+
+ EXPECT_CALL(*mode_controller_, changeFirmwareMode(testing::_))
+ .WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(*legacy_hal_, start())
+ .WillRepeatedly(testing::Return(legacy_hal::WIFI_SUCCESS));
+ }
+
+ private:
+ sp<WifiChip> chip_;
+ ChipId chip_id_ = kFakeChipId;
+ std::shared_ptr<NiceMock<legacy_hal::MockWifiLegacyHal>> legacy_hal_{
+ new NiceMock<legacy_hal::MockWifiLegacyHal>};
+ std::shared_ptr<NiceMock<mode_controller::MockWifiModeController>>
+ mode_controller_{new NiceMock<mode_controller::MockWifiModeController>};
+ std::shared_ptr<NiceMock<feature_flags::MockWifiFeatureFlags>>
+ feature_flags_{new NiceMock<feature_flags::MockWifiFeatureFlags>};
+};
+
+////////// V1 Iface Combinations ////////////
+// Mode 1 - STA + P2P
+// Mode 2 - AP
+class WifiChipV1IfaceCombinationTest : public WifiChipTest {
+ public:
+ void SetUp() override {
+ setupV1IfaceCombination();
+ WifiChipTest::SetUp();
+ // V1 has 2 modes of operation.
+ assertNumberOfModes(2u);
+ }
+};
+
+TEST_F(WifiChipV1IfaceCombinationTest, StaMode_CreateSta_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+}
+
+TEST_F(WifiChipV1IfaceCombinationTest, StaMode_CreateP2p_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+}
+
+TEST_F(WifiChipV1IfaceCombinationTest, StaMode_CreateNan_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_TRUE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV1IfaceCombinationTest, StaMode_CreateAp_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_TRUE(createIface(IfaceType::AP).empty());
+}
+
+TEST_F(WifiChipV1IfaceCombinationTest, StaMode_CreateStaP2p_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+}
+
+TEST_F(WifiChipV1IfaceCombinationTest, ApMode_CreateAp_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_FALSE(createIface(IfaceType::AP).empty());
+}
+
+TEST_F(WifiChipV1IfaceCombinationTest, ApMode_CreateSta_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_TRUE(createIface(IfaceType::STA).empty());
+}
+
+TEST_F(WifiChipV1IfaceCombinationTest, ApMode_CreateP2p_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_TRUE(createIface(IfaceType::STA).empty());
+}
+
+TEST_F(WifiChipV1IfaceCombinationTest, ApMode_CreateNan_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_TRUE(createIface(IfaceType::NAN).empty());
+}
+
+////////// V1 + Aware Iface Combinations ////////////
+// Mode 1 - STA + P2P/NAN
+// Mode 2 - AP
+class WifiChipV1_AwareIfaceCombinationTest : public WifiChipTest {
+ public:
+ void SetUp() override {
+ setupV1_AwareIfaceCombination();
+ WifiChipTest::SetUp();
+ // V1_Aware has 2 modes of operation.
+ assertNumberOfModes(2u);
+ }
+};
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateSta_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateP2p_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateNan_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateAp_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_TRUE(createIface(IfaceType::AP).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest,
+ StaMode_CreateStaP2p_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest,
+ StaMode_CreateStaNan_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ ASSERT_FALSE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest,
+ StaMode_CreateStaP2PNan_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+ ASSERT_TRUE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest,
+ StaMode_CreateStaNan_AfterP2pRemove_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ const auto p2p_iface_name = createIface(IfaceType::P2P);
+ ASSERT_FALSE(p2p_iface_name.empty());
+ ASSERT_TRUE(createIface(IfaceType::NAN).empty());
+
+ // After removing P2P iface, NAN iface creation should succeed.
+ removeIface(IfaceType::P2P, p2p_iface_name);
+ ASSERT_FALSE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest,
+ StaMode_CreateStaP2p_AfterNanRemove_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ const auto nan_iface_name = createIface(IfaceType::NAN);
+ ASSERT_FALSE(nan_iface_name.empty());
+ ASSERT_TRUE(createIface(IfaceType::P2P).empty());
+
+ // After removing NAN iface, P2P iface creation should succeed.
+ removeIface(IfaceType::NAN, nan_iface_name);
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest, ApMode_CreateAp_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_FALSE(createIface(IfaceType::AP).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest, ApMode_CreateSta_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_TRUE(createIface(IfaceType::STA).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest, ApMode_CreateP2p_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_TRUE(createIface(IfaceType::STA).empty());
+}
+
+TEST_F(WifiChipV1_AwareIfaceCombinationTest, ApMode_CreateNan_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_TRUE(createIface(IfaceType::NAN).empty());
+}
+
+////////// V2 + Aware Iface Combinations ////////////
+// Mode 1 - STA + STA/AP
+// - STA + P2P/NAN
+class WifiChipV2_AwareIfaceCombinationTest : public WifiChipTest {
+ public:
+ void SetUp() override {
+ setupV2_AwareIfaceCombination();
+ WifiChipTest::SetUp();
+ // V2_Aware has 1 mode of operation.
+ assertNumberOfModes(1u);
+ }
+};
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateSta_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateP2p_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateNan_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateAp_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::AP).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaSta_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaAp_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_FALSE(createIface(IfaceType::AP).empty());
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaStaAp_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ ASSERT_TRUE(createIface(IfaceType::AP).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest,
+ CreateStaAp_AfterStaRemove_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ const auto sta_iface_name = createIface(IfaceType::STA);
+ ASSERT_FALSE(sta_iface_name.empty());
+ ASSERT_TRUE(createIface(IfaceType::AP).empty());
+
+ // After removing STA iface, AP iface creation should succeed.
+ removeIface(IfaceType::STA, sta_iface_name);
+ ASSERT_FALSE(createIface(IfaceType::AP).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest,
+ CreateStaSta_AfterApRemove_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ const auto ap_iface_name = createIface(IfaceType::AP);
+ ASSERT_FALSE(ap_iface_name.empty());
+ ASSERT_TRUE(createIface(IfaceType::STA).empty());
+
+ // After removing AP iface, STA iface creation should succeed.
+ removeIface(IfaceType::AP, ap_iface_name);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaP2p_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaNan_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ ASSERT_FALSE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaP2PNan_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+ ASSERT_TRUE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest,
+ CreateStaNan_AfterP2pRemove_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ const auto p2p_iface_name = createIface(IfaceType::P2P);
+ ASSERT_FALSE(p2p_iface_name.empty());
+ ASSERT_TRUE(createIface(IfaceType::NAN).empty());
+
+ // After removing P2P iface, NAN iface creation should succeed.
+ removeIface(IfaceType::P2P, p2p_iface_name);
+ ASSERT_FALSE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest,
+ CreateStaP2p_AfterNanRemove_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ const auto nan_iface_name = createIface(IfaceType::NAN);
+ ASSERT_FALSE(nan_iface_name.empty());
+ ASSERT_TRUE(createIface(IfaceType::P2P).empty());
+
+ // After removing NAN iface, P2P iface creation should succeed.
+ removeIface(IfaceType::NAN, nan_iface_name);
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateApNan_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_FALSE(createIface(IfaceType::AP).empty());
+ ASSERT_TRUE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateApP2p_ShouldFail) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ ASSERT_FALSE(createIface(IfaceType::AP).empty());
+ ASSERT_TRUE(createIface(IfaceType::P2P).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest,
+ StaMode_CreateStaNan_AfterP2pRemove_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ const auto p2p_iface_name = createIface(IfaceType::P2P);
+ ASSERT_FALSE(p2p_iface_name.empty());
+ ASSERT_TRUE(createIface(IfaceType::NAN).empty());
+
+ // After removing P2P iface, NAN iface creation should succeed.
+ removeIface(IfaceType::P2P, p2p_iface_name);
+ ASSERT_FALSE(createIface(IfaceType::NAN).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest,
+ StaMode_CreateStaP2p_AfterNanRemove_ShouldSucceed) {
+ findModeAndConfigureForIfaceType(IfaceType::STA);
+ ASSERT_FALSE(createIface(IfaceType::STA).empty());
+ const auto nan_iface_name = createIface(IfaceType::NAN);
+ ASSERT_FALSE(nan_iface_name.empty());
+ ASSERT_TRUE(createIface(IfaceType::P2P).empty());
+
+ // After removing NAN iface, P2P iface creation should succeed.
+ removeIface(IfaceType::NAN, nan_iface_name);
+ ASSERT_FALSE(createIface(IfaceType::P2P).empty());
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest,
+ CreateStaSta_EnsureDifferentIfaceNames) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ const auto sta1_iface_name = createIface(IfaceType::STA);
+ const auto sta2_iface_name = createIface(IfaceType::STA);
+ ASSERT_FALSE(sta1_iface_name.empty());
+ ASSERT_FALSE(sta2_iface_name.empty());
+ ASSERT_NE(sta1_iface_name, sta2_iface_name);
+}
+
+TEST_F(WifiChipV2_AwareIfaceCombinationTest,
+ CreateStaAp_EnsureDifferentIfaceNames) {
+ findModeAndConfigureForIfaceType(IfaceType::AP);
+ const auto sta_iface_name = createIface(IfaceType::STA);
+ const auto ap_iface_name = createIface(IfaceType::AP);
+ ASSERT_FALSE(sta_iface_name.empty());
+ ASSERT_FALSE(ap_iface_name.empty());
+ ASSERT_NE(sta_iface_name, ap_iface_name);
+}
+} // namespace implementation
+} // namespace V1_2
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.2/default/wifi.cpp b/wifi/1.2/default/wifi.cpp
index a2d8f9f..06f5058 100644
--- a/wifi/1.2/default/wifi.cpp
+++ b/wifi/1.2/default/wifi.cpp
@@ -33,9 +33,13 @@
using hidl_return_util::validateAndCall;
using hidl_return_util::validateAndCallWithLock;
-Wifi::Wifi()
- : legacy_hal_(new legacy_hal::WifiLegacyHal()),
- mode_controller_(new mode_controller::WifiModeController()),
+Wifi::Wifi(
+ const std::shared_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
+ const std::shared_ptr<mode_controller::WifiModeController> mode_controller,
+ const std::shared_ptr<feature_flags::WifiFeatureFlags> feature_flags)
+ : legacy_hal_(legacy_hal),
+ mode_controller_(mode_controller),
+ feature_flags_(feature_flags),
run_state_(RunState::STOPPED) {}
bool Wifi::isValid() {
@@ -88,10 +92,11 @@
return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE,
"HAL is stopping");
}
- WifiStatus wifi_status = initializeLegacyHal();
+ WifiStatus wifi_status = initializeModeControllerAndLegacyHal();
if (wifi_status.code == WifiStatusCode::SUCCESS) {
// Create the chip instance once the HAL is started.
- chip_ = new WifiChip(kChipId, legacy_hal_, mode_controller_);
+ chip_ = new WifiChip(kChipId, legacy_hal_, mode_controller_,
+ feature_flags_);
run_state_ = RunState::STARTED;
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onStart().isOk()) {
@@ -161,7 +166,11 @@
return {createWifiStatus(WifiStatusCode::SUCCESS), chip_};
}
-WifiStatus Wifi::initializeLegacyHal() {
+WifiStatus Wifi::initializeModeControllerAndLegacyHal() {
+ if (!mode_controller_->initialize()) {
+ LOG(ERROR) << "Failed to initialize firmware mode controller";
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
+ }
legacy_hal::wifi_error legacy_status = legacy_hal_->initialize();
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
LOG(ERROR) << "Failed to initialize legacy HAL: "
diff --git a/wifi/1.2/default/wifi.h b/wifi/1.2/default/wifi.h
index 114d774..440c3c7 100644
--- a/wifi/1.2/default/wifi.h
+++ b/wifi/1.2/default/wifi.h
@@ -25,6 +25,7 @@
#include "hidl_callback_util.h"
#include "wifi_chip.h"
+#include "wifi_feature_flags.h"
#include "wifi_legacy_hal.h"
#include "wifi_mode_controller.h"
@@ -39,7 +40,10 @@
*/
class Wifi : public V1_2::IWifi {
public:
- Wifi();
+ Wifi(const std::shared_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
+ const std::shared_ptr<mode_controller::WifiModeController>
+ mode_controller,
+ const std::shared_ptr<feature_flags::WifiFeatureFlags> feature_flags);
bool isValid();
@@ -64,7 +68,7 @@
std::pair<WifiStatus, std::vector<ChipId>> getChipIdsInternal();
std::pair<WifiStatus, sp<IWifiChip>> getChipInternal(ChipId chip_id);
- WifiStatus initializeLegacyHal();
+ WifiStatus initializeModeControllerAndLegacyHal();
WifiStatus stopLegacyHalAndDeinitializeModeController(
std::unique_lock<std::recursive_mutex>* lock);
@@ -72,6 +76,7 @@
// and shared with all the child HIDL interface objects.
std::shared_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
std::shared_ptr<mode_controller::WifiModeController> mode_controller_;
+ std::shared_ptr<feature_flags::WifiFeatureFlags> feature_flags_;
RunState run_state_;
sp<WifiChip> chip_;
hidl_callback_util::HidlCallbackHandler<IWifiEventCallback>
diff --git a/wifi/1.2/default/wifi_ap_iface.cpp b/wifi/1.2/default/wifi_ap_iface.cpp
index 284f9b9..92b7b48 100644
--- a/wifi/1.2/default/wifi_ap_iface.cpp
+++ b/wifi/1.2/default/wifi_ap_iface.cpp
@@ -40,6 +40,8 @@
bool WifiApIface::isValid() { return is_valid_; }
+std::string WifiApIface::getName() { return ifname_; }
+
Return<void> WifiApIface::getName(getName_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
&WifiApIface::getNameInternal, hidl_status_cb);
diff --git a/wifi/1.2/default/wifi_ap_iface.h b/wifi/1.2/default/wifi_ap_iface.h
index 6375121..5363ec2 100644
--- a/wifi/1.2/default/wifi_ap_iface.h
+++ b/wifi/1.2/default/wifi_ap_iface.h
@@ -39,6 +39,7 @@
// Refer to |WifiChip::invalidate()|.
void invalidate();
bool isValid();
+ std::string getName();
// HIDL methods exposed.
Return<void> getName(getName_cb hidl_status_cb) override;
diff --git a/wifi/1.2/default/wifi_chip.cpp b/wifi/1.2/default/wifi_chip.cpp
index 4e2191d..adba054 100644
--- a/wifi/1.2/default/wifi_chip.cpp
+++ b/wifi/1.2/default/wifi_chip.cpp
@@ -20,27 +20,59 @@
#include "hidl_return_util.h"
#include "hidl_struct_util.h"
#include "wifi_chip.h"
-#include "wifi_feature_flags.h"
#include "wifi_status_util.h"
namespace {
using android::hardware::hidl_string;
using android::hardware::hidl_vec;
using android::hardware::wifi::V1_0::ChipModeId;
-using android::hardware::wifi::V1_0::IWifiChip;
using android::hardware::wifi::V1_0::IfaceType;
+using android::hardware::wifi::V1_0::IWifiChip;
using android::sp;
-constexpr ChipModeId kStaChipModeId = 0;
-constexpr ChipModeId kApChipModeId = 1;
constexpr ChipModeId kInvalidModeId = UINT32_MAX;
+// These mode ID's should be unique (even across combo versions). Refer to
+// handleChipConfiguration() for it's usage.
+// Mode ID's for V1
+constexpr ChipModeId kV1StaChipModeId = 0;
+constexpr ChipModeId kV1ApChipModeId = 1;
+// Mode ID for V2
+constexpr ChipModeId kV2ChipModeId = 2;
template <typename Iface>
-void invalidateAndClear(sp<Iface>& iface) {
- if (iface.get()) {
+void invalidateAndClear(std::vector<sp<Iface>>& ifaces, sp<Iface> iface) {
+ iface->invalidate();
+ ifaces.erase(std::remove(ifaces.begin(), ifaces.end(), iface),
+ ifaces.end());
+}
+
+template <typename Iface>
+void invalidateAndClearAll(std::vector<sp<Iface>>& ifaces) {
+ for (const auto& iface : ifaces) {
iface->invalidate();
- iface.clear();
}
+ ifaces.clear();
+}
+
+template <typename Iface>
+std::vector<hidl_string> getNames(std::vector<sp<Iface>>& ifaces) {
+ std::vector<hidl_string> names;
+ for (const auto& iface : ifaces) {
+ names.emplace_back(iface->getName());
+ }
+ return names;
+}
+
+template <typename Iface>
+sp<Iface> findUsingName(std::vector<sp<Iface>>& ifaces,
+ const std::string& name) {
+ std::vector<hidl_string> names;
+ for (const auto& iface : ifaces) {
+ if (name == iface->getName()) {
+ return iface;
+ }
+ }
+ return nullptr;
}
std::string getWlan0IfaceName() {
@@ -49,13 +81,11 @@
return buffer.data();
}
-/** Not used yet.
std::string getWlan1IfaceName() {
- std::array<char, PROPERTY_VALUE_MAX> buffer;
- property_get("wifi.concurrent.interface", buffer.data(), "wlan1");
- return buffer.data();
+ std::array<char, PROPERTY_VALUE_MAX> buffer;
+ property_get("wifi.concurrent.interface", buffer.data(), "wlan1");
+ return buffer.data();
}
-*/
std::string getP2pIfaceName() {
std::array<char, PROPERTY_VALUE_MAX> buffer;
@@ -75,13 +105,17 @@
WifiChip::WifiChip(
ChipId chip_id, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
- const std::weak_ptr<mode_controller::WifiModeController> mode_controller)
+ const std::weak_ptr<mode_controller::WifiModeController> mode_controller,
+ const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags)
: chip_id_(chip_id),
legacy_hal_(legacy_hal),
mode_controller_(mode_controller),
+ feature_flags_(feature_flags),
is_valid_(true),
current_mode_id_(kInvalidModeId),
- debug_ring_buffer_cb_registered_(false) {}
+ debug_ring_buffer_cb_registered_(false) {
+ populateModes();
+}
void WifiChip::invalidate() {
invalidateAndRemoveAllIfaces();
@@ -317,10 +351,10 @@
}
void WifiChip::invalidateAndRemoveAllIfaces() {
- invalidateAndClear(ap_iface_);
- invalidateAndClear(nan_iface_);
- invalidateAndClear(p2p_iface_);
- invalidateAndClear(sta_iface_);
+ invalidateAndClearAll(ap_ifaces_);
+ invalidateAndClearAll(nan_ifaces_);
+ invalidateAndClearAll(p2p_ifaces_);
+ invalidateAndClearAll(sta_ifaces_);
// Since all the ifaces are invalid now, all RTT controller objects
// using those ifaces also need to be invalidated.
for (const auto& rtt : rtt_controllers_) {
@@ -365,43 +399,13 @@
std::pair<WifiStatus, std::vector<IWifiChip::ChipMode>>
WifiChip::getAvailableModesInternal() {
- // The chip combination supported for current devices is fixed for now with
- // 2 separate modes of operation:
- // Mode 1 (STA mode): Will support 1 STA and 1 P2P or NAN iface operations
- // concurrently [NAN conditional on wifiHidlFeatureAware]
- // Mode 2 (AP mode): Will support 1 AP iface operations.
- // TODO (b/32997844): Read this from some device specific flags in the
- // makefile.
- // STA mode iface combinations.
- const IWifiChip::ChipIfaceCombinationLimit
- sta_chip_iface_combination_limit_1 = {{IfaceType::STA}, 1};
- IWifiChip::ChipIfaceCombinationLimit sta_chip_iface_combination_limit_2;
- if (WifiFeatureFlags::wifiHidlFeatureAware) {
- sta_chip_iface_combination_limit_2 = {{IfaceType::P2P, IfaceType::NAN},
- 1};
- } else {
- sta_chip_iface_combination_limit_2 = {{IfaceType::P2P}, 1};
- }
- const IWifiChip::ChipIfaceCombination sta_chip_iface_combination = {
- {sta_chip_iface_combination_limit_1,
- sta_chip_iface_combination_limit_2}};
- const IWifiChip::ChipMode sta_chip_mode = {kStaChipModeId,
- {sta_chip_iface_combination}};
- // AP mode iface combinations.
- const IWifiChip::ChipIfaceCombinationLimit ap_chip_iface_combination_limit =
- {{IfaceType::AP}, 1};
- const IWifiChip::ChipIfaceCombination ap_chip_iface_combination = {
- {ap_chip_iface_combination_limit}};
- const IWifiChip::ChipMode ap_chip_mode = {kApChipModeId,
- {ap_chip_iface_combination}};
- return {createWifiStatus(WifiStatusCode::SUCCESS),
- {sta_chip_mode, ap_chip_mode}};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), modes_};
}
WifiStatus WifiChip::configureChipInternal(
/* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
ChipModeId mode_id) {
- if (mode_id != kStaChipModeId && mode_id != kApChipModeId) {
+ if (!isValidModeId(mode_id)) {
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
if (mode_id == current_mode_id_) {
@@ -429,7 +433,7 @@
}
std::pair<WifiStatus, uint32_t> WifiChip::getModeInternal() {
- if (current_mode_id_ == kInvalidModeId) {
+ if (!isValidModeId(current_mode_id_)) {
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE),
current_mode_id_};
}
@@ -497,40 +501,43 @@
}
std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::createApIfaceInternal() {
- if (current_mode_id_ != kApChipModeId || ap_iface_.get()) {
+ if (!canCurrentModeSupportIfaceOfType(IfaceType::AP)) {
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
- std::string ifname = getWlan0IfaceName();
- ap_iface_ = new WifiApIface(ifname, legacy_hal_);
+ std::string ifname = allocateApOrStaIfaceName();
+ sp<WifiApIface> iface = new WifiApIface(ifname, legacy_hal_);
+ ap_ifaces_.push_back(iface);
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onIfaceAdded(IfaceType::AP, ifname).isOk()) {
LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
}
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), iface};
}
std::pair<WifiStatus, std::vector<hidl_string>>
WifiChip::getApIfaceNamesInternal() {
- if (!ap_iface_.get()) {
+ if (ap_ifaces_.empty()) {
return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), {getWlan0IfaceName()}};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), getNames(ap_ifaces_)};
}
std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::getApIfaceInternal(
const std::string& ifname) {
- if (!ap_iface_.get() || (ifname != getWlan0IfaceName())) {
+ const auto iface = findUsingName(ap_ifaces_, ifname);
+ if (!iface.get()) {
return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), iface};
}
WifiStatus WifiChip::removeApIfaceInternal(const std::string& ifname) {
- if (!ap_iface_.get() || (ifname != getWlan0IfaceName())) {
+ const auto iface = findUsingName(ap_ifaces_, ifname);
+ if (!iface.get()) {
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
- invalidateAndClear(ap_iface_);
+ invalidateAndClear(ap_ifaces_, iface);
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onIfaceRemoved(IfaceType::AP, ifname).isOk()) {
LOG(ERROR) << "Failed to invoke onIfaceRemoved callback";
@@ -540,46 +547,44 @@
}
std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::createNanIfaceInternal() {
- // Only 1 of NAN or P2P iface can be active at a time.
- if (WifiFeatureFlags::wifiHidlFeatureAware) {
- if (current_mode_id_ != kStaChipModeId || nan_iface_.get() ||
- p2p_iface_.get()) {
- return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
- }
- std::string ifname = getWlan0IfaceName();
- nan_iface_ = new WifiNanIface(ifname, legacy_hal_);
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onIfaceAdded(IfaceType::NAN, ifname).isOk()) {
- LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
- }
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
- } else {
+ if (!canCurrentModeSupportIfaceOfType(IfaceType::NAN)) {
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
+ // These are still assumed to be based on wlan0.
+ std::string ifname = getWlan0IfaceName();
+ sp<WifiNanIface> iface = new WifiNanIface(ifname, legacy_hal_);
+ nan_ifaces_.push_back(iface);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onIfaceAdded(IfaceType::NAN, ifname).isOk()) {
+ LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ }
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), iface};
}
std::pair<WifiStatus, std::vector<hidl_string>>
WifiChip::getNanIfaceNamesInternal() {
- if (!nan_iface_.get()) {
+ if (nan_ifaces_.empty()) {
return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), {getWlan0IfaceName()}};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), getNames(nan_ifaces_)};
}
std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::getNanIfaceInternal(
const std::string& ifname) {
- if (!nan_iface_.get() || (ifname != getWlan0IfaceName())) {
+ const auto iface = findUsingName(nan_ifaces_, ifname);
+ if (!iface.get()) {
return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), iface};
}
WifiStatus WifiChip::removeNanIfaceInternal(const std::string& ifname) {
- if (!nan_iface_.get() || (ifname != getWlan0IfaceName())) {
+ const auto iface = findUsingName(nan_ifaces_, ifname);
+ if (!iface.get()) {
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
- invalidateAndClear(nan_iface_);
+ invalidateAndClear(nan_ifaces_, iface);
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onIfaceRemoved(IfaceType::NAN, ifname).isOk()) {
LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
@@ -589,42 +594,43 @@
}
std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::createP2pIfaceInternal() {
- // Only 1 of NAN or P2P iface can be active at a time.
- if (current_mode_id_ != kStaChipModeId || p2p_iface_.get() ||
- nan_iface_.get()) {
+ if (!canCurrentModeSupportIfaceOfType(IfaceType::P2P)) {
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
std::string ifname = getP2pIfaceName();
- p2p_iface_ = new WifiP2pIface(ifname, legacy_hal_);
+ sp<WifiP2pIface> iface = new WifiP2pIface(ifname, legacy_hal_);
+ p2p_ifaces_.push_back(iface);
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onIfaceAdded(IfaceType::P2P, ifname).isOk()) {
LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
}
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), iface};
}
std::pair<WifiStatus, std::vector<hidl_string>>
WifiChip::getP2pIfaceNamesInternal() {
- if (!p2p_iface_.get()) {
+ if (p2p_ifaces_.empty()) {
return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), {getP2pIfaceName()}};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), getNames(p2p_ifaces_)};
}
std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::getP2pIfaceInternal(
const std::string& ifname) {
- if (!p2p_iface_.get() || (ifname != getP2pIfaceName())) {
+ const auto iface = findUsingName(p2p_ifaces_, ifname);
+ if (!iface.get()) {
return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), iface};
}
WifiStatus WifiChip::removeP2pIfaceInternal(const std::string& ifname) {
- if (!p2p_iface_.get() || (ifname != getP2pIfaceName())) {
+ const auto iface = findUsingName(p2p_ifaces_, ifname);
+ if (!iface.get()) {
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
- invalidateAndClear(p2p_iface_);
+ invalidateAndClear(p2p_ifaces_, iface);
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onIfaceRemoved(IfaceType::P2P, ifname).isOk()) {
LOG(ERROR) << "Failed to invoke onIfaceRemoved callback";
@@ -634,40 +640,43 @@
}
std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::createStaIfaceInternal() {
- if (current_mode_id_ != kStaChipModeId || sta_iface_.get()) {
+ if (!canCurrentModeSupportIfaceOfType(IfaceType::STA)) {
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
- std::string ifname = getWlan0IfaceName();
- sta_iface_ = new WifiStaIface(ifname, legacy_hal_);
+ std::string ifname = allocateApOrStaIfaceName();
+ sp<WifiStaIface> iface = new WifiStaIface(ifname, legacy_hal_);
+ sta_ifaces_.push_back(iface);
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onIfaceAdded(IfaceType::STA, ifname).isOk()) {
LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
}
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), iface};
}
std::pair<WifiStatus, std::vector<hidl_string>>
WifiChip::getStaIfaceNamesInternal() {
- if (!sta_iface_.get()) {
+ if (sta_ifaces_.empty()) {
return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), {getWlan0IfaceName()}};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), getNames(sta_ifaces_)};
}
std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::getStaIfaceInternal(
const std::string& ifname) {
- if (!sta_iface_.get() || (ifname != getWlan0IfaceName())) {
+ const auto iface = findUsingName(sta_ifaces_, ifname);
+ if (!iface.get()) {
return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
}
- return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), iface};
}
WifiStatus WifiChip::removeStaIfaceInternal(const std::string& ifname) {
- if (!sta_iface_.get() || (ifname != getWlan0IfaceName())) {
+ const auto iface = findUsingName(sta_ifaces_, ifname);
+ if (!iface.get()) {
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
- invalidateAndClear(sta_iface_);
+ invalidateAndClear(sta_ifaces_, iface);
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onIfaceRemoved(IfaceType::STA, ifname).isOk()) {
LOG(ERROR) << "Failed to invoke onIfaceRemoved callback";
@@ -801,7 +810,7 @@
ChipModeId mode_id) {
// If the chip is already configured in a different mode, stop
// the legacy HAL and then start it after firmware mode change.
- if (current_mode_id_ != kInvalidModeId) {
+ if (isValidModeId(current_mode_id_)) {
LOG(INFO) << "Reconfiguring chip from mode " << current_mode_id_
<< " to mode " << mode_id;
invalidateAndRemoveAllIfaces();
@@ -813,10 +822,11 @@
return createWifiStatusFromLegacyError(legacy_status);
}
}
- bool success;
- if (mode_id == kStaChipModeId) {
+ // Firmware mode change not needed for V2 devices.
+ bool success = true;
+ if (mode_id == kV1StaChipModeId) {
success = mode_controller_.lock()->changeFirmwareMode(IfaceType::STA);
- } else {
+ } else if (mode_id == kV1ApChipModeId) {
success = mode_controller_.lock()->changeFirmwareMode(IfaceType::AP);
}
if (!success) {
@@ -871,6 +881,204 @@
return createWifiStatusFromLegacyError(legacy_status);
}
+void WifiChip::populateModes() {
+ // The chip combination supported for current devices is fixed.
+ // They can be one of the following based on device features:
+ // a) 2 separate modes of operation with 1 interface combination each:
+ // Mode 1 (STA mode): Will support 1 STA and 1 P2P or NAN(optional)
+ // concurrent iface operations.
+ // Mode 2 (AP mode): Will support 1 AP iface operation.
+ //
+ // b) 1 mode of operation with 2 interface combinations
+ // (conditional on isDualInterfaceSupported()):
+ // Interface Combination 1: Will support 1 STA and 1 P2P or NAN(optional)
+ // concurrent iface operations.
+ // Interface Combination 2: Will support 1 STA and 1 STA or AP concurrent
+ // iface operations.
+ // If Aware is enabled (conditional on isAwareSupported()), the iface
+ // combination will be modified to support either P2P or NAN in place of
+ // just P2P.
+ if (feature_flags_.lock()->isDualInterfaceSupported()) {
+ // V2 Iface combinations for Mode Id = 2.
+ const IWifiChip::ChipIfaceCombinationLimit
+ chip_iface_combination_limit_1 = {{IfaceType::STA}, 1};
+ const IWifiChip::ChipIfaceCombinationLimit
+ chip_iface_combination_limit_2 = {{IfaceType::STA, IfaceType::AP},
+ 1};
+ IWifiChip::ChipIfaceCombinationLimit chip_iface_combination_limit_3;
+ if (feature_flags_.lock()->isAwareSupported()) {
+ chip_iface_combination_limit_3 = {{IfaceType::P2P, IfaceType::NAN},
+ 1};
+ } else {
+ chip_iface_combination_limit_3 = {{IfaceType::P2P}, 1};
+ }
+ const IWifiChip::ChipIfaceCombination chip_iface_combination_1 = {
+ {chip_iface_combination_limit_1, chip_iface_combination_limit_2}};
+ const IWifiChip::ChipIfaceCombination chip_iface_combination_2 = {
+ {chip_iface_combination_limit_1, chip_iface_combination_limit_3}};
+ const IWifiChip::ChipMode chip_mode = {
+ kV2ChipModeId,
+ {chip_iface_combination_1, chip_iface_combination_2}};
+ modes_ = {chip_mode};
+ } else {
+ // V1 Iface combinations for Mode Id = 0. (STA Mode)
+ const IWifiChip::ChipIfaceCombinationLimit
+ sta_chip_iface_combination_limit_1 = {{IfaceType::STA}, 1};
+ IWifiChip::ChipIfaceCombinationLimit sta_chip_iface_combination_limit_2;
+ if (feature_flags_.lock()->isAwareSupported()) {
+ sta_chip_iface_combination_limit_2 = {
+ {IfaceType::P2P, IfaceType::NAN}, 1};
+ } else {
+ sta_chip_iface_combination_limit_2 = {{IfaceType::P2P}, 1};
+ }
+ const IWifiChip::ChipIfaceCombination sta_chip_iface_combination = {
+ {sta_chip_iface_combination_limit_1,
+ sta_chip_iface_combination_limit_2}};
+ const IWifiChip::ChipMode sta_chip_mode = {
+ kV1StaChipModeId, {sta_chip_iface_combination}};
+ // Iface combinations for Mode Id = 1. (AP Mode)
+ const IWifiChip::ChipIfaceCombinationLimit
+ ap_chip_iface_combination_limit = {{IfaceType::AP}, 1};
+ const IWifiChip::ChipIfaceCombination ap_chip_iface_combination = {
+ {ap_chip_iface_combination_limit}};
+ const IWifiChip::ChipMode ap_chip_mode = {kV1ApChipModeId,
+ {ap_chip_iface_combination}};
+ modes_ = {sta_chip_mode, ap_chip_mode};
+ }
+}
+
+std::vector<IWifiChip::ChipIfaceCombination>
+WifiChip::getCurrentModeIfaceCombinations() {
+ if (!isValidModeId(current_mode_id_)) {
+ LOG(ERROR) << "Chip not configured in a mode yet";
+ return {};
+ }
+ for (const auto& mode : modes_) {
+ if (mode.id == current_mode_id_) {
+ return mode.availableCombinations;
+ }
+ }
+ CHECK(0) << "Expected to find iface combinations for current mode!";
+ return {};
+}
+
+// Returns a map indexed by IfaceType with the number of ifaces currently
+// created of the corresponding type.
+std::map<IfaceType, size_t> WifiChip::getCurrentIfaceCombination() {
+ std::map<IfaceType, size_t> iface_counts;
+ iface_counts[IfaceType::AP] = ap_ifaces_.size();
+ iface_counts[IfaceType::NAN] = nan_ifaces_.size();
+ iface_counts[IfaceType::P2P] = p2p_ifaces_.size();
+ iface_counts[IfaceType::STA] = sta_ifaces_.size();
+ return iface_counts;
+}
+
+// This expands the provided iface combinations to a more parseable
+// form. Returns a vector of available combinations possible with the number
+// of ifaces of each type in the combination.
+// This method is a port of HalDeviceManager.expandIfaceCombos() from framework.
+std::vector<std::map<IfaceType, size_t>> WifiChip::expandIfaceCombinations(
+ const IWifiChip::ChipIfaceCombination& combination) {
+ uint32_t num_expanded_combos = 1;
+ for (const auto& limit : combination.limits) {
+ for (uint32_t i = 0; i < limit.maxIfaces; i++) {
+ num_expanded_combos *= limit.types.size();
+ }
+ }
+
+ // Allocate the vector of expanded combos and reset all iface counts to 0
+ // in each combo.
+ std::vector<std::map<IfaceType, size_t>> expanded_combos;
+ expanded_combos.resize(num_expanded_combos);
+ for (auto& expanded_combo : expanded_combos) {
+ for (const auto type :
+ {IfaceType::AP, IfaceType::NAN, IfaceType::P2P, IfaceType::STA}) {
+ expanded_combo[type] = 0;
+ }
+ }
+ uint32_t span = num_expanded_combos;
+ for (const auto& limit : combination.limits) {
+ for (uint32_t i = 0; i < limit.maxIfaces; i++) {
+ span /= limit.types.size();
+ for (uint32_t k = 0; k < num_expanded_combos; ++k) {
+ const auto iface_type =
+ limit.types[(k / span) % limit.types.size()];
+ expanded_combos[k][iface_type]++;
+ }
+ }
+ }
+ return expanded_combos;
+}
+
+bool WifiChip::canExpandedIfaceCombinationSupportIfaceOfType(
+ const std::map<IfaceType, size_t>& combo, IfaceType requested_type) {
+ const auto current_combo = getCurrentIfaceCombination();
+
+ // Check if we have space for 1 more iface of |type| in this combo
+ for (const auto type :
+ {IfaceType::AP, IfaceType::NAN, IfaceType::P2P, IfaceType::STA}) {
+ size_t num_ifaces_needed = current_combo.at(type);
+ if (type == requested_type) {
+ num_ifaces_needed++;
+ }
+ size_t num_ifaces_allowed = combo.at(type);
+ if (num_ifaces_needed > num_ifaces_allowed) {
+ return false;
+ }
+ }
+ return true;
+}
+
+// This method does the following:
+// a) Enumerate all possible iface combos by expanding the current
+// ChipIfaceCombination.
+// b) Check if the requested iface type can be added to the current mode.
+bool WifiChip::canCurrentModeSupportIfaceOfType(IfaceType type) {
+ if (!isValidModeId(current_mode_id_)) {
+ LOG(ERROR) << "Chip not configured in a mode yet";
+ return false;
+ }
+ const auto combinations = getCurrentModeIfaceCombinations();
+ for (const auto& combination : combinations) {
+ const auto expanded_combos = expandIfaceCombinations(combination);
+ for (const auto& expanded_combo : expanded_combos) {
+ if (canExpandedIfaceCombinationSupportIfaceOfType(expanded_combo,
+ type)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool WifiChip::isValidModeId(ChipModeId mode_id) {
+ for (const auto& mode : modes_) {
+ if (mode.id == mode_id) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Return "wlan0", if "wlan0" is not already in use, else return "wlan1".
+// This is based on the assumption that we'll have a max of 2 concurrent
+// AP/STA ifaces.
+std::string WifiChip::allocateApOrStaIfaceName() {
+ auto ap_iface = findUsingName(ap_ifaces_, getWlan0IfaceName());
+ auto sta_iface = findUsingName(sta_ifaces_, getWlan0IfaceName());
+ if (!ap_iface.get() && !sta_iface.get()) {
+ return getWlan0IfaceName();
+ }
+ ap_iface = findUsingName(ap_ifaces_, getWlan1IfaceName());
+ sta_iface = findUsingName(sta_ifaces_, getWlan1IfaceName());
+ if (!ap_iface.get() && !sta_iface.get()) {
+ return getWlan1IfaceName();
+ }
+ // This should never happen. We screwed up somewhere if it did.
+ CHECK(0) << "wlan0 and wlan1 in use already!";
+ return {};
+}
+
} // namespace implementation
} // namespace V1_2
} // namespace wifi
diff --git a/wifi/1.2/default/wifi_chip.h b/wifi/1.2/default/wifi_chip.h
index ac59d59..97c434e 100644
--- a/wifi/1.2/default/wifi_chip.h
+++ b/wifi/1.2/default/wifi_chip.h
@@ -24,6 +24,7 @@
#include "hidl_callback_util.h"
#include "wifi_ap_iface.h"
+#include "wifi_feature_flags.h"
#include "wifi_legacy_hal.h"
#include "wifi_mode_controller.h"
#include "wifi_nan_iface.h"
@@ -45,10 +46,12 @@
*/
class WifiChip : public V1_1::IWifiChip {
public:
- WifiChip(ChipId chip_id,
- const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
- const std::weak_ptr<mode_controller::WifiModeController>
- mode_controller);
+ WifiChip(
+ ChipId chip_id,
+ const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
+ const std::weak_ptr<mode_controller::WifiModeController>
+ mode_controller,
+ const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags);
// HIDL does not provide a built-in mechanism to let the server invalidate
// a HIDL interface object after creation. If any client process holds onto
// a reference to the object in their context, any method calls on that
@@ -190,16 +193,31 @@
std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);
WifiStatus registerDebugRingBufferCallback();
+ void populateModes();
+ std::vector<IWifiChip::ChipIfaceCombination>
+ getCurrentModeIfaceCombinations();
+ std::map<IfaceType, size_t> getCurrentIfaceCombination();
+ std::vector<std::map<IfaceType, size_t>> expandIfaceCombinations(
+ const IWifiChip::ChipIfaceCombination& combination);
+ bool canExpandedIfaceCombinationSupportIfaceOfType(
+ const std::map<IfaceType, size_t>& combo, IfaceType type);
+ bool canCurrentModeSupportIfaceOfType(IfaceType type);
+ bool isValidModeId(ChipModeId mode_id);
+ std::string allocateApOrStaIfaceName();
+
ChipId chip_id_;
std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
std::weak_ptr<mode_controller::WifiModeController> mode_controller_;
- sp<WifiApIface> ap_iface_;
- sp<WifiNanIface> nan_iface_;
- sp<WifiP2pIface> p2p_iface_;
- sp<WifiStaIface> sta_iface_;
+ std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags_;
+ std::vector<sp<WifiApIface>> ap_ifaces_;
+ std::vector<sp<WifiNanIface>> nan_ifaces_;
+ std::vector<sp<WifiP2pIface>> p2p_ifaces_;
+ std::vector<sp<WifiStaIface>> sta_ifaces_;
std::vector<sp<WifiRttController>> rtt_controllers_;
bool is_valid_;
+ // Members pertaining to chip configuration.
uint32_t current_mode_id_;
+ std::vector<IWifiChip::ChipMode> modes_;
// The legacy ring buffer callback API has only a global callback
// registration mechanism. Use this to check if we have already
// registered a callback.
diff --git a/wifi/1.2/default/wifi_feature_flags.cpp b/wifi/1.2/default/wifi_feature_flags.cpp
new file mode 100644
index 0000000..554d4d5
--- /dev/null
+++ b/wifi/1.2/default/wifi_feature_flags.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi_feature_flags.h"
+
+namespace {
+#ifdef WIFI_HIDL_FEATURE_AWARE
+static const bool wifiHidlFeatureAware = true;
+#else
+static const bool wifiHidlFeatureAware = false;
+#endif // WIFI_HIDL_FEATURE_AWARE
+#ifdef WIFI_HIDL_FEATURE_DUAL_INTERFACE
+static const bool wifiHidlFeatureDualInterface = true;
+#else
+static const bool wifiHidlFeatureDualInterface = false;
+#endif // WIFI_HIDL_FEATURE_DUAL_INTERFACE
+} // namespace
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_2 {
+namespace implementation {
+namespace feature_flags {
+
+WifiFeatureFlags::WifiFeatureFlags() {}
+bool WifiFeatureFlags::isAwareSupported() { return wifiHidlFeatureAware; }
+bool WifiFeatureFlags::isDualInterfaceSupported() {
+ return wifiHidlFeatureDualInterface;
+}
+
+} // namespace feature_flags
+} // namespace implementation
+} // namespace V1_2
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.2/default/wifi_feature_flags.h b/wifi/1.2/default/wifi_feature_flags.h
index da4ca37..dc0c1ff 100644
--- a/wifi/1.2/default/wifi_feature_flags.h
+++ b/wifi/1.2/default/wifi_feature_flags.h
@@ -22,16 +22,18 @@
namespace wifi {
namespace V1_2 {
namespace implementation {
+namespace feature_flags {
class WifiFeatureFlags {
public:
-#ifdef WIFI_HIDL_FEATURE_AWARE
- static const bool wifiHidlFeatureAware = true;
-#else
- static const bool wifiHidlFeatureAware = false;
-#endif // WIFI_HIDL_FEATURE_AWARE
+ WifiFeatureFlags();
+ virtual ~WifiFeatureFlags() = default;
+
+ virtual bool isAwareSupported();
+ virtual bool isDualInterfaceSupported();
};
+} // namespace feature_flags
} // namespace implementation
} // namespace V1_2
} // namespace wifi
diff --git a/wifi/1.2/default/wifi_legacy_hal.cpp b/wifi/1.2/default/wifi_legacy_hal.cpp
index 24b80d5..9abe514 100644
--- a/wifi/1.2/default/wifi_legacy_hal.cpp
+++ b/wifi/1.2/default/wifi_legacy_hal.cpp
@@ -455,7 +455,7 @@
const std::string& iface_name) {
feature_set set;
static_assert(sizeof(set) == sizeof(uint32_t),
- "Some features can not be represented in output");
+ "Some feature_flags can not be represented in output");
wifi_error status = global_func_table_.wifi_get_supported_feature_set(
getIfaceHandle(iface_name), &set);
return {status, static_cast<uint32_t>(set)};
@@ -759,11 +759,11 @@
std::pair<wifi_error, uint32_t> WifiLegacyHal::getLoggerSupportedFeatureSet(
const std::string& iface_name) {
- uint32_t supported_features;
+ uint32_t supported_feature_flags;
wifi_error status =
global_func_table_.wifi_get_logger_supported_feature_set(
- getIfaceHandle(iface_name), &supported_features);
- return {status, supported_features};
+ getIfaceHandle(iface_name), &supported_feature_flags);
+ return {status, supported_feature_flags};
}
wifi_error WifiLegacyHal::startPktFateMonitoring(
diff --git a/wifi/1.2/default/wifi_legacy_hal.h b/wifi/1.2/default/wifi_legacy_hal.h
index 05f700e..da88f6b 100644
--- a/wifi/1.2/default/wifi_legacy_hal.h
+++ b/wifi/1.2/default/wifi_legacy_hal.h
@@ -142,15 +142,16 @@
class WifiLegacyHal {
public:
WifiLegacyHal();
+ virtual ~WifiLegacyHal() = default;
// Initialize the legacy HAL function table.
- wifi_error initialize();
+ virtual wifi_error initialize();
// Start the legacy HAL and the event looper thread.
- wifi_error start();
+ virtual wifi_error start();
// Deinitialize the legacy HAL and wait for the event loop thread to exit
// using a predefined timeout.
- wifi_error stop(std::unique_lock<std::recursive_mutex>* lock,
- const std::function<void()>& on_complete_callback);
+ virtual wifi_error stop(std::unique_lock<std::recursive_mutex>* lock,
+ const std::function<void()>& on_complete_callback);
// Wrappers for all the functions in the legacy HAL function table.
std::pair<wifi_error, std::string> getDriverVersion(
const std::string& iface_name);
@@ -190,7 +191,7 @@
wifi_error stopGscan(const std::string& iface_name, wifi_request_id id);
std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForBand(
const std::string& iface_name, wifi_band band);
- wifi_error setDfsFlag(const std::string& iface_name, bool dfs_on);
+ virtual wifi_error setDfsFlag(const std::string& iface_name, bool dfs_on);
// Link layer stats functions.
wifi_error enableLinkLayerStats(const std::string& iface_name, bool debug);
wifi_error disableLinkLayerStats(const std::string& iface_name);
@@ -276,12 +277,12 @@
wifi_error setRttLcr(const std::string& iface_name, wifi_request_id id,
const wifi_lcr_information& info);
// NAN functions.
- wifi_error nanRegisterCallbackHandlers(
+ virtual wifi_error nanRegisterCallbackHandlers(
const std::string& iface_name, const NanCallbackHandlers& callbacks);
wifi_error nanEnableRequest(const std::string& iface_name,
transaction_id id, const NanEnableRequest& msg);
- wifi_error nanDisableRequest(const std::string& iface_name,
- transaction_id id);
+ virtual wifi_error nanDisableRequest(const std::string& iface_name,
+ transaction_id id);
wifi_error nanPublishRequest(const std::string& iface_name,
transaction_id id,
const NanPublishRequest& msg);
@@ -312,9 +313,9 @@
wifi_error nanDataInterfaceCreate(const std::string& iface_name,
transaction_id id,
const std::string& data_iface_name);
- wifi_error nanDataInterfaceDelete(const std::string& iface_name,
- transaction_id id,
- const std::string& data_iface_name);
+ virtual wifi_error nanDataInterfaceDelete(
+ const std::string& iface_name, transaction_id id,
+ const std::string& data_iface_name);
wifi_error nanDataRequestInitiator(const std::string& iface_name,
transaction_id id,
const NanDataPathInitiatorRequest& msg);
diff --git a/wifi/1.2/default/wifi_mode_controller.cpp b/wifi/1.2/default/wifi_mode_controller.cpp
index 8a89e81..c286d24 100644
--- a/wifi/1.2/default/wifi_mode_controller.cpp
+++ b/wifi/1.2/default/wifi_mode_controller.cpp
@@ -59,11 +59,15 @@
convertIfaceTypeToFirmwareMode(type));
}
-bool WifiModeController::changeFirmwareMode(IfaceType type) {
+bool WifiModeController::initialize() {
if (!driver_tool_->LoadDriver()) {
LOG(ERROR) << "Failed to load WiFi driver";
return false;
}
+ return true;
+}
+
+bool WifiModeController::changeFirmwareMode(IfaceType type) {
if (!driver_tool_->ChangeFirmwareMode(
convertIfaceTypeToFirmwareMode(type))) {
LOG(ERROR) << "Failed to change firmware mode";
diff --git a/wifi/1.2/default/wifi_mode_controller.h b/wifi/1.2/default/wifi_mode_controller.h
index 839bf9e..395aa5d 100644
--- a/wifi/1.2/default/wifi_mode_controller.h
+++ b/wifi/1.2/default/wifi_mode_controller.h
@@ -37,15 +37,17 @@
class WifiModeController {
public:
WifiModeController();
+ virtual ~WifiModeController() = default;
// Checks if a firmware mode change is necessary to support the specified
// iface type operations.
- bool isFirmwareModeChangeNeeded(IfaceType type);
+ virtual bool isFirmwareModeChangeNeeded(IfaceType type);
+ virtual bool initialize();
// Change the firmware mode to support the specified iface type operations.
- bool changeFirmwareMode(IfaceType type);
+ virtual bool changeFirmwareMode(IfaceType type);
// Unload the driver. This should be invoked whenever |IWifi.stop()| is
// invoked.
- bool deinitialize();
+ virtual bool deinitialize();
private:
std::unique_ptr<wifi_hal::DriverTool> driver_tool_;
diff --git a/wifi/1.2/default/wifi_nan_iface.cpp b/wifi/1.2/default/wifi_nan_iface.cpp
index e7bbfaa..12e4d7b 100644
--- a/wifi/1.2/default/wifi_nan_iface.cpp
+++ b/wifi/1.2/default/wifi_nan_iface.cpp
@@ -494,6 +494,8 @@
bool WifiNanIface::isValid() { return is_valid_; }
+std::string WifiNanIface::getName() { return ifname_; }
+
std::set<sp<IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks() {
return event_cb_handler_.getCallbacks();
}
diff --git a/wifi/1.2/default/wifi_nan_iface.h b/wifi/1.2/default/wifi_nan_iface.h
index 2ca2e45..6fa7b0c 100644
--- a/wifi/1.2/default/wifi_nan_iface.h
+++ b/wifi/1.2/default/wifi_nan_iface.h
@@ -41,6 +41,7 @@
// Refer to |WifiChip::invalidate()|.
void invalidate();
bool isValid();
+ std::string getName();
// HIDL methods exposed.
Return<void> getName(getName_cb hidl_status_cb) override;
diff --git a/wifi/1.2/default/wifi_p2p_iface.cpp b/wifi/1.2/default/wifi_p2p_iface.cpp
index f1fbf2c..92bbaee 100644
--- a/wifi/1.2/default/wifi_p2p_iface.cpp
+++ b/wifi/1.2/default/wifi_p2p_iface.cpp
@@ -39,6 +39,8 @@
bool WifiP2pIface::isValid() { return is_valid_; }
+std::string WifiP2pIface::getName() { return ifname_; }
+
Return<void> WifiP2pIface::getName(getName_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
&WifiP2pIface::getNameInternal, hidl_status_cb);
diff --git a/wifi/1.2/default/wifi_p2p_iface.h b/wifi/1.2/default/wifi_p2p_iface.h
index 839d3c3..76120b1 100644
--- a/wifi/1.2/default/wifi_p2p_iface.h
+++ b/wifi/1.2/default/wifi_p2p_iface.h
@@ -39,6 +39,7 @@
// Refer to |WifiChip::invalidate()|.
void invalidate();
bool isValid();
+ std::string getName();
// HIDL methods exposed.
Return<void> getName(getName_cb hidl_status_cb) override;
diff --git a/wifi/1.2/default/wifi_sta_iface.cpp b/wifi/1.2/default/wifi_sta_iface.cpp
index c8605ee..6faf009 100644
--- a/wifi/1.2/default/wifi_sta_iface.cpp
+++ b/wifi/1.2/default/wifi_sta_iface.cpp
@@ -49,6 +49,8 @@
bool WifiStaIface::isValid() { return is_valid_; }
+std::string WifiStaIface::getName() { return ifname_; }
+
std::set<sp<IWifiStaIfaceEventCallback>> WifiStaIface::getEventCallbacks() {
return event_cb_handler_.getCallbacks();
}
diff --git a/wifi/1.2/default/wifi_sta_iface.h b/wifi/1.2/default/wifi_sta_iface.h
index 6731864..423365c 100644
--- a/wifi/1.2/default/wifi_sta_iface.h
+++ b/wifi/1.2/default/wifi_sta_iface.h
@@ -42,6 +42,7 @@
void invalidate();
bool isValid();
std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks();
+ std::string getName();
// HIDL methods exposed.
Return<void> getName(getName_cb hidl_status_cb) override;