diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl index 272d76823b..c1f4df868d 100644 --- a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl +++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl @@ -46,5 +46,6 @@ interface IContextHub { void onHostEndpointConnected(in android.hardware.contexthub.HostEndpointInfo hostEndpointInfo); void onHostEndpointDisconnected(char hostEndpointId); long[] getPreloadedNanoappIds(); + void onNanSessionStateChanged(in boolean state); const int EX_CONTEXT_HUB_UNSPECIFIED = -1; } diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl index f81f7cfdee..e72ae73147 100644 --- a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl +++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl @@ -38,4 +38,6 @@ interface IContextHubCallback { void handleContextHubMessage(in android.hardware.contexthub.ContextHubMessage msg, in String[] msgContentPerms); void handleContextHubAsyncEvent(in android.hardware.contexthub.AsyncEventType evt); void handleTransactionResult(in int transactionId, in boolean success); + void handleNanSessionRequest(in boolean enable); + const int CONTEXTHUB_NAN_TRANSACTION_TIMEOUT_MS = 10000; } diff --git a/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl b/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl index 9fa67a5aa1..7f507306f3 100644 --- a/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl +++ b/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl @@ -203,6 +203,19 @@ interface IContextHub { */ long[] getPreloadedNanoappIds(); + /** + * Invoked when the state of the NAN session requested through handleNanSessionRequest() + * changes. This function may be invoked without a corresponding handleNanSessionRequest to + * indicate if a NAN session was terminated without a request due to resource limitations. + * + * If the state becomes disabled without an explicit request from the HAL, the HAL MUST + * explicitly invoke handleNanSessionRequest() at a later point in time to attempt to + * re-enable NAN. + * + * @param state True if the NAN session is currently enabled. + */ + void onNanSessionStateChanged(in boolean state); + /** * Error codes that are used as service specific errors with the AIDL return * value EX_SERVICE_SPECIFIC. diff --git a/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl b/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl index e385d48c55..cff18935c3 100644 --- a/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl +++ b/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl @@ -74,4 +74,25 @@ interface IContextHubCallback { * */ void handleTransactionResult(in int transactionId, in boolean success); + + /** + * This callback is passed by the Contexthub service to the HAL implementation to allow the HAL + * to request a WiFi NAN session is created to allow the Contexthub to be able to utilize NAN + * functionality. + * + * onNanSessionStateChanged() will be invoked asynchronously after the NAN session request has + * been completed. This must be done within CONTEXTHUB_NAN_TRANSACTION_TIMEOUT_MS. If the + * request times out, onNanSessionStateChanged() will be invoked with the state that the session + * was previously in. + * + * @param enable Whether the NAN session should be enabled or disabled depending on whether the + * Contexthub needs access to NAN. + */ + void handleNanSessionRequest(in boolean enable); + + /** + * Amount of time, in milliseconds, that a handleNanSessionRequest can be pending before the + * Contexthub service must respond. + */ + const int CONTEXTHUB_NAN_TRANSACTION_TIMEOUT_MS = 10000; }