Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Telatynski
Olm
Commits
332d9d0c
Commit
332d9d0c
authored
Oct 23, 2016
by
pedroGitt
Browse files
Add serialization for inbound group session
- remove compiler warnings when logs are not enabled - new getInstanceId() function to refactor code
parent
fae85758
Changes
16
Hide whitespace changes
Inline
Side-by-side
java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmGroupSessionTest.java
View file @
332d9d0c
...
...
@@ -28,7 +28,8 @@ import static org.junit.Assert.assertTrue;
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
OlmGroupSessionTest
{
private
static
final
String
LOG_TAG
=
"OlmSessionTest"
;
private
final
String
FILE_NAME_SERIAL_SESSION
=
"SerialGroupSession"
;
private
final
String
FILE_NAME_SERIAL_OUT_SESSION
=
"SerialOutGroupSession"
;
private
final
String
FILE_NAME_SERIAL_IN_SESSION
=
"SerialInGroupSession"
;
private
static
OlmManager
mOlmManager
;
private
static
OlmOutboundGroupSession
mAliceOutboundGroupSession
;
...
...
@@ -158,27 +159,26 @@ public class OlmGroupSessionTest {
OlmOutboundGroupSession
outboundGroupSessionRef
=
null
;
OlmOutboundGroupSession
outboundGroupSessionSerial
=
null
;
//
alice
create
s
OUTBOUND GROUP SESSION
// create
one
OUTBOUND GROUP SESSION
try
{
outboundGroupSessionRef
=
new
OlmOutboundGroupSession
();
}
catch
(
OlmException
e
)
{
assertTrue
(
"Exception in OlmOutboundGroupSession, Exception code="
+
e
.
getExceptionCode
(),
false
);
}
assertNotNull
(
outboundGroupSessionRef
);
// serialize alice session
Context
context
=
getInstrumentation
().
getContext
();
try
{
FileOutputStream
fileOutput
=
context
.
openFileOutput
(
FILE_NAME_SERIAL_SESSION
,
Context
.
MODE_PRIVATE
);
FileOutputStream
fileOutput
=
context
.
openFileOutput
(
FILE_NAME_SERIAL_
OUT_
SESSION
,
Context
.
MODE_PRIVATE
);
ObjectOutputStream
objectOutput
=
new
ObjectOutputStream
(
fileOutput
);
objectOutput
.
writeObject
(
outboundGroupSessionRef
);
objectOutput
.
flush
();
objectOutput
.
close
();
// deserialize session
FileInputStream
fileInput
=
context
.
openFileInput
(
FILE_NAME_SERIAL_SESSION
);
FileInputStream
fileInput
=
context
.
openFileInput
(
FILE_NAME_SERIAL_
OUT_
SESSION
);
ObjectInputStream
objectInput
=
new
ObjectInputStream
(
fileInput
);
outboundGroupSessionSerial
=
(
OlmOutboundGroupSession
)
objectInput
.
readObject
();
objectInput
.
close
();
...
...
@@ -204,6 +204,9 @@ public class OlmGroupSessionTest {
// session IDs comparison
assertTrue
(
sessionIdRef
.
equals
(
sessionIdSerial
));
outboundGroupSessionRef
.
releaseSession
();
outboundGroupSessionSerial
.
releaseSession
();
}
catch
(
FileNotFoundException
e
)
{
Log
.
e
(
LOG_TAG
,
"## test03SessionSerialization(): Exception FileNotFoundException Msg=="
+
e
.
getMessage
());
...
...
@@ -223,5 +226,78 @@ public class OlmGroupSessionTest {
}
@Test
public
void
test15SerializeInboundSession
()
{
OlmOutboundGroupSession
aliceOutboundGroupSession
=
null
;
OlmInboundGroupSession
bobInboundGroupSessionRef
=
null
;
OlmInboundGroupSession
bobInboundGroupSessionSerial
=
null
;
// alice creates OUTBOUND GROUP SESSION
try
{
aliceOutboundGroupSession
=
new
OlmOutboundGroupSession
();
}
catch
(
OlmException
e
)
{
assertTrue
(
"Exception in OlmOutboundGroupSession, Exception code="
+
e
.
getExceptionCode
(),
false
);
}
assertNotNull
(
aliceOutboundGroupSession
);
// get the session key from the outbound group session
String
sessionKeyRef
=
aliceOutboundGroupSession
.
sessionKey
();
assertNotNull
(
sessionKeyRef
);
// bob creates INBOUND GROUP SESSION
try
{
bobInboundGroupSessionRef
=
new
OlmInboundGroupSession
(
sessionKeyRef
);
}
catch
(
OlmException
e
)
{
assertTrue
(
"Exception in OlmInboundGroupSession, Exception code="
+
e
.
getExceptionCode
(),
false
);
}
assertNotNull
(
bobInboundGroupSessionRef
);
// serialize alice session
Context
context
=
getInstrumentation
().
getContext
();
try
{
FileOutputStream
fileOutput
=
context
.
openFileOutput
(
FILE_NAME_SERIAL_IN_SESSION
,
Context
.
MODE_PRIVATE
);
ObjectOutputStream
objectOutput
=
new
ObjectOutputStream
(
fileOutput
);
objectOutput
.
writeObject
(
bobInboundGroupSessionRef
);
objectOutput
.
flush
();
objectOutput
.
close
();
// deserialize session
FileInputStream
fileInput
=
context
.
openFileInput
(
FILE_NAME_SERIAL_OUT_SESSION
);
ObjectInputStream
objectInput
=
new
ObjectInputStream
(
fileInput
);
bobInboundGroupSessionSerial
=
(
OlmInboundGroupSession
)
objectInput
.
readObject
();
objectInput
.
close
();
// get sessions IDs
String
aliceSessionId
=
aliceOutboundGroupSession
.
sessionIdentifier
();
String
sessionIdRef
=
bobInboundGroupSessionRef
.
sessionIdentifier
();
String
sessionIdSerial
=
bobInboundGroupSessionSerial
.
sessionIdentifier
();
// session ID sanity check
assertFalse
(
TextUtils
.
isEmpty
(
aliceSessionId
));
assertFalse
(
TextUtils
.
isEmpty
(
sessionIdRef
));
assertFalse
(
TextUtils
.
isEmpty
(
sessionIdSerial
));
// session IDs comparison
assertTrue
(
aliceSessionId
.
equals
(
sessionIdSerial
));
assertTrue
(
sessionIdRef
.
equals
(
sessionIdSerial
));
}
catch
(
FileNotFoundException
e
)
{
Log
.
e
(
LOG_TAG
,
"## test03SessionSerialization(): Exception FileNotFoundException Msg=="
+
e
.
getMessage
());
}
catch
(
ClassNotFoundException
e
)
{
Log
.
e
(
LOG_TAG
,
"## test03SessionSerialization(): Exception ClassNotFoundException Msg=="
+
e
.
getMessage
());
}
catch
(
IOException
e
)
{
Log
.
e
(
LOG_TAG
,
"## test03SessionSerialization(): Exception IOException Msg=="
+
e
.
getMessage
());
}
/*catch (OlmException e) {
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception OlmException Msg==" + e.getMessage());
}*/
catch
(
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
"## test03SessionSerialization(): Exception Msg=="
+
e
.
getMessage
());
}
}
}
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
View file @
332d9d0c
...
...
@@ -26,7 +26,6 @@ import java.io.IOException;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.io.Serializable
;
import
java.util.Random
;
public
class
OlmAccount
implements
Serializable
{
private
static
final
long
serialVersionUID
=
3497486121598434824L
;
...
...
@@ -52,7 +51,7 @@ public class OlmAccount implements Serializable {
/** account raw pointer value (OlmAccount*) returned by JNI.
* this value identifies uniquely the native account instance.
*/
private
transient
long
mNative
OlmAccount
Id
;
private
transient
long
mNativeId
;
public
OlmAccount
()
throws
OlmException
{
...
...
@@ -179,7 +178,7 @@ public class OlmAccount implements Serializable {
* @return native account ID
*/
public
long
getOlmAccountId
(){
return
mNative
OlmAccount
Id
;
return
mNativeId
;
}
/**
...
...
@@ -189,7 +188,7 @@ public class OlmAccount implements Serializable {
public
void
releaseAccount
(){
releaseAccountJni
();
mNative
OlmAccount
Id
=
0
;
mNativeId
=
0
;
}
/**
...
...
@@ -208,7 +207,7 @@ public class OlmAccount implements Serializable {
*/
private
boolean
initNewAccount
()
{
boolean
retCode
=
false
;
if
(
0
!=
(
mNative
OlmAccount
Id
=
initNewAccountJni
())){
if
(
0
!=
(
mNativeId
=
initNewAccountJni
())){
retCode
=
true
;
}
return
retCode
;
...
...
@@ -217,7 +216,7 @@ public class OlmAccount implements Serializable {
/**
* Create and initialize an OLM account in native side.<br>
* Do not forget to call {@link #releaseAccount()} when JAVA side is done.
* @return native account instance identifier (see {@link #mNative
OlmAccount
Id})
* @return native account instance identifier (see {@link #mNativeId})
*/
private
native
long
initNewAccountJni
();
...
...
@@ -230,7 +229,7 @@ public class OlmAccount implements Serializable {
*/
private
boolean
createNewAccount
()
{
boolean
retCode
=
false
;
if
(
0
!=
(
mNative
OlmAccount
Id
=
createNewAccountJni
())){
if
(
0
!=
(
mNativeId
=
createNewAccountJni
())){
retCode
=
true
;
}
return
retCode
;
...
...
@@ -239,7 +238,7 @@ public class OlmAccount implements Serializable {
/**
* Create an OLM account in native side.<br>
* Do not forget to call {@link #releaseAccount()} when JAVA side is done.
* @return native account instance identifier (see {@link #mNative
OlmAccount
Id})
* @return native account instance identifier (see {@link #mNativeId})
*/
private
native
long
createNewAccountJni
();
...
...
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmException.java
View file @
332d9d0c
...
...
@@ -33,6 +33,8 @@ public class OlmException extends Exception {
public
static
final
int
EXCEPTION_CODE_INIT_SESSION_CREATION
=
9
;
public
static
final
int
EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_SERIALIZATION
=
10
;
public
static
final
int
EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_DESERIALIZATION
=
11
;
public
static
final
int
EXCEPTION_CODE_INBOUND_GROUP_SESSION_SERIALIZATION
=
12
;
public
static
final
int
EXCEPTION_CODE_INBOUND_GROUP_SESSION_DESERIALIZATION
=
13
;
// exception human readable messages
public
static
final
String
EXCEPTION_MSG_NEW_OUTBOUND_GROUP_SESSION
=
"failed to create a new outbound group Session"
;
...
...
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
View file @
332d9d0c
...
...
@@ -23,6 +23,9 @@ package org.matrix.olm;
import
android.text.TextUtils
;
import
android.util.Log
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.io.Serializable
;
public
class
OlmInboundGroupSession
implements
Serializable
{
...
...
@@ -32,26 +35,18 @@ public class OlmInboundGroupSession implements Serializable {
/** session raw pointer value returned by JNI.<br>
* this value uniquely identifies the native inbound group session instance.
*/
private
long
mNativeOlmInboundGroupSessionId
;
/**
* Getter on the native inbound group session ID.
* @return native inbound group session ID
*/
public
long
getOlmInboundGroupSessionId
()
{
return
mNativeOlmInboundGroupSessionId
;
}
private
transient
long
mNativeId
;
/**
* Constructor.<br>
* Create and save a new native session instance ID and start a new inbound group session.
* The session key parameter is retrieved from an outbound group session
* See {@link #
init
NewSession()} and {@link #initInboundGroupSessionWithSessionKey(String)}
* See {@link #
create
NewSession()} and {@link #initInboundGroupSessionWithSessionKey(String)}
* @param aSessionKey session key
* @throws OlmException constructor failure
*/
public
OlmInboundGroupSession
(
String
aSessionKey
)
throws
OlmException
{
if
(
init
NewSession
())
{
if
(
create
NewSession
())
{
if
(
0
!=
initInboundGroupSessionWithSessionKey
(
aSessionKey
))
{
releaseSession
();
// prevent memory leak before throwing
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_INIT_INBOUND_GROUP_SESSION
,
OlmException
.
EXCEPTION_MSG_INIT_INBOUND_GROUP_SESSION
);
...
...
@@ -68,14 +63,14 @@ public class OlmInboundGroupSession implements Serializable {
public
void
releaseSession
(){
releaseSessionJni
();
mNative
OlmInboundGroupSession
Id
=
0
;
mNativeId
=
0
;
}
/**
* Destroy the corresponding OLM inbound group session native object.<br>
* This method must ALWAYS be called when this JAVA instance
* is destroyed (ie. garbage collected) to prevent memory leak in native side.
* See {@link #
init
NewSessionJni()}.
* See {@link #
create
NewSessionJni()}.
*/
private
native
void
releaseSessionJni
();
...
...
@@ -84,9 +79,9 @@ public class OlmInboundGroupSession implements Serializable {
* To be called before any other API call.
* @return true if init succeed, false otherwise.
*/
private
boolean
init
NewSession
()
{
private
boolean
create
NewSession
()
{
boolean
retCode
=
false
;
if
(
0
!=
(
mNative
OlmInboundGroupSessionId
=
init
NewSessionJni
())){
if
(
0
!=
(
mNative
Id
=
create
NewSessionJni
())){
retCode
=
true
;
}
return
retCode
;
...
...
@@ -95,13 +90,13 @@ public class OlmInboundGroupSession implements Serializable {
/**
* Create the corresponding OLM inbound group session in native side.<br>
* Do not forget to call {@link #releaseSession()} when JAVA side is done.
* @return native session instance identifier (see {@link #mNative
OlmInboundGroupSession
Id})
* @return native session instance identifier (see {@link #mNativeId})
*/
private
native
long
init
NewSessionJni
();
private
native
long
create
NewSessionJni
();
/**
* Start a new inbound group session.<br>
* The session key parameter is retrieved from a outbound group session
* The session key parameter is retrieved from a
n
outbound group session
* see {@link OlmOutboundGroupSession#sessionKey()}
* @param aSessionKey session key
* @return 0 if operation succeed, -1 otherwise
...
...
@@ -132,8 +127,128 @@ public class OlmInboundGroupSession implements Serializable {
private
native
String
decryptMessageJni
(
String
aEncryptedMsg
);
// TODO missing API: initWithSerializedData
// TODO missing API: serializeDataWithKey
// TODO missing API: initWithCoder
// TODO missing API: encodeWithCoder
/**
* Kick off the serialization mechanism.
* @param aOutStream output stream for serializing
* @throws IOException
* @throws OlmException
*/
private
void
writeObject
(
ObjectOutputStream
aOutStream
)
throws
IOException
,
OlmException
{
aOutStream
.
defaultWriteObject
();
// generate serialization key
String
key
=
OlmUtility
.
getRandomKey
();
// compute pickle string
StringBuffer
errorMsg
=
new
StringBuffer
();
String
pickledData
=
serializeDataWithKey
(
key
,
errorMsg
);
if
(
null
==
pickledData
)
{
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_INBOUND_GROUP_SESSION_SERIALIZATION
,
String
.
valueOf
(
errorMsg
));
}
else
{
aOutStream
.
writeObject
(
key
);
aOutStream
.
writeObject
(
pickledData
);
}
}
/**
* Kick off the deserialization mechanism.
* @param aInStream
* @throws IOException
* @throws ClassNotFoundException
* @throws OlmException
*/
private
void
readObject
(
ObjectInputStream
aInStream
)
throws
IOException
,
ClassNotFoundException
,
OlmException
{
aInStream
.
defaultReadObject
();
StringBuffer
errorMsg
=
new
StringBuffer
();
String
key
=
(
String
)
aInStream
.
readObject
();
String
pickledData
=
(
String
)
aInStream
.
readObject
();
if
(
TextUtils
.
isEmpty
(
key
))
{
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_INBOUND_GROUP_SESSION_DESERIALIZATION
,
OlmException
.
EXCEPTION_MSG_INVALID_PARAMS_DESERIALIZATION
+
" key"
);
}
else
if
(
TextUtils
.
isEmpty
(
pickledData
))
{
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_INBOUND_GROUP_SESSION_DESERIALIZATION
,
OlmException
.
EXCEPTION_MSG_INVALID_PARAMS_DESERIALIZATION
+
" pickle"
);
}
else
if
(!
createNewSession
())
{
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_INBOUND_GROUP_SESSION_DESERIALIZATION
,
OlmException
.
EXCEPTION_MSG_INIT_NEW_ACCOUNT_DESERIALIZATION
);
}
else
if
(!
initWithSerializedData
(
pickledData
,
key
,
errorMsg
))
{
releaseSession
();
// prevent memory leak
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_INBOUND_GROUP_SESSION_DESERIALIZATION
,
String
.
valueOf
(
errorMsg
));
}
else
{
Log
.
d
(
LOG_TAG
,
"## readObject(): success"
);
}
}
/**
* Return a session as a base64 string.<br>
* The account is serialized and encrypted with aKey.
* In case of failure, an error human readable
* description is provide in aErrorMsg.
* @param aKey encryption key
* @param aErrorMsg error message description
* @return pickled base64 string if operation succeed, null otherwise
*/
private
String
serializeDataWithKey
(
String
aKey
,
StringBuffer
aErrorMsg
)
{
String
pickleRetValue
=
null
;
// sanity check
if
(
null
==
aErrorMsg
)
{
Log
.
e
(
LOG_TAG
,
"## serializeDataWithKey(): invalid parameter - aErrorMsg=null"
);
}
else
if
(
TextUtils
.
isEmpty
(
aKey
))
{
aErrorMsg
.
append
(
"Invalid input parameters in serializeDataWithKey()"
);
}
else
{
aErrorMsg
.
setLength
(
0
);
pickleRetValue
=
serializeDataWithKeyJni
(
aKey
,
aErrorMsg
);
}
return
pickleRetValue
;
}
/**
* JNI counter part of {@link #serializeDataWithKey(String, StringBuffer)}.
* @param aKey encryption key
* @param aErrorMsg error message description
* @return pickled base64 string if operation succeed, null otherwise
*/
private
native
String
serializeDataWithKeyJni
(
String
aKey
,
StringBuffer
aErrorMsg
);
/**
* Loads an account from a pickled base64 string.<br>
* See {@link #serializeDataWithKey(String, StringBuffer)}
* @param aSerializedData pickled account in a base64 string format
* @param aKey key used to encrypted
* @param aErrorMsg error message description
* @return true if operation succeed, false otherwise
*/
private
boolean
initWithSerializedData
(
String
aSerializedData
,
String
aKey
,
StringBuffer
aErrorMsg
)
{
boolean
retCode
=
false
;
String
jniError
;
if
(
null
==
aErrorMsg
)
{
Log
.
e
(
LOG_TAG
,
"## initWithSerializedData(): invalid input error parameter"
);
}
else
{
aErrorMsg
.
setLength
(
0
);
if
(
TextUtils
.
isEmpty
(
aSerializedData
)
||
TextUtils
.
isEmpty
(
aKey
))
{
Log
.
e
(
LOG_TAG
,
"## initWithSerializedData(): invalid input parameters"
);
}
else
if
(
null
==
(
jniError
=
initWithSerializedDataJni
(
aSerializedData
,
aKey
)))
{
retCode
=
true
;
}
else
{
aErrorMsg
.
append
(
jniError
);
}
}
return
retCode
;
}
/**
* JNI counter part of {@link #initWithSerializedData(String, String, StringBuffer)}.
* @param aSerializedData pickled account in a base64 string format
* @param aKey key used to encrypted
* @return null if operation succeed, an error message if operation failed
*/
private
native
String
initWithSerializedDataJni
(
String
aSerializedData
,
String
aKey
);
}
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
View file @
332d9d0c
...
...
@@ -32,25 +32,17 @@ public class OlmOutboundGroupSession implements Serializable {
/** session raw pointer value returned by JNI.<br>
* this value uniquely identifies the native inbound group session instance.
*/
private
long
mNativeOlmOutboundGroupSessionId
;
/**
* Getter on the native outbound group session ID.
* @return native outbound group session ID
*/
public
long
getOlmInboundGroupSessionId
(){
return
mNativeOlmOutboundGroupSessionId
;
}
private
transient
long
mNativeId
;
/**
* Constructor.<br>
* Create and save a new session native instance ID and
* initialise a new outbound group session.<br>
* See {@link #
init
NewSession()} and {@link #initOutboundGroupSession()}
* See {@link #
create
NewSession()} and {@link #initOutboundGroupSession()}
* @throws OlmException constructor failure
*/
public
OlmOutboundGroupSession
()
throws
OlmException
{
if
(
init
NewSession
())
{
if
(
create
NewSession
())
{
if
(
0
!=
initOutboundGroupSession
())
{
releaseSession
();
// prevent memory leak before throwing
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_INIT_OUTBOUND_GROUP_SESSION
,
OlmException
.
EXCEPTION_MSG_INIT_OUTBOUND_GROUP_SESSION
);
...
...
@@ -104,7 +96,7 @@ public class OlmOutboundGroupSession implements Serializable {
}
else
if
(
TextUtils
.
isEmpty
(
pickledData
))
{
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_DESERIALIZATION
,
OlmException
.
EXCEPTION_MSG_INVALID_PARAMS_DESERIALIZATION
+
" pickle"
);
}
else
if
(!
init
NewSession
())
{
}
else
if
(!
create
NewSession
())
{
throw
new
OlmException
(
OlmException
.
EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_DESERIALIZATION
,
OlmException
.
EXCEPTION_MSG_INIT_NEW_ACCOUNT_DESERIALIZATION
);
}
else
if
(!
initWithSerializedData
(
pickledData
,
key
,
errorMsg
))
{
...
...
@@ -180,26 +172,26 @@ public class OlmOutboundGroupSession implements Serializable {
*/
public
void
releaseSession
()
{
releaseSessionJni
();
mNative
OlmOutboundGroupSession
Id
=
0
;
mNativeId
=
0
;
}
/**
* Destroy the corresponding OLM outbound group session native object.<br>
* This method must ALWAYS be called when this JAVA instance
* is destroyed (ie. garbage collected) to prevent memory leak in native side.
* See {@link #
init
NewSessionJni()}.
* See {@link #
create
NewSessionJni()}.
*/
private
native
void
releaseSessionJni
();
/**
* Create and save the session native instance ID.
* Wrapper for {@link #
init
NewSessionJni()}.<br>
* Wrapper for {@link #
create
NewSessionJni()}.<br>
* To be called before any other API call.
* @return true if init succeed, false otherwise.
*/
private
boolean
init
NewSession
()
{
private
boolean
create
NewSession
()
{
boolean
retCode
=
false
;
if
(
0
!=
(
mNative
OlmOutboundGroupSessionId
=
init
NewSessionJni
())){
if
(
0
!=
(
mNative
Id
=
create
NewSessionJni
())){
retCode
=
true
;
}
return
retCode
;
...
...
@@ -208,9 +200,9 @@ public class OlmOutboundGroupSession implements Serializable {
/**
* Create the corresponding OLM outbound group session in native side.<br>
* Do not forget to call {@link #releaseSession()} when JAVA side is done.
* @return native session instance identifier (see {@link #mNative
OlmOutboundGroupSession
Id})
* @return native session instance identifier (see {@link #mNativeId})
*/
private
native
long
init
NewSessionJni
();
private
native
long
create
NewSessionJni
();
/**
* Start a new outbound group session.<br>
...
...
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
View file @
332d9d0c
...
...
@@ -31,7 +31,7 @@ public class OlmSession implements Serializable {
/** session raw pointer value (OlmSession*) returned by JNI.
* this value uniquely identifies the native session instance.
**/
private
transient
long
mNative
OlmSession
Id
;
private
transient
long
mNativeId
;
public
OlmSession
()
throws
OlmException
{
...
...
@@ -158,7 +158,7 @@ public class OlmSession implements Serializable {
* @return native session ID
*/
public
long
getOlmSessionId
(){
return
mNative
OlmSession
Id
;
return
mNativeId
;
}
/**
...
...
@@ -176,7 +176,7 @@ public class OlmSession implements Serializable {
public
void
releaseSession
(){
releaseSessionJni
();
mNative
OlmSession
Id
=
0
;
mNativeId
=
0
;
}
/**
...
...
@@ -187,7 +187,7 @@ public class OlmSession implements Serializable {
*/
private
boolean
initNewSession
()
{
boolean
retCode
=
false
;
if
(
0
!=
(
mNative
OlmSession
Id
=
initNewSessionJni
())){
if
(
0
!=
(
mNativeId
=
initNewSessionJni
())){
retCode
=
true
;
}
return
retCode
;
...
...
@@ -196,7 +196,7 @@ public class OlmSession implements Serializable {
/**
* Create the corresponding OLM session in native side.<br>
* Do not forget to call {@link #releaseSession()} when JAVA side is done.
* @return native session instance identifier (see {@link #mNative
OlmSession
Id})
* @return native session instance identifier (see {@link #mNativeId})
*/
private
native
long
initNewSessionJni
();
...
...
@@ -210,7 +210,7 @@ public class OlmSession implements Serializable {
*/
private
boolean
createNewSession
()
{
boolean
retCode
=
false
;
if
(
0
!=
(
mNative
OlmSession
Id
=
createNewSessionJni
())){
if
(
0
!=
(
mNativeId
=
createNewSessionJni
())){
retCode
=
true
;
}
return
retCode
;
...
...
@@ -219,7 +219,7 @@ public class OlmSession implements Serializable {
/**
* Create an OLM account in native side.<br>
* Do not forget to call {@link #releaseSession()} when JAVA side is done.
* @return native account instance identifier (see {@link #mNative
OlmSession
Id})
* @return native account instance identifier (see {@link #mNativeId})
*/
private
native
long
createNewSessionJni
();
...
...
java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
View file @
332d9d0c
...
...
@@ -19,7 +19,6 @@ package org.matrix.olm;
import
android.text.TextUtils
;
import
android.util.Log
;
import
java.io.Serializable
;
import
java.util.Random
;
public
class
OlmUtility
{
...
...
@@ -31,20 +30,12 @@ public class OlmUtility {
/** raw pointer value returned by JNI.
* this value uniquely identifies this utility instance.
**/