16
16
*/
17
17
#include " AndroidCallbacks.h"
18
18
#include < controller/java/AndroidClusterExceptions.h>
19
+ #include < controller/java/AndroidControllerExceptions.h>
19
20
#include < controller/java/CHIPAttributeTLVValueDecoder.h>
20
21
#include < controller/java/CHIPEventTLVValueDecoder.h>
21
22
#include < jni.h>
@@ -105,16 +106,14 @@ void GetConnectedDeviceCallback::OnDeviceConnectionFailureFn(void * context, con
105
106
JniReferences::GetInstance ().FindMethod (env, javaCallback, " onConnectionFailure" , " (JLjava/lang/Exception;)V" , &failureMethod);
106
107
VerifyOrReturn (failureMethod != nullptr , ChipLogError (Controller, " Could not find onConnectionFailure method" ));
107
108
108
- // Create the exception to return.
109
- jclass controllerExceptionCls;
110
- CHIP_ERROR err = JniReferences::GetInstance ().GetClassRef (env, " chip/devicecontroller/ChipDeviceControllerException" ,
111
- controllerExceptionCls);
112
- VerifyOrReturn (err == CHIP_NO_ERROR, ChipLogError (Controller, " Could not find exception type for onConnectionFailure" ));
113
- JniClass controllerExceptionJniCls (controllerExceptionCls);
114
-
115
- jmethodID exceptionConstructor = env->GetMethodID (controllerExceptionCls, " <init>" , " (ILjava/lang/String;)V" );
116
- jobject exception =
117
- env->NewObject (controllerExceptionCls, exceptionConstructor, error.AsInteger (), env->NewStringUTF (ErrorStr (error)));
109
+ jthrowable exception ;
110
+ CHIP_ERROR err = AndroidControllerExceptions::GetInstance ().CreateAndroidControllerException (env, ErrorStr (error),
111
+ error.AsInteger (), exception );
112
+ VerifyOrReturn (
113
+ err == CHIP_NO_ERROR,
114
+ ChipLogError (Controller,
115
+ " Unable to create AndroidControllerException on GetConnectedDeviceCallback::OnDeviceConnectionFailureFn: %s" ,
116
+ ErrorStr (err)));
118
117
119
118
DeviceLayer::StackUnlock unlock;
120
119
env->CallVoidMethod (javaCallback, failureMethod, peerId.GetNodeId (), exception );
@@ -558,12 +557,12 @@ CHIP_ERROR ReportCallback::OnResubscriptionNeeded(app::ReadClient * apReadClient
558
557
559
558
jmethodID onResubscriptionAttemptMethod;
560
559
ReturnLogErrorOnFailure (JniReferences::GetInstance ().FindMethod (
561
- env, mResubscriptionAttemptCallbackRef , " onResubscriptionAttempt" , " (II )V" , &onResubscriptionAttemptMethod));
560
+ env, mResubscriptionAttemptCallbackRef , " onResubscriptionAttempt" , " (JJ )V" , &onResubscriptionAttemptMethod));
562
561
563
562
DeviceLayer::StackUnlock unlock;
564
563
env->CallVoidMethod (mResubscriptionAttemptCallbackRef , onResubscriptionAttemptMethod,
565
- static_cast <jint >(aTerminationCause.AsInteger ()),
566
- static_cast <jint >(apReadClient->ComputeTimeTillNextSubscription ()));
564
+ static_cast <jlong >(aTerminationCause.AsInteger ()),
565
+ static_cast <jlong >(apReadClient->ComputeTimeTillNextSubscription ()));
567
566
VerifyOrReturnError (!env->ExceptionCheck (), CHIP_JNI_ERROR_EXCEPTION_THROWN);
568
567
return CHIP_NO_ERROR;
569
568
}
@@ -585,8 +584,10 @@ void ReportCallback::ReportError(jobject attributePath, jobject eventPath, const
585
584
JNIEnv * env = JniReferences::GetInstance ().GetEnvForCurrentThread ();
586
585
587
586
jthrowable exception ;
588
- err = AndroidClusterExceptions::GetInstance ().CreateIllegalStateException (env, message, errorCode, exception );
589
- VerifyOrReturn (err == CHIP_NO_ERROR, ChipLogError (Controller, " Unable to create IllegalStateException: %s" , ErrorStr (err)));
587
+ err = AndroidControllerExceptions::GetInstance ().CreateAndroidControllerException (env, message, errorCode, exception );
588
+ VerifyOrReturn (
589
+ err == CHIP_NO_ERROR,
590
+ ChipLogError (Controller, " Unable to create AndroidControllerException on ReportCallback::ReportError: %s" , ErrorStr (err)));
590
591
591
592
jmethodID onErrorMethod;
592
593
err = JniReferences::GetInstance ().FindMethod (
@@ -813,12 +814,12 @@ CHIP_ERROR ReportEventCallback::OnResubscriptionNeeded(app::ReadClient * apReadC
813
814
814
815
jmethodID onResubscriptionAttemptMethod;
815
816
ReturnLogErrorOnFailure (JniReferences::GetInstance ().FindMethod (
816
- env, mResubscriptionAttemptCallbackRef , " onResubscriptionAttempt" , " (II )V" , &onResubscriptionAttemptMethod));
817
+ env, mResubscriptionAttemptCallbackRef , " onResubscriptionAttempt" , " (JJ )V" , &onResubscriptionAttemptMethod));
817
818
818
819
DeviceLayer::StackUnlock unlock;
819
820
env->CallVoidMethod (mResubscriptionAttemptCallbackRef , onResubscriptionAttemptMethod,
820
- static_cast <jint >(aTerminationCause.AsInteger ()),
821
- static_cast <jint >(apReadClient->ComputeTimeTillNextSubscription ()));
821
+ static_cast <jlong >(aTerminationCause.AsInteger ()),
822
+ static_cast <jlong >(apReadClient->ComputeTimeTillNextSubscription ()));
822
823
823
824
return CHIP_NO_ERROR;
824
825
}
@@ -839,8 +840,10 @@ void ReportEventCallback::ReportError(jobject eventPath, const char * message, C
839
840
JNIEnv * env = JniReferences::GetInstance ().GetEnvForCurrentThread ();
840
841
841
842
jthrowable exception ;
842
- err = AndroidClusterExceptions::GetInstance ().CreateIllegalStateException (env, message, errorCode, exception );
843
- VerifyOrReturn (err == CHIP_NO_ERROR, ChipLogError (Controller, " Unable to create IllegalStateException: %s" , ErrorStr (err)));
843
+ err = AndroidControllerExceptions::GetInstance ().CreateAndroidControllerException (env, message, errorCode, exception );
844
+ VerifyOrReturn (err == CHIP_NO_ERROR,
845
+ ChipLogError (Controller, " Unable to create AndroidControllerException: %s on eportEventCallback::ReportError" ,
846
+ ErrorStr (err)));
844
847
845
848
jmethodID onErrorMethod;
846
849
err = JniReferences::GetInstance ().FindMethod (
@@ -943,8 +946,11 @@ void WriteAttributesCallback::ReportError(jobject attributePath, const char * me
943
946
944
947
ChipLogError (Controller, " WriteAttributesCallback ReportError is called" );
945
948
jthrowable exception ;
946
- err = AndroidClusterExceptions::GetInstance ().CreateIllegalStateException (env, message, errorCode, exception );
947
- VerifyOrReturn (err == CHIP_NO_ERROR, ChipLogError (Controller, " Unable to create IllegalStateException: %s" , ErrorStr (err)));
949
+ err = AndroidControllerExceptions::GetInstance ().CreateAndroidControllerException (env, message, errorCode, exception );
950
+ VerifyOrReturn (err == CHIP_NO_ERROR,
951
+ ChipLogError (Controller,
952
+ " Unable to create AndroidControllerException on WriteAttributesCallback::ReportError: %s" ,
953
+ ErrorStr (err)));
948
954
949
955
jmethodID onErrorMethod;
950
956
err = JniReferences::GetInstance ().FindMethod (env, mJavaCallbackRef , " onError" ,
@@ -1043,8 +1049,10 @@ void InvokeCallback::ReportError(const char * message, ChipError::StorageType er
1043
1049
1044
1050
ChipLogError (Controller, " InvokeCallback ReportError is called" );
1045
1051
jthrowable exception ;
1046
- err = AndroidClusterExceptions::GetInstance ().CreateIllegalStateException (env, message, errorCode, exception );
1047
- VerifyOrReturn (err == CHIP_NO_ERROR, ChipLogError (Controller, " Unable to create IllegalStateException: %s" , ErrorStr (err)));
1052
+ err = AndroidControllerExceptions::GetInstance ().CreateAndroidControllerException (env, message, errorCode, exception );
1053
+ VerifyOrReturn (
1054
+ err == CHIP_NO_ERROR,
1055
+ ChipLogError (Controller, " Unable to create AndroidControllerException: %s on InvokeCallback::ReportError" , ErrorStr (err)));
1048
1056
1049
1057
jmethodID onErrorMethod;
1050
1058
err = JniReferences::GetInstance ().FindMethod (env, mJavaCallbackRef , " onError" , " (Ljava/lang/Exception;)V" , &onErrorMethod);
0 commit comments