androidandroid-management-api

Android management API autoUpdateMode not applied


I've implemented a management server via this library which google provides.

com.google.apis:google-api-services-androidmanagement:v1-rev20211122-1.32.1

My policy looks as below.

Policy()
    .setApplications(
        Collections.singletonList(
            ApplicationPolicy()
                .setPackageName(getAppPackageByHotelSeq(hotelSeq))
                .setManagedConfiguration(getPolicyParams(policyName))
                .setInstallType("KIOSK")
                .setDefaultPermissionPolicy("GRANT")
                .setPermissionGrants(
                    mutableListOf(
                        PermissionGrant().setPermission("android.permission.ACCESS_NETWORK_STATE")
                            .setPolicy("GRANT"),
                        PermissionGrant().setPermission("android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS")
                            .setPolicy("GRANT"),
                        PermissionGrant().setPermission("android.permission.CAMERA").setPolicy("GRANT"),
                        PermissionGrant().setPermission("android.permission.ACCESS_COARSE_LOCATION")
                            .setPolicy("GRANT"),
                        PermissionGrant().setPermission("android.permission.ACCESS_FINE_LOCATION")
                            .setPolicy("GRANT"),
                        PermissionGrant().setPermission("android.permission.WAKE_LOCK").setPolicy("GRANT"),
                        PermissionGrant().setPermission("android.permission.WRITE_EXTERNAL_STORAGE")
                            .setPolicy("GRANT"),
                        PermissionGrant().setPermission("android.permission.READ_EXTERNAL_STORAGE")
                            .setPolicy("GRANT"),
                        PermissionGrant().setPermission("android.permission.READ_PHONE_STATE").setPolicy("GRANT"),
                        PermissionGrant().setPermission("android.permission.ACCESS_WIFI_STATE").setPolicy("GRANT"),
                        PermissionGrant().setPermission("android.permission.RECORD_AUDIO").setPolicy("GRANT")
                    )
                )
                .setLockTaskAllowed(true)
                **.setAutoUpdateMode("AUTO_UPDATE_HIGH_PRIORITY")**
        )
    )
    .setPersistentPreferredActivities(
        Collections.singletonList(
            PersistentPreferredActivity()
                .setReceiverActivity(getAppPackageByHotelSeq(hotelSeq))
                .setActions(
                    Collections.singletonList("android.intent.action.MAIN")
                )
                .setCategories(categories)
        )
    )
    .setSystemUpdate(SystemUpdate().setType("WINDOWED").setStartMinutes(0).setEndMinutes(1439))
    .setKeyguardDisabled(true)
    .setDebuggingFeaturesAllowed(true)
    .setStatusBarDisabled(true)
    .setStatusReportingSettings(StatusReportingSettings().apply {
        applicationReportsEnabled = false
        deviceSettingsEnabled = true
        softwareInfoEnabled = true
        memoryInfoEnabled = false
        networkInfoEnabled = true
        displayInfoEnabled = true
        powerManagementEventsEnabled = true
        hardwareStatusEnabled = false
        systemPropertiesEnabled = true
        applicationReportingSettings = ApplicationReportingSettings()
    }).apply {
        if (!enablePower) {
            this.kioskCustomization = KioskCustomization().setPowerButtonActions("POWER_BUTTON_BLOCKED")
        }
    }

According to the documentation(https://developers.google.com/android/management/control-app-updates), the line

.setAutoUpdateMode("AUTO_UPDATE_HIGH_PRIORITY")

is supposed to update my target app immediately after an update is posted. However, it isn't happenning.

If I add this line and apply the policy,

 minimumVersionCode = 'my newest version code as integer'

A warning popup is shown almost instantly that the app version is low, and without a manual update, the device will be deleted in 9 days. (After 10~15 minutes after this threatening popup, the update seems to kick in.)

What can I do to solve this issue?


Solution

  • The time window for autoUpdateHighPriority, at the time being, will take up to 30 minutes - 2 hours before the app gets updated. In your case, it only takes 10-15 minutes after the update kicks in and is working as intended. For more information, please refer to this documentation.

    When setting minimumVersionCode, Android Device Policy makes sure that the app is updated to the minimumVersion that you set. If the version is lower, it makes the device non-compliant. Hence, the popup appears that the device will be deleted in 9 days and is gone after the update kicks in.