Commit 034fa6be authored by pedroGitt's avatar pedroGitt
Browse files

- Add new API for OlmUtility

- Introducing namespace AndroidOlmSdk
- Fix logs (function names mixed up)
- Add new check based on the calling java object instance type (IsInstanceOf())
- Fix return value for getXXXInstanceId() in case of failure. Now 0 is returned.
parent 4ccc45ab
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "olm_account.h" #include "olm_account.h"
using namespace AndroidOlmSdk;
/** /**
* Init memory allocation for account creation. * Init memory allocation for account creation.
* @return valid memory allocation, NULL otherwise * @return valid memory allocation, NULL otherwise
...@@ -264,36 +266,36 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(oneTimeKeysJni)(JNIEnv *env, jobject t ...@@ -264,36 +266,36 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(oneTimeKeysJni)(JNIEnv *env, jobject t
size_t keysResult; size_t keysResult;
jbyteArray byteArrayRetValue = NULL; jbyteArray byteArrayRetValue = NULL;
LOGD("## oneTimeKeys(): accountPtr =%p",accountPtr); LOGD("## oneTimeKeysJni(): IN");
if(NULL == (accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz))) if(NULL == (accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz)))
{ {
LOGE("## oneTimeKeys(): failure - invalid Account ptr"); LOGE("## oneTimeKeysJni(): failure - invalid Account ptr");
} }
else else
{ // keys memory allocation { // keys memory allocation
keysLength = olm_account_one_time_keys_length(accountPtr); keysLength = olm_account_one_time_keys_length(accountPtr);
if(NULL == (keysBytesPtr=(uint8_t *)malloc(keysLength*sizeof(uint8_t)))) if(NULL == (keysBytesPtr=(uint8_t *)malloc(keysLength*sizeof(uint8_t))))
{ {
LOGE("## oneTimeKeys(): failure - one time keys array OOM"); LOGE("## oneTimeKeysJni(): failure - one time keys array OOM");
} }
else else
{ // retrieve key pairs in keysBytesPtr { // retrieve key pairs in keysBytesPtr
keysResult = olm_account_one_time_keys(accountPtr, keysBytesPtr, keysLength); keysResult = olm_account_one_time_keys(accountPtr, keysBytesPtr, keysLength);
if(keysResult == olm_error()) { if(keysResult == olm_error()) {
const char *errorMsgPtr = olm_account_last_error(accountPtr); const char *errorMsgPtr = olm_account_last_error(accountPtr);
LOGE("## oneTimeKeys(): failure - error getting one time keys Msg=%s",errorMsgPtr); LOGE("## oneTimeKeysJni(): failure - error getting one time keys Msg=%s",errorMsgPtr);
} }
else else
{ // allocate the byte array to be returned to java { // allocate the byte array to be returned to java
if(NULL == (byteArrayRetValue=env->NewByteArray(keysLength))) if(NULL == (byteArrayRetValue=env->NewByteArray(keysLength)))
{ {
LOGE("## oneTimeKeys(): failure - return byte array OOM"); LOGE("## oneTimeKeysJni(): failure - return byte array OOM");
} }
else else
{ {
env->SetByteArrayRegion(byteArrayRetValue, 0/*offset*/, keysLength, (const jbyte*)keysBytesPtr); env->SetByteArrayRegion(byteArrayRetValue, 0/*offset*/, keysLength, (const jbyte*)keysBytesPtr);
LOGD("## oneTimeKeys(): success"); LOGD("## oneTimeKeysJni(): success");
} }
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "olm_inbound_group_session.h" #include "olm_inbound_group_session.h"
using namespace AndroidOlmSdk;
/** /**
* Release the session allocation made by initializeInboundGroupSessionMemory().<br> * Release the session allocation made by initializeInboundGroupSessionMemory().<br>
......
...@@ -44,21 +44,16 @@ ...@@ -44,21 +44,16 @@
#define FUNC_DEF(class_name,func_name) JNICALL Java_org_matrix_olm_##class_name##_##func_name #define FUNC_DEF(class_name,func_name) JNICALL Java_org_matrix_olm_##class_name##_##func_name
// Error codes definition namespace AndroidOlmSdk
static const int ERROR_CODE_OK = 0; {
static const int ERROR_CODE_NO_MATCHING_ONE_TIME_KEYS = ERROR_CODE_OK+1; // Error codes definition
static const int ERROR_CODE_KO = -1; static const int ERROR_CODE_OK = 0;
static const int ERROR_CODE_NO_MATCHING_ONE_TIME_KEYS = ERROR_CODE_OK+1;
// constants static const int ERROR_CODE_KO = -1;
static const int ACCOUNT_CREATION_RANDOM_MODULO = 256;
// constants
static const int ACCOUNT_CREATION_RANDOM_MODULO = 256;
// strings }
static const char *CLASS_OLM_OUTBOUND_GROUP_SESSION = "org/matrix/olm/OlmOutboundGroupSession";
static const char *CLASS_OLM_INBOUND_GROUP_SESSION = "org/matrix/olm/OlmInboundGroupSession";
static const char *CLASS_OLM_SESSION = "org/matrix/olm/OlmSession";
static const char *CLASS_OLM_ACCOUNT = "org/matrix/olm/OlmAccount";
static const char *CLASS_OLM_UTILITY = "org/matrix/olm/OlmUtility";
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -70,7 +65,7 @@ jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject); ...@@ -70,7 +65,7 @@ jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject); jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject); jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject); jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
jlong getUtilityInstanceId(JNIEnv* aJniEnv, jobject aJavaObject);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include "olm_jni.h" #include "olm_jni_helper.h"
using namespace AndroidOlmSdk;
/** /**
* Init a buffer with a given number of random values. * Init a buffer with a given number of random values.
...@@ -30,15 +32,15 @@ bool setRandomInBuffer(uint8_t **aBuffer2Ptr, size_t aRandomSize) ...@@ -30,15 +32,15 @@ bool setRandomInBuffer(uint8_t **aBuffer2Ptr, size_t aRandomSize)
bool retCode = false; bool retCode = false;
if(NULL == aBuffer2Ptr) if(NULL == aBuffer2Ptr)
{ {
LOGD("## setRandomInBuffer(): failure - aBuffer=NULL"); LOGE("## setRandomInBuffer(): failure - aBuffer=NULL");
} }
else if(0 == aRandomSize) else if(0 == aRandomSize)
{ {
LOGD("## setRandomInBuffer(): failure - random size=0"); LOGE("## setRandomInBuffer(): failure - random size=0");
} }
else if(NULL == (*aBuffer2Ptr = (uint8_t*)malloc(aRandomSize*sizeof(uint8_t)))) else if(NULL == (*aBuffer2Ptr = (uint8_t*)malloc(aRandomSize*sizeof(uint8_t))))
{ {
LOGD("## setRandomInBuffer(): failure - alloc mem OOM"); LOGE("## setRandomInBuffer(): failure - alloc mem OOM");
} }
else else
{ {
...@@ -67,7 +69,7 @@ bool setRandomInBuffer(uint8_t **aBuffer2Ptr, size_t aRandomSize) ...@@ -67,7 +69,7 @@ bool setRandomInBuffer(uint8_t **aBuffer2Ptr, size_t aRandomSize)
**/ **/
jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
{ {
jlong instanceId=-1; jlong instanceId = 0;
jfieldID instanceIdField; jfieldID instanceIdField;
jclass loaderClass; jclass loaderClass;
jclass requiredClass = 0; jclass requiredClass = 0;
...@@ -78,7 +80,7 @@ jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -78,7 +80,7 @@ jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
if((0 != requiredClass) && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass))) if((0 != requiredClass) && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass)))
{ {
LOGD("## getAccountInstanceId() failure - invalid instance of"); LOGE("## getAccountInstanceId() failure - invalid instance of");
} }
else if(0 != (loaderClass=aJniEnv->GetObjectClass(aJavaObject))) else if(0 != (loaderClass=aJniEnv->GetObjectClass(aJavaObject)))
{ {
...@@ -90,17 +92,17 @@ jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -90,17 +92,17 @@ jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
} }
else else
{ {
LOGD("## getAccountInstanceId() ERROR! GetFieldID=null"); LOGE("## getAccountInstanceId() ERROR! GetFieldID=null");
} }
} }
else else
{ {
LOGD("## getAccountInstanceId() ERROR! GetObjectClass=null"); LOGE("## getAccountInstanceId() ERROR! GetObjectClass=null");
} }
} }
else else
{ {
LOGD("## getAccountInstanceId() ERROR! aJniEnv=NULL"); LOGE("## getAccountInstanceId() ERROR! aJniEnv=NULL");
} }
LOGD("## getAccountInstanceId() success - instanceId=%lld",instanceId); LOGD("## getAccountInstanceId() success - instanceId=%lld",instanceId);
return instanceId; return instanceId;
...@@ -114,7 +116,7 @@ jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -114,7 +116,7 @@ jlong getAccountInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
**/ **/
jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
{ {
jlong instanceId=-1; jlong instanceId = 0;
jfieldID instanceIdField; jfieldID instanceIdField;
jclass loaderClass; jclass loaderClass;
jclass requiredClass = 0; jclass requiredClass = 0;
...@@ -125,7 +127,7 @@ jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -125,7 +127,7 @@ jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
if((0 != requiredClass) && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass))) if((0 != requiredClass) && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass)))
{ {
LOGD("## getSessionInstanceId() failure - invalid instance of"); LOGE("## getSessionInstanceId() failure - invalid instance of");
} }
else if(0 != (loaderClass=aJniEnv->GetObjectClass(aJavaObject))) else if(0 != (loaderClass=aJniEnv->GetObjectClass(aJavaObject)))
{ {
...@@ -136,17 +138,17 @@ jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -136,17 +138,17 @@ jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
} }
else else
{ {
LOGD("## getSessionInstanceId() ERROR! GetFieldID=null"); LOGE("## getSessionInstanceId() ERROR! GetFieldID=null");
} }
} }
else else
{ {
LOGD("## getSessionInstanceId() ERROR! GetObjectClass=null"); LOGE("## getSessionInstanceId() ERROR! GetObjectClass=null");
} }
} }
else else
{ {
LOGD("## getSessionInstanceId() ERROR! aJniEnv=NULL"); LOGE("## getSessionInstanceId() ERROR! aJniEnv=NULL");
} }
//LOGD("## getSessionInstanceId() success - instanceId=%lld",instanceId); //LOGD("## getSessionInstanceId() success - instanceId=%lld",instanceId);
...@@ -162,7 +164,7 @@ jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -162,7 +164,7 @@ jlong getSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
**/ **/
jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
{ {
jlong instanceId=-1; jlong instanceId = 0;
jfieldID instanceIdField; jfieldID instanceIdField;
jclass loaderClass; jclass loaderClass;
jclass requiredClass = 0; jclass requiredClass = 0;
...@@ -173,7 +175,7 @@ jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -173,7 +175,7 @@ jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
if((0 != requiredClass) && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass))) if((0 != requiredClass) && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass)))
{ {
LOGD("## getInboundGroupSessionInstanceId() failure - invalid instance of"); LOGE("## getInboundGroupSessionInstanceId() failure - invalid instance of");
} }
else if(0 != (loaderClass=aJniEnv->GetObjectClass(aJavaObject))) else if(0 != (loaderClass=aJniEnv->GetObjectClass(aJavaObject)))
{ {
...@@ -184,17 +186,17 @@ jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -184,17 +186,17 @@ jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
} }
else else
{ {
LOGD("## getInboundGroupSessionInstanceId() ERROR! GetFieldID=null"); LOGE("## getInboundGroupSessionInstanceId() ERROR! GetFieldID=null");
} }
} }
else else
{ {
LOGD("## getInboundGroupSessionInstanceId() ERROR! GetObjectClass=null"); LOGE("## getInboundGroupSessionInstanceId() ERROR! GetObjectClass=null");
} }
} }
else else
{ {
LOGD("## getInboundGroupSessionInstanceId() ERROR! aJniEnv=NULL"); LOGE("## getInboundGroupSessionInstanceId() ERROR! aJniEnv=NULL");
} }
return instanceId; return instanceId;
...@@ -209,7 +211,7 @@ jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -209,7 +211,7 @@ jlong getInboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
**/ **/
jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
{ {
jlong instanceId=-1; jlong instanceId = 0;
jfieldID instanceIdField; jfieldID instanceIdField;
jclass loaderClass; jclass loaderClass;
jclass requiredClass = 0; jclass requiredClass = 0;
...@@ -220,7 +222,7 @@ jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -220,7 +222,7 @@ jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
if((0 != requiredClass) && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass))) if((0 != requiredClass) && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass)))
{ {
LOGD("## getOutboundGroupSessionInstanceId() failure - invalid instance of"); LOGE("## getOutboundGroupSessionInstanceId() failure - invalid instance of");
} }
else if(0 != (loaderClass=aJniEnv->GetObjectClass(aJavaObject))) else if(0 != (loaderClass=aJniEnv->GetObjectClass(aJavaObject)))
{ {
...@@ -231,17 +233,17 @@ jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -231,17 +233,17 @@ jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
} }
else else
{ {
LOGD("## getOutboundGroupSessionInstanceId() ERROR! GetFieldID=null"); LOGE("## getOutboundGroupSessionInstanceId() ERROR! GetFieldID=null");
} }
} }
else else
{ {
LOGD("## getOutboundGroupSessionInstanceId() ERROR! GetObjectClass=null"); LOGE("## getOutboundGroupSessionInstanceId() ERROR! GetObjectClass=null");
} }
} }
else else
{ {
LOGD("## getOutboundGroupSessionInstanceId() ERROR! aJniEnv=NULL"); LOGE("## getOutboundGroupSessionInstanceId() ERROR! aJniEnv=NULL");
} }
return instanceId; return instanceId;
...@@ -249,7 +251,7 @@ jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -249,7 +251,7 @@ jlong getOutboundGroupSessionInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
jlong getUtilityInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) jlong getUtilityInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
{ {
jlong instanceId=-1; jlong instanceId = 0;
jfieldID instanceIdField; jfieldID instanceIdField;
jclass loaderClass; jclass loaderClass;
jclass requiredClass = 0; jclass requiredClass = 0;
...@@ -260,28 +262,28 @@ jlong getUtilityInstanceId(JNIEnv* aJniEnv, jobject aJavaObject) ...@@ -260,28 +262,28 @@ jlong getUtilityInstanceId(JNIEnv* aJniEnv, jobject aJavaObject)
if((0 != requiredClass) && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass))) if((0 != requiredClass) && (JNI_TRUE != aJniEnv->IsInstanceOf(aJavaObject, requiredClass)))
{ {
LOGD("## getOutboundGroupSessionInstanceId() failure - invalid instance of"); LOGE("## getUtilityInstanceId() failure - invalid instance of");
} }
else if(0 != (loaderClass=aJniEnv->GetObjectClass(aJavaObject))) else if(0 != (loaderClass=aJniEnv->GetObjectClass(aJavaObject)))
{ {
if(0 != (instanceIdField=aJniEnv->GetFieldID(loaderClass, "mNativeOlmOutboundGroupSessionId", "J"))) if(0 != (instanceIdField=aJniEnv->GetFieldID(loaderClass, "mNativeOlmUtilityId", "J")))
{ {
instanceId = aJniEnv->GetLongField(aJavaObject, instanceIdField); instanceId = aJniEnv->GetLongField(aJavaObject, instanceIdField);
aJniEnv->DeleteLocalRef(loaderClass); aJniEnv->DeleteLocalRef(loaderClass);
} }
else else
{ {
LOGD("## getOutboundGroupSessionInstanceId() ERROR! GetFieldID=null"); LOGE("## getUtilityInstanceId() ERROR! GetFieldID=null");
} }
} }
else else
{ {
LOGD("## getOutboundGroupSessionInstanceId() ERROR! GetObjectClass=null"); LOGE("## getUtilityInstanceId() ERROR! GetObjectClass=null");
} }
} }
else else
{ {
LOGD("## getOutboundGroupSessionInstanceId() ERROR! aJniEnv=NULL"); LOGE("## getUtilityInstanceId() ERROR! aJniEnv=NULL");
} }
return instanceId; return instanceId;
......
/**
* Created by pedrocon on 06/10/2016.
*/
/*
* Copyright 2016 OpenMarket Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "olm_jni.h"
// constant strings
namespace AndroidOlmSdk
{
static const char *CLASS_OLM_INBOUND_GROUP_SESSION = "org/matrix/olm/OlmInboundGroupSession";
static const char *CLASS_OLM_OUTBOUND_GROUP_SESSION = "org/matrix/olm/OlmOutboundGroupSession";
static const char *CLASS_OLM_SESSION = "org/matrix/olm/OlmSession";
static const char *CLASS_OLM_ACCOUNT = "org/matrix/olm/OlmAccount";
static const char *CLASS_OLM_UTILITY = "org/matrix/olm/OlmUtility";
}
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "olm_outbound_group_session.h" #include "olm_outbound_group_session.h"
using namespace AndroidOlmSdk;
/** /**
* Release the session allocation made by initializeOutboundGroupSessionMemory().<br> * Release the session allocation made by initializeOutboundGroupSessionMemory().<br>
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "olm_session.h" #include "olm_session.h"
using namespace AndroidOlmSdk;
/** /**
* Init memory allocation for a session creation.<br> * Init memory allocation for a session creation.<br>
...@@ -585,31 +586,31 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject t ...@@ -585,31 +586,31 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject t
if(NULL == (sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz))) if(NULL == (sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
{ {
LOGE("## decryptMessageJni(): failure - invalid Session ptr=NULL"); LOGE("## decryptMessageJni(): failure - invalid Session ptr=NULL");
} }
else if(0 == aEncryptedMsg) else if(0 == aEncryptedMsg)
{ {
LOGE("## decryptMessageJni(): failure - invalid encrypted message"); LOGE("## decryptMessageJni(): failure - invalid encrypted message");
} }
else if(0 == (encryptedMsgJclass = env->GetObjectClass(aEncryptedMsg))) else if(0 == (encryptedMsgJclass = env->GetObjectClass(aEncryptedMsg)))
{ {
LOGE("## decryptMessageJni(): failure - unable to get encrypted message class"); LOGE("## decryptMessageJni(): failure - unable to get encrypted message class");
} }
else if(0 == (encryptedMsgFieldId = env->GetFieldID(encryptedMsgJclass,"mCipherText","Ljava/lang/String;"))) else if(0 == (encryptedMsgFieldId = env->GetFieldID(encryptedMsgJclass,"mCipherText","Ljava/lang/String;")))
{ {
LOGE("## decryptMessageJni(): failure - unable to get message field"); LOGE("## decryptMessageJni(): failure - unable to get message field");
} }
else if(0 == (typeMsgFieldId = env->GetFieldID(encryptedMsgJclass,"mType","J"))) else if(0 == (typeMsgFieldId = env->GetFieldID(encryptedMsgJclass,"mType","J")))
{ {
LOGE("## decryptMessageJni(): failure - unable to get message type field"); LOGE("## decryptMessageJni(): failure - unable to get message type field");
} }
else if(0 == (encryptedMsgJstring = (jstring)env->GetObjectField(aEncryptedMsg, encryptedMsgFieldId))) else if(0 == (encryptedMsgJstring = (jstring)env->GetObjectField(aEncryptedMsg, encryptedMsgFieldId)))
{ {
LOGE("## decryptMessageJni(): failure - JNI encrypted object "); LOGE("## decryptMessageJni(): failure - JNI encrypted object ");
} }
else if(0 == (encryptedMsgPtr = env->GetStringUTFChars(encryptedMsgJstring, 0))) else if(0 == (encryptedMsgPtr = env->GetStringUTFChars(encryptedMsgJstring, 0)))
{ {
LOGE("## decryptMessageJni(): failure - encrypted message JNI allocation OOM"); LOGE("## decryptMessageJni(): failure - encrypted message JNI allocation OOM");
} }