Skip to content

Commit

Permalink
Divide Matter Interaction client JNI API
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo committed Jan 2, 2024
1 parent b364ee6 commit c789217
Show file tree
Hide file tree
Showing 8 changed files with 1,881 additions and 1,219 deletions.
10 changes: 4 additions & 6 deletions src/controller/java/AndroidCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ CHIP_ERROR ReportCallback::CreateChipEventPath(JNIEnv * env, const app::Concrete
return CHIP_NO_ERROR;
}

GetConnectedDeviceCallback::GetConnectedDeviceCallback(jobject wrapperCallback, jobject javaCallback) :
mOnSuccess(OnDeviceConnectedFn, this), mOnFailure(OnDeviceConnectionFailureFn, this)
GetConnectedDeviceCallback::GetConnectedDeviceCallback(jobject wrapperCallback, jobject javaCallback, const char * callbackClassSignature) :
mOnSuccess(OnDeviceConnectedFn, this), mOnFailure(OnDeviceConnectionFailureFn, this), mCallbackClassSignature(callbackClassSignature)
{
VerifyOrReturn(mWrapperCallbackRef.Init(wrapperCallback) == CHIP_NO_ERROR,
ChipLogError(Controller, "Could not init mWrapperCallbackRef in %s", __func__));
Expand All @@ -98,8 +98,7 @@ void GetConnectedDeviceCallback::OnDeviceConnectedFn(void * context, Messaging::
JniGlobalReference globalRef(std::move(self->mWrapperCallbackRef));

jclass getConnectedDeviceCallbackCls = nullptr;
JniReferences::GetInstance().GetLocalClassRef(
env, "chip/devicecontroller/GetConnectedDeviceCallbackJni$GetConnectedDeviceCallback", getConnectedDeviceCallbackCls);
JniReferences::GetInstance().GetLocalClassRef(env, self->mCallbackClassSignature, getConnectedDeviceCallbackCls);
VerifyOrReturn(getConnectedDeviceCallbackCls != nullptr,
ChipLogError(Controller, "Could not find GetConnectedDeviceCallback class"));

Expand Down Expand Up @@ -127,8 +126,7 @@ void GetConnectedDeviceCallback::OnDeviceConnectionFailureFn(void * context,
JniLocalReferenceManager manager(env);

jclass getConnectedDeviceCallbackCls = nullptr;
JniReferences::GetInstance().GetLocalClassRef(
env, "chip/devicecontroller/GetConnectedDeviceCallbackJni$GetConnectedDeviceCallback", getConnectedDeviceCallbackCls);
JniReferences::GetInstance().GetLocalClassRef(env, self->mCallbackClassSignature, getConnectedDeviceCallbackCls);
VerifyOrReturn(getConnectedDeviceCallbackCls != nullptr,
ChipLogError(Controller, "Could not find GetConnectedDeviceCallback class"));

Expand Down
5 changes: 4 additions & 1 deletion src/controller/java/AndroidCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CHIP_ERROR CreateChipAttributePath(JNIEnv * env, const app::ConcreteDataAttribut
// Callback for success and failure cases of GetConnectedDevice().
struct GetConnectedDeviceCallback
{
GetConnectedDeviceCallback(jobject wrapperCallback, jobject javaCallback);
GetConnectedDeviceCallback(jobject wrapperCallback, jobject javaCallback, const char * callbackClassSignature = "chip/devicecontroller/GetConnectedDeviceCallbackJni$GetConnectedDeviceCallback");
~GetConnectedDeviceCallback();

static void OnDeviceConnectedFn(void * context, Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle);
Expand All @@ -45,6 +45,9 @@ struct GetConnectedDeviceCallback
Callback::Callback<OperationalSessionSetup::OnSetupFailure> mOnFailure;
JniGlobalReference mWrapperCallbackRef;
JniGlobalReference mJavaCallbackRef;

private:
const char * mCallbackClassSignature;
};

struct ReportCallback : public app::ClusterStateCache::Callback
Expand Down
1 change: 1 addition & 0 deletions src/controller/java/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ shared_library("jni") {
"CHIPDeviceController-JNI.cpp",
"DeviceAttestationDelegateBridge.cpp",
"DeviceAttestationDelegateBridge.h",
"MatterInteractionClient-JNI.cpp",
]

deps = [
Expand Down
806 changes: 0 additions & 806 deletions src/controller/java/CHIPDeviceController-JNI.cpp

Large diffs are not rendered by default.

Loading

0 comments on commit c789217

Please sign in to comment.