### Specify app for setup Source: https://developers.google.com/android/management/provision-device Define an application to be installed and launched during device setup. Ensure the `installType` is set to `REQUIRED_FOR_SETUP` for provisioning to succeed. ```json { "applications":[ { "packageName":"com.my.vpnapp.", "installType":"REQUIRED_FOR_SETUP" } ] } ``` -------------------------------- ### startAccountSetup Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Starts a new account setup process for a managed device. This is a synchronous call. ```APIDOC ## startAccountSetup ### Description Starts a new account setup process for a managed device. This is a synchronous call. ### Method POST ### Endpoint /v1/devices/{deviceName}/accountSetupAttempts ### Parameters #### Path Parameters - **deviceName** (string) - Required - The name of the device to start account setup for. #### Request Body - **accountSetupConfiguration** (object) - Required - Configuration for the account setup. - **username** (string) - Required - The username for the managed account. - **password** (string) - Required - The password for the managed account. ### Response #### Success Response (200) - **attemptId** (string) - The ID of the newly created account setup attempt. ``` -------------------------------- ### Start Account Setup (Synchronous) Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/AccountSetupClient Initiates account setup synchronously. This method delegates app restriction management to the Android Device Policy app. ```kotlin suspend fun startAccountSetup(startAccountSetupRequest: StartAccountSetupRequest): AccountSetupAttempt ``` -------------------------------- ### Start Account Setup (Asynchronous) Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/AccountSetupClient Initiates account setup asynchronously, returning a ListenableFuture. This method delegates app restriction management to the Android Device Policy app. ```kotlin fun startAccountSetupFuture( startAccountSetupRequest: StartAccountSetupRequest ): ListenableFuture ``` -------------------------------- ### startAccountSetupFuture Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Starts a new account setup process for a managed device asynchronously. Returns a Future that can be used to track the operation. ```APIDOC ## startAccountSetupFuture ### Description Starts a new account setup process for a managed device asynchronously. Returns a Future that can be used to track the operation. ### Method POST ### Endpoint /v1/devices/{deviceName}/accountSetupAttempts ### Parameters #### Path Parameters - **deviceName** (string) - Required - The name of the device to start account setup for. #### Request Body - **accountSetupConfiguration** (object) - Required - Configuration for the account setup. - **username** (string) - Required - The username for the managed account. - **password** (string) - Required - The password for the managed account. ### Response #### Success Response (200) - **attemptId** (string) - The ID of the newly created account setup attempt. ``` -------------------------------- ### StartAccountSetupRequest Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/model/package-summary Request object used to start the account setup process on a device. ```APIDOC ## Class: StartAccountSetupRequest ### Description Request object used to start the account setup process on a device. ### Builder Provides a builder pattern for constructing `StartAccountSetupRequest` instances. ``` -------------------------------- ### startAccountSetup Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/AccountSetupClient Starts account setup. This is a suspend function for coroutine-based environments. ```APIDOC ## startAccountSetup ### Description Starts account setup. ### Method POST ### Endpoint `/accountSetup/start` (Assumed) ### Parameters #### Request Body - **startAccountSetupRequest** (StartAccountSetupRequest) - Required - The request object containing details for starting account setup. ### Request Example ```json { "userId": "example_user_id" } ``` ### Response #### Success Response (200) - **AccountSetupAttempt** (AccountSetupAttempt) - The newly created account setup attempt. #### Response Example ```json { "status": "IN_PROGRESS", "errorCode": null, "errorMessage": null } ``` ``` -------------------------------- ### startAccountSetupFuture Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Starts the account setup process asynchronously, returning a ListenableFuture. This method also delegates app restriction management to the Android Device Policy app. ```APIDOC ## startAccountSetupFuture ### Description Starts account setup asynchronously, returning a `ListenableFuture`. This method delegates the `android.app.admin.DevicePolicyManager.DELEGATION_APP_RESTRICTIONS` scope to the Android Device Policy app, allowing it to manage app restrictions on behalf of the calling admin. Upon completion of the account setup, this delegation scope to Android Device Policy will be removed. ### Method `abstract @NonNull ListenableFuture<@NonNull AccountSetupAttempt> startAccountSetupFuture(@NonNull StartAccountSetupRequest startAccountSetupRequest)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **startAccountSetupRequest** (`@NonNull StartAccountSetupRequest`) - Required - The request to start account setup. ### Request Example ```json { "startAccountSetupRequest": { ... } } ``` ### Response #### Success Response (200) * **ListenableFuture<@NonNull AccountSetupAttempt>** - A `ListenableFuture` wrapping the result. This can be: * A successful future wrapping an account setup attempt. * A failed future wrapping an `EnvironmentNotReadyException` if the environment is not prepared. * A failed future wrapping an `com.google.android.managementapi.accountsetup.AccountSetupUnknownException` if an unknown error occurs during account setup. * A failed future wrapping an `com.google.android.managementapi.accountsetup.AccountSetupInvalidEnrollmentTokenException` if enrollment token is empty or not set in the request. * A failed future wrapping an `com.google.android.managementapi.accountsetup.AccountSetupInvalidAdminComponentException` if the admin `DeviceAdminReceiver` component is not an active admin on the device. * A failed future wrapping an `com.google.android.managementapi.accountsetup.AccountSetupInvalidNotificationReceiverComponentException` if the notification receiver component is not present on the device. #### Response Example ```json { "futureResult": { ... } } ``` ### Error Handling See Response section for details on potential exceptions wrapped in the `ListenableFuture`. ``` -------------------------------- ### Example: Successful App Install Log Source: https://developers.google.com/android/management/debug-installs-updates This log message confirms the successful installation of an application. It includes the package name and an internal identifier for the installation. ```log 02-11 08:42:30.187 10031 14335 14335 I Finsky : [2] mqd.c(4): IT: Successful install of com.android.chrome (isid: ...) ``` -------------------------------- ### Start Account Setup (Asynchronous) Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Initiates the account setup process asynchronously, returning a ListenableFuture. This method delegates scope to the Android Device Policy app and removes it upon completion. Use when the setup process should not block the current thread, allowing for background execution and non-blocking results. ```java abstract @NonNull ListenableFuture<@NonNull AccountSetupAttempt> startAccountSetupFuture( @NonNull StartAccountSetupRequest startAccountSetupRequest ) ``` -------------------------------- ### startAccountSetupFuture Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/AccountSetupClient Starts account setup asynchronously, returning a ListenableFuture. This method also delegates app restriction management to the Android Device Policy app and revokes it upon completion. ```APIDOC ## startAccountSetupFuture ### Description Starts account setup asynchronously, returning a `ListenableFuture`. This method delegates the `android.app.admin.DevicePolicyManager.DELEGATION_APP_RESTRICTIONS` scope to the Android Device Policy app, allowing it to manage app restrictions on behalf of the calling admin. Upon completion of the account setup, this delegation scope to Android Device Policy will be removed. ### Method `fun` ### Parameters #### Request Body - **startAccountSetupRequest** (StartAccountSetupRequest) - Required - The request to start account setup. ### Returns - **ListenableFuture** - A `ListenableFuture` wrapping the result. This can be: * A successful future wrapping an account setup attempt. * A failed future wrapping an `EnvironmentNotReadyException` if the environment is not prepared. * A failed future wrapping an `com.google.android.managementapi.accountsetup.AccountSetupUnknownException` if an unknown error occurs during account setup. * A failed future wrapping an `com.google.android.managementapi.accountsetup.AccountSetupInvalidEnrollmentTokenException` if enrollment token is empty or not set in the request. * A failed future wrapping an `com.google.android.managementapi.accountsetup.AccountSetupInvalidAdminComponentException` if the admin `DeviceAdminReceiver` component is not an active admin on the device. * A failed future wrapping an `com.google.android.managementapi.accountsetup.AccountSetupInvalidNotificationReceiverComponentException` if the notification receiver component is not present on the device. ``` -------------------------------- ### startAccountSetup Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Starts the account setup process synchronously. This method delegates app restriction management to the Android Device Policy app and removes the delegation upon completion. ```APIDOC ## startAccountSetup ### Description Starts account setup synchronously. This method delegates the `android.app.admin.DevicePolicyManager.DELEGATION_APP_RESTRICTIONS` scope to the Android Device Policy app, allowing it to manage app restrictions on behalf of the calling admin. Upon completion of the account setup, this delegation scope to Android Device Policy will be removed. ### Method `abstract @NonNull AccountSetupAttempt startAccountSetup(@NonNull StartAccountSetupRequest startAccountSetupRequest)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **startAccountSetupRequest** (`@NonNull StartAccountSetupRequest`) - Required - The request to start account setup. ### Request Example ```json { "startAccountSetupRequest": { ... } } ``` ### Response #### Success Response (200) * **AccountSetupAttempt** (`@NonNull AccountSetupAttempt`) - The account setup attempt. #### Response Example ```json { "accountSetupAttempt": { ... } } ``` ### Error Handling * `com.google.android.managementapi.environment.exception.EnvironmentNotReadyException` - if the environment is not prepared. * `com.google.android.managementapi.accountsetup.AccountSetupUnknownException` - if an unknown error occurs during account setup. * `com.google.android.managementapi.accountsetup.AccountSetupInvalidEnrollmentTokenException` - if the enrollment token is empty or not set in the request. * `com.google.android.managementapi.accountsetup.AccountSetupInvalidAdminComponentException` - if the admin `DeviceAdminReceiver` component is not an active admin on the device. * `com.google.android.managementapi.accountsetup.AccountSetupInvalidNotificationReceiverComponentException` - if the notification receiver component is not present on the device. ``` -------------------------------- ### Start Account Setup (Synchronous) Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Initiates the account setup process synchronously. This method delegates scope to the Android Device Policy app and removes it upon completion. Use when an immediate result is required and blocking the current thread is acceptable. ```java abstract @NonNull AccountSetupAttempt startAccountSetup( @NonNull StartAccountSetupRequest startAccountSetupRequest ) ``` -------------------------------- ### Get Account Setup Attempt Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/CancelAccountSetupAttemptRequest Retrieves the account setup attempt associated with the request. Use this to access the specific attempt to be canceled. ```java AccountSetupAttempt! getAccountSetupAttempt() ``` -------------------------------- ### Prepare Environment Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/environment/EnvironmentClient Ensures the Android Device Policy app is installed and ready. Use this to initiate the setup process for device management. Requires a ComponentName for notification callbacks. ```java abstract @NonNull PrepareEnvironmentResponse prepareEnvironment( @NonNull PrepareEnvironmentRequest request, ComponentName notificationServiceComponentName ) ``` -------------------------------- ### List Account Setup Attempts Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Lists all account setup attempts. Only the last 20 attempts are returned. ```java abstract @NonNull List<@NonNull AccountSetupAttempt> listAccountSetupAttempts() ``` -------------------------------- ### Enterprise IT Admin Signup Flow Example Source: https://developers.google.com/android/management/create-enterprise This is an example of the callback URL appended with an enterpriseToken after the IT admin completes the signup flow. ```url https://example.com/?**enterpriseToken**=EAH2pBTtGCs2K28dqhq5uw0uCyVzYMqGivap4wdlH7KNlPtCmlC8uyl ``` -------------------------------- ### Set Account Setup Attempt Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/model/CancelAccountSetupAttemptRequest.Builder Sets the account setup attempt to be cancelled. ```java public CancelAccountSetupAttemptRequest.Builder setAccountSetupAttempt(AccountSetupAttempt value) ``` -------------------------------- ### Environment Listener Implementation Example Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/environment/EnvironmentClient Example of implementing EnvironmentListener and NotificationReceiverService for receiving environment preparation events. This demonstrates how to handle callbacks during the preparation process. ```java class MyEnvironmentListener : EnvironmentListener { override fun onEnvironmentEvent(event: EnvironmentEvent) { // Handle the environment event. } } class MyNotificationReceiverService : NotificationReceiverService() { override fun getPrepareEnvironmentListener(): EnvironmentListener? { return MyEnvironmentListener() } } ``` -------------------------------- ### List Account Setup Attempts (Future) Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/AccountSetupClient Retrieves a list of all account setup attempts asynchronously using ListenableFuture. Only the last 20 attempts are returned. ```kotlin fun listAccountSetupAttemptsFuture(): ListenableFuture> ``` -------------------------------- ### onStartCommand Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/notification/NotificationReceiverService Called by the system every time a client starts the service using startService() or it is starting as a direct result of the system running the service to the point where it needs to be started. Inherited from Service. ```APIDOC ## onStartCommand ### Description Called by the system to start the service. Handles commands from clients. ### Method `int` ### Parameters * **intent** (`Intent`) - The Intent supplied to `startService()`, as given. This may be null if the service is being started by the system without an explicit Intent, so care should be taken not to de-reference it without checking. * **flags** (`int`) - Additional data about this start request. May be 0 or any combination of the constants `START_FLAG_REDELIVER_INTENT` and `START_FLAG_RETRY`. * **startId** (`int`) - A unique integer representing this specific starting request. ``` -------------------------------- ### Account Setup Failure Reason: New Account Not In Enterprise Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason Indicates that the account setup cannot proceed because the account is not associated with the enterprise. ```kotlin val AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason.ACCOUNT_SETUP_FAILURE_NEW_ACCOUNT_NOT_IN_ENTERPRISE:  AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason ``` -------------------------------- ### Set Account Setup Attempt Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/model/LaunchAuthenticationActivityRequest.Builder Sets the account setup attempt for the builder. This is used for the AUTHENTICATION_ACTIVITY_LAUNCH_REQUIRED_INFORMATION state. ```java public LaunchAuthenticationActivityRequest.Builder setAccountSetupAttempt(AccountSetupAttempt value) ``` -------------------------------- ### Get Account Setup Error State Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.StateCase Retrieves the error state of the account setup attempt. Use this when an error occurs during setup. ```kotlin abstract fun accountSetupError(): AccountSetupAttempt.AccountSetupError! ``` -------------------------------- ### Account Setup Failure Reason: Unspecified Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason Used when the reason for the account setup failure is not specified. ```kotlin val AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason.ACCOUNT_SETUP_FAILURE_REASON_UNSPECIFIED:  AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason ``` -------------------------------- ### List Account Setup Attempts (Suspend) Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/AccountSetupClient Retrieves a list of all account setup attempts using a suspend function. Only the last 20 attempts are returned. ```kotlin suspend fun listAccountSetupAttempts(): List ``` -------------------------------- ### Track User Consent for ADP App Installation (Kotlin) Source: https://developers.google.com/android/management/device-trust-api Implement a NotificationReceiverService to track user interaction during ADP app installation. Override getPrepareEnvironmentListener to return a custom EnvironmentListener that logs when the user accepts or rejects the installation consent. ```kotlin import android.util.Log import com.google.android.managementapi.environment.EnvironmentListener import com.google.android.managementapi.environment.model.EnvironmentEvent.EventCase.Kind.ANDROID_DEVICE_POLICY_INSTALL_CONSENT_ACCEPTED import com.google.android.managementapi.environment.model.EnvironmentEvent import com.google.android.managementapi.notification.NotificationReceiverService class MyNotificationReceiverService : NotificationReceiverService() { override fun getPrepareEnvironmentListener(): EnvironmentListener { return MyEnvironmentListener() } } class MyEnvironmentListener : EnvironmentListener { override fun onEnvironmentEvent( event: EnvironmentEvent ) { if (event.event.kind == ANDROID_DEVICE_POLICY_INSTALL_CONSENT_ACCEPTED) { Log.d(TAG, "User provided install consent") } else { Log.d(TAG, "User rejected install consent") } } companion object { private val TAG: String = MyEnvironmentListener::class.java.simpleName } } ``` -------------------------------- ### Get In Progress State Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.StateCase Retrieves the state indicating that account setup is currently in progress. Use this to check if the setup process is ongoing. ```kotlin abstract fun inProgress(): AccountSetupAttempt.InProgress! ``` -------------------------------- ### Get Install Custom App Status Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/commands/model/Command.StatusCase Retrieves the status of the install custom app command. This is an abstract function within the Command class. ```kotlin abstract fun installCustomAppStatus(): Command.CustomAppOperationStatus! ``` -------------------------------- ### Get Install Custom App Command Status Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/commands/model/Command.StatusCase Retrieves the status of the install custom app command. This method is abstract and requires implementation. ```java public abstract Command.CustomAppOperationStatus installCustomAppStatus() ``` -------------------------------- ### List Account Setup Attempts Asynchronously Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Lists all account setup attempts asynchronously, returning a ListenableFuture for the list of attempts. Only the last 20 attempts are returned. ```java abstract @NonNull ListenableFuture<@NonNull List<@NonNull AccountSetupAttempt>> listAccountSetupAttemptsFuture() ``` -------------------------------- ### Account Setup Failure Reason: Attempt Cancelled Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason Represents the case where the account setup was intentionally cancelled by the Device Policy Controller (DPC). ```kotlin val AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason.ACCOUNT_SETUP_FAILURE_ATTEMPT_CANCELLED:  AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason ``` -------------------------------- ### Get State Kind Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.StateCase Retrieves the kind of the current state of the account setup attempt. ```kotlin abstract fun getKind(): AccountSetupAttempt.StateCase.Kind! ``` -------------------------------- ### StartAccountSetupRequest Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/StartAccountSetupRequest The StartAccountSetupRequest class is an abstract class used to construct requests for initiating the account setup on a device. It includes methods to set and retrieve the enrollment token, and optionally, component names for the DeviceAdminReceiver and notification receiver service. ```APIDOC ## StartAccountSetupRequest ### Description Represents a request to start the account setup process for a device. This class allows for the configuration of essential details needed to initiate device enrollment and setup, including the enrollment token and optional component names for administrative and notification services. ### Methods - **`builder()`**: Creates a new `Builder` instance for constructing a `StartAccountSetupRequest`. - **`getAdminComponentName()`**: Retrieves the component name of the `DeviceAdminReceiver` for the calling DPC. Returns `null` if not set. - **`getDefaultInstance()`**: Returns the default instance of `StartAccountSetupRequest`. - **`getEnrollmentToken()`**: Retrieves the enrollment token for the device. This is a required field. - **`getNotificationReceiverServiceComponentName()`**: Retrieves the component name of the notification receiver service. Returns `null` if not set. - **`hasAdminComponentName()`**: Returns `true` if the `adminComponentName` has been set. - **`hasNotificationReceiverServiceComponentName()`**: Returns `true` if the `notificationReceiverServiceComponentName` has been set. - **`toBuilder()`**: Creates a `Builder` instance initialized with the current `StartAccountSetupRequest`'s values. ### Nested Types - **`StartAccountSetupRequest.Builder`**: An abstract builder class used to construct `StartAccountSetupRequest` objects. It provides methods to set the enrollment token and optional component names. ``` -------------------------------- ### SetupAction Source: https://developers.google.com/android/management/reference/mcp/get_policy Defines an action to be performed during device setup, such as launching an application. ```APIDOC ## SetupAction ### Description An action to be executed during the device setup process. This can include displaying a title and description, and performing a specific launch action. ### Fields - **title** (object (UserFacingMessage)) - Optional - The title of this action. - **description** (object (UserFacingMessage)) - Optional - The description of this action. ### Action This is a union field, and only one of the following can be specified: - **launchApp** (object (LaunchAppAction)) - An action to launch an application. The app is launched with an intent indicating it's a setup action. If this action references an app, the `installType` in the application policy must be `REQUIRED_FOR_SETUP`. ``` -------------------------------- ### Get Installed Apps (Java) Source: https://developers.google.com/android/management/manage-custom-apps Retrieves a list of installed applications on a device using the Android Management API in Java. This method returns a ListenableFuture for asynchronous handling and requires an executor for transformations. ```java import android.content.Context; import com.google.android.managementapi.device.DeviceClientFactory; import com.google.android.managementapi.device.model.GetDeviceRequest; import com.google.android.managementapi.device.model.Device; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.List; import java.util.concurrent.Executor; public ListenableFuture getInstalledApps() { ListenableFuture deviceFuture = DeviceClientFactory.create(context) .getDevice(GetDeviceRequest.getDefaultInstance()); return Futures.transform( deviceFuture, Device::getApplicationReports, executor // Use the provided executor ); } ``` -------------------------------- ### Create Install Custom App Request (Instance) Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/commands/model/IssueCommandRequest.ParamsCase Static factory method to create an IssueCommandRequest for installing a custom app using an existing InstallCustomApp instance. ```java java-static fun ofInstallCustomApp(value: IssueCommandRequest.InstallCustomApp!): IssueCommandRequest.ParamsCase! ``` -------------------------------- ### Get Installed Apps (Kotlin) Source: https://developers.google.com/android/management/manage-custom-apps Retrieves a list of installed applications on a device using the Android Management API in Kotlin. Requires context for client creation and uses coroutines for asynchronous operations. ```kotlin import android.content.Context import com.google.android.managementapi.device.DeviceClientFactory import com.google.android.managementapi.device.model.GetDeviceRequest import kotlinx.coroutines.guava.await suspend fun getInstalledApps(context: Context) = DeviceClientFactory.create(context) .getDevice(GetDeviceRequest.getDefaultInstance()) .await() .getApplicationReports() ``` -------------------------------- ### listAccountSetupAttemptsFuture Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Lists all account setup attempts asynchronously, returning a ListenableFuture. ```APIDOC ## listAccountSetupAttemptsFuture ### Description Lists all account setup attempts asynchronously. Only the last 20 account setup attempts are returned. Returns a `ListenableFuture` wrapping the result. ### Method Signature ```java abstract @NonNull ListenableFuture<@NonNull List<@NonNull AccountSetupAttempt>> listAccountSetupAttemptsFuture() ``` ### Returns * **ListenableFuture<@NonNull List<@NonNull AccountSetupAttempt>>** - A `ListenableFuture` wrapping the list of account setup attempts. ``` -------------------------------- ### Get Added Account State Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.StateCase Retrieves the successfully added enterprise account. Use this when account setup completes successfully. ```kotlin abstract fun addedAccount(): AccountSetupAttempt.EnterpriseAccount! ``` -------------------------------- ### Get Lifecycle Observer Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Retrieves the LifecycleObserver for handling lifecycle-dependent setup. This observer must be registered with the host's Lifecycle. ```java abstract @NonNull LifecycleObserver getLifecycleObserver() ``` -------------------------------- ### build Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/model/StartAccountSetupRequest.Builder Builds the StartAccountSetupRequest object. ```APIDOC ## build ### Description Builds the StartAccountSetupRequest object. ### Method abstract ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response (200) - **StartAccountSetupRequest** - The constructed StartAccountSetupRequest object. ### Response Example None ``` -------------------------------- ### Build StartAccountSetupRequest Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/model/StartAccountSetupRequest.Builder Builds the StartAccountSetupRequest instance. ```java public abstract StartAccountSetupRequest build() ``` -------------------------------- ### Get Notification Receiver Service Component Name Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/StartAccountSetupRequest Retrieves the component name for account setup notifications. The component must be valid and exported. ```java ComponentName? getNotificationReceiverServiceComponentName() ``` -------------------------------- ### Get Default GetCommandRequest Instance Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/commands/model/GetCommandRequest Obtains a default, pre-configured instance of GetCommandRequest. This can be useful for starting points or when no specific parameters are needed initially. ```java java-static GetCommandRequest! getDefaultInstance() ``` -------------------------------- ### Configure app launch during setup Source: https://developers.google.com/android/management/provision-device Add an app to `setupActions` to be launched during device provisioning. Use `title` and `description` to provide user instructions. The `launchApp` field specifies the package name of the app to launch. ```json { "setupActions":[ { "title":{ "defaultMessage":"Configure VPN" }, "description":{ "defaultMessage":"Enable your VPN client to access corporate resources." }, "launchApp":{ "packageName":"com.my.vpnapp." } } ] } ``` -------------------------------- ### build Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.AuthenticationActivityLaunchRequiredInformation.Builder Builds an instance of AccountSetupAttempt.AuthenticationActivityLaunchRequiredInformation. ```APIDOC ## build ``` public abstract AccountSetupAttempt.AuthenticationActivityLaunchRequiredInformation build() ``` ### Description Builds an instance of AccountSetupAttempt.AuthenticationActivityLaunchRequiredInformation. ### Method abstract ### Returns An instance of AccountSetupAttempt.AuthenticationActivityLaunchRequiredInformation. ``` -------------------------------- ### Prepare Environment Asynchronously (Java) Source: https://developers.google.com/android/management/device-trust-api This Java code demonstrates how to asynchronously prepare the device environment using `prepareEnvironmentAsync`. It utilizes `ListenableFuture` and `FutureCallback` to handle the response, checking the ADP environment's state and version upon success. ```java try { ComponentName myNotificationReceiverService = new ComponentName( context, MyNotificationReceiverService.class ); ImmutableList roles = new ImmutableList.Builder() .add(Role.builder() .setRoleType(Role.RoleType.IDENTITY_PROVIDER) .build()) .build(); PrepareEnvironmentRequest request = PrepareEnvironmentRequest.builder() .setRoles(roles) .build(); ListenableFuture environmentFuture = environmentClient.prepareEnvironmentAsync( request, myNotificationReceiverService ); Futures.addCallback(environmentFuture, new FutureCallback<>() { @Override public void onSuccess(PrepareEnvironmentResponse response) { Environment environment = response.getEnvironment(); AndroidDevicePolicyEnvironment adpEnvironment = environment.getAndroidDevicePolicyEnvironment(); AndroidDevicePolicyEnvironment.State state = adpEnvironment.getState(); AndroidDevicePolicyEnvironment.Version version = adpEnvironment.getVersion(); if (state == READY && version == UP_TO_DATE) { // AMAPI Environment State OK, Version OK. Requesting Device signals.. DeviceClient deviceClient = DeviceClientFactory.create(context); checkDevice(deviceClient); } else { // The prepareEnvironment call failed to prepare Log.w( TAG, "AMAPI environment was not ready: " + adpEnvironment.getState() + " - " + adpEnvironment.getVersion() ); } } @Override public void onFailure(@NonNull Throwable t) { // Handle the error Log.d(TAG, "AMAPI response did not contain an ADP environment"); } }, MoreExecutors.directExecutor()); } catch (Exception e) { Log.d(TAG, e.toString()); } ``` -------------------------------- ### startInstrumentation Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/notification/NotificationReceiverService Start instrumentation. ```APIDOC ## startInstrumentation ### Description Start instrumentation. ### Method `startInstrumentation` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **p0** (@NonNull ComponentName) - Required - The ComponentName of the instrumentation to start. - **p1** (@Nullable String) - Optional - The package name of the process to run the instrumentation in. - **p2** (@Nullable Bundle) - Optional - Any additional arguments to pass to the instrumentation. ### Request Example None provided in source. ### Response #### Success Response boolean - True if the instrumentation was started successfully, false otherwise. #### Response Example None provided in source. ``` -------------------------------- ### Example Policy for Default Browser and Dialer Source: https://developers.google.com/android/management/default-application-settings This JSON policy configures default applications for browser and dialer, enabling status reporting. It specifies applications, their installation types, and the scopes for which these defaults apply. ```json { "applications": [ { "packageName": "com.android.chrome", "installType": "AVAILABLE" }, { "packageName": "com.google.android.dialer", "installType": "AVAILABLE" }, { "packageName": "com.samsung.android.dialer", "installType": "AVAILABLE" } ], "statusReportingSettings": { "defaultApplicationInfoReportingEnabled": true }, "defaultApplicationSettings": [ { "defaultApplicationType": "DEFAULT_BROWSER", "defaultApplications": [ { "packageName": "com.android.chrome" } ], "defaultApplicationScopes": [ "SCOPE_FULLY_MANAGED", "SCOPE_WORK_PROFILE" ] }, { "defaultApplicationType": "DEFAULT_DIALER", "defaultApplications": [ { "packageName": "com.google.android.dialer" }, { "packageName": "com.samsung.android.dialer" } ], "defaultApplicationScopes": [ "SCOPE_FULLY_MANAGED", "SCOPE_WORK_PROFILE", "SCOPE_PERSONAL_PROFILE" ] } ] } ``` -------------------------------- ### Get System Update (Asynchronous) Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/oemsystemupdate/OemSystemUpdateClient Retrieves a SystemUpdate resource asynchronously using a ListenableFuture. This is suitable for non-blocking operations where the update status can be processed later. Ensure the Android Device Policy app is installed, enabled, and updated, and the device is managed. ```java abstract @NonNull ListenableFuture<@NonNull SystemUpdate> getSystemUpdateFuture(@NonNull GetSystemUpdateRequest request) ``` -------------------------------- ### Get System Update (Synchronous) Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/oemsystemupdate/OemSystemUpdateClient Retrieves a SystemUpdate resource synchronously. Use this when immediate retrieval of update status is required and blocking the current thread is acceptable. Ensure the Android Device Policy app is installed, enabled, and updated, and the device is managed. ```java abstract @NonNull SystemUpdate getSystemUpdate(@NonNull GetSystemUpdateRequest request) ``` -------------------------------- ### startService Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/notification/NotificationReceiverService Start a service. ```APIDOC ## startService ### Description Start a service. ### Method `startService` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **p0** (@NonNull Intent) - Required - The Intent describing the service to start. ### Request Example None provided in source. ### Response #### Success Response @Nullable ComponentName - The ComponentName of the started service, or null if the service could not be started. #### Response Example None provided in source. ``` -------------------------------- ### SetupAction JSON Structure Source: https://developers.google.com/android/management/reference/mcp/list_policies Represents an action to be performed during device setup, which can include launching an app. ```json { "title": { "object" (UserFacingMessage) }, "description": { "object" (UserFacingMessage) }, // Union field action can be only one of the following: "launchApp": { "object" (LaunchAppAction) } // End of list of possible types for union field action. } ``` -------------------------------- ### Install App via Package Name Source: https://developers.google.com/android/management/apps Add an app to a device's policy for installation by specifying its package name and install type. This ensures the app is installed on the device or added to the managed Google Play Store. ```json "applications":[ { "installType":"FORCE_INSTALLED", "packageName":"com.android.chrome", }, ], ``` -------------------------------- ### Set Package Name for Custom App Installation Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/commands/model/IssueCommandRequest.InstallCustomApp.Builder Sets the package name of the app to be installed. This is a required field for custom app installations. ```kotlin abstract fun setPackageName(value: String!): IssueCommandRequest.InstallCustomApp.Builder! ``` -------------------------------- ### Example Policy Configuration Source: https://developers.google.com/android/management/policies/work-profile This snippet demonstrates how to configure various policies for a work profile, personal profile, and the entire device. It includes password requirements, application management, personal usage restrictions like camera and screen capture disabling, and device-wide settings such as disabling Bluetooth and USB file transfer. ```json // Applies to the work profile "passwordRequirements": { "passwordMinimumLength": 6, "passwordQuality": "ALPHABETIC" }, "applications": [{ "defaultPermissionPolicy": "GRANT", "installType": "FORCE_INSTALLED", // Auto-installs app in the work profile "packageName": "com.google.android.gm" }, { "installType": "AVAILABLE", // Adds app to the work profile's managed Play Store "packageName": "com.google.android.apps.docs" }], // Applies to the personal profile "personalUsagePolicies": { "personalPlayStoreMode": "BLACKLIST", "personalApplicationPolicy": [{ "packageName": "com.example.app", "installType": "BLOCKED" }], "maxDaysWithWorkOff": 3, "cameraDisabled": true, "screenCaptureDisabled": true }, // Applies to the whole device. "bluetoothDisabled": true, "usbFileTransferDisabled": true ``` -------------------------------- ### AccountSetupListener Interface Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/package-summary Listener for account setup related notifications. ```APIDOC ## Interface: AccountSetupListener ### Description Listener for account setup related notifications. ### Methods (No specific methods are documented in the provided text, only the interface itself.) ``` -------------------------------- ### get Source: https://developers.google.com/android/management/reference/rest/v1/enterprises.devices.operations Gets the latest state of a long-running operation. ```APIDOC ## get ### Description Gets the latest state of a long-running operation. ### Method GET ### Endpoint /v1/operations/{operationId} ### Parameters #### Path Parameters - **operationId** (string) - Required - The ID of the operation to retrieve. ### Response #### Success Response (200) - **name** (string) - The name of the operation. - **metadata** (object) - Service-specific metadata for the operation. - **done** (boolean) - Indicates if the operation is complete. - **error** (Status) - If `done` is true, this contains the error if the operation failed. - **response** (object) - If `done` is true, this contains the successful response. #### Response Example { "name": "operations/12345", "metadata": {}, "done": false } ``` -------------------------------- ### Set Account Setup Attempt Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/LaunchAuthenticationActivityRequest.Builder Sets the account setup attempt for the builder. This is used when the account setup state requires launching an authentication activity. ```kotlin fun setAccountSetupAttempt(value: AccountSetupAttempt!): LaunchAuthenticationActivityRequest.Builder! ``` -------------------------------- ### startActivity Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/notification/NotificationReceiverService Start an activity. ```APIDOC ## startActivity ### Description Start an activity. ### Method `startActivity` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Overloads 1. `startActivity(@NonNull Intent p0)` 2. `startActivity(@NonNull Intent p0, @Nullable Bundle p1)` ### Request Example None provided in source. ### Response #### Success Response void #### Response Example None provided in source. ``` -------------------------------- ### Install Custom App Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/commands/model/IssueCommandRequest.ParamsCase A request to install a custom application on the device. ```APIDOC ## installCustomApp() ### Description A request to install a custom app. ### Method N/A (SDK method) ### Endpoint N/A (SDK method) ### Parameters None ### Request Example ```json { "installCustomApp": {} } ``` ### Response Success Response (200) - **field1** (type) - Description ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### prepareEnvironmentAsync Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/environment/EnvironmentClient Prepares the device by ensuring the Android Device Policy app is installed and ready. This method returns a ListenableFuture. ```APIDOC ## prepareEnvironmentAsync ### Description Prepares the device by ensuring the Android Device Policy app is installed and ready, asynchronously. ### Method Asynchronous call returning a `ListenableFuture`. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **request** (PrepareEnvironmentRequest) - Required - The request object to prepare the environment. - **notificationServiceComponentName** (ComponentName) - Required - The component name of the notification service. ### Response #### Success Response (200) - **ListenableFuture** - A future that will complete with the preparation response. #### Response Example ```json { "status": "prepared" } ``` ``` -------------------------------- ### AccountSetupAttempt.InProgress Method Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.StateCase Retrieves the state indicating that account setup is in progress. ```java public abstract AccountSetupAttempt.InProgress inProgress() ``` -------------------------------- ### v1.signupUrls.create Source: https://developers.google.com/android/management/reference/rest Creates a signup URL for a new enterprise. ```APIDOC ## POST /v1/signupUrls ### Description Creates an enterprise signup URL. ### Method POST ### Endpoint /v1/signupUrls ``` -------------------------------- ### Get ToBuilder Instance Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/oemsystemupdate/model/ListPendingSystemUpdatesResponse Abstract method to get a builder instance for ListPendingSystemUpdatesResponse. ```java abstract fun toBuilder(): ListPendingSystemUpdatesResponse.Builder! ``` -------------------------------- ### Launch Authentication Activity (Suspend) Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/AccountSetupClient Launches the authentication activity for a user or account picker. The account setup attempt must be in the AUTHENTICATION_ACTIVITY_LAUNCH_REQUIRED_INFORMATION state. Throws SecurityException or AccountSetupInvalidStateException. ```kotlin suspend fun launchAuthenticationActivity( launchAuthenticationActivityRequest: LaunchAuthenticationActivityRequest ): AccountSetupAttempt ``` -------------------------------- ### Get Default Instance Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/oemsystemupdate/model/ListPendingSystemUpdatesResponse Static method to get the default instance of ListPendingSystemUpdatesResponse. ```java java-static fun getDefaultInstance(): ListPendingSystemUpdatesResponse! ``` -------------------------------- ### listAccountSetupAttemptsFuture Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Lists all ongoing account setup attempts for a given device asynchronously. Returns a Future that can be used to track the operation. ```APIDOC ## listAccountSetupAttemptsFuture ### Description Lists all ongoing account setup attempts for a given device asynchronously. Returns a Future that can be used to track the operation. ### Method GET ### Endpoint /v1/devices/{deviceName}/accountSetupAttempts ### Parameters #### Path Parameters - **deviceName** (string) - Required - The name of the device to list account setup attempts for. ### Response #### Success Response (200) - **accountSetupAttempts** (array) - A list of account setup attempts. - **attemptId** (string) - The ID of the setup attempt. - **status** (string) - The current status of the setup attempt. ``` -------------------------------- ### Get Builder Instance Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/oemsystemupdate/model/ListPendingSystemUpdatesResponse Static method to get a builder instance for ListPendingSystemUpdatesResponse. ```java java-static fun builder(): ListPendingSystemUpdatesResponse.Builder! ``` -------------------------------- ### Create AccountSetupClient Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/AccountSetupClientFactory Factory method to create an AccountSetupClient. Ensure the lifecycle observer is registered before the host activity or fragment is created. ```kotlin fun create(context: Context, registry: ActivityResultRegistry): AccountSetupClient ``` -------------------------------- ### Kotlin Get Eid Function Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/commands/model/Command.RequestDeviceInfoStatus.EidInfo.Eid An abstract Kotlin function to get the EID number. ```kotlin abstract fun getEid(): String! ``` -------------------------------- ### startForegroundService Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/notification/NotificationReceiverService Start a foreground service. ```APIDOC ## startForegroundService ### Description Start a foreground service. ### Method `startForegroundService` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **p0** (@NonNull Intent) - Required - The Intent describing the service to start. ### Request Example None provided in source. ### Response #### Success Response @Nullable ComponentName - The ComponentName of the started service, or null if the service could not be started. #### Response Example None provided in source. ``` -------------------------------- ### Get Default Instance Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/StartAccountSetupRequest Provides a static method to get the default instance of StartAccountSetupRequest. ```java java-static StartAccountSetupRequest! getDefaultInstance() ``` -------------------------------- ### Install Closed Tracks on Devices Source: https://developers.google.com/android/management/apps Specify accessible track IDs in a device's policy to install a closed track. If multiple tracks from the same app are included, the one with the highest version code is installed. ```json "applications":[ { "installType":"AVAILABLE", "packageName":"com.google.android.gm", "accessibleTrackIds":[ "123456", "789101" ] }, ], ``` -------------------------------- ### prepareEnvironment Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/environment/EnvironmentClient Prepares the device by ensuring the Android Device Policy app is installed and ready. This is a synchronous method. ```APIDOC ## prepareEnvironment ### Description Prepares the device by ensuring the Android Device Policy app is installed and ready. ### Method Synchronous call. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **request** (PrepareEnvironmentRequest) - Required - The request object to prepare the environment. - **notificationServiceComponentName** (ComponentName) - Required - The component name of the notification service. ### Response #### Success Response (200) - **PrepareEnvironmentResponse** - The response object indicating the preparation status. #### Response Example ```json { "status": "prepared" } ``` ``` -------------------------------- ### Clear InstallerPackageNameMetadata Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/device/model/ApplicationReport.Builder Clears the metadata for the installer package name. Use this when the installer information is not needed. ```kotlin fun clearInstallerPackageNameMetadata(): ApplicationReport.Builder! ``` -------------------------------- ### startActivities Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/notification/NotificationReceiverService Start multiple activities. ```APIDOC ## startActivities ### Description Start multiple activities. ### Method `startActivities` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Overloads 1. `startActivities(@NonNull Intent[] p0)` 2. `startActivities(@NonNull Intent[] p0, @Nullable Bundle p1)` ### Request Example None provided in source. ### Response #### Success Response void #### Response Example None provided in source. ``` -------------------------------- ### ofInProgress Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.StateCase Factory method to create an AccountSetupAttempt representing an in-progress setup. ```APIDOC ## ofInProgress ### Description Factory method to create an AccountSetupAttempt representing an account setup that is currently in progress. ### Method Factory method. ### Parameters None explicitly documented. ### Response An instance of AccountSetupAttempt in an in-progress state. ``` -------------------------------- ### Install Custom App Request Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/commands/model/IssueCommandRequest.ParamsCase Abstract function to create a request for installing a custom application. ```kotlin abstract fun installCustomApp(): IssueCommandRequest.InstallCustomApp! ``` -------------------------------- ### build Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.InProgress.Builder Builds an instance of AccountSetupAttempt.InProgress. ```APIDOC ## build ```kotlin abstract fun build(): AccountSetupAttempt.InProgress! ``` ### Description Builds an instance of `AccountSetupAttempt.InProgress`. ### Method build ### Returns An instance of `AccountSetupAttempt.InProgress`. ``` -------------------------------- ### create Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/oemsystemupdate/OemSystemUpdateClientFactory Creates a OemSystemUpdateClient instance. ```APIDOC ## create ### Description Creates a `OemSystemUpdateClient` instance. ### Method ``` public static final @NonNull OemSystemUpdateClient create(@NonNull Context context) ``` ### Parameters #### Path Parameters - **context** (`@NonNull Context`) - The Android `Context` used to create the client. ### Returns - **@NonNull OemSystemUpdateClient** - A `OemSystemUpdateClient` instance. ``` -------------------------------- ### Set InstallerPackageNameMetadata Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/device/model/ApplicationReport.Builder Sets metadata for the installer package name. This provides additional context for the installer information. ```kotlin fun setInstallerPackageNameMetadata(value: Metadata!): ApplicationReport.Builder! ``` -------------------------------- ### build() Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.InProgress.Builder Builds an instance of AccountSetupAttempt.InProgress from the current builder state. ```APIDOC ## build ```java public abstract AccountSetupAttempt.InProgress build() ``` ### Description Builds and returns an `AccountSetupAttempt.InProgress` object based on the configuration set in the builder. ### Method `build` ### Returns An `AccountSetupAttempt.InProgress` object. ``` -------------------------------- ### Account Setup Failure Reason: Unknown Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason Signifies that an unidentified issue is preventing the account setup from completing. ```kotlin val AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason.ACCOUNT_SETUP_FAILURE_REASON_UNKNOWN:  AccountSetupAttempt.AccountSetupError.AccountSetupFailureReason ``` -------------------------------- ### launchAuthenticationActivity Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Launches the authentication activity for account setup. This is a synchronous call that expects the result to be handled via callbacks. ```APIDOC ## launchAuthenticationActivity ### Description Launches the authentication activity required for account setup. This method is synchronous and relies on the lifecycle observer to handle the result callbacks. ### Method POST ### Endpoint /v1/devices/{deviceName}/accountSetupAttempts/{attemptId}:launchAuthentication ### Parameters #### Path Parameters - **deviceName** (string) - Required - The name of the device for which to launch the authentication activity. - **attemptId** (string) - Required - The ID of the account setup attempt. ### Response #### Success Response (200) An empty response body indicates success. The result of the authentication will be delivered via the `AccountSetupListener`. ``` -------------------------------- ### Get Command Kind Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/commands/model/Command.StatusCase Abstract function to get the kind of command status. This is part of the Command class. ```kotlin abstract fun getKind(): Command.StatusCase.Kind! ``` -------------------------------- ### listAccountSetupAttempts Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/accountsetup/AccountSetupClient Lists all account setup attempts. ```APIDOC ## listAccountSetupAttempts ### Description Lists all account setup attempts. ### Method GET ### Endpoint /accountSetupAttempts ### Response #### Success Response (200) - **List** - A list of all account setup attempts. ``` -------------------------------- ### Get Default Instance Function (Kotlin) Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/commands/model/Command.RequestDeviceInfoStatus.EidInfo Static function to get the default instance of Command.RequestDeviceInfoStatus.EidInfo in Kotlin. ```kotlin java-static fun getDefaultInstance(): Command.RequestDeviceInfoStatus.EidInfo! ``` -------------------------------- ### IssueCommandRequest.InstallCustomApp.Builder Source: https://developers.google.com/android/management/reference/amapi/com/google/android/managementapi/commands/model/IssueCommandRequest.InstallCustomApp.Builder Provides methods to construct an InstallCustomApp request. ```APIDOC ## IssueCommandRequest.InstallCustomApp.Builder ### Description Builder for `IssueCommandRequest.InstallCustomApp`. ### Public Methods #### `build()` ```java abstract IssueCommandRequest.InstallCustomApp build() ``` Builds the `IssueCommandRequest.InstallCustomApp` object. #### `setPackageName(String value)` ```java abstract IssueCommandRequest.InstallCustomApp.Builder setPackageName(String value) ``` The package name of the app to be installed. #### `setPackageUri(String value)` ```java abstract IssueCommandRequest.InstallCustomApp.Builder setPackageUri(String value) ``` A file URI of the package that needs to be installed, in the format of `file:///`. **Note:** The apk file should be stored in the directory returned by `LocalCommandClient.InstallCustomAppCommand.getCustomApksStorageDirectory`. If the file is not stored in the correct directory, the command will fail. The caller is responsible for managing the lifecycle of the file and its cleanup after the command is executed. ``` -------------------------------- ### Kotlin Get Enrollment Token Function Source: https://developers.google.com/android/management/reference/amapi/kotlin/com/google/android/managementapi/accountsetup/model/StartAccountSetupRequest Defines the abstract function to get the enrollment token in Kotlin. ```kotlin abstract fun getEnrollmentToken(): String! ```