From 2981121987e11169a33b0be5582cc982b48af2fa Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Fri, 22 Sep 2023 06:47:15 -0700 Subject: [PATCH] Return custom status code in invoke response callback (#29398) * Return custom status code in invoke response callback * Restyled by clang-format --------- Co-authored-by: Restyled.io --- src/controller/java/AndroidCallbacks.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/controller/java/AndroidCallbacks.cpp b/src/controller/java/AndroidCallbacks.cpp index f27042edf6158c..5f4f8dbb6a12be 100644 --- a/src/controller/java/AndroidCallbacks.cpp +++ b/src/controller/java/AndroidCallbacks.cpp @@ -832,7 +832,16 @@ void InvokeCallback::OnResponse(app::CommandSender * apCommandSender, const app: VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Unable to find onResponse method: %s", ErrorStr(err))); DeviceLayer::StackUnlock unlock; - env->CallVoidMethod(mJavaCallbackRef, onResponseMethod, invokeElementObj, static_cast(aStatusIB.mStatus)); + if (aStatusIB.mClusterStatus.HasValue()) + { + env->CallVoidMethod(mJavaCallbackRef, onResponseMethod, invokeElementObj, + static_cast(aStatusIB.mClusterStatus.Value())); + } + else + { + env->CallVoidMethod(mJavaCallbackRef, onResponseMethod, invokeElementObj, + static_cast(Protocols::InteractionModel::Status::Success)); + } VerifyOrReturn(!env->ExceptionCheck(), env->ExceptionDescribe()); }