For the complete documentation index, see llms.txt. This page is also available as Markdown.

Handling Results

When the background evaluation process completes and identifies one or more threats, the detection engine triggers a callback to your application. This section details how to intercept this callback, parse the threat data, and implement dynamic remediation strategies.


Receiving the Callback

The results of the scan are delivered asynchronously via the standard Threat Callback mechanism. Because the engine automatically filters out safe system applications and caches benign results, this callback is only fired if a suspicious application is actively detected on the device.

Implement the onMalwareDetected method from the ThreatListener.ThreatDetected interface:

override fun onMalwareDetected(suspiciousApps: List<SuspiciousAppInfo>?) {
    suspiciousApps?.forEach { app ->
        Log.w("Talsec", "Detected malware: ${app.packageInfo.packageName}")
    }
}

Provide the onMalware callback within your ThreatCallback object:

final callback = ThreatCallback(
    onMalware: (List<SuspiciousAppInfo?> suspiciousApps) {
        for (var app in suspiciousApps) {
            print('Detected malware: ${app?.packageInfo.packageName}');
        }
    },
    // Other callbacks...
);

Add the malware callback to your actions object:

import { type SuspiciousAppInfo } from 'freerasp-react-native';

const actions = {
    // Other threat callbacks...
    malware: (suspiciousApps: SuspiciousAppInfo[]) => {
        console.log('Detected suspicious apps: ', suspiciousApps);
    },
};

Add the malware callback to your actions object:

Add the malware callback to your actions object:

Collect FreeRaspEvent.Malware events from the threatEvents SharedFlow:


Interpreting SuspiciousAppInfo

For each identified threat, the engine generates a SuspiciousAppInfo data object containing metadata about the offending application and the specific rules it violated.

The structure of this object depends on the version of the module integrated into your project.

Modern (V2) API

Compatibility

Android: 18.1.0 | Flutter: 8.0.0 | React Native: 5.0.0 |

Capacitor: 3.0.0 | Cordova: 9.0.0 | KMP: 2.0.0

Property
Type
Description

packageInfo.packageName

String

Unique package identifier.

packageInfo.appName

String?

Public display name.

packageInfo.version

String?

versionName string.

packageInfo.installerStore

String?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

String?

Base64 encoded icon (null by default).

reasons

Set<String>

Rules violated (blocklist, installSource, suspiciousPermission).

permissions

Set<String>?

Exact permissions that triggered detection (if flagged with suspiciousPermission).

Property
Type
Description

packageInfo.packageName

String

Unique package identifier.

packageInfo.appName

String?

Public display name.

packageInfo.version

String?

versionName string.

packageInfo.installerStore

String?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

String?

Base64 encoded icon (null by default).

reasons

List<String>

Rules violated (blocklist, installSource, suspiciousPermission).

permissions

List<String>?

Exact permissions that triggered detection (if flagged with suspiciousPermission).

Property
Type
Description

packageInfo.packageName

string

Unique package identifier.

packageInfo.appName

string?

Public display name.

packageInfo.version

string?

versionName string.

packageInfo.installerStore

string?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

string?

Base64 encoded icon (null by default).

reasons

string[]

Rules violated (blocklist, installSource, suspiciousPermission).

permissions

string[]?

Exact permissions that triggered detection (if flagged with suspiciousPermission).

Property
Type
Description

packageInfo.packageName

string

Unique package identifier.

packageInfo.appName

string?

Public display name.

packageInfo.version

string?

versionName string.

packageInfo.installerStore

string?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

string?

Base64 encoded icon (null by default).

reasons

string[]

Rules violated (blocklist, installSource, suspiciousPermission).

permissions

string[]?

Exact permissions that triggered detection (if flagged with suspiciousPermission).

Property
Type
Description

packageInfo.packageName

string

Unique package identifier.

packageInfo.appName

string?

Public display name.

packageInfo.version

string?

versionName string.

packageInfo.installerStore

string?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

string?

Base64 encoded icon (null by default).

reasons

string[]

Rules violated (blocklist, installSource, suspiciousPermission).

permissions

string[]?

Exact permissions that triggered detection (if flagged with suspiciousPermission).

Property
Type
Description

packageInfo.packageName

String

Unique package identifier.

packageInfo.appName

String?

Public display name.

packageInfo.version

String?

versionName string.

packageInfo.installerStore

String?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

String?

Base64 encoded icon (null by default).

reasons

Set<String>

Rules violated (blocklist, installSource, suspiciousPermission).

permissions

Set<String>?

Exact permissions that triggered detection (if flagged with suspiciousPermission).

Premium Tier Extension

The Premium tier adds a fourth reason: onlineMalwareDatabase — returned when the application is confirmed as malicious by the App Reputation API cloud database.

Legacy (V1) API

Compatibility

Android: <18.1.0 | Flutter: <8.0.0 | React Native: <5.0.0 |

Capacitor: <3.0.0 | Cordova: <9.0.0 | KMP: <2.0.0

Property
Type
Description

packageInfo

PackageInfo

The native Android PackageInfo object. Provides comprehensive OS-level metadata about the flagged application (e.g., version, signatures, installed location).

reason

String

The primary threat signal (blocklist, installSource, or suspiciousPermission). Returns only the highest-priority match (suspiciousPermission overrides installSource).

Property
Type
Description

packageInfo.packageName

String

Unique package identifier.

packageInfo.appName

String?

Public display name.

packageInfo.version

String?

versionName string.

packageInfo.installationSource

String?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

String?

Base64 encoded icon (null by default).

reason

String

The primary threat signal (blocklist, installSource, or suspiciousPermission). Returns only the highest-priority match (suspiciousPermission overrides installSource).

Property
Type
Description

packageInfo.packageName

string

Unique package identifier.

packageInfo.appName

string?

Public display name.

packageInfo.version

string?

versionName string.

packageInfo.installerStore

string?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

string?

Base64 encoded icon (null by default).

reason

string

The primary threat signal (blocklist, installSource, or suspiciousPermission). Returns only the highest-priority match (suspiciousPermission overrides installSource).

Property
Type
Description

packageInfo.packageName

string

Unique package identifier.

packageInfo.appName

string?

Public display name.

packageInfo.version

string?

versionName string.

packageInfo.installerStore

string?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

string?

Base64 encoded icon (null by default).

reason

string

The primary threat signal (blocklist, installSource, or suspiciousPermission). Returns only the highest-priority match (suspiciousPermission overrides installSource).

Property
Type
Description

packageInfo.packageName

string

Unique package identifier.

packageInfo.appName

string?

Public display name.

packageInfo.version

string?

versionName string.

packageInfo.installerStore

string?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

string?

Base64 encoded icon (null by default).

reason

string

The primary threat signal (blocklist, installSource, or suspiciousPermission). Returns only the highest-priority match (suspiciousPermission overrides installSource).

Property
Type
Description

packageInfo.packageName

String

Unique package identifier.

packageInfo.appName

String?

Public display name.

packageInfo.version

String?

versionName string.

packageInfo.installerStore

String?

Installer package name (e.g., com.android.vending).

packageInfo.appIcon

String?

Base64 encoded icon (null by default).

reason

String

The primary threat signal (blocklist, installSource, or suspiciousPermission). Returns only the highest-priority match (suspiciousPermission overrides installSource).


Retrieving the App Icon

By default, the appIcon property is omitted to reduce the computation time required to serialize the payload. If your application requires displaying a threat warning dialog with visual context, retrieve the icon asynchronously.

Retrieve the icon natively using the Android PackageManager:

Exception Handling Required

The getAppIcon() Promise will reject if the target application is uninstalled before the fetch completes. Wrap the await call in a try-catch block.


Local Whitelisting

Because behavioral heuristics are probabilistic, legitimate tools may occasionally be flagged. To handle false positives, you can manually whitelist specific package names on the local device.

Once an application is whitelisted, the engine ignores it during all future evaluations until the detection configuration changes.


Remediation

If you determine an application is an absolute threat and the user is unable to proceed, you can programmatically prompt them to uninstall it.

Because Android security constraints prevent applications from silently uninstalling other packages, remediation requires direct user intervention. The standard approach is to dispatch a native Intent that routes the user to the system's Application Details screen.

Last updated