diff --git a/native/android/app/src/cpp/MessageOperationsUtilitiesJNIHelper.cpp b/native/android/app/src/cpp/MessageOperationsUtilitiesJNIHelper.cpp new file mode 100644 --- /dev/null +++ b/native/android/app/src/cpp/MessageOperationsUtilitiesJNIHelper.cpp @@ -0,0 +1,23 @@ +#include "MessageOperationsUtilitiesJNIHelper.h" +#include "MessageOperationsUtilities.h" +#include "SQLiteQueryExecutor.h" + +namespace comm { +void MessageOperationsUtilitiesJNIHelper::storeMessageInfos( + facebook::jni::alias_ref jThis, + facebook::jni::JString sqliteFilePath, + facebook::jni::JString rawMessageInfosString) { + std::string sqliteFilePathCpp = sqliteFilePath.toStdString(); + std::string rawMessageInfosStringCpp = rawMessageInfosString.toStdString(); + SQLiteQueryExecutor::initialize(sqliteFilePathCpp); + MessageOperationsUtilities::storeMessageInfos(rawMessageInfosStringCpp); +} + +void MessageOperationsUtilitiesJNIHelper::registerNatives() { + javaClassStatic()->registerNatives({ + makeNativeMethod( + "storeMessageInfos", + MessageOperationsUtilitiesJNIHelper::storeMessageInfos), + }); +} +} // namespace comm diff --git a/native/android/app/src/cpp/jsiInstaller.cpp b/native/android/app/src/cpp/jsiInstaller.cpp --- a/native/android/app/src/cpp/jsiInstaller.cpp +++ b/native/android/app/src/cpp/jsiInstaller.cpp @@ -1,5 +1,6 @@ #include "CommCoreModule.h" #include "GlobalNetworkSingletonJNIHelper.h" +#include "MessageOperationsUtilitiesJNIHelper.h" #include "SQLiteQueryExecutor.h" #include "ThreadOperationsJNIHelper.h" #include "jniHelpers.h" @@ -54,5 +55,6 @@ CommHybrid::registerNatives(); comm::GlobalNetworkSingletonJNIHelper::registerNatives(); comm::ThreadOperationsJNIHelper::registerNatives(); + comm::MessageOperationsUtilitiesJNIHelper::registerNatives(); }); } diff --git a/native/android/app/src/main/java/app/comm/android/fbjni/MessageOperationsUtilities.java b/native/android/app/src/main/java/app/comm/android/fbjni/MessageOperationsUtilities.java new file mode 100644 --- /dev/null +++ b/native/android/app/src/main/java/app/comm/android/fbjni/MessageOperationsUtilities.java @@ -0,0 +1,6 @@ +package app.comm.android.fbjni; + +public class MessageOperationsUtilities { + public static native void + storeMessageInfos(String sqliteFilePath, String rawMessageInfosString); +} diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageOperationsUtilitiesJNIHelper.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageOperationsUtilitiesJNIHelper.h new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageOperationsUtilitiesJNIHelper.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace comm { +class MessageOperationsUtilitiesJNIHelper + : public facebook::jni::JavaClass { +public: + static auto constexpr kJavaDescriptor = + "Lapp/comm/android/fbjni/MessageOperationsUtilities;"; + + static void storeMessageInfos( + facebook::jni::alias_ref jThis, + facebook::jni::JString sqliteFilePath, + facebook::jni::JString rawMessageInfosString); + static void registerNatives(); +}; +} // namespace comm