Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3528169
D4957.id15998.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4957.id15998.diff
View Options
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -17,6 +17,10 @@
#include <system_error>
#include <thread>
+#ifdef __ANDROID__
+#include <fbjni/fbjni.h>
+#endif
+
#define ACCOUNT_ID 1
namespace comm {
@@ -340,6 +344,19 @@
return true;
}
+void run_with_native_accessible(std::function<void()> &&task) {
+ // Some methods of SQLiteQueryExecutor are meant to be executed on
+ // auxiliary threads. In case they require access to native Java
+ // API we need to temporarily attach the thread to JVM
+ // This function attaches thread to JVM for the time
+ // lambda passed to this function will be executing.
+#ifdef __ANDROID__
+ facebook::jni::ThreadScope::WithClassLoader(std::move(task));
+#else
+ task();
+#endif
+}
+
void validate_encryption() {
std::string temp_encrypted_db_path =
SQLiteQueryExecutor::sqliteFilePath + "_temp_encrypted";
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 8:28 AM (11 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2702065
Default Alt Text
D4957.id15998.diff (1 KB)
Attached To
Mode
D4957: Introduce utility function to temporarily attach thread to JVM
Attached
Detach File
Event Timeline
Log In to Comment