diff options
author | Christopher Wiley <wiley@google.com> | 2016-06-15 12:54:12 -0700 |
---|---|---|
committer | Christopher Wiley <wiley@google.com> | 2016-06-16 10:17:14 -0700 |
commit | 189a1eff9eef200cab7a61e5bf6e9865bfa46ce4 (patch) | |
tree | 18c29c91d8bcf2ce53750f02525bfc4c138e1d98 | |
parent | 051a0607b6b2f1ad058f048e2a104e4ebe36c730 (diff) |
Wrap vendor provided HAL in libwifi-hal
While here, fix the include paths so that we explicitly refer to the
headers in hardware_legacy.
Bug: 29396611
Test: Compiles, can associate to an AP on angler/bullhead
Test: runtest frameworks-wifi continues to pass
Change-Id: Ic76ce613b80eb9b3200699c5e1dd083a43e2b1c5
-rw-r--r-- | libwifi_hal/Android.mk | 65 | ||||
-rw-r--r-- | libwifi_hal/wifi_hal_fallback.cpp | 21 | ||||
-rw-r--r-- | service/Android.mk | 84 | ||||
-rw-r--r-- | service/jni/com_android_server_wifi_WifiNative.cpp | 4 | ||||
-rw-r--r-- | service/jni/com_android_server_wifi_nan_WifiNanNative.cpp | 2 | ||||
-rw-r--r-- | service/jni/jni_helper.cpp | 2 | ||||
-rw-r--r-- | service/jni/wifi_hal_stub.h | 2 | ||||
-rw-r--r-- | service/lib/wifi_hal.cpp | 6 | ||||
-rw-r--r-- | service/lib/wifi_hal_stub.cpp | 3 | ||||
-rw-r--r-- | tests/wifitests/Android.mk | 4 | ||||
-rw-r--r-- | tests/wifitests/jni/wifi_hal_mock.cpp | 2 | ||||
-rw-r--r-- | tests/wifitests/jni/wifi_hal_mock.h | 2 | ||||
-rw-r--r-- | tests/wifitests/jni/wifi_nan_hal_mock.cpp | 2 |
13 files changed, 119 insertions, 80 deletions
diff --git a/libwifi_hal/Android.mk b/libwifi_hal/Android.mk new file mode 100644 index 000000000..e83c25e47 --- /dev/null +++ b/libwifi_hal/Android.mk @@ -0,0 +1,65 @@ +# 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. + +LOCAL_PATH := $(call my-dir) +ifneq ($(TARGET_BUILD_PDK), true) + +# A fallback "vendor" HAL library. +# Don't link this, link libwifi-hal. +# ============================================================ +include $(CLEAR_VARS) +LOCAL_MODULE := libwifi-hal-fallback +LOCAL_CFLAGS := \ + -Wall \ + -Werror \ + -Wextra \ + -Winit-self \ + -Wno-unused-function \ + -Wno-unused-parameter \ + -Wshadow \ + -Wunused-variable \ + -Wwrite-strings +LOCAL_SRC_FILES := wifi_hal_fallback.cpp +LOCAL_C_INCLUDES := $(call include-path-for, libhardware_legacy) +include $(BUILD_STATIC_LIBRARY) + +# Pick a vendor provided HAL implementation library. +# ============================================================ +LIB_WIFI_HAL := libwifi-hal-fallback +ifeq ($(BOARD_WLAN_DEVICE), bcmdhd) + LIB_WIFI_HAL := libwifi-hal-bcm +else ifeq ($(BOARD_WLAN_DEVICE), qcwcn) + LIB_WIFI_HAL := libwifi-hal-qcom +else ifeq ($(BOARD_WLAN_DEVICE), mrvl) + # this is commented because none of the nexus devices + # that sport Marvell's wifi have support for HAL + # LIB_WIFI_HAL := libwifi-hal-mrvl +else ifeq ($(BOARD_WLAN_DEVICE), MediaTek) + # support MTK WIFI HAL + LIB_WIFI_HAL := libwifi-hal-mt66xx +endif + +# The WiFi HAL that you should be linking. +# ============================================================ +include $(CLEAR_VARS) +LOCAL_MODULE := libwifi-hal +LOCAL_EXPORT_C_INCLUDE_DIRS := $(call include-path-for, libhardware_legacy) +LOCAL_SHARED_LIBRARIES := \ + liblog \ + libnl \ + libutils +LOCAL_WHOLE_STATIC_LIBRARIES := $(LIB_WIFI_HAL) +include $(BUILD_SHARED_LIBRARY) + +endif diff --git a/libwifi_hal/wifi_hal_fallback.cpp b/libwifi_hal/wifi_hal_fallback.cpp new file mode 100644 index 000000000..64259a11d --- /dev/null +++ b/libwifi_hal/wifi_hal_fallback.cpp @@ -0,0 +1,21 @@ +/* + * Copyright 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 "hardware_legacy/wifi_hal.h" + +wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) { + return WIFI_ERROR_NOT_SUPPORTED; +} diff --git a/service/Android.mk b/service/Android.mk index 9b3ed1d17..5c824c886 100644 --- a/service/Android.mk +++ b/service/Android.mk @@ -16,79 +16,39 @@ LOCAL_PATH := $(call my-dir) ifneq ($(TARGET_BUILD_PDK), true) -# Make HAL stub library 1 +# This is the HAL stub library. We initialize the HAL function table +# with functions from here so that we have reasonable "unimplemented" +# fallback behavior when a behavior isn't implemented by a vendor. # ============================================================ - -include $(CLEAR_VARS) - -LOCAL_REQUIRED_MODULES := - -LOCAL_CFLAGS += -Wall -Werror -Wextra -Wno-unused-parameter -Wno-unused-function \ - -Wunused-variable -Winit-self -Wwrite-strings -Wshadow - -LOCAL_C_INCLUDES += \ - external/libnl-headers \ - $(call include-path-for, libhardware_legacy)/hardware_legacy - -LOCAL_SRC_FILES := \ - lib/wifi_hal.cpp - -LOCAL_MODULE := libwifi-hal - -include $(BUILD_STATIC_LIBRARY) - -# Make HAL stub library 2 -# ============================================================ - include $(CLEAR_VARS) - -LOCAL_REQUIRED_MODULES := - -LOCAL_CFLAGS += -Wall -Werror -Wextra -Wno-unused-parameter -Wno-unused-function \ - -Wunused-variable -Winit-self -Wwrite-strings -Wshadow - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/jni \ - external/libnl-headers \ - $(call include-path-for, libhardware_legacy)/hardware_legacy - -LOCAL_SRC_FILES := \ - lib/wifi_hal_stub.cpp - LOCAL_MODULE := libwifi-hal-stub - +LOCAL_CFLAGS := \ + -Wall \ + -Werror \ + -Wextra \ + -Wno-unused-parameter \ + -Wno-unused-function \ + -Wunused-variable \ + -Winit-self \ + -Wwrite-strings \ + -Wshadow + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/jni \ + $(call include-path-for, libhardware_legacy) +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES) +LOCAL_SRC_FILES := lib/wifi_hal_stub.cpp include $(BUILD_STATIC_LIBRARY) -# set correct hal library path -# ============================================================ -LIB_WIFI_HAL := libwifi-hal - -ifeq ($(BOARD_WLAN_DEVICE), bcmdhd) - LIB_WIFI_HAL := libwifi-hal-bcm -else ifeq ($(BOARD_WLAN_DEVICE), qcwcn) - LIB_WIFI_HAL := libwifi-hal-qcom -else ifeq ($(BOARD_WLAN_DEVICE), mrvl) - # this is commented because none of the nexus devices - # that sport Marvell's wifi have support for HAL - # LIB_WIFI_HAL := libwifi-hal-mrvl -else ifeq ($(BOARD_WLAN_DEVICE), MediaTek) - # support MTK WIFI HAL - LIB_WIFI_HAL := libwifi-hal-mt66xx -endif - # Make the JNI part # ============================================================ include $(CLEAR_VARS) -LOCAL_REQUIRED_MODULES := libwifi-system - LOCAL_CFLAGS += -Wall -Werror -Wextra -Wno-unused-parameter -Wno-unused-function \ -Wunused-variable -Winit-self -Wwrite-strings -Wshadow LOCAL_C_INCLUDES += \ $(JNI_H_INCLUDE) \ - $(call include-path-for, libhardware)/hardware \ - $(call include-path-for, libhardware_legacy)/hardware_legacy \ libcore/include LOCAL_SHARED_LIBRARIES += \ @@ -96,13 +56,11 @@ LOCAL_SHARED_LIBRARIES += \ libnativehelper \ libcutils \ libutils \ - libhardware \ - libnl \ libdl \ + libwifi-hal \ libwifi-system -LOCAL_STATIC_LIBRARIES += libwifi-hal-stub -LOCAL_STATIC_LIBRARIES += $(LIB_WIFI_HAL) +LOCAL_STATIC_LIBRARIES := libwifi-hal-stub LOCAL_SRC_FILES := \ jni/com_android_server_wifi_WifiNative.cpp \ diff --git a/service/jni/com_android_server_wifi_WifiNative.cpp b/service/jni/com_android_server_wifi_WifiNative.cpp index 7fd7303f9..f4fadde84 100644 --- a/service/jni/com_android_server_wifi_WifiNative.cpp +++ b/service/jni/com_android_server_wifi_WifiNative.cpp @@ -35,9 +35,9 @@ #include <vector> #include "wifi_system/wifi.h" -#include "wifi_hal.h" +#include "hardware_legacy/wifi_hal.h" #include "jni_helper.h" -#include "rtt.h" +#include "hardware_legacy/rtt.h" #include "wifi_hal_stub.h" #define REPLY_BUF_SIZE (4096 + 1) // wpa_supplicant's maximum size + 1 for nul #define EVENT_BUF_SIZE 2048 diff --git a/service/jni/com_android_server_wifi_nan_WifiNanNative.cpp b/service/jni/com_android_server_wifi_nan_WifiNanNative.cpp index d8dce6b1e..fce4e93a7 100644 --- a/service/jni/com_android_server_wifi_nan_WifiNanNative.cpp +++ b/service/jni/com_android_server_wifi_nan_WifiNanNative.cpp @@ -28,7 +28,7 @@ #include <sys/socket.h> #include <linux/if.h> #include "wifi_system/wifi.h" -#include "wifi_hal.h" +#include "hardware_legacy/wifi_hal.h" #include "jni_helper.h" namespace android { diff --git a/service/jni/jni_helper.cpp b/service/jni/jni_helper.cpp index eb4f80cf9..f80b2bd7a 100644 --- a/service/jni/jni_helper.cpp +++ b/service/jni/jni_helper.cpp @@ -24,7 +24,7 @@ #include <utils/String16.h> #include "wifi_system/wifi.h" -#include "wifi_hal.h" +#include "hardware_legacy/wifi_hal.h" #include "jni_helper.h" namespace android { diff --git a/service/jni/wifi_hal_stub.h b/service/jni/wifi_hal_stub.h index d49aeb707..e853c0ce4 100644 --- a/service/jni/wifi_hal_stub.h +++ b/service/jni/wifi_hal_stub.h @@ -22,7 +22,7 @@ extern "C" { #endif -#include "wifi_hal.h" +#include "hardware_legacy/wifi_hal.h" int init_wifi_stub_hal_func_table(wifi_hal_fn *hal_fn); diff --git a/service/lib/wifi_hal.cpp b/service/lib/wifi_hal.cpp deleted file mode 100644 index 25bb373d9..000000000 --- a/service/lib/wifi_hal.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include <stdint.h> -#include "wifi_hal.h" - -wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) { - return WIFI_ERROR_NOT_SUPPORTED; -} diff --git a/service/lib/wifi_hal_stub.cpp b/service/lib/wifi_hal_stub.cpp index f4165a066..f4c263fd9 100644 --- a/service/lib/wifi_hal_stub.cpp +++ b/service/lib/wifi_hal_stub.cpp @@ -15,7 +15,8 @@ */ #include <stdint.h> -#include "wifi_hal.h" + +#include "hardware_legacy/wifi_hal.h" #include "wifi_hal_stub.h" wifi_error wifi_initialize_stub(wifi_handle *handle) { diff --git a/tests/wifitests/Android.mk b/tests/wifitests/Android.mk index e13422136..71e28a22d 100644 --- a/tests/wifitests/Android.mk +++ b/tests/wifitests/Android.mk @@ -28,7 +28,7 @@ LOCAL_C_INCLUDES += \ $(JNI_H_INCLUDE) \ $(LOCAL_PATH)/../../service/jni \ $(call include-path-for, libhardware)/hardware \ - $(call include-path-for, libhardware_legacy)/hardware_legacy \ + $(call include-path-for, libhardware_legacy) \ packages/apps/Test/connectivity/sl4n/rapidjson/include \ libcore/include @@ -42,7 +42,6 @@ endif LOCAL_MODULE := libwifi-hal-mock -LOCAL_STATIC_LIBRARIES += libwifi-hal LOCAL_SHARED_LIBRARIES += \ libnativehelper \ libcutils \ @@ -143,6 +142,7 @@ LOCAL_JNI_SHARED_LIBRARIES := \ libstagefright_foundation \ libstdc++ \ libsync \ + libwifi-hal \ libwifi-system \ libui \ libunwind \ diff --git a/tests/wifitests/jni/wifi_hal_mock.cpp b/tests/wifitests/jni/wifi_hal_mock.cpp index 9c0b2158e..96c0dd540 100644 --- a/tests/wifitests/jni/wifi_hal_mock.cpp +++ b/tests/wifitests/jni/wifi_hal_mock.cpp @@ -26,7 +26,7 @@ #include <sys/socket.h> #include <linux/if.h> #include "wifi_system/wifi.h" -#include "wifi_hal.h" +#include "hardware_legacy/wifi_hal.h" #include "jni_helper.h" #include "wifi_hal_mock.h" #include <sstream> diff --git a/tests/wifitests/jni/wifi_hal_mock.h b/tests/wifitests/jni/wifi_hal_mock.h index a5263934b..f31612244 100644 --- a/tests/wifitests/jni/wifi_hal_mock.h +++ b/tests/wifitests/jni/wifi_hal_mock.h @@ -17,7 +17,7 @@ #ifndef __WIFI_HAL_MOCK_H__ #define __WIFI_HAL_MOCK_H__ -#include "wifi_hal.h" +#include "hardware_legacy/wifi_hal.h" #include <rapidjson/document.h> #include <rapidjson/stringbuffer.h> diff --git a/tests/wifitests/jni/wifi_nan_hal_mock.cpp b/tests/wifitests/jni/wifi_nan_hal_mock.cpp index ae1fea404..01da519e5 100644 --- a/tests/wifitests/jni/wifi_nan_hal_mock.cpp +++ b/tests/wifitests/jni/wifi_nan_hal_mock.cpp @@ -26,7 +26,7 @@ #include <sys/socket.h> #include <linux/if.h> #include "wifi_system/wifi.h" -#include "wifi_hal.h" +#include "hardware_legacy/wifi_hal.h" #include "jni_helper.h" #include "wifi_hal_mock.h" #include <sstream> |