diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/FailureCallback.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/FailureCallback.java index 698d091ca06896..2ad3b9fc7222fe 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/FailureCallback.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/FailureCallback.java @@ -24,7 +24,7 @@ public abstract class FailureCallback { public abstract void handle(MatterError err); - private final void handleInternal(int errorCode, String errorMessage) { + protected final void handleInternal(int errorCode, String errorMessage) { try { handle(new MatterError(errorCode, errorMessage)); } catch (Throwable t) { diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MatterCallbackHandler.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MatterCallbackHandler.java index 8eb3d2c4f1318e..493635beb692f1 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MatterCallbackHandler.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/MatterCallbackHandler.java @@ -24,7 +24,7 @@ public abstract class MatterCallbackHandler { public abstract void handle(MatterError err); - private final void handleInternal(int errorCode, String errorMessage) { + protected final void handleInternal(int errorCode, String errorMessage) { try { handle(new MatterError(errorCode, errorMessage)); } catch (Throwable t) { diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SubscriptionEstablishedCallback.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SubscriptionEstablishedCallback.java index 6bac295871e18c..aab9dcd9306fd7 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SubscriptionEstablishedCallback.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SubscriptionEstablishedCallback.java @@ -24,7 +24,7 @@ public abstract class SubscriptionEstablishedCallback { public abstract void handle(); - private void handleInternal() { + protected void handleInternal() { try { handle(); } catch (Throwable t) { diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SuccessCallback.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SuccessCallback.java index 8f10aa72cce16e..b82845567d8276 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SuccessCallback.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/SuccessCallback.java @@ -24,7 +24,7 @@ public abstract class SuccessCallback { public abstract void handle(R response); - public void handleInternal(R response) { + protected final void handleInternal(R response) { try { handle(response); } catch (Throwable t) { diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp index 0c841c4f19039f..3d35e0d29a49c9 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp @@ -31,7 +31,10 @@ CHIP_ERROR CallbackBaseJNI::SetUp(JNIEnv * env, jobject inHandler) mClazz = env->GetObjectClass(mObject); VerifyOrExit(mClazz != nullptr, ChipLogError(AppServer, "Failed to get handler Java class")); - mMethod = env->GetMethodID(mClazz, "handleInternal", mMethodSignature); + mSuperClazz = env->GetSuperclass(mClazz); + VerifyOrExit(mSuperClazz != nullptr, ChipLogError(AppServer, "Failed to get handler's parent's Java class")); + + mMethod = env->GetMethodID(mSuperClazz, "handleInternal", mMethodSignature); if (mMethod == nullptr) { ChipLogError(AppServer, "Failed to access 'handleInternal' method with signature %s", mMethodSignature); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h index b37b9ec12ec431..346043c837dcde 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.h @@ -37,6 +37,7 @@ class CallbackBaseJNI protected: jobject mObject = nullptr; jclass mClazz = nullptr; + jclass mSuperClazz = nullptr; jmethodID mMethod = nullptr; const char * mMethodSignature = nullptr; };