Merge remote-tracking branch 'origin/LA.QSSI.11.0.R1.11.00.00.668.170.00' into fp4t-target-0414
diff --git a/SN100x/src/gki/common/gki_time.cc b/SN100x/src/gki/common/gki_time.cc
old mode 100755
new mode 100644
index dcae18e..9f12de4
--- a/SN100x/src/gki/common/gki_time.cc
+++ b/SN100x/src/gki/common/gki_time.cc
@@ -17,6 +17,41 @@
  *  limitations under the License.
  *
  ******************************************************************************/
+/*
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER 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
+ ***************************************************************************************/
 #include <android-base/stringprintf.h>
 #include <base/logging.h>
 #include "gki_int.h"
@@ -190,6 +225,14 @@
   uint8_t task_id = GKI_get_taskid();
   bool bad_timer = false;
 
+#if (NXP_EXTNS == TRUE)
+   if (task_id >= GKI_MAX_TASKS) {
+     LOG(ERROR) << StringPrintf(
+     "%s: invalid task_id:0x%02x. start timer failed", __func__, task_id);
+     return;
+   }
+#endif
+
   if (ticks <= 0) ticks = 1;
 
   orig_ticks = ticks; /* save the ticks in case adjustment is necessary */
@@ -289,34 +332,36 @@
 
   GKI_disable();
 
-  switch (tnum) {
+  if (task_id < GKI_MAX_TASKS) {
+    switch (tnum) {
 #if (GKI_NUM_TIMERS > 0)
-    case TIMER_0:
-      gki_cb.com.OSTaskTmr0R[task_id] = 0;
-      gki_cb.com.OSTaskTmr0[task_id] = 0;
-      break;
+      case TIMER_0:
+        gki_cb.com.OSTaskTmr0R[task_id] = 0;
+        gki_cb.com.OSTaskTmr0[task_id] = 0;
+        break;
 #endif
 
 #if (GKI_NUM_TIMERS > 1)
-    case TIMER_1:
-      gki_cb.com.OSTaskTmr1R[task_id] = 0;
-      gki_cb.com.OSTaskTmr1[task_id] = 0;
-      break;
+      case TIMER_1:
+        gki_cb.com.OSTaskTmr1R[task_id] = 0;
+        gki_cb.com.OSTaskTmr1[task_id] = 0;
+        break;
 #endif
 
 #if (GKI_NUM_TIMERS > 2)
-    case TIMER_2:
-      gki_cb.com.OSTaskTmr2R[task_id] = 0;
-      gki_cb.com.OSTaskTmr2[task_id] = 0;
-      break;
+      case TIMER_2:
+        gki_cb.com.OSTaskTmr2R[task_id] = 0;
+        gki_cb.com.OSTaskTmr2[task_id] = 0;
+        break;
 #endif
 
 #if (GKI_NUM_TIMERS > 3)
-    case TIMER_3:
-      gki_cb.com.OSTaskTmr3R[task_id] = 0;
-      gki_cb.com.OSTaskTmr3[task_id] = 0;
-      break;
+      case TIMER_3:
+        gki_cb.com.OSTaskTmr3R[task_id] = 0;
+        gki_cb.com.OSTaskTmr3[task_id] = 0;
+        break;
 #endif
+    }
   }
 
   if (gki_timers_is_timer_running() == false) {
diff --git a/SN100x/src/nfa/dm/nfa_dm_discover.cc b/SN100x/src/nfa/dm/nfa_dm_discover.cc
index 319a0a3..dd935a2 100755
--- a/SN100x/src/nfa/dm/nfa_dm_discover.cc
+++ b/SN100x/src/nfa/dm/nfa_dm_discover.cc
@@ -1899,7 +1899,14 @@
 
   /* if selection failed */
   if (event == NFC_ERROR_CEVT) {
+#if(NXP_EXTNS == TRUE)
+    tNFA_DM_RF_DISC_DATA rf_disc_data;
+    rf_disc_data.nfc_discover.status =
+            (p_data?p_data->data.status:NFA_STATUS_TIMEOUT);
+    nfa_dm_disc_sm_execute(NFA_DM_CORE_INTF_ERROR_NTF, &rf_disc_data);
+#else
     nfa_dm_disc_sm_execute(NFA_DM_CORE_INTF_ERROR_NTF, nullptr);
+#endif
   } else if (event == NFC_DATA_CEVT) {
     GKI_freebuf(p_data->data.p_data);
   }
@@ -2395,7 +2402,9 @@
       (nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_CHECKING);
   bool sleep_wakeup_event = false;
   bool sleep_wakeup_event_processed = false;
-
+#if(NXP_EXTNS == TRUE)
+  tNFA_CONN_EVT_DATA conn_evt_data;
+#endif
   switch (event) {
     case NFA_DM_RF_DEACTIVATE_CMD:
 
@@ -2563,7 +2572,8 @@
         nfa_dm_send_deactivate_cmd(NFA_DEACTIVATE_TYPE_DISCOVERY);
       }
 #if(NXP_EXTNS == TRUE)
-      nfa_dm_act_conn_cback_notify(NFA_RW_INTF_ERROR_EVT, NULL);
+      conn_evt_data.status = p_data->nfc_discover.status;
+      nfa_dm_act_conn_cback_notify(NFA_RW_INTF_ERROR_EVT, &conn_evt_data);
 #endif
       break;
 
diff --git a/src/gki/common/gki_time.cc b/src/gki/common/gki_time.cc
index 4384387..8ea7d45 100644
--- a/src/gki/common/gki_time.cc
+++ b/src/gki/common/gki_time.cc
@@ -18,6 +18,41 @@
  *  limitations under the License.
  *
  ******************************************************************************/
+/*
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER 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
+ **************************************************************************************/
 #include <android-base/stringprintf.h>
 #include <base/logging.h>
 #include "gki_int.h"
@@ -194,6 +229,14 @@
   }
   bool bad_timer = false;
 
+#if (NXP_EXTNS == TRUE)
+   if (task_id >= GKI_MAX_TASKS) {
+     LOG(ERROR) << StringPrintf(
+     "%s: invalid task_id:0x%02x. start timer failed", __func__, task_id);
+     return;
+   }
+#endif
+
   if (ticks <= 0) ticks = 1;
 
   orig_ticks = ticks; /* save the ticks in case adjustment is necessary */
@@ -296,34 +339,36 @@
   }
   GKI_disable();
 
-  switch (tnum) {
+  if (task_id < GKI_MAX_TASKS) {
+    switch (tnum) {
 #if (GKI_NUM_TIMERS > 0)
-    case TIMER_0:
-      gki_cb.com.OSTaskTmr0R[task_id] = 0;
-      gki_cb.com.OSTaskTmr0[task_id] = 0;
-      break;
+      case TIMER_0:
+        gki_cb.com.OSTaskTmr0R[task_id] = 0;
+        gki_cb.com.OSTaskTmr0[task_id] = 0;
+        break;
 #endif
 
 #if (GKI_NUM_TIMERS > 1)
-    case TIMER_1:
-      gki_cb.com.OSTaskTmr1R[task_id] = 0;
-      gki_cb.com.OSTaskTmr1[task_id] = 0;
-      break;
+      case TIMER_1:
+        gki_cb.com.OSTaskTmr1R[task_id] = 0;
+        gki_cb.com.OSTaskTmr1[task_id] = 0;
+        break;
 #endif
 
 #if (GKI_NUM_TIMERS > 2)
-    case TIMER_2:
-      gki_cb.com.OSTaskTmr2R[task_id] = 0;
-      gki_cb.com.OSTaskTmr2[task_id] = 0;
-      break;
+      case TIMER_2:
+        gki_cb.com.OSTaskTmr2R[task_id] = 0;
+        gki_cb.com.OSTaskTmr2[task_id] = 0;
+        break;
 #endif
 
 #if (GKI_NUM_TIMERS > 3)
-    case TIMER_3:
-      gki_cb.com.OSTaskTmr3R[task_id] = 0;
-      gki_cb.com.OSTaskTmr3[task_id] = 0;
-      break;
+      case TIMER_3:
+        gki_cb.com.OSTaskTmr3R[task_id] = 0;
+        gki_cb.com.OSTaskTmr3[task_id] = 0;
+        break;
 #endif
+    }
   }
 
   if (gki_timers_is_timer_running() == false) {