diff --git a/native/android/app/CMakeLists.txt b/native/android/app/CMakeLists.txt --- a/native/android/app/CMakeLists.txt +++ b/native/android/app/CMakeLists.txt @@ -116,6 +116,7 @@ "./src/cpp/TerminateApp.cpp" "./src/cpp/ThreadOperationsJNIHelper.cpp" "./src/cpp/jsiInstaller.cpp" + "./src/cpp/NotificationsCryptoModuleJNIHelper.cpp" ) list(APPEND GENERATED_NATIVE_CODE diff --git a/native/android/app/src/cpp/NotificationsCryptoModuleJNIHelper.cpp b/native/android/app/src/cpp/NotificationsCryptoModuleJNIHelper.cpp new file mode 100644 --- /dev/null +++ b/native/android/app/src/cpp/NotificationsCryptoModuleJNIHelper.cpp @@ -0,0 +1,28 @@ +#include +#include + +namespace comm { +int NotificationsCryptoModuleJNIHelper::olmEncryptedTypeMessage( + facebook::jni::alias_ref jThis) { + return NotificationsCryptoModule::olmEncryptedTypeMessage; +} + +std::string NotificationsCryptoModuleJNIHelper::decrypt( + facebook::jni::alias_ref jThis, + std::string data, + int messageType, + std::string callingProcessName) { + std::string decryptedData = + NotificationsCryptoModule::decrypt(data, messageType, callingProcessName); + return decryptedData; +} + +void NotificationsCryptoModuleJNIHelper::registerNatives() { + javaClassStatic()->registerNatives({ + makeNativeMethod( + "olmEncryptedTypeMessage", + NotificationsCryptoModuleJNIHelper::olmEncryptedTypeMessage), + makeNativeMethod("decrypt", NotificationsCryptoModuleJNIHelper::decrypt), + }); +} +} // namespace comm \ No newline at end of file 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 @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -66,5 +67,6 @@ comm::MessageOperationsUtilitiesJNIHelper::registerNatives(); comm::GlobalDBSingletonJNIHelper::registerNatives(); comm::DatabaseInitializerJNIHelper::registerNatives(); + comm::NotificationsCryptoModuleJNIHelper::registerNatives(); }); } diff --git a/native/android/app/src/main/java/app/comm/android/fbjni/NotificationsCryptoModule.java b/native/android/app/src/main/java/app/comm/android/fbjni/NotificationsCryptoModule.java new file mode 100644 --- /dev/null +++ b/native/android/app/src/main/java/app/comm/android/fbjni/NotificationsCryptoModule.java @@ -0,0 +1,7 @@ +package app.comm.android.fbjni; + +public class NotificationsCryptoModule { + public static native int olmEncryptedTypeMessage(); + public static native String + decrypt(String data, int messageType, String callingProcessName); +} diff --git a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModuleJNIHelper.h b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModuleJNIHelper.h new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModuleJNIHelper.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +namespace comm { +class NotificationsCryptoModuleJNIHelper + : public facebook::jni::JavaClass { +public: + static auto constexpr kJavaDescriptor = + "Lapp/comm/android/fbjni/NotificationsCryptoModule;"; + + static int olmEncryptedTypeMessage( + facebook::jni::alias_ref jThis); + + static std::string decrypt( + facebook::jni::alias_ref jThis, + std::string data, + int messageType, + std::string callingProcessName); + + static void registerNatives(); +}; +} // namespace comm \ No newline at end of file