Merge "sensors: route sensor handle for multi-hal event injection"
diff --git a/Android.bp b/Android.bp
index f6aacd2..9c5a9cc 100644
--- a/Android.bp
+++ b/Android.bp
@@ -23,6 +23,7 @@
         "libcutils",
         "liblog",
         "libdl",
+        "libvndksupport",
     ],
     cflags: ["-DQEMU_HARDWARE"],
 
diff --git a/hardware.c b/hardware.c
index 7e4debe..8faac07 100644
--- a/hardware.c
+++ b/hardware.c
@@ -29,6 +29,8 @@
 #define LOG_TAG "HAL"
 #include <log/log.h>
 
+#include <vndksupport/linker.h>
+
 /** Base path of the hal modules */
 #if defined(__LP64__)
 #define HAL_LIBRARY_PATH1 "/system/lib64/hw"
@@ -80,7 +82,14 @@
      * dlopen returns. Since RTLD_GLOBAL is not or'd in with
      * RTLD_NOW the external symbols will not be global
      */
-    handle = dlopen(path, RTLD_NOW);
+    if (strncmp(path, "/system/", 8) == 0) {
+        /* If the library is in system partition, no need to check
+         * sphal namespace. Open it with dlopen.
+         */
+        handle = dlopen(path, RTLD_NOW);
+    } else {
+        handle = android_load_sphal_library(path, RTLD_NOW);
+    }
     if (handle == NULL) {
         char const *err_str = dlerror();
         ALOGE("load: module=%s\n%s", path, err_str?err_str:"unknown");
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index b706e8a..6e287e6 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -35,7 +35,7 @@
 #define BT_STACK_TEST_MODULE_ID "bluetooth_test"
 
 
-/* Bluetooth profile interface IDs */
+/** Bluetooth profile interface IDs */
 
 #define BT_PROFILE_HANDSFREE_ID "handsfree"
 #define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client"
@@ -52,6 +52,9 @@
 #define BT_PROFILE_AV_RC_ID "avrcp"
 #define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
 
+/** Bluetooth test interface IDs */
+#define BT_TEST_INTERFACE_MCAP_ID "mcap_test"
+
 /** Bluetooth Address */
 typedef struct {
     uint8_t address[6];
diff --git a/include/hardware/bt_gatt_client.h b/include/hardware/bt_gatt_client.h
index 33a6825..154cb09 100644
--- a/include/hardware/bt_gatt_client.h
+++ b/include/hardware/bt_gatt_client.h
@@ -223,6 +223,11 @@
      */
     bt_status_t (*search_service)(int conn_id, bt_uuid_t *filter_uuid );
 
+    /**
+     * Sead "Find service by UUID" request. Used only for PTS tests.
+     */
+    void (*btif_gattc_discover_service_by_uuid)(int conn_id, bt_uuid_t *uuid);
+
     /** Read a characteristic on a remote device */
     bt_status_t (*read_characteristic)(int conn_id, uint16_t handle,
                                        int auth_req);
diff --git a/include/hardware/bt_hh.h b/include/hardware/bt_hh.h
index dad9586..ece3c11 100644
--- a/include/hardware/bt_hh.h
+++ b/include/hardware/bt_hh.h
@@ -165,6 +165,12 @@
     /** Set the HID proto mode. */
     bt_status_t (*set_protocol)(bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode);
 
+    /** Get the HID Idle Time */
+    bt_status_t (*get_idle_time)(bt_bdaddr_t *bd_addr);
+
+    /** Set the HID Idle Time */
+    bt_status_t (*set_idle_time)(bt_bdaddr_t *bd_addr, uint8_t idleTime);
+
     /** Send a GET_REPORT to HID device. */
     bt_status_t (*get_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, uint8_t reportId, int bufferSize);
 
@@ -174,7 +180,7 @@
     /** Send data to HID device. */
     bt_status_t (*send_data)(bt_bdaddr_t *bd_addr, char* data);
 
-	/** Closes the interface. */
+    /** Closes the interface. */
     void  (*cleanup)( void );
 
 } bthh_interface_t;
diff --git a/include/hardware/gralloc.h b/include/hardware/gralloc.h
index 1b06ebf..5dafea0 100644
--- a/include/hardware/gralloc.h
+++ b/include/hardware/gralloc.h
@@ -18,7 +18,6 @@
 #ifndef ANDROID_GRALLOC_INTERFACE_H
 #define ANDROID_GRALLOC_INTERFACE_H
 
-#include <system/window.h>
 #include <system/graphics.h>
 #include <hardware/hardware.h>
 
diff --git a/include/hardware/gralloc1.h b/include/hardware/gralloc1.h
index 4845010..0a6843f 100644
--- a/include/hardware/gralloc1.h
+++ b/include/hardware/gralloc1.h
@@ -18,7 +18,7 @@
 #define ANDROID_HARDWARE_GRALLOC1_H
 
 #include <hardware/hardware.h>
-#include <system/window.h>
+#include <cutils/native_handle.h>
 
 __BEGIN_DECLS
 
diff --git a/include/hardware/tv_input.h b/include/hardware/tv_input.h
index ed3fafb..b421d43 100644
--- a/include/hardware/tv_input.h
+++ b/include/hardware/tv_input.h
@@ -23,7 +23,7 @@
 
 #include <hardware/hardware.h>
 #include <system/audio.h>
-#include <system/window.h>
+#include <cutils/native_handle.h>
 
 __BEGIN_DECLS
 
diff --git a/modules/radio/radio_hw.c b/modules/radio/radio_hw.c
index cdc3ef3..29204df 100644
--- a/modules/radio/radio_hw.c
+++ b/modules/radio/radio_hw.c
@@ -323,6 +323,7 @@
 
                 case CMD_CONFIG: {
                     tuner->config = cmd->config;
+                    tuner->config.antenna_connected = true;
                     event.type = RADIO_EVENT_CONFIG;
                     event.config = tuner->config;
                     ALOGV("%s CMD_CONFIG type %d low %d up %d",
diff --git a/tests/hardware/struct-last.cpp b/tests/hardware/struct-last.cpp
index 44a7b2d..276d786 100644
--- a/tests/hardware/struct-last.cpp
+++ b/tests/hardware/struct-last.cpp
@@ -15,7 +15,6 @@
  */
 
 #include <cstddef>
-#include <system/window.h>
 #include <hardware/hardware.h>
 #include <hardware/sensors.h>
 #include <hardware/fb.h>
diff --git a/tests/hardware/struct-offset.cpp b/tests/hardware/struct-offset.cpp
index 7f7f2e0..6f86f03 100644
--- a/tests/hardware/struct-offset.cpp
+++ b/tests/hardware/struct-offset.cpp
@@ -15,7 +15,6 @@
  */
 
 #include <cstddef>
-#include <system/window.h>
 #include <hardware/hardware.h>
 #include <hardware/sensors.h>
 #include <hardware/fb.h>
diff --git a/tests/hardware/struct-size.cpp b/tests/hardware/struct-size.cpp
index acb9d2d..232b55d 100644
--- a/tests/hardware/struct-size.cpp
+++ b/tests/hardware/struct-size.cpp
@@ -15,7 +15,6 @@
  */
 
 
-#include <system/window.h>
 #include <hardware/hardware.h>
 #include <hardware/sensors.h>
 #include <hardware/fb.h>
diff --git a/tests/hwc/Android.mk b/tests/hwc/Android.mk
index 367f5f4..0416ff1 100644
--- a/tests/hwc/Android.mk
+++ b/tests/hwc/Android.mk
@@ -4,12 +4,13 @@
 LOCAL_MODULE := libcnativewindow 
 LOCAL_SRC_FILES := cnativewindow.c util.c
 LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_SHARED_LIBRARIES := libEGL libGLESv2 libdl libhardware libnativewindow
 include $(BUILD_STATIC_LIBRARY)
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := hwc-test-arrows
 LOCAL_SRC_FILES := test-arrows.c
 LOCAL_STATIC_LIBRARIES := libcnativewindow
-LOCAL_SHARED_LIBRARIES := libEGL libGLESv2 libdl libhardware
+LOCAL_SHARED_LIBRARIES := libEGL libGLESv2 libdl libhardware libnativewindow
 LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES
 include $(BUILD_EXECUTABLE)