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.java19
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java16
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java18
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java17
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java19
5 files changed, 74 insertions, 15 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 1345a50..aeeaebc 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
@@ -35,6 +35,7 @@ import java.io.Serializable;
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
@@ -53,8 +54,8 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
never leave the device, but the public part is published to the Matrix network. **/
public static final String JSON_KEY_FINGER_PRINT_KEY = "ed25519";
- /** account raw pointer value (OlmAccount*) returned by JNI.
- * this value identifies uniquely the native account instance.
+ /** Account Id returned by JNI.
+ * This value identifies uniquely the native account instance.
*/
private transient long mNativeId;
@@ -167,7 +168,7 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
*/
public void releaseAccount(){
releaseAccountJni();
-
+ mUnreleasedCount--;
mNativeId = 0;
}
@@ -188,6 +189,7 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
private boolean initNewAccount() {
boolean retCode = false;
if(0 != (mNativeId = initNewAccountJni())){
+ mUnreleasedCount++;
retCode = true;
}
return retCode;
@@ -210,6 +212,7 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
private boolean createNewAccount() {
boolean retCode = false;
if(0 != (mNativeId = createNewAccountJni())){
+ mUnreleasedCount++;
retCode = true;
}
return retCode;
@@ -353,7 +356,7 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
private native int markOneTimeKeysAsPublishedJni();
/**
- * Sign a message with the ed25519 fingerprint key for this account.
+ * Sign a message with the ed25519 fingerprint key for this account.<br>
* The signed message is returned by the method.
* @param aMessage message to sign
* @return the signed message if operation succeed, null otherwise
@@ -362,4 +365,12 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
return signMessageJni(aMessage);
}
private native String signMessageJni(String aMessage);
+
+ /**
+ * Return the number of unreleased OlmAccount instances.<br>
+ * @return number of unreleased instances
+ */
+ public int getUnreleasedCount() {
+ return mUnreleasedCount;
+ }
}
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 6f27507..50e77f7 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
@@ -37,9 +37,10 @@ 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 raw pointer value returned by JNI.<br>
- * this value uniquely identifies the native inbound group session instance.
+ /** Session Id returned by JNI.<br>
+ * This value uniquely identifies the native inbound group session instance.
*/
private transient long mNativeId;
@@ -68,7 +69,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
*/
public void releaseSession(){
releaseSessionJni();
-
+ mUnreleasedCount--;
mNativeId = 0;
}
@@ -88,6 +89,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
private boolean createNewSession() {
boolean retCode = false;
if(0 != (mNativeId = createNewSessionJni())){
+ mUnreleasedCount++;
retCode = true;
}
return retCode;
@@ -232,4 +234,12 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
* @return null if operation succeed, an error message if operation failed
*/
private native String initWithSerializedDataJni(String aSerializedData, String aKey);
+
+ /**
+ * Return the number of unreleased OlmInboundGroupSession instances.<br>
+ * @return number of unreleased instances
+ */
+ public int getUnreleasedCount() {
+ return mUnreleasedCount;
+ }
}
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 5b59362..f7d5f17 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
@@ -35,9 +35,10 @@ 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 raw pointer value returned by JNI.<br>
- * this value uniquely identifies the native inbound group session instance.
+ /** Session Id returned by JNI.<br>
+ * This value uniquely identifies the native outbound group session instance.
*/
private transient long mNativeId;
@@ -153,7 +154,8 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
* Public API for {@link #releaseSessionJni()}.
*/
public void releaseSession() {
- releaseSessionJni();
+ releaseSessionJni();
+ mUnreleasedCount--;
mNativeId = 0;
}
@@ -174,6 +176,7 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
private boolean createNewSession() {
boolean retCode = false;
if(0 != (mNativeId = createNewSessionJni())){
+ mUnreleasedCount++;
retCode = true;
}
return retCode;
@@ -237,6 +240,7 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
/**
* Encrypt some plain-text message.<br>
+ * The message given as parameter is encrypted and returned as the return value.
* @param aClearMsg message to be encrypted
* @return the encrypted message if operation succeed, null otherwise
*/
@@ -250,4 +254,12 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
return retValue;
}
private native String encryptMessageJni(String aClearMsg);
+
+ /**
+ * Return the number of unreleased OlmOutboundGroupSession instances.<br>
+ * @return number of unreleased instances
+ */
+ public int getUnreleasedCount() {
+ return mUnreleasedCount;
+ }
}
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 ffc899a..38e8c89 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
@@ -35,9 +35,10 @@ 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 raw pointer value (OlmSession*) returned by JNI.
- * this value uniquely identifies the native session instance.
+ /** Session Id returned by JNI.
+ * This value uniquely identifies the native session instance.
**/
private transient long mNativeId;
@@ -158,7 +159,7 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
*/
public void releaseSession(){
releaseSessionJni();
-
+ mUnreleasedCount--;
mNativeId = 0;
}
@@ -171,6 +172,7 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
private boolean initNewSession() {
boolean retCode = false;
if(0 != (mNativeId = initNewSessionJni())){
+ mUnreleasedCount++;
retCode = true;
}
return retCode;
@@ -194,6 +196,7 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
private boolean createNewSession() {
boolean retCode = false;
if(0 != (mNativeId = createNewSessionJni())){
+ mUnreleasedCount++;
retCode = true;
}
return retCode;
@@ -367,5 +370,13 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
}
private native String decryptMessageJni(OlmMessage aEncryptedMsg);
+
+ /**
+ * Return the number of unreleased OlmSession instances.<br>
+ * @return number of unreleased instances
+ */
+ public int getUnreleasedCount() {
+ return mUnreleasedCount;
+ }
}
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 9bd7aaa..8cc14c0 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
@@ -29,9 +29,10 @@ public class OlmUtility {
public static final int RANDOM_KEY_SIZE = 32;
public static final int RANDOM_RANGE = 256;
+ private transient int mUnreleasedCount;
- /** raw pointer value returned by JNI.
- * this value uniquely identifies this utility instance.
+ /** Instance Id returned by JNI.
+ * This value uniquely identifies this utility instance.
**/
private long mNativeId;
@@ -47,6 +48,7 @@ public class OlmUtility {
private boolean initUtility() {
boolean retCode = false;
if(0 != (mNativeId = initUtilityJni())){
+ mUnreleasedCount++;
retCode = true;
}
return retCode;
@@ -59,6 +61,7 @@ public class OlmUtility {
*/
public void releaseUtility(){
releaseUtilityJni();
+ mUnreleasedCount--;
mNativeId = 0;
}
private native void releaseUtilityJni();
@@ -126,6 +129,10 @@ public class OlmUtility {
private native String sha256Jni(String aMessage);
+ /**
+ * Helper method to compute a string based on random integers.
+ * @return string containing randoms integer values
+ */
public static String getRandomKey() {
String keyRetValue;
Random rand = new Random();
@@ -138,5 +145,13 @@ public class OlmUtility {
return keyRetValue;
}
+
+ /**
+ * Return the number of unreleased OlmUtility instances.<br>
+ * @return number of unreleased instances
+ */
+ public int getUnreleasedCount() {
+ return mUnreleasedCount;
+ }
}