Skip to content

Commit 184dfb8

Browse files
RSNarafacebook-github-bot
authored andcommitted
Introduce ModuleDataCleaner.cleanDataFromModules(ReactContext)
Summary: ModuleDataCleaner.cleanDataFromModules(**ReactContext**) is just like ModuleDataCleaner.cleanDataFromModules(**CatalystInstance**). However, one key difference is that this new method is bridgeless mode compatible. CatalystInstance doesn't exist in bridgeless mode. Changelog: [Android][Added] Introduce ModuleDataCleaner.cleanDataFromModules(ReactContext) Reviewed By: sshic Differential Revision: D35286939 fbshipit-source-id: 1c09a3b34add88f848eab43b42b39ab624f0818b
1 parent b978308 commit 184dfb8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/modules/common/ModuleDataCleaner.java

+16
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.facebook.common.logging.FLog;
1111
import com.facebook.react.bridge.CatalystInstance;
1212
import com.facebook.react.bridge.NativeModule;
13+
import com.facebook.react.bridge.ReactContext;
1314
import com.facebook.react.common.ReactConstants;
1415

1516
/**
@@ -36,6 +37,12 @@ public interface Cleanable {
3637
void clearSensitiveData();
3738
}
3839

40+
/**
41+
* Please use the cleanDataFromModules(ReactContext) instead. This method is not compatible with
42+
* bridgeless mode.
43+
*
44+
* @deprecated
45+
*/
3946
public static void cleanDataFromModules(CatalystInstance catalystInstance) {
4047
for (NativeModule nativeModule : catalystInstance.getNativeModules()) {
4148
if (nativeModule instanceof Cleanable) {
@@ -44,4 +51,13 @@ public static void cleanDataFromModules(CatalystInstance catalystInstance) {
4451
}
4552
}
4653
}
54+
55+
public static void cleanDataFromModules(ReactContext reactContext) {
56+
for (NativeModule nativeModule : reactContext.getNativeModules()) {
57+
if (nativeModule instanceof Cleanable) {
58+
FLog.d(ReactConstants.TAG, "Cleaning data from " + nativeModule.getName());
59+
((Cleanable) nativeModule).clearSensitiveData();
60+
}
61+
}
62+
}
4763
}

0 commit comments

Comments
 (0)