EnvironmentClient

interface EnvironmentClient


클라이언트가 환경 관련 API에 액세스합니다.

EnvironmentClientFactory를 사용하여 인스턴스를 만듭니다.

요약

공개 함수

suspend Environment

Environment를 반환합니다.

ListenableFuture<Environment>

Environment를 반환합니다.

suspend PrepareEnvironmentResponse
@RequiresApi(value = 28)
prepareEnvironment(
    request: PrepareEnvironmentRequest,
    notificationServiceComponentName: ComponentName?
)

기기 환경을 준비합니다.

ListenableFuture<PrepareEnvironmentResponse>
@RequiresApi(value = 28)
prepareEnvironmentAsync(
    request: PrepareEnvironmentRequest,
    notificationServiceComponentName: ComponentName?
)

기기 환경을 준비합니다.

공개 함수

getEnvironment

@RequiresApi(value = 28)
suspend fun getEnvironment(request: GetEnvironmentRequest): Environment

Environment를 반환합니다. 호출자가 환경이 준비되었는지 여부를 알 수 있도록 합니다.

생성 값
java.lang.SecurityException

호출자가 이 API를 호출할 권한이 없는 경우

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

기기 API 수준이 28 미만인 경우

com.google.android.managementapi.common.exceptions.InvalidArgumentException

요청된 역할이 유효하지 않은 경우

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

내부 오류로 인해 호출이 실패한 경우

getEnvironmentAsync

@RequiresApi(value = 28)
fun getEnvironmentAsync(request: GetEnvironmentRequest): ListenableFuture<Environment>

Environment를 반환합니다. 호출자가 환경이 준비되었는지 여부를 알 수 있도록 지원합니다.

반환 값
ListenableFuture<Environment>

결과를 래핑하는 ListenableFuture ID는 다음 중 하나일 수 있습니다.

  • 성공한 경우 Environment를 래핑하는 성공적인 future입니다.

  • 호출자가 이 API를 호출할 권한이 없는 경우 SecurityException를 래핑하는 실패한 future입니다.

  • 기기 API 수준이 28 미만인 경우 ApiLevelException를 래핑하는 실패한 future입니다.

  • 요청된 역할이 유효하지 않은 경우 InvalidArgumentException를 래핑하는 실패한 future입니다.

  • 내부 오류로 인해 호출이 실패한 경우 InternalException를 래핑하는 실패한 future입니다.

prepareEnvironment

@RequiresApi(value = 28)
suspend fun prepareEnvironment(
    request: PrepareEnvironmentRequest,
    notificationServiceComponentName: ComponentName?
): PrepareEnvironmentResponse

기기 환경을 준비합니다.

사용자에게 필요한 Android Device Policy 애플리케이션을 설치하라는 메시지를 표시합니다. 사용자가 메시지를 수락하면 설치를 진행합니다. 설치가 완료되면 Android Device Policy 앱이 준비되었는지 확인하는 작업을 실행합니다.

매개변수
notificationServiceComponentName: ComponentName?

NotificationReceiverService를 확장하는 서비스의 ComponentName입니다. 제공된 경우 호출 앱에 속하며 매니페스트에서 내보낸 유효한 구성요소여야 합니다. 환경 준비 이벤트에 대한 알림을 받으려면 다음을 실행해야 합니다.

  1. 앱에 EnvironmentListener 인터페이스를 구현합니다.

  2. 수신된 이벤트를 처리하는 방법의 구현을 제공합니다.

  3. NotificationReceiverService를 확장하고 EnvironmentListener 인스턴스를 제공합니다.

  4. 확장된 NotificationReceiverService 클래스를 AndroidManifest.xml에 추가하고 내보내기합니다.

예를 들면 다음과 같습니다.

class MyEnvironmentListener : EnvironmentListener {
override fun onEnvironmentEvent(event: EnvironmentEvent) {
// Handle the environment event.
}
}

class MyNotificationReceiverService : NotificationReceiverService() {
override fun getPrepareEnvironmentListener(): EnvironmentListener? {
return MyEnvironmentListener()
}
}
반환 값
PrepareEnvironmentResponse

환경 준비의 최종 상태에 관한 세부정보가 포함된 PrepareEnvironmentResponse

생성 값
com.google.android.managementapi.common.exceptions.InvalidArgumentException

조건:

  • [notificationServiceComponentName] 은 호출 앱에 속한 유효한 구성요소가 아니거나 매니페스트에 내보내지 않았습니다.
  • 요청된 역할이 유효하지 않습니다.
com.google.android.managementapi.common.exceptions.ApiLevelException

기기 API 수준이 28 미만인 경우

java.lang.SecurityException

호출자가 이 API를 호출할 권한이 없는 경우

com.google.android.managementapi.environment.exception.GooglePlayServicesAppNotUpdatedException Google Play 서비스가 최신 버전이 아닙니다.

com.google.android.managementapi.environment.exception.AndroidDevicePolicyInstallOrUpdateUnrecoverableException Android 기기 정책을 설치하거나 업데이트할 수 없으며 오류를 복구할 수 없는 경우

com.google.android.managementapi.environment.exception.AndroidDevicePolicyInstallOrUpdateRecoverableException Android 기기 정책 앱이 설치 또는 업데이트되지 않고 오류를 복구할 수 있는 경우 (예: 일시적인 네트워크 문제로 인해 요청이 실패함) 요청을 다시 시도할 수 있습니다.

com.google.android.managementapi.environment.exception.AndroidDevicePolicyInstallConsentDeclinedException 사용자가 Android Device Policy 앱 설치를 거부하는 경우

com.google.android.managementapi.environment.exception.AndroidDevicePolicyInstallConsentDismissedException 사용자가 설치 동의 화면을 닫는 경우

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

내부 오류로 인해 호출이 실패한 경우

prepareEnvironmentAsync

@RequiresApi(value = 28)
fun prepareEnvironmentAsync(
    request: PrepareEnvironmentRequest,
    notificationServiceComponentName: ComponentName?
): ListenableFuture<PrepareEnvironmentResponse>

기기 환경을 준비합니다.

사용자에게 필요한 Android Device Policy 애플리케이션을 설치하라는 메시지를 표시합니다. 사용자가 메시지를 수락하면 설치를 진행합니다. 설치가 완료되면 Android Device Policy 앱이 준비되었는지 확인하는 작업을 실행합니다.

매개변수
notificationServiceComponentName: ComponentName?

NotificationReceiverService를 확장하는 서비스의 ComponentName입니다. 제공된 경우 호출 앱에 속하며 매니페스트에서 내보낸 유효한 구성요소여야 합니다. 환경 준비 이벤트에 대한 알림을 받으려면 다음을 실행해야 합니다.

  1. 앱에 EnvironmentListener 인터페이스를 구현합니다.

  2. 수신된 이벤트를 처리하는 방법의 구현을 제공합니다.

  3. NotificationReceiverService를 확장하고 EnvironmentListener 인스턴스를 제공합니다.

  4. 확장된 NotificationReceiverService 클래스를 AndroidManifest.xml에 추가하고 내보내기합니다.

예를 들면 다음과 같습니다.

class MyEnvironmentListener : EnvironmentListener {
override fun onEnvironmentEvent(event: EnvironmentEvent) {
// Handle the environment event.
}
}

class MyNotificationReceiverService : NotificationReceiverService() {
override fun getPrepareEnvironmentListener(): EnvironmentListener? {
return MyEnvironmentListener()
}
}
반환 값
ListenableFuture<PrepareEnvironmentResponse>

결과를 래핑하는 ListenableFuture 다음과 같은 값을 가질 수 있습니다.