summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/hardware/contexthub/IContextHubEndpoint.aidl6
-rw-r--r--services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java18
2 files changed, 18 insertions, 6 deletions
diff --git a/core/java/android/hardware/contexthub/IContextHubEndpoint.aidl b/core/java/android/hardware/contexthub/IContextHubEndpoint.aidl
index b76b2271fe57..44f80c819e83 100644
--- a/core/java/android/hardware/contexthub/IContextHubEndpoint.aidl
+++ b/core/java/android/hardware/contexthub/IContextHubEndpoint.aidl
@@ -39,6 +39,7 @@ interface IContextHubEndpoint {
* @throws IllegalArgumentException If the HubEndpointInfo is not valid.
* @throws IllegalStateException If there are too many opened sessions.
*/
+ @EnforcePermission("ACCESS_CONTEXT_HUB")
int openSession(in HubEndpointInfo destination, in @nullable String serviceDescriptor);
/**
@@ -49,6 +50,7 @@ interface IContextHubEndpoint {
*
* @throws IllegalStateException If the session wasn't opened.
*/
+ @EnforcePermission("ACCESS_CONTEXT_HUB")
void closeSession(int sessionId, int reason);
/**
@@ -60,11 +62,13 @@ interface IContextHubEndpoint {
*
* @throws IllegalStateException If the session wasn't opened.
*/
+ @EnforcePermission("ACCESS_CONTEXT_HUB")
void openSessionRequestComplete(int sessionId);
/**
* Unregister this endpoint from the HAL, invalidate the EndpointInfo previously assigned.
*/
+ @EnforcePermission("ACCESS_CONTEXT_HUB")
void unregister();
/**
@@ -76,6 +80,7 @@ interface IContextHubEndpoint {
* @param transactionCallback Nullable. If the hub message requires a reply, the transactionCallback
* will be set to non-null.
*/
+ @EnforcePermission("ACCESS_CONTEXT_HUB")
void sendMessage(int sessionId, in HubMessage message,
in @nullable IContextHubTransactionCallback transactionCallback);
@@ -87,5 +92,6 @@ interface IContextHubEndpoint {
* @param messageSeqNumber The message sequence number, this should match a previously received HubMessage.
* @param errorCode The message delivery status detail.
*/
+ @EnforcePermission("ACCESS_CONTEXT_HUB")
void sendMessageDeliveryStatus(int sessionId, int messageSeqNumber, byte errorCode);
}
diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java b/services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java
index 78c10453cd95..4e1df769100b 100644
--- a/services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java
+++ b/services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java
@@ -112,9 +112,10 @@ public class ContextHubEndpointBroker extends IContextHubEndpoint.Stub
}
@Override
+ @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
public int openSession(HubEndpointInfo destination, String serviceDescriptor)
throws RemoteException {
- ContextHubServiceUtil.checkPermissions(mContext);
+ super.openSession_enforcePermission();
if (!mIsRegistered.get()) throw new IllegalStateException("Endpoint is not registered");
int sessionId = mEndpointManager.reserveSessionId();
EndpointInfo halEndpointInfo = ContextHubServiceUtil.convertHalEndpointInfo(destination);
@@ -139,8 +140,9 @@ public class ContextHubEndpointBroker extends IContextHubEndpoint.Stub
}
@Override
+ @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
public void closeSession(int sessionId, int reason) throws RemoteException {
- ContextHubServiceUtil.checkPermissions(mContext);
+ super.closeSession_enforcePermission();
if (!mIsRegistered.get()) throw new IllegalStateException("Endpoint is not registered");
try {
mContextHubProxy.closeEndpointSession(sessionId, (byte) reason);
@@ -151,8 +153,9 @@ public class ContextHubEndpointBroker extends IContextHubEndpoint.Stub
}
@Override
+ @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
public void unregister() {
- ContextHubServiceUtil.checkPermissions(mContext);
+ super.unregister_enforcePermission();
mIsRegistered.set(false);
try {
mContextHubProxy.unregisterEndpoint(mHalEndpointInfo);
@@ -174,8 +177,9 @@ public class ContextHubEndpointBroker extends IContextHubEndpoint.Stub
}
@Override
+ @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
public void openSessionRequestComplete(int sessionId) {
- ContextHubServiceUtil.checkPermissions(mContext);
+ super.openSessionRequestComplete_enforcePermission();
synchronized (mOpenSessionLock) {
try {
mContextHubProxy.endpointSessionOpenComplete(sessionId);
@@ -187,9 +191,10 @@ public class ContextHubEndpointBroker extends IContextHubEndpoint.Stub
}
@Override
+ @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
public void sendMessage(
int sessionId, HubMessage message, IContextHubTransactionCallback callback) {
- ContextHubServiceUtil.checkPermissions(mContext);
+ super.sendMessage_enforcePermission();
Message halMessage = ContextHubServiceUtil.createHalMessage(message);
synchronized (mOpenSessionLock) {
if (!mActiveSessionIds.contains(sessionId)
@@ -227,8 +232,9 @@ public class ContextHubEndpointBroker extends IContextHubEndpoint.Stub
}
@Override
+ @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
public void sendMessageDeliveryStatus(int sessionId, int messageSeqNumber, byte errorCode) {
- ContextHubServiceUtil.checkPermissions(mContext);
+ super.sendMessageDeliveryStatus_enforcePermission();
MessageDeliveryStatus status = new MessageDeliveryStatus();
status.messageSequenceNumber = messageSeqNumber;
status.errorCode = errorCode;