diff options
| author | 2016-11-04 14:02:09 +0000 | |
|---|---|---|
| committer | 2016-11-04 14:02:12 +0000 | |
| commit | e50a485c22334fd5b63663200a8e39f7e2b5b108 (patch) | |
| tree | d686adb6008172dbbeae557eec84386917e5cd16 | |
| parent | 343dbac2e0519f0dda41eb9337957b35f53098a9 (diff) | |
| parent | 34fb70ab88408b629350a80f6f68648a95db62bf (diff) | |
Merge "If the current device is a watch, fix DeviceOwner/ProfileOwner logic." into cw-f-dev
| -rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 37144950e97d..96331e83dd31 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -6144,6 +6144,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return hasUserSetupCompleted(UserHandle.getCallingUserId()); } + // This checks only if the Setup Wizard has run. Since Wear devices pair before + // completing Setup Wizard, and pairing involves transferring user data, calling + // logic may want to check mIsWatch or mPaired in addition to hasUserSetupCompleted(). private boolean hasUserSetupCompleted(int userHandle) { if (!mHasFeature) { return true; @@ -6388,7 +6391,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } int callingUid = mInjector.binderGetCallingUid(); if (callingUid == Process.SHELL_UID || callingUid == Process.ROOT_UID) { - if (hasUserSetupCompleted(userHandle) + if ((mIsWatch || hasUserSetupCompleted(userHandle)) && hasIncompatibleAccountsLocked(userHandle, owner)) { throw new IllegalStateException("Not allowed to set the profile owner because " + "there are already some accounts on the profile"); @@ -6396,7 +6399,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return; } enforceCanManageProfileAndDeviceOwners(); - if (hasUserSetupCompleted(userHandle) && !isCallerWithSystemUid()) { + if ((mIsWatch || hasUserSetupCompleted(userHandle)) && !isCallerWithSystemUid()) { throw new IllegalStateException("Cannot set the profile owner on a user which is " + "already set-up"); } @@ -8633,6 +8636,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (hasUserSetupCompleted(callingUserId)) { return false; } + if (mIsWatch && hasPaired(UserHandle.USER_SYSTEM)) { + return false; + } return true; } else if (DevicePolicyManager.ACTION_PROVISION_MANAGED_SHAREABLE_DEVICE.equals(action)) { if (!mInjector.userManagerIsSplitSystemUser()) { @@ -8664,7 +8670,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } if (isAdb) { // if shell command runs after user setup completed check device status. Otherwise, OK. - if (hasUserSetupCompleted(UserHandle.USER_SYSTEM)) { + if (mIsWatch || hasUserSetupCompleted(UserHandle.USER_SYSTEM)) { if (!mInjector.userManagerIsSplitSystemUser()) { if (mUserManager.getUserCount() > 1) { return CODE_NONSYSTEM_USER_EXISTS; |