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

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

Merge "Check system and phone UID in multiple-user-aware way" into main

parents b91f6c71 199a542c
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -921,8 +921,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {

    //helper function to determine if limit on num listeners applies to callingUid
    private boolean doesLimitApplyForListeners(int callingUid, int exemptUid) {
        return (callingUid != Process.SYSTEM_UID
                && callingUid != Process.PHONE_UID
        return (!TelephonyPermissions.isSystemOrPhone(callingUid)
                && callingUid != exemptUid);
    }

+14 −4
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import android.os.UserHandle;
import android.util.Log;
import android.widget.Toast;

import com.android.internal.telephony.TelephonyPermissions;
import com.android.internal.telephony.flags.Flags;
import com.android.internal.telephony.util.TelephonyUtils;

/**
@@ -310,11 +312,19 @@ public final class LocationAccessPolicy {
        // This avoid breaking legacy code that rely on public-facing APIs to access cell location,
        // and it doesn't create an info leak risk because the cell location is stored in the phone
        // process anyway, and the system server already has location access.
        if (Flags.supportPhoneUidCheckForMultiuser()) {
            if (TelephonyPermissions.isSystemOrPhone(query.callingUid)
                    || UserHandle.isSameApp(query.callingUid, Process.NETWORK_STACK_UID)
                    || UserHandle.isSameApp(query.callingUid, Process.ROOT_UID)) {
                return LocationPermissionResult.ALLOWED;
            }
        } else {
            if (query.callingUid == Process.PHONE_UID || query.callingUid == Process.SYSTEM_UID
                    || query.callingUid == Process.NETWORK_STACK_UID
                    || query.callingUid == Process.ROOT_UID) {
                return LocationPermissionResult.ALLOWED;
            }
        }

        // Check the system-wide requirements. If the location main switch is off and the caller is
        // not in the allowlist of apps that always have loation access or the app's profile