From fd88fe8c9885d3f35581d4203a0bf5cecc468883 Mon Sep 17 00:00:00 2001 From: Joonhaeng Heo Date: Wed, 29 Jun 2022 14:54:52 +0900 Subject: [PATCH 1/2] Fix Android Crash --- .../java/CHIPDeviceController-JNI.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index 8f8dc166e026a5..02e2af09ee6d29 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -87,8 +87,6 @@ pthread_t sIOThread = PTHREAD_NULL; jclass sChipDeviceControllerExceptionCls = NULL; -const char * PARAMS_CLASS = "()Lchip/devicecontroller/ControllerParams;"; - } // namespace // NOTE: Remote device ID is in sync with the echo server device id @@ -166,27 +164,32 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr // Retrieve initialization params. jmethodID getUdpListenPort; - err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getUdpListenPort", PARAMS_CLASS, &getUdpListenPort); + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getUdpListenPort", "()I", &getUdpListenPort); SuccessOrExit(err); jmethodID getKeypairDelegate; - err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getKeypairDelegate", PARAMS_CLASS, + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getKeypairDelegate", "()Lchip/devicecontroller/KeypairDelegate;", &getKeypairDelegate); + SuccessOrExit(err); jmethodID getRootCertificate; - err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getRootCertificate", PARAMS_CLASS, + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getRootCertificate", "()[B", &getRootCertificate); + SuccessOrExit(err); jmethodID getIntermediateCertificate; - err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getIntermediateCertificate", PARAMS_CLASS, + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getIntermediateCertificate", "()[B", &getIntermediateCertificate); + SuccessOrExit(err); jmethodID getOperationalCertificate; - err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getOperationalCertificate", PARAMS_CLASS, + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getOperationalCertificate", "()[B", &getOperationalCertificate); + SuccessOrExit(err); jmethodID getIpk; - err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getIpk", PARAMS_CLASS, &getIpk); + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getIpk", "()[B", &getIpk); + SuccessOrExit(err); { uint16_t listenPort = env->CallIntMethod(controllerParams, getUdpListenPort); From 459384e7f26b6fe84e31f678475eb6e678026fae Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 29 Jun 2022 06:02:21 +0000 Subject: [PATCH 2/2] Restyled by clang-format --- src/controller/java/CHIPDeviceController-JNI.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index 02e2af09ee6d29..bed9cb146b4c56 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -168,13 +168,12 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self, jobject contr SuccessOrExit(err); jmethodID getKeypairDelegate; - err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getKeypairDelegate", "()Lchip/devicecontroller/KeypairDelegate;", - &getKeypairDelegate); + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getKeypairDelegate", + "()Lchip/devicecontroller/KeypairDelegate;", &getKeypairDelegate); SuccessOrExit(err); jmethodID getRootCertificate; - err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getRootCertificate", "()[B", - &getRootCertificate); + err = chip::JniReferences::GetInstance().FindMethod(env, controllerParams, "getRootCertificate", "()[B", &getRootCertificate); SuccessOrExit(err); jmethodID getIntermediateCertificate;