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

Commit 9d90bbc9 authored by Pavel Grafov's avatar Pavel Grafov
Browse files

Ensure correct admin name is logged.

Currently if permission checks aren't enabled, caller.getPackageName()
will return null and it will be passed to metrics and security log.
This CL changes it so that caller always has package.

Bug: 266588263
Test: atest OrgOwnedProfileOwnerTest#testSecurityLogging
Change-Id: I55ce06b89563421af50280d893029ac7a41f8081
parent 8f21c8a4
Loading
Loading
Loading
Loading
+2 −6
Original line number Original line Diff line number Diff line
@@ -2315,7 +2315,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
     * Creates a new {@link CallerIdentity} object to represent the caller's identity.
     * Creates a new {@link CallerIdentity} object to represent the caller's identity.
     */
     */
    private CallerIdentity getCallerIdentity(@Nullable String callerPackage) {
    private CallerIdentity getCallerIdentity(@Nullable String callerPackage) {
        return getCallerIdentity(null, callerPackage);
        return getCallerIdentity(null, callerPackage);
    }
    }
@@ -5305,11 +5304,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        Preconditions.checkArgument(allowedModes.contains(passwordComplexity),
        Preconditions.checkArgument(allowedModes.contains(passwordComplexity),
                "Provided complexity is not one of the allowed values.");
                "Provided complexity is not one of the allowed values.");
        CallerIdentity caller;
        CallerIdentity caller = getCallerIdentity(callerPackageName);
        if (isPermissionCheckFlagEnabled()) {
        if (!isPermissionCheckFlagEnabled()) {
            caller = getCallerIdentity(callerPackageName);
        } else {
            caller = getCallerIdentity();
            Preconditions.checkCallAuthorization(
            Preconditions.checkCallAuthorization(
                    isDefaultDeviceOwner(caller) || isProfileOwner(caller));
                    isDefaultDeviceOwner(caller) || isProfileOwner(caller));
            Preconditions.checkArgument(!calledOnParent || isProfileOwner(caller));
            Preconditions.checkArgument(!calledOnParent || isProfileOwner(caller));