Loading core/java/android/hardware/contexthub/IContextHubEndpoint.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -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); /** Loading @@ -49,6 +50,7 @@ interface IContextHubEndpoint { * * @throws IllegalStateException If the session wasn't opened. */ @EnforcePermission("ACCESS_CONTEXT_HUB") void closeSession(int sessionId, int reason); /** Loading @@ -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(); /** Loading @@ -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); Loading @@ -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); } services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java +12 −6 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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) Loading Loading @@ -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; Loading Loading
core/java/android/hardware/contexthub/IContextHubEndpoint.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -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); /** Loading @@ -49,6 +50,7 @@ interface IContextHubEndpoint { * * @throws IllegalStateException If the session wasn't opened. */ @EnforcePermission("ACCESS_CONTEXT_HUB") void closeSession(int sessionId, int reason); /** Loading @@ -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(); /** Loading @@ -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); Loading @@ -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); }
services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java +12 −6 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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) Loading Loading @@ -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; Loading