From 735b4dc0af2571926d4ca573377881959237a6a4 Mon Sep 17 00:00:00 2001 From: Greg Plesur Date: Thu, 9 Feb 2017 11:06:24 -0500 Subject: [PATCH] Allow any device with a device_owner to execute setDeviceOwnerSystemPropertyLocked(). BUG: 34824902 Change-Id: I95fbe0a352c48a3fff5af57b91325901a16d3d89 --- .../devicepolicy/DevicePolicyManagerService.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index daffefe81643a..690978e6b3f7d 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -1725,11 +1725,14 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } private void setDeviceOwnerSystemPropertyLocked() { - // Device owner may still be provisioned, do not set the read-only system property yet. - // Wear devices don't set device_provisioned until the device is paired, so allow - // device_owner property to be set without that. - if (!mIsWatch - && mInjector.settingsGlobalGetInt(Settings.Global.DEVICE_PROVISIONED, 0) == 0) { + final boolean deviceProvisioned = + mInjector.settingsGlobalGetInt(Settings.Global.DEVICE_PROVISIONED, 0) != 0; + // If the device is not provisioned and there is currently no device owner, do not set the + // read-only system property yet, since Device owner may still be provisioned. For Wear + // devices, if there is already a device owner then it's OK to set the property to true now, + // regardless the provision state. + final boolean isWatchWithDeviceOwner = mIsWatch && mOwners.hasDeviceOwner(); + if (!isWatchWithDeviceOwner && !deviceProvisioned) { return; } // Still at the first stage of CryptKeeper double bounce, mOwners.hasDeviceOwner is