Add missing check in hasGrantedPolicy

Add check that if component name is specified, it belong to the caller.

Bug: 192247339
Test: NA

Change-Id: I6f821d039a6dfd70fb005165af2c5cb13ad3de9b
Merged-In: I6f821d039a6dfd70fb005165af2c5cb13ad3de9b
(cherry picked from commit c7abd726dd508e327073df0293fcf9084c7004f0)
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 193d92a..dca12245 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -3599,6 +3599,9 @@
 
         final CallerIdentity caller = getCallerIdentity();
         Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
+        Preconditions.checkCallAuthorization(
+                isCallingFromPackage(adminReceiver.getPackageName(), caller.getUid())
+                        || isSystemUid(caller));
 
         synchronized (getLockObject()) {
             ActiveAdmin administrator = getActiveAdminUncheckedLocked(adminReceiver, userHandle);