Update SDK JAVA API making initNewAccount() private and called in the respective constructors

This commit is contained in:
pedroGitt 2016-10-13 10:30:08 +02:00
parent 42c85adbc4
commit 618eab0086
4 changed files with 4 additions and 26 deletions

View file

@ -70,11 +70,6 @@ public class OlmAccountTest {
public void test02CreateAccount() { public void test02CreateAccount() {
mOlmAccount = new OlmAccount(); mOlmAccount = new OlmAccount();
assertNotNull(mOlmAccount); assertNotNull(mOlmAccount);
}
@Test
public void test03InitNewAccount() {
assertTrue(mOlmAccount.initNewAccount());
mIsAccountCreated = true; mIsAccountCreated = true;
} }
@ -154,7 +149,6 @@ public class OlmAccountTest {
@Test @Test
public void test10RemoveOneTimeKeysForSession() { public void test10RemoveOneTimeKeysForSession() {
OlmSession olmSession = new OlmSession(); OlmSession olmSession = new OlmSession();
olmSession.initNewSession();
long sessionId = olmSession.getOlmSessionId(); long sessionId = olmSession.getOlmSessionId();
assertTrue(0 != sessionId); assertTrue(0 != sessionId);
@ -189,7 +183,6 @@ public class OlmAccountTest {
Log.d(LOG_TAG, "## testJni(): lib version="+versionLib); Log.d(LOG_TAG, "## testJni(): lib version="+versionLib);
OlmAccount account = new OlmAccount(); OlmAccount account = new OlmAccount();
boolean initStatus = account.initNewAccount();
long accountNativeId = account.getOlmAccountId(); long accountNativeId = account.getOlmAccountId();
Log.d(LOG_TAG, "## testJni(): lib accountNativeId="+accountNativeId); Log.d(LOG_TAG, "## testJni(): lib accountNativeId="+accountNativeId);

View file

@ -50,10 +50,7 @@ public class OlmSessionTest {
// creates alice & bob accounts // creates alice & bob accounts
OlmAccount aliceAccount = new OlmAccount(); OlmAccount aliceAccount = new OlmAccount();
aliceAccount.initNewAccount();
OlmAccount bobAccount = new OlmAccount(); OlmAccount bobAccount = new OlmAccount();
bobAccount.initNewAccount();
// test accounts creation // test accounts creation
assertTrue(0!=bobAccount.getOlmAccountId()); assertTrue(0!=bobAccount.getOlmAccountId());
@ -88,7 +85,6 @@ public class OlmSessionTest {
// CREATE ALICE SESSION // CREATE ALICE SESSION
OlmSession aliceSession = new OlmSession(); OlmSession aliceSession = new OlmSession();
aliceSession.initNewSession();
assertTrue(0!=aliceSession.getOlmSessionId()); assertTrue(0!=aliceSession.getOlmSessionId());
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob // CREATE ALICE OUTBOUND SESSION and encrypt message to bob
@ -100,7 +96,6 @@ public class OlmSessionTest {
// CREATE BOB INBOUND SESSION and decrypt message from alice // CREATE BOB INBOUND SESSION and decrypt message from alice
OlmSession bobSession = new OlmSession(); OlmSession bobSession = new OlmSession();
bobSession.initNewSession();
assertTrue(0!=bobSession.getOlmSessionId()); assertTrue(0!=bobSession.getOlmSessionId());
assertNotNull(bobSession.initInboundSessionWithAccount(bobAccount, encryptedMsgToBob.mCipherText)); assertNotNull(bobSession.initInboundSessionWithAccount(bobAccount, encryptedMsgToBob.mCipherText));
String decryptedMsg = bobSession.decryptMessage(encryptedMsgToBob); String decryptedMsg = bobSession.decryptMessage(encryptedMsgToBob);
@ -140,10 +135,7 @@ public class OlmSessionTest {
// creates alice & bob accounts // creates alice & bob accounts
OlmAccount aliceAccount = new OlmAccount(); OlmAccount aliceAccount = new OlmAccount();
aliceAccount.initNewAccount();
OlmAccount bobAccount = new OlmAccount(); OlmAccount bobAccount = new OlmAccount();
bobAccount.initNewAccount();
// test accounts creation // test accounts creation
assertTrue(0!=bobAccount.getOlmAccountId()); assertTrue(0!=bobAccount.getOlmAccountId());
@ -178,7 +170,6 @@ public class OlmSessionTest {
// CREATE ALICE SESSION // CREATE ALICE SESSION
OlmSession aliceSession = new OlmSession(); OlmSession aliceSession = new OlmSession();
aliceSession.initNewSession();
assertTrue(0!=aliceSession.getOlmSessionId()); assertTrue(0!=aliceSession.getOlmSessionId());
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob // CREATE ALICE OUTBOUND SESSION and encrypt message to bob
@ -190,7 +181,6 @@ public class OlmSessionTest {
// CREATE BOB INBOUND SESSION and decrypt message from alice // CREATE BOB INBOUND SESSION and decrypt message from alice
OlmSession bobSession = new OlmSession(); OlmSession bobSession = new OlmSession();
bobSession.initNewSession();
assertTrue(0!=bobSession.getOlmSessionId()); assertTrue(0!=bobSession.getOlmSessionId());
assertNotNull(bobSession.initInboundSessionWithAccount(bobAccount, encryptedAliceToBobMsg1.mCipherText)); assertNotNull(bobSession.initInboundSessionWithAccount(bobAccount, encryptedAliceToBobMsg1.mCipherText));
@ -237,10 +227,7 @@ public class OlmSessionTest {
public void test03AliceBobSessionId() { public void test03AliceBobSessionId() {
// creates alice & bob accounts // creates alice & bob accounts
OlmAccount aliceAccount = new OlmAccount(); OlmAccount aliceAccount = new OlmAccount();
aliceAccount.initNewAccount();
OlmAccount bobAccount = new OlmAccount(); OlmAccount bobAccount = new OlmAccount();
bobAccount.initNewAccount();
// test accounts creation // test accounts creation
assertTrue(0!=bobAccount.getOlmAccountId()); assertTrue(0!=bobAccount.getOlmAccountId());
@ -248,12 +235,10 @@ public class OlmSessionTest {
// CREATE ALICE SESSION // CREATE ALICE SESSION
OlmSession aliceSession = new OlmSession(); OlmSession aliceSession = new OlmSession();
aliceSession.initNewSession();
assertTrue(0!=aliceSession.getOlmSessionId()); assertTrue(0!=aliceSession.getOlmSessionId());
// CREATE BOB INBOUND SESSION and decrypt message from alice // CREATE BOB INBOUND SESSION and decrypt message from alice
OlmSession bobSession = new OlmSession(); OlmSession bobSession = new OlmSession();
bobSession.initNewSession();
assertTrue(0!=bobSession.getOlmSessionId()); assertTrue(0!=bobSession.getOlmSessionId());
String aliceSessionId = aliceSession.sessionIdentifier(); String aliceSessionId = aliceSession.sessionIdentifier();

View file

@ -35,7 +35,7 @@ public class OlmAccount {
private long mNativeOlmAccountId; private long mNativeOlmAccountId;
public OlmAccount() { public OlmAccount() {
//initNewAccount(); initNewAccount();
} }
/** /**
@ -79,7 +79,7 @@ public class OlmAccount {
* To be called before any other API call. * To be called before any other API call.
* @return true if init succeed, false otherwise. * @return true if init succeed, false otherwise.
*/ */
public boolean initNewAccount() { private boolean initNewAccount() {
boolean retCode = false; boolean retCode = false;
if(0 != (mNativeOlmAccountId = initNewAccountJni())){ if(0 != (mNativeOlmAccountId = initNewAccountJni())){
retCode = true; retCode = true;

View file

@ -31,7 +31,7 @@ public class OlmSession {
private OlmAccount mOlmAccount; private OlmAccount mOlmAccount;
public OlmSession() { public OlmSession() {
//initNewSession(); initNewSession();
} }
/** /**
@ -76,7 +76,7 @@ public class OlmSession {
* To be called before any other API call. * To be called before any other API call.
* @return true if init succeed, false otherwise. * @return true if init succeed, false otherwise.
*/ */
public boolean initNewSession() { private boolean initNewSession() {
boolean retCode = false; boolean retCode = false;
if(0 != (mNativeOlmSessionId = initNewSessionJni())){ if(0 != (mNativeOlmSessionId = initNewSessionJni())){
retCode = true; retCode = true;