summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Rubin Xu <rubinxu@google.com> 2015-07-31 13:28:42 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2015-07-31 13:28:42 +0000
commit3eaf7d2155d0c513eb08f66abc02f87b09659be7 (patch)
tree97e0e9525822eba05b685553afb25b460b1ecfc6
parent54aed5215d8542e7425c107e1bcdfea2dfa0fff8 (diff)
parent6501720c721f2a0997d7cdd45303ed14eb54ded7 (diff)
am 6501720c: am 489043d4: am 9a81a182: Merge "Don\'t always transfer device owner status to other users." into mnc-dev
* commit '6501720c721f2a0997d7cdd45303ed14eb54ded7': Don't always transfer device owner status to other users.
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index d9afa005bc98..1e833b1e7aba 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -1277,11 +1277,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
&& !hasUserSetupCompleted(userId);
if (reqPolicy == DeviceAdminInfo.USES_POLICY_DEVICE_OWNER) {
- if (ownsDevice || (userId == UserHandle.USER_OWNER && ownsInitialization)) {
+ if ((userId == UserHandle.USER_OWNER && (ownsDevice || ownsInitialization))
+ || (ownsDevice && ownsProfile)) {
return true;
}
} else if (reqPolicy == DeviceAdminInfo.USES_POLICY_PROFILE_OWNER) {
- if (ownsDevice || ownsProfile || ownsInitialization) {
+ if ((userId == UserHandle.USER_OWNER && ownsDevice) || ownsProfile
+ || ownsInitialization) {
return true;
}
} else {
@@ -4244,6 +4246,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
throw new IllegalArgumentException("Invalid component name " + initializer
+ " for device initializer");
}
+ boolean isInitializerSystemApp;
+ try {
+ isInitializerSystemApp = isSystemApp(AppGlobals.getPackageManager(),
+ initializer.getPackageName(), Binder.getCallingUserHandle().getIdentifier());
+ } catch (RemoteException | IllegalArgumentException e) {
+ isInitializerSystemApp = false;
+ Slog.e(LOG_TAG, "Fail to check if device initialzer is system app.", e);
+ }
+ if (!isInitializerSystemApp) {
+ throw new IllegalArgumentException("Only system app can be set as device initializer.");
+ }
synchronized (this) {
enforceCanSetDeviceInitializer(who);