# DeviceController

# DeviceController

Artifact:[androidx.test:monitor](https://developer.android.com/jetpack/androidx/releases/test)  
[View Source](https://cs.android.com/search?q=file:androidx/test/platform/device/DeviceController.java+class:androidx.test.platform.device.DeviceController)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/test/platform/device/DeviceController "View this page in Java")

<br />

```
interface DeviceController
```

<br />

*** ** * ** ***

Provides base-level device operations that can be used to build user actions such as folding a device, changing screen orientation etc.

This is a low level API, typically used by higher level test frameworks. It is generally not recommended for direct use by most tests. Please use high-level Espresso device APIs to interact with the device.

## Summary

|                                                                                                 ### Nested types                                                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `enum `[DeviceController.ScreenOrientation](https://developer.android.com/reference/kotlin/androidx/test/platform/device/DeviceController.ScreenOrientation) Enum for screen orientations a device can be set to. |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [setDeviceMode](https://developer.android.com/reference/kotlin/androidx/test/platform/device/DeviceController#setDeviceMode(int))`(deviceMode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets the connected device to the provided mode. unsupported device mode.           |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [setScreenOrientation](https://developer.android.com/reference/kotlin/androidx/test/platform/device/DeviceController#setScreenOrientation(int))`(screenOrientation: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets the connected device to the provided screen orientation. |

## Public functions

### setDeviceMode

```
fun setDeviceMode(deviceMode: Int): Unit
```

Sets the connected device to the provided mode. unsupported device mode.  

|                                        Parameters                                         |
|-------------------------------------------------------------------------------------------|-------------------------------|
| `deviceMode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the mode to put the device in |

|                                                                                        Throws                                                                                         |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [androidx.test.platform.device.UnsupportedDeviceOperationException](https://developer.android.com/reference/kotlin/androidx/test/platform/device/UnsupportedDeviceOperationException) | if used on an unsupported device. |

### setScreenOrientation

```
fun setScreenOrientation(screenOrientation: Int): Unit
```

Sets the connected device to the provided screen orientation.  

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|--------------------------------------|
| `screenOrientation: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the orientation to put the device in |

|                                                                                        Throws                                                                                         |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [androidx.test.platform.device.UnsupportedDeviceOperationException](https://developer.android.com/reference/kotlin/androidx/test/platform/device/UnsupportedDeviceOperationException) | if used on an unsupported device. |