Loading services/appfunctions/java/com/android/server/appfunctions/CallerValidatorImpl.java +33 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.pm.PackageManager; import android.os.Binder; import android.os.Process; import android.os.UserHandle; import android.permission.flags.Flags; import com.android.internal.infra.AndroidFuture; Loading Loading @@ -63,8 +64,12 @@ class CallerValidatorImpl implements CallerValidator { int callingUid = Binder.getCallingUid(); final long callingIdentityToken = Binder.clearCallingIdentity(); try { if (Flags.appFunctionAccessServiceEnabled()) { return handleIncomingUserCrossUserNotAllowed(targetUserHandle, callingUid); } else { return handleIncomingUser( claimedCallingPackage, targetUserHandle, callingPid, callingUid); } } finally { Binder.restoreCallingIdentity(callingIdentityToken); } Loading Loading @@ -162,6 +167,32 @@ class CallerValidatorImpl implements CallerValidator { + Manifest.permission.INTERACT_ACROSS_USERS_FULL); } /** * Helper for dealing with incoming user arguments to system service calls. * * <p>Takes care of if interaction is cross user, this method will simply throw. * * @param targetUserHandle The user which the caller is requesting to execute as. * @param callingUid The actual uid of the caller as determined by Binder. * @return the user handle that the call should run as. Will always be a concrete user. * @throws SecurityException if caller trying to interact across user. */ @NonNull private UserHandle handleIncomingUserCrossUserNotAllowed( @NonNull UserHandle targetUserHandle, int callingUid) { UserHandle callingUserHandle = UserHandle.getUserHandleForUid(callingUid); if (callingUserHandle.equals(targetUserHandle)) { return targetUserHandle; } throw new SecurityException( "Permission denied while calling from uid " + callingUid + " with " + targetUserHandle + "; Cross user interaction is not allowed"); } /** * Checks that the caller's supposed package name matches the uid making the call. * Loading Loading
services/appfunctions/java/com/android/server/appfunctions/CallerValidatorImpl.java +33 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.pm.PackageManager; import android.os.Binder; import android.os.Process; import android.os.UserHandle; import android.permission.flags.Flags; import com.android.internal.infra.AndroidFuture; Loading Loading @@ -63,8 +64,12 @@ class CallerValidatorImpl implements CallerValidator { int callingUid = Binder.getCallingUid(); final long callingIdentityToken = Binder.clearCallingIdentity(); try { if (Flags.appFunctionAccessServiceEnabled()) { return handleIncomingUserCrossUserNotAllowed(targetUserHandle, callingUid); } else { return handleIncomingUser( claimedCallingPackage, targetUserHandle, callingPid, callingUid); } } finally { Binder.restoreCallingIdentity(callingIdentityToken); } Loading Loading @@ -162,6 +167,32 @@ class CallerValidatorImpl implements CallerValidator { + Manifest.permission.INTERACT_ACROSS_USERS_FULL); } /** * Helper for dealing with incoming user arguments to system service calls. * * <p>Takes care of if interaction is cross user, this method will simply throw. * * @param targetUserHandle The user which the caller is requesting to execute as. * @param callingUid The actual uid of the caller as determined by Binder. * @return the user handle that the call should run as. Will always be a concrete user. * @throws SecurityException if caller trying to interact across user. */ @NonNull private UserHandle handleIncomingUserCrossUserNotAllowed( @NonNull UserHandle targetUserHandle, int callingUid) { UserHandle callingUserHandle = UserHandle.getUserHandleForUid(callingUid); if (callingUserHandle.equals(targetUserHandle)) { return targetUserHandle; } throw new SecurityException( "Permission denied while calling from uid " + callingUid + " with " + targetUserHandle + "; Cross user interaction is not allowed"); } /** * Checks that the caller's supposed package name matches the uid making the call. * Loading