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

Commit cc9897b5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refactored same profile group check for CrossProfileApps."

parents 0e21df30 096104f3
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
                        android.Manifest.permission.INTERACT_ACROSS_PROFILES, callingUid,
                        -1, true);
                if (permissionFlag != PackageManager.PERMISSION_GRANTED
                        || !mInjector.getUserManager().isSameProfileGroup(callerUserId, userId)) {
                        || !isSameProfileGroup(callerUserId, userId)) {
                    throw new SecurityException("Attempt to launch activity without required "
                            + android.Manifest.permission.INTERACT_ACROSS_PROFILES + " permission"
                            + " or target user is not in the same profile group.");
@@ -209,6 +209,15 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
        }
    }

    private boolean isSameProfileGroup(@UserIdInt int callerUserId, @UserIdInt int userId) {
        final long ident = mInjector.clearCallingIdentity();
        try {
            return mInjector.getUserManager().isSameProfileGroup(callerUserId, userId);
        } finally {
            mInjector.restoreCallingIdentity(ident);
        }
    }

    /**
     * Verify that the given calling package is belong to the calling UID.
     */