Page MenuHomePhabricator

D6772.id22876.diff
No OneTemporary

D6772.id22876.diff

diff --git a/native/android/app/src/main/java/app/comm/android/MainApplication.java b/native/android/app/src/main/java/app/comm/android/MainApplication.java
--- a/native/android/app/src/main/java/app/comm/android/MainApplication.java
+++ b/native/android/app/src/main/java/app/comm/android/MainApplication.java
@@ -34,6 +34,8 @@
System.loadLibrary("comm_jni_module");
}
+ private static Context context;
+
private final ReactNativeHost mReactNativeHost =
new ReactNativeHostWrapper(this, new ReactNativeHost(this) {
@Override
@@ -80,6 +82,7 @@
super.onCreate();
// If you opted-in for the New Architecture, we enable the TurboModule
// system
+ MainApplication.context = this.getApplicationContext();
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
Security.insertProviderAt(new org.conscrypt.OpenSSLProvider(), 1);
@@ -104,6 +107,10 @@
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
}
+ public static Context getMainApplicationContext() {
+ return MainApplication.context;
+ }
+
private void initializeDatabase() {
File sqliteFile =
this.getApplicationContext().getDatabasePath("comm.sqlite");
diff --git a/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java b/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
--- a/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
+++ b/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
@@ -1,10 +1,11 @@
package app.comm.android.fbjni;
+import android.content.Context;
import android.util.Log;
+import app.comm.android.MainApplication;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
-
public class PlatformSpecificTools {
static SecureRandom secureRandom = new SecureRandom();
@@ -13,4 +14,16 @@
secureRandom.nextBytes(buffer);
return buffer;
}
+
+ public static String getNotificationsCryptoAccountPath() {
+ Context mainApplicationContext =
+ MainApplication.getMainApplicationContext();
+ if (mainApplicationContext == null) {
+ throw new RuntimeException(
+ "Failed to resolve notifications crypto account path - main application context not initialized.");
+ }
+ return mainApplicationContext
+ .getFileStreamPath("comm_notifications_crypto_account")
+ .getPath();
+ }
}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 6:44 PM (20 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605771
Default Alt Text
D6772.id22876.diff (2 KB)

Event Timeline