| /* | |
| * Copyright (C) 2024 The Android Open Source Project | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| * See the License for the specific language governing permissions and | |
| * limitations under the License. | |
| */ | |
| package android.hardware.contexthub; | |
| import android.hardware.contexthub.DataFlowId; | |
| import android.hardware.contexthub.DataFlowSinkRegistrationParams; | |
| import android.hardware.contexthub.EndpointId; | |
| import android.hardware.contexthub.EndpointInfo; | |
| import android.hardware.contexthub.Message; | |
| import android.hardware.contexthub.MessageDeliveryStatus; | |
| import android.hardware.contexthub.Reason; | |
| import android.hardware.contexthub.Service; | |
| @VintfStability | |
| oneway interface IEndpointCallback { | |
| /** | |
| * Lifecycle event notification for endpoint starting from remote side. There is no need to | |
| * report already started endpoint prior to the registration of an EndpointLifecycleCallbacks | |
| * object. The EndpointInfo reported here should be consistent with values from getEndpoints(). | |
| * | |
| * Endpoints added by registerEndpoint should not be included. registerEndpoint() should not | |
| * cause this call. | |
| * | |
| * @param endpointInfos An array of EndpointInfo representing endpoints that just started. | |
| */ | |
| void onEndpointStarted(in EndpointInfo[] endpointInfos); | |
| /** | |
| * Lifecycle event notification for endpoint stopping from remote side. There is no need to | |
| * report already stopped endpoint prior to the registration of an EndpointLifecycleCallbacks | |
| * object. The EndpointId reported here should represent a previously started Endpoint. | |
| * | |
| * When a hub crashes or restart, events should be batched into be a single call (containing all | |
| * the EndpointId that were impacted). | |
| * | |
| * Endpoints added by registerEndpoint should not be included. unregisterEndpoint() should not | |
| * cause this call. | |
| * | |
| * @param endpointIds An array of EndpointId representing endpoints that just stopped. | |
| * @param reason The reason for why the endpoints stopped. | |
| */ | |
| void onEndpointStopped(in EndpointId[] endpointIds, Reason reason); | |
| /** | |
| * Invoked when an endpoint sends message to another endpoint (on host) on the (currently open) | |
| * session. | |
| * | |
| * @param sessionId The integer representing the communication session, previously set in | |
| * openEndpointSession() or onEndpointSessionOpenRequest(). | |
| * @param msg The Message object representing a message from endpoint to an endpoint on host. | |
| */ | |
| void onMessageReceived(int sessionId, in Message msg); | |
| /** | |
| * Invoked when an endpoint sends the response for a message that requires delivery status. | |
| * | |
| * The response is the message delivery status of a recently sent message within a session. See | |
| * sendMessageDeliveryStatusToEndpoint() for more details. | |
| * | |
| * @param sessionId The integer representing the communication session, previously set in | |
| * openEndpointSession() or onEndpointSessionOpenRequest(). | |
| * @param msgStatus The MessageDeliveryStatus object representing the delivery status for a | |
| * specific message (identified by the sequenceNumber) within the session. | |
| */ | |
| void onMessageDeliveryStatusReceived(int sessionId, in MessageDeliveryStatus msgStatus); | |
| /** | |
| * Invoked when session initiation is requested by a remote endpoint. The receiving host client | |
| * must later call endpointSessionOpenComplete() to indicate successful connection and | |
| * acceptance of the session, or closeEndpointSession() to indicate failure. | |
| * | |
| * @param sessionId Caller-allocated session identifier, which must be unique across all active | |
| * sessions, and must not fall in a range allocated via requestSessionIdRange(). | |
| * @param destination The EndpointId representing the destination side of the session, which | |
| * must've already been published through registerEndpoint(). | |
| * @param initiator The EndpointId representing the initiating side of the session. | |
| * @param serviceDescriptor Descriptor for the service specification for scoping this session | |
| * (nullable). Null indicates a fully custom marshalling scheme. The value should match | |
| * a published descriptor for both endpoints. | |
| * | |
| * @throws EX_ILLEGAL_ARGUMENT if any of the arguments are invalid, or the combination of the | |
| * arguments is invalid. | |
| */ | |
| void onEndpointSessionOpenRequest(int sessionId, in EndpointId destination, | |
| in EndpointId initiator, in @nullable String serviceDescriptor); | |
| /** | |
| * Invoked when a session has either failed to open, or has been closed by the remote side. | |
| * Upon receiving this callback, the session is closed and further messages on it will not be | |
| * delivered. | |
| * | |
| * @param sessionId The integer representing the communication session, previously set in | |
| * openEndpointSession() or onEndpointSessionOpenRequest(). | |
| * @param reason The reason for this close endpoint session notification. | |
| */ | |
| void onCloseEndpointSession(int sessionId, in Reason reason); | |
| /** | |
| * Callback when a session is opened. This callback is the status callback for a previous | |
| * openEndpointSession(). | |
| * | |
| * @param sessionId The integer representing the communication session, previously set in | |
| * onEndpointSessionOpenRequest(). This id is assigned by the host. | |
| */ | |
| void onEndpointSessionOpenComplete(int sessionId); | |
| /** | |
| * Callback delivering a sink context for a data flow whose source is an offload endpoint. The | |
| * client (e.g. the Android framework) must check the endpoint permissions before forwarding | |
| * the context. On failure, the client must call {@code | |
| * IEndpointCommunication.unregisterDataFlowHostSink()} to clean up HAL resources. | |
| * | |
| * @param params The parameters for registering a new sink on a data flow. | |
| */ | |
| void onDataFlowHostSinkRegistered(in DataFlowSinkRegistrationParams params); | |
| /** | |
| * Callback indicating that an offload endpoint has stopped accessing a data flow. This will | |
| * only notify a host endpoint that has not unregistered the data flow yet via | |
| * IEndpointCommunication::unregisterDataFlowHostSource() or | |
| * IEndpointCommunication::unregisterDataFlowHostSink(). It will be called both in the case that | |
| * the offload endpoint crashed and when the endpoint intentionally stops accessing the data | |
| * flow. | |
| * | |
| * This callback is required to handle the case that an endpoint on the other side of the data | |
| * flow has not correctly updated metadata in the shared data region(s) and notified the host | |
| * endpoint. For a host sink, tghis is a signal that it must immediately stop accessing the | |
| * data flow. For a host source, this is a signal that it should clean up any references to | |
| * the sink endpoint. | |
| * | |
| * @param dataFlowId The id of the data flow this callback is being sent for. | |
| * @param endpointId The id of the endpoint that is no longer accessing the data flow. | |
| * @param destinationIds The ids of the endpoints that should be notified. This will only | |
| * contain a single endpoint id for a data flow whose source is a host endpoint. | |
| */ | |
| void onDataFlowOffloadEndpointUnregistered( | |
| in DataFlowId dataFlowId, in EndpointId endpointId, in EndpointId[] destinationIds); | |
| } |