diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-08 16:02:29 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-08 16:02:29 +0000 |
commit | 1fe4911c1a6ccc4d5e1857a3dfb95a39b825e31c (patch) | |
tree | 1863de2b6f4d423659844f114fa2e4edb3f988db | |
parent | 98203dea8bf04f888fcda67c86134d43b5e7ed7e (diff) | |
parent | 22f705057482747bd4b7c5f3e9d60a12a4558257 (diff) | |
download | libhardware_legacy-aml_tz2_305400100.tar.gz |
Snap for 8426163 from 22f705057482747bd4b7c5f3e9d60a12a4558257 to mainline-tzdata2-releaseandroid-mainline-12.0.0_r112aml_tz2_305400500aml_tz2_305400300aml_tz2_305400100aml_tz2_304500300aml_tz2_303900110aml_tz2_303900102aml_tz2_303800002aml_tz2_303800001aml_tz2_303200001android12-mainline-tzdata2-releaseaml_tz2_305400100
Change-Id: I6e3f32b4c68dbb496adc636bd53ed10930bd1be5
-rw-r--r-- | Android.bp | 19 | ||||
-rw-r--r-- | METADATA | 3 | ||||
-rw-r--r-- | MODULE_LICENSE_APACHE2 | 0 | ||||
-rw-r--r-- | audio/Android.bp | 9 | ||||
-rw-r--r-- | audio/audio_hw_hal.cpp | 14 | ||||
-rw-r--r-- | block_suspend.cpp | 10 | ||||
-rw-r--r-- | include/hardware_legacy/AudioSystemLegacy.h | 5 | ||||
-rw-r--r-- | include/hardware_legacy/link_layer_stats.h | 28 | ||||
-rw-r--r-- | include/hardware_legacy/wifi_config.h | 2 | ||||
-rw-r--r-- | include/hardware_legacy/wifi_hal.h | 395 | ||||
-rw-r--r-- | include/hardware_legacy/wifi_logger.h | 1 | ||||
-rw-r--r-- | include/hardware_legacy/wifi_nan.h | 15 | ||||
-rw-r--r-- | include/hardware_legacy/wifi_twt.h | 156 | ||||
-rw-r--r-- | include/wakelock/wakelock.h | 13 | ||||
-rw-r--r-- | power.cpp | 29 | ||||
-rw-r--r-- | power_test.cpp | 21 |
16 files changed, 64 insertions, 656 deletions
@@ -1,22 +1,5 @@ // 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, @@ -53,8 +36,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 deleted file mode 100644 index d97975c..0000000 --- a/METADATA +++ /dev/null @@ -1,3 +0,0 @@ -third_party { - license_type: NOTICE -} diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MODULE_LICENSE_APACHE2 diff --git a/audio/Android.bp b/audio/Android.bp index 5695e84..b4c0799 100644 --- a/audio/Android.bp +++ b/audio/Android.bp @@ -3,15 +3,6 @@ //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 6ea05fd..d15044a 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 audio_devices_t convert_audio_device(uint32_t from_device, int from_rev, int to_rev) +static uint32_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; - audio_devices_t to_device = AUDIO_DEVICE_NONE; + uint32_t to_device = AUDIO_DEVICE_NONE; uint32_t in_bit = 0; if (from_rev != HAL_API_REV_1_0) { @@ -107,7 +107,7 @@ static audio_devices_t convert_audio_device(uint32_t from_device, int from_rev, for (i = 0; i < k_num_devices; i++) { if (audio_device_conv_table[i][from_rev] == cur_device) { - to_device = (audio_devices_t)(to_device | audio_device_conv_table[i][to_rev]); + to_device |= audio_device_conv_table[i][to_rev]; break; } } @@ -504,16 +504,14 @@ 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, - &raw_channel_mask, + &config->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; @@ -573,15 +571,13 @@ 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, - &raw_channel_mask, &config->sample_rate, + &config->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 d780904..99341b8 100644 --- a/block_suspend.cpp +++ b/block_suspend.cpp @@ -14,8 +14,6 @@ * limitations under the License. */ -#include <unistd.h> - #include <iostream> #include <wakelock/wakelock.h> @@ -34,12 +32,8 @@ int main(int argc, char ** /* argv */) { return 0; } - auto wl = android::wakelock::WakeLock::tryGet(gWakeLockName); // RAII object - if (!wl.has_value()) { - return EXIT_FAILURE; - } - - while (true) { sleep(1000000); }; + android::wakelock::WakeLock wl{gWakeLockName}; // RAII object + while (true) {}; std::abort(); // should never reach here return 0; } diff --git a/include/hardware_legacy/AudioSystemLegacy.h b/include/hardware_legacy/AudioSystemLegacy.h index 0bec0f2..8227037 100644 --- a/include/hardware_legacy/AudioSystemLegacy.h +++ b/include/hardware_legacy/AudioSystemLegacy.h @@ -17,7 +17,6 @@ #ifndef ANDROID_AUDIOSYSTEM_LEGACY_H_ #define ANDROID_AUDIOSYSTEM_LEGACY_H_ -#include <cutils/bitops.h> #include <utils/Errors.h> #include <media/AudioParameter.h> @@ -345,10 +344,10 @@ public: static bool isLinearPCM(uint32_t format) { return audio_is_linear_pcm((audio_format_t) format); } - static bool isOutputChannel(audio_channel_mask_t channel) { + static bool isOutputChannel(uint32_t channel) { return audio_is_output_channel(channel); } - static bool isInputChannel(audio_channel_mask_t channel) { + static bool isInputChannel(uint32_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 9b67f6d..7a43230 100644 --- a/include/hardware_legacy/link_layer_stats.h +++ b/include/hardware_legacy/link_layer_stats.h @@ -34,7 +34,6 @@ 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;
@@ -46,17 +45,15 @@ 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
- 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_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_link_layer_info;
/* channel information */
@@ -161,17 +158,10 @@ 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 9ddf8b8..8ad14f4 100644 --- a/include/hardware_legacy/wifi_config.h +++ b/include/hardware_legacy/wifi_config.h @@ -12,6 +12,8 @@ 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 81948d6..5dabeb6 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -25,31 +25,6 @@ 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 { @@ -73,13 +48,6 @@ 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 { @@ -97,15 +65,6 @@ 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, @@ -123,11 +82,12 @@ 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 Operates in 60 GHz Band */ - WLAN_MAC_60_0_BAND = 1 << 3, + WLAN_MAC_6_0_BAND = 1 << 2 } wlan_mac_band; +typedef int wifi_radio; +typedef int wifi_channel; + typedef struct { wifi_channel_width width; int center_frequency0; @@ -135,53 +95,6 @@ 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, @@ -204,6 +117,26 @@ 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 */ @@ -257,9 +190,11 @@ 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) @@ -280,70 +215,6 @@ 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 { @@ -375,10 +246,6 @@ 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); @@ -391,9 +258,6 @@ 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 * @@ -473,30 +337,6 @@ 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" @@ -508,7 +348,6 @@ typedef struct { #include "wifi_nan.h" #include "wifi_offload.h" #include "roam.h" -#include "wifi_twt.h" //wifi HAL function pointer table typedef struct { @@ -714,188 +553,8 @@ 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 e6f7c48..465c00b 100644 --- a/include/hardware_legacy/wifi_logger.h +++ b/include/hardware_legacy/wifi_logger.h @@ -35,6 +35,7 @@ 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 1fb7138..334e37a 100644 --- a/include/hardware_legacy/wifi_nan.h +++ b/include/hardware_legacy/wifi_nan.h @@ -389,7 +389,6 @@ typedef struct { u32 max_sdea_service_specific_info_len; u32 max_subscribe_address; u32 ndpe_attr_supported; - bool is_instant_mode_supported; } NanCapabilities; /* @@ -1034,13 +1033,6 @@ 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; /* @@ -1526,13 +1518,6 @@ 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 deleted file mode 100644 index ba71991..0000000 --- a/include/hardware_legacy/wifi_twt.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 44c962c..75a7c72 100644 --- a/include/wakelock/wakelock.h +++ b/include/wakelock/wakelock.h @@ -17,7 +17,6 @@ #pragma once #include <memory> -#include <optional> #include <string> namespace android { @@ -25,17 +24,13 @@ 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 @@ -88,51 +88,26 @@ class WakeLock::WakeLockImpl { public: WakeLockImpl(const std::string& name); ~WakeLockImpl(); - bool acquireOk(); private: sp<IWakeLock> mWakeLock; }; -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(const std::string& name) : mImpl(std::make_unique<WakeLockImpl>(name)) {} WakeLock::~WakeLock() = default; WakeLock::WakeLockImpl::WakeLockImpl(const std::string& name) : mWakeLock(nullptr) { static sp<ISystemSuspend> suspendService = ISystemSuspend::getService(); - 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; - } + mWakeLock = suspendService->acquireWakeLock(WakeLockType::PARTIAL, name); } 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 9a68651..d6e414d 100644 --- a/power_test.cpp +++ b/power_test.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include <android/system/suspend/internal/ISuspendControlServiceInternal.h> +#include <android/system/suspend/ISuspendControlService.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::internal::ISuspendControlServiceInternal; -using android::system::suspend::internal::WakeLockInfo; +using android::system::suspend::ISuspendControlService; +using android::system::suspend::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_internal")); - ASSERT_NE(control, nullptr) << "failed to get the internal suspend control service"; - controlService = interface_cast<ISuspendControlServiceInternal>(control); + android::defaultServiceManager()->getService(android::String16("suspend_control")); + ASSERT_NE(control, nullptr) << "failed to get the suspend control service"; + controlService = interface_cast<ISuspendControlService>(control); } // Returns true iff found. - bool findWakeLockInfoByName(const sp<ISuspendControlServiceInternal>& service, const std::string& name, + bool findWakeLockInfoByName(const sp<ISuspendControlService>& service, const std::string& name, WakeLockInfo* info) { std::vector<WakeLockInfo> wlStats; service->getWakeLockStats(&wlStats); @@ -114,17 +114,14 @@ class WakeLockTest : public ::testing::Test { } // All userspace wake locks are registered with system suspend. - sp<ISuspendControlServiceInternal> controlService; + sp<ISuspendControlService> controlService; }; // Test RAII properties of WakeLock destructor. TEST_F(WakeLockTest, WakeLockDestructor) { auto name = std::to_string(rand()); { - auto wl = android::wakelock::WakeLock::tryGet(name); - if (!wl.has_value()) { - return; - } + android::wakelock::WakeLock wl{name}; WakeLockInfo info; auto success = findWakeLockInfoByName(controlService, name, &info); |