diff --git a/nci/jni/NfcTag.cpp b/nci/jni/NfcTag.cpp index b9d8d555..5af2b79e 100755 --- a/nci/jni/NfcTag.cpp +++ b/nci/jni/NfcTag.cpp @@ -289,6 +289,10 @@ void NfcTag::discoverTechnologies(tNFA_ACTIVATED& activationData) { if (mTechListTail < (MAX_NUM_TECHNOLOGY - 1)) { mNumTechList = mTechListTail; + } else { + LOG(ERROR) << StringPrintf("%s: exceed max=%d", fn, MAX_NUM_TECHNOLOGY); + android_errorWriteLog(0x534e4554, "189942532"); + goto TheEnd; } mTechHandles[mNumTechList] = rfDetail.rf_disc_id; mTechLibNfcTypes[mNumTechList] = rfDetail.protocol; @@ -413,6 +417,7 @@ void NfcTag::discoverTechnologies(tNFA_ACTIVATED& activationData) { << StringPrintf("%s: index=%d; tech=%d; handle=%d; nfc type=%d", fn, i, mTechList[i], mTechHandles[i], mTechLibNfcTypes[i]); } +TheEnd: DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn); } @@ -1624,4 +1629,4 @@ void NfcTag::setNumDiscNtf(int numDiscNtfValue) { ** Returns: number of discovery notifications received from NFCC ** *******************************************************************************/ -int NfcTag::getNumDiscNtf() { return mNumDiscNtf; } \ No newline at end of file +int NfcTag::getNumDiscNtf() { return mNumDiscNtf; } diff --git a/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.cpp b/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.cpp index 3ddc2ca8..7ad6aab9 100644 --- a/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.cpp +++ b/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.cpp @@ -1117,8 +1117,9 @@ static NFCSTATUS phNciNfc_RecvMfResp(phNciNfc_Buff_t* RspBuffInfo, if (NULL == RspBuffInfo) { status = NFCSTATUS_FAILED; } else { - if ((0 == (RspBuffInfo->wLen)) || (PH_NCINFC_STATUS_OK != wStatus) || - (NULL == (RspBuffInfo->pBuff))) { + if (((PHNCINFC_EXTNID_SIZE + PHNCINFC_EXTNSTATUS_SIZE) > + RspBuffInfo->wLen) || + (PH_NCINFC_STATUS_OK != wStatus) || (NULL == (RspBuffInfo->pBuff))) { status = NFCSTATUS_FAILED; } else { RecvdExtnRspId = (phNciNfc_ExtnRespId_t)RspBuffInfo->pBuff[0]; @@ -1132,10 +1133,6 @@ static NFCSTATUS phNciNfc_RecvMfResp(phNciNfc_Buff_t* RspBuffInfo, NdefMap->State == PH_FRINFC_NDEFMAP_STATE_WRITE || NdefMap->State == PH_FRINFC_NDEFMAP_STATE_WR_NDEF_LEN || NdefMap->State == PH_FRINFC_NDEFMAP_STATE_INIT)) { - if (2 > RspBuffInfo->wLen) { - android_errorWriteLog(0x534e4554, "181346550"); - return NFCSTATUS_FAILED; - } uint8_t rspAck = RspBuffInfo->pBuff[RspBuffInfo->wLen - 2]; uint8_t rspAckMask = ((RspBuffInfo->pBuff[RspBuffInfo->wLen - 1]) & MAX_NUM_VALID_BITS_FOR_ACK); @@ -1149,11 +1146,6 @@ static NFCSTATUS phNciNfc_RecvMfResp(phNciNfc_Buff_t* RspBuffInfo, status = NFCSTATUS_SUCCESS; uint16_t wRecvDataSz = 0; - if ((PHNCINFC_EXTNID_SIZE + PHNCINFC_EXTNSTATUS_SIZE) > - RspBuffInfo->wLen) { - android_errorWriteLog(0x534e4554, "181346550"); - return NFCSTATUS_FAILED; - } /* DataLen = TotalRecvdLen - (sizeof(RspId) + sizeof(Status)) */ wPldDataSize = ((RspBuffInfo->wLen) - (PHNCINFC_EXTNID_SIZE + PHNCINFC_EXTNSTATUS_SIZE)); diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 4516e454..9828cb41 100644 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -916,6 +916,12 @@ void enforceBeamShareActivityPolicy(Context context, UserHandle uh) { } } + public boolean isSecureNfcEnabled() { + synchronized (NfcService.this) { + return mIsSecureNfcEnabled; + } + } + final class NfcAdapterService extends INfcAdapter.Stub { /** * An interface for vendor specific extensions diff --git a/src/com/android/nfc/cardemulation/CardEmulationManager.java b/src/com/android/nfc/cardemulation/CardEmulationManager.java index 489196ed..5c93a929 100644 --- a/src/com/android/nfc/cardemulation/CardEmulationManager.java +++ b/src/com/android/nfc/cardemulation/CardEmulationManager.java @@ -262,28 +262,9 @@ void verifyDefaults(int userId, List services) { getDefaultServiceForCategory(userId, CardEmulation.CATEGORY_PAYMENT, true); if (DBG) Log.d(TAG, "Current default: " + defaultPaymentService); if (defaultPaymentService == null) { - // A payment service may have been removed, leaving only one; - // in that case, automatically set that app as default. - int numPaymentServices = 0; - ComponentName lastFoundPaymentService = null; - for (ApduServiceInfo service : services) { - if (service.hasCategory(CardEmulation.CATEGORY_PAYMENT)) { - numPaymentServices++; - lastFoundPaymentService = service.getComponent(); - } - } - if (numPaymentServices > 1) { - // More than one service left, leave default unset - if (DBG) Log.d(TAG, "No default set, more than one service left."); - } else if (numPaymentServices == 1) { - // Make single found payment service the default - if (DBG) Log.d(TAG, "No default set, making single service default."); - setDefaultServiceForCategoryChecked(userId, lastFoundPaymentService, - CardEmulation.CATEGORY_PAYMENT); - } else { - // No payment services left, leave default at null - if (DBG) Log.d(TAG, "No default set, last payment service removed."); - } + // A payment service may have been removed, set default payment selection to "not set". + if (DBG) Log.d(TAG, "No default set, last payment service removed."); + setDefaultServiceForCategoryChecked(userId, null, CardEmulation.CATEGORY_PAYMENT); } } diff --git a/src/com/android/nfc/cardemulation/HostEmulationManager.java b/src/com/android/nfc/cardemulation/HostEmulationManager.java index 2d763f93..54b2babd 100644 --- a/src/com/android/nfc/cardemulation/HostEmulationManager.java +++ b/src/com/android/nfc/cardemulation/HostEmulationManager.java @@ -174,8 +174,9 @@ public void onHostEmulationData(byte[] data) { // Resolve to default // Check if resolvedService requires unlock ApduServiceInfo defaultServiceInfo = resolveInfo.defaultService; - if (defaultServiceInfo.requiresUnlock() && - mKeyguard.isKeyguardLocked() && mKeyguard.isKeyguardSecure()) { + if ((defaultServiceInfo.requiresUnlock() + || NfcService.getInstance().isSecureNfcEnabled()) + && mKeyguard.isKeyguardLocked() && mKeyguard.isKeyguardSecure()) { // Just ignore all future APDUs until next tap mState = STATE_W4_DEACTIVATE; launchTapAgain(resolveInfo.defaultService, resolveInfo.category);