summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNattharat Jariyanuntanaet <nattharatj@google.com>2024-03-07 08:28:58 +0000
committerNattharat Jariyanuntanaet <nattharatj@google.com>2024-03-20 13:47:11 +0000
commit59cf5f46384d0401914c45af2cb7414aa35e2c5b (patch)
tree74b1010f3c39f6753af376c00e2bca84db0d5a8c
parentfc69a7b645a55ea0dc444286665695eed783bbe3 (diff)
downloadNfc-59cf5f46384d0401914c45af2cb7414aa35e2c5b.tar.gz
Store Nfc logs when command timeout w/o recovery
Test: manual Bug: 315419114 Change-Id: I00eb912aba0f3c87ac73970878ca4202be604e13 Merged-In: I00eb912aba0f3c87ac73970878ca4202be604e13
-rw-r--r--nci/jni/NativeNfcManager.cpp18
-rwxr-xr-xnci/src/com/android/nfc/dhimpl/NativeNfcManager.java5
-rw-r--r--src/com/android/nfc/NfcService.java2
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 78018898..ff846239 100644
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -3845,7 +3845,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);