diff options
author | suryaprakash.konduru <suryaprakash.konduru@nxp.com> | 2024-02-27 09:28:17 +0530 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2024-02-27 13:50:50 -0800 |
commit | da9673973ed8c5945b1fc4fd85acb19525f59e75 (patch) | |
tree | 05e5805ee4ac42c5467511ce497992cc70daaab0 /nci/jni | |
parent | 5ae3f671c49aadd0ad83ca07979930f76d7509a3 (diff) | |
download | Nfc-da9673973ed8c5945b1fc4fd85acb19525f59e75.tar.gz |
nfc: Add support for vendor specific notifications
- All the vendor(OID) notification's other than 0x0C OID are notified to
application using Vendor Notification Callback API
Bug: 325896953
Test: Manual test
Merged-In: Ia619a3273ce9b5606bbb6f2b459b5720e6dcfbc8
Change-Id: Ia619a3273ce9b5606bbb6f2b459b5720e6dcfbc8
Diffstat (limited to 'nci/jni')
-rw-r--r-- | nci/jni/NativeNfcManager.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index 00c85f57..ed95f931 100644 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -96,6 +96,7 @@ jmethodID gCachedNfcManagerNotifyRfFieldDeactivated; jmethodID gCachedNfcManagerNotifyEeUpdated; jmethodID gCachedNfcManagerNotifyHwErrorReported; jmethodID gCachedNfcManagerNotifyPollingLoopFrame; +jmethodID gCachedNfcManagerNotifyVendorSpecificEvent; const char* gNativeP2pDeviceClassName = "com/android/nfc/dhimpl/NativeP2pDevice"; const char* gNativeNfcTagClassName = "com/android/nfc/dhimpl/NativeNfcTag"; @@ -669,6 +670,8 @@ static jboolean nfcManager_initNativeStruc(JNIEnv* e, jobject o) { gCachedNfcManagerNotifyPollingLoopFrame = e->GetMethodID(cls.get(), "notifyPollingLoopFrame", "(I[B)V"); + gCachedNfcManagerNotifyVendorSpecificEvent = + e->GetMethodID(cls.get(), "notifyVendorSpecificEvent", "(II[B)V"); if (nfc_jni_cache_object(e, gNativeNfcTagClassName, &(nat->cached_NfcTag)) == -1) { @@ -1030,9 +1033,32 @@ void static nfaVSCallback(uint8_t event, uint16_t param_len, uint8_t* p_param) { android_sub_opcode); } } break; - default: - LOG(DEBUG) << StringPrintf("Unknown NFC Proprietary opcode %x", event); - break; + default: { + struct nfc_jni_native_data* nat = getNative(NULL, NULL); + if (!nat) { + LOG(ERROR) << StringPrintf("%s: cached nat is null", __FUNCTION__); + return; + } + JNIEnv* e = NULL; + ScopedAttach attach(nat->vm, &e); + if (e == NULL) { + LOG(ERROR) << StringPrintf("%s: jni env is null", __FUNCTION__); + return; + } + ScopedLocalRef<jobject> dataJavaArray(e, e->NewByteArray(param_len)); + if (dataJavaArray.get() == NULL) { + LOG(ERROR) << StringPrintf("%s: fail allocate array", __FUNCTION__); + return; + } + e->SetByteArrayRegion((jbyteArray)dataJavaArray.get(), 0, param_len, (jbyte*)(p_param)); + if (e->ExceptionCheck()) { + e->ExceptionClear(); + LOG(ERROR) << StringPrintf("%s failed to fill array", __FUNCTION__); + return; + } + e->CallVoidMethod(nat->manager, android::gCachedNfcManagerNotifyVendorSpecificEvent, + (jint)event, (jint)param_len, dataJavaArray.get()); + } break; } } @@ -1266,7 +1292,7 @@ static jboolean nfcManager_doInitialize(JNIEnv* e, jobject o) { TheEnd: if (sIsNfaEnabled) { PowerSwitch::getInstance().setLevel(PowerSwitch::LOW_POWER); - if (android_nfc_nfc_read_polling_loop()) { + if (android_nfc_nfc_read_polling_loop() || android_nfc_nfc_vendor_cmd()) { NFA_RegVSCback(true, &nfaVSCallback); } } |