Skip to content

Options

Pass options once, to DeaSdk.init, as a DeaConfig. They are read when the SDK starts. A later init call returns the running instance and keeps its options; the later call's options are ignored without a warning.

import ai.dea.base.CAPTURE_EVENTS
import ai.dea.sdk.DeaConfig
import ai.dea.sdk.DeaSdk
import android.app.Application

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        DeaSdk.init(
            this,
            DeaConfig(
                appId = "YOUR_APP_ID",
                appKey = "YOUR_APP_KEY",
                requireConsent = true,
                consent = null,
                events = CAPTURE_EVENTS,
                motionRate = 50,
                playIntegrityProject = 123456789012L,
                modelUpdates = true,
                modelDirectory = null,
                modelTimeoutMs = 30_000,
                debug = false,
                onLog = null,
            ),
        )
    }
}

DeaConfig has a few more fields that this guide does not cover; leave them at their defaults.

Telemetry, the SDK's log and the input it captures, reaches your app on the staging and test packages: see Telemetry.

Core options

appId

Type Default Required
String "unknown-app" Yes

The appId DEA issued for this Android app. See Accounts and keys. Always pass it: the default is a placeholder. A staging or test build logs sdk.app_id_missing when appId is missing, blank or unknown-app.

appKey

Type Default Required
String? null Yes, for Attest

The app key DEA issued together with your appId. It identifies your app to DEA and is not a secret. The SDK sends it in the X-App-Key header when it registers the device key, and DEA files the registration under the app this key belongs to.

Without it, attest() and renewAttestation() answer UNSUPPORTED without contacting DEA, and detail says that no appKey was given. Surrounding whitespace is trimmed; an empty value counts as none. Reading the classification does not use it.

DeaSdk.init(this, DeaConfig(appId = "YOUR_APP_ID", appKey = "YOUR_APP_KEY"))

registryAppId

Type Default Required
String? null No

Deprecated. Ignored since 0.20.8. Proofs carry no appId: DEA takes the app from the device key that signed the proof, and checks that it is the app of appKey. The option stays so existing apps still compile. Remove it when you next update.

requireConsent

Type Default Required
Boolean true No

When true, nothing is recorded until the user has agreed. See User Consent.

Set it to false only when consent is already established outside the SDK — for example, your app asks during onboarding and calls DeaSdk.init only after the user agrees. With false, the SDK records whatever the stored answer is: setConsent(false) does not stop recording.

Type Default Required
Consent? null (the answer is stored in the app's preferences) No

Where the consent answer is kept. Leave it null to store the answer on the device, so the user is asked once. Pass Consent() to keep the answer for this launch only — for a shared device — or Consent.granted() when your own consent record already says yes. To keep the answer beside your own records, pass Consent(store = yourStore), where yourStore implements ConsentStore. See User Consent.

debug

Type Default Required
Boolean false No

Prints a line for every captured event to Logcat (tag System.out, prefixed [dea]), naming the kind of event and the session id. It prints only in an SDK build of the test channel; the SDK you ship prints nothing, with debug on or off. Never enable it in production builds.

onLog

Type Default Required
((LogEntry) -> Unit)? null No

Receives every SDK log entry, as a LogEntry from ai.dea.base.log. The SDK still writes each entry to Logcat under the tag dea. The SDK can call it on any thread, and ignores an exception it throws.

Only the staging and test packages log: staging writes INFO, WARN and ERROR, and test also writes DEBUG. The production package writes no entry, so it never calls onLog. Android has no option to change the level: filter on entry.levelText in your callback. See Telemetry.

import ai.dea.sdk.DeaConfig
import ai.dea.sdk.DeaSdk
import android.util.Log

DeaSdk.init(
    this,
    DeaConfig(
        appId = "YOUR_APP_ID",
        appKey = "YOUR_APP_KEY",
        onLog = { entry -> Log.d("MyApp", entry.line) },
    ),
)

Capture options

events

Type Default Required
List<CaptureEvent> CAPTURE_EVENTS: the first five kinds below No

The kinds of input to capture. Capturing fewer kinds reduces work but also reduces the evidence the classification is built on.

Value Captures
CaptureEvent.POINTER Finger, stylus and mouse: down, move, up, cancel and hover
CaptureEvent.SCROLL Mouse-wheel and trackpad scrolling
CaptureEvent.MOTION Accelerometer and gyroscope
CaptureEvent.LIFECYCLE The app moving to the background and back
CaptureEvent.CUSTOM Your own custom events
CaptureEvent.KEY_DOWN Key presses your app reports with captureKey. Not in the default
CaptureEvent.KEY_UP Key releases your app reports with captureKey. Not in the default

Without CaptureEvent.CUSTOM, captureEvent records nothing and returns false. Without CaptureEvent.KEY_DOWN, captureKey records nothing: the key is dropped, and a test or staging build logs capture.key_ignored once.

motionRate

Type Default Required
Int (Hz) 50 No

The accelerometer and gyroscope rate to request. The device may deliver a different rate. Once the first motion data arrives, sessionInfo.device.sensorRate reads the requested rate; 0 means no motion data has arrived. setMotion(true) after motionRate = 0 starts the sensors at 50 Hz.

Keep it at 25 or above: below that the motion data is too sparse to be useful. The SDK does not raise a lower value for you.

targets

Type Default Required
TargetReader ViewTargetReader() No

An argument of DeaSdk.init, not a field of DeaConfig. Decides which kind of control a touch landed on (a button, a link, a text field, a scrolling list) and which control it was, from the resource entry name you gave the view in your layout (buy_button). It never reads text, labels or content descriptions.

Most apps leave the default. To correct a view the default reads wrongly — for example a clickable TextView that is really a link — declare it on the view:

import ai.dea.base.TargetBucket
import ai.dea.base.deaTarget

headline.deaTarget("story_headline", TargetBucket.LINK)

Pass your own TargetReader only if your views keep their names somewhere the default does not look. It is asked on each touch down, with the window's root view and the touch's screen coordinates in pixels:

import ai.dea.base.TargetReader
import ai.dea.base.ViewTargetReader
import ai.dea.sdk.DeaConfig
import ai.dea.sdk.DeaSdk

val viewReader = ViewTargetReader()
val myReader = TargetReader { root, x, y ->
    // Look your own names up here, and fall back to the default reader.
    viewReader.targetAt(root, x, y)
}

DeaSdk.init(this, DeaConfig(appId = "YOUR_APP_ID", appKey = "YOUR_APP_KEY"), targets = myReader)

Never use a name that contains personal information.

Attestation options

playIntegrityProject

Type Default Required
Long? null Yes, for Attest

The Google Cloud project number DEA issued for your app, together with its appId and appKey. Write it with the L suffix: a twelve-digit number does not fit in an Int. See Attest.

DeaSdk.init(
    this,
    DeaConfig(appId = "YOUR_APP_ID", appKey = "YOUR_APP_KEY", playIntegrityProject = 123456789012L),
)

Model options

The SDK scores with a model built into the package. By default it also downloads newer models DEA publishes and keeps the newest on the device. It checks at every launch and, when the app returns to the foreground, again once a day has passed since the last check. The checks run in the background and never delay init or getClassification(). The SDK downloads models only from DEA's model host, over HTTPS, and loads only a version newer than the one in use; a newer model starts scoring as soon as it has loaded, within the running session. See Privacy and network for the requests.

modelUpdates

Type Default Required
Boolean true No

Set it to false to make no model request at all. The SDK then deletes any model it downloaded earlier and scores with the built-in model.

modelDirectory

Type Default Required
java.io.File? null (the app's noBackupFilesDir) No

Where a downloaded model is kept; the SDK creates dea/models/ota inside it. The default is excluded from Android backups, which is what you want: a downloaded model can always be fetched again.

modelTimeoutMs

Type Default Required
Int (ms) 30000 No

How long one model request may take before the SDK abandons it and keeps the model it has.

Reserved

DeaConfig has five more fields reserved for DEA's own tooling and tests. Leave them at their defaults:

Field What it does
integrations Ignored by the production package, except the collection transporter's stream delivery, which attaches on every package — see Collect Data. On the staging and test packages it also attaches your own integration — see Telemetry
modelUrlOverride Ignored by the production package
openCore Replaces the scoring engine; one that throws leaves the SDK as if the engine failed to load
keystore Makes the device key or Play Integrity refuse, to test those failures
transport Puts an HttpTransport in front of every request the SDK makes

The last three are honoured with any appId, as on iOS. None of them can make the SDK sign or send anything it would not otherwise.