summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-01-23 21:41:39 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-01-23 21:41:39 +0000
commit296afcc02972d7a1bcf65a350728038d9d59f72a (patch)
treeb81ea676b8f422524c2ded14477ca4e58dc46089
parent0f681fb3fb2e85a39ac434e4728d0255e14f1d50 (diff)
parentca00dd49003ae2c0ce3fccd952a516bae6045c8e (diff)
Merge "Expose system update related API to corp-owned managed profile"
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java9
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java9
2 files changed, 11 insertions, 7 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 62557dca9e7e..fa9dd274488f 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -9109,7 +9109,8 @@ public class DevicePolicyManager {
}
/**
- * Called by device owners to set a local system update policy. When a new policy is set,
+ * Called by device owners or profile owners of an organization-owned managed profile to to set
+ * a local system update policy. When a new policy is set,
* {@link #ACTION_SYSTEM_UPDATE_POLICY_CHANGED} is broadcasted.
* <p>
* If the supplied system update policy has freeze periods set but the freeze periods do not
@@ -9127,7 +9128,8 @@ public class DevicePolicyManager {
* components in the device owner package can set system update policies and the most
* recent policy takes effect.
* @param policy the new policy, or {@code null} to clear the current policy.
- * @throws SecurityException if {@code admin} is not a device owner.
+ * @throws SecurityException if {@code admin} is not a device owner or a profile owner of an
+ * organization-owned managed profile.
* @throws IllegalArgumentException if the policy type or maintenance window is not valid.
* @throws SystemUpdatePolicy.ValidationFailedException if the policy's freeze period does not
* meet the requirement.
@@ -11212,7 +11214,8 @@ public class DevicePolicyManager {
}
/**
- * Called by device owner to install a system update from the given file. The device will be
+ * Called by device owner or profile owner of an organization-owned managed profile to install
+ * a system update from the given file. The device will be
* rebooted in order to finish installing the update. Note that if the device is rebooted, this
* doesn't necessarily mean that the update has been applied successfully. The caller should
* additionally check the system version with {@link android.os.Build#FINGERPRINT} or {@link
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index da107d04b551..b6953f6e3e36 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -12211,7 +12211,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
LocalDate.now());
}
synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
+ getActiveAdminForCallerLocked(who,
+ DeviceAdminInfo.USES_POLICY_ORGANIZATION_OWNED_PROFILE_OWNER);
if (policy == null) {
mOwners.clearSystemUpdatePolicy();
} else {
@@ -12220,9 +12221,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
mOwners.writeDeviceOwner();
}
- mContext.sendBroadcastAsUser(
+ mInjector.binderWithCleanCallingIdentity(() -> mContext.sendBroadcastAsUser(
new Intent(DevicePolicyManager.ACTION_SYSTEM_UPDATE_POLICY_CHANGED),
- UserHandle.SYSTEM);
+ UserHandle.SYSTEM));
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.SET_SYSTEM_UPDATE_POLICY)
.setAdmin(who)
@@ -14884,7 +14885,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
.setAdmin(admin)
.setBoolean(isDeviceAB())
.write();
- enforceDeviceOwner(admin);
+ enforceDeviceOwnerOrProfileOwnerOnOrganizationOwnedDevice(admin);
mInjector.binderWithCleanCallingIdentity(() -> {
UpdateInstaller updateInstaller;
if (isDeviceAB()) {