| /* |
| * |
| * Copyright (c) 2022 Project CHIP Authors |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| // THIS FILE IS GENERATED BY ZAP |
| #include "CHIPInvokeCallbacks.h" |
| #include <jni/CHIPCallbackTypes.h> |
| |
| #include <app-common/zap-generated/cluster-objects.h> |
| #include <jni.h> |
| #include <lib/support/CHIPJNIError.h> |
| #include <lib/support/CodeUtils.h> |
| #include <lib/support/JniReferences.h> |
| #include <lib/support/JniTypeWrappers.h> |
| #include <platform/PlatformManager.h> |
| |
| namespace chip { |
| |
| CHIPGroupsClusterAddGroupResponseCallback::CHIPGroupsClusterAddGroupResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPGroupsClusterAddGroupResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPGroupsClusterAddGroupResponseCallback::~CHIPGroupsClusterAddGroupResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPGroupsClusterAddGroupResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPGroupsClusterAddGroupResponseCallback, void (*)(CHIPGroupsClusterAddGroupResponseCallback *)> cppCallback( |
| reinterpret_cast<CHIPGroupsClusterAddGroupResponseCallback *>(context), |
| chip::Platform::Delete<CHIPGroupsClusterAddGroupResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID); |
| } |
| CHIPGroupsClusterViewGroupResponseCallback::CHIPGroupsClusterViewGroupResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPGroupsClusterViewGroupResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPGroupsClusterViewGroupResponseCallback::~CHIPGroupsClusterViewGroupResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPGroupsClusterViewGroupResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::Groups::Commands::ViewGroupResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPGroupsClusterViewGroupResponseCallback, void (*)(CHIPGroupsClusterViewGroupResponseCallback *)> cppCallback( |
| reinterpret_cast<CHIPGroupsClusterViewGroupResponseCallback *>(context), |
| chip::Platform::Delete<CHIPGroupsClusterViewGroupResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| jobject GroupName; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.groupName, GroupName)); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, GroupName); |
| } |
| CHIPGroupsClusterGetGroupMembershipResponseCallback::CHIPGroupsClusterGetGroupMembershipResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPGroupsClusterGetGroupMembershipResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPGroupsClusterGetGroupMembershipResponseCallback::~CHIPGroupsClusterGetGroupMembershipResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPGroupsClusterGetGroupMembershipResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::Groups::Commands::GetGroupMembershipResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPGroupsClusterGetGroupMembershipResponseCallback, |
| void (*)(CHIPGroupsClusterGetGroupMembershipResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPGroupsClusterGetGroupMembershipResponseCallback *>(context), |
| chip::Platform::Delete<CHIPGroupsClusterGetGroupMembershipResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/ArrayList;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Capacity; |
| if (dataResponse.capacity.IsNull()) |
| { |
| Capacity = nullptr; |
| } |
| else |
| { |
| std::string CapacityClassName = "java/lang/Integer"; |
| std::string CapacityCtorSignature = "(I)V"; |
| jint jniCapacity = static_cast<jint>(dataResponse.capacity.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(CapacityClassName.c_str(), CapacityCtorSignature.c_str(), |
| jniCapacity, Capacity); |
| } |
| jobject GroupList; |
| chip::JniReferences::GetInstance().CreateArrayList(GroupList); |
| |
| auto iter_GroupList_0 = dataResponse.groupList.begin(); |
| while (iter_GroupList_0.Next()) |
| { |
| auto & entry_0 = iter_GroupList_0.GetValue(); |
| jobject newElement_0; |
| std::string newElement_0ClassName = "java/lang/Integer"; |
| std::string newElement_0CtorSignature = "(I)V"; |
| jint jninewElement_0 = static_cast<jint>(entry_0); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), |
| jninewElement_0, newElement_0); |
| chip::JniReferences::GetInstance().AddToList(GroupList, newElement_0); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Capacity, GroupList); |
| } |
| CHIPGroupsClusterRemoveGroupResponseCallback::CHIPGroupsClusterRemoveGroupResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPGroupsClusterRemoveGroupResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPGroupsClusterRemoveGroupResponseCallback::~CHIPGroupsClusterRemoveGroupResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPGroupsClusterRemoveGroupResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::Groups::Commands::RemoveGroupResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPGroupsClusterRemoveGroupResponseCallback, void (*)(CHIPGroupsClusterRemoveGroupResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPGroupsClusterRemoveGroupResponseCallback *>(context), |
| chip::Platform::Delete<CHIPGroupsClusterRemoveGroupResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID); |
| } |
| CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::~CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImageResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback, |
| void (*)(CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback *>(context), |
| chip::Platform::Delete<CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" |
| "Optional;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject DelayedActionTime; |
| if (!dataResponse.delayedActionTime.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, DelayedActionTime); |
| } |
| else |
| { |
| jobject DelayedActionTimeInsideOptional; |
| std::string DelayedActionTimeInsideOptionalClassName = "java/lang/Long"; |
| std::string DelayedActionTimeInsideOptionalCtorSignature = "(J)V"; |
| jlong jniDelayedActionTimeInsideOptional = static_cast<jlong>(dataResponse.delayedActionTime.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>( |
| DelayedActionTimeInsideOptionalClassName.c_str(), DelayedActionTimeInsideOptionalCtorSignature.c_str(), |
| jniDelayedActionTimeInsideOptional, DelayedActionTimeInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(DelayedActionTimeInsideOptional, DelayedActionTime); |
| } |
| jobject ImageURI; |
| if (!dataResponse.imageURI.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, ImageURI); |
| } |
| else |
| { |
| jobject ImageURIInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.imageURI.Value(), ImageURIInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(ImageURIInsideOptional, ImageURI); |
| } |
| jobject SoftwareVersion; |
| if (!dataResponse.softwareVersion.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, SoftwareVersion); |
| } |
| else |
| { |
| jobject SoftwareVersionInsideOptional; |
| std::string SoftwareVersionInsideOptionalClassName = "java/lang/Long"; |
| std::string SoftwareVersionInsideOptionalCtorSignature = "(J)V"; |
| jlong jniSoftwareVersionInsideOptional = static_cast<jlong>(dataResponse.softwareVersion.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>( |
| SoftwareVersionInsideOptionalClassName.c_str(), SoftwareVersionInsideOptionalCtorSignature.c_str(), |
| jniSoftwareVersionInsideOptional, SoftwareVersionInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(SoftwareVersionInsideOptional, SoftwareVersion); |
| } |
| jobject SoftwareVersionString; |
| if (!dataResponse.softwareVersionString.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, SoftwareVersionString); |
| } |
| else |
| { |
| jobject SoftwareVersionStringInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.softwareVersionString.Value(), |
| SoftwareVersionStringInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(SoftwareVersionStringInsideOptional, SoftwareVersionString); |
| } |
| jobject UpdateToken; |
| if (!dataResponse.updateToken.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, UpdateToken); |
| } |
| else |
| { |
| jobject UpdateTokenInsideOptional; |
| jbyteArray UpdateTokenInsideOptionalByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.updateToken.Value().size())); |
| env->SetByteArrayRegion(UpdateTokenInsideOptionalByteArray, 0, static_cast<jsize>(dataResponse.updateToken.Value().size()), |
| reinterpret_cast<const jbyte *>(dataResponse.updateToken.Value().data())); |
| UpdateTokenInsideOptional = UpdateTokenInsideOptionalByteArray; |
| chip::JniReferences::GetInstance().CreateOptional(UpdateTokenInsideOptional, UpdateToken); |
| } |
| jobject UserConsentNeeded; |
| if (!dataResponse.userConsentNeeded.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, UserConsentNeeded); |
| } |
| else |
| { |
| jobject UserConsentNeededInsideOptional; |
| std::string UserConsentNeededInsideOptionalClassName = "java/lang/Boolean"; |
| std::string UserConsentNeededInsideOptionalCtorSignature = "(Z)V"; |
| jboolean jniUserConsentNeededInsideOptional = static_cast<jboolean>(dataResponse.userConsentNeeded.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| UserConsentNeededInsideOptionalClassName.c_str(), UserConsentNeededInsideOptionalCtorSignature.c_str(), |
| jniUserConsentNeededInsideOptional, UserConsentNeededInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(UserConsentNeededInsideOptional, UserConsentNeeded); |
| } |
| jobject MetadataForRequestor; |
| if (!dataResponse.metadataForRequestor.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, MetadataForRequestor); |
| } |
| else |
| { |
| jobject MetadataForRequestorInsideOptional; |
| jbyteArray MetadataForRequestorInsideOptionalByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.metadataForRequestor.Value().size())); |
| env->SetByteArrayRegion(MetadataForRequestorInsideOptionalByteArray, 0, |
| static_cast<jsize>(dataResponse.metadataForRequestor.Value().size()), |
| reinterpret_cast<const jbyte *>(dataResponse.metadataForRequestor.Value().data())); |
| MetadataForRequestorInsideOptional = MetadataForRequestorInsideOptionalByteArray; |
| chip::JniReferences::GetInstance().CreateOptional(MetadataForRequestorInsideOptional, MetadataForRequestor); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, DelayedActionTime, ImageURI, SoftwareVersion, SoftwareVersionString, |
| UpdateToken, UserConsentNeeded, MetadataForRequestor); |
| } |
| CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback::CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback( |
| jobject javaCallback) : |
| Callback::Callback<CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback::~CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback, |
| void (*)(CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback *>(context), |
| chip::Platform::Delete<CHIPOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Long;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Action; |
| std::string ActionClassName = "java/lang/Integer"; |
| std::string ActionCtorSignature = "(I)V"; |
| jint jniAction = static_cast<jint>(dataResponse.action); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(ActionClassName.c_str(), ActionCtorSignature.c_str(), jniAction, |
| Action); |
| jobject DelayedActionTime; |
| std::string DelayedActionTimeClassName = "java/lang/Long"; |
| std::string DelayedActionTimeCtorSignature = "(J)V"; |
| jlong jniDelayedActionTime = static_cast<jlong>(dataResponse.delayedActionTime); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>( |
| DelayedActionTimeClassName.c_str(), DelayedActionTimeCtorSignature.c_str(), jniDelayedActionTime, DelayedActionTime); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Action, DelayedActionTime); |
| } |
| CHIPGeneralCommissioningClusterArmFailSafeResponseCallback::CHIPGeneralCommissioningClusterArmFailSafeResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPGeneralCommissioningClusterArmFailSafeResponseCallback::~CHIPGeneralCommissioningClusterArmFailSafeResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPGeneralCommissioningClusterArmFailSafeResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::GeneralCommissioning::Commands::ArmFailSafeResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPGeneralCommissioningClusterArmFailSafeResponseCallback, |
| void (*)(CHIPGeneralCommissioningClusterArmFailSafeResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPGeneralCommissioningClusterArmFailSafeResponseCallback *>(context), |
| chip::Platform::Delete<CHIPGeneralCommissioningClusterArmFailSafeResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/String;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject ErrorCode; |
| std::string ErrorCodeClassName = "java/lang/Integer"; |
| std::string ErrorCodeCtorSignature = "(I)V"; |
| jint jniErrorCode = static_cast<jint>(dataResponse.errorCode); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), |
| jniErrorCode, ErrorCode); |
| jobject DebugText; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); |
| } |
| CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback:: |
| CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback:: |
| ~CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback, |
| void (*)(CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback *>(context), |
| chip::Platform::Delete<CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/String;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject ErrorCode; |
| std::string ErrorCodeClassName = "java/lang/Integer"; |
| std::string ErrorCodeCtorSignature = "(I)V"; |
| jint jniErrorCode = static_cast<jint>(dataResponse.errorCode); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), |
| jniErrorCode, ErrorCode); |
| jobject DebugText; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); |
| } |
| CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback:: |
| CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback:: |
| ~CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::GeneralCommissioning::Commands::CommissioningCompleteResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback, |
| void (*)(CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback *>(context), |
| chip::Platform::Delete<CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/String;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject ErrorCode; |
| std::string ErrorCodeClassName = "java/lang/Integer"; |
| std::string ErrorCodeCtorSignature = "(I)V"; |
| jint jniErrorCode = static_cast<jint>(dataResponse.errorCode); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), |
| jniErrorCode, ErrorCode); |
| jobject DebugText; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); |
| } |
| CHIPNetworkCommissioningClusterScanNetworksResponseCallback::CHIPNetworkCommissioningClusterScanNetworksResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPNetworkCommissioningClusterScanNetworksResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPNetworkCommissioningClusterScanNetworksResponseCallback::~CHIPNetworkCommissioningClusterScanNetworksResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPNetworkCommissioningClusterScanNetworksResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworksResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPNetworkCommissioningClusterScanNetworksResponseCallback, |
| void (*)(CHIPNetworkCommissioningClusterScanNetworksResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPNetworkCommissioningClusterScanNetworksResponseCallback *>(context), |
| chip::Platform::Delete<CHIPNetworkCommissioningClusterScanNetworksResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject NetworkingStatus; |
| std::string NetworkingStatusClassName = "java/lang/Integer"; |
| std::string NetworkingStatusCtorSignature = "(I)V"; |
| jint jniNetworkingStatus = static_cast<jint>(dataResponse.networkingStatus); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| NetworkingStatusClassName.c_str(), NetworkingStatusCtorSignature.c_str(), jniNetworkingStatus, NetworkingStatus); |
| jobject DebugText; |
| if (!dataResponse.debugText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); |
| } |
| else |
| { |
| jobject DebugTextInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); |
| } |
| jobject WiFiScanResults; |
| if (!dataResponse.wiFiScanResults.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, WiFiScanResults); |
| } |
| else |
| { |
| jobject WiFiScanResultsInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(WiFiScanResultsInsideOptional); |
| |
| auto iter_WiFiScanResultsInsideOptional_1 = dataResponse.wiFiScanResults.Value().begin(); |
| while (iter_WiFiScanResultsInsideOptional_1.Next()) |
| { |
| auto & entry_1 = iter_WiFiScanResultsInsideOptional_1.GetValue(); |
| jobject newElement_1; |
| jobject newElement_1_security; |
| std::string newElement_1_securityClassName = "java/lang/Integer"; |
| std::string newElement_1_securityCtorSignature = "(I)V"; |
| jint jninewElement_1_security = static_cast<jint>(entry_1.security.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_1_securityClassName.c_str(), |
| newElement_1_securityCtorSignature.c_str(), |
| jninewElement_1_security, newElement_1_security); |
| jobject newElement_1_ssid; |
| jbyteArray newElement_1_ssidByteArray = env->NewByteArray(static_cast<jsize>(entry_1.ssid.size())); |
| env->SetByteArrayRegion(newElement_1_ssidByteArray, 0, static_cast<jsize>(entry_1.ssid.size()), |
| reinterpret_cast<const jbyte *>(entry_1.ssid.data())); |
| newElement_1_ssid = newElement_1_ssidByteArray; |
| jobject newElement_1_bssid; |
| jbyteArray newElement_1_bssidByteArray = env->NewByteArray(static_cast<jsize>(entry_1.bssid.size())); |
| env->SetByteArrayRegion(newElement_1_bssidByteArray, 0, static_cast<jsize>(entry_1.bssid.size()), |
| reinterpret_cast<const jbyte *>(entry_1.bssid.data())); |
| newElement_1_bssid = newElement_1_bssidByteArray; |
| jobject newElement_1_channel; |
| std::string newElement_1_channelClassName = "java/lang/Integer"; |
| std::string newElement_1_channelCtorSignature = "(I)V"; |
| jint jninewElement_1_channel = static_cast<jint>(entry_1.channel); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_1_channelClassName.c_str(), |
| newElement_1_channelCtorSignature.c_str(), |
| jninewElement_1_channel, newElement_1_channel); |
| jobject newElement_1_wiFiBand; |
| std::string newElement_1_wiFiBandClassName = "java/lang/Integer"; |
| std::string newElement_1_wiFiBandCtorSignature = "(I)V"; |
| jint jninewElement_1_wiFiBand = static_cast<jint>(entry_1.wiFiBand); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_1_wiFiBandClassName.c_str(), |
| newElement_1_wiFiBandCtorSignature.c_str(), |
| jninewElement_1_wiFiBand, newElement_1_wiFiBand); |
| jobject newElement_1_rssi; |
| std::string newElement_1_rssiClassName = "java/lang/Integer"; |
| std::string newElement_1_rssiCtorSignature = "(I)V"; |
| jint jninewElement_1_rssi = static_cast<jint>(entry_1.rssi); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_1_rssiClassName.c_str(), |
| newElement_1_rssiCtorSignature.c_str(), jninewElement_1_rssi, |
| newElement_1_rssi); |
| |
| jclass wiFiInterfaceScanResultStructStructClass_2; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$NetworkCommissioningClusterWiFiInterfaceScanResultStruct", |
| wiFiInterfaceScanResultStructStructClass_2); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$NetworkCommissioningClusterWiFiInterfaceScanResultStruct"); |
| return; |
| } |
| |
| jmethodID wiFiInterfaceScanResultStructStructCtor_2; |
| err = chip::JniReferences::GetInstance().FindMethod( |
| env, wiFiInterfaceScanResultStructStructClass_2, "<init>", |
| "(Ljava/lang/Integer;[B[BLjava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", |
| &wiFiInterfaceScanResultStructStructCtor_2); |
| if (err != CHIP_NO_ERROR || wiFiInterfaceScanResultStructStructCtor_2 == nullptr) |
| { |
| ChipLogError(Zcl, |
| "Could not find ChipStructs$NetworkCommissioningClusterWiFiInterfaceScanResultStruct constructor"); |
| return; |
| } |
| |
| newElement_1 = env->NewObject(wiFiInterfaceScanResultStructStructClass_2, wiFiInterfaceScanResultStructStructCtor_2, |
| newElement_1_security, newElement_1_ssid, newElement_1_bssid, newElement_1_channel, |
| newElement_1_wiFiBand, newElement_1_rssi); |
| chip::JniReferences::GetInstance().AddToList(WiFiScanResultsInsideOptional, newElement_1); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(WiFiScanResultsInsideOptional, WiFiScanResults); |
| } |
| jobject ThreadScanResults; |
| if (!dataResponse.threadScanResults.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, ThreadScanResults); |
| } |
| else |
| { |
| jobject ThreadScanResultsInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(ThreadScanResultsInsideOptional); |
| |
| auto iter_ThreadScanResultsInsideOptional_1 = dataResponse.threadScanResults.Value().begin(); |
| while (iter_ThreadScanResultsInsideOptional_1.Next()) |
| { |
| auto & entry_1 = iter_ThreadScanResultsInsideOptional_1.GetValue(); |
| jobject newElement_1; |
| jobject newElement_1_panId; |
| std::string newElement_1_panIdClassName = "java/lang/Integer"; |
| std::string newElement_1_panIdCtorSignature = "(I)V"; |
| jint jninewElement_1_panId = static_cast<jint>(entry_1.panId); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_1_panIdClassName.c_str(), |
| newElement_1_panIdCtorSignature.c_str(), |
| jninewElement_1_panId, newElement_1_panId); |
| jobject newElement_1_extendedPanId; |
| std::string newElement_1_extendedPanIdClassName = "java/lang/Long"; |
| std::string newElement_1_extendedPanIdCtorSignature = "(J)V"; |
| jlong jninewElement_1_extendedPanId = static_cast<jlong>(entry_1.extendedPanId); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(newElement_1_extendedPanIdClassName.c_str(), |
| newElement_1_extendedPanIdCtorSignature.c_str(), |
| jninewElement_1_extendedPanId, newElement_1_extendedPanId); |
| jobject newElement_1_networkName; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_1.networkName, newElement_1_networkName)); |
| jobject newElement_1_channel; |
| std::string newElement_1_channelClassName = "java/lang/Integer"; |
| std::string newElement_1_channelCtorSignature = "(I)V"; |
| jint jninewElement_1_channel = static_cast<jint>(entry_1.channel); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_1_channelClassName.c_str(), |
| newElement_1_channelCtorSignature.c_str(), |
| jninewElement_1_channel, newElement_1_channel); |
| jobject newElement_1_version; |
| std::string newElement_1_versionClassName = "java/lang/Integer"; |
| std::string newElement_1_versionCtorSignature = "(I)V"; |
| jint jninewElement_1_version = static_cast<jint>(entry_1.version); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_1_versionClassName.c_str(), |
| newElement_1_versionCtorSignature.c_str(), |
| jninewElement_1_version, newElement_1_version); |
| jobject newElement_1_extendedAddress; |
| jbyteArray newElement_1_extendedAddressByteArray = |
| env->NewByteArray(static_cast<jsize>(entry_1.extendedAddress.size())); |
| env->SetByteArrayRegion(newElement_1_extendedAddressByteArray, 0, static_cast<jsize>(entry_1.extendedAddress.size()), |
| reinterpret_cast<const jbyte *>(entry_1.extendedAddress.data())); |
| newElement_1_extendedAddress = newElement_1_extendedAddressByteArray; |
| jobject newElement_1_rssi; |
| std::string newElement_1_rssiClassName = "java/lang/Integer"; |
| std::string newElement_1_rssiCtorSignature = "(I)V"; |
| jint jninewElement_1_rssi = static_cast<jint>(entry_1.rssi); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_1_rssiClassName.c_str(), |
| newElement_1_rssiCtorSignature.c_str(), jninewElement_1_rssi, |
| newElement_1_rssi); |
| jobject newElement_1_lqi; |
| std::string newElement_1_lqiClassName = "java/lang/Integer"; |
| std::string newElement_1_lqiCtorSignature = "(I)V"; |
| jint jninewElement_1_lqi = static_cast<jint>(entry_1.lqi); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_1_lqiClassName.c_str(), newElement_1_lqiCtorSignature.c_str(), jninewElement_1_lqi, newElement_1_lqi); |
| |
| jclass threadInterfaceScanResultStructStructClass_2; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$NetworkCommissioningClusterThreadInterfaceScanResultStruct", |
| threadInterfaceScanResultStructStructClass_2); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$NetworkCommissioningClusterThreadInterfaceScanResultStruct"); |
| return; |
| } |
| |
| jmethodID threadInterfaceScanResultStructStructCtor_2; |
| err = chip::JniReferences::GetInstance().FindMethod( |
| env, threadInterfaceScanResultStructStructClass_2, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Integer;[BLjava/lang/" |
| "Integer;Ljava/lang/Integer;)V", |
| &threadInterfaceScanResultStructStructCtor_2); |
| if (err != CHIP_NO_ERROR || threadInterfaceScanResultStructStructCtor_2 == nullptr) |
| { |
| ChipLogError(Zcl, |
| "Could not find ChipStructs$NetworkCommissioningClusterThreadInterfaceScanResultStruct constructor"); |
| return; |
| } |
| |
| newElement_1 = |
| env->NewObject(threadInterfaceScanResultStructStructClass_2, threadInterfaceScanResultStructStructCtor_2, |
| newElement_1_panId, newElement_1_extendedPanId, newElement_1_networkName, newElement_1_channel, |
| newElement_1_version, newElement_1_extendedAddress, newElement_1_rssi, newElement_1_lqi); |
| chip::JniReferences::GetInstance().AddToList(ThreadScanResultsInsideOptional, newElement_1); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(ThreadScanResultsInsideOptional, ThreadScanResults); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, NetworkingStatus, DebugText, WiFiScanResults, ThreadScanResults); |
| } |
| CHIPNetworkCommissioningClusterNetworkConfigResponseCallback::CHIPNetworkCommissioningClusterNetworkConfigResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPNetworkCommissioningClusterNetworkConfigResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPNetworkCommissioningClusterNetworkConfigResponseCallback::~CHIPNetworkCommissioningClusterNetworkConfigResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPNetworkCommissioningClusterNetworkConfigResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::NetworkCommissioning::Commands::NetworkConfigResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPNetworkCommissioningClusterNetworkConfigResponseCallback, |
| void (*)(CHIPNetworkCommissioningClusterNetworkConfigResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPNetworkCommissioningClusterNetworkConfigResponseCallback *>(context), |
| chip::Platform::Delete<CHIPNetworkCommissioningClusterNetworkConfigResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject NetworkingStatus; |
| std::string NetworkingStatusClassName = "java/lang/Integer"; |
| std::string NetworkingStatusCtorSignature = "(I)V"; |
| jint jniNetworkingStatus = static_cast<jint>(dataResponse.networkingStatus); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| NetworkingStatusClassName.c_str(), NetworkingStatusCtorSignature.c_str(), jniNetworkingStatus, NetworkingStatus); |
| jobject DebugText; |
| if (!dataResponse.debugText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); |
| } |
| else |
| { |
| jobject DebugTextInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); |
| } |
| jobject NetworkIndex; |
| if (!dataResponse.networkIndex.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NetworkIndex); |
| } |
| else |
| { |
| jobject NetworkIndexInsideOptional; |
| std::string NetworkIndexInsideOptionalClassName = "java/lang/Integer"; |
| std::string NetworkIndexInsideOptionalCtorSignature = "(I)V"; |
| jint jniNetworkIndexInsideOptional = static_cast<jint>(dataResponse.networkIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(NetworkIndexInsideOptionalClassName.c_str(), |
| NetworkIndexInsideOptionalCtorSignature.c_str(), |
| jniNetworkIndexInsideOptional, NetworkIndexInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(NetworkIndexInsideOptional, NetworkIndex); |
| } |
| jobject ClientIdentity; |
| if (!dataResponse.clientIdentity.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, ClientIdentity); |
| } |
| else |
| { |
| jobject ClientIdentityInsideOptional; |
| jbyteArray ClientIdentityInsideOptionalByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.clientIdentity.Value().size())); |
| env->SetByteArrayRegion(ClientIdentityInsideOptionalByteArray, 0, |
| static_cast<jsize>(dataResponse.clientIdentity.Value().size()), |
| reinterpret_cast<const jbyte *>(dataResponse.clientIdentity.Value().data())); |
| ClientIdentityInsideOptional = ClientIdentityInsideOptionalByteArray; |
| chip::JniReferences::GetInstance().CreateOptional(ClientIdentityInsideOptional, ClientIdentity); |
| } |
| jobject PossessionSignature; |
| if (!dataResponse.possessionSignature.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, PossessionSignature); |
| } |
| else |
| { |
| jobject PossessionSignatureInsideOptional; |
| jbyteArray PossessionSignatureInsideOptionalByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.possessionSignature.Value().size())); |
| env->SetByteArrayRegion(PossessionSignatureInsideOptionalByteArray, 0, |
| static_cast<jsize>(dataResponse.possessionSignature.Value().size()), |
| reinterpret_cast<const jbyte *>(dataResponse.possessionSignature.Value().data())); |
| PossessionSignatureInsideOptional = PossessionSignatureInsideOptionalByteArray; |
| chip::JniReferences::GetInstance().CreateOptional(PossessionSignatureInsideOptional, PossessionSignature); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, NetworkingStatus, DebugText, NetworkIndex, ClientIdentity, |
| PossessionSignature); |
| } |
| CHIPNetworkCommissioningClusterConnectNetworkResponseCallback::CHIPNetworkCommissioningClusterConnectNetworkResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPNetworkCommissioningClusterConnectNetworkResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPNetworkCommissioningClusterConnectNetworkResponseCallback::~CHIPNetworkCommissioningClusterConnectNetworkResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPNetworkCommissioningClusterConnectNetworkResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetworkResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPNetworkCommissioningClusterConnectNetworkResponseCallback, |
| void (*)(CHIPNetworkCommissioningClusterConnectNetworkResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPNetworkCommissioningClusterConnectNetworkResponseCallback *>(context), |
| chip::Platform::Delete<CHIPNetworkCommissioningClusterConnectNetworkResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/lang/Long;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject NetworkingStatus; |
| std::string NetworkingStatusClassName = "java/lang/Integer"; |
| std::string NetworkingStatusCtorSignature = "(I)V"; |
| jint jniNetworkingStatus = static_cast<jint>(dataResponse.networkingStatus); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| NetworkingStatusClassName.c_str(), NetworkingStatusCtorSignature.c_str(), jniNetworkingStatus, NetworkingStatus); |
| jobject DebugText; |
| if (!dataResponse.debugText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); |
| } |
| else |
| { |
| jobject DebugTextInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); |
| } |
| jobject ErrorValue; |
| if (dataResponse.errorValue.IsNull()) |
| { |
| ErrorValue = nullptr; |
| } |
| else |
| { |
| std::string ErrorValueClassName = "java/lang/Long"; |
| std::string ErrorValueCtorSignature = "(J)V"; |
| jlong jniErrorValue = static_cast<jlong>(dataResponse.errorValue.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(ErrorValueClassName.c_str(), ErrorValueCtorSignature.c_str(), |
| jniErrorValue, ErrorValue); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, NetworkingStatus, DebugText, ErrorValue); |
| } |
| CHIPNetworkCommissioningClusterQueryIdentityResponseCallback::CHIPNetworkCommissioningClusterQueryIdentityResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPNetworkCommissioningClusterQueryIdentityResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPNetworkCommissioningClusterQueryIdentityResponseCallback::~CHIPNetworkCommissioningClusterQueryIdentityResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPNetworkCommissioningClusterQueryIdentityResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::NetworkCommissioning::Commands::QueryIdentityResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPNetworkCommissioningClusterQueryIdentityResponseCallback, |
| void (*)(CHIPNetworkCommissioningClusterQueryIdentityResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPNetworkCommissioningClusterQueryIdentityResponseCallback *>(context), |
| chip::Platform::Delete<CHIPNetworkCommissioningClusterQueryIdentityResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([BLjava/util/Optional;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Identity; |
| jbyteArray IdentityByteArray = env->NewByteArray(static_cast<jsize>(dataResponse.identity.size())); |
| env->SetByteArrayRegion(IdentityByteArray, 0, static_cast<jsize>(dataResponse.identity.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.identity.data())); |
| Identity = IdentityByteArray; |
| jobject PossessionSignature; |
| if (!dataResponse.possessionSignature.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, PossessionSignature); |
| } |
| else |
| { |
| jobject PossessionSignatureInsideOptional; |
| jbyteArray PossessionSignatureInsideOptionalByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.possessionSignature.Value().size())); |
| env->SetByteArrayRegion(PossessionSignatureInsideOptionalByteArray, 0, |
| static_cast<jsize>(dataResponse.possessionSignature.Value().size()), |
| reinterpret_cast<const jbyte *>(dataResponse.possessionSignature.Value().data())); |
| PossessionSignatureInsideOptional = PossessionSignatureInsideOptionalByteArray; |
| chip::JniReferences::GetInstance().CreateOptional(PossessionSignatureInsideOptional, PossessionSignature); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Identity, PossessionSignature); |
| } |
| CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback::CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPDiagnosticLogsClusterRetrieveLogsResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback::~CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback, |
| void (*)(CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback *>(context), |
| chip::Platform::Delete<CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;[BLjava/util/Optional;Ljava/util/Optional;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject LogContent; |
| jbyteArray LogContentByteArray = env->NewByteArray(static_cast<jsize>(dataResponse.logContent.size())); |
| env->SetByteArrayRegion(LogContentByteArray, 0, static_cast<jsize>(dataResponse.logContent.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.logContent.data())); |
| LogContent = LogContentByteArray; |
| jobject UTCTimeStamp; |
| if (!dataResponse.UTCTimeStamp.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, UTCTimeStamp); |
| } |
| else |
| { |
| jobject UTCTimeStampInsideOptional; |
| std::string UTCTimeStampInsideOptionalClassName = "java/lang/Long"; |
| std::string UTCTimeStampInsideOptionalCtorSignature = "(J)V"; |
| jlong jniUTCTimeStampInsideOptional = static_cast<jlong>(dataResponse.UTCTimeStamp.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(UTCTimeStampInsideOptionalClassName.c_str(), |
| UTCTimeStampInsideOptionalCtorSignature.c_str(), |
| jniUTCTimeStampInsideOptional, UTCTimeStampInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(UTCTimeStampInsideOptional, UTCTimeStamp); |
| } |
| jobject TimeSinceBoot; |
| if (!dataResponse.timeSinceBoot.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, TimeSinceBoot); |
| } |
| else |
| { |
| jobject TimeSinceBootInsideOptional; |
| std::string TimeSinceBootInsideOptionalClassName = "java/lang/Long"; |
| std::string TimeSinceBootInsideOptionalCtorSignature = "(J)V"; |
| jlong jniTimeSinceBootInsideOptional = static_cast<jlong>(dataResponse.timeSinceBoot.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(TimeSinceBootInsideOptionalClassName.c_str(), |
| TimeSinceBootInsideOptionalCtorSignature.c_str(), |
| jniTimeSinceBootInsideOptional, TimeSinceBootInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(TimeSinceBootInsideOptional, TimeSinceBoot); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, LogContent, UTCTimeStamp, TimeSinceBoot); |
| } |
| CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback::CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback::~CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::GeneralDiagnostics::Commands::TimeSnapshotResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback, |
| void (*)(CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback *>(context), |
| chip::Platform::Delete<CHIPGeneralDiagnosticsClusterTimeSnapshotResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;Ljava/lang/Long;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject SystemTimeMs; |
| std::string SystemTimeMsClassName = "java/lang/Long"; |
| std::string SystemTimeMsCtorSignature = "(J)V"; |
| jlong jniSystemTimeMs = static_cast<jlong>(dataResponse.systemTimeMs); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(SystemTimeMsClassName.c_str(), SystemTimeMsCtorSignature.c_str(), |
| jniSystemTimeMs, SystemTimeMs); |
| jobject PosixTimeMs; |
| if (dataResponse.posixTimeMs.IsNull()) |
| { |
| PosixTimeMs = nullptr; |
| } |
| else |
| { |
| std::string PosixTimeMsClassName = "java/lang/Long"; |
| std::string PosixTimeMsCtorSignature = "(J)V"; |
| jlong jniPosixTimeMs = static_cast<jlong>(dataResponse.posixTimeMs.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(PosixTimeMsClassName.c_str(), PosixTimeMsCtorSignature.c_str(), |
| jniPosixTimeMs, PosixTimeMs); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, SystemTimeMs, PosixTimeMs); |
| } |
| CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPTimeSynchronizationClusterSetTimeZoneResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::~CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback, |
| void (*)(CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback *>(context), |
| chip::Platform::Delete<CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject DSTOffsetRequired; |
| std::string DSTOffsetRequiredClassName = "java/lang/Boolean"; |
| std::string DSTOffsetRequiredCtorSignature = "(Z)V"; |
| jboolean jniDSTOffsetRequired = static_cast<jboolean>(dataResponse.DSTOffsetRequired); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| DSTOffsetRequiredClassName.c_str(), DSTOffsetRequiredCtorSignature.c_str(), jniDSTOffsetRequired, DSTOffsetRequired); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, DSTOffsetRequired); |
| } |
| CHIPOperationalCredentialsClusterAttestationResponseCallback::CHIPOperationalCredentialsClusterAttestationResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPOperationalCredentialsClusterAttestationResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPOperationalCredentialsClusterAttestationResponseCallback::~CHIPOperationalCredentialsClusterAttestationResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPOperationalCredentialsClusterAttestationResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::OperationalCredentials::Commands::AttestationResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPOperationalCredentialsClusterAttestationResponseCallback, |
| void (*)(CHIPOperationalCredentialsClusterAttestationResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPOperationalCredentialsClusterAttestationResponseCallback *>(context), |
| chip::Platform::Delete<CHIPOperationalCredentialsClusterAttestationResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B[B)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject AttestationElements; |
| jbyteArray AttestationElementsByteArray = env->NewByteArray(static_cast<jsize>(dataResponse.attestationElements.size())); |
| env->SetByteArrayRegion(AttestationElementsByteArray, 0, static_cast<jsize>(dataResponse.attestationElements.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.attestationElements.data())); |
| AttestationElements = AttestationElementsByteArray; |
| jobject AttestationSignature; |
| jbyteArray AttestationSignatureByteArray = env->NewByteArray(static_cast<jsize>(dataResponse.attestationSignature.size())); |
| env->SetByteArrayRegion(AttestationSignatureByteArray, 0, static_cast<jsize>(dataResponse.attestationSignature.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.attestationSignature.data())); |
| AttestationSignature = AttestationSignatureByteArray; |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, AttestationElements, AttestationSignature); |
| } |
| CHIPOperationalCredentialsClusterCertificateChainResponseCallback:: |
| CHIPOperationalCredentialsClusterCertificateChainResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPOperationalCredentialsClusterCertificateChainResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPOperationalCredentialsClusterCertificateChainResponseCallback:: |
| ~CHIPOperationalCredentialsClusterCertificateChainResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPOperationalCredentialsClusterCertificateChainResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::OperationalCredentials::Commands::CertificateChainResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPOperationalCredentialsClusterCertificateChainResponseCallback, |
| void (*)(CHIPOperationalCredentialsClusterCertificateChainResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPOperationalCredentialsClusterCertificateChainResponseCallback *>(context), |
| chip::Platform::Delete<CHIPOperationalCredentialsClusterCertificateChainResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Certificate; |
| jbyteArray CertificateByteArray = env->NewByteArray(static_cast<jsize>(dataResponse.certificate.size())); |
| env->SetByteArrayRegion(CertificateByteArray, 0, static_cast<jsize>(dataResponse.certificate.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.certificate.data())); |
| Certificate = CertificateByteArray; |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Certificate); |
| } |
| CHIPOperationalCredentialsClusterCSRResponseCallback::CHIPOperationalCredentialsClusterCSRResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPOperationalCredentialsClusterCSRResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPOperationalCredentialsClusterCSRResponseCallback::~CHIPOperationalCredentialsClusterCSRResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPOperationalCredentialsClusterCSRResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::OperationalCredentials::Commands::CSRResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPOperationalCredentialsClusterCSRResponseCallback, |
| void (*)(CHIPOperationalCredentialsClusterCSRResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPOperationalCredentialsClusterCSRResponseCallback *>(context), |
| chip::Platform::Delete<CHIPOperationalCredentialsClusterCSRResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B[B)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject NOCSRElements; |
| jbyteArray NOCSRElementsByteArray = env->NewByteArray(static_cast<jsize>(dataResponse.NOCSRElements.size())); |
| env->SetByteArrayRegion(NOCSRElementsByteArray, 0, static_cast<jsize>(dataResponse.NOCSRElements.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.NOCSRElements.data())); |
| NOCSRElements = NOCSRElementsByteArray; |
| jobject AttestationSignature; |
| jbyteArray AttestationSignatureByteArray = env->NewByteArray(static_cast<jsize>(dataResponse.attestationSignature.size())); |
| env->SetByteArrayRegion(AttestationSignatureByteArray, 0, static_cast<jsize>(dataResponse.attestationSignature.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.attestationSignature.data())); |
| AttestationSignature = AttestationSignatureByteArray; |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, NOCSRElements, AttestationSignature); |
| } |
| CHIPOperationalCredentialsClusterNOCResponseCallback::CHIPOperationalCredentialsClusterNOCResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPOperationalCredentialsClusterNOCResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPOperationalCredentialsClusterNOCResponseCallback::~CHIPOperationalCredentialsClusterNOCResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPOperationalCredentialsClusterNOCResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::OperationalCredentials::Commands::NOCResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPOperationalCredentialsClusterNOCResponseCallback, |
| void (*)(CHIPOperationalCredentialsClusterNOCResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPOperationalCredentialsClusterNOCResponseCallback *>(context), |
| chip::Platform::Delete<CHIPOperationalCredentialsClusterNOCResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject StatusCode; |
| std::string StatusCodeClassName = "java/lang/Integer"; |
| std::string StatusCodeCtorSignature = "(I)V"; |
| jint jniStatusCode = static_cast<jint>(dataResponse.statusCode); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusCodeClassName.c_str(), StatusCodeCtorSignature.c_str(), |
| jniStatusCode, StatusCode); |
| jobject FabricIndex; |
| if (!dataResponse.fabricIndex.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, FabricIndex); |
| } |
| else |
| { |
| jobject FabricIndexInsideOptional; |
| std::string FabricIndexInsideOptionalClassName = "java/lang/Integer"; |
| std::string FabricIndexInsideOptionalCtorSignature = "(I)V"; |
| jint jniFabricIndexInsideOptional = static_cast<jint>(dataResponse.fabricIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(FabricIndexInsideOptionalClassName.c_str(), |
| FabricIndexInsideOptionalCtorSignature.c_str(), |
| jniFabricIndexInsideOptional, FabricIndexInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(FabricIndexInsideOptional, FabricIndex); |
| } |
| jobject DebugText; |
| if (!dataResponse.debugText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, DebugText); |
| } |
| else |
| { |
| jobject DebugTextInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, StatusCode, FabricIndex, DebugText); |
| } |
| CHIPGroupKeyManagementClusterKeySetReadResponseCallback::CHIPGroupKeyManagementClusterKeySetReadResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPGroupKeyManagementClusterKeySetReadResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPGroupKeyManagementClusterKeySetReadResponseCallback::~CHIPGroupKeyManagementClusterKeySetReadResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPGroupKeyManagementClusterKeySetReadResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPGroupKeyManagementClusterKeySetReadResponseCallback, |
| void (*)(CHIPGroupKeyManagementClusterKeySetReadResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPGroupKeyManagementClusterKeySetReadResponseCallback *>(context), |
| chip::Platform::Delete<CHIPGroupKeyManagementClusterKeySetReadResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", "(Lchip/devicecontroller/ChipStructs$GroupKeyManagementClusterGroupKeySetStruct;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject GroupKeySet; |
| jobject GroupKeySet_groupKeySetID; |
| std::string GroupKeySet_groupKeySetIDClassName = "java/lang/Integer"; |
| std::string GroupKeySet_groupKeySetIDCtorSignature = "(I)V"; |
| jint jniGroupKeySet_groupKeySetID = static_cast<jint>(dataResponse.groupKeySet.groupKeySetID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupKeySet_groupKeySetIDClassName.c_str(), |
| GroupKeySet_groupKeySetIDCtorSignature.c_str(), |
| jniGroupKeySet_groupKeySetID, GroupKeySet_groupKeySetID); |
| jobject GroupKeySet_groupKeySecurityPolicy; |
| std::string GroupKeySet_groupKeySecurityPolicyClassName = "java/lang/Integer"; |
| std::string GroupKeySet_groupKeySecurityPolicyCtorSignature = "(I)V"; |
| jint jniGroupKeySet_groupKeySecurityPolicy = static_cast<jint>(dataResponse.groupKeySet.groupKeySecurityPolicy); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| GroupKeySet_groupKeySecurityPolicyClassName.c_str(), GroupKeySet_groupKeySecurityPolicyCtorSignature.c_str(), |
| jniGroupKeySet_groupKeySecurityPolicy, GroupKeySet_groupKeySecurityPolicy); |
| jobject GroupKeySet_epochKey0; |
| if (dataResponse.groupKeySet.epochKey0.IsNull()) |
| { |
| GroupKeySet_epochKey0 = nullptr; |
| } |
| else |
| { |
| jbyteArray GroupKeySet_epochKey0ByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.groupKeySet.epochKey0.Value().size())); |
| env->SetByteArrayRegion(GroupKeySet_epochKey0ByteArray, 0, |
| static_cast<jsize>(dataResponse.groupKeySet.epochKey0.Value().size()), |
| reinterpret_cast<const jbyte *>(dataResponse.groupKeySet.epochKey0.Value().data())); |
| GroupKeySet_epochKey0 = GroupKeySet_epochKey0ByteArray; |
| } |
| jobject GroupKeySet_epochStartTime0; |
| if (dataResponse.groupKeySet.epochStartTime0.IsNull()) |
| { |
| GroupKeySet_epochStartTime0 = nullptr; |
| } |
| else |
| { |
| std::string GroupKeySet_epochStartTime0ClassName = "java/lang/Long"; |
| std::string GroupKeySet_epochStartTime0CtorSignature = "(J)V"; |
| jlong jniGroupKeySet_epochStartTime0 = static_cast<jlong>(dataResponse.groupKeySet.epochStartTime0.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(GroupKeySet_epochStartTime0ClassName.c_str(), |
| GroupKeySet_epochStartTime0CtorSignature.c_str(), |
| jniGroupKeySet_epochStartTime0, GroupKeySet_epochStartTime0); |
| } |
| jobject GroupKeySet_epochKey1; |
| if (dataResponse.groupKeySet.epochKey1.IsNull()) |
| { |
| GroupKeySet_epochKey1 = nullptr; |
| } |
| else |
| { |
| jbyteArray GroupKeySet_epochKey1ByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.groupKeySet.epochKey1.Value().size())); |
| env->SetByteArrayRegion(GroupKeySet_epochKey1ByteArray, 0, |
| static_cast<jsize>(dataResponse.groupKeySet.epochKey1.Value().size()), |
| reinterpret_cast<const jbyte *>(dataResponse.groupKeySet.epochKey1.Value().data())); |
| GroupKeySet_epochKey1 = GroupKeySet_epochKey1ByteArray; |
| } |
| jobject GroupKeySet_epochStartTime1; |
| if (dataResponse.groupKeySet.epochStartTime1.IsNull()) |
| { |
| GroupKeySet_epochStartTime1 = nullptr; |
| } |
| else |
| { |
| std::string GroupKeySet_epochStartTime1ClassName = "java/lang/Long"; |
| std::string GroupKeySet_epochStartTime1CtorSignature = "(J)V"; |
| jlong jniGroupKeySet_epochStartTime1 = static_cast<jlong>(dataResponse.groupKeySet.epochStartTime1.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(GroupKeySet_epochStartTime1ClassName.c_str(), |
| GroupKeySet_epochStartTime1CtorSignature.c_str(), |
| jniGroupKeySet_epochStartTime1, GroupKeySet_epochStartTime1); |
| } |
| jobject GroupKeySet_epochKey2; |
| if (dataResponse.groupKeySet.epochKey2.IsNull()) |
| { |
| GroupKeySet_epochKey2 = nullptr; |
| } |
| else |
| { |
| jbyteArray GroupKeySet_epochKey2ByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.groupKeySet.epochKey2.Value().size())); |
| env->SetByteArrayRegion(GroupKeySet_epochKey2ByteArray, 0, |
| static_cast<jsize>(dataResponse.groupKeySet.epochKey2.Value().size()), |
| reinterpret_cast<const jbyte *>(dataResponse.groupKeySet.epochKey2.Value().data())); |
| GroupKeySet_epochKey2 = GroupKeySet_epochKey2ByteArray; |
| } |
| jobject GroupKeySet_epochStartTime2; |
| if (dataResponse.groupKeySet.epochStartTime2.IsNull()) |
| { |
| GroupKeySet_epochStartTime2 = nullptr; |
| } |
| else |
| { |
| std::string GroupKeySet_epochStartTime2ClassName = "java/lang/Long"; |
| std::string GroupKeySet_epochStartTime2CtorSignature = "(J)V"; |
| jlong jniGroupKeySet_epochStartTime2 = static_cast<jlong>(dataResponse.groupKeySet.epochStartTime2.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(GroupKeySet_epochStartTime2ClassName.c_str(), |
| GroupKeySet_epochStartTime2CtorSignature.c_str(), |
| jniGroupKeySet_epochStartTime2, GroupKeySet_epochStartTime2); |
| } |
| |
| jclass groupKeySetStructStructClass_0; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$GroupKeyManagementClusterGroupKeySetStruct", groupKeySetStructStructClass_0); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$GroupKeyManagementClusterGroupKeySetStruct"); |
| return; |
| } |
| |
| jmethodID groupKeySetStructStructCtor_0; |
| err = chip::JniReferences::GetInstance().FindMethod( |
| env, groupKeySetStructStructClass_0, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;[BLjava/lang/Long;[BLjava/lang/Long;[BLjava/lang/Long;)V", |
| &groupKeySetStructStructCtor_0); |
| if (err != CHIP_NO_ERROR || groupKeySetStructStructCtor_0 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$GroupKeyManagementClusterGroupKeySetStruct constructor"); |
| return; |
| } |
| |
| GroupKeySet = |
| env->NewObject(groupKeySetStructStructClass_0, groupKeySetStructStructCtor_0, GroupKeySet_groupKeySetID, |
| GroupKeySet_groupKeySecurityPolicy, GroupKeySet_epochKey0, GroupKeySet_epochStartTime0, |
| GroupKeySet_epochKey1, GroupKeySet_epochStartTime1, GroupKeySet_epochKey2, GroupKeySet_epochStartTime2); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, GroupKeySet); |
| } |
| CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback:: |
| CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback:: |
| ~CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndicesResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback, |
| void (*)(CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback *>(context), |
| chip::Platform::Delete<CHIPGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/ArrayList;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject GroupKeySetIDs; |
| chip::JniReferences::GetInstance().CreateArrayList(GroupKeySetIDs); |
| |
| auto iter_GroupKeySetIDs_0 = dataResponse.groupKeySetIDs.begin(); |
| while (iter_GroupKeySetIDs_0.Next()) |
| { |
| auto & entry_0 = iter_GroupKeySetIDs_0.GetValue(); |
| jobject newElement_0; |
| std::string newElement_0ClassName = "java/lang/Integer"; |
| std::string newElement_0CtorSignature = "(I)V"; |
| jint jninewElement_0 = static_cast<jint>(entry_0); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), |
| jninewElement_0, newElement_0); |
| chip::JniReferences::GetInstance().AddToList(GroupKeySetIDs, newElement_0); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, GroupKeySetIDs); |
| } |
| CHIPIcdManagementClusterRegisterClientResponseCallback::CHIPIcdManagementClusterRegisterClientResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPIcdManagementClusterRegisterClientResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPIcdManagementClusterRegisterClientResponseCallback::~CHIPIcdManagementClusterRegisterClientResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPIcdManagementClusterRegisterClientResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::IcdManagement::Commands::RegisterClientResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPIcdManagementClusterRegisterClientResponseCallback, |
| void (*)(CHIPIcdManagementClusterRegisterClientResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPIcdManagementClusterRegisterClientResponseCallback *>(context), |
| chip::Platform::Delete<CHIPIcdManagementClusterRegisterClientResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject ICDCounter; |
| std::string ICDCounterClassName = "java/lang/Long"; |
| std::string ICDCounterCtorSignature = "(J)V"; |
| jlong jniICDCounter = static_cast<jlong>(dataResponse.ICDCounter); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(ICDCounterClassName.c_str(), ICDCounterCtorSignature.c_str(), |
| jniICDCounter, ICDCounter); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, ICDCounter); |
| } |
| CHIPIcdManagementClusterStayActiveResponseCallback::CHIPIcdManagementClusterStayActiveResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPIcdManagementClusterStayActiveResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPIcdManagementClusterStayActiveResponseCallback::~CHIPIcdManagementClusterStayActiveResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPIcdManagementClusterStayActiveResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::IcdManagement::Commands::StayActiveResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPIcdManagementClusterStayActiveResponseCallback, |
| void (*)(CHIPIcdManagementClusterStayActiveResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPIcdManagementClusterStayActiveResponseCallback *>(context), |
| chip::Platform::Delete<CHIPIcdManagementClusterStayActiveResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject PromisedActiveDuration; |
| std::string PromisedActiveDurationClassName = "java/lang/Long"; |
| std::string PromisedActiveDurationCtorSignature = "(J)V"; |
| jlong jniPromisedActiveDuration = static_cast<jlong>(dataResponse.promisedActiveDuration); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(PromisedActiveDurationClassName.c_str(), |
| PromisedActiveDurationCtorSignature.c_str(), |
| jniPromisedActiveDuration, PromisedActiveDuration); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, PromisedActiveDuration); |
| } |
| CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback:: |
| CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback:: |
| ~CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::OvenCavityOperationalState::Commands::OperationalCommandResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback, |
| void (*)(CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback *>(context), |
| chip::Platform::Delete<CHIPOvenCavityOperationalStateClusterOperationalCommandResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Lchip/devicecontroller/ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject CommandResponseState; |
| jobject CommandResponseState_errorStateID; |
| std::string CommandResponseState_errorStateIDClassName = "java/lang/Integer"; |
| std::string CommandResponseState_errorStateIDCtorSignature = "(I)V"; |
| jint jniCommandResponseState_errorStateID = static_cast<jint>(dataResponse.commandResponseState.errorStateID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| CommandResponseState_errorStateIDClassName.c_str(), CommandResponseState_errorStateIDCtorSignature.c_str(), |
| jniCommandResponseState_errorStateID, CommandResponseState_errorStateID); |
| jobject CommandResponseState_errorStateLabel; |
| if (!dataResponse.commandResponseState.errorStateLabel.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateLabel); |
| } |
| else |
| { |
| jobject CommandResponseState_errorStateLabelInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( |
| dataResponse.commandResponseState.errorStateLabel.Value(), CommandResponseState_errorStateLabelInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateLabelInsideOptional, |
| CommandResponseState_errorStateLabel); |
| } |
| jobject CommandResponseState_errorStateDetails; |
| if (!dataResponse.commandResponseState.errorStateDetails.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateDetails); |
| } |
| else |
| { |
| jobject CommandResponseState_errorStateDetailsInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( |
| dataResponse.commandResponseState.errorStateDetails.Value(), CommandResponseState_errorStateDetailsInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateDetailsInsideOptional, |
| CommandResponseState_errorStateDetails); |
| } |
| |
| jclass errorStateStructStructClass_0; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct"); |
| return; |
| } |
| |
| jmethodID errorStateStructStructCtor_0; |
| err = chip::JniReferences::GetInstance().FindMethod(env, errorStateStructStructClass_0, "<init>", |
| "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &errorStateStructStructCtor_0); |
| if (err != CHIP_NO_ERROR || errorStateStructStructCtor_0 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$OvenCavityOperationalStateClusterErrorStateStruct constructor"); |
| return; |
| } |
| |
| CommandResponseState = |
| env->NewObject(errorStateStructStructClass_0, errorStateStructStructCtor_0, CommandResponseState_errorStateID, |
| CommandResponseState_errorStateLabel, CommandResponseState_errorStateDetails); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, CommandResponseState); |
| } |
| CHIPOvenModeClusterChangeToModeResponseCallback::CHIPOvenModeClusterChangeToModeResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPOvenModeClusterChangeToModeResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPOvenModeClusterChangeToModeResponseCallback::~CHIPOvenModeClusterChangeToModeResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPOvenModeClusterChangeToModeResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::OvenMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPOvenModeClusterChangeToModeResponseCallback, void (*)(CHIPOvenModeClusterChangeToModeResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPOvenModeClusterChangeToModeResponseCallback *>(context), |
| chip::Platform::Delete<CHIPOvenModeClusterChangeToModeResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject StatusText; |
| if (!dataResponse.statusText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); |
| } |
| else |
| { |
| jobject StatusTextInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); |
| } |
| CHIPLaundryWasherModeClusterChangeToModeResponseCallback::CHIPLaundryWasherModeClusterChangeToModeResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPLaundryWasherModeClusterChangeToModeResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPLaundryWasherModeClusterChangeToModeResponseCallback::~CHIPLaundryWasherModeClusterChangeToModeResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPLaundryWasherModeClusterChangeToModeResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::LaundryWasherMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPLaundryWasherModeClusterChangeToModeResponseCallback, |
| void (*)(CHIPLaundryWasherModeClusterChangeToModeResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPLaundryWasherModeClusterChangeToModeResponseCallback *>(context), |
| chip::Platform::Delete<CHIPLaundryWasherModeClusterChangeToModeResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject StatusText; |
| if (!dataResponse.statusText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); |
| } |
| else |
| { |
| jobject StatusTextInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); |
| } |
| CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback:: |
| CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback:: |
| ~CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::RefrigeratorAndTemperatureControlledCabinetMode::Commands::ChangeToModeResponse::DecodableType & |
| dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback, |
| void (*)(CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback *)> |
| cppCallback( |
| reinterpret_cast<CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback *>(context), |
| chip::Platform::Delete<CHIPRefrigeratorAndTemperatureControlledCabinetModeClusterChangeToModeResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject StatusText; |
| if (!dataResponse.statusText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); |
| } |
| else |
| { |
| jobject StatusTextInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); |
| } |
| CHIPRvcRunModeClusterChangeToModeResponseCallback::CHIPRvcRunModeClusterChangeToModeResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPRvcRunModeClusterChangeToModeResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPRvcRunModeClusterChangeToModeResponseCallback::~CHIPRvcRunModeClusterChangeToModeResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPRvcRunModeClusterChangeToModeResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::RvcRunMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPRvcRunModeClusterChangeToModeResponseCallback, |
| void (*)(CHIPRvcRunModeClusterChangeToModeResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPRvcRunModeClusterChangeToModeResponseCallback *>(context), |
| chip::Platform::Delete<CHIPRvcRunModeClusterChangeToModeResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject StatusText; |
| if (!dataResponse.statusText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); |
| } |
| else |
| { |
| jobject StatusTextInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); |
| } |
| CHIPRvcCleanModeClusterChangeToModeResponseCallback::CHIPRvcCleanModeClusterChangeToModeResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPRvcCleanModeClusterChangeToModeResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPRvcCleanModeClusterChangeToModeResponseCallback::~CHIPRvcCleanModeClusterChangeToModeResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPRvcCleanModeClusterChangeToModeResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::RvcCleanMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPRvcCleanModeClusterChangeToModeResponseCallback, |
| void (*)(CHIPRvcCleanModeClusterChangeToModeResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPRvcCleanModeClusterChangeToModeResponseCallback *>(context), |
| chip::Platform::Delete<CHIPRvcCleanModeClusterChangeToModeResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject StatusText; |
| if (!dataResponse.statusText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); |
| } |
| else |
| { |
| jobject StatusTextInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); |
| } |
| CHIPDishwasherModeClusterChangeToModeResponseCallback::CHIPDishwasherModeClusterChangeToModeResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPDishwasherModeClusterChangeToModeResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPDishwasherModeClusterChangeToModeResponseCallback::~CHIPDishwasherModeClusterChangeToModeResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPDishwasherModeClusterChangeToModeResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::DishwasherMode::Commands::ChangeToModeResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPDishwasherModeClusterChangeToModeResponseCallback, |
| void (*)(CHIPDishwasherModeClusterChangeToModeResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPDishwasherModeClusterChangeToModeResponseCallback *>(context), |
| chip::Platform::Delete<CHIPDishwasherModeClusterChangeToModeResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject StatusText; |
| if (!dataResponse.statusText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, StatusText); |
| } |
| else |
| { |
| jobject StatusTextInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.statusText.Value(), StatusTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(StatusTextInsideOptional, StatusText); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, StatusText); |
| } |
| CHIPOperationalStateClusterOperationalCommandResponseCallback::CHIPOperationalStateClusterOperationalCommandResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPOperationalStateClusterOperationalCommandResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPOperationalStateClusterOperationalCommandResponseCallback::~CHIPOperationalStateClusterOperationalCommandResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPOperationalStateClusterOperationalCommandResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPOperationalStateClusterOperationalCommandResponseCallback, |
| void (*)(CHIPOperationalStateClusterOperationalCommandResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPOperationalStateClusterOperationalCommandResponseCallback *>(context), |
| chip::Platform::Delete<CHIPOperationalStateClusterOperationalCommandResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Lchip/devicecontroller/ChipStructs$OperationalStateClusterErrorStateStruct;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject CommandResponseState; |
| jobject CommandResponseState_errorStateID; |
| std::string CommandResponseState_errorStateIDClassName = "java/lang/Integer"; |
| std::string CommandResponseState_errorStateIDCtorSignature = "(I)V"; |
| jint jniCommandResponseState_errorStateID = static_cast<jint>(dataResponse.commandResponseState.errorStateID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| CommandResponseState_errorStateIDClassName.c_str(), CommandResponseState_errorStateIDCtorSignature.c_str(), |
| jniCommandResponseState_errorStateID, CommandResponseState_errorStateID); |
| jobject CommandResponseState_errorStateLabel; |
| if (!dataResponse.commandResponseState.errorStateLabel.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateLabel); |
| } |
| else |
| { |
| jobject CommandResponseState_errorStateLabelInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( |
| dataResponse.commandResponseState.errorStateLabel.Value(), CommandResponseState_errorStateLabelInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateLabelInsideOptional, |
| CommandResponseState_errorStateLabel); |
| } |
| jobject CommandResponseState_errorStateDetails; |
| if (!dataResponse.commandResponseState.errorStateDetails.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateDetails); |
| } |
| else |
| { |
| jobject CommandResponseState_errorStateDetailsInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( |
| dataResponse.commandResponseState.errorStateDetails.Value(), CommandResponseState_errorStateDetailsInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateDetailsInsideOptional, |
| CommandResponseState_errorStateDetails); |
| } |
| |
| jclass errorStateStructStructClass_0; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$OperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$OperationalStateClusterErrorStateStruct"); |
| return; |
| } |
| |
| jmethodID errorStateStructStructCtor_0; |
| err = chip::JniReferences::GetInstance().FindMethod(env, errorStateStructStructClass_0, "<init>", |
| "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &errorStateStructStructCtor_0); |
| if (err != CHIP_NO_ERROR || errorStateStructStructCtor_0 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$OperationalStateClusterErrorStateStruct constructor"); |
| return; |
| } |
| |
| CommandResponseState = |
| env->NewObject(errorStateStructStructClass_0, errorStateStructStructCtor_0, CommandResponseState_errorStateID, |
| CommandResponseState_errorStateLabel, CommandResponseState_errorStateDetails); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, CommandResponseState); |
| } |
| CHIPRvcOperationalStateClusterOperationalCommandResponseCallback::CHIPRvcOperationalStateClusterOperationalCommandResponseCallback( |
| jobject javaCallback) : |
| Callback::Callback<CHIPRvcOperationalStateClusterOperationalCommandResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPRvcOperationalStateClusterOperationalCommandResponseCallback:: |
| ~CHIPRvcOperationalStateClusterOperationalCommandResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPRvcOperationalStateClusterOperationalCommandResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPRvcOperationalStateClusterOperationalCommandResponseCallback, |
| void (*)(CHIPRvcOperationalStateClusterOperationalCommandResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPRvcOperationalStateClusterOperationalCommandResponseCallback *>(context), |
| chip::Platform::Delete<CHIPRvcOperationalStateClusterOperationalCommandResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", "(Lchip/devicecontroller/ChipStructs$RvcOperationalStateClusterErrorStateStruct;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject CommandResponseState; |
| jobject CommandResponseState_errorStateID; |
| std::string CommandResponseState_errorStateIDClassName = "java/lang/Integer"; |
| std::string CommandResponseState_errorStateIDCtorSignature = "(I)V"; |
| jint jniCommandResponseState_errorStateID = static_cast<jint>(dataResponse.commandResponseState.errorStateID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| CommandResponseState_errorStateIDClassName.c_str(), CommandResponseState_errorStateIDCtorSignature.c_str(), |
| jniCommandResponseState_errorStateID, CommandResponseState_errorStateID); |
| jobject CommandResponseState_errorStateLabel; |
| if (!dataResponse.commandResponseState.errorStateLabel.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateLabel); |
| } |
| else |
| { |
| jobject CommandResponseState_errorStateLabelInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( |
| dataResponse.commandResponseState.errorStateLabel.Value(), CommandResponseState_errorStateLabelInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateLabelInsideOptional, |
| CommandResponseState_errorStateLabel); |
| } |
| jobject CommandResponseState_errorStateDetails; |
| if (!dataResponse.commandResponseState.errorStateDetails.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, CommandResponseState_errorStateDetails); |
| } |
| else |
| { |
| jobject CommandResponseState_errorStateDetailsInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( |
| dataResponse.commandResponseState.errorStateDetails.Value(), CommandResponseState_errorStateDetailsInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(CommandResponseState_errorStateDetailsInsideOptional, |
| CommandResponseState_errorStateDetails); |
| } |
| |
| jclass errorStateStructStructClass_0; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$RvcOperationalStateClusterErrorStateStruct", errorStateStructStructClass_0); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$RvcOperationalStateClusterErrorStateStruct"); |
| return; |
| } |
| |
| jmethodID errorStateStructStructCtor_0; |
| err = chip::JniReferences::GetInstance().FindMethod(env, errorStateStructStructClass_0, "<init>", |
| "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &errorStateStructStructCtor_0); |
| if (err != CHIP_NO_ERROR || errorStateStructStructCtor_0 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$RvcOperationalStateClusterErrorStateStruct constructor"); |
| return; |
| } |
| |
| CommandResponseState = |
| env->NewObject(errorStateStructStructClass_0, errorStateStructStructCtor_0, CommandResponseState_errorStateID, |
| CommandResponseState_errorStateLabel, CommandResponseState_errorStateDetails); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, CommandResponseState); |
| } |
| CHIPScenesManagementClusterAddSceneResponseCallback::CHIPScenesManagementClusterAddSceneResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPScenesManagementClusterAddSceneResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPScenesManagementClusterAddSceneResponseCallback::~CHIPScenesManagementClusterAddSceneResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPScenesManagementClusterAddSceneResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ScenesManagement::Commands::AddSceneResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPScenesManagementClusterAddSceneResponseCallback, |
| void (*)(CHIPScenesManagementClusterAddSceneResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPScenesManagementClusterAddSceneResponseCallback *>(context), |
| chip::Platform::Delete<CHIPScenesManagementClusterAddSceneResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| jobject SceneID; |
| std::string SceneIDClassName = "java/lang/Integer"; |
| std::string SceneIDCtorSignature = "(I)V"; |
| jint jniSceneID = static_cast<jint>(dataResponse.sceneID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, |
| SceneID); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID); |
| } |
| CHIPScenesManagementClusterViewSceneResponseCallback::CHIPScenesManagementClusterViewSceneResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPScenesManagementClusterViewSceneResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPScenesManagementClusterViewSceneResponseCallback::~CHIPScenesManagementClusterViewSceneResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPScenesManagementClusterViewSceneResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ScenesManagement::Commands::ViewSceneResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPScenesManagementClusterViewSceneResponseCallback, |
| void (*)(CHIPScenesManagementClusterViewSceneResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPScenesManagementClusterViewSceneResponseCallback *>(context), |
| chip::Platform::Delete<CHIPScenesManagementClusterViewSceneResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| jobject SceneID; |
| std::string SceneIDClassName = "java/lang/Integer"; |
| std::string SceneIDCtorSignature = "(I)V"; |
| jint jniSceneID = static_cast<jint>(dataResponse.sceneID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, |
| SceneID); |
| jobject TransitionTime; |
| if (!dataResponse.transitionTime.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, TransitionTime); |
| } |
| else |
| { |
| jobject TransitionTimeInsideOptional; |
| std::string TransitionTimeInsideOptionalClassName = "java/lang/Integer"; |
| std::string TransitionTimeInsideOptionalCtorSignature = "(I)V"; |
| jint jniTransitionTimeInsideOptional = static_cast<jint>(dataResponse.transitionTime.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(TransitionTimeInsideOptionalClassName.c_str(), |
| TransitionTimeInsideOptionalCtorSignature.c_str(), |
| jniTransitionTimeInsideOptional, TransitionTimeInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(TransitionTimeInsideOptional, TransitionTime); |
| } |
| jobject SceneName; |
| if (!dataResponse.sceneName.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, SceneName); |
| } |
| else |
| { |
| jobject SceneNameInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.sceneName.Value(), SceneNameInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(SceneNameInsideOptional, SceneName); |
| } |
| jobject ExtensionFieldSets; |
| if (!dataResponse.extensionFieldSets.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, ExtensionFieldSets); |
| } |
| else |
| { |
| jobject ExtensionFieldSetsInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(ExtensionFieldSetsInsideOptional); |
| |
| auto iter_ExtensionFieldSetsInsideOptional_1 = dataResponse.extensionFieldSets.Value().begin(); |
| while (iter_ExtensionFieldSetsInsideOptional_1.Next()) |
| { |
| auto & entry_1 = iter_ExtensionFieldSetsInsideOptional_1.GetValue(); |
| jobject newElement_1; |
| jobject newElement_1_clusterID; |
| std::string newElement_1_clusterIDClassName = "java/lang/Long"; |
| std::string newElement_1_clusterIDCtorSignature = "(J)V"; |
| jlong jninewElement_1_clusterID = static_cast<jlong>(entry_1.clusterID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(newElement_1_clusterIDClassName.c_str(), |
| newElement_1_clusterIDCtorSignature.c_str(), |
| jninewElement_1_clusterID, newElement_1_clusterID); |
| jobject newElement_1_attributeValueList; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_1_attributeValueList); |
| |
| auto iter_newElement_1_attributeValueList_3 = entry_1.attributeValueList.begin(); |
| while (iter_newElement_1_attributeValueList_3.Next()) |
| { |
| auto & entry_3 = iter_newElement_1_attributeValueList_3.GetValue(); |
| jobject newElement_3; |
| jobject newElement_3_attributeID; |
| std::string newElement_3_attributeIDClassName = "java/lang/Long"; |
| std::string newElement_3_attributeIDCtorSignature = "(J)V"; |
| jlong jninewElement_3_attributeID = static_cast<jlong>(entry_3.attributeID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(newElement_3_attributeIDClassName.c_str(), |
| newElement_3_attributeIDCtorSignature.c_str(), |
| jninewElement_3_attributeID, newElement_3_attributeID); |
| jobject newElement_3_attributeValue; |
| std::string newElement_3_attributeValueClassName = "java/lang/Long"; |
| std::string newElement_3_attributeValueCtorSignature = "(J)V"; |
| jlong jninewElement_3_attributeValue = static_cast<jlong>(entry_3.attributeValue); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>( |
| newElement_3_attributeValueClassName.c_str(), newElement_3_attributeValueCtorSignature.c_str(), |
| jninewElement_3_attributeValue, newElement_3_attributeValue); |
| |
| jclass attributeValuePairStructClass_4; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ScenesManagementClusterAttributeValuePair", |
| attributeValuePairStructClass_4); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ScenesManagementClusterAttributeValuePair"); |
| return; |
| } |
| |
| jmethodID attributeValuePairStructCtor_4; |
| err = chip::JniReferences::GetInstance().FindMethod(env, attributeValuePairStructClass_4, "<init>", |
| "(Ljava/lang/Long;Ljava/lang/Long;)V", |
| &attributeValuePairStructCtor_4); |
| if (err != CHIP_NO_ERROR || attributeValuePairStructCtor_4 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ScenesManagementClusterAttributeValuePair constructor"); |
| return; |
| } |
| |
| newElement_3 = env->NewObject(attributeValuePairStructClass_4, attributeValuePairStructCtor_4, |
| newElement_3_attributeID, newElement_3_attributeValue); |
| chip::JniReferences::GetInstance().AddToList(newElement_1_attributeValueList, newElement_3); |
| } |
| |
| jclass extensionFieldSetStructClass_2; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ScenesManagementClusterExtensionFieldSet", extensionFieldSetStructClass_2); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ScenesManagementClusterExtensionFieldSet"); |
| return; |
| } |
| |
| jmethodID extensionFieldSetStructCtor_2; |
| err = chip::JniReferences::GetInstance().FindMethod(env, extensionFieldSetStructClass_2, "<init>", |
| "(Ljava/lang/Long;Ljava/util/ArrayList;)V", |
| &extensionFieldSetStructCtor_2); |
| if (err != CHIP_NO_ERROR || extensionFieldSetStructCtor_2 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ScenesManagementClusterExtensionFieldSet constructor"); |
| return; |
| } |
| |
| newElement_1 = env->NewObject(extensionFieldSetStructClass_2, extensionFieldSetStructCtor_2, newElement_1_clusterID, |
| newElement_1_attributeValueList); |
| chip::JniReferences::GetInstance().AddToList(ExtensionFieldSetsInsideOptional, newElement_1); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(ExtensionFieldSetsInsideOptional, ExtensionFieldSets); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID, TransitionTime, SceneName, ExtensionFieldSets); |
| } |
| CHIPScenesManagementClusterRemoveSceneResponseCallback::CHIPScenesManagementClusterRemoveSceneResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPScenesManagementClusterRemoveSceneResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPScenesManagementClusterRemoveSceneResponseCallback::~CHIPScenesManagementClusterRemoveSceneResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPScenesManagementClusterRemoveSceneResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ScenesManagement::Commands::RemoveSceneResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPScenesManagementClusterRemoveSceneResponseCallback, |
| void (*)(CHIPScenesManagementClusterRemoveSceneResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPScenesManagementClusterRemoveSceneResponseCallback *>(context), |
| chip::Platform::Delete<CHIPScenesManagementClusterRemoveSceneResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| jobject SceneID; |
| std::string SceneIDClassName = "java/lang/Integer"; |
| std::string SceneIDCtorSignature = "(I)V"; |
| jint jniSceneID = static_cast<jint>(dataResponse.sceneID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, |
| SceneID); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID); |
| } |
| CHIPScenesManagementClusterRemoveAllScenesResponseCallback::CHIPScenesManagementClusterRemoveAllScenesResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPScenesManagementClusterRemoveAllScenesResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPScenesManagementClusterRemoveAllScenesResponseCallback::~CHIPScenesManagementClusterRemoveAllScenesResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPScenesManagementClusterRemoveAllScenesResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ScenesManagement::Commands::RemoveAllScenesResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPScenesManagementClusterRemoveAllScenesResponseCallback, |
| void (*)(CHIPScenesManagementClusterRemoveAllScenesResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPScenesManagementClusterRemoveAllScenesResponseCallback *>(context), |
| chip::Platform::Delete<CHIPScenesManagementClusterRemoveAllScenesResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID); |
| } |
| CHIPScenesManagementClusterStoreSceneResponseCallback::CHIPScenesManagementClusterStoreSceneResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPScenesManagementClusterStoreSceneResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPScenesManagementClusterStoreSceneResponseCallback::~CHIPScenesManagementClusterStoreSceneResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPScenesManagementClusterStoreSceneResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ScenesManagement::Commands::StoreSceneResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPScenesManagementClusterStoreSceneResponseCallback, |
| void (*)(CHIPScenesManagementClusterStoreSceneResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPScenesManagementClusterStoreSceneResponseCallback *>(context), |
| chip::Platform::Delete<CHIPScenesManagementClusterStoreSceneResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| jobject SceneID; |
| std::string SceneIDClassName = "java/lang/Integer"; |
| std::string SceneIDCtorSignature = "(I)V"; |
| jint jniSceneID = static_cast<jint>(dataResponse.sceneID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, |
| SceneID); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID); |
| } |
| CHIPScenesManagementClusterGetSceneMembershipResponseCallback::CHIPScenesManagementClusterGetSceneMembershipResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPScenesManagementClusterGetSceneMembershipResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPScenesManagementClusterGetSceneMembershipResponseCallback::~CHIPScenesManagementClusterGetSceneMembershipResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPScenesManagementClusterGetSceneMembershipResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ScenesManagement::Commands::GetSceneMembershipResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPScenesManagementClusterGetSceneMembershipResponseCallback, |
| void (*)(CHIPScenesManagementClusterGetSceneMembershipResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPScenesManagementClusterGetSceneMembershipResponseCallback *>(context), |
| chip::Platform::Delete<CHIPScenesManagementClusterGetSceneMembershipResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject Capacity; |
| if (dataResponse.capacity.IsNull()) |
| { |
| Capacity = nullptr; |
| } |
| else |
| { |
| std::string CapacityClassName = "java/lang/Integer"; |
| std::string CapacityCtorSignature = "(I)V"; |
| jint jniCapacity = static_cast<jint>(dataResponse.capacity.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(CapacityClassName.c_str(), CapacityCtorSignature.c_str(), |
| jniCapacity, Capacity); |
| } |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| jobject SceneList; |
| if (!dataResponse.sceneList.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, SceneList); |
| } |
| else |
| { |
| jobject SceneListInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(SceneListInsideOptional); |
| |
| auto iter_SceneListInsideOptional_1 = dataResponse.sceneList.Value().begin(); |
| while (iter_SceneListInsideOptional_1.Next()) |
| { |
| auto & entry_1 = iter_SceneListInsideOptional_1.GetValue(); |
| jobject newElement_1; |
| std::string newElement_1ClassName = "java/lang/Integer"; |
| std::string newElement_1CtorSignature = "(I)V"; |
| jint jninewElement_1 = static_cast<jint>(entry_1); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); |
| chip::JniReferences::GetInstance().AddToList(SceneListInsideOptional, newElement_1); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(SceneListInsideOptional, SceneList); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Capacity, GroupID, SceneList); |
| } |
| CHIPScenesManagementClusterEnhancedAddSceneResponseCallback::CHIPScenesManagementClusterEnhancedAddSceneResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPScenesManagementClusterEnhancedAddSceneResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPScenesManagementClusterEnhancedAddSceneResponseCallback::~CHIPScenesManagementClusterEnhancedAddSceneResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPScenesManagementClusterEnhancedAddSceneResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ScenesManagement::Commands::EnhancedAddSceneResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPScenesManagementClusterEnhancedAddSceneResponseCallback, |
| void (*)(CHIPScenesManagementClusterEnhancedAddSceneResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPScenesManagementClusterEnhancedAddSceneResponseCallback *>(context), |
| chip::Platform::Delete<CHIPScenesManagementClusterEnhancedAddSceneResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| jobject SceneID; |
| std::string SceneIDClassName = "java/lang/Integer"; |
| std::string SceneIDCtorSignature = "(I)V"; |
| jint jniSceneID = static_cast<jint>(dataResponse.sceneID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, |
| SceneID); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID); |
| } |
| CHIPScenesManagementClusterEnhancedViewSceneResponseCallback::CHIPScenesManagementClusterEnhancedViewSceneResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPScenesManagementClusterEnhancedViewSceneResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPScenesManagementClusterEnhancedViewSceneResponseCallback::~CHIPScenesManagementClusterEnhancedViewSceneResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPScenesManagementClusterEnhancedViewSceneResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ScenesManagement::Commands::EnhancedViewSceneResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPScenesManagementClusterEnhancedViewSceneResponseCallback, |
| void (*)(CHIPScenesManagementClusterEnhancedViewSceneResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPScenesManagementClusterEnhancedViewSceneResponseCallback *>(context), |
| chip::Platform::Delete<CHIPScenesManagementClusterEnhancedViewSceneResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupID; |
| std::string GroupIDClassName = "java/lang/Integer"; |
| std::string GroupIDCtorSignature = "(I)V"; |
| jint jniGroupID = static_cast<jint>(dataResponse.groupID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), jniGroupID, |
| GroupID); |
| jobject SceneID; |
| std::string SceneIDClassName = "java/lang/Integer"; |
| std::string SceneIDCtorSignature = "(I)V"; |
| jint jniSceneID = static_cast<jint>(dataResponse.sceneID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(SceneIDClassName.c_str(), SceneIDCtorSignature.c_str(), jniSceneID, |
| SceneID); |
| jobject TransitionTime; |
| if (!dataResponse.transitionTime.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, TransitionTime); |
| } |
| else |
| { |
| jobject TransitionTimeInsideOptional; |
| std::string TransitionTimeInsideOptionalClassName = "java/lang/Integer"; |
| std::string TransitionTimeInsideOptionalCtorSignature = "(I)V"; |
| jint jniTransitionTimeInsideOptional = static_cast<jint>(dataResponse.transitionTime.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(TransitionTimeInsideOptionalClassName.c_str(), |
| TransitionTimeInsideOptionalCtorSignature.c_str(), |
| jniTransitionTimeInsideOptional, TransitionTimeInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(TransitionTimeInsideOptional, TransitionTime); |
| } |
| jobject SceneName; |
| if (!dataResponse.sceneName.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, SceneName); |
| } |
| else |
| { |
| jobject SceneNameInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.sceneName.Value(), SceneNameInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(SceneNameInsideOptional, SceneName); |
| } |
| jobject ExtensionFieldSets; |
| if (!dataResponse.extensionFieldSets.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, ExtensionFieldSets); |
| } |
| else |
| { |
| jobject ExtensionFieldSetsInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(ExtensionFieldSetsInsideOptional); |
| |
| auto iter_ExtensionFieldSetsInsideOptional_1 = dataResponse.extensionFieldSets.Value().begin(); |
| while (iter_ExtensionFieldSetsInsideOptional_1.Next()) |
| { |
| auto & entry_1 = iter_ExtensionFieldSetsInsideOptional_1.GetValue(); |
| jobject newElement_1; |
| jobject newElement_1_clusterID; |
| std::string newElement_1_clusterIDClassName = "java/lang/Long"; |
| std::string newElement_1_clusterIDCtorSignature = "(J)V"; |
| jlong jninewElement_1_clusterID = static_cast<jlong>(entry_1.clusterID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(newElement_1_clusterIDClassName.c_str(), |
| newElement_1_clusterIDCtorSignature.c_str(), |
| jninewElement_1_clusterID, newElement_1_clusterID); |
| jobject newElement_1_attributeValueList; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_1_attributeValueList); |
| |
| auto iter_newElement_1_attributeValueList_3 = entry_1.attributeValueList.begin(); |
| while (iter_newElement_1_attributeValueList_3.Next()) |
| { |
| auto & entry_3 = iter_newElement_1_attributeValueList_3.GetValue(); |
| jobject newElement_3; |
| jobject newElement_3_attributeID; |
| std::string newElement_3_attributeIDClassName = "java/lang/Long"; |
| std::string newElement_3_attributeIDCtorSignature = "(J)V"; |
| jlong jninewElement_3_attributeID = static_cast<jlong>(entry_3.attributeID); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(newElement_3_attributeIDClassName.c_str(), |
| newElement_3_attributeIDCtorSignature.c_str(), |
| jninewElement_3_attributeID, newElement_3_attributeID); |
| jobject newElement_3_attributeValue; |
| std::string newElement_3_attributeValueClassName = "java/lang/Long"; |
| std::string newElement_3_attributeValueCtorSignature = "(J)V"; |
| jlong jninewElement_3_attributeValue = static_cast<jlong>(entry_3.attributeValue); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>( |
| newElement_3_attributeValueClassName.c_str(), newElement_3_attributeValueCtorSignature.c_str(), |
| jninewElement_3_attributeValue, newElement_3_attributeValue); |
| |
| jclass attributeValuePairStructClass_4; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ScenesManagementClusterAttributeValuePair", |
| attributeValuePairStructClass_4); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ScenesManagementClusterAttributeValuePair"); |
| return; |
| } |
| |
| jmethodID attributeValuePairStructCtor_4; |
| err = chip::JniReferences::GetInstance().FindMethod(env, attributeValuePairStructClass_4, "<init>", |
| "(Ljava/lang/Long;Ljava/lang/Long;)V", |
| &attributeValuePairStructCtor_4); |
| if (err != CHIP_NO_ERROR || attributeValuePairStructCtor_4 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ScenesManagementClusterAttributeValuePair constructor"); |
| return; |
| } |
| |
| newElement_3 = env->NewObject(attributeValuePairStructClass_4, attributeValuePairStructCtor_4, |
| newElement_3_attributeID, newElement_3_attributeValue); |
| chip::JniReferences::GetInstance().AddToList(newElement_1_attributeValueList, newElement_3); |
| } |
| |
| jclass extensionFieldSetStructClass_2; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ScenesManagementClusterExtensionFieldSet", extensionFieldSetStructClass_2); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ScenesManagementClusterExtensionFieldSet"); |
| return; |
| } |
| |
| jmethodID extensionFieldSetStructCtor_2; |
| err = chip::JniReferences::GetInstance().FindMethod(env, extensionFieldSetStructClass_2, "<init>", |
| "(Ljava/lang/Long;Ljava/util/ArrayList;)V", |
| &extensionFieldSetStructCtor_2); |
| if (err != CHIP_NO_ERROR || extensionFieldSetStructCtor_2 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ScenesManagementClusterExtensionFieldSet constructor"); |
| return; |
| } |
| |
| newElement_1 = env->NewObject(extensionFieldSetStructClass_2, extensionFieldSetStructCtor_2, newElement_1_clusterID, |
| newElement_1_attributeValueList); |
| chip::JniReferences::GetInstance().AddToList(ExtensionFieldSetsInsideOptional, newElement_1); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(ExtensionFieldSetsInsideOptional, ExtensionFieldSets); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, SceneID, TransitionTime, SceneName, ExtensionFieldSets); |
| } |
| CHIPScenesManagementClusterCopySceneResponseCallback::CHIPScenesManagementClusterCopySceneResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPScenesManagementClusterCopySceneResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPScenesManagementClusterCopySceneResponseCallback::~CHIPScenesManagementClusterCopySceneResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPScenesManagementClusterCopySceneResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ScenesManagement::Commands::CopySceneResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPScenesManagementClusterCopySceneResponseCallback, |
| void (*)(CHIPScenesManagementClusterCopySceneResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPScenesManagementClusterCopySceneResponseCallback *>(context), |
| chip::Platform::Delete<CHIPScenesManagementClusterCopySceneResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject GroupIdentifierFrom; |
| std::string GroupIdentifierFromClassName = "java/lang/Integer"; |
| std::string GroupIdentifierFromCtorSignature = "(I)V"; |
| jint jniGroupIdentifierFrom = static_cast<jint>(dataResponse.groupIdentifierFrom); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(GroupIdentifierFromClassName.c_str(), |
| GroupIdentifierFromCtorSignature.c_str(), jniGroupIdentifierFrom, |
| GroupIdentifierFrom); |
| jobject SceneIdentifierFrom; |
| std::string SceneIdentifierFromClassName = "java/lang/Integer"; |
| std::string SceneIdentifierFromCtorSignature = "(I)V"; |
| jint jniSceneIdentifierFrom = static_cast<jint>(dataResponse.sceneIdentifierFrom); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(SceneIdentifierFromClassName.c_str(), |
| SceneIdentifierFromCtorSignature.c_str(), jniSceneIdentifierFrom, |
| SceneIdentifierFrom); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupIdentifierFrom, SceneIdentifierFrom); |
| } |
| CHIPEnergyEvseClusterGetTargetsResponseCallback::CHIPEnergyEvseClusterGetTargetsResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPEnergyEvseClusterGetTargetsResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPEnergyEvseClusterGetTargetsResponseCallback::~CHIPEnergyEvseClusterGetTargetsResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPEnergyEvseClusterGetTargetsResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::EnergyEvse::Commands::GetTargetsResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPEnergyEvseClusterGetTargetsResponseCallback, void (*)(CHIPEnergyEvseClusterGetTargetsResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPEnergyEvseClusterGetTargetsResponseCallback *>(context), |
| chip::Platform::Delete<CHIPEnergyEvseClusterGetTargetsResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/ArrayList;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject ChargingTargetSchedules; |
| chip::JniReferences::GetInstance().CreateArrayList(ChargingTargetSchedules); |
| |
| auto iter_ChargingTargetSchedules_0 = dataResponse.chargingTargetSchedules.begin(); |
| while (iter_ChargingTargetSchedules_0.Next()) |
| { |
| auto & entry_0 = iter_ChargingTargetSchedules_0.GetValue(); |
| jobject newElement_0; |
| jobject newElement_0_dayOfWeekForSequence; |
| std::string newElement_0_dayOfWeekForSequenceClassName = "java/lang/Integer"; |
| std::string newElement_0_dayOfWeekForSequenceCtorSignature = "(I)V"; |
| jint jninewElement_0_dayOfWeekForSequence = static_cast<jint>(entry_0.dayOfWeekForSequence.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_0_dayOfWeekForSequenceClassName.c_str(), newElement_0_dayOfWeekForSequenceCtorSignature.c_str(), |
| jninewElement_0_dayOfWeekForSequence, newElement_0_dayOfWeekForSequence); |
| jobject newElement_0_chargingTargets; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_0_chargingTargets); |
| |
| auto iter_newElement_0_chargingTargets_2 = entry_0.chargingTargets.begin(); |
| while (iter_newElement_0_chargingTargets_2.Next()) |
| { |
| auto & entry_2 = iter_newElement_0_chargingTargets_2.GetValue(); |
| jobject newElement_2; |
| jobject newElement_2_targetTimeMinutesPastMidnight; |
| std::string newElement_2_targetTimeMinutesPastMidnightClassName = "java/lang/Integer"; |
| std::string newElement_2_targetTimeMinutesPastMidnightCtorSignature = "(I)V"; |
| jint jninewElement_2_targetTimeMinutesPastMidnight = static_cast<jint>(entry_2.targetTimeMinutesPastMidnight); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_2_targetTimeMinutesPastMidnightClassName.c_str(), |
| newElement_2_targetTimeMinutesPastMidnightCtorSignature.c_str(), jninewElement_2_targetTimeMinutesPastMidnight, |
| newElement_2_targetTimeMinutesPastMidnight); |
| jobject newElement_2_targetSoC; |
| if (!entry_2.targetSoC.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_targetSoC); |
| } |
| else |
| { |
| jobject newElement_2_targetSoCInsideOptional; |
| std::string newElement_2_targetSoCInsideOptionalClassName = "java/lang/Integer"; |
| std::string newElement_2_targetSoCInsideOptionalCtorSignature = "(I)V"; |
| jint jninewElement_2_targetSoCInsideOptional = static_cast<jint>(entry_2.targetSoC.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_2_targetSoCInsideOptionalClassName.c_str(), |
| newElement_2_targetSoCInsideOptionalCtorSignature.c_str(), jninewElement_2_targetSoCInsideOptional, |
| newElement_2_targetSoCInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_2_targetSoCInsideOptional, newElement_2_targetSoC); |
| } |
| jobject newElement_2_addedEnergy; |
| if (!entry_2.addedEnergy.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_addedEnergy); |
| } |
| else |
| { |
| jobject newElement_2_addedEnergyInsideOptional; |
| std::string newElement_2_addedEnergyInsideOptionalClassName = "java/lang/Long"; |
| std::string newElement_2_addedEnergyInsideOptionalCtorSignature = "(J)V"; |
| jlong jninewElement_2_addedEnergyInsideOptional = static_cast<jlong>(entry_2.addedEnergy.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>( |
| newElement_2_addedEnergyInsideOptionalClassName.c_str(), |
| newElement_2_addedEnergyInsideOptionalCtorSignature.c_str(), jninewElement_2_addedEnergyInsideOptional, |
| newElement_2_addedEnergyInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_2_addedEnergyInsideOptional, newElement_2_addedEnergy); |
| } |
| |
| jclass chargingTargetStructStructClass_3; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$EnergyEvseClusterChargingTargetStruct", chargingTargetStructStructClass_3); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$EnergyEvseClusterChargingTargetStruct"); |
| return; |
| } |
| |
| jmethodID chargingTargetStructStructCtor_3; |
| err = chip::JniReferences::GetInstance().FindMethod(env, chargingTargetStructStructClass_3, "<init>", |
| "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &chargingTargetStructStructCtor_3); |
| if (err != CHIP_NO_ERROR || chargingTargetStructStructCtor_3 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$EnergyEvseClusterChargingTargetStruct constructor"); |
| return; |
| } |
| |
| newElement_2 = |
| env->NewObject(chargingTargetStructStructClass_3, chargingTargetStructStructCtor_3, |
| newElement_2_targetTimeMinutesPastMidnight, newElement_2_targetSoC, newElement_2_addedEnergy); |
| chip::JniReferences::GetInstance().AddToList(newElement_0_chargingTargets, newElement_2); |
| } |
| |
| jclass chargingTargetScheduleStructStructClass_1; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$EnergyEvseClusterChargingTargetScheduleStruct", |
| chargingTargetScheduleStructStructClass_1); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$EnergyEvseClusterChargingTargetScheduleStruct"); |
| return; |
| } |
| |
| jmethodID chargingTargetScheduleStructStructCtor_1; |
| err = chip::JniReferences::GetInstance().FindMethod(env, chargingTargetScheduleStructStructClass_1, "<init>", |
| "(Ljava/lang/Integer;Ljava/util/ArrayList;)V", |
| &chargingTargetScheduleStructStructCtor_1); |
| if (err != CHIP_NO_ERROR || chargingTargetScheduleStructStructCtor_1 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$EnergyEvseClusterChargingTargetScheduleStruct constructor"); |
| return; |
| } |
| |
| newElement_0 = env->NewObject(chargingTargetScheduleStructStructClass_1, chargingTargetScheduleStructStructCtor_1, |
| newElement_0_dayOfWeekForSequence, newElement_0_chargingTargets); |
| chip::JniReferences::GetInstance().AddToList(ChargingTargetSchedules, newElement_0); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, ChargingTargetSchedules); |
| } |
| CHIPDoorLockClusterGetWeekDayScheduleResponseCallback::CHIPDoorLockClusterGetWeekDayScheduleResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPDoorLockClusterGetWeekDayScheduleResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPDoorLockClusterGetWeekDayScheduleResponseCallback::~CHIPDoorLockClusterGetWeekDayScheduleResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPDoorLockClusterGetWeekDayScheduleResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::DoorLock::Commands::GetWeekDayScheduleResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPDoorLockClusterGetWeekDayScheduleResponseCallback, |
| void (*)(CHIPDoorLockClusterGetWeekDayScheduleResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPDoorLockClusterGetWeekDayScheduleResponseCallback *>(context), |
| chip::Platform::Delete<CHIPDoorLockClusterGetWeekDayScheduleResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" |
| "Optional;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject WeekDayIndex; |
| std::string WeekDayIndexClassName = "java/lang/Integer"; |
| std::string WeekDayIndexCtorSignature = "(I)V"; |
| jint jniWeekDayIndex = static_cast<jint>(dataResponse.weekDayIndex); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(WeekDayIndexClassName.c_str(), WeekDayIndexCtorSignature.c_str(), |
| jniWeekDayIndex, WeekDayIndex); |
| jobject UserIndex; |
| std::string UserIndexClassName = "java/lang/Integer"; |
| std::string UserIndexCtorSignature = "(I)V"; |
| jint jniUserIndex = static_cast<jint>(dataResponse.userIndex); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), |
| jniUserIndex, UserIndex); |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject DaysMask; |
| if (!dataResponse.daysMask.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, DaysMask); |
| } |
| else |
| { |
| jobject DaysMaskInsideOptional; |
| std::string DaysMaskInsideOptionalClassName = "java/lang/Integer"; |
| std::string DaysMaskInsideOptionalCtorSignature = "(I)V"; |
| jint jniDaysMaskInsideOptional = static_cast<jint>(dataResponse.daysMask.Value().Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(DaysMaskInsideOptionalClassName.c_str(), |
| DaysMaskInsideOptionalCtorSignature.c_str(), |
| jniDaysMaskInsideOptional, DaysMaskInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(DaysMaskInsideOptional, DaysMask); |
| } |
| jobject StartHour; |
| if (!dataResponse.startHour.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, StartHour); |
| } |
| else |
| { |
| jobject StartHourInsideOptional; |
| std::string StartHourInsideOptionalClassName = "java/lang/Integer"; |
| std::string StartHourInsideOptionalCtorSignature = "(I)V"; |
| jint jniStartHourInsideOptional = static_cast<jint>(dataResponse.startHour.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StartHourInsideOptionalClassName.c_str(), |
| StartHourInsideOptionalCtorSignature.c_str(), |
| jniStartHourInsideOptional, StartHourInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(StartHourInsideOptional, StartHour); |
| } |
| jobject StartMinute; |
| if (!dataResponse.startMinute.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, StartMinute); |
| } |
| else |
| { |
| jobject StartMinuteInsideOptional; |
| std::string StartMinuteInsideOptionalClassName = "java/lang/Integer"; |
| std::string StartMinuteInsideOptionalCtorSignature = "(I)V"; |
| jint jniStartMinuteInsideOptional = static_cast<jint>(dataResponse.startMinute.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StartMinuteInsideOptionalClassName.c_str(), |
| StartMinuteInsideOptionalCtorSignature.c_str(), |
| jniStartMinuteInsideOptional, StartMinuteInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(StartMinuteInsideOptional, StartMinute); |
| } |
| jobject EndHour; |
| if (!dataResponse.endHour.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, EndHour); |
| } |
| else |
| { |
| jobject EndHourInsideOptional; |
| std::string EndHourInsideOptionalClassName = "java/lang/Integer"; |
| std::string EndHourInsideOptionalCtorSignature = "(I)V"; |
| jint jniEndHourInsideOptional = static_cast<jint>(dataResponse.endHour.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(EndHourInsideOptionalClassName.c_str(), |
| EndHourInsideOptionalCtorSignature.c_str(), |
| jniEndHourInsideOptional, EndHourInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(EndHourInsideOptional, EndHour); |
| } |
| jobject EndMinute; |
| if (!dataResponse.endMinute.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, EndMinute); |
| } |
| else |
| { |
| jobject EndMinuteInsideOptional; |
| std::string EndMinuteInsideOptionalClassName = "java/lang/Integer"; |
| std::string EndMinuteInsideOptionalCtorSignature = "(I)V"; |
| jint jniEndMinuteInsideOptional = static_cast<jint>(dataResponse.endMinute.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(EndMinuteInsideOptionalClassName.c_str(), |
| EndMinuteInsideOptionalCtorSignature.c_str(), |
| jniEndMinuteInsideOptional, EndMinuteInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(EndMinuteInsideOptional, EndMinute); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, WeekDayIndex, UserIndex, Status, DaysMask, StartHour, StartMinute, EndHour, |
| EndMinute); |
| } |
| CHIPDoorLockClusterGetYearDayScheduleResponseCallback::CHIPDoorLockClusterGetYearDayScheduleResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPDoorLockClusterGetYearDayScheduleResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPDoorLockClusterGetYearDayScheduleResponseCallback::~CHIPDoorLockClusterGetYearDayScheduleResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPDoorLockClusterGetYearDayScheduleResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::DoorLock::Commands::GetYearDayScheduleResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPDoorLockClusterGetYearDayScheduleResponseCallback, |
| void (*)(CHIPDoorLockClusterGetYearDayScheduleResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPDoorLockClusterGetYearDayScheduleResponseCallback *>(context), |
| chip::Platform::Delete<CHIPDoorLockClusterGetYearDayScheduleResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject YearDayIndex; |
| std::string YearDayIndexClassName = "java/lang/Integer"; |
| std::string YearDayIndexCtorSignature = "(I)V"; |
| jint jniYearDayIndex = static_cast<jint>(dataResponse.yearDayIndex); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(YearDayIndexClassName.c_str(), YearDayIndexCtorSignature.c_str(), |
| jniYearDayIndex, YearDayIndex); |
| jobject UserIndex; |
| std::string UserIndexClassName = "java/lang/Integer"; |
| std::string UserIndexCtorSignature = "(I)V"; |
| jint jniUserIndex = static_cast<jint>(dataResponse.userIndex); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), |
| jniUserIndex, UserIndex); |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject LocalStartTime; |
| if (!dataResponse.localStartTime.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalStartTime); |
| } |
| else |
| { |
| jobject LocalStartTimeInsideOptional; |
| std::string LocalStartTimeInsideOptionalClassName = "java/lang/Long"; |
| std::string LocalStartTimeInsideOptionalCtorSignature = "(J)V"; |
| jlong jniLocalStartTimeInsideOptional = static_cast<jlong>(dataResponse.localStartTime.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(LocalStartTimeInsideOptionalClassName.c_str(), |
| LocalStartTimeInsideOptionalCtorSignature.c_str(), |
| jniLocalStartTimeInsideOptional, LocalStartTimeInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(LocalStartTimeInsideOptional, LocalStartTime); |
| } |
| jobject LocalEndTime; |
| if (!dataResponse.localEndTime.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalEndTime); |
| } |
| else |
| { |
| jobject LocalEndTimeInsideOptional; |
| std::string LocalEndTimeInsideOptionalClassName = "java/lang/Long"; |
| std::string LocalEndTimeInsideOptionalCtorSignature = "(J)V"; |
| jlong jniLocalEndTimeInsideOptional = static_cast<jlong>(dataResponse.localEndTime.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(LocalEndTimeInsideOptionalClassName.c_str(), |
| LocalEndTimeInsideOptionalCtorSignature.c_str(), |
| jniLocalEndTimeInsideOptional, LocalEndTimeInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(LocalEndTimeInsideOptional, LocalEndTime); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, YearDayIndex, UserIndex, Status, LocalStartTime, LocalEndTime); |
| } |
| CHIPDoorLockClusterGetHolidayScheduleResponseCallback::CHIPDoorLockClusterGetHolidayScheduleResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPDoorLockClusterGetHolidayScheduleResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPDoorLockClusterGetHolidayScheduleResponseCallback::~CHIPDoorLockClusterGetHolidayScheduleResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPDoorLockClusterGetHolidayScheduleResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::DoorLock::Commands::GetHolidayScheduleResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPDoorLockClusterGetHolidayScheduleResponseCallback, |
| void (*)(CHIPDoorLockClusterGetHolidayScheduleResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPDoorLockClusterGetHolidayScheduleResponseCallback *>(context), |
| chip::Platform::Delete<CHIPDoorLockClusterGetHolidayScheduleResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject HolidayIndex; |
| std::string HolidayIndexClassName = "java/lang/Integer"; |
| std::string HolidayIndexCtorSignature = "(I)V"; |
| jint jniHolidayIndex = static_cast<jint>(dataResponse.holidayIndex); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(HolidayIndexClassName.c_str(), HolidayIndexCtorSignature.c_str(), |
| jniHolidayIndex, HolidayIndex); |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject LocalStartTime; |
| if (!dataResponse.localStartTime.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalStartTime); |
| } |
| else |
| { |
| jobject LocalStartTimeInsideOptional; |
| std::string LocalStartTimeInsideOptionalClassName = "java/lang/Long"; |
| std::string LocalStartTimeInsideOptionalCtorSignature = "(J)V"; |
| jlong jniLocalStartTimeInsideOptional = static_cast<jlong>(dataResponse.localStartTime.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(LocalStartTimeInsideOptionalClassName.c_str(), |
| LocalStartTimeInsideOptionalCtorSignature.c_str(), |
| jniLocalStartTimeInsideOptional, LocalStartTimeInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(LocalStartTimeInsideOptional, LocalStartTime); |
| } |
| jobject LocalEndTime; |
| if (!dataResponse.localEndTime.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, LocalEndTime); |
| } |
| else |
| { |
| jobject LocalEndTimeInsideOptional; |
| std::string LocalEndTimeInsideOptionalClassName = "java/lang/Long"; |
| std::string LocalEndTimeInsideOptionalCtorSignature = "(J)V"; |
| jlong jniLocalEndTimeInsideOptional = static_cast<jlong>(dataResponse.localEndTime.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(LocalEndTimeInsideOptionalClassName.c_str(), |
| LocalEndTimeInsideOptionalCtorSignature.c_str(), |
| jniLocalEndTimeInsideOptional, LocalEndTimeInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(LocalEndTimeInsideOptional, LocalEndTime); |
| } |
| jobject OperatingMode; |
| if (!dataResponse.operatingMode.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, OperatingMode); |
| } |
| else |
| { |
| jobject OperatingModeInsideOptional; |
| std::string OperatingModeInsideOptionalClassName = "java/lang/Integer"; |
| std::string OperatingModeInsideOptionalCtorSignature = "(I)V"; |
| jint jniOperatingModeInsideOptional = static_cast<jint>(dataResponse.operatingMode.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(OperatingModeInsideOptionalClassName.c_str(), |
| OperatingModeInsideOptionalCtorSignature.c_str(), |
| jniOperatingModeInsideOptional, OperatingModeInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(OperatingModeInsideOptional, OperatingMode); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, HolidayIndex, Status, LocalStartTime, LocalEndTime, OperatingMode); |
| } |
| CHIPDoorLockClusterGetUserResponseCallback::CHIPDoorLockClusterGetUserResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPDoorLockClusterGetUserResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPDoorLockClusterGetUserResponseCallback::~CHIPDoorLockClusterGetUserResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPDoorLockClusterGetUserResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::DoorLock::Commands::GetUserResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPDoorLockClusterGetUserResponseCallback, void (*)(CHIPDoorLockClusterGetUserResponseCallback *)> cppCallback( |
| reinterpret_cast<CHIPDoorLockClusterGetUserResponseCallback *>(context), |
| chip::Platform::Delete<CHIPDoorLockClusterGetUserResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/" |
| "ArrayList;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject UserIndex; |
| std::string UserIndexClassName = "java/lang/Integer"; |
| std::string UserIndexCtorSignature = "(I)V"; |
| jint jniUserIndex = static_cast<jint>(dataResponse.userIndex); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), |
| jniUserIndex, UserIndex); |
| jobject UserName; |
| if (dataResponse.userName.IsNull()) |
| { |
| UserName = nullptr; |
| } |
| else |
| { |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.userName.Value(), UserName)); |
| } |
| jobject UserUniqueID; |
| if (dataResponse.userUniqueID.IsNull()) |
| { |
| UserUniqueID = nullptr; |
| } |
| else |
| { |
| std::string UserUniqueIDClassName = "java/lang/Long"; |
| std::string UserUniqueIDCtorSignature = "(J)V"; |
| jlong jniUserUniqueID = static_cast<jlong>(dataResponse.userUniqueID.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>( |
| UserUniqueIDClassName.c_str(), UserUniqueIDCtorSignature.c_str(), jniUserUniqueID, UserUniqueID); |
| } |
| jobject UserStatus; |
| if (dataResponse.userStatus.IsNull()) |
| { |
| UserStatus = nullptr; |
| } |
| else |
| { |
| std::string UserStatusClassName = "java/lang/Integer"; |
| std::string UserStatusCtorSignature = "(I)V"; |
| jint jniUserStatus = static_cast<jint>(dataResponse.userStatus.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(UserStatusClassName.c_str(), UserStatusCtorSignature.c_str(), |
| jniUserStatus, UserStatus); |
| } |
| jobject UserType; |
| if (dataResponse.userType.IsNull()) |
| { |
| UserType = nullptr; |
| } |
| else |
| { |
| std::string UserTypeClassName = "java/lang/Integer"; |
| std::string UserTypeCtorSignature = "(I)V"; |
| jint jniUserType = static_cast<jint>(dataResponse.userType.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(UserTypeClassName.c_str(), UserTypeCtorSignature.c_str(), |
| jniUserType, UserType); |
| } |
| jobject CredentialRule; |
| if (dataResponse.credentialRule.IsNull()) |
| { |
| CredentialRule = nullptr; |
| } |
| else |
| { |
| std::string CredentialRuleClassName = "java/lang/Integer"; |
| std::string CredentialRuleCtorSignature = "(I)V"; |
| jint jniCredentialRule = static_cast<jint>(dataResponse.credentialRule.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| CredentialRuleClassName.c_str(), CredentialRuleCtorSignature.c_str(), jniCredentialRule, CredentialRule); |
| } |
| jobject Credentials; |
| if (dataResponse.credentials.IsNull()) |
| { |
| Credentials = nullptr; |
| } |
| else |
| { |
| chip::JniReferences::GetInstance().CreateArrayList(Credentials); |
| |
| auto iter_Credentials_1 = dataResponse.credentials.Value().begin(); |
| while (iter_Credentials_1.Next()) |
| { |
| auto & entry_1 = iter_Credentials_1.GetValue(); |
| jobject newElement_1; |
| jobject newElement_1_credentialType; |
| std::string newElement_1_credentialTypeClassName = "java/lang/Integer"; |
| std::string newElement_1_credentialTypeCtorSignature = "(I)V"; |
| jint jninewElement_1_credentialType = static_cast<jint>(entry_1.credentialType); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_1_credentialTypeClassName.c_str(), |
| newElement_1_credentialTypeCtorSignature.c_str(), |
| jninewElement_1_credentialType, newElement_1_credentialType); |
| jobject newElement_1_credentialIndex; |
| std::string newElement_1_credentialIndexClassName = "java/lang/Integer"; |
| std::string newElement_1_credentialIndexCtorSignature = "(I)V"; |
| jint jninewElement_1_credentialIndex = static_cast<jint>(entry_1.credentialIndex); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_1_credentialIndexClassName.c_str(), newElement_1_credentialIndexCtorSignature.c_str(), |
| jninewElement_1_credentialIndex, newElement_1_credentialIndex); |
| |
| jclass credentialStructStructClass_2; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$DoorLockClusterCredentialStruct", credentialStructStructClass_2); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$DoorLockClusterCredentialStruct"); |
| return; |
| } |
| |
| jmethodID credentialStructStructCtor_2; |
| err = chip::JniReferences::GetInstance().FindMethod(env, credentialStructStructClass_2, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;)V", |
| &credentialStructStructCtor_2); |
| if (err != CHIP_NO_ERROR || credentialStructStructCtor_2 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$DoorLockClusterCredentialStruct constructor"); |
| return; |
| } |
| |
| newElement_1 = env->NewObject(credentialStructStructClass_2, credentialStructStructCtor_2, newElement_1_credentialType, |
| newElement_1_credentialIndex); |
| chip::JniReferences::GetInstance().AddToList(Credentials, newElement_1); |
| } |
| } |
| jobject CreatorFabricIndex; |
| if (dataResponse.creatorFabricIndex.IsNull()) |
| { |
| CreatorFabricIndex = nullptr; |
| } |
| else |
| { |
| std::string CreatorFabricIndexClassName = "java/lang/Integer"; |
| std::string CreatorFabricIndexCtorSignature = "(I)V"; |
| jint jniCreatorFabricIndex = static_cast<jint>(dataResponse.creatorFabricIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(CreatorFabricIndexClassName.c_str(), |
| CreatorFabricIndexCtorSignature.c_str(), jniCreatorFabricIndex, |
| CreatorFabricIndex); |
| } |
| jobject LastModifiedFabricIndex; |
| if (dataResponse.lastModifiedFabricIndex.IsNull()) |
| { |
| LastModifiedFabricIndex = nullptr; |
| } |
| else |
| { |
| std::string LastModifiedFabricIndexClassName = "java/lang/Integer"; |
| std::string LastModifiedFabricIndexCtorSignature = "(I)V"; |
| jint jniLastModifiedFabricIndex = static_cast<jint>(dataResponse.lastModifiedFabricIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(LastModifiedFabricIndexClassName.c_str(), |
| LastModifiedFabricIndexCtorSignature.c_str(), |
| jniLastModifiedFabricIndex, LastModifiedFabricIndex); |
| } |
| jobject NextUserIndex; |
| if (dataResponse.nextUserIndex.IsNull()) |
| { |
| NextUserIndex = nullptr; |
| } |
| else |
| { |
| std::string NextUserIndexClassName = "java/lang/Integer"; |
| std::string NextUserIndexCtorSignature = "(I)V"; |
| jint jniNextUserIndex = static_cast<jint>(dataResponse.nextUserIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| NextUserIndexClassName.c_str(), NextUserIndexCtorSignature.c_str(), jniNextUserIndex, NextUserIndex); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, UserIndex, UserName, UserUniqueID, UserStatus, UserType, CredentialRule, |
| Credentials, CreatorFabricIndex, LastModifiedFabricIndex, NextUserIndex); |
| } |
| CHIPDoorLockClusterSetCredentialResponseCallback::CHIPDoorLockClusterSetCredentialResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPDoorLockClusterSetCredentialResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPDoorLockClusterSetCredentialResponseCallback::~CHIPDoorLockClusterSetCredentialResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPDoorLockClusterSetCredentialResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::DoorLock::Commands::SetCredentialResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPDoorLockClusterSetCredentialResponseCallback, void (*)(CHIPDoorLockClusterSetCredentialResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPDoorLockClusterSetCredentialResponseCallback *>(context), |
| chip::Platform::Delete<CHIPDoorLockClusterSetCredentialResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject UserIndex; |
| if (dataResponse.userIndex.IsNull()) |
| { |
| UserIndex = nullptr; |
| } |
| else |
| { |
| std::string UserIndexClassName = "java/lang/Integer"; |
| std::string UserIndexCtorSignature = "(I)V"; |
| jint jniUserIndex = static_cast<jint>(dataResponse.userIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), |
| jniUserIndex, UserIndex); |
| } |
| jobject NextCredentialIndex; |
| if (dataResponse.nextCredentialIndex.IsNull()) |
| { |
| NextCredentialIndex = nullptr; |
| } |
| else |
| { |
| std::string NextCredentialIndexClassName = "java/lang/Integer"; |
| std::string NextCredentialIndexCtorSignature = "(I)V"; |
| jint jniNextCredentialIndex = static_cast<jint>(dataResponse.nextCredentialIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(NextCredentialIndexClassName.c_str(), |
| NextCredentialIndexCtorSignature.c_str(), jniNextCredentialIndex, |
| NextCredentialIndex); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, UserIndex, NextCredentialIndex); |
| } |
| CHIPDoorLockClusterGetCredentialStatusResponseCallback::CHIPDoorLockClusterGetCredentialStatusResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPDoorLockClusterGetCredentialStatusResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPDoorLockClusterGetCredentialStatusResponseCallback::~CHIPDoorLockClusterGetCredentialStatusResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPDoorLockClusterGetCredentialStatusResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::DoorLock::Commands::GetCredentialStatusResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPDoorLockClusterGetCredentialStatusResponseCallback, |
| void (*)(CHIPDoorLockClusterGetCredentialStatusResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPDoorLockClusterGetCredentialStatusResponseCallback *>(context), |
| chip::Platform::Delete<CHIPDoorLockClusterGetCredentialStatusResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Boolean;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject CredentialExists; |
| std::string CredentialExistsClassName = "java/lang/Boolean"; |
| std::string CredentialExistsCtorSignature = "(Z)V"; |
| jboolean jniCredentialExists = static_cast<jboolean>(dataResponse.credentialExists); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| CredentialExistsClassName.c_str(), CredentialExistsCtorSignature.c_str(), jniCredentialExists, CredentialExists); |
| jobject UserIndex; |
| if (dataResponse.userIndex.IsNull()) |
| { |
| UserIndex = nullptr; |
| } |
| else |
| { |
| std::string UserIndexClassName = "java/lang/Integer"; |
| std::string UserIndexCtorSignature = "(I)V"; |
| jint jniUserIndex = static_cast<jint>(dataResponse.userIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(UserIndexClassName.c_str(), UserIndexCtorSignature.c_str(), |
| jniUserIndex, UserIndex); |
| } |
| jobject CreatorFabricIndex; |
| if (dataResponse.creatorFabricIndex.IsNull()) |
| { |
| CreatorFabricIndex = nullptr; |
| } |
| else |
| { |
| std::string CreatorFabricIndexClassName = "java/lang/Integer"; |
| std::string CreatorFabricIndexCtorSignature = "(I)V"; |
| jint jniCreatorFabricIndex = static_cast<jint>(dataResponse.creatorFabricIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(CreatorFabricIndexClassName.c_str(), |
| CreatorFabricIndexCtorSignature.c_str(), jniCreatorFabricIndex, |
| CreatorFabricIndex); |
| } |
| jobject LastModifiedFabricIndex; |
| if (dataResponse.lastModifiedFabricIndex.IsNull()) |
| { |
| LastModifiedFabricIndex = nullptr; |
| } |
| else |
| { |
| std::string LastModifiedFabricIndexClassName = "java/lang/Integer"; |
| std::string LastModifiedFabricIndexCtorSignature = "(I)V"; |
| jint jniLastModifiedFabricIndex = static_cast<jint>(dataResponse.lastModifiedFabricIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(LastModifiedFabricIndexClassName.c_str(), |
| LastModifiedFabricIndexCtorSignature.c_str(), |
| jniLastModifiedFabricIndex, LastModifiedFabricIndex); |
| } |
| jobject NextCredentialIndex; |
| if (dataResponse.nextCredentialIndex.IsNull()) |
| { |
| NextCredentialIndex = nullptr; |
| } |
| else |
| { |
| std::string NextCredentialIndexClassName = "java/lang/Integer"; |
| std::string NextCredentialIndexCtorSignature = "(I)V"; |
| jint jniNextCredentialIndex = static_cast<jint>(dataResponse.nextCredentialIndex.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(NextCredentialIndexClassName.c_str(), |
| NextCredentialIndexCtorSignature.c_str(), jniNextCredentialIndex, |
| NextCredentialIndex); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, CredentialExists, UserIndex, CreatorFabricIndex, LastModifiedFabricIndex, |
| NextCredentialIndex); |
| } |
| CHIPThermostatClusterGetWeeklyScheduleResponseCallback::CHIPThermostatClusterGetWeeklyScheduleResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPThermostatClusterGetWeeklyScheduleResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPThermostatClusterGetWeeklyScheduleResponseCallback::~CHIPThermostatClusterGetWeeklyScheduleResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPThermostatClusterGetWeeklyScheduleResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::Thermostat::Commands::GetWeeklyScheduleResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPThermostatClusterGetWeeklyScheduleResponseCallback, |
| void (*)(CHIPThermostatClusterGetWeeklyScheduleResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPThermostatClusterGetWeeklyScheduleResponseCallback *>(context), |
| chip::Platform::Delete<CHIPThermostatClusterGetWeeklyScheduleResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/ArrayList;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject NumberOfTransitionsForSequence; |
| std::string NumberOfTransitionsForSequenceClassName = "java/lang/Integer"; |
| std::string NumberOfTransitionsForSequenceCtorSignature = "(I)V"; |
| jint jniNumberOfTransitionsForSequence = static_cast<jint>(dataResponse.numberOfTransitionsForSequence); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(NumberOfTransitionsForSequenceClassName.c_str(), |
| NumberOfTransitionsForSequenceCtorSignature.c_str(), |
| jniNumberOfTransitionsForSequence, NumberOfTransitionsForSequence); |
| jobject DayOfWeekForSequence; |
| std::string DayOfWeekForSequenceClassName = "java/lang/Integer"; |
| std::string DayOfWeekForSequenceCtorSignature = "(I)V"; |
| jint jniDayOfWeekForSequence = static_cast<jint>(dataResponse.dayOfWeekForSequence.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(DayOfWeekForSequenceClassName.c_str(), |
| DayOfWeekForSequenceCtorSignature.c_str(), jniDayOfWeekForSequence, |
| DayOfWeekForSequence); |
| jobject ModeForSequence; |
| std::string ModeForSequenceClassName = "java/lang/Integer"; |
| std::string ModeForSequenceCtorSignature = "(I)V"; |
| jint jniModeForSequence = static_cast<jint>(dataResponse.modeForSequence.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| ModeForSequenceClassName.c_str(), ModeForSequenceCtorSignature.c_str(), jniModeForSequence, ModeForSequence); |
| jobject Transitions; |
| chip::JniReferences::GetInstance().CreateArrayList(Transitions); |
| |
| auto iter_Transitions_0 = dataResponse.transitions.begin(); |
| while (iter_Transitions_0.Next()) |
| { |
| auto & entry_0 = iter_Transitions_0.GetValue(); |
| jobject newElement_0; |
| jobject newElement_0_transitionTime; |
| std::string newElement_0_transitionTimeClassName = "java/lang/Integer"; |
| std::string newElement_0_transitionTimeCtorSignature = "(I)V"; |
| jint jninewElement_0_transitionTime = static_cast<jint>(entry_0.transitionTime); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_0_transitionTimeClassName.c_str(), |
| newElement_0_transitionTimeCtorSignature.c_str(), |
| jninewElement_0_transitionTime, newElement_0_transitionTime); |
| jobject newElement_0_heatSetpoint; |
| if (entry_0.heatSetpoint.IsNull()) |
| { |
| newElement_0_heatSetpoint = nullptr; |
| } |
| else |
| { |
| std::string newElement_0_heatSetpointClassName = "java/lang/Integer"; |
| std::string newElement_0_heatSetpointCtorSignature = "(I)V"; |
| jint jninewElement_0_heatSetpoint = static_cast<jint>(entry_0.heatSetpoint.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_0_heatSetpointClassName.c_str(), |
| newElement_0_heatSetpointCtorSignature.c_str(), |
| jninewElement_0_heatSetpoint, newElement_0_heatSetpoint); |
| } |
| jobject newElement_0_coolSetpoint; |
| if (entry_0.coolSetpoint.IsNull()) |
| { |
| newElement_0_coolSetpoint = nullptr; |
| } |
| else |
| { |
| std::string newElement_0_coolSetpointClassName = "java/lang/Integer"; |
| std::string newElement_0_coolSetpointCtorSignature = "(I)V"; |
| jint jninewElement_0_coolSetpoint = static_cast<jint>(entry_0.coolSetpoint.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_0_coolSetpointClassName.c_str(), |
| newElement_0_coolSetpointCtorSignature.c_str(), |
| jninewElement_0_coolSetpoint, newElement_0_coolSetpoint); |
| } |
| |
| jclass weeklyScheduleTransitionStructStructClass_1; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ThermostatClusterWeeklyScheduleTransitionStruct", |
| weeklyScheduleTransitionStructStructClass_1); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ThermostatClusterWeeklyScheduleTransitionStruct"); |
| return; |
| } |
| |
| jmethodID weeklyScheduleTransitionStructStructCtor_1; |
| err = chip::JniReferences::GetInstance().FindMethod(env, weeklyScheduleTransitionStructStructClass_1, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V", |
| &weeklyScheduleTransitionStructStructCtor_1); |
| if (err != CHIP_NO_ERROR || weeklyScheduleTransitionStructStructCtor_1 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ThermostatClusterWeeklyScheduleTransitionStruct constructor"); |
| return; |
| } |
| |
| newElement_0 = env->NewObject(weeklyScheduleTransitionStructStructClass_1, weeklyScheduleTransitionStructStructCtor_1, |
| newElement_0_transitionTime, newElement_0_heatSetpoint, newElement_0_coolSetpoint); |
| chip::JniReferences::GetInstance().AddToList(Transitions, newElement_0); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, NumberOfTransitionsForSequence, DayOfWeekForSequence, ModeForSequence, |
| Transitions); |
| } |
| CHIPChannelClusterChangeChannelResponseCallback::CHIPChannelClusterChangeChannelResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPChannelClusterChangeChannelResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPChannelClusterChangeChannelResponseCallback::~CHIPChannelClusterChangeChannelResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPChannelClusterChangeChannelResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::Channel::Commands::ChangeChannelResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPChannelClusterChangeChannelResponseCallback, void (*)(CHIPChannelClusterChangeChannelResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPChannelClusterChangeChannelResponseCallback *>(context), |
| chip::Platform::Delete<CHIPChannelClusterChangeChannelResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject Data; |
| if (!dataResponse.data.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); |
| } |
| else |
| { |
| jobject DataInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); |
| } |
| CHIPChannelClusterProgramGuideResponseCallback::CHIPChannelClusterProgramGuideResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPChannelClusterProgramGuideResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPChannelClusterProgramGuideResponseCallback::~CHIPChannelClusterProgramGuideResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPChannelClusterProgramGuideResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::Channel::Commands::ProgramGuideResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPChannelClusterProgramGuideResponseCallback, void (*)(CHIPChannelClusterProgramGuideResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPChannelClusterProgramGuideResponseCallback *>(context), |
| chip::Platform::Delete<CHIPChannelClusterProgramGuideResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Lchip/devicecontroller/ChipStructs$ChannelClusterChannelPagingStruct;Ljava/util/ArrayList;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Paging; |
| jobject Paging_previousToken; |
| if (!dataResponse.paging.previousToken.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousToken); |
| } |
| else |
| { |
| jobject Paging_previousTokenInsideOptional; |
| if (dataResponse.paging.previousToken.Value().IsNull()) |
| { |
| Paging_previousTokenInsideOptional = nullptr; |
| } |
| else |
| { |
| jobject Paging_previousTokenInsideOptional_limit; |
| if (!dataResponse.paging.previousToken.Value().Value().limit.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousTokenInsideOptional_limit); |
| } |
| else |
| { |
| jobject Paging_previousTokenInsideOptional_limitInsideOptional; |
| std::string Paging_previousTokenInsideOptional_limitInsideOptionalClassName = "java/lang/Integer"; |
| std::string Paging_previousTokenInsideOptional_limitInsideOptionalCtorSignature = "(I)V"; |
| jint jniPaging_previousTokenInsideOptional_limitInsideOptional = |
| static_cast<jint>(dataResponse.paging.previousToken.Value().Value().limit.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| Paging_previousTokenInsideOptional_limitInsideOptionalClassName.c_str(), |
| Paging_previousTokenInsideOptional_limitInsideOptionalCtorSignature.c_str(), |
| jniPaging_previousTokenInsideOptional_limitInsideOptional, |
| Paging_previousTokenInsideOptional_limitInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional_limitInsideOptional, |
| Paging_previousTokenInsideOptional_limit); |
| } |
| jobject Paging_previousTokenInsideOptional_after; |
| if (!dataResponse.paging.previousToken.Value().Value().after.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousTokenInsideOptional_after); |
| } |
| else |
| { |
| jobject Paging_previousTokenInsideOptional_afterInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( |
| dataResponse.paging.previousToken.Value().Value().after.Value(), |
| Paging_previousTokenInsideOptional_afterInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional_afterInsideOptional, |
| Paging_previousTokenInsideOptional_after); |
| } |
| jobject Paging_previousTokenInsideOptional_before; |
| if (!dataResponse.paging.previousToken.Value().Value().before.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_previousTokenInsideOptional_before); |
| } |
| else |
| { |
| jobject Paging_previousTokenInsideOptional_beforeInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( |
| dataResponse.paging.previousToken.Value().Value().before.Value(), |
| Paging_previousTokenInsideOptional_beforeInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional_beforeInsideOptional, |
| Paging_previousTokenInsideOptional_before); |
| } |
| |
| jclass pageTokenStructStructClass_3; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ChannelClusterPageTokenStruct", pageTokenStructStructClass_3); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterPageTokenStruct"); |
| return; |
| } |
| |
| jmethodID pageTokenStructStructCtor_3; |
| err = chip::JniReferences::GetInstance().FindMethod(env, pageTokenStructStructClass_3, "<init>", |
| "(Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &pageTokenStructStructCtor_3); |
| if (err != CHIP_NO_ERROR || pageTokenStructStructCtor_3 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterPageTokenStruct constructor"); |
| return; |
| } |
| |
| Paging_previousTokenInsideOptional = |
| env->NewObject(pageTokenStructStructClass_3, pageTokenStructStructCtor_3, Paging_previousTokenInsideOptional_limit, |
| Paging_previousTokenInsideOptional_after, Paging_previousTokenInsideOptional_before); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(Paging_previousTokenInsideOptional, Paging_previousToken); |
| } |
| jobject Paging_nextToken; |
| if (!dataResponse.paging.nextToken.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextToken); |
| } |
| else |
| { |
| jobject Paging_nextTokenInsideOptional; |
| if (dataResponse.paging.nextToken.Value().IsNull()) |
| { |
| Paging_nextTokenInsideOptional = nullptr; |
| } |
| else |
| { |
| jobject Paging_nextTokenInsideOptional_limit; |
| if (!dataResponse.paging.nextToken.Value().Value().limit.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextTokenInsideOptional_limit); |
| } |
| else |
| { |
| jobject Paging_nextTokenInsideOptional_limitInsideOptional; |
| std::string Paging_nextTokenInsideOptional_limitInsideOptionalClassName = "java/lang/Integer"; |
| std::string Paging_nextTokenInsideOptional_limitInsideOptionalCtorSignature = "(I)V"; |
| jint jniPaging_nextTokenInsideOptional_limitInsideOptional = |
| static_cast<jint>(dataResponse.paging.nextToken.Value().Value().limit.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| Paging_nextTokenInsideOptional_limitInsideOptionalClassName.c_str(), |
| Paging_nextTokenInsideOptional_limitInsideOptionalCtorSignature.c_str(), |
| jniPaging_nextTokenInsideOptional_limitInsideOptional, Paging_nextTokenInsideOptional_limitInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional_limitInsideOptional, |
| Paging_nextTokenInsideOptional_limit); |
| } |
| jobject Paging_nextTokenInsideOptional_after; |
| if (!dataResponse.paging.nextToken.Value().Value().after.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextTokenInsideOptional_after); |
| } |
| else |
| { |
| jobject Paging_nextTokenInsideOptional_afterInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.paging.nextToken.Value().Value().after.Value(), |
| Paging_nextTokenInsideOptional_afterInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional_afterInsideOptional, |
| Paging_nextTokenInsideOptional_after); |
| } |
| jobject Paging_nextTokenInsideOptional_before; |
| if (!dataResponse.paging.nextToken.Value().Value().before.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Paging_nextTokenInsideOptional_before); |
| } |
| else |
| { |
| jobject Paging_nextTokenInsideOptional_beforeInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.paging.nextToken.Value().Value().before.Value(), |
| Paging_nextTokenInsideOptional_beforeInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional_beforeInsideOptional, |
| Paging_nextTokenInsideOptional_before); |
| } |
| |
| jclass pageTokenStructStructClass_3; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ChannelClusterPageTokenStruct", pageTokenStructStructClass_3); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterPageTokenStruct"); |
| return; |
| } |
| |
| jmethodID pageTokenStructStructCtor_3; |
| err = chip::JniReferences::GetInstance().FindMethod(env, pageTokenStructStructClass_3, "<init>", |
| "(Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &pageTokenStructStructCtor_3); |
| if (err != CHIP_NO_ERROR || pageTokenStructStructCtor_3 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterPageTokenStruct constructor"); |
| return; |
| } |
| |
| Paging_nextTokenInsideOptional = |
| env->NewObject(pageTokenStructStructClass_3, pageTokenStructStructCtor_3, Paging_nextTokenInsideOptional_limit, |
| Paging_nextTokenInsideOptional_after, Paging_nextTokenInsideOptional_before); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(Paging_nextTokenInsideOptional, Paging_nextToken); |
| } |
| |
| jclass channelPagingStructStructClass_0; |
| err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$ChannelClusterChannelPagingStruct", |
| channelPagingStructStructClass_0); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterChannelPagingStruct"); |
| return; |
| } |
| |
| jmethodID channelPagingStructStructCtor_0; |
| err = chip::JniReferences::GetInstance().FindMethod(env, channelPagingStructStructClass_0, "<init>", |
| "(Ljava/util/Optional;Ljava/util/Optional;)V", |
| &channelPagingStructStructCtor_0); |
| if (err != CHIP_NO_ERROR || channelPagingStructStructCtor_0 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterChannelPagingStruct constructor"); |
| return; |
| } |
| |
| Paging = |
| env->NewObject(channelPagingStructStructClass_0, channelPagingStructStructCtor_0, Paging_previousToken, Paging_nextToken); |
| jobject ProgramList; |
| chip::JniReferences::GetInstance().CreateArrayList(ProgramList); |
| |
| auto iter_ProgramList_0 = dataResponse.programList.begin(); |
| while (iter_ProgramList_0.Next()) |
| { |
| auto & entry_0 = iter_ProgramList_0.GetValue(); |
| jobject newElement_0; |
| jobject newElement_0_identifier; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.identifier, newElement_0_identifier)); |
| jobject newElement_0_channel; |
| jobject newElement_0_channel_majorNumber; |
| std::string newElement_0_channel_majorNumberClassName = "java/lang/Integer"; |
| std::string newElement_0_channel_majorNumberCtorSignature = "(I)V"; |
| jint jninewElement_0_channel_majorNumber = static_cast<jint>(entry_0.channel.majorNumber); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_0_channel_majorNumberClassName.c_str(), newElement_0_channel_majorNumberCtorSignature.c_str(), |
| jninewElement_0_channel_majorNumber, newElement_0_channel_majorNumber); |
| jobject newElement_0_channel_minorNumber; |
| std::string newElement_0_channel_minorNumberClassName = "java/lang/Integer"; |
| std::string newElement_0_channel_minorNumberCtorSignature = "(I)V"; |
| jint jninewElement_0_channel_minorNumber = static_cast<jint>(entry_0.channel.minorNumber); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_0_channel_minorNumberClassName.c_str(), newElement_0_channel_minorNumberCtorSignature.c_str(), |
| jninewElement_0_channel_minorNumber, newElement_0_channel_minorNumber); |
| jobject newElement_0_channel_name; |
| if (!entry_0.channel.name.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_name); |
| } |
| else |
| { |
| jobject newElement_0_channel_nameInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.channel.name.Value(), |
| newElement_0_channel_nameInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_nameInsideOptional, newElement_0_channel_name); |
| } |
| jobject newElement_0_channel_callSign; |
| if (!entry_0.channel.callSign.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_callSign); |
| } |
| else |
| { |
| jobject newElement_0_channel_callSignInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.channel.callSign.Value(), |
| newElement_0_channel_callSignInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_callSignInsideOptional, |
| newElement_0_channel_callSign); |
| } |
| jobject newElement_0_channel_affiliateCallSign; |
| if (!entry_0.channel.affiliateCallSign.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_affiliateCallSign); |
| } |
| else |
| { |
| jobject newElement_0_channel_affiliateCallSignInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( |
| entry_0.channel.affiliateCallSign.Value(), newElement_0_channel_affiliateCallSignInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_affiliateCallSignInsideOptional, |
| newElement_0_channel_affiliateCallSign); |
| } |
| jobject newElement_0_channel_identifier; |
| if (!entry_0.channel.identifier.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_identifier); |
| } |
| else |
| { |
| jobject newElement_0_channel_identifierInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.channel.identifier.Value(), |
| newElement_0_channel_identifierInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_identifierInsideOptional, |
| newElement_0_channel_identifier); |
| } |
| jobject newElement_0_channel_type; |
| if (!entry_0.channel.type.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_channel_type); |
| } |
| else |
| { |
| jobject newElement_0_channel_typeInsideOptional; |
| std::string newElement_0_channel_typeInsideOptionalClassName = "java/lang/Integer"; |
| std::string newElement_0_channel_typeInsideOptionalCtorSignature = "(I)V"; |
| jint jninewElement_0_channel_typeInsideOptional = static_cast<jint>(entry_0.channel.type.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_0_channel_typeInsideOptionalClassName.c_str(), |
| newElement_0_channel_typeInsideOptionalCtorSignature.c_str(), |
| jninewElement_0_channel_typeInsideOptional, |
| newElement_0_channel_typeInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_channel_typeInsideOptional, newElement_0_channel_type); |
| } |
| |
| jclass channelInfoStructStructClass_2; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ChannelClusterChannelInfoStruct", channelInfoStructStructClass_2); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterChannelInfoStruct"); |
| return; |
| } |
| |
| jmethodID channelInfoStructStructCtor_2; |
| err = |
| chip::JniReferences::GetInstance().FindMethod(env, channelInfoStructStructClass_2, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/" |
| "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &channelInfoStructStructCtor_2); |
| if (err != CHIP_NO_ERROR || channelInfoStructStructCtor_2 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterChannelInfoStruct constructor"); |
| return; |
| } |
| |
| newElement_0_channel = |
| env->NewObject(channelInfoStructStructClass_2, channelInfoStructStructCtor_2, newElement_0_channel_majorNumber, |
| newElement_0_channel_minorNumber, newElement_0_channel_name, newElement_0_channel_callSign, |
| newElement_0_channel_affiliateCallSign, newElement_0_channel_identifier, newElement_0_channel_type); |
| jobject newElement_0_startTime; |
| std::string newElement_0_startTimeClassName = "java/lang/Long"; |
| std::string newElement_0_startTimeCtorSignature = "(J)V"; |
| jlong jninewElement_0_startTime = static_cast<jlong>(entry_0.startTime); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(newElement_0_startTimeClassName.c_str(), |
| newElement_0_startTimeCtorSignature.c_str(), |
| jninewElement_0_startTime, newElement_0_startTime); |
| jobject newElement_0_endTime; |
| std::string newElement_0_endTimeClassName = "java/lang/Long"; |
| std::string newElement_0_endTimeCtorSignature = "(J)V"; |
| jlong jninewElement_0_endTime = static_cast<jlong>(entry_0.endTime); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(newElement_0_endTimeClassName.c_str(), |
| newElement_0_endTimeCtorSignature.c_str(), |
| jninewElement_0_endTime, newElement_0_endTime); |
| jobject newElement_0_title; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.title, newElement_0_title)); |
| jobject newElement_0_subtitle; |
| if (!entry_0.subtitle.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_subtitle); |
| } |
| else |
| { |
| jobject newElement_0_subtitleInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(entry_0.subtitle.Value(), newElement_0_subtitleInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_subtitleInsideOptional, newElement_0_subtitle); |
| } |
| jobject newElement_0_description; |
| if (!entry_0.description.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_description); |
| } |
| else |
| { |
| jobject newElement_0_descriptionInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.description.Value(), |
| newElement_0_descriptionInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_descriptionInsideOptional, newElement_0_description); |
| } |
| jobject newElement_0_audioLanguages; |
| if (!entry_0.audioLanguages.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_audioLanguages); |
| } |
| else |
| { |
| jobject newElement_0_audioLanguagesInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_0_audioLanguagesInsideOptional); |
| |
| auto iter_newElement_0_audioLanguagesInsideOptional_3 = entry_0.audioLanguages.Value().begin(); |
| while (iter_newElement_0_audioLanguagesInsideOptional_3.Next()) |
| { |
| auto & entry_3 = iter_newElement_0_audioLanguagesInsideOptional_3.GetValue(); |
| jobject newElement_3; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3, newElement_3)); |
| chip::JniReferences::GetInstance().AddToList(newElement_0_audioLanguagesInsideOptional, newElement_3); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_audioLanguagesInsideOptional, |
| newElement_0_audioLanguages); |
| } |
| jobject newElement_0_ratings; |
| if (!entry_0.ratings.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_ratings); |
| } |
| else |
| { |
| jobject newElement_0_ratingsInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_0_ratingsInsideOptional); |
| |
| auto iter_newElement_0_ratingsInsideOptional_3 = entry_0.ratings.Value().begin(); |
| while (iter_newElement_0_ratingsInsideOptional_3.Next()) |
| { |
| auto & entry_3 = iter_newElement_0_ratingsInsideOptional_3.GetValue(); |
| jobject newElement_3; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3, newElement_3)); |
| chip::JniReferences::GetInstance().AddToList(newElement_0_ratingsInsideOptional, newElement_3); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_ratingsInsideOptional, newElement_0_ratings); |
| } |
| jobject newElement_0_thumbnailUrl; |
| if (!entry_0.thumbnailUrl.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_thumbnailUrl); |
| } |
| else |
| { |
| jobject newElement_0_thumbnailUrlInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.thumbnailUrl.Value(), |
| newElement_0_thumbnailUrlInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_thumbnailUrlInsideOptional, newElement_0_thumbnailUrl); |
| } |
| jobject newElement_0_posterArtUrl; |
| if (!entry_0.posterArtUrl.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_posterArtUrl); |
| } |
| else |
| { |
| jobject newElement_0_posterArtUrlInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.posterArtUrl.Value(), |
| newElement_0_posterArtUrlInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_posterArtUrlInsideOptional, newElement_0_posterArtUrl); |
| } |
| jobject newElement_0_dvbiUrl; |
| if (!entry_0.dvbiUrl.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_dvbiUrl); |
| } |
| else |
| { |
| jobject newElement_0_dvbiUrlInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(entry_0.dvbiUrl.Value(), newElement_0_dvbiUrlInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_dvbiUrlInsideOptional, newElement_0_dvbiUrl); |
| } |
| jobject newElement_0_releaseDate; |
| if (!entry_0.releaseDate.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_releaseDate); |
| } |
| else |
| { |
| jobject newElement_0_releaseDateInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.releaseDate.Value(), |
| newElement_0_releaseDateInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_releaseDateInsideOptional, newElement_0_releaseDate); |
| } |
| jobject newElement_0_parentalGuidanceText; |
| if (!entry_0.parentalGuidanceText.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_parentalGuidanceText); |
| } |
| else |
| { |
| jobject newElement_0_parentalGuidanceTextInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.parentalGuidanceText.Value(), |
| newElement_0_parentalGuidanceTextInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_parentalGuidanceTextInsideOptional, |
| newElement_0_parentalGuidanceText); |
| } |
| jobject newElement_0_recordingFlag; |
| if (!entry_0.recordingFlag.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_recordingFlag); |
| } |
| else |
| { |
| jobject newElement_0_recordingFlagInsideOptional; |
| std::string newElement_0_recordingFlagInsideOptionalClassName = "java/lang/Long"; |
| std::string newElement_0_recordingFlagInsideOptionalCtorSignature = "(J)V"; |
| jlong jninewElement_0_recordingFlagInsideOptional = static_cast<jlong>(entry_0.recordingFlag.Value().Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>( |
| newElement_0_recordingFlagInsideOptionalClassName.c_str(), |
| newElement_0_recordingFlagInsideOptionalCtorSignature.c_str(), jninewElement_0_recordingFlagInsideOptional, |
| newElement_0_recordingFlagInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_recordingFlagInsideOptional, newElement_0_recordingFlag); |
| } |
| jobject newElement_0_seriesInfo; |
| if (!entry_0.seriesInfo.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_seriesInfo); |
| } |
| else |
| { |
| jobject newElement_0_seriesInfoInsideOptional; |
| if (entry_0.seriesInfo.Value().IsNull()) |
| { |
| newElement_0_seriesInfoInsideOptional = nullptr; |
| } |
| else |
| { |
| jobject newElement_0_seriesInfoInsideOptional_season; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.seriesInfo.Value().Value().season, |
| newElement_0_seriesInfoInsideOptional_season)); |
| jobject newElement_0_seriesInfoInsideOptional_episode; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( |
| entry_0.seriesInfo.Value().Value().episode, newElement_0_seriesInfoInsideOptional_episode)); |
| |
| jclass seriesInfoStructStructClass_4; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ChannelClusterSeriesInfoStruct", seriesInfoStructStructClass_4); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterSeriesInfoStruct"); |
| return; |
| } |
| |
| jmethodID seriesInfoStructStructCtor_4; |
| err = chip::JniReferences::GetInstance().FindMethod(env, seriesInfoStructStructClass_4, "<init>", |
| "(Ljava/lang/String;Ljava/lang/String;)V", |
| &seriesInfoStructStructCtor_4); |
| if (err != CHIP_NO_ERROR || seriesInfoStructStructCtor_4 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterSeriesInfoStruct constructor"); |
| return; |
| } |
| |
| newElement_0_seriesInfoInsideOptional = |
| env->NewObject(seriesInfoStructStructClass_4, seriesInfoStructStructCtor_4, |
| newElement_0_seriesInfoInsideOptional_season, newElement_0_seriesInfoInsideOptional_episode); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_seriesInfoInsideOptional, newElement_0_seriesInfo); |
| } |
| jobject newElement_0_categoryList; |
| if (!entry_0.categoryList.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_categoryList); |
| } |
| else |
| { |
| jobject newElement_0_categoryListInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_0_categoryListInsideOptional); |
| |
| auto iter_newElement_0_categoryListInsideOptional_3 = entry_0.categoryList.Value().begin(); |
| while (iter_newElement_0_categoryListInsideOptional_3.Next()) |
| { |
| auto & entry_3 = iter_newElement_0_categoryListInsideOptional_3.GetValue(); |
| jobject newElement_3; |
| jobject newElement_3_category; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.category, newElement_3_category)); |
| jobject newElement_3_subCategory; |
| if (!entry_3.subCategory.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_3_subCategory); |
| } |
| else |
| { |
| jobject newElement_3_subCategoryInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.subCategory.Value(), |
| newElement_3_subCategoryInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(newElement_3_subCategoryInsideOptional, |
| newElement_3_subCategory); |
| } |
| |
| jclass programCategoryStructStructClass_4; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramCategoryStruct", |
| programCategoryStructStructClass_4); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramCategoryStruct"); |
| return; |
| } |
| |
| jmethodID programCategoryStructStructCtor_4; |
| err = chip::JniReferences::GetInstance().FindMethod(env, programCategoryStructStructClass_4, "<init>", |
| "(Ljava/lang/String;Ljava/util/Optional;)V", |
| &programCategoryStructStructCtor_4); |
| if (err != CHIP_NO_ERROR || programCategoryStructStructCtor_4 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramCategoryStruct constructor"); |
| return; |
| } |
| |
| newElement_3 = env->NewObject(programCategoryStructStructClass_4, programCategoryStructStructCtor_4, |
| newElement_3_category, newElement_3_subCategory); |
| chip::JniReferences::GetInstance().AddToList(newElement_0_categoryListInsideOptional, newElement_3); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_categoryListInsideOptional, newElement_0_categoryList); |
| } |
| jobject newElement_0_castList; |
| if (!entry_0.castList.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_castList); |
| } |
| else |
| { |
| jobject newElement_0_castListInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_0_castListInsideOptional); |
| |
| auto iter_newElement_0_castListInsideOptional_3 = entry_0.castList.Value().begin(); |
| while (iter_newElement_0_castListInsideOptional_3.Next()) |
| { |
| auto & entry_3 = iter_newElement_0_castListInsideOptional_3.GetValue(); |
| jobject newElement_3; |
| jobject newElement_3_name; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.name, newElement_3_name)); |
| jobject newElement_3_role; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.role, newElement_3_role)); |
| |
| jclass programCastStructStructClass_4; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramCastStruct", programCastStructStructClass_4); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramCastStruct"); |
| return; |
| } |
| |
| jmethodID programCastStructStructCtor_4; |
| err = chip::JniReferences::GetInstance().FindMethod(env, programCastStructStructClass_4, "<init>", |
| "(Ljava/lang/String;Ljava/lang/String;)V", |
| &programCastStructStructCtor_4); |
| if (err != CHIP_NO_ERROR || programCastStructStructCtor_4 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramCastStruct constructor"); |
| return; |
| } |
| |
| newElement_3 = env->NewObject(programCastStructStructClass_4, programCastStructStructCtor_4, newElement_3_name, |
| newElement_3_role); |
| chip::JniReferences::GetInstance().AddToList(newElement_0_castListInsideOptional, newElement_3); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_castListInsideOptional, newElement_0_castList); |
| } |
| jobject newElement_0_externalIDList; |
| if (!entry_0.externalIDList.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_externalIDList); |
| } |
| else |
| { |
| jobject newElement_0_externalIDListInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_0_externalIDListInsideOptional); |
| |
| auto iter_newElement_0_externalIDListInsideOptional_3 = entry_0.externalIDList.Value().begin(); |
| while (iter_newElement_0_externalIDListInsideOptional_3.Next()) |
| { |
| auto & entry_3 = iter_newElement_0_externalIDListInsideOptional_3.GetValue(); |
| jobject newElement_3; |
| jobject newElement_3_name; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.name, newElement_3_name)); |
| jobject newElement_3_role; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_3.role, newElement_3_role)); |
| |
| jclass programCastStructStructClass_4; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramCastStruct", programCastStructStructClass_4); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramCastStruct"); |
| return; |
| } |
| |
| jmethodID programCastStructStructCtor_4; |
| err = chip::JniReferences::GetInstance().FindMethod(env, programCastStructStructClass_4, "<init>", |
| "(Ljava/lang/String;Ljava/lang/String;)V", |
| &programCastStructStructCtor_4); |
| if (err != CHIP_NO_ERROR || programCastStructStructCtor_4 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramCastStruct constructor"); |
| return; |
| } |
| |
| newElement_3 = env->NewObject(programCastStructStructClass_4, programCastStructStructCtor_4, newElement_3_name, |
| newElement_3_role); |
| chip::JniReferences::GetInstance().AddToList(newElement_0_externalIDListInsideOptional, newElement_3); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(newElement_0_externalIDListInsideOptional, |
| newElement_0_externalIDList); |
| } |
| |
| jclass programStructStructClass_1; |
| err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$ChannelClusterProgramStruct", |
| programStructStructClass_1); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$ChannelClusterProgramStruct"); |
| return; |
| } |
| |
| jmethodID programStructStructCtor_1; |
| err = chip::JniReferences::GetInstance().FindMethod( |
| env, programStructStructClass_1, "<init>", |
| "(Ljava/lang/String;Lchip/devicecontroller/ChipStructs$ChannelClusterChannelInfoStruct;Ljava/lang/Long;Ljava/lang/" |
| "Long;Ljava/lang/String;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" |
| "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/" |
| "util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &programStructStructCtor_1); |
| if (err != CHIP_NO_ERROR || programStructStructCtor_1 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$ChannelClusterProgramStruct constructor"); |
| return; |
| } |
| |
| newElement_0 = env->NewObject( |
| programStructStructClass_1, programStructStructCtor_1, newElement_0_identifier, newElement_0_channel, |
| newElement_0_startTime, newElement_0_endTime, newElement_0_title, newElement_0_subtitle, newElement_0_description, |
| newElement_0_audioLanguages, newElement_0_ratings, newElement_0_thumbnailUrl, newElement_0_posterArtUrl, |
| newElement_0_dvbiUrl, newElement_0_releaseDate, newElement_0_parentalGuidanceText, newElement_0_recordingFlag, |
| newElement_0_seriesInfo, newElement_0_categoryList, newElement_0_castList, newElement_0_externalIDList); |
| chip::JniReferences::GetInstance().AddToList(ProgramList, newElement_0); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Paging, ProgramList); |
| } |
| CHIPTargetNavigatorClusterNavigateTargetResponseCallback::CHIPTargetNavigatorClusterNavigateTargetResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPTargetNavigatorClusterNavigateTargetResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPTargetNavigatorClusterNavigateTargetResponseCallback::~CHIPTargetNavigatorClusterNavigateTargetResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPTargetNavigatorClusterNavigateTargetResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::TargetNavigator::Commands::NavigateTargetResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPTargetNavigatorClusterNavigateTargetResponseCallback, |
| void (*)(CHIPTargetNavigatorClusterNavigateTargetResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPTargetNavigatorClusterNavigateTargetResponseCallback *>(context), |
| chip::Platform::Delete<CHIPTargetNavigatorClusterNavigateTargetResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject Data; |
| if (!dataResponse.data.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); |
| } |
| else |
| { |
| jobject DataInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); |
| } |
| CHIPMediaPlaybackClusterPlaybackResponseCallback::CHIPMediaPlaybackClusterPlaybackResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPMediaPlaybackClusterPlaybackResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPMediaPlaybackClusterPlaybackResponseCallback::~CHIPMediaPlaybackClusterPlaybackResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPMediaPlaybackClusterPlaybackResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPMediaPlaybackClusterPlaybackResponseCallback, void (*)(CHIPMediaPlaybackClusterPlaybackResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPMediaPlaybackClusterPlaybackResponseCallback *>(context), |
| chip::Platform::Delete<CHIPMediaPlaybackClusterPlaybackResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject Data; |
| if (!dataResponse.data.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); |
| } |
| else |
| { |
| jobject DataInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); |
| } |
| CHIPKeypadInputClusterSendKeyResponseCallback::CHIPKeypadInputClusterSendKeyResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPKeypadInputClusterSendKeyResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPKeypadInputClusterSendKeyResponseCallback::~CHIPKeypadInputClusterSendKeyResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPKeypadInputClusterSendKeyResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::KeypadInput::Commands::SendKeyResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPKeypadInputClusterSendKeyResponseCallback, void (*)(CHIPKeypadInputClusterSendKeyResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPKeypadInputClusterSendKeyResponseCallback *>(context), |
| chip::Platform::Delete<CHIPKeypadInputClusterSendKeyResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status); |
| } |
| CHIPContentLauncherClusterLauncherResponseCallback::CHIPContentLauncherClusterLauncherResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPContentLauncherClusterLauncherResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPContentLauncherClusterLauncherResponseCallback::~CHIPContentLauncherClusterLauncherResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPContentLauncherClusterLauncherResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ContentLauncher::Commands::LauncherResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPContentLauncherClusterLauncherResponseCallback, |
| void (*)(CHIPContentLauncherClusterLauncherResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPContentLauncherClusterLauncherResponseCallback *>(context), |
| chip::Platform::Delete<CHIPContentLauncherClusterLauncherResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject Data; |
| if (!dataResponse.data.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); |
| } |
| else |
| { |
| jobject DataInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); |
| } |
| CHIPApplicationLauncherClusterLauncherResponseCallback::CHIPApplicationLauncherClusterLauncherResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPApplicationLauncherClusterLauncherResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPApplicationLauncherClusterLauncherResponseCallback::~CHIPApplicationLauncherClusterLauncherResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPApplicationLauncherClusterLauncherResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPApplicationLauncherClusterLauncherResponseCallback, |
| void (*)(CHIPApplicationLauncherClusterLauncherResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPApplicationLauncherClusterLauncherResponseCallback *>(context), |
| chip::Platform::Delete<CHIPApplicationLauncherClusterLauncherResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject Data; |
| if (!dataResponse.data.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); |
| } |
| else |
| { |
| jobject DataInsideOptional; |
| jbyteArray DataInsideOptionalByteArray = env->NewByteArray(static_cast<jsize>(dataResponse.data.Value().size())); |
| env->SetByteArrayRegion(DataInsideOptionalByteArray, 0, static_cast<jsize>(dataResponse.data.Value().size()), |
| reinterpret_cast<const jbyte *>(dataResponse.data.Value().data())); |
| DataInsideOptional = DataInsideOptionalByteArray; |
| chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data); |
| } |
| CHIPAccountLoginClusterGetSetupPINResponseCallback::CHIPAccountLoginClusterGetSetupPINResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPAccountLoginClusterGetSetupPINResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPAccountLoginClusterGetSetupPINResponseCallback::~CHIPAccountLoginClusterGetSetupPINResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPAccountLoginClusterGetSetupPINResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::AccountLogin::Commands::GetSetupPINResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPAccountLoginClusterGetSetupPINResponseCallback, |
| void (*)(CHIPAccountLoginClusterGetSetupPINResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPAccountLoginClusterGetSetupPINResponseCallback *>(context), |
| chip::Platform::Delete<CHIPAccountLoginClusterGetSetupPINResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/String;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject SetupPIN; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.setupPIN, SetupPIN)); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, SetupPIN); |
| } |
| CHIPContentControlClusterResetPINResponseCallback::CHIPContentControlClusterResetPINResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPContentControlClusterResetPINResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPContentControlClusterResetPINResponseCallback::~CHIPContentControlClusterResetPINResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPContentControlClusterResetPINResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::ContentControl::Commands::ResetPINResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPContentControlClusterResetPINResponseCallback, |
| void (*)(CHIPContentControlClusterResetPINResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPContentControlClusterResetPINResponseCallback *>(context), |
| chip::Platform::Delete<CHIPContentControlClusterResetPINResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/String;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject PINCode; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.PINCode, PINCode)); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, PINCode); |
| } |
| CHIPContentAppObserverClusterContentAppMessageResponseCallback::CHIPContentAppObserverClusterContentAppMessageResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPContentAppObserverClusterContentAppMessageResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPContentAppObserverClusterContentAppMessageResponseCallback::~CHIPContentAppObserverClusterContentAppMessageResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPContentAppObserverClusterContentAppMessageResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::ContentAppObserver::Commands::ContentAppMessageResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPContentAppObserverClusterContentAppMessageResponseCallback, |
| void (*)(CHIPContentAppObserverClusterContentAppMessageResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPContentAppObserverClusterContentAppMessageResponseCallback *>(context), |
| chip::Platform::Delete<CHIPContentAppObserverClusterContentAppMessageResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Integer;Ljava/util/Optional;Ljava/util/Optional;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject Status; |
| std::string StatusClassName = "java/lang/Integer"; |
| std::string StatusCtorSignature = "(I)V"; |
| jint jniStatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(StatusClassName.c_str(), StatusCtorSignature.c_str(), jniStatus, |
| Status); |
| jobject Data; |
| if (!dataResponse.data.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, Data); |
| } |
| else |
| { |
| jobject DataInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); |
| } |
| jobject EncodingHint; |
| if (!dataResponse.encodingHint.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, EncodingHint); |
| } |
| else |
| { |
| jobject EncodingHintInsideOptional; |
| LogErrorOnFailure( |
| chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.encodingHint.Value(), EncodingHintInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(EncodingHintInsideOptional, EncodingHint); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, Status, Data, EncodingHint); |
| } |
| CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback:: |
| CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback(jobject javaCallback) : |
| Callback::Callback<CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback:: |
| ~CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::ElectricalMeasurement::Commands::GetProfileInfoResponseCommand::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback, |
| void (*)(CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback *)> |
| cppCallback(reinterpret_cast<CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback *>(context), |
| chip::Platform::Delete<CHIPElectricalMeasurementClusterGetProfileInfoResponseCommandCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/ArrayList;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject profileCount; |
| std::string profileCountClassName = "java/lang/Integer"; |
| std::string profileCountCtorSignature = "(I)V"; |
| jint jniprofileCount = static_cast<jint>(dataResponse.profileCount); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(profileCountClassName.c_str(), profileCountCtorSignature.c_str(), |
| jniprofileCount, profileCount); |
| jobject profileIntervalPeriod; |
| std::string profileIntervalPeriodClassName = "java/lang/Integer"; |
| std::string profileIntervalPeriodCtorSignature = "(I)V"; |
| jint jniprofileIntervalPeriod = static_cast<jint>(dataResponse.profileIntervalPeriod); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(profileIntervalPeriodClassName.c_str(), |
| profileIntervalPeriodCtorSignature.c_str(), jniprofileIntervalPeriod, |
| profileIntervalPeriod); |
| jobject maxNumberOfIntervals; |
| std::string maxNumberOfIntervalsClassName = "java/lang/Integer"; |
| std::string maxNumberOfIntervalsCtorSignature = "(I)V"; |
| jint jnimaxNumberOfIntervals = static_cast<jint>(dataResponse.maxNumberOfIntervals); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(maxNumberOfIntervalsClassName.c_str(), |
| maxNumberOfIntervalsCtorSignature.c_str(), jnimaxNumberOfIntervals, |
| maxNumberOfIntervals); |
| jobject listOfAttributes; |
| chip::JniReferences::GetInstance().CreateArrayList(listOfAttributes); |
| |
| auto iter_listOfAttributes_0 = dataResponse.listOfAttributes.begin(); |
| while (iter_listOfAttributes_0.Next()) |
| { |
| auto & entry_0 = iter_listOfAttributes_0.GetValue(); |
| jobject newElement_0; |
| std::string newElement_0ClassName = "java/lang/Integer"; |
| std::string newElement_0CtorSignature = "(I)V"; |
| jint jninewElement_0 = static_cast<jint>(entry_0); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), |
| jninewElement_0, newElement_0); |
| chip::JniReferences::GetInstance().AddToList(listOfAttributes, newElement_0); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, profileCount, profileIntervalPeriod, maxNumberOfIntervals, listOfAttributes); |
| } |
| CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback:: |
| CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback(jobject javaCallback) : |
| Callback::Callback<CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback:: |
| ~CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::ElectricalMeasurement::Commands::GetMeasurementProfileResponseCommand::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback, |
| void (*)(CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback *)> |
| cppCallback(reinterpret_cast<CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback *>(context), |
| chip::Platform::Delete<CHIPElectricalMeasurementClusterGetMeasurementProfileResponseCommandCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Long;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/util/ArrayList;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject startTime; |
| std::string startTimeClassName = "java/lang/Long"; |
| std::string startTimeCtorSignature = "(J)V"; |
| jlong jnistartTime = static_cast<jlong>(dataResponse.startTime); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(startTimeClassName.c_str(), startTimeCtorSignature.c_str(), |
| jnistartTime, startTime); |
| jobject status; |
| std::string statusClassName = "java/lang/Integer"; |
| std::string statusCtorSignature = "(I)V"; |
| jint jnistatus = static_cast<jint>(dataResponse.status); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(statusClassName.c_str(), statusCtorSignature.c_str(), jnistatus, |
| status); |
| jobject profileIntervalPeriod; |
| std::string profileIntervalPeriodClassName = "java/lang/Integer"; |
| std::string profileIntervalPeriodCtorSignature = "(I)V"; |
| jint jniprofileIntervalPeriod = static_cast<jint>(dataResponse.profileIntervalPeriod); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(profileIntervalPeriodClassName.c_str(), |
| profileIntervalPeriodCtorSignature.c_str(), jniprofileIntervalPeriod, |
| profileIntervalPeriod); |
| jobject numberOfIntervalsDelivered; |
| std::string numberOfIntervalsDeliveredClassName = "java/lang/Integer"; |
| std::string numberOfIntervalsDeliveredCtorSignature = "(I)V"; |
| jint jninumberOfIntervalsDelivered = static_cast<jint>(dataResponse.numberOfIntervalsDelivered); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(numberOfIntervalsDeliveredClassName.c_str(), |
| numberOfIntervalsDeliveredCtorSignature.c_str(), |
| jninumberOfIntervalsDelivered, numberOfIntervalsDelivered); |
| jobject attributeId; |
| std::string attributeIdClassName = "java/lang/Integer"; |
| std::string attributeIdCtorSignature = "(I)V"; |
| jint jniattributeId = static_cast<jint>(dataResponse.attributeId); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(attributeIdClassName.c_str(), attributeIdCtorSignature.c_str(), |
| jniattributeId, attributeId); |
| jobject intervals; |
| chip::JniReferences::GetInstance().CreateArrayList(intervals); |
| |
| auto iter_intervals_0 = dataResponse.intervals.begin(); |
| while (iter_intervals_0.Next()) |
| { |
| auto & entry_0 = iter_intervals_0.GetValue(); |
| jobject newElement_0; |
| std::string newElement_0ClassName = "java/lang/Integer"; |
| std::string newElement_0CtorSignature = "(I)V"; |
| jint jninewElement_0 = static_cast<jint>(entry_0); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), |
| jninewElement_0, newElement_0); |
| chip::JniReferences::GetInstance().AddToList(intervals, newElement_0); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, startTime, status, profileIntervalPeriod, numberOfIntervalsDelivered, |
| attributeId, intervals); |
| } |
| CHIPUnitTestingClusterTestSpecificResponseCallback::CHIPUnitTestingClusterTestSpecificResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPUnitTestingClusterTestSpecificResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestSpecificResponseCallback::~CHIPUnitTestingClusterTestSpecificResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestSpecificResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::TestSpecificResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestSpecificResponseCallback, |
| void (*)(CHIPUnitTestingClusterTestSpecificResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestSpecificResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestSpecificResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject returnValue; |
| std::string returnValueClassName = "java/lang/Integer"; |
| std::string returnValueCtorSignature = "(I)V"; |
| jint jnireturnValue = static_cast<jint>(dataResponse.returnValue); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), |
| jnireturnValue, returnValue); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); |
| } |
| CHIPUnitTestingClusterTestAddArgumentsResponseCallback::CHIPUnitTestingClusterTestAddArgumentsResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPUnitTestingClusterTestAddArgumentsResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestAddArgumentsResponseCallback::~CHIPUnitTestingClusterTestAddArgumentsResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestAddArgumentsResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::TestAddArgumentsResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestAddArgumentsResponseCallback, |
| void (*)(CHIPUnitTestingClusterTestAddArgumentsResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestAddArgumentsResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestAddArgumentsResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject returnValue; |
| std::string returnValueClassName = "java/lang/Integer"; |
| std::string returnValueCtorSignature = "(I)V"; |
| jint jnireturnValue = static_cast<jint>(dataResponse.returnValue); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), |
| jnireturnValue, returnValue); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); |
| } |
| CHIPUnitTestingClusterTestSimpleArgumentResponseCallback::CHIPUnitTestingClusterTestSimpleArgumentResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPUnitTestingClusterTestSimpleArgumentResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestSimpleArgumentResponseCallback::~CHIPUnitTestingClusterTestSimpleArgumentResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestSimpleArgumentResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::TestSimpleArgumentResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestSimpleArgumentResponseCallback, |
| void (*)(CHIPUnitTestingClusterTestSimpleArgumentResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestSimpleArgumentResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestSimpleArgumentResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject returnValue; |
| std::string returnValueClassName = "java/lang/Boolean"; |
| std::string returnValueCtorSignature = "(Z)V"; |
| jboolean jnireturnValue = static_cast<jboolean>(dataResponse.returnValue); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), |
| jnireturnValue, returnValue); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); |
| } |
| CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPUnitTestingClusterTestStructArrayArgumentResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::~CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::TestStructArrayArgumentResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback, |
| void (*)(CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", |
| "(Ljava/util/ArrayList;Ljava/util/ArrayList;Ljava/util/ArrayList;Ljava/util/" |
| "ArrayList;Ljava/lang/Integer;Ljava/lang/Boolean;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject arg1; |
| chip::JniReferences::GetInstance().CreateArrayList(arg1); |
| |
| auto iter_arg1_0 = dataResponse.arg1.begin(); |
| while (iter_arg1_0.Next()) |
| { |
| auto & entry_0 = iter_arg1_0.GetValue(); |
| jobject newElement_0; |
| jobject newElement_0_a; |
| std::string newElement_0_aClassName = "java/lang/Integer"; |
| std::string newElement_0_aCtorSignature = "(I)V"; |
| jint jninewElement_0_a = static_cast<jint>(entry_0.a); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_0_aClassName.c_str(), newElement_0_aCtorSignature.c_str(), jninewElement_0_a, newElement_0_a); |
| jobject newElement_0_b; |
| std::string newElement_0_bClassName = "java/lang/Boolean"; |
| std::string newElement_0_bCtorSignature = "(Z)V"; |
| jboolean jninewElement_0_b = static_cast<jboolean>(entry_0.b); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| newElement_0_bClassName.c_str(), newElement_0_bCtorSignature.c_str(), jninewElement_0_b, newElement_0_b); |
| jobject newElement_0_c; |
| jobject newElement_0_c_a; |
| std::string newElement_0_c_aClassName = "java/lang/Integer"; |
| std::string newElement_0_c_aCtorSignature = "(I)V"; |
| jint jninewElement_0_c_a = static_cast<jint>(entry_0.c.a); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_0_c_aClassName.c_str(), newElement_0_c_aCtorSignature.c_str(), jninewElement_0_c_a, newElement_0_c_a); |
| jobject newElement_0_c_b; |
| std::string newElement_0_c_bClassName = "java/lang/Boolean"; |
| std::string newElement_0_c_bCtorSignature = "(Z)V"; |
| jboolean jninewElement_0_c_b = static_cast<jboolean>(entry_0.c.b); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| newElement_0_c_bClassName.c_str(), newElement_0_c_bCtorSignature.c_str(), jninewElement_0_c_b, newElement_0_c_b); |
| jobject newElement_0_c_c; |
| std::string newElement_0_c_cClassName = "java/lang/Integer"; |
| std::string newElement_0_c_cCtorSignature = "(I)V"; |
| jint jninewElement_0_c_c = static_cast<jint>(entry_0.c.c); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_0_c_cClassName.c_str(), newElement_0_c_cCtorSignature.c_str(), jninewElement_0_c_c, newElement_0_c_c); |
| jobject newElement_0_c_d; |
| jbyteArray newElement_0_c_dByteArray = env->NewByteArray(static_cast<jsize>(entry_0.c.d.size())); |
| env->SetByteArrayRegion(newElement_0_c_dByteArray, 0, static_cast<jsize>(entry_0.c.d.size()), |
| reinterpret_cast<const jbyte *>(entry_0.c.d.data())); |
| newElement_0_c_d = newElement_0_c_dByteArray; |
| jobject newElement_0_c_e; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.c.e, newElement_0_c_e)); |
| jobject newElement_0_c_f; |
| std::string newElement_0_c_fClassName = "java/lang/Integer"; |
| std::string newElement_0_c_fCtorSignature = "(I)V"; |
| jint jninewElement_0_c_f = static_cast<jint>(entry_0.c.f.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_0_c_fClassName.c_str(), newElement_0_c_fCtorSignature.c_str(), jninewElement_0_c_f, newElement_0_c_f); |
| jobject newElement_0_c_g; |
| std::string newElement_0_c_gClassName = "java/lang/Float"; |
| std::string newElement_0_c_gCtorSignature = "(F)V"; |
| jfloat jninewElement_0_c_g = static_cast<jfloat>(entry_0.c.g); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jfloat>( |
| newElement_0_c_gClassName.c_str(), newElement_0_c_gCtorSignature.c_str(), jninewElement_0_c_g, newElement_0_c_g); |
| jobject newElement_0_c_h; |
| std::string newElement_0_c_hClassName = "java/lang/Double"; |
| std::string newElement_0_c_hCtorSignature = "(D)V"; |
| jdouble jninewElement_0_c_h = static_cast<jdouble>(entry_0.c.h); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jdouble>( |
| newElement_0_c_hClassName.c_str(), newElement_0_c_hCtorSignature.c_str(), jninewElement_0_c_h, newElement_0_c_h); |
| |
| jclass simpleStructStructClass_2; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_2); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); |
| return; |
| } |
| |
| jmethodID simpleStructStructCtor_2; |
| err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_2, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" |
| "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", |
| &simpleStructStructCtor_2); |
| if (err != CHIP_NO_ERROR || simpleStructStructCtor_2 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); |
| return; |
| } |
| |
| newElement_0_c = env->NewObject(simpleStructStructClass_2, simpleStructStructCtor_2, newElement_0_c_a, newElement_0_c_b, |
| newElement_0_c_c, newElement_0_c_d, newElement_0_c_e, newElement_0_c_f, newElement_0_c_g, |
| newElement_0_c_h); |
| jobject newElement_0_d; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_0_d); |
| |
| auto iter_newElement_0_d_2 = entry_0.d.begin(); |
| while (iter_newElement_0_d_2.Next()) |
| { |
| auto & entry_2 = iter_newElement_0_d_2.GetValue(); |
| jobject newElement_2; |
| jobject newElement_2_a; |
| std::string newElement_2_aClassName = "java/lang/Integer"; |
| std::string newElement_2_aCtorSignature = "(I)V"; |
| jint jninewElement_2_a = static_cast<jint>(entry_2.a); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_2_aClassName.c_str(), newElement_2_aCtorSignature.c_str(), jninewElement_2_a, newElement_2_a); |
| jobject newElement_2_b; |
| std::string newElement_2_bClassName = "java/lang/Boolean"; |
| std::string newElement_2_bCtorSignature = "(Z)V"; |
| jboolean jninewElement_2_b = static_cast<jboolean>(entry_2.b); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| newElement_2_bClassName.c_str(), newElement_2_bCtorSignature.c_str(), jninewElement_2_b, newElement_2_b); |
| jobject newElement_2_c; |
| std::string newElement_2_cClassName = "java/lang/Integer"; |
| std::string newElement_2_cCtorSignature = "(I)V"; |
| jint jninewElement_2_c = static_cast<jint>(entry_2.c); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_2_cClassName.c_str(), newElement_2_cCtorSignature.c_str(), jninewElement_2_c, newElement_2_c); |
| jobject newElement_2_d; |
| jbyteArray newElement_2_dByteArray = env->NewByteArray(static_cast<jsize>(entry_2.d.size())); |
| env->SetByteArrayRegion(newElement_2_dByteArray, 0, static_cast<jsize>(entry_2.d.size()), |
| reinterpret_cast<const jbyte *>(entry_2.d.data())); |
| newElement_2_d = newElement_2_dByteArray; |
| jobject newElement_2_e; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_2.e, newElement_2_e)); |
| jobject newElement_2_f; |
| std::string newElement_2_fClassName = "java/lang/Integer"; |
| std::string newElement_2_fCtorSignature = "(I)V"; |
| jint jninewElement_2_f = static_cast<jint>(entry_2.f.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_2_fClassName.c_str(), newElement_2_fCtorSignature.c_str(), jninewElement_2_f, newElement_2_f); |
| jobject newElement_2_g; |
| std::string newElement_2_gClassName = "java/lang/Float"; |
| std::string newElement_2_gCtorSignature = "(F)V"; |
| jfloat jninewElement_2_g = static_cast<jfloat>(entry_2.g); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jfloat>( |
| newElement_2_gClassName.c_str(), newElement_2_gCtorSignature.c_str(), jninewElement_2_g, newElement_2_g); |
| jobject newElement_2_h; |
| std::string newElement_2_hClassName = "java/lang/Double"; |
| std::string newElement_2_hCtorSignature = "(D)V"; |
| jdouble jninewElement_2_h = static_cast<jdouble>(entry_2.h); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jdouble>( |
| newElement_2_hClassName.c_str(), newElement_2_hCtorSignature.c_str(), jninewElement_2_h, newElement_2_h); |
| |
| jclass simpleStructStructClass_3; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_3); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); |
| return; |
| } |
| |
| jmethodID simpleStructStructCtor_3; |
| err = chip::JniReferences::GetInstance().FindMethod( |
| env, simpleStructStructClass_3, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/Integer;Ljava/lang/" |
| "Float;Ljava/lang/Double;)V", |
| &simpleStructStructCtor_3); |
| if (err != CHIP_NO_ERROR || simpleStructStructCtor_3 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); |
| return; |
| } |
| |
| newElement_2 = |
| env->NewObject(simpleStructStructClass_3, simpleStructStructCtor_3, newElement_2_a, newElement_2_b, newElement_2_c, |
| newElement_2_d, newElement_2_e, newElement_2_f, newElement_2_g, newElement_2_h); |
| chip::JniReferences::GetInstance().AddToList(newElement_0_d, newElement_2); |
| } |
| jobject newElement_0_e; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_0_e); |
| |
| auto iter_newElement_0_e_2 = entry_0.e.begin(); |
| while (iter_newElement_0_e_2.Next()) |
| { |
| auto & entry_2 = iter_newElement_0_e_2.GetValue(); |
| jobject newElement_2; |
| std::string newElement_2ClassName = "java/lang/Long"; |
| std::string newElement_2CtorSignature = "(J)V"; |
| jlong jninewElement_2 = static_cast<jlong>(entry_2); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>( |
| newElement_2ClassName.c_str(), newElement_2CtorSignature.c_str(), jninewElement_2, newElement_2); |
| chip::JniReferences::GetInstance().AddToList(newElement_0_e, newElement_2); |
| } |
| jobject newElement_0_f; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_0_f); |
| |
| auto iter_newElement_0_f_2 = entry_0.f.begin(); |
| while (iter_newElement_0_f_2.Next()) |
| { |
| auto & entry_2 = iter_newElement_0_f_2.GetValue(); |
| jobject newElement_2; |
| jbyteArray newElement_2ByteArray = env->NewByteArray(static_cast<jsize>(entry_2.size())); |
| env->SetByteArrayRegion(newElement_2ByteArray, 0, static_cast<jsize>(entry_2.size()), |
| reinterpret_cast<const jbyte *>(entry_2.data())); |
| newElement_2 = newElement_2ByteArray; |
| chip::JniReferences::GetInstance().AddToList(newElement_0_f, newElement_2); |
| } |
| jobject newElement_0_g; |
| chip::JniReferences::GetInstance().CreateArrayList(newElement_0_g); |
| |
| auto iter_newElement_0_g_2 = entry_0.g.begin(); |
| while (iter_newElement_0_g_2.Next()) |
| { |
| auto & entry_2 = iter_newElement_0_g_2.GetValue(); |
| jobject newElement_2; |
| std::string newElement_2ClassName = "java/lang/Integer"; |
| std::string newElement_2CtorSignature = "(I)V"; |
| jint jninewElement_2 = static_cast<jint>(entry_2); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_2ClassName.c_str(), newElement_2CtorSignature.c_str(), jninewElement_2, newElement_2); |
| chip::JniReferences::GetInstance().AddToList(newElement_0_g, newElement_2); |
| } |
| |
| jclass nestedStructListStructClass_1; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$UnitTestingClusterNestedStructList", nestedStructListStructClass_1); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterNestedStructList"); |
| return; |
| } |
| |
| jmethodID nestedStructListStructCtor_1; |
| err = chip::JniReferences::GetInstance().FindMethod( |
| env, nestedStructListStructClass_1, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Boolean;Lchip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct;Ljava/util/" |
| "ArrayList;Ljava/util/ArrayList;Ljava/util/ArrayList;Ljava/util/ArrayList;)V", |
| &nestedStructListStructCtor_1); |
| if (err != CHIP_NO_ERROR || nestedStructListStructCtor_1 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterNestedStructList constructor"); |
| return; |
| } |
| |
| newElement_0 = env->NewObject(nestedStructListStructClass_1, nestedStructListStructCtor_1, newElement_0_a, newElement_0_b, |
| newElement_0_c, newElement_0_d, newElement_0_e, newElement_0_f, newElement_0_g); |
| chip::JniReferences::GetInstance().AddToList(arg1, newElement_0); |
| } |
| jobject arg2; |
| chip::JniReferences::GetInstance().CreateArrayList(arg2); |
| |
| auto iter_arg2_0 = dataResponse.arg2.begin(); |
| while (iter_arg2_0.Next()) |
| { |
| auto & entry_0 = iter_arg2_0.GetValue(); |
| jobject newElement_0; |
| jobject newElement_0_a; |
| std::string newElement_0_aClassName = "java/lang/Integer"; |
| std::string newElement_0_aCtorSignature = "(I)V"; |
| jint jninewElement_0_a = static_cast<jint>(entry_0.a); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_0_aClassName.c_str(), newElement_0_aCtorSignature.c_str(), jninewElement_0_a, newElement_0_a); |
| jobject newElement_0_b; |
| std::string newElement_0_bClassName = "java/lang/Boolean"; |
| std::string newElement_0_bCtorSignature = "(Z)V"; |
| jboolean jninewElement_0_b = static_cast<jboolean>(entry_0.b); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| newElement_0_bClassName.c_str(), newElement_0_bCtorSignature.c_str(), jninewElement_0_b, newElement_0_b); |
| jobject newElement_0_c; |
| std::string newElement_0_cClassName = "java/lang/Integer"; |
| std::string newElement_0_cCtorSignature = "(I)V"; |
| jint jninewElement_0_c = static_cast<jint>(entry_0.c); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_0_cClassName.c_str(), newElement_0_cCtorSignature.c_str(), jninewElement_0_c, newElement_0_c); |
| jobject newElement_0_d; |
| jbyteArray newElement_0_dByteArray = env->NewByteArray(static_cast<jsize>(entry_0.d.size())); |
| env->SetByteArrayRegion(newElement_0_dByteArray, 0, static_cast<jsize>(entry_0.d.size()), |
| reinterpret_cast<const jbyte *>(entry_0.d.data())); |
| newElement_0_d = newElement_0_dByteArray; |
| jobject newElement_0_e; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.e, newElement_0_e)); |
| jobject newElement_0_f; |
| std::string newElement_0_fClassName = "java/lang/Integer"; |
| std::string newElement_0_fCtorSignature = "(I)V"; |
| jint jninewElement_0_f = static_cast<jint>(entry_0.f.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_0_fClassName.c_str(), newElement_0_fCtorSignature.c_str(), jninewElement_0_f, newElement_0_f); |
| jobject newElement_0_g; |
| std::string newElement_0_gClassName = "java/lang/Float"; |
| std::string newElement_0_gCtorSignature = "(F)V"; |
| jfloat jninewElement_0_g = static_cast<jfloat>(entry_0.g); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jfloat>( |
| newElement_0_gClassName.c_str(), newElement_0_gCtorSignature.c_str(), jninewElement_0_g, newElement_0_g); |
| jobject newElement_0_h; |
| std::string newElement_0_hClassName = "java/lang/Double"; |
| std::string newElement_0_hCtorSignature = "(D)V"; |
| jdouble jninewElement_0_h = static_cast<jdouble>(entry_0.h); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jdouble>( |
| newElement_0_hClassName.c_str(), newElement_0_hCtorSignature.c_str(), jninewElement_0_h, newElement_0_h); |
| |
| jclass simpleStructStructClass_1; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); |
| return; |
| } |
| |
| jmethodID simpleStructStructCtor_1; |
| err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" |
| "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", |
| &simpleStructStructCtor_1); |
| if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); |
| return; |
| } |
| |
| newElement_0 = |
| env->NewObject(simpleStructStructClass_1, simpleStructStructCtor_1, newElement_0_a, newElement_0_b, newElement_0_c, |
| newElement_0_d, newElement_0_e, newElement_0_f, newElement_0_g, newElement_0_h); |
| chip::JniReferences::GetInstance().AddToList(arg2, newElement_0); |
| } |
| jobject arg3; |
| chip::JniReferences::GetInstance().CreateArrayList(arg3); |
| |
| auto iter_arg3_0 = dataResponse.arg3.begin(); |
| while (iter_arg3_0.Next()) |
| { |
| auto & entry_0 = iter_arg3_0.GetValue(); |
| jobject newElement_0; |
| std::string newElement_0ClassName = "java/lang/Integer"; |
| std::string newElement_0CtorSignature = "(I)V"; |
| jint jninewElement_0 = static_cast<jint>(entry_0); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), |
| jninewElement_0, newElement_0); |
| chip::JniReferences::GetInstance().AddToList(arg3, newElement_0); |
| } |
| jobject arg4; |
| chip::JniReferences::GetInstance().CreateArrayList(arg4); |
| |
| auto iter_arg4_0 = dataResponse.arg4.begin(); |
| while (iter_arg4_0.Next()) |
| { |
| auto & entry_0 = iter_arg4_0.GetValue(); |
| jobject newElement_0; |
| std::string newElement_0ClassName = "java/lang/Boolean"; |
| std::string newElement_0CtorSignature = "(Z)V"; |
| jboolean jninewElement_0 = static_cast<jboolean>(entry_0); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), jninewElement_0, newElement_0); |
| chip::JniReferences::GetInstance().AddToList(arg4, newElement_0); |
| } |
| jobject arg5; |
| std::string arg5ClassName = "java/lang/Integer"; |
| std::string arg5CtorSignature = "(I)V"; |
| jint jniarg5 = static_cast<jint>(dataResponse.arg5); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(arg5ClassName.c_str(), arg5CtorSignature.c_str(), jniarg5, arg5); |
| jobject arg6; |
| std::string arg6ClassName = "java/lang/Boolean"; |
| std::string arg6CtorSignature = "(Z)V"; |
| jboolean jniarg6 = static_cast<jboolean>(dataResponse.arg6); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(arg6ClassName.c_str(), arg6CtorSignature.c_str(), jniarg6, arg6); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, arg1, arg2, arg3, arg4, arg5, arg6); |
| } |
| CHIPUnitTestingClusterTestListInt8UReverseResponseCallback::CHIPUnitTestingClusterTestListInt8UReverseResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPUnitTestingClusterTestListInt8UReverseResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestListInt8UReverseResponseCallback::~CHIPUnitTestingClusterTestListInt8UReverseResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestListInt8UReverseResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::TestListInt8UReverseResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestListInt8UReverseResponseCallback, |
| void (*)(CHIPUnitTestingClusterTestListInt8UReverseResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestListInt8UReverseResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestListInt8UReverseResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/ArrayList;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject arg1; |
| chip::JniReferences::GetInstance().CreateArrayList(arg1); |
| |
| auto iter_arg1_0 = dataResponse.arg1.begin(); |
| while (iter_arg1_0.Next()) |
| { |
| auto & entry_0 = iter_arg1_0.GetValue(); |
| jobject newElement_0; |
| std::string newElement_0ClassName = "java/lang/Integer"; |
| std::string newElement_0CtorSignature = "(I)V"; |
| jint jninewElement_0 = static_cast<jint>(entry_0); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), |
| jninewElement_0, newElement_0); |
| chip::JniReferences::GetInstance().AddToList(arg1, newElement_0); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, arg1); |
| } |
| CHIPUnitTestingClusterTestEnumsResponseCallback::CHIPUnitTestingClusterTestEnumsResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPUnitTestingClusterTestEnumsResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestEnumsResponseCallback::~CHIPUnitTestingClusterTestEnumsResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestEnumsResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::TestEnumsResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestEnumsResponseCallback, void (*)(CHIPUnitTestingClusterTestEnumsResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestEnumsResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestEnumsResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/Integer;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject arg1; |
| std::string arg1ClassName = "java/lang/Integer"; |
| std::string arg1CtorSignature = "(I)V"; |
| jint jniarg1 = static_cast<jint>(dataResponse.arg1); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(arg1ClassName.c_str(), arg1CtorSignature.c_str(), jniarg1, arg1); |
| jobject arg2; |
| std::string arg2ClassName = "java/lang/Integer"; |
| std::string arg2CtorSignature = "(I)V"; |
| jint jniarg2 = static_cast<jint>(dataResponse.arg2); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(arg2ClassName.c_str(), arg2CtorSignature.c_str(), jniarg2, arg2); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, arg1, arg2); |
| } |
| CHIPUnitTestingClusterTestNullableOptionalResponseCallback::CHIPUnitTestingClusterTestNullableOptionalResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPUnitTestingClusterTestNullableOptionalResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestNullableOptionalResponseCallback::~CHIPUnitTestingClusterTestNullableOptionalResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestNullableOptionalResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::TestNullableOptionalResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestNullableOptionalResponseCallback, |
| void (*)(CHIPUnitTestingClusterTestNullableOptionalResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestNullableOptionalResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestNullableOptionalResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject wasPresent; |
| std::string wasPresentClassName = "java/lang/Boolean"; |
| std::string wasPresentCtorSignature = "(Z)V"; |
| jboolean jniwasPresent = static_cast<jboolean>(dataResponse.wasPresent); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(wasPresentClassName.c_str(), wasPresentCtorSignature.c_str(), |
| jniwasPresent, wasPresent); |
| jobject wasNull; |
| if (!dataResponse.wasNull.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, wasNull); |
| } |
| else |
| { |
| jobject wasNullInsideOptional; |
| std::string wasNullInsideOptionalClassName = "java/lang/Boolean"; |
| std::string wasNullInsideOptionalCtorSignature = "(Z)V"; |
| jboolean jniwasNullInsideOptional = static_cast<jboolean>(dataResponse.wasNull.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(wasNullInsideOptionalClassName.c_str(), |
| wasNullInsideOptionalCtorSignature.c_str(), |
| jniwasNullInsideOptional, wasNullInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(wasNullInsideOptional, wasNull); |
| } |
| jobject value; |
| if (!dataResponse.value.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, value); |
| } |
| else |
| { |
| jobject valueInsideOptional; |
| std::string valueInsideOptionalClassName = "java/lang/Integer"; |
| std::string valueInsideOptionalCtorSignature = "(I)V"; |
| jint jnivalueInsideOptional = static_cast<jint>(dataResponse.value.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(valueInsideOptionalClassName.c_str(), |
| valueInsideOptionalCtorSignature.c_str(), jnivalueInsideOptional, |
| valueInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(valueInsideOptional, value); |
| } |
| jobject originalValue; |
| if (!dataResponse.originalValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, originalValue); |
| } |
| else |
| { |
| jobject originalValueInsideOptional; |
| if (dataResponse.originalValue.Value().IsNull()) |
| { |
| originalValueInsideOptional = nullptr; |
| } |
| else |
| { |
| std::string originalValueInsideOptionalClassName = "java/lang/Integer"; |
| std::string originalValueInsideOptionalCtorSignature = "(I)V"; |
| jint jnioriginalValueInsideOptional = static_cast<jint>(dataResponse.originalValue.Value().Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(originalValueInsideOptionalClassName.c_str(), |
| originalValueInsideOptionalCtorSignature.c_str(), |
| jnioriginalValueInsideOptional, originalValueInsideOptional); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(originalValueInsideOptional, originalValue); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, wasPresent, wasNull, value, originalValue); |
| } |
| CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback:: |
| CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback:: |
| ~CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::UnitTesting::Commands::TestComplexNullableOptionalResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback, |
| void (*)(CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", |
| "(Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/" |
| "Optional;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/" |
| "Boolean;Ljava/util/Optional;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/" |
| "Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/lang/" |
| "Boolean;Ljava/util/Optional;Ljava/lang/Boolean;Ljava/util/Optional;Ljava/util/Optional;)V", |
| &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject NullableIntWasNull; |
| std::string NullableIntWasNullClassName = "java/lang/Boolean"; |
| std::string NullableIntWasNullCtorSignature = "(Z)V"; |
| jboolean jniNullableIntWasNull = static_cast<jboolean>(dataResponse.nullableIntWasNull); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| NullableIntWasNullClassName.c_str(), NullableIntWasNullCtorSignature.c_str(), jniNullableIntWasNull, NullableIntWasNull); |
| jobject NullableIntValue; |
| if (!dataResponse.nullableIntValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableIntValue); |
| } |
| else |
| { |
| jobject NullableIntValueInsideOptional; |
| std::string NullableIntValueInsideOptionalClassName = "java/lang/Integer"; |
| std::string NullableIntValueInsideOptionalCtorSignature = "(I)V"; |
| jint jniNullableIntValueInsideOptional = static_cast<jint>(dataResponse.nullableIntValue.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| NullableIntValueInsideOptionalClassName.c_str(), NullableIntValueInsideOptionalCtorSignature.c_str(), |
| jniNullableIntValueInsideOptional, NullableIntValueInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(NullableIntValueInsideOptional, NullableIntValue); |
| } |
| jobject OptionalIntWasPresent; |
| std::string OptionalIntWasPresentClassName = "java/lang/Boolean"; |
| std::string OptionalIntWasPresentCtorSignature = "(Z)V"; |
| jboolean jniOptionalIntWasPresent = static_cast<jboolean>(dataResponse.optionalIntWasPresent); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(OptionalIntWasPresentClassName.c_str(), |
| OptionalIntWasPresentCtorSignature.c_str(), |
| jniOptionalIntWasPresent, OptionalIntWasPresent); |
| jobject OptionalIntValue; |
| if (!dataResponse.optionalIntValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalIntValue); |
| } |
| else |
| { |
| jobject OptionalIntValueInsideOptional; |
| std::string OptionalIntValueInsideOptionalClassName = "java/lang/Integer"; |
| std::string OptionalIntValueInsideOptionalCtorSignature = "(I)V"; |
| jint jniOptionalIntValueInsideOptional = static_cast<jint>(dataResponse.optionalIntValue.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| OptionalIntValueInsideOptionalClassName.c_str(), OptionalIntValueInsideOptionalCtorSignature.c_str(), |
| jniOptionalIntValueInsideOptional, OptionalIntValueInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(OptionalIntValueInsideOptional, OptionalIntValue); |
| } |
| jobject NullableOptionalIntWasPresent; |
| std::string NullableOptionalIntWasPresentClassName = "java/lang/Boolean"; |
| std::string NullableOptionalIntWasPresentCtorSignature = "(Z)V"; |
| jboolean jniNullableOptionalIntWasPresent = static_cast<jboolean>(dataResponse.nullableOptionalIntWasPresent); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(NullableOptionalIntWasPresentClassName.c_str(), |
| NullableOptionalIntWasPresentCtorSignature.c_str(), |
| jniNullableOptionalIntWasPresent, NullableOptionalIntWasPresent); |
| jobject NullableOptionalIntWasNull; |
| if (!dataResponse.nullableOptionalIntWasNull.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalIntWasNull); |
| } |
| else |
| { |
| jobject NullableOptionalIntWasNullInsideOptional; |
| std::string NullableOptionalIntWasNullInsideOptionalClassName = "java/lang/Boolean"; |
| std::string NullableOptionalIntWasNullInsideOptionalCtorSignature = "(Z)V"; |
| jboolean jniNullableOptionalIntWasNullInsideOptional = |
| static_cast<jboolean>(dataResponse.nullableOptionalIntWasNull.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| NullableOptionalIntWasNullInsideOptionalClassName.c_str(), |
| NullableOptionalIntWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalIntWasNullInsideOptional, |
| NullableOptionalIntWasNullInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(NullableOptionalIntWasNullInsideOptional, NullableOptionalIntWasNull); |
| } |
| jobject NullableOptionalIntValue; |
| if (!dataResponse.nullableOptionalIntValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalIntValue); |
| } |
| else |
| { |
| jobject NullableOptionalIntValueInsideOptional; |
| std::string NullableOptionalIntValueInsideOptionalClassName = "java/lang/Integer"; |
| std::string NullableOptionalIntValueInsideOptionalCtorSignature = "(I)V"; |
| jint jniNullableOptionalIntValueInsideOptional = static_cast<jint>(dataResponse.nullableOptionalIntValue.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| NullableOptionalIntValueInsideOptionalClassName.c_str(), NullableOptionalIntValueInsideOptionalCtorSignature.c_str(), |
| jniNullableOptionalIntValueInsideOptional, NullableOptionalIntValueInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(NullableOptionalIntValueInsideOptional, NullableOptionalIntValue); |
| } |
| jobject NullableStringWasNull; |
| std::string NullableStringWasNullClassName = "java/lang/Boolean"; |
| std::string NullableStringWasNullCtorSignature = "(Z)V"; |
| jboolean jniNullableStringWasNull = static_cast<jboolean>(dataResponse.nullableStringWasNull); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(NullableStringWasNullClassName.c_str(), |
| NullableStringWasNullCtorSignature.c_str(), |
| jniNullableStringWasNull, NullableStringWasNull); |
| jobject NullableStringValue; |
| if (!dataResponse.nullableStringValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableStringValue); |
| } |
| else |
| { |
| jobject NullableStringValueInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableStringValue.Value(), |
| NullableStringValueInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(NullableStringValueInsideOptional, NullableStringValue); |
| } |
| jobject OptionalStringWasPresent; |
| std::string OptionalStringWasPresentClassName = "java/lang/Boolean"; |
| std::string OptionalStringWasPresentCtorSignature = "(Z)V"; |
| jboolean jniOptionalStringWasPresent = static_cast<jboolean>(dataResponse.optionalStringWasPresent); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(OptionalStringWasPresentClassName.c_str(), |
| OptionalStringWasPresentCtorSignature.c_str(), |
| jniOptionalStringWasPresent, OptionalStringWasPresent); |
| jobject OptionalStringValue; |
| if (!dataResponse.optionalStringValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalStringValue); |
| } |
| else |
| { |
| jobject OptionalStringValueInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.optionalStringValue.Value(), |
| OptionalStringValueInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(OptionalStringValueInsideOptional, OptionalStringValue); |
| } |
| jobject NullableOptionalStringWasPresent; |
| std::string NullableOptionalStringWasPresentClassName = "java/lang/Boolean"; |
| std::string NullableOptionalStringWasPresentCtorSignature = "(Z)V"; |
| jboolean jniNullableOptionalStringWasPresent = static_cast<jboolean>(dataResponse.nullableOptionalStringWasPresent); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| NullableOptionalStringWasPresentClassName.c_str(), NullableOptionalStringWasPresentCtorSignature.c_str(), |
| jniNullableOptionalStringWasPresent, NullableOptionalStringWasPresent); |
| jobject NullableOptionalStringWasNull; |
| if (!dataResponse.nullableOptionalStringWasNull.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStringWasNull); |
| } |
| else |
| { |
| jobject NullableOptionalStringWasNullInsideOptional; |
| std::string NullableOptionalStringWasNullInsideOptionalClassName = "java/lang/Boolean"; |
| std::string NullableOptionalStringWasNullInsideOptionalCtorSignature = "(Z)V"; |
| jboolean jniNullableOptionalStringWasNullInsideOptional = |
| static_cast<jboolean>(dataResponse.nullableOptionalStringWasNull.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| NullableOptionalStringWasNullInsideOptionalClassName.c_str(), |
| NullableOptionalStringWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalStringWasNullInsideOptional, |
| NullableOptionalStringWasNullInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStringWasNullInsideOptional, |
| NullableOptionalStringWasNull); |
| } |
| jobject NullableOptionalStringValue; |
| if (!dataResponse.nullableOptionalStringValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStringValue); |
| } |
| else |
| { |
| jobject NullableOptionalStringValueInsideOptional; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableOptionalStringValue.Value(), |
| NullableOptionalStringValueInsideOptional)); |
| chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStringValueInsideOptional, NullableOptionalStringValue); |
| } |
| jobject NullableStructWasNull; |
| std::string NullableStructWasNullClassName = "java/lang/Boolean"; |
| std::string NullableStructWasNullCtorSignature = "(Z)V"; |
| jboolean jniNullableStructWasNull = static_cast<jboolean>(dataResponse.nullableStructWasNull); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(NullableStructWasNullClassName.c_str(), |
| NullableStructWasNullCtorSignature.c_str(), |
| jniNullableStructWasNull, NullableStructWasNull); |
| jobject NullableStructValue; |
| if (!dataResponse.nullableStructValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableStructValue); |
| } |
| else |
| { |
| jobject NullableStructValueInsideOptional; |
| jobject NullableStructValueInsideOptional_a; |
| std::string NullableStructValueInsideOptional_aClassName = "java/lang/Integer"; |
| std::string NullableStructValueInsideOptional_aCtorSignature = "(I)V"; |
| jint jniNullableStructValueInsideOptional_a = static_cast<jint>(dataResponse.nullableStructValue.Value().a); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| NullableStructValueInsideOptional_aClassName.c_str(), NullableStructValueInsideOptional_aCtorSignature.c_str(), |
| jniNullableStructValueInsideOptional_a, NullableStructValueInsideOptional_a); |
| jobject NullableStructValueInsideOptional_b; |
| std::string NullableStructValueInsideOptional_bClassName = "java/lang/Boolean"; |
| std::string NullableStructValueInsideOptional_bCtorSignature = "(Z)V"; |
| jboolean jniNullableStructValueInsideOptional_b = static_cast<jboolean>(dataResponse.nullableStructValue.Value().b); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| NullableStructValueInsideOptional_bClassName.c_str(), NullableStructValueInsideOptional_bCtorSignature.c_str(), |
| jniNullableStructValueInsideOptional_b, NullableStructValueInsideOptional_b); |
| jobject NullableStructValueInsideOptional_c; |
| std::string NullableStructValueInsideOptional_cClassName = "java/lang/Integer"; |
| std::string NullableStructValueInsideOptional_cCtorSignature = "(I)V"; |
| jint jniNullableStructValueInsideOptional_c = static_cast<jint>(dataResponse.nullableStructValue.Value().c); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| NullableStructValueInsideOptional_cClassName.c_str(), NullableStructValueInsideOptional_cCtorSignature.c_str(), |
| jniNullableStructValueInsideOptional_c, NullableStructValueInsideOptional_c); |
| jobject NullableStructValueInsideOptional_d; |
| jbyteArray NullableStructValueInsideOptional_dByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.nullableStructValue.Value().d.size())); |
| env->SetByteArrayRegion(NullableStructValueInsideOptional_dByteArray, 0, |
| static_cast<jsize>(dataResponse.nullableStructValue.Value().d.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.nullableStructValue.Value().d.data())); |
| NullableStructValueInsideOptional_d = NullableStructValueInsideOptional_dByteArray; |
| jobject NullableStructValueInsideOptional_e; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableStructValue.Value().e, |
| NullableStructValueInsideOptional_e)); |
| jobject NullableStructValueInsideOptional_f; |
| std::string NullableStructValueInsideOptional_fClassName = "java/lang/Integer"; |
| std::string NullableStructValueInsideOptional_fCtorSignature = "(I)V"; |
| jint jniNullableStructValueInsideOptional_f = static_cast<jint>(dataResponse.nullableStructValue.Value().f.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| NullableStructValueInsideOptional_fClassName.c_str(), NullableStructValueInsideOptional_fCtorSignature.c_str(), |
| jniNullableStructValueInsideOptional_f, NullableStructValueInsideOptional_f); |
| jobject NullableStructValueInsideOptional_g; |
| std::string NullableStructValueInsideOptional_gClassName = "java/lang/Float"; |
| std::string NullableStructValueInsideOptional_gCtorSignature = "(F)V"; |
| jfloat jniNullableStructValueInsideOptional_g = static_cast<jfloat>(dataResponse.nullableStructValue.Value().g); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jfloat>( |
| NullableStructValueInsideOptional_gClassName.c_str(), NullableStructValueInsideOptional_gCtorSignature.c_str(), |
| jniNullableStructValueInsideOptional_g, NullableStructValueInsideOptional_g); |
| jobject NullableStructValueInsideOptional_h; |
| std::string NullableStructValueInsideOptional_hClassName = "java/lang/Double"; |
| std::string NullableStructValueInsideOptional_hCtorSignature = "(D)V"; |
| jdouble jniNullableStructValueInsideOptional_h = static_cast<jdouble>(dataResponse.nullableStructValue.Value().h); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jdouble>( |
| NullableStructValueInsideOptional_hClassName.c_str(), NullableStructValueInsideOptional_hCtorSignature.c_str(), |
| jniNullableStructValueInsideOptional_h, NullableStructValueInsideOptional_h); |
| |
| jclass simpleStructStructClass_1; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); |
| return; |
| } |
| |
| jmethodID simpleStructStructCtor_1; |
| err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" |
| "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", |
| &simpleStructStructCtor_1); |
| if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); |
| return; |
| } |
| |
| NullableStructValueInsideOptional = env->NewObject( |
| simpleStructStructClass_1, simpleStructStructCtor_1, NullableStructValueInsideOptional_a, |
| NullableStructValueInsideOptional_b, NullableStructValueInsideOptional_c, NullableStructValueInsideOptional_d, |
| NullableStructValueInsideOptional_e, NullableStructValueInsideOptional_f, NullableStructValueInsideOptional_g, |
| NullableStructValueInsideOptional_h); |
| chip::JniReferences::GetInstance().CreateOptional(NullableStructValueInsideOptional, NullableStructValue); |
| } |
| jobject OptionalStructWasPresent; |
| std::string OptionalStructWasPresentClassName = "java/lang/Boolean"; |
| std::string OptionalStructWasPresentCtorSignature = "(Z)V"; |
| jboolean jniOptionalStructWasPresent = static_cast<jboolean>(dataResponse.optionalStructWasPresent); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(OptionalStructWasPresentClassName.c_str(), |
| OptionalStructWasPresentCtorSignature.c_str(), |
| jniOptionalStructWasPresent, OptionalStructWasPresent); |
| jobject OptionalStructValue; |
| if (!dataResponse.optionalStructValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalStructValue); |
| } |
| else |
| { |
| jobject OptionalStructValueInsideOptional; |
| jobject OptionalStructValueInsideOptional_a; |
| std::string OptionalStructValueInsideOptional_aClassName = "java/lang/Integer"; |
| std::string OptionalStructValueInsideOptional_aCtorSignature = "(I)V"; |
| jint jniOptionalStructValueInsideOptional_a = static_cast<jint>(dataResponse.optionalStructValue.Value().a); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| OptionalStructValueInsideOptional_aClassName.c_str(), OptionalStructValueInsideOptional_aCtorSignature.c_str(), |
| jniOptionalStructValueInsideOptional_a, OptionalStructValueInsideOptional_a); |
| jobject OptionalStructValueInsideOptional_b; |
| std::string OptionalStructValueInsideOptional_bClassName = "java/lang/Boolean"; |
| std::string OptionalStructValueInsideOptional_bCtorSignature = "(Z)V"; |
| jboolean jniOptionalStructValueInsideOptional_b = static_cast<jboolean>(dataResponse.optionalStructValue.Value().b); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| OptionalStructValueInsideOptional_bClassName.c_str(), OptionalStructValueInsideOptional_bCtorSignature.c_str(), |
| jniOptionalStructValueInsideOptional_b, OptionalStructValueInsideOptional_b); |
| jobject OptionalStructValueInsideOptional_c; |
| std::string OptionalStructValueInsideOptional_cClassName = "java/lang/Integer"; |
| std::string OptionalStructValueInsideOptional_cCtorSignature = "(I)V"; |
| jint jniOptionalStructValueInsideOptional_c = static_cast<jint>(dataResponse.optionalStructValue.Value().c); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| OptionalStructValueInsideOptional_cClassName.c_str(), OptionalStructValueInsideOptional_cCtorSignature.c_str(), |
| jniOptionalStructValueInsideOptional_c, OptionalStructValueInsideOptional_c); |
| jobject OptionalStructValueInsideOptional_d; |
| jbyteArray OptionalStructValueInsideOptional_dByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.optionalStructValue.Value().d.size())); |
| env->SetByteArrayRegion(OptionalStructValueInsideOptional_dByteArray, 0, |
| static_cast<jsize>(dataResponse.optionalStructValue.Value().d.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.optionalStructValue.Value().d.data())); |
| OptionalStructValueInsideOptional_d = OptionalStructValueInsideOptional_dByteArray; |
| jobject OptionalStructValueInsideOptional_e; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.optionalStructValue.Value().e, |
| OptionalStructValueInsideOptional_e)); |
| jobject OptionalStructValueInsideOptional_f; |
| std::string OptionalStructValueInsideOptional_fClassName = "java/lang/Integer"; |
| std::string OptionalStructValueInsideOptional_fCtorSignature = "(I)V"; |
| jint jniOptionalStructValueInsideOptional_f = static_cast<jint>(dataResponse.optionalStructValue.Value().f.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| OptionalStructValueInsideOptional_fClassName.c_str(), OptionalStructValueInsideOptional_fCtorSignature.c_str(), |
| jniOptionalStructValueInsideOptional_f, OptionalStructValueInsideOptional_f); |
| jobject OptionalStructValueInsideOptional_g; |
| std::string OptionalStructValueInsideOptional_gClassName = "java/lang/Float"; |
| std::string OptionalStructValueInsideOptional_gCtorSignature = "(F)V"; |
| jfloat jniOptionalStructValueInsideOptional_g = static_cast<jfloat>(dataResponse.optionalStructValue.Value().g); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jfloat>( |
| OptionalStructValueInsideOptional_gClassName.c_str(), OptionalStructValueInsideOptional_gCtorSignature.c_str(), |
| jniOptionalStructValueInsideOptional_g, OptionalStructValueInsideOptional_g); |
| jobject OptionalStructValueInsideOptional_h; |
| std::string OptionalStructValueInsideOptional_hClassName = "java/lang/Double"; |
| std::string OptionalStructValueInsideOptional_hCtorSignature = "(D)V"; |
| jdouble jniOptionalStructValueInsideOptional_h = static_cast<jdouble>(dataResponse.optionalStructValue.Value().h); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jdouble>( |
| OptionalStructValueInsideOptional_hClassName.c_str(), OptionalStructValueInsideOptional_hCtorSignature.c_str(), |
| jniOptionalStructValueInsideOptional_h, OptionalStructValueInsideOptional_h); |
| |
| jclass simpleStructStructClass_1; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); |
| return; |
| } |
| |
| jmethodID simpleStructStructCtor_1; |
| err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" |
| "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", |
| &simpleStructStructCtor_1); |
| if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); |
| return; |
| } |
| |
| OptionalStructValueInsideOptional = env->NewObject( |
| simpleStructStructClass_1, simpleStructStructCtor_1, OptionalStructValueInsideOptional_a, |
| OptionalStructValueInsideOptional_b, OptionalStructValueInsideOptional_c, OptionalStructValueInsideOptional_d, |
| OptionalStructValueInsideOptional_e, OptionalStructValueInsideOptional_f, OptionalStructValueInsideOptional_g, |
| OptionalStructValueInsideOptional_h); |
| chip::JniReferences::GetInstance().CreateOptional(OptionalStructValueInsideOptional, OptionalStructValue); |
| } |
| jobject NullableOptionalStructWasPresent; |
| std::string NullableOptionalStructWasPresentClassName = "java/lang/Boolean"; |
| std::string NullableOptionalStructWasPresentCtorSignature = "(Z)V"; |
| jboolean jniNullableOptionalStructWasPresent = static_cast<jboolean>(dataResponse.nullableOptionalStructWasPresent); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| NullableOptionalStructWasPresentClassName.c_str(), NullableOptionalStructWasPresentCtorSignature.c_str(), |
| jniNullableOptionalStructWasPresent, NullableOptionalStructWasPresent); |
| jobject NullableOptionalStructWasNull; |
| if (!dataResponse.nullableOptionalStructWasNull.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStructWasNull); |
| } |
| else |
| { |
| jobject NullableOptionalStructWasNullInsideOptional; |
| std::string NullableOptionalStructWasNullInsideOptionalClassName = "java/lang/Boolean"; |
| std::string NullableOptionalStructWasNullInsideOptionalCtorSignature = "(Z)V"; |
| jboolean jniNullableOptionalStructWasNullInsideOptional = |
| static_cast<jboolean>(dataResponse.nullableOptionalStructWasNull.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| NullableOptionalStructWasNullInsideOptionalClassName.c_str(), |
| NullableOptionalStructWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalStructWasNullInsideOptional, |
| NullableOptionalStructWasNullInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStructWasNullInsideOptional, |
| NullableOptionalStructWasNull); |
| } |
| jobject NullableOptionalStructValue; |
| if (!dataResponse.nullableOptionalStructValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalStructValue); |
| } |
| else |
| { |
| jobject NullableOptionalStructValueInsideOptional; |
| jobject NullableOptionalStructValueInsideOptional_a; |
| std::string NullableOptionalStructValueInsideOptional_aClassName = "java/lang/Integer"; |
| std::string NullableOptionalStructValueInsideOptional_aCtorSignature = "(I)V"; |
| jint jniNullableOptionalStructValueInsideOptional_a = static_cast<jint>(dataResponse.nullableOptionalStructValue.Value().a); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(NullableOptionalStructValueInsideOptional_aClassName.c_str(), |
| NullableOptionalStructValueInsideOptional_aCtorSignature.c_str(), |
| jniNullableOptionalStructValueInsideOptional_a, |
| NullableOptionalStructValueInsideOptional_a); |
| jobject NullableOptionalStructValueInsideOptional_b; |
| std::string NullableOptionalStructValueInsideOptional_bClassName = "java/lang/Boolean"; |
| std::string NullableOptionalStructValueInsideOptional_bCtorSignature = "(Z)V"; |
| jboolean jniNullableOptionalStructValueInsideOptional_b = |
| static_cast<jboolean>(dataResponse.nullableOptionalStructValue.Value().b); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| NullableOptionalStructValueInsideOptional_bClassName.c_str(), |
| NullableOptionalStructValueInsideOptional_bCtorSignature.c_str(), jniNullableOptionalStructValueInsideOptional_b, |
| NullableOptionalStructValueInsideOptional_b); |
| jobject NullableOptionalStructValueInsideOptional_c; |
| std::string NullableOptionalStructValueInsideOptional_cClassName = "java/lang/Integer"; |
| std::string NullableOptionalStructValueInsideOptional_cCtorSignature = "(I)V"; |
| jint jniNullableOptionalStructValueInsideOptional_c = static_cast<jint>(dataResponse.nullableOptionalStructValue.Value().c); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(NullableOptionalStructValueInsideOptional_cClassName.c_str(), |
| NullableOptionalStructValueInsideOptional_cCtorSignature.c_str(), |
| jniNullableOptionalStructValueInsideOptional_c, |
| NullableOptionalStructValueInsideOptional_c); |
| jobject NullableOptionalStructValueInsideOptional_d; |
| jbyteArray NullableOptionalStructValueInsideOptional_dByteArray = |
| env->NewByteArray(static_cast<jsize>(dataResponse.nullableOptionalStructValue.Value().d.size())); |
| env->SetByteArrayRegion(NullableOptionalStructValueInsideOptional_dByteArray, 0, |
| static_cast<jsize>(dataResponse.nullableOptionalStructValue.Value().d.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.nullableOptionalStructValue.Value().d.data())); |
| NullableOptionalStructValueInsideOptional_d = NullableOptionalStructValueInsideOptional_dByteArray; |
| jobject NullableOptionalStructValueInsideOptional_e; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableOptionalStructValue.Value().e, |
| NullableOptionalStructValueInsideOptional_e)); |
| jobject NullableOptionalStructValueInsideOptional_f; |
| std::string NullableOptionalStructValueInsideOptional_fClassName = "java/lang/Integer"; |
| std::string NullableOptionalStructValueInsideOptional_fCtorSignature = "(I)V"; |
| jint jniNullableOptionalStructValueInsideOptional_f = |
| static_cast<jint>(dataResponse.nullableOptionalStructValue.Value().f.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(NullableOptionalStructValueInsideOptional_fClassName.c_str(), |
| NullableOptionalStructValueInsideOptional_fCtorSignature.c_str(), |
| jniNullableOptionalStructValueInsideOptional_f, |
| NullableOptionalStructValueInsideOptional_f); |
| jobject NullableOptionalStructValueInsideOptional_g; |
| std::string NullableOptionalStructValueInsideOptional_gClassName = "java/lang/Float"; |
| std::string NullableOptionalStructValueInsideOptional_gCtorSignature = "(F)V"; |
| jfloat jniNullableOptionalStructValueInsideOptional_g = |
| static_cast<jfloat>(dataResponse.nullableOptionalStructValue.Value().g); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jfloat>( |
| NullableOptionalStructValueInsideOptional_gClassName.c_str(), |
| NullableOptionalStructValueInsideOptional_gCtorSignature.c_str(), jniNullableOptionalStructValueInsideOptional_g, |
| NullableOptionalStructValueInsideOptional_g); |
| jobject NullableOptionalStructValueInsideOptional_h; |
| std::string NullableOptionalStructValueInsideOptional_hClassName = "java/lang/Double"; |
| std::string NullableOptionalStructValueInsideOptional_hCtorSignature = "(D)V"; |
| jdouble jniNullableOptionalStructValueInsideOptional_h = |
| static_cast<jdouble>(dataResponse.nullableOptionalStructValue.Value().h); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jdouble>( |
| NullableOptionalStructValueInsideOptional_hClassName.c_str(), |
| NullableOptionalStructValueInsideOptional_hCtorSignature.c_str(), jniNullableOptionalStructValueInsideOptional_h, |
| NullableOptionalStructValueInsideOptional_h); |
| |
| jclass simpleStructStructClass_1; |
| err = chip::JniReferences::GetInstance().GetClassRef( |
| env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", simpleStructStructClass_1); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); |
| return; |
| } |
| |
| jmethodID simpleStructStructCtor_1; |
| err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_1, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/" |
| "lang/String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", |
| &simpleStructStructCtor_1); |
| if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); |
| return; |
| } |
| |
| NullableOptionalStructValueInsideOptional = |
| env->NewObject(simpleStructStructClass_1, simpleStructStructCtor_1, NullableOptionalStructValueInsideOptional_a, |
| NullableOptionalStructValueInsideOptional_b, NullableOptionalStructValueInsideOptional_c, |
| NullableOptionalStructValueInsideOptional_d, NullableOptionalStructValueInsideOptional_e, |
| NullableOptionalStructValueInsideOptional_f, NullableOptionalStructValueInsideOptional_g, |
| NullableOptionalStructValueInsideOptional_h); |
| chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStructValueInsideOptional, NullableOptionalStructValue); |
| } |
| jobject NullableListWasNull; |
| std::string NullableListWasNullClassName = "java/lang/Boolean"; |
| std::string NullableListWasNullCtorSignature = "(Z)V"; |
| jboolean jniNullableListWasNull = static_cast<jboolean>(dataResponse.nullableListWasNull); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(NullableListWasNullClassName.c_str(), |
| NullableListWasNullCtorSignature.c_str(), jniNullableListWasNull, |
| NullableListWasNull); |
| jobject NullableListValue; |
| if (!dataResponse.nullableListValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableListValue); |
| } |
| else |
| { |
| jobject NullableListValueInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(NullableListValueInsideOptional); |
| |
| auto iter_NullableListValueInsideOptional_1 = dataResponse.nullableListValue.Value().begin(); |
| while (iter_NullableListValueInsideOptional_1.Next()) |
| { |
| auto & entry_1 = iter_NullableListValueInsideOptional_1.GetValue(); |
| jobject newElement_1; |
| std::string newElement_1ClassName = "java/lang/Integer"; |
| std::string newElement_1CtorSignature = "(I)V"; |
| jint jninewElement_1 = static_cast<jint>(entry_1); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); |
| chip::JniReferences::GetInstance().AddToList(NullableListValueInsideOptional, newElement_1); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(NullableListValueInsideOptional, NullableListValue); |
| } |
| jobject OptionalListWasPresent; |
| std::string OptionalListWasPresentClassName = "java/lang/Boolean"; |
| std::string OptionalListWasPresentCtorSignature = "(Z)V"; |
| jboolean jniOptionalListWasPresent = static_cast<jboolean>(dataResponse.optionalListWasPresent); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(OptionalListWasPresentClassName.c_str(), |
| OptionalListWasPresentCtorSignature.c_str(), |
| jniOptionalListWasPresent, OptionalListWasPresent); |
| jobject OptionalListValue; |
| if (!dataResponse.optionalListValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, OptionalListValue); |
| } |
| else |
| { |
| jobject OptionalListValueInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(OptionalListValueInsideOptional); |
| |
| auto iter_OptionalListValueInsideOptional_1 = dataResponse.optionalListValue.Value().begin(); |
| while (iter_OptionalListValueInsideOptional_1.Next()) |
| { |
| auto & entry_1 = iter_OptionalListValueInsideOptional_1.GetValue(); |
| jobject newElement_1; |
| std::string newElement_1ClassName = "java/lang/Integer"; |
| std::string newElement_1CtorSignature = "(I)V"; |
| jint jninewElement_1 = static_cast<jint>(entry_1); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); |
| chip::JniReferences::GetInstance().AddToList(OptionalListValueInsideOptional, newElement_1); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(OptionalListValueInsideOptional, OptionalListValue); |
| } |
| jobject NullableOptionalListWasPresent; |
| std::string NullableOptionalListWasPresentClassName = "java/lang/Boolean"; |
| std::string NullableOptionalListWasPresentCtorSignature = "(Z)V"; |
| jboolean jniNullableOptionalListWasPresent = static_cast<jboolean>(dataResponse.nullableOptionalListWasPresent); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| NullableOptionalListWasPresentClassName.c_str(), NullableOptionalListWasPresentCtorSignature.c_str(), |
| jniNullableOptionalListWasPresent, NullableOptionalListWasPresent); |
| jobject NullableOptionalListWasNull; |
| if (!dataResponse.nullableOptionalListWasNull.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalListWasNull); |
| } |
| else |
| { |
| jobject NullableOptionalListWasNullInsideOptional; |
| std::string NullableOptionalListWasNullInsideOptionalClassName = "java/lang/Boolean"; |
| std::string NullableOptionalListWasNullInsideOptionalCtorSignature = "(Z)V"; |
| jboolean jniNullableOptionalListWasNullInsideOptional = |
| static_cast<jboolean>(dataResponse.nullableOptionalListWasNull.Value()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>( |
| NullableOptionalListWasNullInsideOptionalClassName.c_str(), |
| NullableOptionalListWasNullInsideOptionalCtorSignature.c_str(), jniNullableOptionalListWasNullInsideOptional, |
| NullableOptionalListWasNullInsideOptional); |
| chip::JniReferences::GetInstance().CreateOptional(NullableOptionalListWasNullInsideOptional, NullableOptionalListWasNull); |
| } |
| jobject NullableOptionalListValue; |
| if (!dataResponse.nullableOptionalListValue.HasValue()) |
| { |
| chip::JniReferences::GetInstance().CreateOptional(nullptr, NullableOptionalListValue); |
| } |
| else |
| { |
| jobject NullableOptionalListValueInsideOptional; |
| chip::JniReferences::GetInstance().CreateArrayList(NullableOptionalListValueInsideOptional); |
| |
| auto iter_NullableOptionalListValueInsideOptional_1 = dataResponse.nullableOptionalListValue.Value().begin(); |
| while (iter_NullableOptionalListValueInsideOptional_1.Next()) |
| { |
| auto & entry_1 = iter_NullableOptionalListValueInsideOptional_1.GetValue(); |
| jobject newElement_1; |
| std::string newElement_1ClassName = "java/lang/Integer"; |
| std::string newElement_1CtorSignature = "(I)V"; |
| jint jninewElement_1 = static_cast<jint>(entry_1); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>( |
| newElement_1ClassName.c_str(), newElement_1CtorSignature.c_str(), jninewElement_1, newElement_1); |
| chip::JniReferences::GetInstance().AddToList(NullableOptionalListValueInsideOptional, newElement_1); |
| } |
| chip::JniReferences::GetInstance().CreateOptional(NullableOptionalListValueInsideOptional, NullableOptionalListValue); |
| } |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, NullableIntWasNull, NullableIntValue, OptionalIntWasPresent, OptionalIntValue, |
| NullableOptionalIntWasPresent, NullableOptionalIntWasNull, NullableOptionalIntValue, NullableStringWasNull, |
| NullableStringValue, OptionalStringWasPresent, OptionalStringValue, NullableOptionalStringWasPresent, |
| NullableOptionalStringWasNull, NullableOptionalStringValue, NullableStructWasNull, NullableStructValue, |
| OptionalStructWasPresent, OptionalStructValue, NullableOptionalStructWasPresent, |
| NullableOptionalStructWasNull, NullableOptionalStructValue, NullableListWasNull, NullableListValue, |
| OptionalListWasPresent, OptionalListValue, NullableOptionalListWasPresent, NullableOptionalListWasNull, |
| NullableOptionalListValue); |
| } |
| CHIPUnitTestingClusterBooleanResponseCallback::CHIPUnitTestingClusterBooleanResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPUnitTestingClusterBooleanResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterBooleanResponseCallback::~CHIPUnitTestingClusterBooleanResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterBooleanResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::BooleanResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterBooleanResponseCallback, void (*)(CHIPUnitTestingClusterBooleanResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterBooleanResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterBooleanResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject value; |
| std::string valueClassName = "java/lang/Boolean"; |
| std::string valueCtorSignature = "(Z)V"; |
| jboolean jnivalue = static_cast<jboolean>(dataResponse.value); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, |
| value); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, value); |
| } |
| CHIPUnitTestingClusterSimpleStructResponseCallback::CHIPUnitTestingClusterSimpleStructResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPUnitTestingClusterSimpleStructResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterSimpleStructResponseCallback::~CHIPUnitTestingClusterSimpleStructResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterSimpleStructResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::SimpleStructResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterSimpleStructResponseCallback, |
| void (*)(CHIPUnitTestingClusterSimpleStructResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterSimpleStructResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterSimpleStructResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod( |
| env, javaCallbackRef, "onSuccess", "(Lchip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject arg1; |
| jobject arg1_a; |
| std::string arg1_aClassName = "java/lang/Integer"; |
| std::string arg1_aCtorSignature = "(I)V"; |
| jint jniarg1_a = static_cast<jint>(dataResponse.arg1.a); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(arg1_aClassName.c_str(), arg1_aCtorSignature.c_str(), jniarg1_a, |
| arg1_a); |
| jobject arg1_b; |
| std::string arg1_bClassName = "java/lang/Boolean"; |
| std::string arg1_bCtorSignature = "(Z)V"; |
| jboolean jniarg1_b = static_cast<jboolean>(dataResponse.arg1.b); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jboolean>(arg1_bClassName.c_str(), arg1_bCtorSignature.c_str(), jniarg1_b, |
| arg1_b); |
| jobject arg1_c; |
| std::string arg1_cClassName = "java/lang/Integer"; |
| std::string arg1_cCtorSignature = "(I)V"; |
| jint jniarg1_c = static_cast<jint>(dataResponse.arg1.c); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(arg1_cClassName.c_str(), arg1_cCtorSignature.c_str(), jniarg1_c, |
| arg1_c); |
| jobject arg1_d; |
| jbyteArray arg1_dByteArray = env->NewByteArray(static_cast<jsize>(dataResponse.arg1.d.size())); |
| env->SetByteArrayRegion(arg1_dByteArray, 0, static_cast<jsize>(dataResponse.arg1.d.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.arg1.d.data())); |
| arg1_d = arg1_dByteArray; |
| jobject arg1_e; |
| LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.arg1.e, arg1_e)); |
| jobject arg1_f; |
| std::string arg1_fClassName = "java/lang/Integer"; |
| std::string arg1_fCtorSignature = "(I)V"; |
| jint jniarg1_f = static_cast<jint>(dataResponse.arg1.f.Raw()); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(arg1_fClassName.c_str(), arg1_fCtorSignature.c_str(), jniarg1_f, |
| arg1_f); |
| jobject arg1_g; |
| std::string arg1_gClassName = "java/lang/Float"; |
| std::string arg1_gCtorSignature = "(F)V"; |
| jfloat jniarg1_g = static_cast<jfloat>(dataResponse.arg1.g); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jfloat>(arg1_gClassName.c_str(), arg1_gCtorSignature.c_str(), jniarg1_g, |
| arg1_g); |
| jobject arg1_h; |
| std::string arg1_hClassName = "java/lang/Double"; |
| std::string arg1_hCtorSignature = "(D)V"; |
| jdouble jniarg1_h = static_cast<jdouble>(dataResponse.arg1.h); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jdouble>(arg1_hClassName.c_str(), arg1_hCtorSignature.c_str(), jniarg1_h, |
| arg1_h); |
| |
| jclass simpleStructStructClass_0; |
| err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$UnitTestingClusterSimpleStruct", |
| simpleStructStructClass_0); |
| if (err != CHIP_NO_ERROR) |
| { |
| ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterSimpleStruct"); |
| return; |
| } |
| |
| jmethodID simpleStructStructCtor_0; |
| err = chip::JniReferences::GetInstance().FindMethod(env, simpleStructStructClass_0, "<init>", |
| "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/" |
| "String;Ljava/lang/Integer;Ljava/lang/Float;Ljava/lang/Double;)V", |
| &simpleStructStructCtor_0); |
| if (err != CHIP_NO_ERROR || simpleStructStructCtor_0 == nullptr) |
| { |
| ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterSimpleStruct constructor"); |
| return; |
| } |
| |
| arg1 = env->NewObject(simpleStructStructClass_0, simpleStructStructCtor_0, arg1_a, arg1_b, arg1_c, arg1_d, arg1_e, arg1_f, |
| arg1_g, arg1_h); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, arg1); |
| } |
| CHIPUnitTestingClusterTestEmitTestEventResponseCallback::CHIPUnitTestingClusterTestEmitTestEventResponseCallback( |
| jobject javaCallback) : Callback::Callback<CHIPUnitTestingClusterTestEmitTestEventResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestEmitTestEventResponseCallback::~CHIPUnitTestingClusterTestEmitTestEventResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestEmitTestEventResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::TestEmitTestEventResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestEmitTestEventResponseCallback, |
| void (*)(CHIPUnitTestingClusterTestEmitTestEventResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestEmitTestEventResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestEmitTestEventResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject value; |
| std::string valueClassName = "java/lang/Long"; |
| std::string valueCtorSignature = "(J)V"; |
| jlong jnivalue = static_cast<jlong>(dataResponse.value); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, |
| value); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, value); |
| } |
| CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback:: |
| CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback:: |
| ~CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback::CallbackFn( |
| void * context, |
| const chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback, |
| void (*)(CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject value; |
| std::string valueClassName = "java/lang/Long"; |
| std::string valueCtorSignature = "(J)V"; |
| jlong jnivalue = static_cast<jlong>(dataResponse.value); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jlong>(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, |
| value); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, value); |
| } |
| CHIPUnitTestingClusterTestBatchHelperResponseCallback::CHIPUnitTestingClusterTestBatchHelperResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPUnitTestingClusterTestBatchHelperResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPUnitTestingClusterTestBatchHelperResponseCallback::~CHIPUnitTestingClusterTestBatchHelperResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPUnitTestingClusterTestBatchHelperResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPUnitTestingClusterTestBatchHelperResponseCallback, |
| void (*)(CHIPUnitTestingClusterTestBatchHelperResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPUnitTestingClusterTestBatchHelperResponseCallback *>(context), |
| chip::Platform::Delete<CHIPUnitTestingClusterTestBatchHelperResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject buffer; |
| jbyteArray bufferByteArray = env->NewByteArray(static_cast<jsize>(dataResponse.buffer.size())); |
| env->SetByteArrayRegion(bufferByteArray, 0, static_cast<jsize>(dataResponse.buffer.size()), |
| reinterpret_cast<const jbyte *>(dataResponse.buffer.data())); |
| buffer = bufferByteArray; |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, buffer); |
| } |
| CHIPSampleMeiClusterAddArgumentsResponseCallback::CHIPSampleMeiClusterAddArgumentsResponseCallback(jobject javaCallback) : |
| Callback::Callback<CHIPSampleMeiClusterAddArgumentsResponseCallbackType>(CallbackFn, this) |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| return; |
| } |
| |
| javaCallbackRef = env->NewGlobalRef(javaCallback); |
| if (javaCallbackRef == nullptr) |
| { |
| ChipLogError(Zcl, "Could not create global reference for Java callback"); |
| } |
| } |
| |
| CHIPSampleMeiClusterAddArgumentsResponseCallback::~CHIPSampleMeiClusterAddArgumentsResponseCallback() |
| { |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| if (env == nullptr) |
| { |
| ChipLogError(Zcl, "Could not delete global reference for Java callback"); |
| return; |
| } |
| env->DeleteGlobalRef(javaCallbackRef); |
| }; |
| |
| void CHIPSampleMeiClusterAddArgumentsResponseCallback::CallbackFn( |
| void * context, const chip::app::Clusters::SampleMei::Commands::AddArgumentsResponse::DecodableType & dataResponse) |
| { |
| chip::DeviceLayer::StackUnlock unlock; |
| CHIP_ERROR err = CHIP_NO_ERROR; |
| JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); |
| jobject javaCallbackRef; |
| jmethodID javaMethod; |
| |
| VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); |
| |
| std::unique_ptr<CHIPSampleMeiClusterAddArgumentsResponseCallback, void (*)(CHIPSampleMeiClusterAddArgumentsResponseCallback *)> |
| cppCallback(reinterpret_cast<CHIPSampleMeiClusterAddArgumentsResponseCallback *>(context), |
| chip::Platform::Delete<CHIPSampleMeiClusterAddArgumentsResponseCallback>); |
| VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); |
| |
| javaCallbackRef = cppCallback->javaCallbackRef; |
| // Java callback is allowed to be null, exit early if this is the case. |
| VerifyOrReturn(javaCallbackRef != nullptr); |
| |
| err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); |
| VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); |
| |
| jobject returnValue; |
| std::string returnValueClassName = "java/lang/Integer"; |
| std::string returnValueCtorSignature = "(I)V"; |
| jint jnireturnValue = static_cast<jint>(dataResponse.returnValue); |
| chip::JniReferences::GetInstance().CreateBoxedObject<jint>(returnValueClassName.c_str(), returnValueCtorSignature.c_str(), |
| jnireturnValue, returnValue); |
| |
| env->CallVoidMethod(javaCallbackRef, javaMethod, returnValue); |
| } |
| } // namespace chip |