Dwn Profiling SDK
Version: 2.0.2
Example// import Darwinium SDK into app
import com.darwinium.dwn_sdk.DwnProfilingSDK
The Darwinium SDK supports multiple profiling instances, which means you can create an instance based on Activities/Views
In each Activity,
* create an sdk instance on your activity's onCreate() method
* Where biometrics are needed for particular form text fields, use `addTextField()`
* stop Darwinium's profiling by calling <instance>.stop() on your Activity's onDestroy() method
class MyActivity : AppCompatActivity() {
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": true
)
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()
// apply darwinium keyboard biometrics on input fileds
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 {
// stop profiling before collect the information
val fp = sdk.collect()
yourApiCall(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
dwnProfiling.collectAsync(::dwnApiCall)
...
}
// stop SDK when activity destroyed
override fun onDestroy() {
sdk.stop()
}
}
NOTES
#1 The following libraries not add as dependencies for darwinium SDK, if you want to detection location or advertising_id, need add the followings in app build.grade
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.google.android.gms:play-services-ads-lite:20.3.0'
#2 if you use Proguard, add the following lines to proguard-rules.pro
-keep class com.darwinium.dwn_sdk.DwnProfilingSDK { public *; }
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
Parameters
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
Constructors
Functions
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.
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.
Asynchronous method used to collect profiling information and callback function to process the profiling data
Note: collect() wouldn't wait for some biometrics data, e.g. key inputs and touch movements data
if you want collect enough data on key inputs, touch movements and wait for permission gave by the user
It's better to call collect() after enough time for the permissions and human interactions
This is specially for Jetpack Compose UI, if you are NOT using Jetpack Compose UI, just ignore it Normally work with onTextChange
This is specially for Jetpack Compose UI, if you are NOT using Jetpack Compose UI, just ignore it Normally work with onFocusChange
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.
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
Stop a text view for behavioral biometrics profiling.
This will stop one textView which was added with "keyContext"