File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
android/src/main/java/com/freeraspreactnative Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -50,12 +50,15 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex
5050 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .UPSIDE_DOWN_CAKE ) {
5151 reactContext.currentActivity?.let { ScreenProtector .unregister(it) }
5252 }
53+ if (reactContext.currentActivity?.isFinishing == true ) {
54+ PluginThreatHandler .threatDispatcher.unregisterListener()
55+ PluginThreatHandler .executionStateDispatcher.unregisterListener()
56+ PluginThreatHandler .unregisterSDKListener(reactContext)
57+ }
5358 }
5459
5560 override fun onHostDestroy () {
5661 backgroundHandlerThread.quitSafely()
57- PluginThreatHandler .threatDispatcher.unregisterListener()
58- PluginThreatHandler .executionStateDispatcher.unregisterListener()
5962 }
6063 }
6164
@@ -73,10 +76,14 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex
7376 fun talsecStart (
7477 options : ReadableMap , promise : Promise
7578 ) {
79+ if (talsecStarted) {
80+ promise.resolve(" freeRASP started" )
81+ return
82+ }
7683
7784 try {
7885 val config = buildTalsecConfig(options)
79- PluginThreatHandler .registerListener (reactContext)
86+ PluginThreatHandler .registerSDKListener (reactContext)
8087 runOnUiThread {
8188 Talsec .start(reactContext, config, TalsecMode .BACKGROUND )
8289 mainHandler.post {
@@ -344,4 +351,4 @@ class FreeraspReactNativeModule(private val reactContext: ReactApplicationContex
344351 .emit(eventName, params)
345352 }
346353 }
347- }
354+ }
Original file line number Diff line number Diff line change @@ -116,11 +116,11 @@ internal object PluginThreatHandler {
116116
117117 private val internalListener = ThreatListener (threatDetected, deviceState, raspExecutionState)
118118
119- internal fun registerListener (context : Context ) {
119+ internal fun registerSDKListener (context : Context ) {
120120 internalListener.registerListener(context)
121121 }
122122
123- internal fun unregisterListener (context : Context ) {
123+ internal fun unregisterSDKListener (context : Context ) {
124124 internalListener.unregisterListener(context)
125125 }
126126}
You can’t perform that action at this time.
0 commit comments