mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-18 02:58:27 +00:00
feat: add dump functionality
This commit is contained in:
parent
188e7b5ec0
commit
2daf231e59
@ -89,7 +89,21 @@ class InstrumentedTests {
|
||||
|
||||
assertEquals(1, newSeqNo)
|
||||
assertArrayEquals(expectedPush1, newToPush)
|
||||
// We haven't dumped, so still need to dump:
|
||||
assertTrue(userProfile.needsDump())
|
||||
// We did call push but we haven't confirmed it as stored yet, so this will still return true:
|
||||
assertTrue(userProfile.needsPush())
|
||||
|
||||
val dump = userProfile.dump()
|
||||
// (in a real client we'd now store this to disk)
|
||||
assertFalse(userProfile.needsDump())
|
||||
val expectedDump = ("d" +
|
||||
"1:!i2e" +
|
||||
"1:$").encodeToByteArray() + expectedPush1.size.toString().encodeToByteArray() +
|
||||
":".encodeToByteArray() + expectedPush1 +
|
||||
"e".encodeToByteArray()
|
||||
|
||||
assertArrayEquals(expectedDump, dump)
|
||||
|
||||
userProfile.free()
|
||||
}
|
||||
|
@ -137,4 +137,12 @@ Java_network_loki_messenger_libsession_1util_UserProfile_setPic(JNIEnv *env, job
|
||||
auto* pic_string = new std::string(pic_chars);
|
||||
|
||||
profile->set_profile_pic(*pic_string, key_str);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_ConfigBase_dump(JNIEnv *env, jobject thiz) {
|
||||
auto config = ptrToConfigBase(env, thiz);
|
||||
std::string dumped = config->dump();
|
||||
jbyteArray bytes = bytes_from_string(env, dumped);
|
||||
return bytes;
|
||||
}
|
@ -13,6 +13,7 @@ sealed class ConfigBase(protected val /* yucky */ pointer: Long) {
|
||||
external fun needsPush(): Boolean
|
||||
external fun needsDump(): Boolean
|
||||
external fun push(): ConfigWithSeqNo
|
||||
external fun dump(): ByteArray
|
||||
}
|
||||
|
||||
class UserProfile(pointer: Long): ConfigBase(pointer) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user