mirror of
https://github.com/ponces/treble_aosp.git
synced 2025-05-02 15:31:44 +00:00
175 lines
7.1 KiB
Diff
175 lines
7.1 KiB
Diff
From af101e75f1672981e803fb796edca6b3170a31d7 Mon Sep 17 00:00:00 2001
|
|
From: Alexandra Ducati-Manas <alexandra.ducati-manas@st.com>
|
|
Date: Mon, 17 Feb 2025 04:55:44 +0100
|
|
Subject: [PATCH 2/2] Unblock enable if NDEF-NFCEE config but not enabled
|
|
|
|
If NDEF-NFCEE feature is configured in the libnfc-hal.conf file but not enabled at FW level, the NFA enable blocks because it waits for NDEF-NFCEE system flag to be set. Clear this flag when last NFCEE_DISCOVER_NTF is received and NDEF-NFCEE state not yet enabled.
|
|
|
|
Bug: 397104541
|
|
Test: on/off nfc with NDEF-NFCEE enabled/disabled
|
|
Change-Id: I181c2c6604fc0ed2eac90597484deaa097945d81
|
|
---
|
|
src/nfa/ee/nfa_ee_act.cc | 54 ++++++++++++++++++++-----
|
|
src/nfa/include/nfa_nfcee_int.h | 3 ++
|
|
src/nfa/ndefnfcee/t4t/nfa_nfcee_main.cc | 27 +++++++++++++
|
|
3 files changed, 75 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/src/nfa/ee/nfa_ee_act.cc b/src/nfa/ee/nfa_ee_act.cc
|
|
index 513ba06d..00bc7519 100644
|
|
--- a/src/nfa/ee/nfa_ee_act.cc
|
|
+++ b/src/nfa/ee/nfa_ee_act.cc
|
|
@@ -33,6 +33,8 @@
|
|
#include "nfa_ee_int.h"
|
|
#include "nfa_hci_int.h"
|
|
#include "nfa_nfcee_int.h"
|
|
+#include "nfa_sys_int.h"
|
|
+#include "nfc_config.h"
|
|
#include "nfc_int.h"
|
|
|
|
using android::base::StringPrintf;
|
|
@@ -1943,6 +1945,8 @@ void nfa_ee_nci_disc_ntf(tNFA_EE_MSG* p_data) {
|
|
tNFA_EE_ECB* p_cb = nullptr;
|
|
bool notify_enable_done = false;
|
|
bool notify_new_ee = false;
|
|
+ bool notify_ndef_nfcee = false;
|
|
+ bool store_info = true;
|
|
tNFA_EE_CBACK_DATA evt_data = {0};
|
|
tNFA_EE_INFO* p_info;
|
|
tNFA_EE_EM_STATE new_em_state = NFA_EE_EM_STATE_MAX;
|
|
@@ -2017,14 +2021,34 @@ void nfa_ee_nci_disc_ntf(tNFA_EE_MSG* p_data) {
|
|
LOG(VERBOSE) << StringPrintf("nfa_ee_nci_disc_ntf cur_ee:%d", nfa_ee_cb.cur_ee);
|
|
|
|
if (p_cb) {
|
|
- p_cb->nfcee_id = p_ee->nfcee_id;
|
|
- p_cb->ee_status = p_ee->ee_status;
|
|
- p_cb->num_interface = p_ee->num_interface;
|
|
- memcpy(p_cb->ee_interface, p_ee->ee_interface, p_ee->num_interface);
|
|
- p_cb->num_tlvs = p_ee->num_tlvs;
|
|
- memcpy(p_cb->ee_tlv, p_ee->ee_tlv, p_ee->num_tlvs * sizeof(tNFA_EE_TLV));
|
|
- if (NFA_GetNCIVersion() >= NCI_VERSION_2_0)
|
|
- p_cb->ee_power_supply_status = p_ee->nfcee_power_ctrl;
|
|
+ if (p_ee->ee_tlv[NFCEE_TAG_INDEX].tag == NFCEE_TYPE_NDEF) {
|
|
+ int defaultNdefNfcee =
|
|
+ NfcConfig::getUnsigned(NAME_DEFAULT_NDEF_NFCEE_ROUTE, 0x10);
|
|
+ // First, check NFCEE Id matches
|
|
+ if (defaultNdefNfcee == p_ee->nfcee_id) {
|
|
+ // Second check that feature is configured
|
|
+ if (nfa_t4tnfcee_is_config()) {
|
|
+ // Allow normal processing
|
|
+ notify_ndef_nfcee = true;
|
|
+ } else {
|
|
+ LOG(WARNING) << StringPrintf(
|
|
+ "%s: NDEF-NFCEE not config but enabled in FW, discard data",
|
|
+ __func__);
|
|
+ store_info = false;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (store_info) {
|
|
+ p_cb->nfcee_id = p_ee->nfcee_id;
|
|
+ p_cb->ee_status = p_ee->ee_status;
|
|
+ p_cb->num_interface = p_ee->num_interface;
|
|
+ memcpy(p_cb->ee_interface, p_ee->ee_interface, p_ee->num_interface);
|
|
+ p_cb->num_tlvs = p_ee->num_tlvs;
|
|
+ memcpy(p_cb->ee_tlv, p_ee->ee_tlv, p_ee->num_tlvs * sizeof(tNFA_EE_TLV));
|
|
+ if (NFA_GetNCIVersion() >= NCI_VERSION_2_0)
|
|
+ p_cb->ee_power_supply_status = p_ee->nfcee_power_ctrl;
|
|
+ }
|
|
if (nfa_ee_cb.em_state == NFA_EE_EM_STATE_RESTORING) {
|
|
/* NCI spec says: An NFCEE_DISCOVER_NTF that contains a Protocol type of
|
|
* "HCI Access"
|
|
@@ -2040,7 +2064,8 @@ void nfa_ee_nci_disc_ntf(tNFA_EE_MSG* p_data) {
|
|
}
|
|
}
|
|
|
|
- if (p_cb->ee_tlv[NFCEE_TAG_INDEX].tag == NFCEE_TYPE_NDEF) {
|
|
+ if (notify_ndef_nfcee &&
|
|
+ (p_cb->ee_tlv[NFCEE_TAG_INDEX].tag == NFCEE_TYPE_NDEF)) {
|
|
nfa_t4tnfcee_set_ee_cback(p_cb);
|
|
p_info = &evt_data.new_ee;
|
|
p_info->ee_handle = (tNFA_HANDLE)p_cb->nfcee_id;
|
|
@@ -2048,6 +2073,17 @@ void nfa_ee_nci_disc_ntf(tNFA_EE_MSG* p_data) {
|
|
nfa_ee_report_event(p_cb->p_ee_cback, NFA_EE_DISCOVER_EVT, &evt_data);
|
|
}
|
|
|
|
+ // If all have been received, NDEF-NFCEE configured but no
|
|
+ // NFCEE_DISCOVER_NTF received
|
|
+ if (nfa_ee_cb.num_ee_expecting == 0) {
|
|
+ if (nfa_t4tnfcee_is_config() && !nfa_t4tnfcee_is_discovered()) {
|
|
+ LOG(WARNING) << StringPrintf(
|
|
+ "%s: NDEF-NFCEE config but not enabled in FW, resetting flag",
|
|
+ __func__);
|
|
+ nfa_sys_cb.enable_cplt_mask &= ~(0x0001 << NFA_ID_T4TNFCEE);
|
|
+ }
|
|
+ }
|
|
+
|
|
if ((nfa_ee_cb.p_ee_disc_cback == nullptr) && (notify_new_ee == true)) {
|
|
if (nfa_dm_is_active() && (p_cb->ee_status != NFA_EE_STATUS_REMOVED)) {
|
|
/* report this NFA_EE_NEW_EE_EVT only after NFA_DM_ENABLE_EVT is
|
|
diff --git a/src/nfa/include/nfa_nfcee_int.h b/src/nfa/include/nfa_nfcee_int.h
|
|
index 10205825..af978aab 100644
|
|
--- a/src/nfa/include/nfa_nfcee_int.h
|
|
+++ b/src/nfa/include/nfa_nfcee_int.h
|
|
@@ -140,6 +140,7 @@ typedef struct {
|
|
uint16_t rd_offset; /* current read-offset of incoming NDEF data */
|
|
uint32_t dataLen; /*length of the data*/
|
|
bool ndefEmulationSupport; /* NDEF emulation support */
|
|
+ bool ndefEmulationConfig; /* NDEF emulation configuration */
|
|
uint8_t connId; /* NDEF NFCEE CONN ID */
|
|
} tNFA_T4TNFCEE_CB;
|
|
extern tNFA_T4TNFCEE_CB nfa_t4tnfcee_cb;
|
|
@@ -157,3 +158,5 @@ void nfa_t4tnfcee_set_ee_cback(tNFA_EE_ECB* p_ecb);
|
|
void nfa_t4tnfcee_init();
|
|
void nfa_t4tnfcee_deinit(void);
|
|
tNFC_STATUS nfa_t4tnfcee_proc_disc_evt(tNFA_T4TNFCEE_OP event);
|
|
+bool nfa_t4tnfcee_is_config();
|
|
+bool nfa_t4tnfcee_is_discovered(void);
|
|
diff --git a/src/nfa/ndefnfcee/t4t/nfa_nfcee_main.cc b/src/nfa/ndefnfcee/t4t/nfa_nfcee_main.cc
|
|
index e5114b46..5dd44322 100644
|
|
--- a/src/nfa/ndefnfcee/t4t/nfa_nfcee_main.cc
|
|
+++ b/src/nfa/ndefnfcee/t4t/nfa_nfcee_main.cc
|
|
@@ -61,8 +61,11 @@ void nfa_t4tnfcee_init(void) {
|
|
nfa_t4tnfcee_cb.t4tnfcee_state = NFA_T4TNFCEE_STATE_DISABLED;
|
|
/* register message handler on NFA SYS */
|
|
nfa_sys_register(NFA_ID_T4TNFCEE, &nfa_t4tnfcee_sys_reg);
|
|
+ nfa_t4tnfcee_cb.ndefEmulationConfig = true;
|
|
+ return;
|
|
}
|
|
}
|
|
+ nfa_t4tnfcee_cb.ndefEmulationConfig = false;
|
|
}
|
|
|
|
/*******************************************************************************
|
|
@@ -348,3 +351,27 @@ bool NFA_T4tNfcEeIsProcessing(void) {
|
|
bool NFA_T4tNfcEeIsEmulationSupported(void) {
|
|
return nfa_t4tnfcee_cb.ndefEmulationSupport;
|
|
}
|
|
+
|
|
+/*******************************************************************************
|
|
+**
|
|
+** Function nfa_t4tnfcee_is_config
|
|
+**
|
|
+** Description Indicates if T4t NDEF Nfcee emulation is configured or not
|
|
+**
|
|
+** Returns true if supported else false
|
|
+**
|
|
+*******************************************************************************/
|
|
+bool nfa_t4tnfcee_is_config() { return nfa_t4tnfcee_cb.ndefEmulationConfig; }
|
|
+
|
|
+/*******************************************************************************
|
|
+**
|
|
+** Function nfa_t4tnfcee_is_enabled
|
|
+**
|
|
+** Description T4T is enabled and initialized.
|
|
+**
|
|
+** Returns true if T4T Nfcee is enabled initialization
|
|
+**
|
|
+*******************************************************************************/
|
|
+bool nfa_t4tnfcee_is_discovered(void) {
|
|
+ return (nfa_t4tnfcee_cb.t4tnfcee_state >= NFA_T4TNFCEE_STATE_TRY_ENABLE);
|
|
+}
|
|
--
|
|
2.43.0
|
|
|