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

Commit 44eb1b01 authored by Robin Lee's avatar Robin Lee Committed by Android (Google) Code Review
Browse files

Merge "More meaningful errors for DPM calls by non-owners"

parents cf5085bd 122c595c
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -818,12 +818,20 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }

        if (who != null) {
            if (reqPolicy == DeviceAdminInfo.USES_POLICY_DEVICE_OWNER) {
                throw new SecurityException("Admin " + candidates.get(0).info.getComponent()
                         + " does not own the device");
            }
            if (reqPolicy == DeviceAdminInfo.USES_POLICY_PROFILE_OWNER) {
                throw new SecurityException("Admin " + candidates.get(0).info.getComponent()
                        + " does not own the profile");
            }
            throw new SecurityException("Admin " + candidates.get(0).info.getComponent()
                    + " did not specify uses-policy for: "
                    + candidates.get(0).info.getTagForPolicy(reqPolicy));
        } else {
            throw new SecurityException("No active admin owned by uid "
                    + Binder.getCallingUid() + " for policy:" + reqPolicy);
                    + Binder.getCallingUid() + " for policy #" + reqPolicy);
        }
    }