com.cprot.ead 1.0.8128 → 1.0.8151

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,5 +87,5 @@ project.afterEvaluate {
87
87
  dependencies {
88
88
  implementation("com.facebook.react:react-native:+")
89
89
  implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.24")
90
- implementation("com.cprot:ead:1.0.8127")
90
+ implementation("com.cprot:ead:1.0.8151")
91
91
  }
@@ -218,13 +218,36 @@ class CProtEadModuleModule(reactContext: ReactApplicationContext) :
218
218
  @ReactMethod
219
219
  fun getDeviceFingerprint(promise: Promise) {
220
220
  try {
221
- val result = module?.getDeviceFingerprint() ?: ""
222
- promise.resolve(result)
221
+ module?.let { it ->
222
+ it.getDeviceFingerprint { fingerprint ->
223
+ try {
224
+ val result = fingerprint ?: ""
225
+ promise.resolve(result)
226
+ } catch (e: Exception) {
227
+ promise.reject("CALLBACK_ERROR", "Error inside fingerprint callback", e)
228
+ }
229
+ }
230
+ } ?: run {
231
+ promise.reject("MODULE_NOT_INITIALIZED", "The module is null.")
232
+ }
223
233
  } catch (e: Exception) {
224
- promise.reject("GET_DEVICE_FINGERPRINT_ERROR", "Failed to get device fingerprint", e)
234
+ promise.reject("CALL_ERROR", "Failed to invoke getDeviceFingerprint", e)
225
235
  }
226
236
  }
227
237
 
238
+ @ReactMethod
239
+ fun setPendingNotification(className: String?, argumentKey: String?, argumentPayload: String?) {
240
+ try {
241
+ module?.let { localModule ->
242
+ if (className == null) {
243
+ return
244
+ }
245
+
246
+ localModule.setPendingCProtNotification(className, argumentKey, argumentPayload)
247
+ }
248
+ } catch (e: Exception) {}
249
+ }
250
+
228
251
  @ReactMethod
229
252
  fun isRunInEmulator(promise: Promise) {
230
253
  try {
@@ -373,6 +396,49 @@ class CProtEadModuleModule(reactContext: ReactApplicationContext) :
373
396
  }
374
397
  }
375
398
 
399
+ @ReactMethod
400
+ fun getInfectedApps(promise: Promise) {
401
+ try {
402
+ val infectedApps = module?.getInfectedApps() ?: ArrayList()
403
+ val resultArray = StringBuilder()
404
+ resultArray.append("[")
405
+ for ((index, infectedApp) in infectedApps.withIndex()) {
406
+ val sb = StringBuilder()
407
+ sb.append("{")
408
+ sb.append("\"packageName\":\"").append(infectedApp.getPackageName() ?: "").append("\",")
409
+ sb.append("\"threatName\":\"").append(infectedApp.getThreatName() ?: "").append("\",")
410
+ sb.append("\"name\":\"").append(infectedApp.getName() ?: "").append("\",")
411
+ sb.append("\"version\":\"").append(infectedApp.getVersion() ?: "").append("\",")
412
+ sb.append("\"malwareTypes\":[")
413
+ val malwareEntries = infectedApp.getMalwareTypes()
414
+ if (malwareEntries != null && malwareEntries.isNotEmpty()) {
415
+ for ((i, entry) in malwareEntries.withIndex()) {
416
+ sb.append("{")
417
+ sb.append("\"type\":\"").append(entry.getMalwareType().name).append("\",")
418
+ sb.append("\"score\":").append(String.format(Locale.US, "%.2f", entry.getPercentage()))
419
+ sb.append("}")
420
+ if (i != malwareEntries.size - 1) {
421
+ sb.append(",")
422
+ }
423
+ }
424
+ }
425
+
426
+ sb.append("]")
427
+ sb.append("}")
428
+ resultArray.append(sb.toString())
429
+ if (index != infectedApps.size - 1) {
430
+ resultArray.append(",")
431
+ }
432
+ }
433
+
434
+ resultArray.append("]")
435
+ promise.resolve(resultArray.toString())
436
+ } catch (e: Exception) {
437
+ e.printStackTrace()
438
+ promise.reject("GET_INFECTED_APPS_ERROR", "Failed to get infected apps", e)
439
+ }
440
+ }
441
+
376
442
  //Send log message when ovveride functions worked.
377
443
  private fun sendLogEvent(message: String) {
378
444
  try {
@@ -416,59 +482,52 @@ class CProtEadModuleModule(reactContext: ReactApplicationContext) :
416
482
  sendLogEvent("Rooted device description: $output")
417
483
  }
418
484
 
419
- override fun onThreatDetected(infectedApps: ArrayList<InfectedApp>) {
420
- sendLogEvent("Threat detected: $infectedApps")
421
-
422
- for (infectedApp in infectedApps) {
423
- if (ConstHelper.DetectedThreats.contains(infectedApp.getPackageName())) {
424
- continue
425
- }
426
-
427
- if (infectedApp.getPackageName() != null) {
428
- val detectedTypes = StringBuilder()
429
- val malwareEntries: ArrayList<MalwareEntry>? = infectedApp.getMalwareTypes()
430
-
431
- if (malwareEntries != null && malwareEntries.isNotEmpty()) {
432
- for (entry in malwareEntries) {
433
- detectedTypes.append(entry.getMalwareType().name)
434
- .append(" - ").append("%")
435
- .append(String.format(Locale.US, "%.2f", entry.getPercentage()))
436
- .append(", ")
437
- }
438
- }
485
+ override fun onThreatDetected(infectedApps: ArrayList<InfectedApp>) {
486
+ //sendLogEvent("Threat detected: $infectedApps")
487
+ try {
488
+ val resultArray = StringBuilder()
489
+ resultArray.append("[")
490
+ for ((index, infectedApp) in infectedApps.withIndex()) {
491
+ if (ConstHelper.DetectedThreats.contains(infectedApp.getPackageName())) {
492
+ continue
493
+ }
439
494
 
440
- if (!infectedApp.getPackageName().isNullOrEmpty()) {
441
- sendLogEvent("Threat detected: ${infectedApp.getPackageName()} - ${infectedApp.getThreatName()} - [${detectedTypes}]")
442
- } else {
443
- sendLogEvent("Threat detected: ${infectedApp.getThreatName()} - ${infectedApp.getName()}")
444
- }
495
+ val sb = StringBuilder()
496
+ sb.append("{")
497
+ sb.append("\"packageName\":\"").append(infectedApp.getPackageName() ?: "").append("\",")
498
+ sb.append("\"threatName\":\"").append(infectedApp.getThreatName() ?: "").append("\",")
499
+ sb.append("\"name\":\"").append(infectedApp.getName() ?: "").append("\",")
500
+ sb.append("\"version\":\"").append(infectedApp.getVersion() ?: "").append("\",")
501
+ sb.append("\"malwareTypes\":[")
502
+ val malwareEntries = infectedApp.getMalwareTypes()
503
+ if (malwareEntries != null && malwareEntries.isNotEmpty()) {
504
+ for ((i, entry) in malwareEntries.withIndex()) {
505
+ sb.append("{")
506
+ sb.append("\"type\":\"").append(entry.getMalwareType().name).append("\",")
507
+ sb.append("\"score\":").append(String.format(Locale.US, "%.2f", entry.getPercentage()))
508
+ sb.append("}")
509
+ if (i != malwareEntries.size - 1) {
510
+ sb.append(",")
511
+ }
512
+ }
513
+ }
445
514
 
446
- /*CoroutineScope(Dispatchers.Main).launch {
447
- try {
448
- val currentActivity = reactApplicationContext.currentActivity
449
- if (currentActivity == null) {
450
- sendLogEvent("Error: No valid Activity available to show uninstall dialog")
451
- return@launch
515
+ sb.append("]")
516
+ sb.append("}")
517
+ resultArray.append(sb.toString())
518
+ if (index != infectedApps.size - 1) {
519
+ resultArray.append(",")
452
520
  }
521
+ }
453
522
 
454
- val uninstallHandler = UninstallHandler(
455
- context = currentActivity,
456
- installedAppName = infectedApp.getName() ?: "Unknown App",
457
- installedAppPackageName = infectedApp.getPackageName(),
458
- installedAppVersion = infectedApp.getVersion() ?: "Unknown Version",
459
- threatName = infectedApp.getThreatName() ?: "Unknown Threat"
460
- )
461
- uninstallHandler.showDialog()
462
- sendLogEvent("Uninstall dialog shown for ${infectedApp.getPackageName()}")
463
- } catch (e: Exception) {
464
- sendLogEvent("Error showing uninstall dialog: ${e.message}")
465
- }
466
- }*/
467
- } else {
468
- sendLogEvent("Threat detected: ${infectedApp.getName()} - ${infectedApp.getThreatName()}")
469
- }
523
+ resultArray.append("]")
524
+ val jsonString = resultArray.toString()
525
+ sendLogEvent("$jsonString")
526
+ } catch (e: Exception) {
527
+ e.printStackTrace()
528
+ sendLogEvent("[]")
470
529
  }
471
- }
530
+ }
472
531
 
473
532
  override fun onIncomingCall(state: Int, phoneNumber: String?, incomingNumber: IncomingNumber?) {
474
533
  var callType = "Idle"
@@ -477,12 +536,13 @@ class CProtEadModuleModule(reactContext: ReactApplicationContext) :
477
536
  TelephonyManager.CALL_STATE_RINGING -> callType = "Ringing"
478
537
  TelephonyManager.CALL_STATE_OFFHOOK -> callType = "off hook"
479
538
  }
539
+
480
540
  var isSpam = false
481
541
  if (incomingNumber != null) {
482
542
  isSpam = incomingNumber.isSpam
483
543
  }
484
544
 
485
- sendLogEvent("Incoming Call detected: $phoneNumber -> Is Spam: $isSpam")
545
+ sendLogEvent("Incoming Call detected: $phoneNumber -> Is Spam: $isSpam")
486
546
  }
487
547
 
488
548
  override fun onOutgoingCall(state: Int, phoneNumber: String) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.cprot.ead",
3
- "version": "1.0.8128",
3
+ "version": "1.0.8151",
4
4
  "description": "c-prot ead android module",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "lib/commonjs/index.js",