* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "aitt_jni.h"
+
/**
* This class is used as a native interface between the aitt java and aitt C++ layer. It has exposed following API's to
* communicate with aitt C++
if (env == nullptr || jniInterfaceObject == nullptr) {
JNI_LOG(ANDROID_LOG_ERROR, TAG, "Env or Jobject is null");
return false;
- }else{
+ } else {
return true;
}
}
void AittNativeInterface::Java_com_samsung_android_aitt_Aitt_connectJNI(JNIEnv *env,
jobject jniInterfaceObject, jlong handle, jstring host, jint port)
{
- if(!checkParams(env, jniInterfaceObject))
+ if (!checkParams(env, jniInterfaceObject)) {
return;
+ }
AittNativeInterface *instance = reinterpret_cast<AittNativeInterface *>(handle);
std::string brokerIp = GetStringUTF(env, host);
if (brokerIp.empty()) {
+ JNI_LOG(ANDROID_LOG_ERROR, TAG, "Broker Ip is empty");
return;
}
jobject jniInterfaceObject, jlong handle, jstring topic, jbyteArray data, jlong datalen,
jint protocol, jint qos, jboolean retain)
{
- if(!checkParams(env, jniInterfaceObject))
+ if (!checkParams(env, jniInterfaceObject)) {
return;
+ }
AittNativeInterface *instance = reinterpret_cast<AittNativeInterface *>(handle);
std::string customTopic = GetStringUTF(env, topic);
void AittNativeInterface::Java_com_samsung_android_aitt_Aitt_disconnectJNI(JNIEnv *env,
jobject jniInterfaceObject, jlong handle)
{
- if(!checkParams(env, jniInterfaceObject))
+ if (!checkParams(env, jniInterfaceObject)) {
return;
+ }
AittNativeInterface *instance = reinterpret_cast<AittNativeInterface *>(handle);
try {
}
-bool AittNativeInterface::jniStatusCheck(JNIEnv *env, int JNIStatus){
+bool AittNativeInterface::jniStatusCheck(JNIEnv *&env, int JNIStatus){
if (JNIStatus == JNI_EDETACHED) {
if (cbContext.jvm->AttachCurrentThread(&env, nullptr) != 0) {
JNI_LOG(ANDROID_LOG_ERROR, TAG, "Failed to attach current thread");
jlong AittNativeInterface::Java_com_samsung_android_aitt_Aitt_subscribeJNI(JNIEnv *env,
jobject jniInterfaceObject, jlong handle, jstring topic, jint protocol, jint qos)
{
- if(!checkParams(env, jniInterfaceObject))
+ if (!checkParams(env, jniInterfaceObject)) {
return 0L;
+ }
AittNativeInterface *instance = reinterpret_cast<AittNativeInterface *>(handle);
std::string customTopic = GetStringUTF(env, topic);
int JNIStatus =
cbContext.jvm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6);
- if(!jniStatusCheck(env, JNIStatus))
+ if (!jniStatusCheck(env, JNIStatus)) {
return;
+ }
if (env != nullptr && instance->cbObject != nullptr) {
jstring _topic = env->NewStringUTF(handle->GetTopic().c_str());
void AittNativeInterface::Java_com_samsung_android_aitt_Aitt_unsubscribeJNI(JNIEnv *env,
jobject jniInterfaceObject, jlong handle, jlong aittSubId)
{
- if(!checkParams(env, jniInterfaceObject))
+ if (!checkParams(env, jniInterfaceObject)) {
return;
+ }
AittNativeInterface *instance = reinterpret_cast<AittNativeInterface *>(handle);
void *subId = reinterpret_cast<void *>(aittSubId);
void AittNativeInterface::Java_com_samsung_android_aitt_Aitt_setConnectionCallbackJNI(JNIEnv *env,
jobject jniInterfaceObject, jlong handle)
{
- if(!checkParams(env, jniInterfaceObject))
+ if (!checkParams(env, jniInterfaceObject)) {
return;
+ }
AittNativeInterface *instance = reinterpret_cast<AittNativeInterface *>(handle);
int JNIStatus =
cbContext.jvm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6);
- if(!jniStatusCheck(env, JNIStatus))
+ if (!jniStatusCheck(env, JNIStatus)) {
return;
+ }
if (env != nullptr && instance->cbObject != nullptr) {
env->CallVoidMethod(instance->cbObject, cbContext.connectionCallbackMethodID,
jobject jniInterfaceObject, jstring id, jstring ip, jboolean clearSession)
{
- if(!checkParams(env, jniInterfaceObject))
+ if (!checkParams(env, jniInterfaceObject)) {
return JNI_ERR;
+ }
std::string mqId = GetStringUTF(env, id);
if (mqId.empty()) {