Reset the HCI network if nfaStorage was deleted.
If nfaStroage.bin1 file cannot be opened, send a ADM_CLEAR_ALL_PIPE command
to force the NFCC to recreate all the pipes.
Bug: 140902609
Test: Check open pipe by remove nfaStorage.bin1 manually
Merged-Id: I775612b8c914866197242385c30cabf3f17c8870
Change-Id: I775612b8c914866197242385c30cabf3f17c8870
(cherry picked from commit 4500e7c26d1e9bb25a19537024fb54424d6f9311)
diff --git a/src/nfa/hci/nfa_hci_act.cc b/src/nfa/hci/nfa_hci_act.cc
index 4ad9754..fbc4fbf 100644
--- a/src/nfa/hci/nfa_hci_act.cc
+++ b/src/nfa/hci/nfa_hci_act.cc
@@ -1413,7 +1413,7 @@
/* Something wrong, NVRAM data could be corrupt or first start with
* default session id */
nfa_hciu_send_clear_all_pipe_cmd();
- nfa_hci_cb.b_hci_netwk_reset = true;
+ nfa_hci_cb.b_hci_new_sessionId = true;
if (data_len < NFA_HCI_SESSION_ID_LEN) {
android_errorWriteLog(0x534e4554, "124524315");
}
@@ -1423,9 +1423,15 @@
case NFA_HCI_ANY_OPEN_PIPE:
nfa_hci_cb.cfg.admin_gate.pipe01_state = NFA_HCI_PIPE_OPENED;
-
if (nfa_hci_cb.b_hci_netwk_reset) {
+ /* Something wrong, NVRAM data could be corrupt or first start with
+ * default session id */
+ nfa_hciu_send_clear_all_pipe_cmd();
nfa_hci_cb.b_hci_netwk_reset = false;
+ nfa_hci_cb.b_hci_new_sessionId = true;
+ } else if (nfa_hci_cb.b_hci_new_sessionId) {
+ nfa_hci_cb.b_hci_new_sessionId = false;
+
/* Session ID is reset, Set New session id */
memcpy(
&nfa_hci_cb.cfg.admin_gate.session_id[NFA_HCI_SESSION_ID_LEN / 2],
diff --git a/src/nfa/include/nfa_hci_int.h b/src/nfa/include/nfa_hci_int.h
index 5d13f95..456c279 100644
--- a/src/nfa/include/nfa_hci_int.h
+++ b/src/nfa/include/nfa_hci_int.h
@@ -371,6 +371,7 @@
uint8_t active_host[NFA_HCI_MAX_HOST_IN_NETWORK];
uint8_t reset_host[NFA_HCI_MAX_HOST_IN_NETWORK]; /* List of host reseting */
bool b_low_power_mode; /* Host controller in low power mode */
+ bool b_hci_new_sessionId; /* Command sent to set a new session Id */
bool b_hci_netwk_reset; /* Command sent to reset HCI Network */
bool w4_hci_netwk_init; /* Wait for other host in network to initialize */
TIMER_LIST_ENT timer; /* Timer to avoid indefinitely waiting for response */