Fixed Attribution Source’s calling Uid check for multiuser.

The method UserHandle.getAppId() strips off the part of the Uid that is related to the current user (which may not be zero for multiuser).

Bug: 236100828
Test: Unit test
Merged-In: Ie27c8570ba2551b6d99d9848a0b2469fe76ac3d1
Change-Id: I0c1c1a198bb49e944c2e71fd9e23fc6f528aab9a
This commit is contained in:
Cintia Martins
2022-11-14 14:23:39 +00:00
parent 1b53168c1f
commit 41b093d73f

View File

@@ -29,6 +29,7 @@ import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Process;
import android.os.UserHandle;
import android.permission.PermissionManager;
import android.util.ArraySet;
@@ -297,7 +298,7 @@ public final class AttributionSource implements Parcelable {
public boolean checkCallingUid() {
final int callingUid = Binder.getCallingUid();
if (callingUid != Process.ROOT_UID
&& callingUid != Process.SYSTEM_UID
&& UserHandle.getAppId(callingUid) != Process.SYSTEM_UID
&& callingUid != mAttributionSourceState.uid) {
return false;
}