Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0550536b authored by Rubin Xu's avatar Rubin Xu Committed by Android Git Automerger
Browse files

am 3eaf7d21: am 6501720c: am 489043d4: am 9a81a182: Merge "Don\'t always...

am 3eaf7d21: am 6501720c: am 489043d4: am 9a81a182: Merge "Don\'t always transfer device owner status to other users." into mnc-dev

* commit '3eaf7d21':
  Don't always transfer device owner status to other users.
parents 33cb97c0 3eaf7d21
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -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);