From 4fe4b2e65d68f09bf14601b0ab3b3ea90cc1ed4c Mon Sep 17 00:00:00 2001 From: arangelov Date: Wed, 16 Mar 2022 18:00:32 +0000 Subject: [PATCH] Add extra to inform the role holder of the update attempt result Role holders can request an update. When that happens, the flow returns back to platform, platform performs the update and checks the update result. If update was successful, it restared the role holder, and if not, it failed provisioning. This CL updates this so that the role holder is _always_ started, regardless of the update result. That way the role holder can make a decision whether to continue provisioning or fail it. Bug: 224993192 Test: none Change-Id: Ia7dd61d02c568e8c8ad17af0a61106d127c4869a --- core/api/system-current.txt | 1 + .../app/admin/DevicePolicyManager.java | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 2bdc35cf70e59..e806fcf739426 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -1149,6 +1149,7 @@ package android.app.admin { field public static final String EXTRA_RESTRICTION = "android.app.extra.RESTRICTION"; field public static final String EXTRA_ROLE_HOLDER_PROVISIONING_INITIATOR_PACKAGE = "android.app.extra.ROLE_HOLDER_PROVISIONING_INITIATOR_PACKAGE"; field public static final String EXTRA_ROLE_HOLDER_STATE = "android.app.extra.ROLE_HOLDER_STATE"; + field public static final String EXTRA_ROLE_HOLDER_UPDATE_RESULT_CODE = "android.app.extra.ROLE_HOLDER_UPDATE_RESULT_CODE"; field public static final int FLAG_SUPPORTED_MODES_DEVICE_OWNER = 4; // 0x4 field public static final int FLAG_SUPPORTED_MODES_ORGANIZATION_OWNED = 1; // 0x1 field public static final int FLAG_SUPPORTED_MODES_PERSONALLY_OWNED = 2; // 0x2 diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 10e976f79b398..0eed01f229fb9 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -3345,6 +3345,34 @@ public class DevicePolicyManager { public static final int RESULT_UPDATE_DEVICE_POLICY_MANAGEMENT_ROLE_HOLDER_PROVISIONING_DISABLED = 3; + /** + * An {@code int} extra which contains the result code of the last attempt to update + * the device policy management role holder. + * + *

This extra is provided to the device policy management role holder via either {@link + * #ACTION_ROLE_HOLDER_PROVISION_MANAGED_DEVICE_FROM_TRUSTED_SOURCE} or {@link + * #ACTION_ROLE_HOLDER_PROVISION_MANAGED_PROFILE} when started after the role holder + * had previously returned {@link #RESULT_UPDATE_ROLE_HOLDER}. + * + *

If the role holder update had failed, the role holder can use the value of this extra to + * make a decision whether to fail the provisioning flow or to carry on with the older version + * of the role holder. + * + *

Possible values can be: + *

+ * + * @hide + */ + @SystemApi + public static final String EXTRA_ROLE_HOLDER_UPDATE_RESULT_CODE = + "android.app.extra.ROLE_HOLDER_UPDATE_RESULT_CODE"; + /** * An {@link Intent} extra which resolves to a custom user consent screen. *