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.test.services
18 
19 import android.graphics.Bitmap
20 import android.net.Uri
21 import android.telecom.PhoneAccountHandle
22 import androidx.core.telecom.extensions.KickParticipantAction
23 import androidx.core.telecom.extensions.LocalCallSilenceExtensionRemote
24 import androidx.core.telecom.extensions.Participant
25 import androidx.core.telecom.extensions.RaiseHandAction
26 import androidx.core.telecom.test.ui.calling.CallStateTransition
27 import androidx.core.telecom.util.ExperimentalAppActions
28 
29 enum class CallState {
30     INCOMING,
31     DIALING,
32     ACTIVE,
33     HELD,
34     DISCONNECTING,
35     DISCONNECTED,
36     UNKNOWN
37 }
38 
39 enum class Direction {
40     INCOMING,
41     OUTGOING
42 }
43 
44 enum class AudioRoute {
45     UNKNOWN,
46     EARPIECE,
47     SPEAKER,
48     BLUETOOTH,
49     HEADSET,
50     STREAMING
51 }
52 
53 enum class CallType {
54     AUDIO,
55     VIDEO
56 }
57 
58 enum class Capability {
59     SUPPORTS_HOLD
60 }
61 
62 /** Base relevant call data */
63 data class BaseCallData(
64     val id: Int,
65     val phoneAccountHandle: PhoneAccountHandle,
66     val name: String,
67     val contactName: String?,
68     val contactUri: Uri?,
69     val number: Uri,
70     val state: CallState,
71     val direction: Direction,
72     val callType: CallType,
73     val capabilities: List<Capability>,
74     val onStateChanged: (transition: CallStateTransition) -> Unit
75 )
76 
77 /** Represents a call endpoint from the application's perspective */
78 data class CallAudioEndpoint(
79     val id: String,
80     val audioRoute: AudioRoute,
81     val frameworkName: String? = null
82 )
83 
84 /** data related to the extensions to the call */
85 @OptIn(ExperimentalAppActions::class)
86 data class ParticipantExtensionData(
87     val isSupported: Boolean,
88     val activeParticipant: Participant?,
89     val selfParticipant: Participant?,
90     val participants: Set<Participant>,
91     val raiseHandData: RaiseHandData? = null,
92     val kickParticipantData: KickParticipantData? = null
93 )
94 
95 @OptIn(ExperimentalAppActions::class)
96 data class LocalCallSilenceData(
97     val isLocallySilenced: Boolean,
98     val onInCallServiceUiUpdate: (Boolean) -> Unit,
99     val extension: LocalCallSilenceExtensionRemote?
100 )
101 
102 /** data related to the call icon extension */
103 data class CallIconData(val callIconUri: Bitmap)
104 
105 /** data related to the Meeting Summary extension */
106 data class MeetingSummaryData(val activeSpeaker: String, val participantCount: Int)
107 
108 @OptIn(ExperimentalAppActions::class)
109 data class RaiseHandData(val raisedHands: List<Participant>, val raiseHandAction: RaiseHandAction)
110 
111 @OptIn(ExperimentalAppActions::class)
112 data class KickParticipantData(val kickParticipantAction: KickParticipantAction)
113 
114 /** Combined call data including extensions. */
115 data class CallData(
116     val callData: BaseCallData,
117     val meetingSummaryData: MeetingSummaryData,
118     val participantExtensionData: ParticipantExtensionData?,
119     val localSilenceData: LocalCallSilenceData?,
120     val callIconData: CallIconData?
121 )
122