Merge "Camera: Define error codes for remaining camera_module methods." into lmp-dev
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index 4d38ff7..7c17b64 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -98,6 +98,15 @@
     uint8_t pin[16];
 } __attribute__((packed))bt_pin_code_t;
 
+typedef struct {
+    uint8_t status;
+    uint8_t ctrl_state;     /* stack reported state */
+    uint64_t tx_time;       /* in ms */
+    uint64_t rx_time;       /* in ms */
+    uint64_t idle_time;     /* in ms */
+    uint64_t energy_used;   /* a product of mA, V and ms */
+} __attribute__((packed))bt_activity_energy_info;
+
 /** Bluetooth Adapter Discovery state */
 typedef enum {
     BT_DISCOVERY_STOPPED,
@@ -140,6 +149,7 @@
     uint8_t max_irk_list_size;
     uint8_t max_adv_filter_supported;
     uint8_t scan_result_storage_size;
+    uint8_t activity_energy_info_supported;
 }bt_local_le_features_t;
 
 /* Bluetooth Adapter and Remote Device property types */
@@ -345,6 +355,15 @@
 * This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
 * The num_packets is valid only for le_test_end command */
 typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
+
+/** Callback invoked when energy details are obtained */
+/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
+ * If the ctrl_state value is 0, it means the API call failed
+ * Time values-In milliseconds as returned by the controller
+ * Energy used-Value as returned by the controller
+ * Status-Provides the status of the read_energy_info API call */
+typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info);
+
 /** TODO: Add callbacks for Link Up/Down and other generic
   *  notifications/callbacks */
 
@@ -364,6 +383,7 @@
     callback_thread_event thread_evt_cb;
     dut_mode_recv_callback dut_mode_recv_cb;
     le_test_mode_callback le_test_mode_cb;
+    energy_info_callback energy_info_cb;
 } bt_callbacks_t;
 
 typedef void (*alarm_cb)(void *data);
@@ -507,6 +527,11 @@
       * This should be called immediately after a successful |init|.
       */
     int (*set_os_callouts)(bt_os_callouts_t *callouts);
+
+    /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY
+      * Success indicates that the VSC command was sent to controller
+      */
+    int (*read_energy_info)();
 } bt_interface_t;
 
 /** TODO: Need to add APIs for Service Discovery, Service authorization and
diff --git a/include/hardware/bt_gatt_client.h b/include/hardware/bt_gatt_client.h
index 64c51ab..2f72d3a 100644
--- a/include/hardware/bt_gatt_client.h
+++ b/include/hardware/bt_gatt_client.h
@@ -170,10 +170,6 @@
 /** Callback invoked when a scan filter configuration command has completed */
 typedef void (*scan_filter_status_callback)(int enable, int client_if, int status);
 
-/** Track ADV VSE callback invoked when tracked device is found or lost */
-typedef void (*track_adv_event_callback)(int client_if, int filt_index, int addr_type,
-                                             bt_bdaddr_t* bda, int adv_state);
-
 /** Callback invoked when multi-adv enable operation has completed */
 typedef void (*multi_adv_enable_callback)(int client_if, int status);
 
@@ -205,6 +201,9 @@
 /** Callback invoked when batchscan storage threshold limit is crossed */
 typedef void (*batchscan_threshold_callback)(int client_if);
 
+/** Track ADV VSE callback invoked when tracked device is found or lost */
+typedef void (*track_adv_event_callback)(int client_if, int filt_index, int addr_type,
+                                             bt_bdaddr_t* bda, int adv_state);
 
 typedef struct {
     register_client_callback            register_client_cb;
diff --git a/include/hardware/gralloc.h b/include/hardware/gralloc.h
index e7d0103..91e2f69 100644
--- a/include/hardware/gralloc.h
+++ b/include/hardware/gralloc.h
@@ -124,6 +124,9 @@
      */
     GRALLOC_USAGE_PROTECTED             = 0x00004000,
 
+    /* buffer may be used as a cursor */
+    GRALLOC_USAGE_CURSOR                = 0x00008000,
+
     /* implementation-specific private usage flags */
     GRALLOC_USAGE_PRIVATE_0             = 0x10000000,
     GRALLOC_USAGE_PRIVATE_1             = 0x20000000,
diff --git a/include/hardware/hwcomposer.h b/include/hardware/hwcomposer.h
index af04181..3dfb4fd 100644
--- a/include/hardware/hwcomposer.h
+++ b/include/hardware/hwcomposer.h
@@ -141,6 +141,13 @@
      *   as a solid color since the platform is not currently able to composite
      *   sideband layers with the GPU. This may be improved in future
      *   versions of the platform.
+     *
+     *
+     * HWC_CURSOR_OVERLAY
+     *   Set by the HWC implementation during (*prepare)(), this value
+     *   indicates the layer's composition will now be handled by the HWC.
+     *   Additionally, the client can now asynchronously update the on-screen
+     *   position of this layer using the setCursorPositionAsync() api.
      */
     int32_t compositionType;
 
@@ -505,11 +512,12 @@
      * (*prepare)() can be called more than once, the last call prevails.
      *
      * The HWC responds by setting the compositionType field in each layer to
-     * either HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the
-     * composition for the layer is handled by SurfaceFlinger with OpenGL ES,
-     * in the later case, the HWC will have to handle the layer's composition.
-     * compositionType and hints are preserved between (*prepare)() calles
-     * unless the HWC_GEOMETRY_CHANGED flag is set.
+     * either HWC_FRAMEBUFFER, HWC_OVERLAY, or HWC_CURSOR_OVERLAY. For the
+     * HWC_FRAMEBUFFER type, composition for the layer is handled by
+     * SurfaceFlinger with OpenGL ES. For the latter two overlay types,
+     * the HWC will have to handle the layer's composition. compositionType
+     * and hints are preserved between (*prepare)() calles unless the
+     * HWC_GEOMETRY_CHANGED flag is set.
      *
      * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the
      * list's geometry has changed, that is, when more than just the buffer's
@@ -751,11 +759,37 @@
      */
     int (*setActiveConfig)(struct hwc_composer_device_1* dev, int disp,
             int index);
+    /*
+     * Asynchronously update the location of the cursor layer.
+     *
+     * Within the standard prepare()/set() composition loop, the client
+     * (surfaceflinger) can request that a given layer uses dedicated cursor
+     * composition hardware by specifiying the HWC_IS_CURSOR_LAYER flag. Only
+     * one layer per display can have this flag set. If the layer is suitable
+     * for the platform's cursor hardware, hwcomposer will return from prepare()
+     * a composition type of HWC_CURSOR_OVERLAY for that layer. This indicates
+     * not only that the client is not responsible for compositing that layer,
+     * but also that the client can continue to update the position of that layer
+     * after a call to set(). This can reduce the visible latency of mouse
+     * movement to visible, on-screen cursor updates. Calls to
+     * setCursorPositionAsync() may be made from a different thread doing the
+     * prepare()/set() composition loop, but care must be taken to not interleave
+     * calls of setCursorPositionAsync() between calls of set()/prepare().
+     *
+     * Notes:
+     * - Only one layer per display can be specified as a cursor layer with
+     *   HWC_IS_CURSOR_LAYER.
+     * - hwcomposer will only return one layer per display as HWC_CURSOR_OVERLAY
+     * - This returns 0 on success or -errno on error.
+     * - This field is optional for HWC_DEVICE_API_VERSION_1_4 and later. It
+     *   should be null for previous versions.
+     */
+    int (*setCursorPositionAsync)(struct hwc_composer_device_1 *dev, int disp, int x_pos, int y_pos);
 
     /*
      * Reserved for future use. Must be NULL.
      */
-    void* reserved_proc[2];
+    void* reserved_proc[1];
 
 } hwc_composer_device_1_t;
 
diff --git a/include/hardware/hwcomposer_defs.h b/include/hardware/hwcomposer_defs.h
index d24bc9d..9a52436 100644
--- a/include/hardware/hwcomposer_defs.h
+++ b/include/hardware/hwcomposer_defs.h
@@ -77,6 +77,16 @@
      * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY).
      */
     HWC_SKIP_LAYER = 0x00000001,
+
+    /*
+     * HWC_IS_CURSOR_LAYER is set by surfaceflinger to indicate that this
+     * layer is being used as a cursor on this particular display, and that
+     * surfaceflinger can potentially perform asynchronous position updates for
+     * this layer. If a call to prepare() returns HWC_CURSOR_OVERLAY for the
+     * composition type of this layer, then the hwcomposer will allow async
+     * position updates to this layer via setCursorPositionAsync().
+     */
+    HWC_IS_CURSOR_LAYER = 0x00000002
 };
 
 /*
@@ -100,8 +110,13 @@
     /* this layer's contents are taken from a sideband buffer stream.
      * Added in HWC_DEVICE_API_VERSION_1_4. */
     HWC_SIDEBAND = 4,
-};
 
+    /* this layer's composition will be handled by hwcomposer by dedicated
+       cursor overlay hardware. hwcomposer will also all async position updates
+       of this layer outside of the normal prepare()/set() loop. Added in
+       HWC_DEVICE_API_VERSION_1_4. */
+    HWC_CURSOR_OVERLAY =  5
+ };
 /*
  * hwc_layer_t::blending values
  */
diff --git a/include/hardware/sensors.h b/include/hardware/sensors.h
index ec68b2b..373724e 100644
--- a/include/hardware/sensors.h
+++ b/include/hardware/sensors.h
@@ -611,7 +611,7 @@
  * before (desk, pocket, bag). The only allowed return value is 1.0.
  * This sensor de-activates itself immediately after it triggers.
  */
-#define SENSOR_TYPE_PICK_UP_GESTURE                            (43)
+#define SENSOR_TYPE_PICK_UP_GESTURE                            (44)
 #define SENSOR_STRING_TYPE_PICK_UP_GESTURE                     "android.sensor.pick_up_gesture"
 
 /**
diff --git a/tests/hardware/struct-offset.cpp b/tests/hardware/struct-offset.cpp
index 2354408..a7ff797 100644
--- a/tests/hardware/struct-offset.cpp
+++ b/tests/hardware/struct-offset.cpp
@@ -169,7 +169,8 @@
     CHECK_MEMBER_AT(hwc_composer_device_1_t, getDisplayAttributes, 96, 184);
     CHECK_MEMBER_AT(hwc_composer_device_1_t, getActiveConfig, 100, 192);
     CHECK_MEMBER_AT(hwc_composer_device_1_t, setActiveConfig, 104, 200);
-    CHECK_MEMBER_AT(hwc_composer_device_1_t, reserved_proc, 108, 208);
+    CHECK_MEMBER_AT(hwc_composer_device_1_t, setCursorPositionAsync, 108, 208);
+    CHECK_MEMBER_AT(hwc_composer_device_1_t, reserved_proc, 112, 216);
 
     //Types defined in gralloc.h
     CHECK_MEMBER_AT(gralloc_module_t, common, 0, 0);