LE low power scan feature

LE low power extended scan feature stack changes
based on Google BLE spec v0.95

Bug: 20029342
Change-Id: I1db2d9bb648295340d0e93ca89d27e1b938d33d3
diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c
index 64a084d..8f54d7a 100644
--- a/bta/dm/bta_dm_act.c
+++ b/bta/dm/bta_dm_act.c
@@ -4607,12 +4607,30 @@
 **
 ** Function         bta_dm_ble_set_scan_params
 **
+** Description      This function sets BLE scan parameters.
+**
+** Parameters:
+**
+*******************************************************************************/
+void bta_dm_ble_set_scan_params(tBTA_DM_MSG *p_data)
+{
+    BTM_BleSetScanParams(p_data->ble_set_scan_params.client_if,
+                         p_data->ble_set_scan_params.scan_int,
+                         p_data->ble_set_scan_params.scan_window,
+                         p_data->ble_set_scan_params.scan_mode,
+                         p_data->ble_set_scan_params.scan_param_setup_cback);
+}
+
+/*******************************************************************************
+**
+** Function         bta_dm_ble_set_conn_scan_params
+**
 ** Description      This function set the preferred connection scan parameters.
 **
 ** Parameters:
 **
 *******************************************************************************/
-void bta_dm_ble_set_scan_params (tBTA_DM_MSG *p_data)
+void bta_dm_ble_set_conn_scan_params (tBTA_DM_MSG *p_data)
 {
     BTM_BleSetConnScanParams(p_data->ble_set_scan_params.scan_int,
                              p_data->ble_set_scan_params.scan_window);
@@ -4689,7 +4707,7 @@
 }
 /*******************************************************************************
 **
-** Function         bta_dm_ble_set_scan_params
+** Function         bta_dm_ble_set_adv_params
 **
 ** Description      This function set the adv parameters.
 **
diff --git a/bta/dm/bta_dm_api.c b/bta/dm/bta_dm_api.c
index 9995e17..819656c 100644
--- a/bta/dm/bta_dm_api.c
+++ b/bta/dm/bta_dm_api.c
@@ -903,23 +903,52 @@
 ** Returns          void
 **
 *******************************************************************************/
-void BTA_DmSetBleConnScanParams(UINT16 scan_interval, UINT16 scan_window )
+void BTA_DmSetBleConnScanParams(UINT32 scan_interval, UINT32 scan_window)
 {
-#if BLE_INCLUDED == TRUE
-    tBTA_DM_API_BLE_SCAN_PARAMS    *p_msg;
-
-    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
+    tBTA_DM_API_BLE_SCAN_PARAMS  *p_msg;
+    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
-
-        p_msg->hdr.event = BTA_DM_API_BLE_SCAN_PARAM_EVT;
-
+        p_msg->hdr.event = BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT;
         p_msg->scan_int         = scan_interval;
         p_msg->scan_window      = scan_window;
+        bta_sys_sendmsg(p_msg);
+    }
+}
+
+/*******************************************************************************
+**
+** Function         BTA_DmSetBleScanParams
+**
+** Description      This function is called to set scan parameters
+**
+** Parameters:      client_if - Client IF
+**                  scan_interval - scan interval
+**                  scan_window - scan window
+**                  scan_mode - scan mode
+**                  scan_param_setup_status_cback - Set scan param status callback
+**
+** Returns          void
+**
+*******************************************************************************/
+void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
+                            UINT32 scan_window, tBLE_SCAN_MODE scan_mode,
+                            tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback)
+{
+    tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
+
+    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
+    {
+        memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
+        p_msg->hdr.event = BTA_DM_API_BLE_SCAN_PARAM_EVT;
+        p_msg->client_if = client_if;
+        p_msg->scan_int = scan_interval;
+        p_msg->scan_window = scan_window;
+        p_msg->scan_mode = scan_mode;
+        p_msg->scan_param_setup_cback = scan_param_setup_cback;
 
         bta_sys_sendmsg(p_msg);
     }
-#endif
 }
 
 /*******************************************************************************
@@ -1084,7 +1113,7 @@
 ** Returns          None
 **
 *******************************************************************************/
-extern void BTA_DmBleEnableBatchScan(tBTA_BLE_SCAN_MODE scan_mode,
+extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode,
                                          UINT32 scan_interval, UINT32 scan_window,
                                          tBTA_BLE_DISCARD_RULE discard_rule,
                                          tBLE_ADDR_TYPE        addr_type,
@@ -1141,7 +1170,7 @@
 ** Returns          None
 **
 *******************************************************************************/
-extern void BTA_DmBleReadScanReports(tBTA_BLE_SCAN_MODE scan_type,
+extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type,
                                              tBTA_DM_BLE_REF_VALUE ref_value)
 {
     tBTA_DM_API_READ_SCAN_REPORTS  *p_msg;
diff --git a/bta/dm/bta_dm_int.h b/bta/dm/bta_dm_int.h
index cabe88e..cdd2b97 100644
--- a/bta/dm/bta_dm_int.h
+++ b/bta/dm/bta_dm_int.h
@@ -90,6 +90,7 @@
     BTA_DM_API_BLE_SET_BG_CONN_TYPE,
     BTA_DM_API_BLE_CONN_PARAM_EVT,
     BTA_DM_API_BLE_SCAN_PARAM_EVT,
+    BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT,
     BTA_DM_API_BLE_OBSERVE_EVT,
     BTA_DM_API_UPDATE_CONN_PARAM_EVT,
 #if BLE_PRIVACY_SPT == TRUE
@@ -453,9 +454,12 @@
 /* set scan parameter for BLE connections */
 typedef struct
 {
-    BT_HDR                  hdr;
-    UINT16                  scan_int;
-    UINT16                  scan_window;
+    BT_HDR hdr;
+    tBTA_GATTC_IF client_if;
+    UINT32 scan_int;
+    UINT32 scan_window;
+    tBLE_SCAN_MODE scan_mode;
+    tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback;
 }tBTA_DM_API_BLE_SCAN_PARAMS;
 
 /* Data type for start/stop observe */
@@ -544,7 +548,7 @@
 typedef struct
 {
     BT_HDR                  hdr;
-    tBTA_BLE_SCAN_MODE      scan_mode;
+    tBTA_BLE_BATCH_SCAN_MODE  scan_mode;
     UINT32                  scan_int;
     UINT32                  scan_window;
     tBTA_BLE_DISCARD_RULE   discard_rule;
@@ -561,7 +565,7 @@
 typedef struct
 {
     BT_HDR                  hdr;
-    tBTA_BLE_SCAN_MODE scan_type;
+    tBTA_BLE_BATCH_SCAN_MODE scan_type;
     tBTA_DM_BLE_REF_VALUE    ref_value;
 } tBTA_DM_API_READ_SCAN_REPORTS;
 
@@ -1059,6 +1063,7 @@
 extern void bta_dm_ble_set_bg_conn_type (tBTA_DM_MSG *p_data);
 extern void bta_dm_ble_set_conn_params (tBTA_DM_MSG *p_data);
 extern void bta_dm_ble_set_scan_params (tBTA_DM_MSG *p_data);
+extern void bta_dm_ble_set_conn_scan_params (tBTA_DM_MSG *p_data);
 extern void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data);
 extern void bta_dm_ble_observe (tBTA_DM_MSG *p_data);
 extern void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data);
diff --git a/bta/dm/bta_dm_main.c b/bta/dm/bta_dm_main.c
index 450151a..27c4682 100644
--- a/bta/dm/bta_dm_main.c
+++ b/bta/dm/bta_dm_main.c
@@ -85,14 +85,15 @@
     bta_dm_ble_confirm_reply,   /*  BTA_DM_API_BLE_CONFIRM_REPLY_EVT    */
     bta_dm_security_grant,
     bta_dm_ble_set_bg_conn_type,
-    bta_dm_ble_set_conn_params,      /* BTA_DM_API_BLE_CONN_PARAM_EVT */
-    bta_dm_ble_set_scan_params,      /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
+    bta_dm_ble_set_conn_params,  /* BTA_DM_API_BLE_CONN_PARAM_EVT */
+    bta_dm_ble_set_scan_params,  /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
+    bta_dm_ble_set_conn_scan_params,  /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
     bta_dm_ble_observe,
     bta_dm_ble_update_conn_params,   /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
 #if BLE_PRIVACY_SPT == TRUE
     bta_dm_ble_config_local_privacy,   /* BTA_DM_API_LOCAL_PRIVACY_EVT */
 #endif
-    bta_dm_ble_set_adv_params,     /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
+    bta_dm_ble_set_adv_params,     /* BTA_DM_API_BLE_ADV_PARAM_EVT */
     bta_dm_ble_set_adv_config,     /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
     bta_dm_ble_set_scan_rsp,       /* BTA_DM_API_BLE_SET_SCAN_RSP_EVT */
     bta_dm_ble_broadcast,          /* BTA_DM_API_BLE_BROADCAST_EVT */