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

Commit 9ea7ecb6 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Allow permission renouncement without RENOUNCE permission in test mode." into sc-dev

parents 96811421 9ff28be4
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -546,12 +546,13 @@ public final class Utils {
    // Suppressed since we're not actually enforcing here
    @SuppressLint("AndroidFrameworkRequiresPermission")
    public static boolean hasDisavowedLocationForScan(
            Context context, String packageName, AttributionSource attributionSource) {
            Context context, String packageName, AttributionSource attributionSource,
            boolean inTestMode) {

        // TODO(b/183625242): Handle multi-step attribution chains here.
        if (attributionSource.getRenouncedPermissions().contains(ACCESS_FINE_LOCATION)
                && context.checkCallingPermission(RENOUNCE_PERMISSIONS)
                == PackageManager.PERMISSION_GRANTED) {
                && (inTestMode || context.checkCallingPermission(RENOUNCE_PERMISSIONS)
                        == PackageManager.PERMISSION_GRANTED)) {
            return true;
        }

+5 −1
Original line number Diff line number Diff line
@@ -287,6 +287,8 @@ public class AdapterService extends Service {
    private HearingAidService mHearingAidService;
    private SapService mSapService;

    private boolean mTestModeEnabled;

    /**
     * Register a {@link ProfileService} with AdapterService.
     *
@@ -2473,7 +2475,8 @@ public class AdapterService extends Service {
        mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
        boolean isQApp = Utils.isQApp(this, callingPackage);
        boolean hasDisavowedLocation =
                Utils.hasDisavowedLocationForScan(this, callingPackage, attributionSource);
                Utils.hasDisavowedLocationForScan(this, callingPackage, attributionSource,
                        mTestModeEnabled);
        String permission = null;
        if (Utils.checkCallerHasNetworkSettingsPermission(this)) {
            permission = android.Manifest.permission.NETWORK_SETTINGS;
@@ -3405,6 +3408,7 @@ public class AdapterService extends Service {
            for (ProfileService profile : mRunningProfiles) {
                profile.setTestModeEnabled(testModeEnabled);
            }
            mTestModeEnabled = true;
            return;
        }

+4 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.content.pm.PackageManager.PERMISSION_GRANTED;

import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.app.ActivityThread;
import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.app.Service;
@@ -2270,7 +2269,8 @@ public class GattService extends ProfileService {
                callingPackage.equals(mExposureNotificationPackage);

        scanClient.hasDisavowedLocation =
                Utils.hasDisavowedLocationForScan(this, callingPackage, attributionSource);
                Utils.hasDisavowedLocationForScan(this, callingPackage, attributionSource,
                        isTestModeEnabled());

        scanClient.isQApp = Utils.isQApp(this, callingPackage);
        if (!scanClient.hasDisavowedLocation) {
@@ -2343,7 +2343,8 @@ public class GattService extends ProfileService {
                callingPackage.equals(mExposureNotificationPackage);

        app.mHasDisavowedLocation =
                Utils.hasDisavowedLocationForScan(this, callingPackage, attributionSource);
                Utils.hasDisavowedLocationForScan(this, callingPackage, attributionSource,
                        isTestModeEnabled());

        app.mIsQApp = Utils.isQApp(this, callingPackage);
        if (!app.mHasDisavowedLocation) {