From 83a95852a74ac9e67f7863238a3605c204f6ccce Mon Sep 17 00:00:00 2001 From: Alex Johnston Date: Fri, 12 May 2023 14:40:06 +0000 Subject: [PATCH] Add detailed javadocs for PolicyUpdatedReceiver Required for coexistence Bug: 260847505 Test: NA Change-Id: Icfb9a9174492932f205e97816de8a0781bbf4b8f --- .../app/admin/DevicePolicyManager.java | 262 ++++++++++++++++++ 1 file changed, 262 insertions(+) diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 59b59784b7807..9d51f3de30f16 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -8359,6 +8359,26 @@ public class DevicePolicyManager { * from Android {@link android.os.Build.VERSION_CODES#R}, requests to disable camera from * legacy device admins targeting SDK version {@link android.os.Build.VERSION_CODES#P} or * below will be silently ignored. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the camera disabled + * policy has been set, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, + * Bundle, TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy was + * successfully set or not. This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with or null if the caller is not a device admin @@ -9783,6 +9803,27 @@ public class DevicePolicyManager { *

* The calling device admin must be a profile owner or device owner. If it is not, a security * exception will be thrown. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the persistent preferred + * activity policy has been set, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, + * Bundle, TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy was + * successfully set or not. This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. * *

NOTE: Performs disk I/O and shouldn't be called on the main thread. * @@ -9816,6 +9857,27 @@ public class DevicePolicyManager { *

* The calling device admin must be a profile owner. If it is not, a security exception will be * thrown. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the persistent preferred + * activity policy has been cleared, {@link PolicyUpdateReceiver#onPolicySetResult(Context, + * String, Bundle, TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy + * was successfully cleared or not. This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Null if the * caller is not a device admin. @@ -11475,6 +11537,26 @@ public class DevicePolicyManager { * {@link #getParentProfileInstance(ComponentName)}. To set a restriction globally, call * {@link #addUserRestrictionGlobally} instead. * + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the user restriction + * policy has been set, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, + * Bundle, TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy was + * successfully set or not. This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. + * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param key The key of the restriction. * @throws SecurityException if {@code admin} is not a device or profile owner and if the caller @@ -11507,6 +11589,25 @@ public class DevicePolicyManager { *

See the constants in {@link android.os.UserManager} for the list of restrictions that can * be enforced device-wide. These constants will also state in their documentation which * permission is required to manage the restriction using this API. + *

+ * After the user restriction policy has been set, + * {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin on whether the policy was successfully set or not. + * This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. * * @param key The key of the restriction. * @throws SecurityException if {@code admin} is not a device or profile owner and if the @@ -11544,6 +11645,26 @@ public class DevicePolicyManager { * above, calling this API will result in clearing any local and global restriction with the * specified key that was previously set by the caller. * + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the user restriction + * policy has been cleared, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, + * Bundle, TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy was + * successfully cleared or not. This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. + * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param key The key of the restriction. * @throws SecurityException if {@code admin} is not a device or profile owner and if the @@ -11692,6 +11813,27 @@ public class DevicePolicyManager { * {@link #getParentProfileInstance(ComponentName)}, where the caller must be the profile owner * of an organization-owned managed profile and the package must be a system package. If called * on the parent instance, then the package is hidden or unhidden in the personal profile. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the application hidden + * policy has been set, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, + * Bundle, TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy was + * successfully set or not. This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or * {@code null} if the caller is not a device admin. @@ -11731,6 +11873,9 @@ public class DevicePolicyManager { * of an organization-owned managed profile and the package must be a system package. If called * on the parent instance, this will determine whether the package is hidden or unhidden in the * personal profile. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, the returned policy will be the + * current resolved policy rather than the policy set by the calling admin. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with, or * {@code null} if the caller is not a device admin. @@ -11855,6 +12000,27 @@ public class DevicePolicyManager { * {@link #getParentProfileInstance(ComponentName)} by the profile owner on an * organization-owned device, to restrict accounts that may not be managed on the primary * profile. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the account management + * disabled policy has been set, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, + * Bundle, TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy was + * successfully set or not. This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Null if the * caller is not a device admin. @@ -11987,6 +12153,28 @@ public class DevicePolicyManager { * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_LOCK_TASK}. See * {@link #isAffiliatedUser}. * Any package set via this method will be cleared if the user becomes unaffiliated. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the lock task policy has + * been set, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin on whether the policy was successfully set or not. + * This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, lock task features and lock task + * packages are bundled as one policy. A failure to apply one will result in a failure to apply + * the other. * * @param packages The list of packages allowed to enter lock task mode * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Null if the @@ -12016,6 +12204,9 @@ public class DevicePolicyManager { /** * Returns the list of packages allowed to start the lock task mode. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, the returned policy will be the + * current resolved policy rather than the policy set by the calling admin. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Null if the * caller is not a device admin. @@ -12068,6 +12259,28 @@ public class DevicePolicyManager { * permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_LOCK_TASK}. See * {@link #isAffiliatedUser}. * Any features set using this method are cleared if the user becomes unaffiliated. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the lock task features + * policy has been set, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, Bundle, + * TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy was + * successfully set or not. This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, lock task features and lock task + * packages are bundled as one policy. A failure to apply one will result in a failure to apply + * the other. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Null if the * caller is not a device admin. @@ -12092,6 +12305,9 @@ public class DevicePolicyManager { /** * Gets which system features are enabled for LockTask mode. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, the returned policy will be the + * current resolved policy rather than the policy set by the calling admin. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Null if the * caller is not a device admin. @@ -12577,6 +12793,27 @@ public class DevicePolicyManager { * profile owner, or by a delegate given the {@link #DELEGATION_BLOCK_UNINSTALL} scope via * {@link #setDelegatedScopes} or holders of the permission * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_APPS_CONTROL}. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the set uninstall blocked + * policy has been set, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, + * Bundle, TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy was + * successfully set or not. This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Null if the * caller is not a device admin. @@ -12614,6 +12851,9 @@ public class DevicePolicyManager { * Note: If your app targets Android 11 (API level 30) or higher, * this method returns a filtered result. Learn more about how to * manage package visibility. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, the returned policy will be the + * current resolved policy rather than the policy set by the calling admin. * * @param admin The name of the admin component whose blocking policy will be checked, or * {@code null} to check whether any admin has blocked the uninstallation. Starting @@ -15723,6 +15963,25 @@ public class DevicePolicyManager { * control over apps. User will not be able to clear app data or force-stop packages. When * called by a device owner, applies to all users on the device. Packages with user control * disabled are exempted from App Standby Buckets. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, after the user control disabled + * packages policy has been set, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String, + * Bundle, TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy was + * successfully set or not. This callback will contain: + *

+ * If there has been a change to the policy, + * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, + * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the + * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult} + * will contain the reason why the policy changed. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Null if the * caller is not a device admin. @@ -15749,6 +16008,9 @@ public class DevicePolicyManager { * Returns the list of packages over which user control is disabled by a device or profile * owner or holders of the permission * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_APPS_CONTROL}. + *

+ * Starting from {@link Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, the returned policy will be the + * current resolved policy rather than the policy set by the calling admin. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Null if the * caller is not a device admin.