diff options
author | Alexandra Ducati-Manas <alexandra.ducati-manas@st.com> | 2024-04-18 17:58:50 +0200 |
---|---|---|
committer | Alexandra Ducati-Manas <alexandra.ducati-manas@st.com> | 2024-04-24 02:42:39 +0000 |
commit | 2c2e53709d691d460757e563d22a13e904741b11 (patch) | |
tree | 9fa10dcde6c37c9f5227b8f5dfd9584d0d2f5539 /nci/jni | |
parent | 59d4377e8ccc1cc5c5e60d97d99679ea09fe18d0 (diff) | |
download | Nfc-2c2e53709d691d460757e563d22a13e904741b11.tar.gz |
Code cleanup: removed P2P cases in case of RF detection
Bug: 335639730
Change-Id: Ibfecaf2c7df48de0cae1b62a220c7ca5d0de7421
Diffstat (limited to 'nci/jni')
-rw-r--r-- | nci/jni/NativeNfcManager.cpp | 116 | ||||
-rw-r--r-- | nci/jni/NfcJniUtil.h | 13 | ||||
-rwxr-xr-x | nci/jni/NfcTag.cpp | 67 | ||||
-rw-r--r-- | nci/jni/NfcTag.h | 22 |
4 files changed, 19 insertions, 199 deletions
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index 896f6561..352f8cdf 100644 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -133,9 +133,7 @@ static bool sIsDisabling = false; static bool sRfEnabled = false; // whether RF discovery is enabled static bool sSeRfActive = false; // whether RF with SE is likely active static bool sReaderModeEnabled = - false; // whether we're only reading tags, not allowing P2p/card emu -static bool sP2pEnabled = false; -static bool sP2pActive = false; // whether p2p was last active + false; // whether we're only reading tags, not allowing card emu static bool sAbortConnlessWait = false; static jint sLfT3tMax = 0; static bool sRoutingInitialized = false; @@ -154,7 +152,6 @@ static std::vector<uint8_t> sRawVendorCmdResponse; static void nfaConnectionCallback(uint8_t event, tNFA_CONN_EVT_DATA* eventData); static void nfaDeviceManagementCallback(uint8_t event, tNFA_DM_CBACK_DATA* eventData); -static bool isPeerToPeer(tNFA_ACTIVATED& activated); static bool isListenMode(tNFA_ACTIVATED& activated); static tNFA_STATUS stopPolling_rfDiscoveryDisabled(); static tNFA_STATUS startPolling_rfDiscoveryDisabled( @@ -235,25 +232,13 @@ static void handleRfDiscoveryEvent(tNFC_RESULT_DEVT* discoveredDevice) { return; } - bool isP2p = natTag.isP2pDiscovered(); - if (natTag.getNumDiscNtf() > 1) { natTag.setMultiProtocolTagSupport(true); - if (isP2p) { - // Remove NFC_DEP NTF count - // Skip NFC_DEP protocol in MultiProtocolTag select. - natTag.setNumDiscNtf(natTag.getNumDiscNtf() - 1); - } } - if (sP2pEnabled && !sReaderModeEnabled && isP2p) { - // select the peer that supports P2P - natTag.selectP2p(); - } else { - natTag.setNumDiscNtf(natTag.getNumDiscNtf() - 1); - // select the first of multiple tags that is discovered - natTag.selectFirstTag(); - } + natTag.setNumDiscNtf(natTag.getNumDiscNtf() - 1); + // select the first of multiple tags that is discovered + natTag.selectFirstTag(); } /******************************************************************************* @@ -397,45 +382,20 @@ static void nfaConnectionCallback(uint8_t connEvent, prevScreenState == NFA_SCREEN_STATE_OFF_UNLOCKED)) { NFA_Deactivate(FALSE); } - if (isPeerToPeer(eventData->activated)) { - if (sReaderModeEnabled) { - LOG(DEBUG) << StringPrintf("%s: ignoring peer target in reader mode.", - __func__); - NFA_Deactivate(FALSE); - break; - } - sP2pActive = true; - LOG(DEBUG) << StringPrintf("%s: NFA_ACTIVATED_EVT; is p2p", __func__); - if (NFC_GetNCIVersion() == NCI_VERSION_1_0) { - // Disable RF field events in case of p2p - uint8_t nfa_disable_rf_events[] = {0x00}; - LOG(DEBUG) << StringPrintf("%s: Disabling RF field events", __func__); - status = NFA_SetConfig(NCI_PARAM_ID_RF_FIELD_INFO, - sizeof(nfa_disable_rf_events), - &nfa_disable_rf_events[0]); - if (status == NFA_STATUS_OK) { - LOG(DEBUG) << StringPrintf("%s: Disabled RF field events", - __func__); - } else { - LOG(ERROR) << StringPrintf("%s: Failed to disable RF field events", - __func__); - } - } - } else { - NfcTag::getInstance().connectionEventHandler(connEvent, eventData); - if (NfcTag::getInstance().getNumDiscNtf()) { - /*If its multiprotocol tag, deactivate tag with current selected - protocol to sleep . Select tag with next supported protocol after - deactivation event is received*/ - NFA_Deactivate(true); - } - // We know it is not activating for P2P. If it activated in - // listen mode then it is likely for an SE transaction. - // Send the RF Event. - if (isListenMode(eventData->activated)) { - sSeRfActive = true; - } + NfcTag::getInstance().connectionEventHandler(connEvent, eventData); + if (NfcTag::getInstance().getNumDiscNtf()) { + /*If its multiprotocol tag, deactivate tag with current selected + protocol to sleep . Select tag with next supported protocol after + deactivation event is received*/ + NFA_Deactivate(true); + } + + // If it activated in + // listen mode then it is likely for an SE transaction. + // Send the RF Event. + if (isListenMode(eventData->activated)) { + sSeRfActive = true; } } break; case NFA_DEACTIVATED_EVT: // NFC link/protocol deactivated @@ -465,30 +425,6 @@ static void nfaConnectionCallback(uint8_t connEvent, (eventData->deactivated.type == NFA_DEACTIVATE_TYPE_DISCOVERY)) { if (sSeRfActive) { sSeRfActive = false; - } else if (sP2pActive) { - sP2pActive = false; - // Make sure RF field events are re-enabled - LOG(DEBUG) << StringPrintf("%s: NFA_DEACTIVATED_EVT; is p2p", - __func__); - if (NFC_GetNCIVersion() == NCI_VERSION_1_0) { - // Disable RF field events in case of p2p - uint8_t nfa_enable_rf_events[] = {0x01}; - - if (!sIsDisabling && sIsNfaEnabled) { - LOG(DEBUG) << StringPrintf("%s: Enabling RF field events", - __func__); - status = NFA_SetConfig(NCI_PARAM_ID_RF_FIELD_INFO, - sizeof(nfa_enable_rf_events), - &nfa_enable_rf_events[0]); - if (status == NFA_STATUS_OK) { - LOG(DEBUG) << StringPrintf("%s: Enabled RF field events", - __func__); - } else { - LOG(ERROR) << StringPrintf( - "%s: Failed to enable RF field events", __func__); - } - } - } } } @@ -756,7 +692,7 @@ void nfaDeviceManagementCallback(uint8_t dmEvent, LOG(DEBUG) << StringPrintf( "%s: NFA_DM_RF_FIELD_EVT; status=0x%X; field status=%u", __func__, eventData->rf_field.status, eventData->rf_field.rf_field_status); - if (!sP2pActive && eventData->rf_field.status == NFA_STATUS_OK) { + if (eventData->rf_field.status == NFA_STATUS_OK) { struct nfc_jni_native_data* nat = getNative(NULL, NULL); if (!nat) { LOG(ERROR) << StringPrintf("cached nat is null"); @@ -1526,7 +1462,6 @@ static jboolean nfcManager_doDeinitialize(JNIEnv*, jobject) { sDiscoveryEnabled = false; sPollingEnabled = false; sIsDisabling = false; - sP2pEnabled = false; sReaderModeEnabled = false; gActivated = false; sLfT3tMax = 0; @@ -1546,19 +1481,6 @@ static jboolean nfcManager_doDeinitialize(JNIEnv*, jobject) { /******************************************************************************* ** -** Function: isPeerToPeer -** -** Description: Whether the activation data indicates the peer supports -*NFC-DEP. -** activated: Activation data. -** -** Returns: True if the peer supports NFC-DEP. -** -*******************************************************************************/ -static bool isPeerToPeer(tNFA_ACTIVATED& activated) { return false; } - -/******************************************************************************* -** ** Function: isListenMode ** ** Description: Indicates whether the activation data indicates it is @@ -1810,7 +1732,7 @@ static void nfcManager_doSetScreenState(JNIEnv* e, jobject o, state == NFA_SCREEN_STATE_OFF_UNLOCKED) && (prevScreenState == NFA_SCREEN_STATE_ON_UNLOCKED || prevScreenState == NFA_SCREEN_STATE_ON_LOCKED) && - (!sP2pActive) && (!sSeRfActive)) { + (!sSeRfActive)) { // screen turns off, disconnect tag if connected nativeNfcTag_doDisconnect(NULL, NULL); } diff --git a/nci/jni/NfcJniUtil.h b/nci/jni/NfcJniUtil.h index df2f2fad..6e09c7fc 100644 --- a/nci/jni/NfcJniUtil.h +++ b/nci/jni/NfcJniUtil.h @@ -29,14 +29,7 @@ #define DISCOVERY_MODE_DISABLED 0 #define DISCOVERY_MODE_ENABLED 1 -#define MODE_P2P_TARGET 0 -#define MODE_P2P_INITIATOR 1 - /* Properties values */ -#define PROPERTY_LLCP_LTO 0 -#define PROPERTY_LLCP_MIU 1 -#define PROPERTY_LLCP_WKS 2 -#define PROPERTY_LLCP_OPT 3 #define PROPERTY_NFC_DISCOVERY_A 4 #define PROPERTY_NFC_DISCOVERY_B 5 #define PROPERTY_NFC_DISCOVERY_F 6 @@ -117,12 +110,6 @@ struct nfc_jni_native_data { /* Secure Element selected */ int seId; - /* LLCP params */ - int lto; - int miu; - int wks; - int opt; - int tech_mask; int discovery_duration; diff --git a/nci/jni/NfcTag.cpp b/nci/jni/NfcTag.cpp index 821d5f64..77b915fd 100755 --- a/nci/jni/NfcTag.cpp +++ b/nci/jni/NfcTag.cpp @@ -1022,73 +1022,6 @@ void NfcTag::fillNativeNfcTagMembers5(JNIEnv* e, jclass tag_cls, jobject tag, /******************************************************************************* ** -** Function: isP2pDiscovered -** -** Description: Does the peer support P2P? -** -** Returns: True if the peer supports P2P. -** -*******************************************************************************/ -bool NfcTag::isP2pDiscovered() { - static const char fn[] = "NfcTag::isP2pDiscovered"; - bool retval = false; - - for (int i = 0; i < mNumDiscTechList; i++) { - if (mTechLibNfcTypesDiscData[i] == NFA_PROTOCOL_NFC_DEP) { - // if remote device supports P2P - LOG(DEBUG) << StringPrintf("%s: discovered P2P", fn); - retval = true; - break; - } - } - LOG(DEBUG) << StringPrintf("%s: return=%u", fn, retval); - return retval; -} - -/******************************************************************************* -** -** Function: selectP2p -** -** Description: Select the preferred P2P technology if there is a choice. -** -** Returns: None -** -*******************************************************************************/ -void NfcTag::selectP2p() { - static const char fn[] = "NfcTag::selectP2p"; - uint8_t rfDiscoveryId = 0; - - for (int i = 0; i < mNumTechList; i++) { - // if remote device does not support P2P, just skip it - if (mTechLibNfcTypes[i] != NFA_PROTOCOL_NFC_DEP) continue; - - // if remote device supports tech F; - // tech F is preferred because it is faster than tech A - if ((mTechParams[i].mode == NFC_DISCOVERY_TYPE_POLL_F) || - (mTechParams[i].mode == NFC_DISCOVERY_TYPE_POLL_F_ACTIVE)) { - rfDiscoveryId = mTechHandles[i]; - break; // no need to search further - } else if ((mTechParams[i].mode == NFC_DISCOVERY_TYPE_POLL_A) || - (mTechParams[i].mode == NFC_DISCOVERY_TYPE_POLL_A_ACTIVE)) { - // only choose tech A if tech F is unavailable - if (rfDiscoveryId == 0) rfDiscoveryId = mTechHandles[i]; - } - } - - if (rfDiscoveryId > 0) { - LOG(DEBUG) << StringPrintf("%s: select P2P; target rf discov id=0x%X", fn, - rfDiscoveryId); - tNFA_STATUS stat = - NFA_Select(rfDiscoveryId, NFA_PROTOCOL_NFC_DEP, NFA_INTERFACE_NFC_DEP); - if (stat != NFA_STATUS_OK) - LOG(ERROR) << StringPrintf("%s: fail select P2P; error=0x%X", fn, stat); - } else - LOG(ERROR) << StringPrintf("%s: cannot find P2P", fn); - resetTechnologies(); -} - -/******************************************************************************* -** ** Function: resetTechnologies ** ** Description: Clear all data related to the technology, protocol of the diff --git a/nci/jni/NfcTag.h b/nci/jni/NfcTag.h index 7a943a0a..698db4cf 100644 --- a/nci/jni/NfcTag.h +++ b/nci/jni/NfcTag.h @@ -162,28 +162,6 @@ class NfcTag { /******************************************************************************* ** - ** Function: isP2pDiscovered - ** - ** Description: Does the peer support P2P? - ** - ** Returns: True if the peer supports P2P. - ** - *******************************************************************************/ - bool isP2pDiscovered(); - - /******************************************************************************* - ** - ** Function: selectP2p - ** - ** Description: Select the preferred P2P technology if there is a choice. - ** - ** Returns: None - ** - *******************************************************************************/ - void selectP2p(); - - /******************************************************************************* - ** ** Function: selectFirstTag ** ** Description: When multiple tags are discovered, just select the first |