@@ -29,6 +29,7 @@ import androidx.core.telecom.extensions.addParticipantsSupport
29
29
import androidx.core.telecom.internal.CallCompat
30
30
import androidx.core.telecom.internal.InCallServiceCompat
31
31
import androidx.core.telecom.test.utils.TestUtils.printParticipants
32
+ import androidx.core.telecom.util.ExperimentalAppActions
32
33
import androidx.test.core.app.ActivityScenario.launch
33
34
import java.util.Collections
34
35
import kotlinx.coroutines.CoroutineScope
@@ -45,6 +46,7 @@ import kotlinx.coroutines.withTimeout
45
46
@RequiresApi(Build .VERSION_CODES .O )
46
47
internal class MockInCallServiceDelegate : Service () {
47
48
49
+ @OptIn(ExperimentalAppActions ::class )
48
50
class InCallServiceWoExtensions (context : Context ) : InCallService() {
49
51
init {
50
52
// Icky hack, but since we are using a delegate, we need to attach the Context manually.
@@ -60,12 +62,14 @@ internal class MockInCallServiceDelegate : Service() {
60
62
mCalls.add(callCompat)
61
63
}
62
64
}
65
+
63
66
override fun onCallRemoved (call : Call ) {
64
67
Log .i(LOG_TAG , String .format(" ICS.onCallRemoved: call=[%s]" , call))
65
68
mCalls.removeIf { c -> c.toCall() == call }
66
69
}
67
70
}
68
71
72
+ @ExperimentalAppActions
69
73
class InCallServiceWExtensions (context : Context ) : InCallServiceCompat() {
70
74
init {
71
75
// Icky hack, but since we are using a delegate, we need to attach the Context manually.
@@ -98,11 +102,13 @@ internal class MockInCallServiceDelegate : Service() {
98
102
99
103
companion object {
100
104
const val LOG_TAG = " MockInCallServiceDelegate"
105
+ @OptIn(ExperimentalAppActions ::class )
101
106
val mCalls = Collections .synchronizedList(ArrayList <CallCompat >())
102
107
var mIsServiceBound = false
103
108
var mInCallServiceType: InCallServiceType = InCallServiceType .ICS_WITHOUT_EXTENSIONS
104
109
val mServiceFlow = MutableStateFlow <InCallService ?>(null )
105
110
111
+ @OptIn(ExperimentalAppActions ::class )
106
112
@Suppress(" deprecation" )
107
113
suspend fun destroyAllCalls () {
108
114
Log .i(LOG_TAG , " destroyAllCalls: Calls.size=[${mCalls.size} ]" )
@@ -128,6 +134,7 @@ internal class MockInCallServiceDelegate : Service() {
128
134
}
129
135
}
130
136
137
+ @ExperimentalAppActions
131
138
fun getLastCall (): CallCompat ? {
132
139
return if (mCalls.size == 0 ) {
133
140
null
@@ -136,6 +143,7 @@ internal class MockInCallServiceDelegate : Service() {
136
143
}
137
144
}
138
145
146
+ @OptIn(ExperimentalAppActions ::class )
139
147
fun getCallCount (): Int {
140
148
return mCalls.size
141
149
}
@@ -147,12 +155,14 @@ internal class MockInCallServiceDelegate : Service() {
147
155
fun getService (): InCallService ? {
148
156
return mServiceFlow.value
149
157
}
158
+ @ExperimentalAppActions
150
159
fun getServiceWithExtensions (): InCallServiceCompat ? {
151
160
if (getService() !is InCallServiceCompat ) return null
152
161
return getService() as InCallServiceCompat
153
162
}
154
163
}
155
164
165
+ @OptIn(ExperimentalAppActions ::class )
156
166
override fun onCreate () {
157
167
Log .i(LOG_TAG , " Delegate service onCreate" )
158
168
mServiceFlow.tryEmit(when (mInCallServiceType) {
0 commit comments