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::storeNotification( + facebook::jni::alias_ref jThis, + facebook::jni::JString sqliteFilePath, + facebook::jni::JString rawMessageInfoString) { + std::string sqliteFilePathCpp = sqliteFilePath.toStdString(); + std::string rawMessageInfoStringCpp = rawMessageInfoString.toStdString(); + SQLiteQueryExecutor::initialize(sqliteFilePathCpp); + MessageOperationsUtilities::storeNotification(rawMessageInfoStringCpp); +} + +void MessageOperationsUtilitiesJNIHelper::registerNatives() { + javaClassStatic()->registerNatives({ + makeNativeMethod( + "storeNotification", + MessageOperationsUtilitiesJNIHelper::storeNotification), + }); +} +} // 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 "jniHelpers.h" #include @@ -52,5 +53,6 @@ return jni::initialize(vm, [] { CommHybrid::registerNatives(); comm::GlobalNetworkSingletonJNIHelper::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 + storeNotification(String sqliteFilePath, String rawMessageInfo); +} diff --git a/native/cpp/CommonCpp/NativeModules/MessageOperationsUtilities/MessageOperationsUtilitiesJNIHelper.h b/native/cpp/CommonCpp/NativeModules/MessageOperationsUtilities/MessageOperationsUtilitiesJNIHelper.h new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/NativeModules/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 storeNotification( + facebook::jni::alias_ref jThis, + facebook::jni::JString sqliteFilePath, + facebook::jni::JString rawMessageInfoString); + static void registerNatives(); +}; +} // namespace comm