Skip to content

Commit

Permalink
Introduce ModuleDataCleaner.cleanDataFromModules(ReactContext)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
RSNara authored and facebook-github-bot committed Apr 2, 2022
1 parent b978308 commit 184dfb8
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.common.ReactConstants;

/**
Expand All @@ -36,6 +37,12 @@ public interface Cleanable {
void clearSensitiveData();
}

/**
* Please use the cleanDataFromModules(ReactContext) instead. This method is not compatible with
* bridgeless mode.
*
* @deprecated
*/
public static void cleanDataFromModules(CatalystInstance catalystInstance) {
for (NativeModule nativeModule : catalystInstance.getNativeModules()) {
if (nativeModule instanceof Cleanable) {
Expand All @@ -44,4 +51,13 @@ public static void cleanDataFromModules(CatalystInstance catalystInstance) {
}
}
}

public static void cleanDataFromModules(ReactContext reactContext) {
for (NativeModule nativeModule : reactContext.getNativeModules()) {
if (nativeModule instanceof Cleanable) {
FLog.d(ReactConstants.TAG, "Cleaning data from " + nativeModule.getName());
((Cleanable) nativeModule).clearSensitiveData();
}
}
}
}

0 comments on commit 184dfb8

Please sign in to comment.