mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
fix: use the build static instead of build shared, add a free which works question mark(?)
This commit is contained in:
parent
a7554428d5
commit
ad00aeac4a
@ -24,6 +24,19 @@ class ExampleInstrumentedTest {
|
||||
fun jni_accessible() {
|
||||
val userProfile = UserProfile.newInstance()
|
||||
assertNotNull(userProfile)
|
||||
userProfile.free()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun jni_setting_getting() {
|
||||
val userProfile = UserProfile.newInstance()
|
||||
val newName = "test"
|
||||
println("Name being set via JNI call: $newName")
|
||||
userProfile.setName(newName)
|
||||
val nameFromNative = userProfile.getName()
|
||||
assertEquals(newName, nameFromNative)
|
||||
println("Name received by JNI call: $nameFromNative")
|
||||
userProfile.free()
|
||||
}
|
||||
|
||||
}
|
@ -13,8 +13,8 @@ project("session_util")
|
||||
# or SHARED, and provides the relative paths to its source code.
|
||||
# You can define multiple libraries, and CMake builds them for you.
|
||||
# Gradle automatically packages shared libraries with your APK.
|
||||
|
||||
set(BUILD_SHARED_LIBS ON CACHE BOOL "")
|
||||
set(STATIC_BUNDLE ON)
|
||||
#set(BUILD_SHARED_LIBS ON CACHE BOOL "")
|
||||
add_subdirectory(../../../libsession-util libsession)
|
||||
|
||||
add_library( # Sets the name of the library.
|
||||
|
@ -35,4 +35,20 @@ Java_network_loki_messenger_libsession_1util_UserProfile_setName(
|
||||
jstring newName) {
|
||||
auto profile = ptrToProfile(env, obj);
|
||||
profile->set_name(env->GetStringUTFChars(newName, nullptr));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_UserProfile_getName(JNIEnv *env, jobject obj) {
|
||||
auto profile = ptrToProfile(env, obj);
|
||||
auto name = profile->get_name();
|
||||
jstring returnString = env->NewStringUTF(name->c_str());
|
||||
return returnString;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_UserProfile_free(JNIEnv *env, jobject obj) {
|
||||
auto profile = ptrToProfile(env, obj);
|
||||
delete profile;
|
||||
}
|
@ -2,22 +2,22 @@ package network.loki.messenger.libsession_util
|
||||
|
||||
|
||||
sealed class ConfigBase(protected val /* yucky */ pointer: Long) {
|
||||
|
||||
companion object {
|
||||
init {
|
||||
System.loadLibrary("session_util")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class UserProfile(pointer: Long): ConfigBase(pointer) {
|
||||
|
||||
companion object {
|
||||
init {
|
||||
System.loadLibrary("session_util")
|
||||
}
|
||||
external fun newInstance(): UserProfile
|
||||
}
|
||||
|
||||
var lastError: String? = null
|
||||
|
||||
external fun setName(newName: String)
|
||||
|
||||
|
||||
external fun getName(): String
|
||||
external fun free()
|
||||
}
|
Loading…
Reference in New Issue
Block a user