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,
),
)
}
}
DeaConfig has a few more fields that this guide does not cover; leave them at their defaults.
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.
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.
registryAppId¶
| Type | Default | Required |
|---|---|---|
String? |
null |
No |
The appId the SDK writes inside the proofs it signs, which DEA accepts only when it names the app
behind appKey. Set it to your appId. Left null, proofs carry a built-in development id
instead. Attest and getClassification() do not read it; the proof calls on the
Ads page do.
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.
consent¶
| 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. Never enable it in production builds.
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.
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.
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.