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

Commit 1997453d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add Pid to CallerIdentity" into main

parents 00f8279d e221bfef
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -27,18 +27,25 @@ import android.os.UserHandle;
 */
final class CallerIdentity {

    private final int mPid;
    private final int mUid;
    @Nullable
    private final String mPackageName;
    @Nullable
    private final ComponentName mComponentName;

    CallerIdentity(int uid, @Nullable String packageName, @Nullable ComponentName componentName) {
    CallerIdentity(int pid, int uid, @Nullable String packageName,
            @Nullable ComponentName componentName) {
        mPid = pid;
        mUid = uid;
        mPackageName = packageName;
        mComponentName = componentName;
    }

    public int getPid() {
        return mPid;
    }

    public int getUid() {
        return mUid;
    }
@@ -51,11 +58,13 @@ final class CallerIdentity {
        return UserHandle.getUserHandleForUid(mUid);
    }

    @Nullable public String getPackageName() {
    @Nullable
    public String getPackageName() {
        return mPackageName;
    }

    @Nullable public ComponentName getComponentName() {
    @Nullable
    public ComponentName getComponentName() {
        return mComponentName;
    }

+6 −5
Original line number Diff line number Diff line
@@ -2517,6 +2517,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    CallerIdentity getCallerIdentity(@Nullable ComponentName adminComponent,
            @Nullable String callerPackage) {
        final int callerUid = mInjector.binderGetCallingUid();
        final int callerPid = mInjector.binderGetCallingPid();
        if (callerPackage != null) {
            if (!isCallingFromPackage(callerPackage, callerUid)) {
@@ -2543,7 +2544,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            }
        }
        return new CallerIdentity(callerUid, callerPackage, adminComponent);
        return new CallerIdentity(callerPid, callerUid, callerPackage, adminComponent);
    }
    /**
@@ -16202,17 +16203,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        @Override
        public boolean isActiveDeviceOwner(int uid) {
            return isDefaultDeviceOwner(new CallerIdentity(uid, null, null));
            return isDefaultDeviceOwner(new CallerIdentity(Process.INVALID_PID, uid, null, null));
        }
        @Override
        public boolean isActiveProfileOwner(int uid) {
            return isProfileOwner(new CallerIdentity(uid, null, null));
            return isProfileOwner(new CallerIdentity(Process.INVALID_PID, uid, null, null));
        }
        @Override
        public boolean isActiveSupervisionApp(int uid) {
            if (!isProfileOwner(new CallerIdentity(uid, null, null))) {
            if (!isProfileOwner(new CallerIdentity(Process.INVALID_PID, uid, null, null))) {
                return false;
            }
            synchronized (getLockObject()) {
@@ -16277,7 +16278,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                return false;
            }
            CallerIdentity caller = new CallerIdentity(callerUid, null, null);
            CallerIdentity caller = new CallerIdentity(Process.INVALID_PID, callerUid, null, null);
            if (isUserAffiliatedWithDevice(UserHandle.getUserId(callerUid))
                    && (isActiveProfileOwner(callerUid)
                    || isDefaultDeviceOwner(caller) || isFinancedDeviceOwner(caller))) {