1 /*
2  * Copyright 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 androidx.core.telecom.extensions
18 
19 import android.os.Build.VERSION_CODES
20 import android.telecom.DisconnectCause
21 import androidx.annotation.RequiresApi
22 import androidx.core.telecom.CallAttributesCompat
23 import androidx.core.telecom.CallsManager
24 import androidx.core.telecom.util.ExperimentalAppActions
25 
26 /**
27  * Provide the ability for [CallsManager] to support extensions on a call.
28  *
29  * Extensions allow an application to support optional features beyond the scope of call state
30  * management and audio routing. These optional features provide the application with the ability to
31  * describe additional information about the call, which allows remote surfaces (automotive,
32  * watches, etc..) to provide UX related to this additional information. Additionally, remote
33  * surfaces can perform actions using a configured extension to notify this application of a remote
34  * user request.
35  *
36  * @see ExtensionInitializationScope
37  */
38 public interface CallsManagerExtensions {
39     /**
40      * Adds a call with extensions support using [ExtensionInitializationScope], which allows an app
41      * to implement optional additional actions that go beyond the scope of a call, such as
42      * information about meeting participants and icons.
43      *
44      * @param callAttributes attributes of the new call (incoming or outgoing, address, etc. )
45      * @param onAnswer where callType is the audio/video state the call should be answered as.
46      *   Telecom is informing your VoIP application to answer an incoming call and set it to active.
47      *   Telecom is requesting this on behalf of an system service (e.g. Automotive service) or a
48      *   device (e.g. Wearable).
49      * @param onDisconnect where disconnectCause represents the cause for disconnecting the call.
50      *   Telecom is informing your VoIP application to disconnect the incoming call. Telecom is
51      *   requesting this on behalf of an system service (e.g. Automotive service) or a device (e.g.
52      *   Wearable).
53      * @param onSetActive Telecom is informing your VoIP application to set the call active. Telecom
54      *   is requesting this on behalf of an system service (e.g. Automotive service) or a device
55      *   (e.g. Wearable).
56      * @param onSetInactive Telecom is informing your VoIP application to set the call inactive.
57      *   This is the same as holding a call for two endpoints but can be extended to setting a
58      *   meeting inactive. Telecom is requesting this on behalf of an system service (e.g.
59      *   Automotive service) or a device (e.g.Wearable). Note: Your app must stop using the
60      *   microphone and playing incoming media when returning.
61      * @param init The scope used to first initialize Extensions that will be used when the call is
62      *   first notified to the platform and UX surfaces. Once the call is set up, the user's
63      *   implementation of [ExtensionInitializationScope.onCall] will be called.
64      * @see CallsManager.addCall
65      */
66     @RequiresApi(VERSION_CODES.O)
67     @ExperimentalAppActions
addCallWithExtensionsnull68     public suspend fun addCallWithExtensions(
69         callAttributes: CallAttributesCompat,
70         onAnswer: suspend (callType: @CallAttributesCompat.Companion.CallType Int) -> Unit,
71         onDisconnect: suspend (disconnectCause: DisconnectCause) -> Unit,
72         onSetActive: suspend () -> Unit,
73         onSetInactive: suspend () -> Unit,
74         init: suspend ExtensionInitializationScope.() -> Unit
75     )
76 }
77