Merge "Add empty aid as the last entry of aid routing"
diff --git a/src/nfa/ee/nfa_ee_act.cc b/src/nfa/ee/nfa_ee_act.cc
index 8b637d6..cc2c904 100644
--- a/src/nfa/ee/nfa_ee_act.cc
+++ b/src/nfa/ee/nfa_ee_act.cc
@@ -646,8 +646,8 @@
int* p_offset, int* p_entry) {
int xx, yy, aid_len_offset, offset;
tNFA_EE_ECB *p_ret = nullptr, *p_ecb;
-
- p_ecb = &nfa_ee_cb.ecb[NFA_EE_CB_4_DH];
+ /* NFA_EE_CB_4_DH + Empty aid ECB */
+ p_ecb = &nfa_ee_cb.ecb[NFA_EE_CB_4_DH + 1];
aid_len_offset = 1; /* skip the tag */
for (yy = 0; yy <= nfa_ee_cb.cur_ee; yy++) {
if (p_ecb->aid_entries) {
@@ -2859,6 +2859,16 @@
<< StringPrintf("%s --add the routing for DH!!", __func__);
nfa_ee_route_add_one_ecb_by_route_order(&nfa_ee_cb.ecb[NFA_EE_CB_4_DH], rt,
&max_len, more, p, &cur_offset);
+
+ if (rt == NCI_ROUTE_ORDER_AID) {
+ p_cb = &nfa_ee_cb.ecb[NFA_EE_EMPTY_AID_ECB];
+ if (p_cb->ee_status == NFC_NFCEE_STATUS_ACTIVE) {
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s --add the routing for Empty Aid!!", __func__);
+ nfa_ee_route_add_one_ecb_by_route_order(p_cb, rt, &max_len, more, p,
+ &cur_offset);
+ }
+ }
}
GKI_freebuf(p);
diff --git a/src/nfa/ee/nfa_ee_api.cc b/src/nfa/ee/nfa_ee_api.cc
index 4206863..428ac21 100644
--- a/src/nfa/ee/nfa_ee_api.cc
+++ b/src/nfa/ee/nfa_ee_api.cc
@@ -561,7 +561,11 @@
tNFA_EE_ECB* p_cb;
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("handle:<0x%x>", ee_handle);
- p_cb = nfa_ee_find_ecb(nfcee_id);
+ if (aid_len == 0) {
+ p_cb = &nfa_ee_cb.ecb[NFA_EE_EMPTY_AID_ECB];
+ } else {
+ p_cb = nfa_ee_find_ecb(nfcee_id);
+ }
/* validate parameters - make sure the AID is in valid length range */
if ((p_cb == nullptr) ||
@@ -573,6 +577,7 @@
LOG(ERROR) << StringPrintf("Bad ee_handle or AID (len=%d)", aid_len);
status = NFA_STATUS_INVALID_PARAM;
} else {
+ p_cb->nfcee_id = nfcee_id;
p_msg = (tNFA_EE_API_ADD_AID*)GKI_getbuf(size);
if (p_msg != nullptr) {
if (p_aid != nullptr)
diff --git a/src/nfa/include/nfa_ee_int.h b/src/nfa/include/nfa_ee_int.h
index cf1781a..b280562 100644
--- a/src/nfa/include/nfa_ee_int.h
+++ b/src/nfa/include/nfa_ee_int.h
@@ -30,10 +30,12 @@
/*****************************************************************************
** Constants and data types
*****************************************************************************/
-/* the number of tNFA_EE_ECBs (for NFCEEs and DH) */
-#define NFA_EE_NUM_ECBS (NFA_EE_MAX_EE_SUPPORTED + 1)
+/* the number of tNFA_EE_ECBs (for NFCEEs and DH) + Empty aid ECB */
+#define NFA_EE_NUM_ECBS (NFA_EE_MAX_EE_SUPPORTED + 2)
/* The index for DH in nfa_ee_cb.ee_cb[] */
#define NFA_EE_CB_4_DH NFA_EE_MAX_EE_SUPPORTED
+/* The index for Empty aid in nfa_ee_cb.ee_cb[] */
+#define NFA_EE_EMPTY_AID_ECB (NFA_EE_CB_4_DH + 1)
#define NFA_EE_INVALID 0xFF
/* only A, B, F, Bprime are supported by UICC now */
#define NFA_EE_MAX_TECH_ROUTE 4