Merge tag 'android-6.0.0_r26' into HEAD

Android 6.0.0 release 26

* tag 'android-6.0.0_r26':
  Define the data parameter for POWER_HINT_INTERACTION.
  HWC: Add a color transform attribute per display

Change-Id: I3fd29a6d734563532c7061246488f4c3d274b87a
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index 2389c09..ca7b18b 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -117,6 +117,9 @@
  * or no HW sync is available. */
 #define AUDIO_PARAMETER_HW_AV_SYNC "hw_av_sync"
 
+/* Device state*/
+#define AUDIO_PARAMETER_KEY_DEV_SHUTDOWN "dev_shutdown"
+
 /**
  *  audio stream parameters
  */
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index 3427213..2cba754 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -44,11 +44,13 @@
 #define BT_PROFILE_HEALTH_ID "health"
 #define BT_PROFILE_SOCKETS_ID "socket"
 #define BT_PROFILE_HIDHOST_ID "hidhost"
+#define BT_PROFILE_HIDDEV_ID "hiddev"
 #define BT_PROFILE_PAN_ID "pan"
 #define BT_PROFILE_MAP_CLIENT_ID "map_client"
 #define BT_PROFILE_SDP_CLIENT_ID "sdp"
 #define BT_PROFILE_GATT_ID "gatt"
 #define BT_PROFILE_AV_RC_ID "avrcp"
+#define WIPOWER_PROFILE_ID "wipower"
 #define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
 
 /** Bluetooth Address */
@@ -355,6 +357,10 @@
 /* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
 typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
 
+/** Bluetooth HCI event Callback */
+/* Receive any HCI event from controller for raw commands */
+typedef void (*hci_event_recv_callback)(uint8_t event_code, uint8_t *buf, uint8_t len);
+
 /* LE Test mode callbacks
 * 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 */
@@ -388,6 +394,7 @@
     dut_mode_recv_callback dut_mode_recv_cb;
     le_test_mode_callback le_test_mode_cb;
     energy_info_callback energy_info_cb;
+    hci_event_recv_callback hci_event_recv_cb;
 } bt_callbacks_t;
 
 typedef void (*alarm_cb)(void *data);
@@ -446,6 +453,9 @@
     /** Closes the interface. */
     void (*cleanup)(void);
 
+    /** SSR cleanup. */
+    void (*ssrcleanup)(void);
+
     /** Get all Bluetooth Adapter properties at init */
     int (*get_adapter_properties)(void);
 
@@ -520,6 +530,10 @@
 
     /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
     int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
+
+    /* Send any test HCI command to the controller. */
+    int (*hci_cmd_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
+
     /** BLE Test Mode APIs */
     /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
     int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
@@ -548,6 +562,8 @@
      */
     int (*config_clear)(void);
 
+    /** BT stack Test interface */
+    const void* (*get_testapp_interface)(int test_app_profile);
 } bt_interface_t;
 
 /** TODO: Need to add APIs for Service Discovery, Service authorization and
diff --git a/include/hardware/bt_av.h b/include/hardware/bt_av.h
index 5252a17..be82fbe 100644
--- a/include/hardware/bt_av.h
+++ b/include/hardware/bt_av.h
@@ -1,4 +1,7 @@
 /*
+ * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
  * Copyright (C) 2012 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -47,6 +50,11 @@
 typedef void (* btav_audio_state_callback)(btav_audio_state_t state, 
                                                bt_bdaddr_t *bd_addr);
 
+/** Callback for connection priority of device for incoming connection
+ * btav_connection_priority_t
+ */
+typedef void (* btav_connection_priority_callback)(bt_bdaddr_t *bd_addr);
+
 /** Callback for audio configuration change.
  *  Used only for the A2DP sink interface.
  *  state will have one of the values from btav_audio_state_t
@@ -57,6 +65,18 @@
                                                 uint32_t sample_rate,
                                                 uint8_t channel_count);
 
+/** Callback for updating apps for A2dp multicast state.
+ */
+
+typedef void (* btav_is_multicast_enabled_callback)(int state);
+
+/*
+ * Callback for audio focus request to be used only in
+ * case of A2DP Sink. This is required because we are using
+ * AudioTrack approach for audio data rendering.
+ */
+typedef void (* btav_audio_focus_request_callback)(bt_bdaddr_t *bd_addr);
+
 /** BT-AV callback structure. */
 typedef struct {
     /** set to sizeof(btav_callbacks_t) */
@@ -64,6 +84,9 @@
     btav_connection_state_callback  connection_state_cb;
     btav_audio_state_callback audio_state_cb;
     btav_audio_config_callback audio_config_cb;
+    btav_connection_priority_callback connection_priority_cb;
+    btav_is_multicast_enabled_callback multicast_state_cb;
+    btav_audio_focus_request_callback audio_focus_request_cb;
 } btav_callbacks_t;
 
 /** 
@@ -86,7 +109,8 @@
     /**
      * Register the BtAv callbacks
      */
-    bt_status_t (*init)( btav_callbacks_t* callbacks );
+    bt_status_t (*init)( btav_callbacks_t* callbacks , int max_a2dp_connections,
+                        int a2dp_multicast_state);
 
     /** connect to headset */
     bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
@@ -96,6 +120,12 @@
 
     /** Closes the interface. */
     void  (*cleanup)( void );
+
+    /** Send priority of device to stack*/
+    void (*allow_connection)( int is_valid , bt_bdaddr_t *bd_addr);
+
+    /** Sends Audio Focus State. */
+    void  (*audio_focus_state)( int focus_state );
 } btav_interface_t;
 
 __END_DECLS
diff --git a/include/hardware/bt_hd.h b/include/hardware/bt_hd.h
new file mode 100644
index 0000000..6ba5b09
--- /dev/null
+++ b/include/hardware/bt_hd.h
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Not a Contribution
+ * Copyright (C) 2012 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 ANDROID_INCLUDE_BT_HD_H
+#define ANDROID_INCLUDE_BT_HD_H
+
+#include <stdint.h>
+
+__BEGIN_DECLS
+
+typedef enum
+{
+    BTHD_REPORT_TYPE_OTHER = 0,
+    BTHD_REPORT_TYPE_INPUT,
+    BTHD_REPORT_TYPE_OUTPUT,
+    BTHD_REPORT_TYPE_FEATURE,
+    BTHD_REPORT_TYPE_INTRDATA // special value for reports to be sent on INTR (INPUT is assumed)
+} bthd_report_type_t;
+
+typedef enum
+{
+    BTHD_APP_STATE_NOT_REGISTERED,
+    BTHD_APP_STATE_REGISTERED
+} bthd_application_state_t;
+
+typedef enum
+{
+    BTHD_CONN_STATE_CONNECTED,
+    BTHD_CONN_STATE_CONNECTING,
+    BTHD_CONN_STATE_DISCONNECTED,
+    BTHD_CONN_STATE_DISCONNECTING,
+    BTHD_CONN_STATE_UNKNOWN
+} bthd_connection_state_t;
+
+typedef struct
+{
+    const char      *name;
+    const char      *description;
+    const char      *provider;
+    uint8_t         subclass;
+    uint8_t         *desc_list;
+    int             desc_list_len;
+} bthd_app_param_t;
+
+typedef struct
+{
+    uint8_t  service_type;
+    uint32_t token_rate;
+    uint32_t token_bucket_size;
+    uint32_t peak_bandwidth;
+    uint32_t access_latency;
+    uint32_t delay_variation;
+} bthd_qos_param_t;
+
+typedef void (* bthd_application_state_callback)(bt_bdaddr_t *bd_addr, bthd_application_state_t state);
+typedef void (* bthd_connection_state_callback)(bt_bdaddr_t *bd_addr, bthd_connection_state_t state);
+typedef void (* bthd_get_report_callback)(uint8_t type, uint8_t id, uint16_t buffer_size);
+typedef void (* bthd_set_report_callback)(uint8_t type, uint8_t id, uint16_t len, uint8_t *p_data);
+typedef void (* bthd_set_protocol_callback)(uint8_t protocol);
+typedef void (* bthd_intr_data_callback)(uint8_t report_id, uint16_t len, uint8_t *p_data);
+typedef void (* bthd_vc_unplug_callback)(void);
+
+/** BT-HD callbacks */
+typedef struct {
+    size_t      size;
+
+    bthd_application_state_callback application_state_cb;
+    bthd_connection_state_callback  connection_state_cb;
+    bthd_get_report_callback        get_report_cb;
+    bthd_set_report_callback        set_report_cb;
+    bthd_set_protocol_callback      set_protocol_cb;
+    bthd_intr_data_callback         intr_data_cb;
+    bthd_vc_unplug_callback         vc_unplug_cb;
+} bthd_callbacks_t;
+
+/** BT-HD interface */
+typedef struct {
+
+    size_t          size;
+
+    /** init interface and register callbacks */
+    bt_status_t (*init)(bthd_callbacks_t* callbacks);
+
+    /** close interface */
+    void  (*cleanup)(void);
+
+    /** register application */
+    bt_status_t (*register_app)(bthd_app_param_t *app_param, bthd_qos_param_t *in_qos,
+                                            bthd_qos_param_t *out_qos);
+
+    /** unregister application */
+    bt_status_t (*unregister_app)(void);
+
+    /** connects to host with virtual cable */
+    bt_status_t (*connect)(void);
+
+    /** disconnects from currently connected host */
+    bt_status_t (*disconnect)(void);
+
+    /** send report */
+    bt_status_t (*send_report)(bthd_report_type_t type, uint8_t id, uint16_t len, uint8_t *p_data);
+
+    /** notifies error for invalid SET_REPORT */
+    bt_status_t (*report_error)(uint8_t error);
+
+    /** send Virtual Cable Unplug  */
+    bt_status_t (*virtual_cable_unplug)(void);
+
+} bthd_interface_t;
+
+__END_DECLS
+
+#endif /* ANDROID_INCLUDE_BT_HD_H */
+
diff --git a/include/hardware/bt_hf.h b/include/hardware/bt_hf.h
index 7dcb40a..dbac061 100644
--- a/include/hardware/bt_hf.h
+++ b/include/hardware/bt_hf.h
@@ -65,6 +65,15 @@
    BTHF_WBS_YES
 }bthf_wbs_config_t;
 
+/* BIND type*/
+typedef enum
+{
+   BTHF_BIND_SET,
+   BTHF_BIND_READ,
+   BTHF_BIND_TEST
+}bthf_bind_type_t;
+
+
 /* CHLD - Call held handling */
 typedef enum
 {
@@ -152,6 +161,15 @@
  */
 typedef void (* bthf_key_pressed_cmd_callback)(bt_bdaddr_t *bd_addr);
 
+/** Callback for HF indicators (BIND)
+ */
+typedef void (* bthf_bind_cmd_callback)(char* hf_ind, bthf_bind_type_t type, bt_bdaddr_t *bd_addr);
+
+/** Callback for HF indicator value (BIEV)
+ */
+typedef void (* bthf_biev_cmd_callback)(char* hf_ind_val, bt_bdaddr_t *bd_addr);
+
+
 /** BT-HF callback structure. */
 typedef struct {
     /** set to sizeof(BtHfCallbacks) */
@@ -173,6 +191,8 @@
     bthf_clcc_cmd_callback          clcc_cmd_cb;
     bthf_unknown_at_cmd_callback    unknown_at_cmd_cb;
     bthf_key_pressed_cmd_callback   key_pressed_cmd_cb;
+    bthf_bind_cmd_callback          bind_cmd_cb;
+    bthf_biev_cmd_callback          biev_cmd_cb;
 } bthf_callbacks_t;
 
 /** Network Status */
@@ -216,9 +236,25 @@
 } bthf_call_mpty_type_t;
 
 typedef enum {
+    BTHF_HF_INDICATOR_STATE_DISABLED = 0,
+    BTHF_HF_INDICATOR_STATE_ENABLED
+} bthf_hf_indicator_status_t;
+
+typedef enum {
     BTHF_CALL_ADDRTYPE_UNKNOWN = 0x81,
     BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91
 } bthf_call_addrtype_t;
+
+typedef enum {
+    BTHF_VOIP_CALL_NETWORK_TYPE_MOBILE = 0,
+    BTHF_VOIP_CALL_NETWORK_TYPE_WIFI
+} bthf_voip_call_network_type_t;
+
+typedef enum {
+    BTHF_VOIP_STATE_STOPPED = 0,
+    BTHF_VOIP_STATE_STARTED
+} bthf_voip_state_t;
+
 /** Represents the standard BT-HF interface. */
 typedef struct {
 
@@ -294,6 +330,17 @@
 
     /** configureation for the SCO codec */
     bt_status_t (*configure_wbs)( bt_bdaddr_t *bd_addr ,bthf_wbs_config_t config );
+
+    /** Response for BIND READ command and activation/deactivation of  HF indicator */
+    bt_status_t (*bind_response) (int anum, bthf_hf_indicator_status_t status,
+                                  bt_bdaddr_t *bd_addr);
+
+    /** Response for BIND TEST command */
+    bt_status_t (*bind_string_response) (const char* result, bt_bdaddr_t *bd_addr);
+
+    /** Sends connectivity network type used by Voip currently to stack */
+    bt_status_t (*voip_network_type_wifi) (bthf_voip_state_t is_voip_started,
+                                           bthf_voip_call_network_type_t is_network_wifi);
 } bthf_interface_t;
 
 __END_DECLS
diff --git a/include/hardware/bt_hf_client.h b/include/hardware/bt_hf_client.h
index 8acf1b2..0577e97 100644
--- a/include/hardware/bt_hf_client.h
+++ b/include/hardware/bt_hf_client.h
@@ -266,6 +266,16 @@
  */
 typedef void (* bthf_client_ring_indication_callback) (void);
 
+/**
+ * Callback for sending cgmi indication to app
+ */
+typedef void (* bthf_client_cgmi_indication_callback) (const char *str);
+
+/**
+ * Callback for sending cgmm indication to app
+ */
+typedef void (* bthf_client_cgmm_indication_callback) (const char *str);
+
 /** BT-HF callback structure. */
 typedef struct {
     /** set to sizeof(BtHfClientCallbacks) */
@@ -291,6 +301,8 @@
     bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb;
     bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback;
     bthf_client_ring_indication_callback   ring_indication_cb;
+    bthf_client_cgmi_indication_callback   cgmi_cb;
+    bthf_client_cgmm_indication_callback   cgmm_cb;
 } bthf_client_callbacks_t;
 
 /** Represents the standard BT-HF interface. */
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/bt_rc.h b/include/hardware/bt_rc.h
index c565c48..6e1109d 100644
--- a/include/hardware/bt_rc.h
+++ b/include/hardware/bt_rc.h
@@ -1,4 +1,7 @@
 /*
+ * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
  * Copyright (C) 2012 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,6 +29,7 @@
 #define BTRC_MAX_FOLDER_DEPTH       4
 #define BTRC_MAX_APP_ATTR_SIZE      16
 #define BTRC_MAX_ELEM_ATTR_SIZE     7
+#define BTRC_CHARSET_UTF8           0x006A
 
 typedef uint8_t btrc_uid_t[BTRC_UID_SIZE];
 
@@ -52,11 +56,24 @@
     BTRC_EVT_TRACK_REACHED_START = 0x04,
     BTRC_EVT_PLAY_POS_CHANGED = 0x05,
     BTRC_EVT_APP_SETTINGS_CHANGED = 0x08,
+    BTRC_EVT_NOW_PLAYING_CONTENT_CHANGED = 0x09,
+    BTRC_EVT_AVAILABLE_PLAYERS_CHANGED = 0x0a,
+    BTRC_EVT_ADDRESSED_PLAYER_CHANGED = 0x0b,
 } btrc_event_id_t;
 
+//used for Scope
+typedef enum {
+    BTRC_EVT_MEDIA_PLAYLIST = 0,
+    BTRC_EVT_MEDIA_VIRTUALFILESYST = 1,
+    BTRC_EVT_SEARCH = 2,
+    BTRC_EVT_NOWPLAYING = 3,
+    BTRC_EVT_MAX_BROWSE = 4,
+} btrc_browse_folderitem_t;
+
 typedef enum {
     BTRC_NOTIFICATION_TYPE_INTERIM = 0,
     BTRC_NOTIFICATION_TYPE_CHANGED = 1,
+    BTRC_NOTIFICATION_TYPE_REJECT = 2,
 } btrc_notification_type_t;
 
 typedef enum {
@@ -97,18 +114,33 @@
     BTRC_STS_NO_ERROR       = 0x04  /* Operation Success */
 } btrc_status_t;
 
+typedef enum {
+    BTRC_TYPE_MEDIA_PLAYER = 0x01,
+    BTRC_TYPE_FOLDER = 0x02,
+    BTRC_TYPE_MEDIA_ELEMENT = 0x03
+} btrc_folder_list_item_type_t;
+
 typedef struct {
     uint8_t num_attr;
     uint8_t attr_ids[BTRC_MAX_APP_SETTINGS];
     uint8_t attr_values[BTRC_MAX_APP_SETTINGS];
 } btrc_player_settings_t;
 
+typedef struct {
+    uint32_t start_item;
+    uint32_t end_item;
+    uint32_t size;
+    uint32_t attrs[BTRC_MAX_ELEM_ATTR_SIZE];
+    uint8_t  attr_count;
+}btrc_getfolderitem_t;
+
 typedef union
 {
     btrc_play_status_t play_status;
     btrc_uid_t track; /* queue position in NowPlaying */
     uint32_t song_pos;
     btrc_player_settings_t player_setting;
+    uint16_t player_id;
 } btrc_register_notification_t;
 
 typedef struct {
@@ -124,54 +156,156 @@
 /** Callback for the controller's supported feautres */
 typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr,
                                                       btrc_remote_features_t features);
+#define BTRC_FEATURE_MASK_SIZE 16
+
+typedef uint8_t btrc_feature_mask_t[BTRC_FEATURE_MASK_SIZE];
+
+typedef struct {
+    uint16_t              charset_id;
+    uint16_t              str_len;
+    uint8_t               *p_str;
+} btrc_player_full_name_t;
+
+typedef struct
+{
+    uint32_t              sub_type;
+    uint16_t              player_id;
+    uint8_t               major_type;
+    uint8_t               play_status;
+    btrc_feature_mask_t   features;       /* Supported feature bit mask*/
+    btrc_player_full_name_t     name;           /* The player name, name length and character set id.*/
+} btrc_folder_list_item_player_t;
+
+typedef struct
+{
+    uint64_t                    uid;
+    uint8_t                     type;
+    uint8_t                     playable;
+    btrc_player_full_name_t     name;
+} btrc_folder_list_item_folder_t;
+
+typedef struct
+{
+    uint32_t                    attr_id;
+    btrc_player_full_name_t     name;
+} btrc_attr_entry_t;
+
+typedef struct
+{
+    uint64_t                    uid;
+    uint8_t                     type;
+    uint8_t                     attr_count;
+    btrc_player_full_name_t     name;
+    btrc_attr_entry_t*          p_attr_list;
+} btrc_folder_list_item_media_t;
+
+typedef struct {
+    uint16_t              str_len;
+    uint8_t               *p_str;
+} btrc_name_t;
+
+/* SetBrowsedPlayer */
+typedef struct
+{
+    uint32_t              num_items;
+    uint16_t              uid_counter;
+    uint16_t              charset_id;
+    uint8_t               status;
+    uint8_t               folder_depth;
+    btrc_name_t           *p_folders;
+} btrc_set_browsed_player_rsp_t;
+
+typedef struct
+{
+    uint8_t                          item_type;
+    union
+    {
+        btrc_folder_list_item_player_t   player;
+        btrc_folder_list_item_folder_t   folder;
+        btrc_folder_list_item_media_t    media;
+    } u;
+} btrc_folder_list_item_t;
+
+/* GetFolderItems */
+typedef struct
+{
+    uint16_t                  uid_counter;
+    uint16_t                  item_count;
+    uint8_t                   status;
+    btrc_folder_list_item_t   *p_item_list;
+} btrc_folder_list_entries_t;
 
 /** Callback for play status request */
-typedef void (* btrc_get_play_status_callback)();
+typedef void (* btrc_get_play_status_callback)(bt_bdaddr_t *bd_addr);
 
 /** Callback for list player application attributes (Shuffle, Repeat,...) */
-typedef void (* btrc_list_player_app_attr_callback)();
+typedef void (* btrc_list_player_app_attr_callback)(bt_bdaddr_t *bd_addr);
 
 /** Callback for list player application attributes (Shuffle, Repeat,...) */
-typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id);
+typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id,
+        bt_bdaddr_t *bd_addr);
 
 /** Callback for getting the current player application settings value
 **  num_attr: specifies the number of attribute ids contained in p_attrs
 */
-typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
+typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs,
+        bt_bdaddr_t *bd_addr);
 
 /** Callback for getting the player application settings attributes' text
 **  num_attr: specifies the number of attribute ids contained in p_attrs
 */
-typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
+typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr,
+        btrc_player_attr_t *p_attrs, bt_bdaddr_t *bd_addr);
 
 /** Callback for getting the player application settings values' text
 **  num_attr: specifies the number of value ids contained in p_vals
 */
-typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, uint8_t num_val, uint8_t *p_vals);
+typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id,
+         uint8_t num_val, uint8_t *p_vals, bt_bdaddr_t *bd_addr);
 
 /** Callback for setting the player application settings values */
-typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals);
+typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals,
+        bt_bdaddr_t *bd_addr);
 
 /** Callback to fetch the get element attributes of the current song
 **  num_attr: specifies the number of attributes requested in p_attrs
 */
-typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs);
+typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs,
+        bt_bdaddr_t *bd_addr);
 
 /** Callback for register notification (Play state change/track change/...)
 **  param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED
 */
-typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param);
+typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param,
+        bt_bdaddr_t *bd_addr);
 
 /* AVRCP 1.4 Enhancements */
 /** Callback for volume change on CT
 **  volume: Current volume setting on the CT (0-127)
 */
-typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype);
+typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype, bt_bdaddr_t *bd_addr);
 
 /** Callback for passthrough commands */
-typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state);
+typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state, bt_bdaddr_t *bd_addr);
 
 /** BT-RC Target callback structure. */
+
+typedef void (* btrc_get_folder_items_callback) (btrc_browse_folderitem_t id,
+                  btrc_getfolderitem_t *param, bt_bdaddr_t *bd_addr);
+
+typedef void (* btrc_set_addressed_player_callback) (uint32_t player_id, bt_bdaddr_t *bd_addr);
+
+typedef void (* btrc_set_browsed_player_callback) (uint32_t player_id, bt_bdaddr_t *bd_addr);
+
+typedef void (* btrc_change_path_callback) (uint8_t direction, uint64_t uid, bt_bdaddr_t *bd_addr);
+
+typedef void (* btrc_play_item_callback) (uint8_t scope, uint64_t uid, bt_bdaddr_t *bd_addr);
+
+typedef void (* btrc_get_item_attr_callback) (uint8_t scope, uint64_t uid,
+                  uint8_t num_attr, btrc_media_attr_t *p_attrs, bt_bdaddr_t *bd_addr);
+
+typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr);
+
 typedef struct {
     /** set to sizeof(BtRcCallbacks) */
     size_t      size;
@@ -187,6 +321,13 @@
     btrc_register_notification_callback         register_notification_cb;
     btrc_volume_change_callback                 volume_change_cb;
     btrc_passthrough_cmd_callback               passthrough_cmd_cb;
+    btrc_get_folder_items_callback              get_folderitems_cb;
+    btrc_set_addressed_player_callback          set_addrplayer_cb;
+    btrc_set_browsed_player_callback            set_browsed_player_cb;
+    btrc_change_path_callback                   change_path_cb;
+    btrc_play_item_callback                     play_item_cb;
+    btrc_get_item_attr_callback                 get_item_attr_cb;
+    btrc_connection_state_callback              connection_state_cb;
 } btrc_callbacks_t;
 
 /** Represents the standard BT-RC AVRCP Target interface. */
@@ -197,47 +338,54 @@
     /**
      * Register the BtRc callbacks
      */
-    bt_status_t (*init)( btrc_callbacks_t* callbacks );
+    bt_status_t (*init)( btrc_callbacks_t* callbacks , int max_avrcp_connections);
 
     /** Respose to GetPlayStatus request. Contains the current
     **  1. Play status
     **  2. Song duration/length
     **  3. Song position
     */
-    bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, uint32_t song_pos);
+    bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len,
+                 uint32_t song_pos, bt_bdaddr_t *bd_addr);
 
     /** Lists the support player application attributes (Shuffle/Repeat/...)
     **  num_attr: Specifies the number of attributes contained in the pointer p_attrs
     */
-    bt_status_t (*list_player_app_attr_rsp)( int num_attr, btrc_player_attr_t *p_attrs);
+    bt_status_t (*list_player_app_attr_rsp)( uint8_t num_attr, btrc_player_attr_t *p_attrs,
+            bt_bdaddr_t *bd_addr);
 
     /** Lists the support player application attributes (Shuffle Off/On/Group)
     **  num_val: Specifies the number of values contained in the pointer p_vals
     */
-    bt_status_t (*list_player_app_value_rsp)( int num_val, uint8_t *p_vals);
+    bt_status_t (*list_player_app_value_rsp)( uint8_t num_val, uint8_t *p_vals,
+            bt_bdaddr_t *bd_addr);
 
     /** Returns the current application attribute values for each of the specified attr_id */
-    bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals);
+    bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals,
+            bt_bdaddr_t *bd_addr);
 
     /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
     **  num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
     */
-    bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs);
+    bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs,
+            bt_bdaddr_t *bd_addr);
 
     /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
     **  num_attr: Specifies the number of attribute values' text contained in the pointer p_vals
     */
-    bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals);
+    bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals,
+            bt_bdaddr_t *bd_addr);
 
     /** Returns the current songs' element attributes text ("Title"/"Album"/"Artist")
     **  num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
     */
-    bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
+    bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs,
+            bt_bdaddr_t *bd_addr);
 
     /** Response to set player attribute request ("Shuffle"/"Repeat")
     **  rsp_status: Status of setting the player attributes for the current media player
     */
-    bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status);
+    bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status, bt_bdaddr_t *bd_addr);
 
     /* Response to the register notification request (Play state change/track change/...).
     ** event_id: Refers to the event_id this notification change corresponds too
@@ -246,7 +394,8 @@
     */
     bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id,
                                              btrc_notification_type_t type,
-                                             btrc_register_notification_t *p_param);
+                                             btrc_register_notification_t *p_param,
+                                             bt_bdaddr_t *bd_addr);
 
     /* AVRCP 1.4 enhancements */
 
@@ -255,7 +404,18 @@
     ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level
     ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set
     */
-    bt_status_t (*set_volume)(uint8_t volume);
+    bt_status_t (*set_volume)(uint8_t volume, bt_bdaddr_t *bd_addr);
+    bt_status_t (*get_folder_items_rsp) (btrc_folder_list_entries_t *p_param, bt_bdaddr_t *bd_addr);
+
+    bt_status_t (*set_addressed_player_rsp) (btrc_status_t status_code, bt_bdaddr_t *bd_addr);
+    bt_status_t (*set_browsed_player_rsp) (btrc_set_browsed_player_rsp_t *p_param,
+            bt_bdaddr_t *bd_addr);
+    bt_status_t (*change_path_rsp) (uint8_t status_code, uint32_t item_count,
+            bt_bdaddr_t *bd_addr);
+    bt_status_t (*play_item_rsp) (uint8_t status_code, bt_bdaddr_t *bd_addr);
+    bt_status_t (*get_item_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs,
+            bt_bdaddr_t *bd_addr);
+    bt_status_t (*is_device_active_in_handoff) (bt_bdaddr_t *bd_addr);
 
     /** Closes the interface. */
     void  (*cleanup)( void );
@@ -266,12 +426,51 @@
 
 typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr);
 
+typedef void (* btrc_ctrl_getrcfeatures_callback) (bt_bdaddr_t *bd_addr, int features);
+
+typedef void (* btrc_ctrl_getcapability_rsp_callback) (bt_bdaddr_t *bd_addr, int cap_id,
+                                 uint32_t* supported_values, int num_supported, uint8_t rsp_type);
+
+typedef void (* btrc_ctrl_listplayerappsettingattrib_rsp_callback) (bt_bdaddr_t *bd_addr,
+                                     uint8_t* supported_attribs, int num_attrib, uint8_t rsp_type);
+
+typedef void (* btrc_ctrl_listplayerappsettingvalue_rsp_callback) (bt_bdaddr_t *bd_addr,
+                                        uint8_t* supported_val, uint8_t num_supported, uint8_t rsp_type);
+
+typedef void (* btrc_ctrl_currentplayerappsetting_rsp_callback) (bt_bdaddr_t *bd_addr,uint8_t* supported_ids,
+                                                 uint8_t* supported_val, uint8_t num_attrib, uint8_t rsp_type);
+
+typedef void (* btrc_ctrl_setplayerapplicationsetting_rsp_callback) (bt_bdaddr_t *bd_addr,uint8_t rsp_type);
+
+typedef void (* btrc_ctrl_notification_rsp_callback) (bt_bdaddr_t *bd_addr, uint8_t rsp_type,
+                                 int rsp_len, uint8_t* notification_rsp);
+
+typedef void (* btrc_ctrl_getelementattrib_rsp_callback) (bt_bdaddr_t *bd_addr, uint8_t num_attributes,
+                                                          int rsp_len, uint8_t* attrib_rsp, uint8_t rsp_type);
+
+typedef void (* btrc_ctrl_getplaystatus_rsp_callback) (bt_bdaddr_t *bd_addr, int param_len, uint8_t* play_status_rsp
+                                                                           ,uint8_t rsp_type);
+
+typedef void (* btrc_ctrl_setabsvol_cmd_callback) (bt_bdaddr_t *bd_addr, uint8_t abs_vol);
+
+typedef void (* btrc_ctrl_registernotification_abs_vol_callback) (bt_bdaddr_t *bd_addr);
 /** BT-RC Controller callback structure. */
 typedef struct {
     /** set to sizeof(BtRcCallbacks) */
     size_t      size;
-    btrc_passthrough_rsp_callback               passthrough_rsp_cb;
-    btrc_connection_state_callback              connection_state_cb;
+    btrc_passthrough_rsp_callback                              passthrough_rsp_cb;
+    btrc_connection_state_callback                             connection_state_cb;
+    btrc_ctrl_getrcfeatures_callback                           getrcfeatures_cb;
+    btrc_ctrl_getcapability_rsp_callback                       getcap_rsp_cb;
+    btrc_ctrl_listplayerappsettingattrib_rsp_callback          listplayerappsettingattrib_rsp_cb;
+    btrc_ctrl_listplayerappsettingvalue_rsp_callback           listplayerappsettingvalue_rsp_cb;
+    btrc_ctrl_currentplayerappsetting_rsp_callback             currentplayerappsetting_rsp_cb;
+    btrc_ctrl_setplayerapplicationsetting_rsp_callback         setplayerappsetting_rsp_cb;
+    btrc_ctrl_notification_rsp_callback                        notification_rsp_cb;
+    btrc_ctrl_getelementattrib_rsp_callback                    getelementattrib_rsp_cb;
+    btrc_ctrl_getplaystatus_rsp_callback                       getplaystatus_rsp_cb;
+    btrc_ctrl_setabsvol_cmd_callback                           setabsvol_cmd_cb;
+    btrc_ctrl_registernotification_abs_vol_callback            registernotification_absvol_cb;
 } btrc_ctrl_callbacks_t;
 
 /** Represents the standard BT-RC AVRCP Controller interface. */
@@ -285,7 +484,39 @@
     bt_status_t (*init)( btrc_ctrl_callbacks_t* callbacks );
 
     /** send pass through command to target */
-    bt_status_t (*send_pass_through_cmd) ( bt_bdaddr_t *bd_addr, uint8_t key_code, uint8_t key_state );
+    bt_status_t (*send_pass_through_cmd) ( bt_bdaddr_t *bd_addr, uint8_t key_code,
+            uint8_t key_state );
+
+    /** send get_cap command to target */
+    bt_status_t (*getcapabilities_cmd) (uint8_t cap_id);
+
+    /** send command to get supported player application settings to  target */
+    bt_status_t (*list_player_app_setting_attrib_cmd) (void);
+
+    /** send command to get supported  values of player application settings for a
+     * particular attribute to  target */
+    bt_status_t (*list_player_app_setting_value_cmd) (uint8_t attrib_id);
+
+    /** send command to get current player attributes to target */
+    bt_status_t (*get_player_app_setting_cmd) (uint8_t num_attrib, uint8_t* attrib_ids);
+
+    /** send command to set player applicaiton setting attributes to target */
+    bt_status_t (*set_player_app_setting_cmd) (uint8_t num_attrib, uint8_t* attrib_ids, uint8_t* attrib_vals);
+
+    /** send command to register for supported notificaiton events to target */
+    bt_status_t (*register_notification_cmd) (uint8_t event_id, uint32_t event_value);
+
+    /** send command to get element attribute  to target */
+    bt_status_t (*get_element_attribute_cmd) (uint8_t num_attribute, uint32_t attribute_id);
+
+    /** send command to get play status to target */
+    bt_status_t (*get_play_status_cmd) (void);
+
+    /** send rsp to set_abs_vol received from target */
+    bt_status_t (*send_abs_vol_rsp) (uint8_t abs_vol);
+
+    /** send notificaiton rsp for abs vol to target */
+    bt_status_t (*send_register_abs_vol_rsp) (uint8_t rsp_type, uint8_t abs_vol);
 
     /** Closes the interface. */
     void  (*cleanup)( void );
diff --git a/include/hardware/bt_sock.h b/include/hardware/bt_sock.h
index 5d206d7..9dd83bb 100644
--- a/include/hardware/bt_sock.h
+++ b/include/hardware/bt_sock.h
@@ -30,6 +30,12 @@
     BTSOCK_L2CAP = 3
 } btsock_type_t;
 
+typedef enum {
+    BTSOCK_OPT_GET_MODEM_BITS = 1,
+    BTSOCK_OPT_SET_MODEM_BITS = 2,
+    BTSOCK_OPT_CLR_MODEM_BITS = 3,
+} btsock_option_type_t;
+
 /** Represents the standard BT SOCKET interface. */
 typedef struct {
     short size;
@@ -66,6 +72,19 @@
      */
     bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid,
             int channel, int* sock_fd, int flags);
+
+    /*
+     * get socket option of rfcomm channel socket.
+     */
+    bt_status_t (*get_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name,
+            void *option_value, int *option_len);
+    /*
+
+     * set socket option of rfcomm channel socket.
+     */
+    bt_status_t (*set_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name,
+            void *option_value, int option_len);
+
 } btsock_interface_t;
 
 __END_DECLS
diff --git a/include/hardware/hwcomposer_defs.h b/include/hardware/hwcomposer_defs.h
index a19a26c..9c7d790 100644
--- a/include/hardware/hwcomposer_defs.h
+++ b/include/hardware/hwcomposer_defs.h
@@ -207,15 +207,17 @@
 enum {
     HWC_DISPLAY_PRIMARY     = 0,
     HWC_DISPLAY_EXTERNAL    = 1,    // HDMI, DP, etc.
-    HWC_DISPLAY_VIRTUAL     = 2,
+    HWC_DISPLAY_TERTIARY    = 2,
+    HWC_DISPLAY_VIRTUAL     = 3,
 
-    HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2,
-    HWC_NUM_DISPLAY_TYPES          = 3,
+    HWC_NUM_PHYSICAL_DISPLAY_TYPES = 3,
+    HWC_NUM_DISPLAY_TYPES          = 4,
 };
 
 enum {
     HWC_DISPLAY_PRIMARY_BIT     = 1 << HWC_DISPLAY_PRIMARY,
     HWC_DISPLAY_EXTERNAL_BIT    = 1 << HWC_DISPLAY_EXTERNAL,
+    HWC_DISPLAY_TERTIARY_BIT    = 1 << HWC_DISPLAY_TERTIARY,
     HWC_DISPLAY_VIRTUAL_BIT     = 1 << HWC_DISPLAY_VIRTUAL,
 };
 
diff --git a/include/hardware/tv_input.h b/include/hardware/tv_input.h
index ed3fafb..456b06e 100644
--- a/include/hardware/tv_input.h
+++ b/include/hardware/tv_input.h
@@ -278,6 +278,9 @@
 
     /* OUT: Client must allocate a buffer with this format. */
     uint32_t format;
+
+    /* OUT: Client must allocate buffers based on this count. */
+    uint32_t buffer_count;
 } buffer_producer_stream_t;
 
 typedef struct tv_stream {
diff --git a/include/hardware/wipower.h b/include/hardware/wipower.h
new file mode 100644
index 0000000..eb3a0ee
--- /dev/null
+++ b/include/hardware/wipower.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of The Linux Foundation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ANDROID_INCLUDE_WIPOWER_H
+#define ANDROID_INCLUDE_WIPOWER_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <stdbool.h>
+
+#include <hardware/hardware.h>
+#include <hardware/bluetooth.h>
+
+__BEGIN_DECLS
+
+typedef enum {
+   OFF =0,
+   ON
+} wipower_state_t;
+
+
+typedef struct {
+
+unsigned char optional;
+unsigned short rect_voltage;
+unsigned short rect_current;
+unsigned short out_voltage;
+unsigned short out_current;
+unsigned char temp;
+unsigned short rect_voltage_min;
+unsigned short rect_voltage_set;
+unsigned short rect_voltage_max;
+unsigned char alert;
+unsigned short rfu1;
+unsigned char rfu2;
+
+}__attribute__((packed)) wipower_dyn_data_t;
+
+/** Bluetooth Enable/Disable Callback. */
+typedef void (*wipower_state_changed_callback)(wipower_state_t state);
+
+
+typedef void (*wipower_alerts)(unsigned char alert);
+
+
+typedef void (*wipower_dynamic_data)(wipower_dyn_data_t* alert_data);
+
+
+typedef void (*wipower_power_apply)(unsigned char power_flag);
+
+typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
+
+/** Bluetooth DM callback structure. */
+typedef struct {
+    /** set to sizeof(wipower_callbacks_t) */
+    size_t size;
+    wipower_state_changed_callback wipower_state_changed_cb;
+    wipower_alerts wipower_alert;
+    wipower_dynamic_data wipower_data;
+    wipower_power_apply wipower_power_event;
+    callback_thread_event callback_thread_event;
+} wipower_callbacks_t;
+
+
+/** Represents the standard Wipower interface. */
+typedef struct {
+    /** set to sizeof(wipower_interface_t) */
+    size_t size;
+
+    /** Initialize Wipower modules*/
+    int (*init)(wipower_callbacks_t *wp_callbacks);
+
+    /** Enable/Disable Wipower charging */
+    int (*enable)(bool enable);
+
+    int (*set_current_limit)(short value);
+
+    unsigned char (*get_current_limit)(void);
+
+    wipower_state_t (*get_state)(void);
+
+    /** Enable/Disable Wipower charging */
+    int (*enable_alerts)(bool enable);
+
+    int (*enable_data_notify)(bool enable);
+    int (*enable_power_apply)(bool enable, bool on, bool time_flag);
+} wipower_interface_t;
+
+
+__END_DECLS
+
+#endif /* ANDROID_INCLUDE_WIPOWER_H */
diff --git a/modules/sensors/Android.mk b/modules/sensors/Android.mk
index 445f69e..94d100b 100644
--- a/modules/sensors/Android.mk
+++ b/modules/sensors/Android.mk
@@ -20,9 +20,9 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE := sensors.$(TARGET_DEVICE)
+LOCAL_MODULE := sensors.$(TARGET_BOARD_PLATFORM)
 
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_MODULE_RELATIVE_PATH := hw
 
 LOCAL_CFLAGS := -DLOG_TAG=\"MultiHal\"
 
diff --git a/modules/sensors/multihal.cpp b/modules/sensors/multihal.cpp
index cd67f6d..5fedd4d 100644
--- a/modules/sensors/multihal.cpp
+++ b/modules/sensors/multihal.cpp
@@ -27,6 +27,8 @@
 #include <cutils/log.h>
 
 #include <vector>
+#include <string>
+#include <fstream>
 #include <map>
 #include <string>
 
@@ -36,8 +38,6 @@
 
 
 static const char* CONFIG_FILENAME = "/system/etc/sensors/hals.conf";
-static const char* LEGAL_SUBHAL_PATH_PREFIX = "/system/lib/hw/";
-static const char* LEGAL_SUBHAL_ALTERNATE_PATH_PREFIX = "/system/vendor/lib/";
 static const int MAX_CONF_LINE_LENGTH = 1024;
 
 static pthread_mutex_t init_modules_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -463,39 +463,19 @@
  * Adds valid paths from the config file to the vector passed in.
  * The vector must not be null.
  */
-static void get_so_paths(std::vector<char*> *so_paths) {
-    FILE *conf_file = fopen(CONFIG_FILENAME, "r");
-    if (conf_file == NULL) {
+static void get_so_paths(std::vector<std::string> *so_paths) {
+    std::string line;
+    std::ifstream conf_file(CONFIG_FILENAME);
+
+    if(!conf_file) {
         ALOGW("No multihal config file found at %s", CONFIG_FILENAME);
         return;
     }
     ALOGV("Multihal config file found at %s", CONFIG_FILENAME);
-    char *line = NULL;
-    size_t len = 0;
-    int line_count = 0;
-    while (getline(&line, &len, conf_file) != -1) {
-        // overwrite trailing eoln with null char
-        char* pch = strchr(line, '\n');
-        if (pch != NULL) {
-            *pch = '\0';
-        }
-        ALOGV("config file line #%d: '%s'", ++line_count, line);
-        char *real_path = realpath(line, NULL);
-        if (starts_with(real_path, LEGAL_SUBHAL_PATH_PREFIX) ||
-		starts_with(real_path, LEGAL_SUBHAL_ALTERNATE_PATH_PREFIX)) {
-            ALOGV("accepting valid path '%s'", real_path);
-            char* compact_line = new char[strlen(real_path) + 1];
-            strcpy(compact_line, real_path);
-            so_paths->push_back(compact_line);
-        } else {
-            ALOGW("rejecting path '%s' because it does not start with '%s' or '%s'",
-                    real_path, LEGAL_SUBHAL_PATH_PREFIX, LEGAL_SUBHAL_ALTERNATE_PATH_PREFIX);
-        }
-        free(real_path);
+    while (std::getline(conf_file, line)) {
+        ALOGV("config file line: '%s'", line.c_str());
+        so_paths->push_back(line);
     }
-    free(line);
-    fclose(conf_file);
-    ALOGV("hals.conf contained %d lines", line_count);
 }
 
 /*
@@ -508,15 +488,15 @@
         pthread_mutex_unlock(&init_modules_mutex);
         return;
     }
-    std::vector<char*> *so_paths = new std::vector<char*>();
+    std::vector<std::string> *so_paths = new std::vector<std::string>();
     get_so_paths(so_paths);
 
     // dlopen the module files and cache their module symbols in sub_hw_modules
     sub_hw_modules = new std::vector<hw_module_t *>();
     dlerror(); // clear any old errors
     const char* sym = HAL_MODULE_INFO_SYM_AS_STR;
-    for (std::vector<char*>::iterator it = so_paths->begin(); it != so_paths->end(); it++) {
-        char* path = *it;
+    for (std::vector<std::string>::iterator it = so_paths->begin(); it != so_paths->end(); it++) {
+        const char* path = it->c_str();
         void* lib_handle = dlopen(path, RTLD_LAZY);
         if (lib_handle == NULL) {
             ALOGW("dlerror(): %s", dlerror());