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

Commit 0d5c63b6 authored by Anthony Stange's avatar Anthony Stange Committed by Presubmit Automerger Backend
Browse files

[automerge] Use enforceCallingOrSelfPermission for ContextHub APIs 2p: ce8499e1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16940666

Change-Id: I399012ab1d7662d54529d3f66f81e5baa1873b1c
parents 6100cabe ce8499e1
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.server.location.contexthub;

import static android.content.pm.PackageManager.PERMISSION_GRANTED;

import android.Manifest;
import android.content.Context;
import android.hardware.contexthub.V1_0.AsyncEventType;
@@ -297,20 +295,15 @@ import java.util.List;
    }

    /**
     * Checks for location hardware permissions.
     * Checks for ACCESS_CONTEXT_HUB permissions.
     *
     * @param context the context of the service
     */
    /* package */
    static void checkPermissions(Context context) {
        boolean hasAccessContextHubPermission = (context.checkCallingPermission(
                CONTEXT_HUB_PERMISSION) == PERMISSION_GRANTED);

        if (!hasAccessContextHubPermission) {
            throw new SecurityException(
        context.enforceCallingOrSelfPermission(CONTEXT_HUB_PERMISSION,
                "ACCESS_CONTEXT_HUB permission required to use Context Hub");
    }
    }

    /**
     * Helper function to convert from the HAL Result enum error code to the