DwnProfilingSDK

class DwnProfilingSDK(appActivity: Activity? = null)

Version: 2.4.1 Supports minimum API level 23(Android 6)

The Darwinium SDK supports multiple profiling instances, which means you can create an instance per Activity/View.
In each Activity you want to profile (e.g. Login Activity/View, Payment Activity/View):
- Inside onCreate(): create an sdk instance, sdk = DwnProfilingSDK(), and start() it
- Where activity is not passed in the constructor, it MUST be passed in start(). Omitting in both functions will cause profiling to function incorrectly.
- Where biometrics are needed for particular form text fields, use addTextView()
- Inside onDestroy(): stop Darwinium's profiling with stop()

Example
// import Darwinium SDK into app
import com.darwinium.dwn_sdk.DwnProfilingSDK

class MyActivity : AppCompatActivity() {

// Darwinium support multiple sdk instances,
// it's better to declare each instance inside each activity
private var sdk: DwnProfilingSDK? = null

fun dwnApiCall(fp: String) {
// Send a https request to darwinium API server, pass profiling data within
}

override fun onCreate(savedInstanceState: Bundle?) {
val config = hashMapOf(
"profiling_debug" to true
)

// activity(this) is important for sdk profiling, it has to pass either in constructor or start()
sdk = DwnProfilingSDK()
sdk?.start(config, this)

// Clients can ask user's permissions by using darwinium provided method
// Or clients can only request their preferable permissions
sdk?.requestPermissions(this)

// apply darwinium keyboard biometrics on input fields
val username = this.findViewById<TextView>(R.id.username)
sdk?.addTextView(username, "USER_NAME")

// There are two possible methods to collect profiling data
// 1. set listener when [LOGIN] button clicked
// This is the preferred method, the client can call it after all biometric data has been collected
// e.g. key inputs, touch movements data
loginButton.setOnClickListener {
val fp = sdk?.collect() ?: ""
dwnApiCall(fp)
}

// 2. async collect with callback
// This method will be triggered asynchronously and may result in incomplete biometric data
// e.g. may not collect key inputs and touch movement data
sdk?.collectAsync(::dwnApiCall)
...
}

// stop SDK when activity destroyed
override fun onDestroy() {
sdk?.stop()
}
}

NOTES
The following libraries are not added as dependencies of the Darwinium SDK. If you want to detect location or advertising id, add the following to your app's build.gradle

// for detecting location
implementation 'com.google.android.gms:play-services-location:21.3.0'
// for detecting advertising id (Google Play devices)
implementation 'com.google.android.gms:play-services-ads-identifier:18.3.0'
// for detecting Huawei OAID / advertising id (Huawei / HarmonyOS devices)
// e.g. profiling.android.huawei_advertising_id
implementation 'com.huawei.hms:ads-identifier:3.4.62.300'

The Huawei ads-identifier library is hosted on Huawei's own maven repo, so also add that repo to your settings.gradle (scoped to the com.huawei.hms group so it isn't queried for other dependencies):

dependencyResolutionManagement {
    repositories {
        maven {
            url 'https://developer.huawei.com/repo/'
            content { includeGroup "com.huawei.hms" }
        }
    }
}

Parameters

appActivity

optional, Activity - An activity that you wish to bind to - typically you would use this and instigate within your current view.
- If you wrap sdk in a object() which doesn't know the activity during wrapper constructor, you can pass the activity in start
- Where activity is not known or not available during construction, you can pass the activity in start

Constructors

Link copied to clipboard
constructor(appActivity: Activity? = null)

constructor Creates a new Darwinium profiling instance. The Darwinium Profiling SDK is used to provide risk assessment based on device and behavioral biometric intelligence.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun addTextView(textView: TextView, keyContext: String)

Registers a text view for behavioral biometrics profiling.
Text views can provide valuable insights into typing behavior and whether facilities like copy-paste have been used.

Link copied to clipboard

Synchronous method used to collect profiling information, which is then sent in a subsequent web request.
It is recommended that you provide this in a header, 'Dwn-Profiling', if using the edge, however if not using the edge you may attach it through any means necessary and provide it in your backend call.
collect() is intended to be called after start() has been invoked, and no content will be returned if it has not.

Link copied to clipboard
fun collectAsync(callback: (String) -> Unit, timeout: Long = 15000)

Asynchronous method used to collect profiling information, with a callback function to process the profiling data.
Unlike collect(), collectAsync() waits (up to timeout) for outstanding components before collecting, so it is more likely to include biometrics such as key inputs and touch movements, and permissions granted by the user.

Link copied to clipboard
fun onFocusChange(focus: Boolean, keyContext: String)

This is for situations where text input is not handled through a standard Android UI Text component. This includes: Jetpack Compose React Native Flutter Onscreen Keyboards Where input is handled through a standard text field, this should not be used. Normally work with onTextChange on Jetpack Compose or onKeyPress on React Native App

Link copied to clipboard
fun onKeyPress(keyValue: String, keyContext: String)

This is for situations where text input is not handled through a standard Android UI Text component. This includes: Jetpack Compose React Native Flutter Onscreen Keyboards Where input is handled through a standard text field, this should not be used. This is specially react native app, if you are NOT using react native app, just ignore it Normally work with onFocusChange

Link copied to clipboard
fun onTextChange(value: String, keyContext: String)

This is for situations where text input is not handled through a standard Android UI Text component. This includes: Jetpack Compose React Native Flutter Onscreen Keyboards Where input is handled through a standard text field, this should not be used. Normally work with onFocusChange

Link copied to clipboard
fun processPermissions(requestCode: Int, grantResults: IntArray)

Used when permissions are provided by the activity.
This informs Darwinium of the permissions that have been made available to it.
You would typically call this in your activity’s onRequestPermissionsResult method.

Link copied to clipboard
fun requestPermissions(activity: Activity? = null)

Requests appropriate permissions, * such as geolocation or telephony needed to collect necessary profiling.
Note that this relies on <uses-permission> entries in your AndroidManifest.xml.
If they are not present, this will not be captured as part of the profiling performed.
Refer to The SDK installation guide for more details see also: processPermissions

Link copied to clipboard
fun start(config: <Error class: unknown class><String, Any>? = null, activity: Activity? = null)

Starts profiling.
You can call start() in activity onCreate() and pass the activity as parameter

Link copied to clipboard
fun stop()

Stops profiling.
You can call stop() in activity onDestroy()

Link copied to clipboard
fun stopTextView(keyContext: String)

Stop a text view for behavioral biometrics profiling.
This will stop one textView which was added with "keyContext"