From 59e7a6d7b8c6ab1b2d0fd968468842d860c2666c Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Fri, 12 Nov 2021 21:01:36 +0100 Subject: [PATCH] [HotFix] src/controller/java/zap-generated/ is out of sync (#11750) --- .../java/zap-generated/CHIPReadCallbacks.cpp | 91 +++++++++++++++++-- .../java/zap-generated/CHIPReadCallbacks.h | 2 + .../chip/devicecontroller/ChipClusters.java | 10 +- 3 files changed, 91 insertions(+), 12 deletions(-) diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp index 0da25f7e7e83e5..b2bebd86182f9b 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp @@ -3036,6 +3036,17 @@ CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback::CHIPSoftwareDiagnosticsTh } } +CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback::~CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + void CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback::CallbackFn( void * context, const chip::app::DataModel::DecodableList & @@ -3079,7 +3090,8 @@ void CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback::CallbackFn( ChipLogError(Zcl, "Could not find class chip/devicecontroller/ChipClusters$SoftwareDiagnosticsCluster$ThreadMetricsAttribute")); chip::JniClass attributeJniClass(attributeClass); - jmethodID attributeCtor = env->GetMethodID(attributeClass, "", "(JLjava/lang/String;JJJ)V"); + jmethodID attributeCtor = env->GetMethodID( + attributeClass, "", "(Ljava/lang/Long;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;)V"); VerifyOrReturn(attributeCtor != nullptr, ChipLogError(Zcl, "Could not find ThreadMetricsAttribute constructor")); auto iter = list.begin(); @@ -3087,12 +3099,77 @@ void CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback::CallbackFn( { auto & entry = iter.GetValue(); (void) entry; - jlong id = entry.id; - chip::UtfString nameStr(env, entry.name); - jstring name(nameStr.jniValue()); - jlong stackFreeCurrent = entry.stackFreeCurrent; - jlong stackFreeMinimum = entry.stackFreeMinimum; - jlong stackSize = entry.stackSize; + bool idNull = false; + bool idHasValue = true; + + uint64_t idValue = entry.id; + + jobject id = nullptr; + if (!idNull && idHasValue) + { + jclass idEntryCls; + chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Long", idEntryCls); + chip::JniClass idJniClass(idEntryCls); + jmethodID idEntryTypeCtor = env->GetMethodID(idEntryCls, "", "(J)V"); + id = env->NewObject(idEntryCls, idEntryTypeCtor, idValue); + } + + bool nameNull = false; + bool nameHasValue = true; + + chip::CharSpan nameValue = entry.name; + + jstring name = nullptr; + chip::UtfString nameStr(env, nameValue); + if (!nameNull && nameHasValue) + { + name = jstring(nameStr.jniValue()); + } + + bool stackFreeCurrentNull = false; + bool stackFreeCurrentHasValue = true; + + uint32_t stackFreeCurrentValue = entry.stackFreeCurrent; + + jobject stackFreeCurrent = nullptr; + if (!stackFreeCurrentNull && stackFreeCurrentHasValue) + { + jclass stackFreeCurrentEntryCls; + chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Long", stackFreeCurrentEntryCls); + chip::JniClass stackFreeCurrentJniClass(stackFreeCurrentEntryCls); + jmethodID stackFreeCurrentEntryTypeCtor = env->GetMethodID(stackFreeCurrentEntryCls, "", "(J)V"); + stackFreeCurrent = env->NewObject(stackFreeCurrentEntryCls, stackFreeCurrentEntryTypeCtor, stackFreeCurrentValue); + } + + bool stackFreeMinimumNull = false; + bool stackFreeMinimumHasValue = true; + + uint32_t stackFreeMinimumValue = entry.stackFreeMinimum; + + jobject stackFreeMinimum = nullptr; + if (!stackFreeMinimumNull && stackFreeMinimumHasValue) + { + jclass stackFreeMinimumEntryCls; + chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Long", stackFreeMinimumEntryCls); + chip::JniClass stackFreeMinimumJniClass(stackFreeMinimumEntryCls); + jmethodID stackFreeMinimumEntryTypeCtor = env->GetMethodID(stackFreeMinimumEntryCls, "", "(J)V"); + stackFreeMinimum = env->NewObject(stackFreeMinimumEntryCls, stackFreeMinimumEntryTypeCtor, stackFreeMinimumValue); + } + + bool stackSizeNull = false; + bool stackSizeHasValue = true; + + uint32_t stackSizeValue = entry.stackSize; + + jobject stackSize = nullptr; + if (!stackSizeNull && stackSizeHasValue) + { + jclass stackSizeEntryCls; + chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Long", stackSizeEntryCls); + chip::JniClass stackSizeJniClass(stackSizeEntryCls); + jmethodID stackSizeEntryTypeCtor = env->GetMethodID(stackSizeEntryCls, "", "(J)V"); + stackSize = env->NewObject(stackSizeEntryCls, stackSizeEntryTypeCtor, stackSizeValue); + } jobject attributeObj = env->NewObject(attributeClass, attributeCtor, id, name, stackFreeCurrent, stackFreeMinimum, stackSize); diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.h b/src/controller/java/zap-generated/CHIPReadCallbacks.h index 0cee44cd38c6cd..259c3495f03caa 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.h +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.h @@ -583,6 +583,8 @@ class CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback public: CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback(jobject javaCallback); + ~CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback(); + static void CallbackFn( void * context, const chip::app::DataModel::DecodableList & diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java index 546675d1e847fc..76d86dcfa5a0e3 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -5996,14 +5996,14 @@ public void resetWatermarks(DefaultClusterCallback callback) { private native void resetWatermarks(long chipClusterPtr, DefaultClusterCallback callback); public static class ThreadMetricsAttribute { - public long id; + public Long id; public String name; - public long stackFreeCurrent; - public long stackFreeMinimum; - public long stackSize; + public Long stackFreeCurrent; + public Long stackFreeMinimum; + public Long stackSize; public ThreadMetricsAttribute( - long id, String name, long stackFreeCurrent, long stackFreeMinimum, long stackSize) { + Long id, String name, Long stackFreeCurrent, Long stackFreeMinimum, Long stackSize) { this.id = id; this.name = name; this.stackFreeCurrent = stackFreeCurrent;