Commit 3b3f2c71 authored by Hubert Chathi's avatar Hubert Chathi
Browse files

Merge branch 'bma/upgrade_gradle' into 'master'

Update gradle wrapper and build tools

See merge request !20
parents dbbf4670 f1d8efd8
......@@ -120,8 +120,7 @@ endorsed by the Matrix.org Foundation C.I.C.
First: bump version numbers in ``common.mk``, ``CMakeLists.txt``,
``javascript/package.json``, ``python/olm/__version__.py``, ``OLMKit.podspec``, ``Package.swift``,
and ``android/olm-sdk/build.gradle`` (``versionCode``, ``versionName`` and
``version``).
and ``android/olm-sdk/java/org/matrix/olm/OlmManager.java`` in function ``getVersion()```.
Also, ensure the changelog is up to date, and that everything is committed to
git.
......
......@@ -24,6 +24,6 @@ Development
-----------
import the project from the ``android/`` path.
The project contains some JNI files and some Java wraper files.
The project contains some JNI files and some Java wrapper files.
The project contains some tests under AndroidTests package.
......@@ -2,11 +2,11 @@
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:4.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......@@ -15,7 +15,7 @@ buildscript {
allprojects {
repositories {
jcenter()
mavenCentral()
google()
}
}
......
......@@ -19,4 +19,5 @@
#systemProp.https.proxyHost=batproxy
#systemProp.http.proxyPort=8080
android.useAndroidX=true
org.gradle.configureondemand=false
#Thu Oct 13 09:38:01 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
distributionSha256Sum=81003f83b0056d20eedf48cddd4f52a9813163d4ba185bcf8abd34b8eeea4cbd
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
......@@ -3,15 +3,17 @@ import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
compileSdkVersion 30
defaultConfig {
minSdkVersion 11
targetSdkVersion 28
versionCode 322
versionName "3.2.2"
version "3.2.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 14
targetSdkVersion 30
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// The following argument makes the Android Test Orchestrator run its
// "pm clear" command after each test invocation. This command ensures
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
}
buildTypes {
debug {
......@@ -34,7 +36,7 @@ android {
jni.srcDirs = []
}
task buildJavaDoc(type: Javadoc) {
task buildJavaDoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
destinationDir = file("./doc/")
......@@ -60,14 +62,15 @@ android {
}
tasks.withType(JavaCompile) {
compileTask -> if (compileTask.name.startsWith('compileDebugJava')) {
println 'test compile: Debug'
compileTask.dependsOn ndkBuildNativeDebug
} else if (compileTask.name.startsWith('compileReleaseJava')) {
println 'test compile: Release'
compileTask.dependsOn ndkBuildNativeRelease
}
compileTask.dependsOn buildJavaDoc
compileTask ->
if (compileTask.name.startsWith('compileDebugJava')) {
println 'test compile: Debug'
compileTask.dependsOn ndkBuildNativeDebug
} else if (compileTask.name.startsWith('compileReleaseJava')) {
println 'test compile: Release'
compileTask.dependsOn ndkBuildNativeRelease
}
compileTask.dependsOn buildJavaDoc
}
clean.dependsOn cleanNative
......@@ -117,9 +120,11 @@ def gitRevisionDate() {
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:core:1.3.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
}
......@@ -18,12 +18,12 @@
package org.matrix.olm;
import android.content.Context;
import android.support.test.runner.AndroidJUnit4;
import android.text.TextUtils;
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
......@@ -41,11 +41,13 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Map;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
......@@ -59,15 +61,15 @@ public class OlmAccountTest {
private final String FILE_NAME = "SerialTestFile";
@BeforeClass
public static void setUpClass(){
public static void setUpClass() {
// load native lib
mOlmManager = new OlmManager();
String olmLibVersion = mOlmManager.getOlmLibVersion();
assertNotNull(olmLibVersion);
String olmSdkVersion = mOlmManager.getDetailedVersion(getInstrumentation().getContext());
String olmSdkVersion = mOlmManager.getDetailedVersion(ApplicationProvider.getApplicationContext());
assertNotNull(olmLibVersion);
Log.d(LOG_TAG, "## setUpClass(): Versions - Android Olm SDK = "+olmSdkVersion+" Olm lib ="+olmLibVersion);
Log.d(LOG_TAG, "## setUpClass(): Versions - Android Olm SDK = " + olmSdkVersion + " Olm lib =" + olmLibVersion);
}
@AfterClass
......@@ -77,7 +79,7 @@ public class OlmAccountTest {
@Before
public void setUp() {
if(mIsAccountCreated) {
if (mIsAccountCreated) {
assertNotNull(mOlmAccount);
}
}
......@@ -96,12 +98,12 @@ public class OlmAccountTest {
mOlmAccount = new OlmAccount();
} catch (OlmException e) {
e.printStackTrace();
assertTrue("OlmAccount failed " + e.getMessage(), false);
fail("OlmAccount failed " + e.getMessage());
}
assertNotNull(mOlmAccount);
mOlmAccount.releaseAccount();
assertTrue(0 == mOlmAccount.getOlmAccountId());
assertEquals(0, mOlmAccount.getOlmAccountId());
}
@Test
......@@ -110,7 +112,7 @@ public class OlmAccountTest {
mOlmAccount = new OlmAccount();
} catch (OlmException e) {
e.printStackTrace();
assertTrue("OlmAccount failed " + e.getMessage(), false);
fail("OlmAccount failed " + e.getMessage());
}
assertNotNull(mOlmAccount);
mIsAccountCreated = true;
......@@ -119,8 +121,8 @@ public class OlmAccountTest {
@Test
public void test04GetOlmAccountId() {
long olmNativeInstance = mOlmAccount.getOlmAccountId();
Log.d(LOG_TAG,"## testGetOlmAccountId olmNativeInstance="+olmNativeInstance);
assertTrue(0!=olmNativeInstance);
Log.d(LOG_TAG, "## testGetOlmAccountId olmNativeInstance=" + olmNativeInstance);
assertTrue(0 != olmNativeInstance);
}
/**
......@@ -134,18 +136,18 @@ public class OlmAccountTest {
try {
identityKeys = mOlmAccount.identityKeys();
} catch (Exception e) {
assertTrue("identityKeys failed " + e.getMessage(), false);
fail("identityKeys failed " + e.getMessage());
}
assertNotNull(identityKeys);
Log.d(LOG_TAG,"## testIdentityKeys Keys="+identityKeys);
Log.d(LOG_TAG, "## testIdentityKeys Keys=" + identityKeys);
// is JSON_KEY_FINGER_PRINT_KEY present?
String fingerPrintKey = TestHelper.getFingerprintKey(identityKeys);
assertTrue("fingerprint key missing",!TextUtils.isEmpty(fingerPrintKey));
assertFalse("fingerprint key missing", TextUtils.isEmpty(fingerPrintKey));
// is JSON_KEY_IDENTITY_KEY present?
String identityKey = TestHelper.getIdentityKey(identityKeys);
assertTrue("identity key missing",!TextUtils.isEmpty(identityKey));
assertFalse("identity key missing", TextUtils.isEmpty(identityKey));
}
//****************************************************
......@@ -154,9 +156,9 @@ public class OlmAccountTest {
@Test
public void test06MaxOneTimeKeys() {
long maxOneTimeKeys = mOlmAccount.maxOneTimeKeys();
Log.d(LOG_TAG,"## testMaxOneTimeKeys(): maxOneTimeKeys="+maxOneTimeKeys);
Log.d(LOG_TAG, "## testMaxOneTimeKeys(): maxOneTimeKeys=" + maxOneTimeKeys);
assertTrue(maxOneTimeKeys>0);
assertTrue(maxOneTimeKeys > 0);
}
/**
......@@ -172,7 +174,7 @@ public class OlmAccountTest {
error = e.getMessage();
}
assertTrue(null == error);
assertNull(error);
}
/**
......@@ -186,21 +188,21 @@ public class OlmAccountTest {
try {
oneTimeKeysJson = mOlmAccount.oneTimeKeys();
} catch (Exception e) {
assertTrue(e.getMessage(), false);
fail(e.getMessage());
}
assertNotNull(oneTimeKeysJson);
try {
Map<String, String> map = oneTimeKeysJson.get(OlmAccount.JSON_KEY_ONE_TIME_KEY);
assertTrue(OlmAccount.JSON_KEY_ONE_TIME_KEY +" object is missing", null!=map);
assertNotNull(OlmAccount.JSON_KEY_ONE_TIME_KEY + " object is missing", map);
// test the count of the generated one time keys:
oneTimeKeysCount = map.size();
assertTrue("Expected count="+GENERATION_ONE_TIME_KEYS_NUMBER+" found="+oneTimeKeysCount,GENERATION_ONE_TIME_KEYS_NUMBER==oneTimeKeysCount);
assertEquals("Expected count=" + GENERATION_ONE_TIME_KEYS_NUMBER + " found=" + oneTimeKeysCount, GENERATION_ONE_TIME_KEYS_NUMBER, oneTimeKeysCount);
} catch (Exception e) {
assertTrue("Exception MSg="+e.getMessage(), false);
fail("Exception MSg=" + e.getMessage());
}
}
......@@ -210,7 +212,7 @@ public class OlmAccountTest {
try {
olmSession = new OlmSession();
} catch (OlmException e) {
assertTrue("Exception Msg="+e.getMessage(), false);
fail("Exception Msg=" + e.getMessage());
}
long sessionId = olmSession.getOlmSessionId();
assertTrue(0 != sessionId);
......@@ -222,11 +224,11 @@ public class OlmAccountTest {
} catch (Exception e) {
errorMessage = e.getMessage();
}
assertTrue(null != errorMessage);
assertNotNull(errorMessage);
olmSession.releaseSession();
sessionId = olmSession.getOlmSessionId();
assertTrue(0 == sessionId);
assertEquals(0, sessionId);
}
@Test
......@@ -234,19 +236,19 @@ public class OlmAccountTest {
try {
mOlmAccount.markOneTimeKeysAsPublished();
} catch (Exception e) {
assertTrue(e.getMessage(), false);
fail(e.getMessage());
}
}
@Test
public void test12SignMessage() {
String clearMsg = "String to be signed by olm";
String signedMsg = null;
String signedMsg = null;
try {
signedMsg = mOlmAccount.signMessage(clearMsg);
} catch (Exception e) {
assertTrue(e.getMessage(), false);
fail(e.getMessage());
}
assertNotNull(signedMsg);
......@@ -263,18 +265,18 @@ public class OlmAccountTest {
FileOutputStream fileOutput;
ObjectOutputStream objectOutput;
OlmAccount accountRef = null;
OlmAccount accountDeserial = null;
OlmAccount accountDeserial;
try {
accountRef = new OlmAccount();
} catch (OlmException e) {
assertTrue(e.getMessage(),false);
fail(e.getMessage());
}
try {
accountRef.generateOneTimeKeys(GENERATION_ONE_TIME_KEYS_NUMBER);
} catch (Exception e) {
assertTrue(e.getMessage(),false);
fail(e.getMessage());
}
// get keys references
......@@ -283,7 +285,7 @@ public class OlmAccountTest {
try {
identityKeysRef = accountRef.identityKeys();
} catch (Exception e) {
assertTrue("identityKeys failed " + e.getMessage(), false);
fail("identityKeys failed " + e.getMessage());
}
Map<String, Map<String, String>> oneTimeKeysRef = null;
......@@ -291,14 +293,14 @@ public class OlmAccountTest {
try {
oneTimeKeysRef = accountRef.oneTimeKeys();
} catch (Exception e) {
assertTrue(e.getMessage(), false);
fail(e.getMessage());
}
assertNotNull(identityKeysRef);
assertNotNull(oneTimeKeysRef);
try {
Context context = getInstrumentation().getContext();
Context context = ApplicationProvider.getApplicationContext();
//context.getFilesDir();
fileOutput = context.openFileOutput(FILE_NAME, Context.MODE_PRIVATE);
......@@ -316,38 +318,34 @@ public class OlmAccountTest {
assertNotNull(accountDeserial);
// get de-serialized keys
Map<String, String> identityKeysDeserial = accountDeserial.identityKeys();
Map<String, String> identityKeysDeserial = accountDeserial.identityKeys();
Map<String, Map<String, String>> oneTimeKeysDeserial = accountDeserial.oneTimeKeys();
assertNotNull(identityKeysDeserial);
assertNotNull(oneTimeKeysDeserial);
// compare identity keys
assertTrue(identityKeysDeserial.toString().equals(identityKeysRef.toString()));
assertEquals(identityKeysDeserial.toString(), identityKeysRef.toString());
// compare onetime keys
assertTrue(oneTimeKeysDeserial.toString().equals(oneTimeKeysRef.toString()));
assertEquals(oneTimeKeysDeserial.toString(), oneTimeKeysRef.toString());
accountRef.releaseAccount();
accountDeserial.releaseAccount();
}
catch (FileNotFoundException e) {
Log.e(LOG_TAG, "## test13Serialization(): Exception FileNotFoundException Msg=="+e.getMessage());
assertTrue("test13Serialization failed " + e.getMessage(), false);
}
catch (ClassNotFoundException e) {
} catch (FileNotFoundException e) {
Log.e(LOG_TAG, "## test13Serialization(): Exception FileNotFoundException Msg==" + e.getMessage());
fail("test13Serialization failed " + e.getMessage());
} catch (ClassNotFoundException e) {
Log.e(LOG_TAG, "## test13Serialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
assertTrue("test13Serialization failed " + e.getMessage(), false);
}
catch (IOException e) {
fail("test13Serialization failed " + e.getMessage());
} catch (IOException e) {
Log.e(LOG_TAG, "## test13Serialization(): Exception IOException Msg==" + e.getMessage());
assertTrue("test13Serialization failed " + e.getMessage(), false);
fail("test13Serialization failed " + e.getMessage());
}
/*catch (OlmException e) {
Log.e(LOG_TAG, "## test13Serialization(): Exception OlmException Msg==" + e.getMessage());
}*/
catch (Exception e) {
}*/ catch (Exception e) {
Log.e(LOG_TAG, "## test13Serialization(): Exception Msg==" + e.getMessage());
assertTrue("test13Serialization failed " + e.getMessage(), false);
fail("test13Serialization failed " + e.getMessage());
}
}
......@@ -367,7 +365,7 @@ public class OlmAccountTest {
errorMessage = e.getMessage();
}
assertTrue(null == errorMessage);
assertNull(errorMessage);
// keys number = negative value
errorMessage = null;
......@@ -377,7 +375,7 @@ public class OlmAccountTest {
errorMessage = e.getMessage();
}
assertTrue(null != errorMessage);
assertNotNull(errorMessage);
}
@Test
......@@ -386,13 +384,13 @@ public class OlmAccountTest {
try {
olmAccount = new OlmAccount();
} catch (OlmException e) {
assertTrue(e.getMessage(),false);
fail(e.getMessage());
}
try {
olmAccount.removeOneTimeKeys(null);
} catch (Exception e) {
assertTrue(e.getMessage(), false);
fail(e.getMessage());
}
olmAccount.releaseAccount();
......@@ -404,7 +402,7 @@ public class OlmAccountTest {
try {
olmAccount = new OlmAccount();
} catch (OlmException e) {
assertTrue(e.getMessage(),false);
fail(e.getMessage());
}
String signedMsg = null;
......@@ -449,31 +447,31 @@ public class OlmAccountTest {
String identityKey1 = TestHelper.getIdentityKey(identityKeys1);
String identityKey2 = TestHelper.getIdentityKey(identityKeys2);
assertFalse(identityKey1.equals(identityKey2));
assertNotEquals(identityKey1, identityKey2);
String identityKey3 = TestHelper.getIdentityKey(identityKeys3);
assertFalse(identityKey2.equals(identityKey3));
assertNotEquals(identityKey2, identityKey3);
String identityKey4 = TestHelper.getIdentityKey(identityKeys4);
assertFalse(identityKey3.equals(identityKey4));
assertNotEquals(identityKey3, identityKey4);
String identityKey5 = TestHelper.getIdentityKey(identityKeys5);
assertFalse(identityKey4.equals(identityKey5));
assertNotEquals(identityKey4, identityKey5);
String identityKey6 = TestHelper.getIdentityKey(identityKeys6);
assertFalse(identityKey5.equals(identityKey6));
assertNotEquals(identityKey5, identityKey6);
String identityKey7 = TestHelper.getIdentityKey(identityKeys7);
assertFalse(identityKey6.equals(identityKey7));
assertNotEquals(identityKey6, identityKey7);
String identityKey8 = TestHelper.getIdentityKey(identityKeys8);
assertFalse(identityKey7.equals(identityKey8));
assertNotEquals(identityKey7, identityKey8);
String identityKey9 = TestHelper.getIdentityKey(identityKeys9);
assertFalse(identityKey8.equals(identityKey9));
assertNotEquals(identityKey8, identityKey9);
String identityKey10 = TestHelper.getIdentityKey(identityKeys10);
assertFalse(identityKey9.equals(identityKey10));
assertNotEquals(identityKey9, identityKey10);
account1.releaseAccount();
account2.releaseAccount();
......@@ -487,7 +485,7 @@ public class OlmAccountTest {
account10.releaseAccount();
} catch (OlmException e) {
assertTrue(e.getMessage(),false);
fail(e.getMessage());
}
}
}
......@@ -18,10 +18,12 @@
package org.matrix.olm;
import android.content.Context;
import android.support.test.runner.AndroidJUnit4;
import android.text.TextUtils;
import android.util.Log;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
......@@ -36,10 +38,12 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
......@@ -83,7 +87,7 @@ public class OlmGroupSessionTest {
try {
mAliceOutboundGroupSession = new OlmOutboundGroupSession();
} catch (OlmException e) {
assertTrue("Exception in OlmOutboundGroupSession, Exception code=" + e.getExceptionCode(), false);
fail("Exception in OlmOutboundGroupSession, Exception code=" + e.getExceptionCode());
}
}
......@@ -95,7 +99,7 @@ public class OlmGroupSessionTest {
try {
mAliceSessionIdentifier = mAliceOutboundGroupSession.sessionIdentifier();
} catch (Exception e) {
assertTrue(e.getMessage(), false);
fail(e.getMessage());
}
assertNotNull(mAliceSessionIdentifier);
......@@ -110,7 +114,7 @@ public class OlmGroupSessionTest {
try {
mAliceOutboundSessionKey = mAliceOutboundGroupSession.sessionKey();
} catch (Exception e) {
assertTrue(e.getMessage(), false);
fail(e.getMessage());
}
assertNotNull(mAliceOutboundSessionKey);
assertTrue(mAliceOutboundSessionKey.length() > 0);
......@@ -120,7 +124,7 @@ public class OlmGroupSessionTest {
public void test04GetOutboundGroupMessageIndex() {
// test message index before any encryption
mAliceMessageIndex = mAliceOutboundGroupSession.messageIndex();
assertTrue(0 == mAliceMessageIndex);
assertEquals(0, mAliceMessageIndex);
}
@Test
......@@ -129,13 +133,13 @@ public class OlmGroupSessionTest {
try {
mAliceToBobMessage = mAliceOutboundGroupSession.encryptMessage(CLEAR_MESSAGE1);
} catch (Exception e) {
assertTrue("Exception in bob encryptMessage, Exception code=" + e.getMessage(), false);