Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3366983
D5923.id19634.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D5923.id19634.diff
View Options
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
@@ -1,16 +1,12 @@
package app.comm.android;
-import android.util.Log;
import app.comm.android.fbjni.CommHybrid;
import app.comm.android.fbjni.CommSecureStore;
import com.facebook.react.bridge.JSIModuleSpec;
import com.facebook.react.bridge.JavaScriptContextHolder;
import com.facebook.react.bridge.ReactApplicationContext;
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
-import expo.modules.adapters.react.NativeModulesProxy;
-import expo.modules.core.ModuleRegistry;
import expo.modules.securestore.SecureStoreModule;
-import java.lang.reflect.Field;
import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
@@ -22,7 +18,7 @@
ReactApplicationContext reactApplicationContext,
JavaScriptContextHolder jsContext) {
Supplier<SecureStoreModule> secureStoreModuleSupplier =
- () -> new SecureStoreModule(reactApplicationContext);
+ ExpoUtils.createExpoSecureStoreSupplier(reactApplicationContext);
CommSecureStore.getInstance().initialize(secureStoreModuleSupplier);
CommHybrid.initHybrid(reactApplicationContext);
super.getJSIModules(reactApplicationContext, jsContext);
diff --git a/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java b/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java
--- a/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java
+++ b/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java
@@ -10,12 +10,9 @@
import app.comm.android.fbjni.NetworkModule;
import app.comm.android.fbjni.ThreadOperations;
import com.google.firebase.messaging.RemoteMessage;
-import expo.modules.securestore.SecureStoreModule;
import io.invertase.firebase.messaging.RNFirebaseMessagingService;
import java.io.File;
import me.leolin.shortcutbadger.ShortcutBadger;
-import org.json.JSONException;
-import org.json.JSONObject;
/**
* We're extending RNFirebaseMessagingService here instead of
@@ -57,7 +54,7 @@
public void onCreate() {
super.onCreate();
CommSecureStore.getInstance().initialize(
- () -> new SecureStoreModule(this.getApplicationContext()));
+ ExpoUtils.createExpoSecureStoreSupplier(this.getApplicationContext()));
notificationManager = (NotificationManager)this.getSystemService(
Context.NOTIFICATION_SERVICE);
}
diff --git a/native/android/app/src/main/java/app/comm/android/ExpoUtils.java b/native/android/app/src/main/java/app/comm/android/ExpoUtils.java
new file mode 100644
--- /dev/null
+++ b/native/android/app/src/main/java/app/comm/android/ExpoUtils.java
@@ -0,0 +1,40 @@
+package app.comm.android;
+
+import android.content.Context;
+import androidx.annotation.NonNull;
+import com.facebook.react.bridge.ReactContext;
+import expo.modules.adapters.react.services.UIManagerModuleWrapper;
+import expo.modules.core.ModuleRegistry;
+import expo.modules.core.interfaces.InternalModule;
+import expo.modules.securestore.SecureStoreModule;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Supplier;
+
+public class ExpoUtils {
+ public static Supplier<SecureStoreModule>
+ createExpoSecureStoreSupplier(@NonNull Context context) {
+ return () -> {
+ List<InternalModule> expoInternalModules = new ArrayList<>(1);
+ if (context instanceof ReactContext) {
+ // We can only provide the UIManager module if provided context is a
+ // React context. If this is called from non-react activity, like
+ // CommNotificationsHandler, we skip adding this module. This is fine,
+ // unless we use the `requiresAuthentication` option when dealing with
+ // expo-secure-store (at this moment we don't use it anywhere)
+ expoInternalModules.add(
+ new UIManagerModuleWrapper((ReactContext)context));
+ }
+
+ ModuleRegistry expoModuleRegistry = new ModuleRegistry(
+ expoInternalModules,
+ Collections.emptyList(),
+ Collections.emptyList(),
+ Collections.emptyList());
+ SecureStoreModule secureStoreModule = new SecureStoreModule(context);
+ secureStoreModule.onCreate(expoModuleRegistry);
+ return secureStoreModule;
+ };
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 1:12 PM (11 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2584855
Default Alt Text
D5923.id19634.diff (4 KB)
Attached To
Mode
D5923: [native] [28/40] RN 0.70: Fix Expo 47 SecureStore crash on Android
Attached
Detach File
Event Timeline
Log In to Comment