aboutsummaryrefslogtreecommitdiff
path: root/java/android/OlmLibSdk/olm-sdk/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/main')
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java26
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java18
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java34
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java27
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java19
5 files changed, 39 insertions, 85 deletions
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
index 0aa2c3d..2d91634 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
@@ -39,7 +39,6 @@ import java.util.Map;
public class OlmAccount extends CommonSerializeUtils implements Serializable {
private static final long serialVersionUID = 3497486121598434824L;
private static final String LOG_TAG = "OlmAccount";
- private transient int mUnreleasedCount;
// JSON keys used in the JSON objects returned by JNI
/** As well as the identity key, each device creates a number of Curve25519 key pairs which are
@@ -171,7 +170,6 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
*/
public void releaseAccount(){
releaseAccountJni();
- mUnreleasedCount--;
mNativeId = 0;
}
@@ -190,12 +188,8 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
* @return true if init succeed, false otherwise.
*/
private boolean initNewAccount() {
- boolean retCode = false;
- if(0 != (mNativeId = initNewAccountJni())){
- mUnreleasedCount++;
- retCode = true;
- }
- return retCode;
+ mNativeId = initNewAccountJni();
+ return (0 != mNativeId);
}
/**
@@ -213,12 +207,8 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
* @return true if init succeed, false otherwise.
*/
private boolean createNewAccount() {
- boolean retCode = false;
- if(0 != (mNativeId = createNewAccountJni())){
- mUnreleasedCount++;
- retCode = true;
- }
- return retCode;
+ mNativeId = initNewAccountJni();
+ return (0 != mNativeId);
}
/**
@@ -384,11 +374,11 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
private native String signMessageJni(byte[] aMessage);
/**
- * Return the number of unreleased OlmAccount instances.<br>
- * @return number of unreleased instances
+ * Return true the object resources have been released.<br>
+ * @return true the object resources have been released
*/
- public int getUnreleasedCount() {
- return mUnreleasedCount;
+ public boolean isReleased() {
+ return (0 == mNativeId);
}
/**
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
index ee5a20a..2e32a30 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
@@ -35,7 +35,6 @@ import java.io.Serializable;
public class OlmInboundGroupSession extends CommonSerializeUtils implements Serializable {
private static final long serialVersionUID = -772028491251653253L;
private static final String LOG_TAG = "OlmInboundGroupSession";
- private transient int mUnreleasedCount;
/** Session Id returned by JNI.<br>
* This value uniquely identifies the native inbound group session instance.
@@ -75,7 +74,6 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
*/
public void releaseSession(){
releaseSessionJni();
- mUnreleasedCount--;
mNativeId = 0;
}
@@ -93,12 +91,8 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
* @return true if init succeed, false otherwise.
*/
private boolean createNewSession() {
- boolean retCode = false;
- if(0 != (mNativeId = createNewSessionJni())){
- mUnreleasedCount++;
- retCode = true;
- }
- return retCode;
+ mNativeId = createNewSessionJni();
+ return (0 != mNativeId);
}
/**
@@ -263,10 +257,10 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
private native String initWithSerializedDataJni(String aSerializedData, String aKey);
/**
- * Return the number of unreleased OlmInboundGroupSession instances.<br>
- * @return number of unreleased instances
+ * Return true the object resources have been released.<br>
+ * @return true the object resources have been released
*/
- public int getUnreleasedCount() {
- return mUnreleasedCount;
+ public boolean isReleased() {
+ return (0 == mNativeId);
}
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
index 4aa07b4..4c09313 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
@@ -36,7 +36,6 @@ import java.io.Serializable;
public class OlmOutboundGroupSession extends CommonSerializeUtils implements Serializable {
private static final long serialVersionUID = -3133097431283604416L;
private static final String LOG_TAG = "OlmOutboundGroupSession";
- private transient int mUnreleasedCount;
/** Session Id returned by JNI.<br>
* This value uniquely identifies the native outbound group session instance.
@@ -156,7 +155,6 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
*/
public void releaseSession() {
releaseSessionJni();
- mUnreleasedCount--;
mNativeId = 0;
}
@@ -175,12 +173,8 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
* @return true if init succeed, false otherwise.
*/
private boolean createNewSession() {
- boolean retCode = false;
- if(0 != (mNativeId = createNewSessionJni())){
- mUnreleasedCount++;
- retCode = true;
- }
- return retCode;
+ mNativeId = createNewSessionJni();
+ return (0 != mNativeId);
}
/**
@@ -204,11 +198,9 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
* @return session identifier if operation succeed, null otherwise.
*/
public String sessionIdentifier() {
- String retValue = null;
- retValue = sessionIdentifierJni();
-
- return retValue;
+ return sessionIdentifierJni();
}
+
private native String sessionIdentifierJni();
/**
@@ -218,10 +210,7 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
* @return current session index
*/
public int messageIndex() {
- int retValue =0;
- retValue = messageIndexJni();
-
- return retValue;
+ return messageIndexJni();
}
private native int messageIndexJni();
@@ -232,10 +221,7 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
* @return outbound session key
*/
public String sessionKey() {
- String retValue = null;
- retValue = sessionKeyJni();
-
- return retValue;
+ return sessionKeyJni();
}
private native String sessionKeyJni();
@@ -257,10 +243,10 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
private native String encryptMessageJni(String aClearMsg);
/**
- * Return the number of unreleased OlmOutboundGroupSession instances.<br>
- * @return number of unreleased instances
+ * Return true the object resources have been released.<br>
+ * @return true the object resources have been released
*/
- public int getUnreleasedCount() {
- return mUnreleasedCount;
+ public boolean isReleased() {
+ return (0 == mNativeId);
}
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
index 374659d..139cbb6 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
@@ -36,14 +36,12 @@ import java.io.Serializable;
public class OlmSession extends CommonSerializeUtils implements Serializable {
private static final long serialVersionUID = -8975488639186976419L;
private static final String LOG_TAG = "OlmSession";
- private transient int mUnreleasedCount;
/** Session Id returned by JNI.
* This value uniquely identifies the native session instance.
**/
private transient long mNativeId;
-
public OlmSession() throws OlmException {
if(!initNewSession()) {
throw new OlmException(OlmException.EXCEPTION_CODE_INIT_SESSION_CREATION, OlmException.EXCEPTION_MSG_INIT_SESSION_CREATION);
@@ -160,7 +158,6 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
*/
public void releaseSession(){
releaseSessionJni();
- mUnreleasedCount--;
mNativeId = 0;
}
@@ -171,12 +168,8 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
* @return true if init succeed, false otherwise.
*/
private boolean initNewSession() {
- boolean retCode = false;
- if(0 != (mNativeId = initNewSessionJni())){
- mUnreleasedCount++;
- retCode = true;
- }
- return retCode;
+ mNativeId = initNewSessionJni();
+ return (0 != mNativeId);
}
/**
@@ -195,12 +188,8 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
* @return true if init succeed, false otherwise.
*/
private boolean createNewSession() {
- boolean retCode = false;
- if(0 != (mNativeId = createNewSessionJni())){
- mUnreleasedCount++;
- retCode = true;
- }
- return retCode;
+ mNativeId = initNewSessionJni();
+ return (0 != mNativeId);
}
/**
@@ -368,11 +357,11 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
private native String decryptMessageJni(OlmMessage aEncryptedMsg, boolean aIsUtf8ConversionRequired);
/**
- * Return the number of unreleased OlmSession instances.<br>
- * @return number of unreleased instances
+ * Return true the object resources have been released.<br>
+ * @return true the object resources have been released
*/
- public int getUnreleasedCount() {
- return mUnreleasedCount;
+ public boolean isReleased() {
+ return (0 == mNativeId);
}
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
index c90e552..8db9dca 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
@@ -30,7 +30,6 @@ public class OlmUtility {
public static final int RANDOM_KEY_SIZE = 32;
public static final int RANDOM_RANGE = 256;
- private transient int mUnreleasedCount;
/** Instance Id returned by JNI.
* This value uniquely identifies this utility instance.
@@ -47,13 +46,10 @@ public class OlmUtility {
* @return true if init succeed, false otherwise.
*/
private boolean initUtility() {
- boolean retCode = false;
- if(0 != (mNativeId = initUtilityJni())){
- mUnreleasedCount++;
- retCode = true;
- }
- return retCode;
+ mNativeId = initUtilityJni();
+ return (0 != mNativeId);
}
+
private native long initUtilityJni();
/**
@@ -62,7 +58,6 @@ public class OlmUtility {
*/
public void releaseUtility(){
releaseUtilityJni();
- mUnreleasedCount--;
mNativeId = 0;
}
private native void releaseUtilityJni();
@@ -148,11 +143,11 @@ public class OlmUtility {
}
/**
- * Return the number of unreleased OlmUtility instances.<br>
- * @return number of unreleased instances
+ * Return true the object resources have been released.<br>
+ * @return true the object resources have been released
*/
- public int getUnreleasedCount() {
- return mUnreleasedCount;
+ public boolean isReleased() {
+ return (0 == mNativeId);
}
}