1 /* 2 * Copyright (C) 2020 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.telephony.ims.stub; 18 19 import android.annotation.NonNull; 20 import android.annotation.SystemApi; 21 import android.telephony.ims.DelegateMessageCallback; 22 import android.telephony.ims.DelegateRegistrationState; 23 import android.telephony.ims.ImsService; 24 import android.telephony.ims.SipDelegateConfiguration; 25 import android.telephony.ims.SipDelegateConnection; 26 import android.telephony.ims.SipDelegateManager; 27 import android.telephony.ims.SipMessage; 28 29 /** 30 * The {@link SipDelegate} is implemented by the {@link ImsService} and allows a privileged 31 * IMS application to use this delegate to send SIP messages as well as acknowledge the receipt of 32 * incoming SIP messages delivered to the application over the existing IMS registration, allowing 33 * for a single IMS registration for multiple IMS applications. 34 * <p> 35 * Once the SIP delegate is created for that application, 36 * {@link ImsRegistrationImplBase#updateSipDelegateRegistration()} will be called, indicating that 37 * the application is finished setting up SipDelegates and the existing IMS registration may be 38 * modified to include the features managed by these SipDelegates. 39 * <p> 40 * This SipDelegate will need to notify the remote application of the registration of these features 41 * as well as the associated {@link SipDelegateConfiguration} before the application can start 42 * sending/receiving SIP messages via the transport. See 43 * {@link android.telephony.ims.DelegateStateCallback} for more information. 44 * @hide 45 */ 46 @SystemApi 47 public interface SipDelegate { 48 49 /** 50 * The framework calls this method when a remote RCS application wishes to send a new outgoing 51 * SIP message. 52 * <p> 53 * Once sent, this SIP delegate should notify the remote application of the success or 54 * failure using {@link DelegateMessageCallback#onMessageSent(String)} or 55 * {@link DelegateMessageCallback#onMessageSendFailure(String, int)}. 56 * @param message The SIP message to be sent over the operator’s network. 57 * @param configVersion The SipDelegateImsConfiguration version used to construct the 58 * SipMessage. See {@link SipDelegateConfiguration} for more information. If the 59 * version specified here does not match the most recently constructed 60 * {@link SipDelegateConfiguration}, this message should fail validation checks and 61 * {@link DelegateMessageCallback#onMessageSendFailure} should be called with code 62 * {@link SipDelegateManager#MESSAGE_FAILURE_REASON_STALE_IMS_CONFIGURATION}. 63 */ sendMessage(@onNull SipMessage message, long configVersion)64 void sendMessage(@NonNull SipMessage message, long configVersion); 65 66 /** 67 * The remote IMS application has closed a SIP session and the routing resources associated 68 * with the SIP session using the provided Call-ID may now be cleaned up. 69 * <p> 70 * Typically, a SIP session will be considered closed when all associated dialogs receive a 71 * BYE request. After the session has been closed, the IMS application will call 72 * {@link SipDelegateConnection#cleanupSession(String)} to signal to the framework that 73 * resources can be released. In some cases, the framework will request that the ImsService 74 * close the session due to the open SIP session holding up an event such as applying a 75 * provisioning change or handing over to another transport type. See 76 * {@link DelegateRegistrationState}. 77 * 78 * @param callId The call-ID header value associated with the ongoing SIP Session that the 79 * framework is requesting be cleaned up. 80 */ cleanupSession(@onNull String callId)81 void cleanupSession(@NonNull String callId); 82 83 /** 84 * The remote application has received the SIP message and is processing it. 85 * @param viaTransactionId The Transaction ID found in the via header field of the 86 * previously sent {@link SipMessage}. 87 */ notifyMessageReceived(@onNull String viaTransactionId)88 void notifyMessageReceived(@NonNull String viaTransactionId); 89 90 /** 91 * The remote application has either not received the SIP message or there was an error 92 * processing it. 93 * @param viaTransactionId The Transaction ID found in the via header field of the 94 * previously sent {@link SipMessage}. 95 * @param reason The reason why the message was not correctly received. 96 */ notifyMessageReceiveError(@onNull String viaTransactionId, @SipDelegateManager.MessageFailureReason int reason)97 void notifyMessageReceiveError(@NonNull String viaTransactionId, 98 @SipDelegateManager.MessageFailureReason int reason); 99 } 100