mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 12:37:26 +00:00
Merge branch 'master' into release/1.19.0
This commit is contained in:
@@ -60,7 +60,6 @@
|
||||
<uses-permission android:name="android.permission.RAISED_THREAD_PRIORITY" />
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" tools:node="remove"/>
|
||||
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
|
@@ -215,6 +215,17 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
||||
DatabaseModule.init(this);
|
||||
MessagingModuleConfiguration.configure(this);
|
||||
super.onCreate();
|
||||
|
||||
// we need to clear the snode and onionrequest databases once on first launch
|
||||
// in order to apply a patch that adds a version number to the Snode objects.
|
||||
if(!TextSecurePreferences.hasAppliedPatchSnodeVersion(this)) {
|
||||
ThreadUtils.queue(() -> {
|
||||
lokiAPIDatabase.clearSnodePool();
|
||||
lokiAPIDatabase.clearOnionRequestPaths();
|
||||
TextSecurePreferences.setHasAppliedPatchSnodeVersion(this, true);
|
||||
});
|
||||
}
|
||||
|
||||
messagingModuleConfiguration = new MessagingModuleConfiguration(
|
||||
this,
|
||||
storage,
|
||||
|
@@ -166,6 +166,8 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
|
||||
const val RESET_SEQ_NO = "UPDATE $lastMessageServerIDTable SET $lastMessageServerID = 0;"
|
||||
|
||||
const val EMPTY_VERSION = "0.0.0"
|
||||
|
||||
// endregion
|
||||
}
|
||||
|
||||
@@ -179,7 +181,8 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
val port = components.getOrNull(1)?.toIntOrNull() ?: return@mapNotNull null
|
||||
val ed25519Key = components.getOrNull(2) ?: return@mapNotNull null
|
||||
val x25519Key = components.getOrNull(3) ?: return@mapNotNull null
|
||||
Snode(address, port, Snode.KeySet(ed25519Key, x25519Key))
|
||||
val version = components.getOrNull(4) ?: EMPTY_VERSION
|
||||
Snode(address, port, Snode.KeySet(ed25519Key, x25519Key), version)
|
||||
}
|
||||
}?.toSet() ?: setOf()
|
||||
}
|
||||
@@ -192,6 +195,7 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
if (keySet != null) {
|
||||
string += "-${keySet.ed25519Key}-${keySet.x25519Key}"
|
||||
}
|
||||
string += "-${snode.version}"
|
||||
string
|
||||
}
|
||||
val row = wrap(mapOf( Companion.dummyKey to "dummy_key", snodePool to snodePoolAsString ))
|
||||
@@ -207,6 +211,7 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
if (keySet != null) {
|
||||
snodeAsString += "-${keySet.ed25519Key}-${keySet.x25519Key}"
|
||||
}
|
||||
snodeAsString += "-${snode.version}"
|
||||
val row = wrap(mapOf( Companion.indexPath to indexPath, Companion.snode to snodeAsString ))
|
||||
database.insertOrUpdate(onionRequestPathTable, row, "${Companion.indexPath} = ?", wrap(indexPath))
|
||||
}
|
||||
@@ -232,8 +237,9 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
val port = components.getOrNull(1)?.toIntOrNull()
|
||||
val ed25519Key = components.getOrNull(2)
|
||||
val x25519Key = components.getOrNull(3)
|
||||
val version = components.getOrNull(4) ?: EMPTY_VERSION
|
||||
if (port != null && ed25519Key != null && x25519Key != null) {
|
||||
Snode(address, port, Snode.KeySet(ed25519Key, x25519Key))
|
||||
Snode(address, port, Snode.KeySet(ed25519Key, x25519Key), version)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
@@ -251,6 +257,11 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
return result
|
||||
}
|
||||
|
||||
override fun clearSnodePool() {
|
||||
val database = databaseHelper.writableDatabase
|
||||
database.delete(snodePoolTable, null, null)
|
||||
}
|
||||
|
||||
override fun clearOnionRequestPaths() {
|
||||
val database = databaseHelper.writableDatabase
|
||||
fun delete(indexPath: String) {
|
||||
@@ -271,7 +282,8 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
val port = components.getOrNull(1)?.toIntOrNull() ?: return@mapNotNull null
|
||||
val ed25519Key = components.getOrNull(2) ?: return@mapNotNull null
|
||||
val x25519Key = components.getOrNull(3) ?: return@mapNotNull null
|
||||
Snode(address, port, Snode.KeySet(ed25519Key, x25519Key))
|
||||
val version = components.getOrNull(4) ?: EMPTY_VERSION
|
||||
Snode(address, port, Snode.KeySet(ed25519Key, x25519Key), version)
|
||||
}
|
||||
}?.toSet()
|
||||
}
|
||||
|
Reference in New Issue
Block a user