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

Commit 122c595c authored by Robin Lee's avatar Robin Lee
Browse files

More meaningful errors for DPM calls by non-owners

Now throws an exception titled something like "Admin X does not own the
profile" instead of the rather unhelpful NullPointerException that was
thrown previously.

Change-Id: I33f6da5ea5eb70d8ea3939cfa280c794b01c3382
parent 1b8aef2b
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);
        }
    }