diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-03-21 09:03:24 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-03-21 09:03:24 +0000 |
commit | a9e7c139eb75427e9dd03706b3ff417ba504f55d (patch) | |
tree | 2d63956f3532c46a0ad3ea08ce00db6bd567dc5c | |
parent | b01abe33d772ec297780855474ef7676e7297e4d (diff) | |
parent | 59cf5f46384d0401914c45af2cb7414aa35e2c5b (diff) | |
download | Nfc-a9e7c139eb75427e9dd03706b3ff417ba504f55d.tar.gz |
Merge "Store Nfc logs when command timeout w/o recovery" into main
-rw-r--r-- | nci/jni/NativeNfcManager.cpp | 18 | ||||
-rwxr-xr-x | nci/src/com/android/nfc/dhimpl/NativeNfcManager.java | 5 | ||||
-rw-r--r-- | src/com/android/nfc/NfcService.java | 2 |
3 files changed, 18 insertions, 7 deletions
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index ed95f931..251c3c67 100644 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -97,6 +97,7 @@ jmethodID gCachedNfcManagerNotifyEeUpdated; jmethodID gCachedNfcManagerNotifyHwErrorReported; jmethodID gCachedNfcManagerNotifyPollingLoopFrame; jmethodID gCachedNfcManagerNotifyVendorSpecificEvent; +jmethodID gCachedNfcManagerNotifyCommandTimeout; const char* gNativeP2pDeviceClassName = "com/android/nfc/dhimpl/NativeP2pDevice"; const char* gNativeNfcTagClassName = "com/android/nfc/dhimpl/NativeNfcTag"; @@ -673,6 +674,9 @@ static jboolean nfcManager_initNativeStruc(JNIEnv* e, jobject o) { gCachedNfcManagerNotifyVendorSpecificEvent = e->GetMethodID(cls.get(), "notifyVendorSpecificEvent", "(II[B)V"); + gCachedNfcManagerNotifyCommandTimeout = + e->GetMethodID(cls.get(), "notifyCommandTimeout", "()V"); + if (nfc_jni_cache_object(e, gNativeNfcTagClassName, &(nat->cached_NfcTag)) == -1) { LOG(ERROR) << StringPrintf("%s: fail cache NativeNfcTag", __func__); @@ -784,13 +788,13 @@ void nfaDeviceManagementCallback(uint8_t dmEvent, __func__); struct nfc_jni_native_data* nat = getNative(NULL, NULL); + JNIEnv* e = NULL; + ScopedAttach attach(nat->vm, &e); + if (e == NULL) { + LOG(ERROR) << StringPrintf("jni env is null"); + return; + } if (recovery_option && nat != NULL) { - JNIEnv* e = NULL; - ScopedAttach attach(nat->vm, &e); - if (e == NULL) { - LOG(ERROR) << StringPrintf("jni env is null"); - return; - } LOG(ERROR) << StringPrintf("%s: toggle NFC state to recovery nfc", __func__); sIsRecovering = true; @@ -865,6 +869,8 @@ void nfaDeviceManagementCallback(uint8_t dmEvent, } PowerSwitch::getInstance().initialize(PowerSwitch::UNKNOWN_LEVEL); LOG(ERROR) << StringPrintf("%s: crash NFC service", __func__); + e->CallVoidMethod(nat->manager, + android::gCachedNfcManagerNotifyCommandTimeout); ////////////////////////////////////////////// // crash the NFC service process so it can restart automatically abort(); diff --git a/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java b/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java index f80d0c83..ab2f0984 100755 --- a/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java +++ b/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java @@ -25,6 +25,7 @@ import android.util.Log; import com.android.nfc.DeviceHost; import com.android.nfc.NfcDiscoveryParameters; +import com.android.nfc.NfcService; import com.android.nfc.NfcVendorNciResponse; import java.io.FileDescriptor; @@ -500,4 +501,8 @@ public class NativeNfcManager implements DeviceHost { @Override public native void setTechnologyABRoute(int route); + + private void notifyCommandTimeout() { + NfcService.getInstance().storeNativeCrashLogs(); + } } diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 06e72f0a..84efb73e 100644 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -3866,7 +3866,7 @@ public class NfcService implements DeviceHostListener, ForegroundUtils.Callback } } - private void storeNativeCrashLogs() { + public void storeNativeCrashLogs() { FileOutputStream fos = null; try { File file = new File(NATIVE_LOG_FILE_PATH, NATIVE_LOG_FILE_NAME); |