Merge changes from topic "presubmit-am-b480a938e1a74bd1a08c92e592efe11e" into tm-mainline-prod
* changes:
[automerge] Use enforceCallingOrSelfPermission for ContextHub APIs 2p: ce8499e167
Use enforceCallingOrSelfPermission for ContextHub APIs
This commit is contained in:
committed by
Android (Google) Code Review
commit
bb0084cc13
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.server.location.contexthub;
|
package com.android.server.location.contexthub;
|
||||||
|
|
||||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.contexthub.V1_0.AsyncEventType;
|
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
|
* @param context the context of the service
|
||||||
*/
|
*/
|
||||||
/* package */
|
/* package */
|
||||||
static void checkPermissions(Context context) {
|
static void checkPermissions(Context context) {
|
||||||
boolean hasAccessContextHubPermission = (context.checkCallingPermission(
|
context.enforceCallingOrSelfPermission(CONTEXT_HUB_PERMISSION,
|
||||||
CONTEXT_HUB_PERMISSION) == PERMISSION_GRANTED);
|
|
||||||
|
|
||||||
if (!hasAccessContextHubPermission) {
|
|
||||||
throw new SecurityException(
|
|
||||||
"ACCESS_CONTEXT_HUB permission required to use Context Hub");
|
"ACCESS_CONTEXT_HUB permission required to use Context Hub");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to convert from the HAL Result enum error code to the
|
* Helper function to convert from the HAL Result enum error code to the
|
||||||
|
|||||||
Reference in New Issue
Block a user