Merge tag android-5.1.0_r1 into AOSP_5.1_MERGE

Change-Id: Ib3d2c00278b1d78cfedd965e06ae41078ed033fc
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index 2389c09..c400c74 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -1,5 +1,7 @@
 /*
  * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,6 +30,9 @@
 #include <hardware/hardware.h>
 #include <system/audio.h>
 #include <hardware/audio_effect.h>
+#ifdef AUDIO_LISTEN_ENABLED
+#include <listen_types.h>
+#endif
 
 __BEGIN_DECLS
 
@@ -442,7 +447,8 @@
     size_t chan_samp_sz;
     audio_format_t format = s->get_format(s);
 
-    if (audio_is_linear_pcm(format)) {
+    if (audio_is_linear_pcm(format) &&
+            format != AUDIO_FORMAT_PCM_8_24_BIT) {
         chan_samp_sz = audio_bytes_per_sample(format);
         return popcount(s->get_channels(s)) * chan_samp_sz;
     }
@@ -649,6 +655,28 @@
     int (*set_audio_port_config)(struct audio_hw_device *dev,
                          const struct audio_port_config *config);
 
+#ifdef AUDIO_LISTEN_ENABLED
+    /** This method creates the listen session and returns handle */
+    int (*open_listen_session)(struct audio_hw_device *dev,
+                              listen_open_params_t *params,
+                              struct listen_session** handle);
+
+    /** This method closes the listen session  */
+    int (*close_listen_session)(struct audio_hw_device *dev,
+                                struct listen_session* handle);
+
+    /** This method sets the mad observer callback  */
+    int (*set_mad_observer)(struct audio_hw_device *dev,
+                            listen_callback_t cb_func);
+
+    /**
+     *   This method is used for setting listen hal specfic parameters.
+     *  If multiple paramets are set in one call and setting any one of them
+     *  fails it will return failure.
+     */
+    int (*listen_set_parameters)(struct audio_hw_device *dev,
+                                 const char *kv_pairs);
+#endif
 };
 typedef struct audio_hw_device audio_hw_device_t;
 
diff --git a/include/hardware/audio_effect.h b/include/hardware/audio_effect.h
index ee48e4c..267dc42 100644
--- a/include/hardware/audio_effect.h
+++ b/include/hardware/audio_effect.h
@@ -439,6 +439,7 @@
    EFFECT_CMD_SET_AUDIO_SOURCE,     // set the audio source (see audio.h, audio_source_t)
    EFFECT_CMD_OFFLOAD,              // set if effect thread is an offload one,
                                     // send the ioHandle of the effect thread
+   EFFECT_CMD_HW_ACC,
    EFFECT_CMD_FIRST_PROPRIETARY = 0x10000 // first proprietary command code
 };
 
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index 74cd1fc..1280767 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -1,4 +1,7 @@
 /*
+ * 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");
@@ -44,11 +47,14 @@
 #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_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 */
@@ -132,7 +138,6 @@
    char name[256]; // what's the maximum length
 } bt_service_record_t;
 
-
 /** Bluetooth Remote Version info */
 typedef struct
 {
@@ -153,6 +158,16 @@
     uint8_t activity_energy_info_supported;
 }bt_local_le_features_t;
 
+/* Bluetooth Remote DI record */
+typedef struct
+{
+    int       vendor;
+    int       vendor_id_source;
+    int       product;
+    int       version;
+    int       spec_id;
+} bt_remote_di_record_t;
+
 /* Bluetooth Adapter and Remote Device property types */
 typedef enum {
     /* Properties common to both adapter and remote device */
@@ -242,6 +257,21 @@
      */
     BT_PROPERTY_LOCAL_LE_FEATURES,
 
+   /**
+    * Description - Trust value of the remote device
+    * Access mode - GET and SET
+    * Data type   - boolean.
+    */
+    BT_PROPERTY_REMOTE_TRUST_VALUE = 0xFD,
+
+    /* Properties unique to remote device */
+    /**
+     * Description - DI Record of the remote device
+     * Access mode - GET
+     * Data type   - bt_remote_di_record_t.
+     */
+    BT_PROPERTY_REMOTE_DI_RECORD = 0xFE,
+
     BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
 } bt_property_type_t;
 
@@ -315,7 +345,7 @@
 
 /** Bluetooth Legacy PinKey Request callback */
 typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr,
-                                        bt_bdname_t *bd_name, uint32_t cod);
+                                        bt_bdname_t *bd_name, uint32_t cod, uint8_t secure);
 
 /** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
 /** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
@@ -337,6 +367,20 @@
 /** Bluetooth ACL connection state changed callback */
 typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
                                             bt_acl_state_t state);
+/**  Callback invoked when write rssi threshold command complete */
+typedef void (*le_lpp_write_rssi_thresh_callback) (bt_bdaddr_t *bda, int status);
+
+/**  Callback invoked when read rssi threshold command complete */
+typedef void (*le_lpp_read_rssi_thresh_callback)(bt_bdaddr_t *bda, int low, int upper,
+                                                 int alert, int status);
+
+/**  Callback invoked when enable or disable rssi monitor command complete */
+typedef void (*le_lpp_enable_rssi_monitor_callback)(bt_bdaddr_t *bda,
+                                                    int enable, int status);
+
+/**  Callback triggered when rssi threshold event reported */
+typedef void (*le_lpp_rssi_threshold_evt_callback)(bt_bdaddr_t *bda,
+                                                   int evt_type, int rssi);
 
 typedef enum {
     ASSOCIATE_JVM,
@@ -385,6 +429,10 @@
     dut_mode_recv_callback dut_mode_recv_cb;
     le_test_mode_callback le_test_mode_cb;
     energy_info_callback energy_info_cb;
+    le_lpp_write_rssi_thresh_callback          le_lpp_write_rssi_thresh_cb;
+    le_lpp_read_rssi_thresh_callback           le_lpp_read_rssi_thresh_cb;
+    le_lpp_enable_rssi_monitor_callback        le_lpp_enable_rssi_monitor_cb;
+    le_lpp_rssi_threshold_evt_callback         le_lpp_rssi_threshold_evt_cb;
 } bt_callbacks_t;
 
 typedef void (*alarm_cb)(void *data);
@@ -434,6 +482,9 @@
      */
     int (*init)(bt_callbacks_t* callbacks );
 
+    /*adds callbacks for QC related calls to the btif env*/
+    int (*initq)(bt_callbacks_t* callbacks);
+
     /** Enable Bluetooth. */
     int (*enable)(void);
 
@@ -443,6 +494,9 @@
     /** Closes the interface. */
     void (*cleanup)(void);
 
+    /** SSR cleanup. */
+    void (*ssrcleanup)(void);
+
     /** Get all Bluetooth Adapter properties at init */
     int (*get_adapter_properties)(void);
 
@@ -533,6 +587,13 @@
       * Success indicates that the VSC command was sent to controller
       */
     int (*read_energy_info)();
+    /** BT stack Test interface */
+    const void* (*get_testapp_interface)(int test_app_profile);
+    /** rssi monitoring */
+    bt_status_t (*le_lpp_write_rssi_threshold)(const bt_bdaddr_t *remote_bda, char min, char max);
+    bt_status_t (*le_lpp_enable_rssi_monitor)(const bt_bdaddr_t *remote_bda, int enable);
+    bt_status_t (*le_lpp_read_rssi_threshold)(const bt_bdaddr_t *remote_bda);
+
 } 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
old mode 100644
new mode 100755
index 5252a17..88af757
--- a/include/hardware/bt_av.h
+++ b/include/hardware/bt_av.h
@@ -38,13 +38,13 @@
 /** Callback for connection state change.
  *  state will have one of the values from btav_connection_state_t
  */
-typedef void (* btav_connection_state_callback)(btav_connection_state_t state, 
+typedef void (* btav_connection_state_callback)(btav_connection_state_t state,
                                                     bt_bdaddr_t *bd_addr);
 
 /** Callback for audiopath state change.
  *  state will have one of the values from btav_audio_state_t
  */
-typedef void (* btav_audio_state_callback)(btav_audio_state_t state, 
+typedef void (* btav_audio_state_callback)(btav_audio_state_t state,
                                                bt_bdaddr_t *bd_addr);
 
 /** Callback for audio configuration change.
@@ -56,7 +56,16 @@
 typedef void (* btav_audio_config_callback)(bt_bdaddr_t *bd_addr,
                                                 uint32_t sample_rate,
                                                 uint8_t channel_count);
+/** 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 requesting audio focus.
+ *  enable will be either TRUE or FALSE
+ */
+typedef void (* btav_audio_focus_request_callback)(int enable,
+                                                bt_bdaddr_t *bd_addr);
 /** BT-AV callback structure. */
 typedef struct {
     /** set to sizeof(btav_callbacks_t) */
@@ -64,17 +73,19 @@
     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_audio_focus_request_callback audio_focus_request_cb;
 } btav_callbacks_t;
 
-/** 
+/**
  * NOTE:
  *
  * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands
- *    shall be handled internally via uinput 
+ *    shall be handled internally via uinput
  *
  * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger
  *    android_audio_hw library and the Bluetooth stack.
- * 
+ *
  */
 /** Represents the standard BT-AV interface.
  *  Used for both the A2DP source and sink interfaces.
@@ -96,8 +107,39 @@
 
     /** Closes the interface. */
     void  (*cleanup)( void );
+
+    /** Send priority of device to stack*/
+    void (*allow_connection)( int is_valid );
 } btav_interface_t;
 
+typedef struct {
+
+    /** set to sizeof(btav_interface_t) */
+    size_t          size;
+    /**
+     * Register the BtAv callbacks
+     */
+    bt_status_t (*init)( btav_callbacks_t* callbacks );
+
+    /** connect to headset */
+    bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
+
+    /** dis-connect from headset */
+    bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
+
+    /** Closes the interface. */
+    void  (*cleanup)( void );
+
+    /* suspend stream for A2DP Sink */
+    void (*suspend_sink)( void );
+
+    /* resume stream for A2DP Sink */
+    void (*resume_sink)( void );
+
+    /* inform audio focus state */
+    void (*audio_focus_status)( int is_enable );
+} btav_sink_interface_t;
+
 __END_DECLS
 
 #endif /* ANDROID_INCLUDE_BT_AV_H */
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..15c26e9 100644
--- a/include/hardware/bt_hf.h
+++ b/include/hardware/bt_hf.h
@@ -1,4 +1,6 @@
-/*
+/* 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");
@@ -229,6 +231,9 @@
      */
     bt_status_t (*init)( bthf_callbacks_t* callbacks, int max_hf_clients);
 
+    /** Set the feature bitmask */
+    bt_status_t (*init_features)( int feature_bitmask );
+
     /** connect to headset */
     bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
 
@@ -289,6 +294,9 @@
     bt_status_t (*phone_state_change) (int num_active, int num_held, bthf_call_state_t call_setup_state,
                                        const char *number, bthf_call_addrtype_t type);
 
+    /** get remote supported features */
+    int (*get_remote_features)(bt_bdaddr_t *bd_addr);
+
     /** Closes the interface. */
     void  (*cleanup)( void );
 
diff --git a/include/hardware/bt_hh.h b/include/hardware/bt_hh.h
index dad9586..feaf845 100644
--- a/include/hardware/bt_hh.h
+++ b/include/hardware/bt_hh.h
@@ -80,6 +80,7 @@
     int         product_id;
     int         version;
     uint8_t     ctry_code;
+    int         priority;
     int         dl_len;
     uint8_t     dsc_list[BTHH_MAX_DSC_LEN];
 } bthh_hid_info_t;
@@ -165,6 +166,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 +181,10 @@
     /** Send data to HID device. */
     bt_status_t (*send_data)(bt_bdaddr_t *bd_addr, char* data);
 
-	/** Closes the interface. */
+    /** Set the Device Priority */
+    bt_status_t (*set_priority)(bt_bdaddr_t *bd_addr, int priority);
+
+    /** 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..20fe3bf 100644
--- a/include/hardware/bt_rc.h
+++ b/include/hardware/bt_rc.h
@@ -26,6 +26,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 +53,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 +111,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,6 +153,84 @@
 /** 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)();
@@ -172,6 +279,21 @@
 typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state);
 
 /** BT-RC Target callback structure. */
+
+typedef void (* btrc_get_folder_items_callback) (btrc_browse_folderitem_t id,
+                                                        btrc_getfolderitem_t *param);
+
+typedef void (* btrc_set_addressed_player_callback) (uint32_t player_id);
+
+typedef void (* btrc_set_browsed_player_callback) (uint32_t player_id);
+
+typedef void (* btrc_change_path_callback) (uint8_t direction, uint64_t uid);
+
+typedef void (* btrc_play_item_callback) (uint8_t scope, uint64_t uid);
+
+typedef void (* btrc_get_item_attr_callback) (uint8_t scope, uint64_t uid,
+                                    uint8_t num_attr, btrc_media_attr_t *p_attrs);
+
 typedef struct {
     /** set to sizeof(BtRcCallbacks) */
     size_t      size;
@@ -187,6 +309,12 @@
     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_callbacks_t;
 
 /** Represents the standard BT-RC AVRCP Target interface. */
@@ -209,12 +337,12 @@
     /** 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);
 
     /** 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);
 
     /** 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);
@@ -256,6 +384,13 @@
     ** 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 (*get_folder_items_rsp) (btrc_folder_list_entries_t *p_param);
+
+    bt_status_t (*set_addressed_player_rsp) (btrc_status_t status_code);
+    bt_status_t (*set_browsed_player_rsp) (btrc_set_browsed_player_rsp_t *p_param);
+    bt_status_t (*change_path_rsp) (uint8_t status_code, uint32_t item_count);
+    bt_status_t (*play_item_rsp) (uint8_t status_code);
+    bt_status_t (*get_item_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
 
     /** Closes the interface. */
     void  (*cleanup)( void );
diff --git a/include/hardware/bt_sock.h b/include/hardware/bt_sock.h
index a4aa046..bae41f4 100644
--- a/include/hardware/bt_sock.h
+++ b/include/hardware/bt_sock.h
@@ -19,8 +19,9 @@
 
 __BEGIN_DECLS
 
-#define BTSOCK_FLAG_ENCRYPT 1
-#define BTSOCK_FLAG_AUTH (1 << 1)
+#define BTSOCK_FLAG_ENCRYPT   (1)
+#define BTSOCK_FLAG_AUTH      (1 << 1)
+#define BTSOCK_FLAG_AUTH_HIGH (1 << 2)
 
 typedef enum {
     BTSOCK_RFCOMM = 1,
@@ -28,6 +29,14 @@
     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_OPT_SET_PUT_MTU    = 4,
+    BTSOCK_OPT_GET_CONG_STATUS = 5
+} btsock_option_type_t;
+
 /** Represents the standard BT SOCKET interface. */
 typedef struct {
     short size;
@@ -50,6 +59,15 @@
      * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected
      */
     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;
 
diff --git a/include/hardware/gps.h b/include/hardware/gps.h
index e264cf5..fb1f669 100644
--- a/include/hardware/gps.h
+++ b/include/hardware/gps.h
@@ -117,22 +117,38 @@
 
 /** Flags used to specify which aiding data to delete
     when calling delete_aiding_data(). */
-typedef uint16_t GpsAidingData;
+typedef uint32_t GpsAidingData;
 // IMPORTANT: Note that the following values must match
 // constants in GpsLocationProvider.java.
-#define GPS_DELETE_EPHEMERIS        0x0001
-#define GPS_DELETE_ALMANAC          0x0002
-#define GPS_DELETE_POSITION         0x0004
-#define GPS_DELETE_TIME             0x0008
-#define GPS_DELETE_IONO             0x0010
-#define GPS_DELETE_UTC              0x0020
-#define GPS_DELETE_HEALTH           0x0040
-#define GPS_DELETE_SVDIR            0x0080
-#define GPS_DELETE_SVSTEER          0x0100
-#define GPS_DELETE_SADATA           0x0200
-#define GPS_DELETE_RTI              0x0400
-#define GPS_DELETE_CELLDB_INFO      0x8000
-#define GPS_DELETE_ALL              0xFFFF
+#define GPS_DELETE_EPHEMERIS                     0x00000001
+#define GPS_DELETE_ALMANAC                       0x00000002
+#define GPS_DELETE_POSITION                      0x00000004
+#define GPS_DELETE_TIME                          0x00000008
+#define GPS_DELETE_IONO                          0x00000010
+#define GPS_DELETE_UTC                           0x00000020
+#define GPS_DELETE_HEALTH                        0x00000040
+#define GPS_DELETE_SVDIR                         0x00000080
+#define GPS_DELETE_SVSTEER                       0x00000100
+#define GPS_DELETE_SADATA                        0x00000200
+#define GPS_DELETE_RTI                           0x00000400
+#define GPS_DELETE_CELLDB_INFO                   0x00000800
+#define GPS_DELETE_ALMANAC_CORR                  0x00001000
+#define GPS_DELETE_FREQ_BIAS_EST                 0x00002000
+#define GLO_DELETE_EPHEMERIS                     0x00004000
+#define GLO_DELETE_ALMANAC                       0x00008000
+#define GLO_DELETE_SVDIR                         0x00010000
+#define GLO_DELETE_SVSTEER                       0x00020000
+#define GLO_DELETE_ALMANAC_CORR                  0x00040000
+#define GPS_DELETE_TIME_GPS                      0x00080000
+#define GLO_DELETE_TIME                          0x00100000
+#define BDS_DELETE_SVDIR                         0X00200000
+#define BDS_DELETE_SVSTEER                       0X00400000
+#define BDS_DELETE_TIME                          0X00800000
+#define BDS_DELETE_ALMANAC_CORR                  0X01000000
+#define BDS_DELETE_EPHEMERIS                     0X02000000
+#define BDS_DELETE_ALMANAC                       0X04000000
+
+#define GPS_DELETE_ALL                           0xFFFFFFFF
 
 /** AGPS type */
 typedef uint16_t AGpsType;
diff --git a/include/hardware/hwcomposer.h b/include/hardware/hwcomposer.h
index 3dfb4fd..4818d0b 100644
--- a/include/hardware/hwcomposer.h
+++ b/include/hardware/hwcomposer.h
@@ -215,6 +215,10 @@
              */
             hwc_region_t visibleRegionScreen;
 
+            /* Region of the layer changed in the source buffer since
+             * previous frame */
+            hwc_rect_t dirtyRect;
+
             /* Sync fence object that will be signaled when the buffer's
              * contents are available. May be -1 if the contents are already
              * available. This field is only valid during set(), and should be
diff --git a/include/hardware/hwcomposer_defs.h b/include/hardware/hwcomposer_defs.h
index 9a52436..08faa28 100644
--- a/include/hardware/hwcomposer_defs.h
+++ b/include/hardware/hwcomposer_defs.h
@@ -86,7 +86,14 @@
      * composition type of this layer, then the hwcomposer will allow async
      * position updates to this layer via setCursorPositionAsync().
      */
-    HWC_IS_CURSOR_LAYER = 0x00000002
+    HWC_IS_CURSOR_LAYER = 0x00000002,
+
+    /*
+     * HWC_SCREENSHOT_ANIMATOR_LAYER is set by surfaceflinger to indicate that this
+     * layer is a screenshot animating layer.  HWC uses this info to disable rotation
+     * animation on External Display
+     */
+    HWC_SCREENSHOT_ANIMATOR_LAYER = 0x00000004
 };
 
 /*
@@ -115,8 +122,11 @@
        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_CURSOR_OVERLAY =  5,
+
+    /* this layer will be handled in the HWC, using a blit engine */
+    HWC_BLIT = 6,
+};
 /*
  * hwc_layer_t::blending values
  */
@@ -191,11 +201,17 @@
      */
     HWC_DISPLAY_DPI_X                       = 4,
     HWC_DISPLAY_DPI_Y                       = 5,
+    /* Indicates if the display is secure
+     * For HDMI/WFD if the sink supports HDCP, it will be true
+     * Primary panel is always considered secure
+     */
+    HWC_DISPLAY_SECURE                      = 6,
 };
 
 /* Allowed events for hwc_methods::eventControl() */
 enum {
-    HWC_EVENT_VSYNC     = 0
+    HWC_EVENT_VSYNC     = 0,
+    HWC_EVENT_ORIENTATION
 };
 
 /* Display types and associated mask bits. */
diff --git a/include/hardware/power.h b/include/hardware/power.h
index af7799e..bb57625 100644
--- a/include/hardware/power.h
+++ b/include/hardware/power.h
@@ -34,6 +34,12 @@
  */
 #define POWER_HARDWARE_MODULE_ID "power"
 
+/**
+* This definition is used by Camera HAL during  camcorder recording.
+*
+*/
+#define HAS_MULTIMEDIA_HINTS
+
 /*
  * Power hint identifiers passed to (*powerHint)
  */
diff --git a/include/hardware/wipower.h b/include/hardware/wipower.h
new file mode 100644
index 0000000..ab6b3de
--- /dev/null
+++ b/include/hardware/wipower.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2014, 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>
+
+__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);
+
+/** 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;
+} 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/usbaudio/alsa_device_profile.c b/modules/usbaudio/alsa_device_profile.c
index 8e84471..aac1671 100644
--- a/modules/usbaudio/alsa_device_profile.c
+++ b/modules/usbaudio/alsa_device_profile.c
@@ -56,7 +56,7 @@
 
 /* sort these highest -> lowest (to default to best quality) */
 static const unsigned std_sample_rates[] =
-    {48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
+    {192000, 96000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
 
 static void profile_reset(alsa_device_profile* profile)
 {
diff --git a/tests/keymaster/keymaster_test.cpp b/tests/keymaster/keymaster_test.cpp
index 6b76ccb..9520ddc 100644
--- a/tests/keymaster/keymaster_test.cpp
+++ b/tests/keymaster/keymaster_test.cpp
@@ -344,8 +344,8 @@
         ASSERT_EQ(0, keymaster_open(mod, &sDevice))
                 << "Should be able to open the keymaster device";
 
-        ASSERT_EQ(KEYMASTER_MODULE_API_VERSION_0_2, mod->module_api_version)
-                << "Keymaster should implement API version 2";
+        ASSERT_EQ(KEYMASTER_MODULE_API_VERSION_0_3, mod->module_api_version)
+                << "Keymaster should implement API version 3";
 
         ASSERT_TRUE(sDevice->generate_keypair != NULL)
                 << "Should implement generate_keypair";