DeviceClient

public 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 methods

abstract @NonNull ListenableFuture<@NonNull Device>

Gets the device signals.

abstract @NonNull Device

Gets the device signals.

Public methods

getDevice

@RequiresApi(value = 28)
abstract @NonNull ListenableFuture<@NonNull DevicegetDevice(@NonNull GetDeviceRequest request)

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
@NonNull ListenableFuture<@NonNull 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)
abstract @NonNull Device getDeviceAwait(@NonNull GetDeviceRequest request)

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
@NonNull 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.