# Device

Artifact: [androidx.test.backup:backup-host](https://developer.android.com/jetpack/androidx/releases/test-backup) [View Source](https://cs.android.com/search?q=file:androidx/test/backup/host/Device.kt+class:androidx.test.backup.host.Device) Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

*** ** * ** ***


```
@MustBeDocumented
@Retention(value = AnnotationRetention.RUNTIME)
@Target(allowedTargets = [AnnotationTarget.VALUE_PARAMETER])
annotation Device
```

<br />

*** ** * ** ***

Qualifier annotation used for multi-device orchestration. Instructs the JUnit 5 extension which connected device characteristics to resolve.

A `https://developer.android.com/reference/kotlin/androidx/test/backup/host/BackupRestoreController` parameter that asks for a serial number, through `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#serial()`, a binding of `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#role()` or a system property, gets the device with that serial number. The other controller parameters of a method or constructor each get a matching online device of their own when there are enough: in the order of the parameters, each takes the first free one by serial number, and an earlier parameter moves to another device that matches it if that frees one. A parameter that can't get a device of its own shares the first device that matches it.

A device matches when its API level is `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#api()`, if set, and from `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#minApi()` to `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#maxApi()`: an exact level such as `api = 34` matches the same devices as `minApi = 34, maxApi = 34`. The system properties `androidx.test.backup.device.apis`, a comma-separated list with an API level for each controller parameter, and `androidx.test.backup.device.api`, one API level for all of them, replace `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#api()` but not `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#minApi()` and `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#maxApi()`. So for parameters whose ranges don't overlap, use the list. In both, 0 means any API level, as it does for `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#api()`. A negative value, a `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#minApi()` above `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#maxApi()`, or an `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#api()` or system property outside them fails the test with an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#Device(kotlin.String,kotlin.Int,kotlin.String,kotlin.Int,kotlin.Int)(role: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, api: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, serial: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, minApi: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxApi: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#api()` The API level that matches, exactly, such as 31 or 34. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#maxApi()` The highest API level that matches. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#minApi()` The lowest API level that matches. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#role()` The role of the device in a multi-device test, such as `"source"` or `"target"`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#serial()` The specific hardware/emulator serial number to match, or a name that the system property `androidx.test.backup.device.serial.<serial>` binds to a serial number. |

## Public constructors

### Device

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
Device(
    role: String = "",
    api: Int = 0,
    serial: String = "",
    minApi: Int = 0,
    maxApi: Int = Integer.MAX_VALUE
)
```

## Public properties

### api

```
val api: Int
```

The API level that matches, exactly, such as 31 or 34. Defaults to 0 (any API level).

### maxApi

```
val maxApi: Int
```

The highest API level that matches. Defaults to `Integer.MAX_VALUE` (no upper bound).

### minApi

```
val minApi: Int
```

The lowest API level that matches. Defaults to 0 (no lower bound).

### role

```
val role: String
```

The role of the device in a multi-device test, such as `"source"` or `"target"`. The system property `androidx.test.backup.device.serial.<role>` binds the role to the device with that serial number, whatever `https://developer.android.com/reference/kotlin/androidx/test/backup/host/Device#serial()` and the other device properties ask for. Without the property, the role doesn't change which device is selected. Defaults to "".

### serial

```
val serial: String
```

The specific hardware/emulator serial number to match, or a name that the system property `androidx.test.backup.device.serial.<serial>` binds to a serial number. The system properties `androidx.test.backup.device.serials` and `androidx.test.backup.device.serial` take precedence over a literal serial number. Defaults to "" (any match).