am 5e808468: LE: Do not remove bond on encryption failure

* commit '5e808468e0667a6a2a8a1e6de80efbc4f42fa0f0':
  LE: Do not remove bond on encryption failure
diff --git a/btif/include/btif_dm.h b/btif/include/btif_dm.h
index 37f11b7..297e2a9 100644
--- a/btif/include/btif_dm.h
+++ b/btif/include/btif_dm.h
@@ -92,12 +92,19 @@
 
 typedef struct
 {
+    BT_OCTET16          irk;
+    tBLE_ADDR_TYPE      addr_type;
+    BD_ADDR             static_addr;
+}btif_dm_ble_pid_keys_t;
+
+typedef struct
+{
     BOOLEAN                   is_penc_key_rcvd;
     btif_dm_ble_penc_keys_t   penc_key;       /* received peer encryption key */
     BOOLEAN                   is_pcsrk_key_rcvd;
     btif_dm_ble_pcsrk_keys_t  pcsrk_key;       /* received peer device SRK */
     BOOLEAN                   is_pid_key_rcvd;
-    UINT8                     pid_key[BT_OCTET16_LEN];        /* peer device ID key */
+    btif_dm_ble_pid_keys_t    pid_key;        /* peer device ID key */
     BOOLEAN                   is_lenc_key_rcvd;
     btif_dm_ble_lenc_keys_t   lenc_key;       /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
     BOOLEAN                   is_lcsrk_key_rcvd;
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index c110ee8..a10b372 100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -1723,10 +1723,19 @@
                 case BTA_LE_KEY_PID:
                     BTIF_TRACE_DEBUG("Rcv BTA_LE_KEY_PID");
                     pairing_cb.ble.is_pid_key_rcvd = TRUE;
-                    memcpy(pairing_cb.ble.pid_key, p_data->ble_key.key_value.pid_key.irk, 16);
+                    pairing_cb.ble.pid_key.addr_type = p_data->ble_key.key_value.pid_key.addr_type;
+                    memcpy(pairing_cb.ble.pid_key.irk, p_data->ble_key.key_value.pid_key.irk, 16);
+                    memcpy(pairing_cb.ble.pid_key.static_addr,
+                            p_data->ble_key.key_value.pid_key.static_addr,BD_ADDR_LEN);
                     for (i=0; i<16; i++)
                     {
-                        BTIF_TRACE_DEBUG("pairing_cb.ble.pid_key[%d]=0x%02x",i,pairing_cb.ble.pid_key[i]);
+                        BTIF_TRACE_DEBUG("pairing_cb.ble.pid_key.irk[%d]=0x%02x"
+                                            ,i,pairing_cb.ble.pid_key.irk[i]);
+                    }
+                    for (i=0; i<BD_ADDR_LEN; i++)
+                    {
+                        BTIF_TRACE_DEBUG("piaring_cb.ble.pid_address[%d] = %x"
+                                            ,i, pairing_cb.ble.pid_key.static_addr[i]);
                     }
                     break;
 
@@ -2880,9 +2889,9 @@
     if (pairing_cb.ble.is_pid_key_rcvd)
     {
         btif_storage_add_ble_bonding_key(&bd_addr,
-                                         (char *) &pairing_cb.ble.pid_key[0],
+                                         (char *) &pairing_cb.ble.pid_key,
                                          BTIF_DM_LE_KEY_PID,
-                                         BT_OCTET16_LEN);
+                                         sizeof(btif_dm_ble_pid_keys_t));
     }
 
 
diff --git a/btif/src/btif_gatt_util.c b/btif/src/btif_gatt_util.c
index ed66703..348bcea 100644
--- a/btif/src/btif_gatt_util.c
+++ b/btif/src/btif_gatt_util.c
@@ -48,8 +48,6 @@
     0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
 
-extern bt_status_t btif_dm_remove_bond(const bt_bdaddr_t *bd_addr);
-
 int uuidType(unsigned char* p_uuid)
 {
     int i = 0;
@@ -297,14 +295,12 @@
 
 static void btif_gatt_set_encryption_cb (BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS result)
 {
+    UNUSED(bd_addr);
     UNUSED(transport);
 
     if (result != BTA_SUCCESS && result != BTA_BUSY)
     {
-        bt_bdaddr_t bda;
-        bdcpy(bda.address, bd_addr);
-
-        btif_dm_remove_bond(&bda);
+        BTIF_TRACE_WARNING("%s() - Encryption failed (%d)", __FUNCTION__, result);
     }
 }
 
diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c
index d3ecc45..5b1bf96 100644
--- a/btif/src/btif_storage.c
+++ b/btif/src/btif_storage.c
@@ -1225,7 +1225,7 @@
             if (btif_storage_get_ble_bonding_key(&bd_addr,
                                                  BTIF_DM_LE_KEY_PID,
                                                  buf,
-                                                 sizeof(btif_dm_ble_pcsrk_keys_t)) == BT_STATUS_SUCCESS)
+                                                 sizeof(btif_dm_ble_pid_keys_t)) == BT_STATUS_SUCCESS)
             {
                 if(add)
                 {
@@ -1237,7 +1237,14 @@
                     p = (tBTA_LE_KEY_VALUE *)buf;
                     for (i=0; i<16; i++)
                     {
-                        BTIF_TRACE_DEBUG("p->pid_key[%d]=0x%02x",i,p->pid_key.irk[i]);
+                        BTIF_TRACE_DEBUG("p->pid_key.irk[%d]=0x%02x"
+                                            ,i,p->pid_key.irk[i]);
+                    }
+                    BTIF_TRACE_DEBUG("p->pid_key.addr_type=%d",p->pid_key.addr_type);
+                    for (i=0; i<BD_ADDR_LEN; i++)
+                    {
+                        BTIF_TRACE_DEBUG("p->pid_key.static_addr[%d]=%02x"
+                                            ,i,p->pid_key.static_addr[i]);
                     }
 
                     BTA_DmAddBleKey (bta_bd_addr, (tBTA_LE_KEY_VALUE *)buf, BTIF_DM_LE_KEY_PID);
diff --git a/stack/btm/btm_ble.c b/stack/btm/btm_ble.c
index 9b8a7bb..58d3971 100644
--- a/stack/btm/btm_ble.c
+++ b/stack/btm/btm_ble.c
@@ -1615,9 +1615,6 @@
 
     if (p_dev_rec->ble.ble_addr_type == BLE_ADDR_RANDOM && !addr_matched)
         memcpy(p_dev_rec->ble.cur_rand_addr, bda, BD_ADDR_LEN);
-
-    if (btm_cb.cmn_ble_vsc_cb.rpa_offloading == TRUE)
-        btm_ble_vendor_disable_irk_list();
 #endif
 
     if (role == HCI_ROLE_SLAVE)
diff --git a/stack/btm/btm_ble_bgconn.c b/stack/btm/btm_ble_bgconn.c
index 28a1db8..b33aa2e 100644
--- a/stack/btm/btm_ble_bgconn.c
+++ b/stack/btm/btm_ble_bgconn.c
@@ -76,7 +76,7 @@
     tBT_DEVICE_TYPE dev_type;
 
     if (p_dev_rec != NULL &&
-        p_dev_rec->device_type == BT_DEVICE_TYPE_BLE)
+        p_dev_rec->device_type & BT_DEVICE_TYPE_BLE)
     {
 
         if (to_add)