Page MenuHomePhabricator

D4240.id13600.diff
No OneTemporary

D4240.id13600.diff

diff --git a/native/android/app/src/main/java/app/comm/android/CommCoreJSIModulePackage.java b/native/android/app/src/main/java/app/comm/android/CommCoreJSIModulePackage.java
--- a/native/android/app/src/main/java/app/comm/android/CommCoreJSIModulePackage.java
+++ b/native/android/app/src/main/java/app/comm/android/CommCoreJSIModulePackage.java
@@ -13,6 +13,7 @@
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.List;
+import java.util.function.Supplier;
public class CommCoreJSIModulePackage extends ReanimatedJSIModulePackage {
@@ -20,25 +21,9 @@
public List<JSIModuleSpec> getJSIModules(
ReactApplicationContext reactApplicationContext,
JavaScriptContextHolder jsContext) {
- ModuleRegistry moduleRegistry;
- try {
- Field moduleRegistryField =
- NativeModulesProxy.class.getDeclaredField("mModuleRegistry");
- moduleRegistryField.setAccessible(true);
- NativeModulesProxy proxy =
- (NativeModulesProxy)reactApplicationContext.getCatalystInstance()
- .getNativeModule("NativeUnimoduleProxy");
- moduleRegistry = (ModuleRegistry)moduleRegistryField.get(proxy);
- } catch (Exception e) {
- throw new RuntimeException(
- "Accessing expo modules registry resulted in an error: " +
- Log.getStackTraceString(e) +
- "This might be due to changes in expo's internal implementation.");
- }
- SecureStoreModule secureStoreModule =
- (SecureStoreModule)moduleRegistry.getExportedModuleOfClass(
- SecureStoreModule.class);
- CommSecureStore.getInstance().initialize(secureStoreModule);
+ Supplier<SecureStoreModule> secureStoreModuleSupplier =
+ () -> new SecureStoreModule(reactApplicationContext);
+ CommSecureStore.getInstance().initialize(secureStoreModuleSupplier);
CommHybrid.initHybrid(reactApplicationContext);
super.getJSIModules(reactApplicationContext, jsContext);
return Collections.emptyList();
diff --git a/native/android/app/src/main/java/app/comm/android/fbjni/CommSecureStore.java b/native/android/app/src/main/java/app/comm/android/fbjni/CommSecureStore.java
--- a/native/android/app/src/main/java/app/comm/android/fbjni/CommSecureStore.java
+++ b/native/android/app/src/main/java/app/comm/android/fbjni/CommSecureStore.java
@@ -4,6 +4,7 @@
import expo.modules.core.arguments.MapArguments;
import expo.modules.core.arguments.ReadableArguments;
import expo.modules.securestore.SecureStoreModule;
+import java.util.function.Supplier;
public class CommSecureStore {
@@ -19,8 +20,15 @@
return CommSecureStore.instance;
}
- public void initialize(SecureStoreModule secureStoreModule) {
- this.secureStoreModule = secureStoreModule;
+ public void
+ initialize(Supplier<SecureStoreModule> secureStoreModuleSupplier) {
+ if (this.secureStoreModule == null) {
+ synchronized (this) {
+ if (this.secureStoreModule == null) {
+ this.secureStoreModule = secureStoreModuleSupplier.get();
+ }
+ }
+ }
}
private void checkModule() {

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 3:14 PM (21 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605179
Default Alt Text
D4240.id13600.diff (3 KB)

Event Timeline