1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.hardware.contexthub; 18 19 import android.annotation.FlaggedApi; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.annotation.SystemApi; 23 import android.chre.flags.Flags; 24 25 /** 26 * Interface for listening to lifecycle events of a hub endpoint. 27 * 28 * @hide 29 */ 30 @SystemApi 31 @FlaggedApi(Flags.FLAG_OFFLOAD_API) 32 public interface HubEndpointLifecycleCallback { 33 /** 34 * Called when an endpoint is requesting a session be opened with another endpoint. 35 * 36 * @param requester The {@link HubEndpointInfo} object representing the requester 37 * @param serviceDescriptor A string describing the service associated with this session. Null 38 * indicates that there is no service associated with this session. 39 */ 40 @NonNull onSessionOpenRequest( @onNull HubEndpointInfo requester, @Nullable String serviceDescriptor)41 HubEndpointSessionResult onSessionOpenRequest( 42 @NonNull HubEndpointInfo requester, @Nullable String serviceDescriptor); 43 44 /** 45 * Called when a communication session is opened and ready to be used. 46 * 47 * @param session The {@link HubEndpointSession} object that can be used for communication 48 */ onSessionOpened(@onNull HubEndpointSession session)49 void onSessionOpened(@NonNull HubEndpointSession session); 50 51 /** 52 * Called when a communication session is requested to be closed, or the peer endpoint rejected 53 * the session open request. 54 * 55 * @param session The {@link HubEndpointSession} object that is now closed and shouldn't be 56 * used. 57 * @param reason The reason why this session was closed. 58 */ onSessionClosed(@onNull HubEndpointSession session, @HubEndpoint.Reason int reason)59 void onSessionClosed(@NonNull HubEndpointSession session, @HubEndpoint.Reason int reason); 60 } 61