summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-07-15 01:38:17 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-07-15 01:38:17 +0000
commit2da180ef5adc7b04801ec503ea589cfa8e8e25b5 (patch)
tree83c86860f4ba35032370bce3c9874ad024870bf9
parent22f705057482747bd4b7c5f3e9d60a12a4558257 (diff)
parent9afe37add5704e833d4c0edf3dbd3909f52ea330 (diff)
downloadlibhardware_legacy-android12-mainline-tethering-release.tar.gz
Change-Id: I094d42e1424b59102e7c2b7acc4ce41ba71a2e2f
-rw-r--r--Android.bp19
-rw-r--r--METADATA3
-rw-r--r--MODULE_LICENSE_APACHE20
-rw-r--r--audio/Android.bp9
-rw-r--r--audio/audio_hw_hal.cpp14
-rw-r--r--block_suspend.cpp10
-rw-r--r--include/hardware_legacy/AudioSystemLegacy.h5
-rw-r--r--include/hardware_legacy/link_layer_stats.h28
-rw-r--r--include/hardware_legacy/wifi_config.h2
-rw-r--r--include/hardware_legacy/wifi_hal.h395
-rw-r--r--include/hardware_legacy/wifi_logger.h1
-rw-r--r--include/hardware_legacy/wifi_nan.h15
-rw-r--r--include/hardware_legacy/wifi_twt.h156
-rw-r--r--include/wakelock/wakelock.h13
-rw-r--r--power.cpp29
-rw-r--r--power_test.cpp21
16 files changed, 656 insertions, 64 deletions
diff --git a/Android.bp b/Android.bp
index d196ee6..c10cff3 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,5 +1,22 @@
// Copyright 2006 The Android Open Source Project
+package {
+ default_applicable_licenses: ["hardware_libhardware_legacy_license"],
+}
+
+// Added automatically by a large-scale-change
+// See: http://go/android-license-faq
+license {
+ name: "hardware_libhardware_legacy_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-Apache-2.0",
+ ],
+ license_text: [
+ "NOTICE",
+ ],
+}
+
cc_library_headers {
name: "libhardware_legacy_headers",
vendor_available: true,
@@ -36,8 +53,8 @@ cc_test {
srcs: ["power_test.cpp"],
static_libs: ["libpower"],
shared_libs: [
+ "android.system.suspend.control.internal-cpp",
"android.system.suspend@1.0",
- "suspend_control_aidl_interface-cpp",
],
test_suites: ["device-tests"],
require_root: true,
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..d97975c
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,3 @@
+third_party {
+ license_type: NOTICE
+}
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/audio/Android.bp b/audio/Android.bp
index b4c0799..5695e84 100644
--- a/audio/Android.bp
+++ b/audio/Android.bp
@@ -3,6 +3,15 @@
//AUDIO_POLICY_TEST := true
//ENABLE_AUDIO_DUMP := true
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_libhardware_legacy_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_libhardware_legacy_license"],
+}
+
cc_library_static {
srcs: [
diff --git a/audio/audio_hw_hal.cpp b/audio/audio_hw_hal.cpp
index d15044a..6ea05fd 100644
--- a/audio/audio_hw_hal.cpp
+++ b/audio/audio_hw_hal.cpp
@@ -90,10 +90,10 @@ static uint32_t audio_device_conv_table[][HAL_API_REV_NUM] =
{ AudioSystem::DEVICE_IN_DEFAULT, AUDIO_DEVICE_IN_DEFAULT },
};
-static uint32_t convert_audio_device(uint32_t from_device, int from_rev, int to_rev)
+static audio_devices_t convert_audio_device(uint32_t from_device, int from_rev, int to_rev)
{
const uint32_t k_num_devices = sizeof(audio_device_conv_table)/sizeof(uint32_t)/HAL_API_REV_NUM;
- uint32_t to_device = AUDIO_DEVICE_NONE;
+ audio_devices_t to_device = AUDIO_DEVICE_NONE;
uint32_t in_bit = 0;
if (from_rev != HAL_API_REV_1_0) {
@@ -107,7 +107,7 @@ static uint32_t convert_audio_device(uint32_t from_device, int from_rev, int to_
for (i = 0; i < k_num_devices; i++) {
if (audio_device_conv_table[i][from_rev] == cur_device) {
- to_device |= audio_device_conv_table[i][to_rev];
+ to_device = (audio_devices_t)(to_device | audio_device_conv_table[i][to_rev]);
break;
}
}
@@ -504,14 +504,16 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
devices = convert_audio_device(devices, HAL_API_REV_2_0, HAL_API_REV_1_0);
+ uint32_t raw_channel_mask = config->channel_mask;
out->legacy_out = ladev->hwif->openOutputStreamWithFlags(devices, flags,
(int *) &config->format,
- &config->channel_mask,
+ &raw_channel_mask,
&config->sample_rate, &status);
if (!out->legacy_out) {
ret = status;
goto err_open;
}
+ config->channel_mask = (audio_channel_mask_t)raw_channel_mask;
out->stream.common.get_sample_rate = out_get_sample_rate;
out->stream.common.set_sample_rate = out_set_sample_rate;
@@ -571,13 +573,15 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
devices = convert_audio_device(devices, HAL_API_REV_2_0, HAL_API_REV_1_0);
+ uint32_t raw_channel_mask = config->channel_mask;
in->legacy_in = ladev->hwif->openInputStream(devices, (int *) &config->format,
- &config->channel_mask, &config->sample_rate,
+ &raw_channel_mask, &config->sample_rate,
&status, (AudioSystem::audio_in_acoustics)0);
if (!in->legacy_in) {
ret = status;
goto err_open;
}
+ config->channel_mask = (audio_channel_mask_t)raw_channel_mask;
in->stream.common.get_sample_rate = in_get_sample_rate;
in->stream.common.set_sample_rate = in_set_sample_rate;
diff --git a/block_suspend.cpp b/block_suspend.cpp
index 99341b8..d780904 100644
--- a/block_suspend.cpp
+++ b/block_suspend.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include <unistd.h>
+
#include <iostream>
#include <wakelock/wakelock.h>
@@ -32,8 +34,12 @@ int main(int argc, char ** /* argv */) {
return 0;
}
- android::wakelock::WakeLock wl{gWakeLockName}; // RAII object
- while (true) {};
+ auto wl = android::wakelock::WakeLock::tryGet(gWakeLockName); // RAII object
+ if (!wl.has_value()) {
+ return EXIT_FAILURE;
+ }
+
+ while (true) { sleep(1000000); };
std::abort(); // should never reach here
return 0;
}
diff --git a/include/hardware_legacy/AudioSystemLegacy.h b/include/hardware_legacy/AudioSystemLegacy.h
index 8227037..0bec0f2 100644
--- a/include/hardware_legacy/AudioSystemLegacy.h
+++ b/include/hardware_legacy/AudioSystemLegacy.h
@@ -17,6 +17,7 @@
#ifndef ANDROID_AUDIOSYSTEM_LEGACY_H_
#define ANDROID_AUDIOSYSTEM_LEGACY_H_
+#include <cutils/bitops.h>
#include <utils/Errors.h>
#include <media/AudioParameter.h>
@@ -344,10 +345,10 @@ public:
static bool isLinearPCM(uint32_t format) {
return audio_is_linear_pcm((audio_format_t) format);
}
- static bool isOutputChannel(uint32_t channel) {
+ static bool isOutputChannel(audio_channel_mask_t channel) {
return audio_is_output_channel(channel);
}
- static bool isInputChannel(uint32_t channel) {
+ static bool isInputChannel(audio_channel_mask_t channel) {
return audio_is_input_channel(channel);
}
diff --git a/include/hardware_legacy/link_layer_stats.h b/include/hardware_legacy/link_layer_stats.h
index 7a43230..9b67f6d 100644
--- a/include/hardware_legacy/link_layer_stats.h
+++ b/include/hardware_legacy/link_layer_stats.h
@@ -34,6 +34,7 @@ typedef enum {
WIFI_INTERFACE_P2P_GO = 4,
WIFI_INTERFACE_NAN = 5,
WIFI_INTERFACE_MESH = 6,
+ WIFI_INTERFACE_TDLS = 7,
WIFI_INTERFACE_UNKNOWN = -1
} wifi_interface_mode;
@@ -45,15 +46,17 @@ typedef enum {
#define WIFI_CAPABILITY_COUNTRY 0x00000020 // set is 802.11 Country Element is present
typedef struct {
- wifi_interface_mode mode; // interface mode
- u8 mac_addr[6]; // interface mac address (self)
- wifi_connection_state state; // connection state (valid for STA, CLI only)
- wifi_roam_state roaming; // roaming state
- u32 capabilities; // WIFI_CAPABILITY_XXX (self)
- u8 ssid[33]; // null terminated SSID
- u8 bssid[6]; // bssid
- u8 ap_country_str[3]; // country string advertised by AP
- u8 country_str[3]; // country string for this association
+ wifi_interface_mode mode; // interface mode
+ u8 mac_addr[6]; // interface mac address (self)
+ wifi_connection_state state; // connection state (valid for STA, CLI only)
+ wifi_roam_state roaming; // roaming state
+ u32 capabilities; // WIFI_CAPABILITY_XXX (self)
+ u8 ssid[33]; // null terminated SSID
+ u8 bssid[6]; // bssid
+ u8 ap_country_str[3]; // country string advertised by AP
+ u8 country_str[3]; // country string for this association
+ u8 time_slicing_duty_cycle_percent;// if this iface is being served using time slicing on a radio with one or more ifaces (i.e MCC), then the duty cycle assigned to this iface in %.
+ // If not using time slicing (i.e SCC or DBS), set to 100.
} wifi_interface_link_layer_info;
/* channel information */
@@ -158,10 +161,17 @@ typedef enum
} wifi_peer_type;
/* per peer statistics */
+typedef struct bssload_info {
+ u16 sta_count; // station count
+ u16 chan_util; // channel utilization
+ u8 PAD[4];
+} bssload_info_t;
+
typedef struct {
wifi_peer_type type; // peer type (AP, TDLS, GO etc.)
u8 peer_mac_address[6]; // mac address
u32 capabilities; // peer WIFI_CAPABILITY_XXX
+ bssload_info_t bssload; // STA count and CU
u32 num_rate; // number of rates
wifi_rate_stat rate_stats[]; // per rate statistics, number of entries = num_rate
} wifi_peer_info;
diff --git a/include/hardware_legacy/wifi_config.h b/include/hardware_legacy/wifi_config.h
index 8ad14f4..9ddf8b8 100644
--- a/include/hardware_legacy/wifi_config.h
+++ b/include/hardware_legacy/wifi_config.h
@@ -12,8 +12,6 @@ extern "C"
#define CONFIG_MINOR_VERSION 0
#define CONFIG_MICRO_VERSION 0
-typedef int wifi_radio;
-
// whether the wifi chipset wakes at every dtim beacon or a multiple of the dtim period
// if extended_dtim is set to 3, the STA shall wake up every 3 DTIM beacons
wifi_error wifi_extended_dtim_config_set(wifi_request_id id,
diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h
index 5dabeb6..81948d6 100644
--- a/include/hardware_legacy/wifi_hal.h
+++ b/include/hardware_legacy/wifi_hal.h
@@ -25,6 +25,31 @@ extern "C"
#define IFNAMSIZ 16
+/* typedefs */
+typedef unsigned char byte;
+typedef unsigned char u8;
+typedef signed char s8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef int32_t s32;
+typedef uint64_t u64;
+typedef int64_t s64;
+typedef int wifi_request_id;
+typedef int wifi_channel; // indicates channel frequency in MHz
+typedef int wifi_rssi;
+typedef int wifi_radio;
+typedef byte mac_addr[6];
+typedef byte oui[3];
+typedef int64_t wifi_timestamp; // In microseconds (us)
+typedef int64_t wifi_timespan; // In picoseconds (ps)
+typedef uint64_t feature_set;
+
+/* forward declarations */
+struct wifi_info;
+struct wifi_interface_info;
+typedef struct wifi_info *wifi_handle;
+typedef struct wifi_interface_info *wifi_interface_handle;
+
/* WiFi Common definitions */
/* channel operating width */
typedef enum {
@@ -48,6 +73,13 @@ typedef enum {
WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF = 3,
WIFI_POWER_SCENARIO_ON_BODY_CELL_ON = 4,
WIFI_POWER_SCENARIO_ON_BODY_BT = 5,
+ WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT = 6,
+ WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT_MMW = 7,
+ WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_BT = 8,
+ WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT = 9,
+ WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT = 10,
+ WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_MMW = 11,
+ WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT_MMW = 12,
} wifi_power_scenario;
typedef enum {
@@ -65,6 +97,15 @@ typedef enum {
WIFI_MITIGATION_EMERGENCY = 5,
} wifi_thermal_mode;
+/*
+ * Wifi voice over IP mode
+ * may add new modes later, for example, voice + video over IP mode.
+ */
+typedef enum {
+ WIFI_VOIP_MODE_OFF = 0,
+ WIFI_VOIP_MODE_ON = 1,
+} wifi_voip_mode;
+
/* List of interface types supported */
typedef enum {
WIFI_INTERFACE_TYPE_STA = 0,
@@ -82,12 +123,11 @@ typedef enum {
/* WLAN MAC Operates in 5 GHz Band */
WLAN_MAC_5_0_BAND = 1 << 1,
/* WLAN MAC Operates in 6 GHz Band */
- WLAN_MAC_6_0_BAND = 1 << 2
+ WLAN_MAC_6_0_BAND = 1 << 2,
+/* WLAN MAC Operates in 60 GHz Band */
+ WLAN_MAC_60_0_BAND = 1 << 3,
} wlan_mac_band;
-typedef int wifi_radio;
-typedef int wifi_channel;
-
typedef struct {
wifi_channel_width width;
int center_frequency0;
@@ -95,6 +135,53 @@ typedef struct {
int primary_frequency;
} wifi_channel_spec;
+/*
+ * wifi_usable_channel specifies a channel frequency, bandwidth, and bitmask
+ * of modes allowed on the channel.
+ */
+typedef struct {
+ /* Channel frequency in MHz */
+ wifi_channel freq;
+ /* Channel operating width (20, 40, 80, 160 etc.) */
+ wifi_channel_width width;
+ /* BIT MASK of BIT(WIFI_INTERFACE_*) represented by |wifi_interface_mode|
+ * Bitmask does not represent concurrency.
+ * Examples:
+ * - If a channel is usable only for STA, then only the WIFI_INTERFACE_STA
+ * bit would be set for that channel.
+ * - If 5GHz SAP is not allowed, then none of the 5GHz channels will have
+ * WIFI_INTERFACE_SOFTAP bit set.
+ * Note: TDLS bit is set only if there is a STA connection. TDLS bit is set
+ * on non-STA channels only if TDLS off channel is supported.
+ */
+ u32 iface_mode_mask;
+} wifi_usable_channel;
+
+/*
+ * wifi_usable_channel_filter
+ */
+typedef enum {
+ /* Filter Wifi channels that should be avoided due to cellular coex
+ * restrictions. Some Wifi channels can have extreme interference
+ * from/to cellular due to short frequency separation with neighboring
+ * cellular channels or when there is harmonic and intermodulation
+ * interference. Channels which only have some performance degradation
+ * (e.g. power back off is sufficient to deal with coexistence issue)
+ * can be included and should not be filtered out.
+ */
+ WIFI_USABLE_CHANNEL_FILTER_CELLULAR_COEXISTENCE = 1 << 0,
+ /* Filter channels due to concurrency state.
+ * Examples:
+ * - 5GHz SAP operation may be supported in standalone mode, but if
+ * there is STA connection on 5GHz DFS channel, none of the 5GHz
+ * channels are usable for SAP if device does not support DFS SAP mode.
+ * - P2P GO may not be supported on indoor channels in EU during
+ * standalone mode but if there is a STA connection on indoor channel,
+ * P2P GO may be supported by some vendors on the same STA channel.
+ */
+ WIFI_USABLE_CHANNEL_FILTER_CONCURRENCY = 1 << 1,
+} wifi_usable_channel_filter;
+
typedef enum {
WIFI_SUCCESS = 0,
WIFI_ERROR_NONE = 0,
@@ -117,26 +204,6 @@ typedef enum {
WIFI_ACCESS_CATEGORY_VOICE = 3
} wifi_access_category;
-typedef unsigned char byte;
-typedef unsigned char u8;
-typedef signed char s8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-typedef int32_t s32;
-typedef uint64_t u64;
-typedef int64_t s64;
-typedef int wifi_request_id;
-typedef int wifi_channel; // indicates channel frequency in MHz
-typedef int wifi_rssi;
-typedef byte mac_addr[6];
-typedef byte oui[3];
-typedef int64_t wifi_timestamp; // In microseconds (us)
-typedef int64_t wifi_timespan; // In picoseconds (ps)
-
-struct wifi_info;
-struct wifi_interface_info;
-typedef struct wifi_info *wifi_handle;
-typedef struct wifi_interface_info *wifi_interface_handle;
/* Initialize/Cleanup */
@@ -190,11 +257,9 @@ void wifi_get_error_info(wifi_error err, const char **msg); // return a pointer
#define WIFI_FEATURE_USE_BODY_HEAD_SAR (uint64_t)0x8000000 // Support Using Body/Head Proximity for SAR
#define WIFI_FEATURE_SET_LATENCY_MODE (uint64_t)0x40000000 // Support Latency mode setting
#define WIFI_FEATURE_P2P_RAND_MAC (uint64_t)0x80000000 // Support P2P MAC randomization
+#define WIFI_FEATURE_INFRA_60G (uint64_t)0x100000000 // Support for 60GHz Band
// Add more features here
-
-typedef uint64_t feature_set;
-
#define IS_MASK_SET(mask, flags) (((flags) & (mask)) == (mask))
#define IS_SUPPORTED_FEATURE(feature, featureSet) IS_MASK_SET(feature, featureSet)
@@ -215,6 +280,70 @@ wifi_error wifi_get_ifaces(wifi_handle handle, int *num_ifaces, wifi_interface_h
wifi_error wifi_get_iface_name(wifi_interface_handle iface, char *name, size_t size);
wifi_interface_handle wifi_get_iface_handle(wifi_handle handle, char *name);
+/* STA + STA support - Supported if WIFI_FEATURE_ADDITIONAL_STA is set */
+
+/**
+ * Invoked to indicate that the provided iface is the primary STA iface when there are more
+ * than 1 STA iface concurrently active.
+ *
+ * Note: If the wifi firmware/chip cannot support multiple instances of any offload
+ * (like roaming, APF, rssi threshold, etc), the firmware should ensure that these
+ * offloads are at least enabled for the primary interface. If the new primary interface is
+ * already connected to a network, the firmware must switch all the offloads on
+ * this new interface without disconnecting.
+ */
+wifi_error wifi_multi_sta_set_primary_connection(wifi_handle handle, wifi_interface_handle iface);
+
+/**
+ * When there are 2 or more simultaneous STA connections, this use case hint indicates what
+ * use-case is being enabled by the framework. This use case hint can be used by the firmware
+ * to modify various firmware configurations like:
+ * - Allowed BSSIDs the firmware can choose for the initial connection/roaming attempts.
+ * - Duty cycle to choose for the 2 STA connections if the radio is in MCC mode.
+ * - Whether roaming, APF and other offloads needs to be enabled or not.
+ *
+ * Note:
+ * - This will be invoked before an active wifi connection is established on the second interface.
+ * - This use-case hint is implicitly void when the second STA interface is brought down.
+ */
+typedef enum {
+ /**
+ * Usage:
+ * - This will be sent down for make before break use-case.
+ * - Platform is trying to speculatively connect to a second network and evaluate it without
+ * disrupting the primary connection.
+ *
+ * Requirements for Firmware:
+ * - Do not reduce the number of tx/rx chains of primary connection.
+ * - If using MCC, should set the MCC duty cycle of the primary connection to be higher than
+ * the secondary connection (maybe 70/30 split).
+ * - Should pick the best BSSID for the secondary STA (disregard the chip mode) independent of
+ * the primary STA:
+ * - Don’t optimize for DBS vs MCC/SCC
+ * - Should not impact the primary connection’s bssid selection:
+ * - Don’t downgrade chains of the existing primary connection.
+ * - Don’t optimize for DBS vs MCC/SCC.
+ */
+ WIFI_DUAL_STA_TRANSIENT_PREFER_PRIMARY = 0,
+ /**
+ * Usage:
+ * - This will be sent down for any app requested peer to peer connections.
+ * - In this case, both the connections needs to be allocated equal resources.
+ * - For the peer to peer use case, BSSID for the secondary connection will be chosen by the
+ * framework.
+ *
+ * Requirements for Firmware:
+ * - Can choose MCC or DBS mode depending on the MCC efficiency and HW capability.
+ * - If using MCC, set the MCC duty cycle of the primary connection to be equal to the secondary
+ * connection.
+ * - Prefer BSSID candidates which will help provide the best "overall" performance for both the
+ * connections.
+ */
+ WIFI_DUAL_STA_NON_TRANSIENT_UNBIASED = 1
+} wifi_multi_sta_use_case;
+
+wifi_error wifi_multi_sta_set_use_case(wifi_handle handle, wifi_multi_sta_use_case use_case);
+
/* Configuration events */
typedef struct {
@@ -246,6 +375,10 @@ typedef struct {
void (*on_rssi_threshold_breached)(wifi_request_id id, u8 *cur_bssid, s8 cur_rssi);
} wifi_rssi_event_handler;
+typedef struct {
+ void (*on_subsystem_restart)(const char* error);
+} wifi_subsystem_restart_handler;
+
wifi_error wifi_set_iface_event_handler(wifi_request_id id, wifi_interface_handle iface, wifi_event_handler eh);
wifi_error wifi_reset_iface_event_handler(wifi_request_id id, wifi_interface_handle iface);
@@ -258,6 +391,9 @@ wifi_error wifi_map_dscp_access_category(wifi_handle handle,
uint32_t access_category);
wifi_error wifi_reset_dscp_mapping(wifi_handle handle);
+wifi_error wifi_set_subsystem_restart_handler(wifi_handle handle,
+ wifi_subsystem_restart_handler handler);
+
/**
* Wifi HAL Thermal Mitigation API
*
@@ -337,6 +473,30 @@ typedef struct wlan_driver_wake_reason_cnt_t {
RX_MULTICAST_WAKE_DATA_CNT rx_multicast_wake_pkt_info;
} WLAN_DRIVER_WAKE_REASON_CNT;
+/* Wi-Fi coex channel avoidance support */
+
+#define WIFI_COEX_NO_POWER_CAP (int32_t)0x7FFFFFF
+
+typedef enum {
+ WIFI_AWARE = 1 << 0,
+ SOFTAP = 1 << 1,
+ WIFI_DIRECT = 1 << 2
+} wifi_coex_restriction;
+
+/**
+ * Representation of a Wi-Fi channel to be avoided for Wi-Fi coex channel avoidance.
+ *
+ * band is represented as an WLAN_MAC* enum value defined in wlan_mac_band.
+ * If power_cap_dbm is WIFI_COEX_NO_POWER_CAP, then no power cap should be applied if the specified
+ * channel is used.
+ */
+typedef struct {
+ wlan_mac_band band;
+ u32 channel;
+ s32 power_cap_dbm;
+} wifi_coex_unsafe_channel;
+
+
/* include various feature headers */
#include "gscan.h"
@@ -348,6 +508,7 @@ typedef struct wlan_driver_wake_reason_cnt_t {
#include "wifi_nan.h"
#include "wifi_offload.h"
#include "roam.h"
+#include "wifi_twt.h"
//wifi HAL function pointer table
typedef struct {
@@ -553,8 +714,188 @@ typedef struct {
wifi_interface_type iface_type);
wifi_error (*wifi_virtual_interface_delete)(wifi_handle handle, const char* ifname);
+ wifi_error (*wifi_set_subsystem_restart_handler)(wifi_handle handle,
+ wifi_subsystem_restart_handler handler);
+
+ /**
+ * Allow vendor HAL to choose interface name when creating
+ * an interface. This can be implemented by chips with their
+ * own interface naming policy.
+ * If not implemented, the default naming will be used.
+ */
+ wifi_error (*wifi_get_supported_iface_name)(wifi_handle handle, u32 iface_type,
+ char *name, size_t len);
+
+ /**
+ * Perform early initialization steps that are needed when WIFI
+ * is disabled.
+ * If the function returns failure, it means the vendor HAL is unusable
+ * (for example, if chip hardware is not installed) and no further
+ * functions should be called.
+ */
+ wifi_error (*wifi_early_initialize)(void);
+
+ /**
+ * Get supported feature set which are chip-global, that is
+ * not dependent on any created interface.
+ */
+ wifi_error (*wifi_get_chip_feature_set)(wifi_handle handle, feature_set *set);
+
+ /**
+ * Invoked to indicate that the provided iface is the primary STA iface when there are more
+ * than 1 STA iface concurrently active.
+ */
+ wifi_error (*wifi_multi_sta_set_primary_connection)(wifi_handle handle,
+ wifi_interface_handle iface);
+
+
+ /**
+ * When there are 2 simultaneous STA connections, this use case hint
+ * indicates what STA + STA use-case is being enabled by the framework.
+ */
+ wifi_error (*wifi_multi_sta_set_use_case)(wifi_handle handle,
+ wifi_multi_sta_use_case use_case);
+
+ /**
+ * Invoked to indicate that the following list of wifi_coex_unsafe_channel should be avoided
+ * with the specified restrictions.
+ * @param unsafeChannels list of current |wifi_coex_unsafe_channel| to avoid.
+ * @param restrictions bitmask of |wifi_coex_restriction| indicating wifi interfaces to
+ * restrict from the current unsafe channels.
+ */
+ wifi_error (*wifi_set_coex_unsafe_channels)(wifi_handle handle, u32 num_channels,
+ wifi_coex_unsafe_channel *unsafeChannels,
+ u32 restrictions);
+
+ /**
+ * Invoked to set voip optimization mode for the provided STA iface
+ */
+ wifi_error (*wifi_set_voip_mode)(wifi_interface_handle iface, wifi_voip_mode mode);
+
+ /**@brief twt_register_handler
+ * Request to register TWT callback before sending any TWT request
+ * @param wifi_interface_handle:
+ * @param TwtCallbackHandler: callback function pointers
+ * @return Synchronous wifi_error
+ */
+ wifi_error (*wifi_twt_register_handler)(wifi_interface_handle iface,
+ TwtCallbackHandler handler);
+
+ /**@brief twt_get_capability
+ * Request TWT capability
+ * @param wifi_interface_handle:
+ * @return Synchronous wifi_error and TwtCapabilitySet
+ */
+ wifi_error (*wifi_twt_get_capability)(wifi_interface_handle iface,
+ TwtCapabilitySet* twt_cap_set);
+
+ /**@brief twt_setup_request
+ * Request to send TWT setup frame
+ * @param wifi_interface_handle:
+ * @param TwtSetupRequest: detailed parameters of setup request
+ * @return Synchronous wifi_error
+ * @return Asynchronous EventTwtSetupResponse CB return TwtSetupResponse
+ */
+ wifi_error (*wifi_twt_setup_request)(wifi_interface_handle iface,
+ TwtSetupRequest* msg);
+
+ /**@brief twt_teardown_request
+ * Request to send TWT teardown frame
+ * @param wifi_interface_handle:
+ * @param TwtTeardownRequest: detailed parameters of teardown request
+ * @return Synchronous wifi_error
+ * @return Asynchronous EventTwtTeardownCompletion CB return TwtTeardownCompletion
+ * TwtTeardownCompletion may also be received due to other events
+ * like CSA, BTCX, TWT scheduler, MultiConnection, peer-initiated teardown, etc.
+ */
+ wifi_error (*wifi_twt_teardown_request)(wifi_interface_handle iface,
+ TwtTeardownRequest* msg);
+
+ /**@brief twt_info_frame_request
+ * Request to send TWT info frame
+ * @param wifi_interface_handle:
+ * @param TwtInfoFrameRequest: detailed parameters in info frame
+ * @return Synchronous wifi_error
+ * @return Asynchronous EventTwtInfoFrameReceived CB return TwtInfoFrameReceived
+ * Driver may also receive Peer-initiated TwtInfoFrame
+ */
+ wifi_error (*wifi_twt_info_frame_request)(wifi_interface_handle iface,
+ TwtInfoFrameRequest* msg);
+
+ /**@brief twt_get_stats
+ * Request to get TWT stats
+ * @param wifi_interface_handle:
+ * @param config_id: configuration ID of TWT request
+ * @return Synchronous wifi_error and TwtStats
+ */
+ wifi_error (*wifi_twt_get_stats)(wifi_interface_handle iface, u8 config_id,
+ TwtStats* stats);
+
+ /**@brief twt_clear_stats
+ * Request to clear TWT stats
+ * @param wifi_interface_handle:
+ * @param config_id: configuration ID of TWT request
+ * @return Synchronous wifi_error
+ */
+ wifi_error (*wifi_twt_clear_stats)(wifi_interface_handle iface, u8 config_id);
+
+ /**
+ * Invoked to set DTIM configuration when the host is in the suspend mode
+ * @param wifi_interface_handle:
+ * @param multiplier: when STA in the power saving mode, the wake up interval will be set to
+ * 1) multiplier * DTIM period if multiplier > 0.
+ * 2) the device default value if multiplier <=0
+ * Some implementations may apply an additional cap to wake up interval in the case of 1).
+ */
+ wifi_error (*wifi_set_dtim_config)(wifi_interface_handle handle, u32 multiplier);
+
+ /**@brief wifi_get_usable_channels
+ * Request list of usable channels for the requested bands and modes. Usable
+ * implies channel is allowed as per regulatory for the current country code
+ * and not restricted due to other hard limitations (e.g. DFS, Coex) In
+ * certain modes (e.g. STA+SAP) there could be other hard restrictions
+ * since MCC operation many not be supported by SAP. This API also allows
+ * driver to return list of usable channels for each mode uniquely to
+ * distinguish cases where only a limited set of modes are allowed on
+ * a given channel e.g. srd channels may be supported for P2P but not
+ * for SAP or P2P-Client may be allowed on an indoor channel but P2P-GO
+ * may not be allowed. This API is not interface specific and will be
+ * used to query capabilities of driver in terms of what modes (STA, SAP,
+ * P2P_CLI, P2P_GO, NAN, TDLS) can be supported on each of the channels.
+ * @param handle global wifi_handle
+ * @param band_mask BIT MASK of WLAN_MAC* as represented by |wlan_mac_band|
+ * @param iface_mode_mask BIT MASK of BIT(WIFI_INTERFACE_*) represented by
+ * |wifi_interface_mode|. Bitmask respresents all the modes that the
+ * caller is interested in (e.g. STA, SAP, WFD-CLI, WFD-GO, TDLS, NAN).
+ * Note: Bitmask does not represent concurrency matrix. If the caller
+ * is interested in CLI, GO modes, the iface_mode_mask would be set
+ * to WIFI_INTERFACE_P2P_CLIENT|WIFI_INTERFACE_P2P_GO.
+ * @param filter_mask BIT MASK of WIFI_USABLE_CHANNEL_FILTER_* represented by
+ * |wifi_usable_channel_filter|. Indicates if the channel list should
+ * be filtered based on additional criteria. If filter_mask is not
+ * specified, driver should return list of usable channels purely
+ * based on regulatory constraints.
+ * @param max_size maximum number of |wifi_usable_channel|
+ * @param size actual number of |wifi_usable_channel| entries returned by driver
+ * @param channels list of usable channels represented by |wifi_usable_channel|
+ */
+ wifi_error (*wifi_get_usable_channels)(wifi_handle handle, u32 band_mask, u32 iface_mode_mask,
+ u32 filter_mask, u32 max_size, u32* size,
+ wifi_usable_channel* channels);
+
+ /**
+ * Trigger wifi subsystem restart to reload firmware
+ */
+ wifi_error (*wifi_trigger_subsystem_restart)(wifi_handle handle);
+ /*
+ * when adding new functions make sure to add stubs in
+ * hal_tool.cpp::init_wifi_stub_hal_func_table
+ */
} wifi_hal_fn;
+
wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn);
+typedef wifi_error (*init_wifi_vendor_hal_func_table_t)(wifi_hal_fn *fn);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/hardware_legacy/wifi_logger.h b/include/hardware_legacy/wifi_logger.h
index 465c00b..e6f7c48 100644
--- a/include/hardware_legacy/wifi_logger.h
+++ b/include/hardware_legacy/wifi_logger.h
@@ -35,7 +35,6 @@ extern "C"
*/
-typedef int wifi_radio;
typedef int wifi_ring_buffer_id;
#define PER_PACKET_ENTRY_FLAGS_DIRECTION_TX 1 // 0: TX, 1: RX
diff --git a/include/hardware_legacy/wifi_nan.h b/include/hardware_legacy/wifi_nan.h
index 334e37a..1fb7138 100644
--- a/include/hardware_legacy/wifi_nan.h
+++ b/include/hardware_legacy/wifi_nan.h
@@ -389,6 +389,7 @@ typedef struct {
u32 max_sdea_service_specific_info_len;
u32 max_subscribe_address;
u32 ndpe_attr_supported;
+ bool is_instant_mode_supported;
} NanCapabilities;
/*
@@ -1033,6 +1034,13 @@ typedef struct {
*/
u8 config_ndpe_attr;
u32 use_ndpe_attr;
+ /*
+ Enable NAN v3.1 instant communication mode.
+ 0 - Disable
+ 1 - Enable
+ */
+ u8 config_enable_instant_mode;
+ u32 enable_instant_mode;
} NanEnableRequest;
/*
@@ -1518,6 +1526,13 @@ typedef struct {
*/
u8 config_ndpe_attr;
u32 use_ndpe_attr;
+ /*
+ Enable NAN v3.1 instant communication mode.
+ 0 - Disable
+ 1 - Enable
+ */
+ u8 config_enable_instant_mode;
+ u32 enable_instant_mode;
} NanConfigRequest;
/*
diff --git a/include/hardware_legacy/wifi_twt.h b/include/hardware_legacy/wifi_twt.h
new file mode 100644
index 0000000..ba71991
--- /dev/null
+++ b/include/hardware_legacy/wifi_twt.h
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2020 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 __WIFI_HAL_TWT_H__
+#define __WIFI_HAL_TWT_H__
+
+#include "wifi_hal.h"
+
+typedef struct {
+ u8 requester_supported; // 0 for not supporting requester
+ u8 responder_supported; // 0 for not supporting responder
+ u8 broadcast_twt_supported; // 0 for not supporting broadcast TWT
+ u8 flexibile_twt_supported; // 0 for not supporting flexible TWT
+} TwtCapability;
+
+typedef struct {
+ TwtCapability device_capability;
+ TwtCapability peer_capability;
+} TwtCapabilitySet;
+
+// For all optional fields below, if no value specify -1
+typedef struct {
+ u8 config_id; // An unique ID for an individual TWT request
+ u8 negotiation_type; // 0 for individual TWT, 1 for broadcast TWT
+ u8 trigger_type; // 0 for non-triggered TWT, 1 for triggered TWT
+ s32 wake_dur_us; // Proposed wake duration in us
+ s32 wake_int_us; // Average wake interval in us
+ s32 wake_int_min_us; // Min wake interval in us. Optional.
+ s32 wake_int_max_us; // Max wake interval in us. Optional.
+ s32 wake_dur_min_us; // Min wake duration in us. Optional.
+ s32 wake_dur_max_us; // Max wake duration in us. Optional.
+ s32 avg_pkt_size; // Average bytes of each packet to send in each wake
+ // duration. Optional.
+ s32 avg_pkt_num; // Average number of packets to send in each wake
+ // duration. Optional.
+ s32 wake_time_off_us; // First wake duration time offset in us. Optional.
+} TwtSetupRequest;
+
+typedef enum {
+ TWT_SETUP_SUCCESS = 0, // TWT setup is accepted.
+ TWT_SETUP_REJECT = 1, // TWT setup is rejected by AP.
+ TWT_SETUP_TIMEOUT = 2, // TWT setup response from AP times out.
+ TWT_SETUP_IE = 3, // AP sent TWT Setup IE parsing failure.
+ TWT_SETUP_PARAMS = 4, // AP sent TWT Setup IE Parameters invalid.
+ TWT_SETUP_ERROR = 255, // Generic error
+} TwtSetupReasonCode;
+
+typedef struct {
+ u8 config_id; // An unique ID for an individual TWT request
+ u8 status; // 0 for success, non-zero for failure
+ TwtSetupReasonCode reason_code;
+ u8 negotiation_type; // 0 for individual TWT, 1 for broadcast TWT
+ u8 trigger_type; // 0 for non-triggered TWT, 1 for triggered TWT
+ s32 wake_dur_us; // Proposed wake duration in us
+ s32 wake_int_us; // Average wake interval in us
+ s32 wake_time_off_us; // First wake duration time offset in us.
+} TwtSetupResponse;
+
+typedef struct {
+ u8 config_id; // An unique ID for an individual TWT request
+ u8 all_twt; // 0 for individual setp request, 1 for all TWT
+ u8 negotiation_type; // 0 for individual TWT, 1 for broadcast TWT
+} TwtTeardownRequest;
+
+typedef enum {
+ TWT_TD_RC_HOST = 0, // Teardown triggered by Host
+ TWT_TD_RC_PEER = 1, // Peer initiated teardown
+ TWT_TD_RC_MCHAN = 2, // Teardown due to MCHAN Active
+ TWT_TD_RC_MCNX = 3, // Teardown due to MultiConnection
+ TWT_TD_RC_CSA = 4, // Teardown due to CSA
+ TWT_TD_RC_BTCX = 5, // Teardown due to BT Coex
+ TWT_TD_RC_SETUP_FAIL = 6, // Setup fails midway. Teardown all connections
+ TWT_TD_RC_SCHED = 7, // Teardown by TWT Scheduler
+ TWT_TD_RC_ERROR = 255, // Generic error cases
+} TwtTeardownReason;
+
+typedef struct {
+ u8 config_id; // An unique ID for an individual TWT request
+ u8 all_twt; // 0 for individual setp request, 1 for all TWT
+ u8 status; // 0 for success, non-zero for failure
+ TwtTeardownReason reason;
+} TwtTeardownCompletion;
+
+typedef struct {
+ u8 config_id; // An unique ID for an individual TWT request
+ u8 all_twt; // 0 for individual setup request, 1 for all TWT
+ s32 resume_time_us; // If -1, TWT is suspended for indefinite time.
+ // Otherwise, TWT is suspended for resume_time_us
+} TwtInfoFrameRequest;
+
+typedef enum {
+ TWT_INFO_RC_HOST = 0, // Host initiated TWT Info frame */
+ TWT_INFO_RC_PEER = 1, // Peer initiated TWT Info frame
+ TWT_INFO_RC_ERROR = 2, // Generic error conditions */
+} TwtInfoFrameReason;
+
+// TWT Info frame triggered externally.
+// Device should not send TwtInfoFrameReceived to Host for internally
+// triggered TWT Info frame during SCAN, MCHAN operations.
+typedef struct {
+ u8 config_id; // An unique ID for an individual TWT request
+ u8 all_twt; // 0 for individual setup request, 1 for all TWT
+ u8 status; // 0 for success, non-zero for failure
+ TwtInfoFrameReason reason;
+ u8 twt_resumed; // 1 - TWT resumed, 0 - TWT suspended
+} TwtInfoFrameReceived;
+
+typedef struct {
+ u8 config_id;
+ u32 avg_pkt_num_tx; // Average number of Tx packets in each wake duration.
+ u32 avg_pkt_num_rx; // Average number of Rx packets in each wake duration.
+ u32 avg_tx_pkt_size; // Average bytes per Rx packet in each wake duration.
+ u32 avg_rx_pkt_size; // Average bytes per Rx packet in each wake duration.
+ u32 avg_eosp_dur_us; // Average duration of early terminated SP
+ u32 eosp_count; // Count of early terminations
+ u32 num_sp; // Count of service period (SP), also known as wake duration.
+} TwtStats;
+
+// Asynchronous notification from the device.
+// For example, TWT was torn down by the device and later when the device is
+// ready, it can send this async notification.
+// This can be expandable in future.
+typedef enum {
+ TWT_NOTIF_ALLOW_TWT = 1, // Device ready to process TWT Setup request
+} TwtNotification;
+
+typedef struct {
+ TwtNotification notification;
+} TwtDeviceNotify;
+
+// Callbacks for various TWT responses and events
+typedef struct {
+ // Callback for TWT setup response
+ void (*EventTwtSetupResponse)(TwtSetupResponse *event);
+ // Callback for TWT teardown completion
+ void (*EventTwtTeardownCompletion)(TwtTeardownCompletion* event);
+ // Callback for TWT info frame received event
+ void (*EventTwtInfoFrameReceived)(TwtInfoFrameReceived* event);
+ // Callback for TWT notification from the device
+ void (*EventTwtDeviceNotify)(TwtDeviceNotify* event);
+} TwtCallbackHandler;
+
+#endif /* __WIFI_HAL_TWT_H__ */
diff --git a/include/wakelock/wakelock.h b/include/wakelock/wakelock.h
index 75a7c72..44c962c 100644
--- a/include/wakelock/wakelock.h
+++ b/include/wakelock/wakelock.h
@@ -17,6 +17,7 @@
#pragma once
#include <memory>
+#include <optional>
#include <string>
namespace android {
@@ -24,13 +25,17 @@ namespace wakelock {
// RAII-style wake lock implementation
class WakeLock {
- public:
- WakeLock(const std::string& name);
- ~WakeLock();
-
private:
class WakeLockImpl;
std::unique_ptr<WakeLockImpl> mImpl;
+
+ public:
+ static std::optional<WakeLock> tryGet(const std::string& name);
+ // Constructor is only made public for use with std::optional.
+ // It is not intended to be and cannot be invoked from public context,
+ // since private WakeLockImpl prevents calling the constructor directly.
+ WakeLock(std::unique_ptr<WakeLockImpl> wlImpl);
+ ~WakeLock();
};
} // namespace wakelock
diff --git a/power.cpp b/power.cpp
index 16ed961..a39b32b 100644
--- a/power.cpp
+++ b/power.cpp
@@ -88,26 +88,51 @@ class WakeLock::WakeLockImpl {
public:
WakeLockImpl(const std::string& name);
~WakeLockImpl();
+ bool acquireOk();
private:
sp<IWakeLock> mWakeLock;
};
-WakeLock::WakeLock(const std::string& name) : mImpl(std::make_unique<WakeLockImpl>(name)) {}
+std::optional<WakeLock> WakeLock::tryGet(const std::string& name) {
+ std::unique_ptr<WakeLockImpl> wlImpl = std::make_unique<WakeLockImpl>(name);
+ if (wlImpl->acquireOk()) {
+ return { std::move(wlImpl) };
+ } else {
+ LOG(ERROR) << "Failed to acquire wakelock: " << name;
+ return {};
+ }
+}
+
+WakeLock::WakeLock(std::unique_ptr<WakeLockImpl> wlImpl) : mImpl(std::move(wlImpl)) {}
WakeLock::~WakeLock() = default;
WakeLock::WakeLockImpl::WakeLockImpl(const std::string& name) : mWakeLock(nullptr) {
static sp<ISystemSuspend> suspendService = ISystemSuspend::getService();
- mWakeLock = suspendService->acquireWakeLock(WakeLockType::PARTIAL, name);
+ auto ret = suspendService->acquireWakeLock(WakeLockType::PARTIAL, name);
+ // It's possible that during device SystemSuspend service is not avaiable. In these
+ // situations HIDL calls to it will result in a DEAD_OBJECT transaction error.
+ if (ret.isDeadObject()) {
+ LOG(ERROR) << "ISuspendService::acquireWakeLock() call failed: " << ret.description();
+ } else {
+ mWakeLock = ret;
+ }
}
WakeLock::WakeLockImpl::~WakeLockImpl() {
+ if (!acquireOk()) {
+ return;
+ }
auto ret = mWakeLock->release();
if (!ret.isOk()) {
LOG(ERROR) << "IWakeLock::release() call failed: " << ret.description();
}
}
+bool WakeLock::WakeLockImpl::acquireOk() {
+ return mWakeLock != nullptr;
+}
+
} // namespace wakelock
} // namespace android
diff --git a/power_test.cpp b/power_test.cpp
index d6e414d..9a68651 100644
--- a/power_test.cpp
+++ b/power_test.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <android/system/suspend/ISuspendControlService.h>
+#include <android/system/suspend/internal/ISuspendControlServiceInternal.h>
#include <binder/IServiceManager.h>
#include <gtest/gtest.h>
#include <hardware_legacy/power.h>
@@ -27,8 +27,8 @@
#include <vector>
using android::sp;
-using android::system::suspend::ISuspendControlService;
-using android::system::suspend::WakeLockInfo;
+using android::system::suspend::internal::ISuspendControlServiceInternal;
+using android::system::suspend::internal::WakeLockInfo;
using namespace std::chrono_literals;
namespace android {
@@ -94,13 +94,13 @@ class WakeLockTest : public ::testing::Test {
public:
virtual void SetUp() override {
sp<IBinder> control =
- android::defaultServiceManager()->getService(android::String16("suspend_control"));
- ASSERT_NE(control, nullptr) << "failed to get the suspend control service";
- controlService = interface_cast<ISuspendControlService>(control);
+ android::defaultServiceManager()->getService(android::String16("suspend_control_internal"));
+ ASSERT_NE(control, nullptr) << "failed to get the internal suspend control service";
+ controlService = interface_cast<ISuspendControlServiceInternal>(control);
}
// Returns true iff found.
- bool findWakeLockInfoByName(const sp<ISuspendControlService>& service, const std::string& name,
+ bool findWakeLockInfoByName(const sp<ISuspendControlServiceInternal>& service, const std::string& name,
WakeLockInfo* info) {
std::vector<WakeLockInfo> wlStats;
service->getWakeLockStats(&wlStats);
@@ -114,14 +114,17 @@ class WakeLockTest : public ::testing::Test {
}
// All userspace wake locks are registered with system suspend.
- sp<ISuspendControlService> controlService;
+ sp<ISuspendControlServiceInternal> controlService;
};
// Test RAII properties of WakeLock destructor.
TEST_F(WakeLockTest, WakeLockDestructor) {
auto name = std::to_string(rand());
{
- android::wakelock::WakeLock wl{name};
+ auto wl = android::wakelock::WakeLock::tryGet(name);
+ if (!wl.has_value()) {
+ return;
+ }
WakeLockInfo info;
auto success = findWakeLockInfoByName(controlService, name, &info);