DeviceClient

interface DeviceClient


Client to access device related apis.

Use DeviceClientFactory to create an instance that communicates with Android Device Policy app on device.

Summary

Public functions

ListenableFuture<Device>
@RequiresApi(value = 28)
getDevice(request: GetDeviceRequest)

Gets the device signals.

suspend Device

Gets the device signals.

Public functions

getDevice

@RequiresApi(value = 28)
fun getDevice(request: GetDeviceRequest): ListenableFuture<Device>

Gets the device signals.

This API requires the environment to be prepared before calling this API. The environment can be checked if it is already prepared by calling EnvironmentClient.getEnvironment. If the environment is not prepared, it can be prepared by calling EnvironmentClient.prepareEnvironment.

Note: The signals returned may be different depending on the caller and the device management status.

Returns
ListenableFuture<Device>

A ListenableFuture wrapping the result. This can be

  • A successful future wrapping a Device, in case of success.

  • A failed future wrapping a ApiLevelException if the device API level is less than 28.

  • A failed future wrapping a EnvironmentNotPreparedException, if call failed. The message and the subtype of the exception contain more details about the failure.

  • A failed future wrapping a SecurityException, if the caller is not authorized to call this API.

  • A failed future wrapping a TimeoutException, if call failed due to a timeout.

  • A failed future wrapping a InternalException, if call failed due to an internal error.

getDeviceAwait

@RequiresApi(value = 28)
suspend fun getDeviceAwait(request: GetDeviceRequest): Device

Gets the device signals.

This API requires the environment to be prepared before calling this API. The environment can be checked if it is already prepared by calling EnvironmentClient.getEnvironment. If the environment is not prepared, it can be prepared by calling EnvironmentClient.prepareEnvironment.

Note: The signals returned may be different depending on the caller and the device management status.

Returns
Device

Device representing the device signals.

Throws
com.google.android.managementapi.common.exceptions.ApiLevelException

If the device API level is less than 28.

com.google.android.managementapi.environment.exception.EnvironmentNotPreparedException

If call failed. The message and the subtype of the exception contain more details about the failure.

java.lang.SecurityException

If the caller is not authorized to call this API.

java.util.concurrent.TimeoutException

If call failed due to a timeout.

com.google.android.managementapi.common.exceptions.InternalException

If call failed due to an internal error.