Merge "Add heart rate monitor, stringType and requiredPermissions to sensors.h" into klp-modular-dev
diff --git a/include/hardware/bt_gatt_client.h b/include/hardware/bt_gatt_client.h
index cf4fabe..11b146d 100644
--- a/include/hardware/bt_gatt_client.h
+++ b/include/hardware/bt_gatt_client.h
@@ -156,6 +156,9 @@
  */
 typedef void (*listen_callback)(int status, int server_if);
 
+/** Callback invoked when the MTU for a given connection changes */
+typedef void (*configure_mtu_callback)(int conn_id, int status, int mtu);
+
 typedef struct {
     register_client_callback            register_client_cb;
     scan_result_callback                scan_result_cb;
@@ -175,6 +178,7 @@
     execute_write_callback              execute_write_cb;
     read_remote_rssi_callback           read_remote_rssi_cb;
     listen_callback                     listen_cb;
+    configure_mtu_callback              configure_mtu_cb;
 } btgatt_client_callbacks_t;
 
 /** Represents the standard BT-GATT client interface. */
@@ -282,6 +286,9 @@
                     uint16_t service_data_len, char* service_data,
                     uint16_t service_uuid_len, char* service_uuid);
 
+    /** Configure the MTU for a given connection */
+    bt_status_t (*configure_mtu)(int conn_id, int mtu);
+
     /** Test mode interface */
     bt_status_t (*test_command)( int command, btgatt_test_params_t* params);
 } btgatt_client_interface_t;
diff --git a/include/hardware/hdmi_cec.h b/include/hardware/hdmi_cec.h
index a697334..de6c70c 100644
--- a/include/hardware/hdmi_cec.h
+++ b/include/hardware/hdmi_cec.h
@@ -34,6 +34,7 @@
 #define HDMI_CEC_HARDWARE_INTERFACE "hdmi_cec_hw_if"
 
 typedef enum cec_device_type {
+    CEC_DEVICE_INACTIVE = -1,
     CEC_DEVICE_TV = 0,
     CEC_DEVICE_RECORDER = 1,
     CEC_DEVICE_RESERVED = 2,
@@ -127,7 +128,20 @@
     CEC_MESSAGE_GET_CEC_VERSION = 0x9F,
     CEC_MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0,
     CEC_MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1,
-    CEC_MESSAGE_SET_EXTERNAL_TIMER = 0xA2
+    CEC_MESSAGE_SET_EXTERNAL_TIMER = 0xA2,
+    CEC_MESSAGE_ABORT = 0xFF
+};
+
+/*
+ * Operand description [Abort Reason]
+ */
+enum abort_reason {
+    ABORT_UNRECOGNIZED_MODE = 0,
+    ABORT_NOT_IN_CORRECT_MODE = 1,
+    ABORT_CANNOT_PROVIDE_SOURCE = 2,
+    ABORT_INVALID_OPERAND = 3,
+    ABORT_REFUSED = 4,
+    ABORT_UNABLE_TO_DETERMINE = 5
 };
 
 /*
@@ -210,13 +224,15 @@
      * (*allocate_logical_address)() allocates a new logical address
      * for a given device type. The address is written to addr. The HAL
      * implementation is also expected to configure itself to start receiving
-     * the messages addressed to the allocated one. If allocation
-     * is not successful the addr will be set to CEC_ADDR_UNREGISTERED.
+     * the messages addressed to the allocated one. If the address has been already
+     * allocated, it should simply return the allocated address without attempting
+     * the allocation again. If allocation is not successful the addr will be
+     * set to CEC_ADDR_UNREGISTERED.
      *
      * Returns 0 on success or -errno on error.
      */
     int (*allocate_logical_address)(const struct hdmi_cec_device* dev,
-            int device_type, cec_logical_address_t* addr);
+            cec_device_type_t device_type, cec_logical_address_t* addr);
 
     /*
      * (*get_logical_address)() returns the logical address already allocated
@@ -232,7 +248,7 @@
      * Returns 0 on success or -errno on error.
      */
     int (*get_logical_address)(const struct hdmi_cec_device* dev,
-            int device_type, cec_logical_address_t* addr);
+            cec_device_type_t device_type, cec_logical_address_t* addr);
     /*
      * (*get_physical_address)() returns the CEC physical address. The
      * address is written to addr.
@@ -251,8 +267,7 @@
      *
      * Returns 0 on success or -errno on error.
      */
-    int (*send_message)(const struct hdmi_cec_device* dev,
-            const cec_message_t*);
+    int (*send_message)(const struct hdmi_cec_device* dev, const cec_message_t*);
 
     /*
      * (*register_event_callback)() registers a callback that HDMI-CEC HAL
diff --git a/modules/sensors/multihal.cpp b/modules/sensors/multihal.cpp
index a145c37..36345f9 100644
--- a/modules/sensors/multihal.cpp
+++ b/modules/sensors/multihal.cpp
@@ -214,9 +214,11 @@
 }
 
 int sensors_poll_context_t::activate(int handle, int enabled) {
+    int retval = -EINVAL;
     ALOGV("activate");
     sensors_poll_device_t* v0 = this->get_v0_device_by_handle(handle);
-    int retval = v0->activate(v0, get_local_handle(handle), enabled);
+    if (v0)
+        retval = v0->activate(v0, get_local_handle(handle), enabled);
     ALOGV("retval %d", retval);
     return retval;
 }
@@ -576,7 +578,8 @@
         sensors_module_t *sensors_module = (sensors_module_t*) *it;
         struct hw_device_t* sub_hw_device;
         int sub_open_result = sensors_module->common.methods->open(*it, name, &sub_hw_device);
-        dev->addSubHwDevice(sub_hw_device);
+        if (!sub_open_result)
+            dev->addSubHwDevice(sub_hw_device);
     }
 
     // Prepare the output param and return