Skip to content

Commit

Permalink
Merge "Use the correct @RequiresOptIn for ExperimentalAppActions" int…
Browse files Browse the repository at this point in the history
…o androidx-main
  • Loading branch information
Brad Ebinger authored and Gerrit Code Review committed May 8, 2024
2 parents c7d2a9b + 55d5ec9 commit 6a69101
Show file tree
Hide file tree
Showing 24 changed files with 61 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/core-telecom/api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ package androidx.core.telecom {

package androidx.core.telecom.util {

@SuppressCompatibility @RequiresOptIn @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface ExperimentalAppActions {
@SuppressCompatibility @kotlin.RequiresOptIn @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public @interface ExperimentalAppActions {
}

}
Expand Down
2 changes: 1 addition & 1 deletion core/core-telecom/api/restricted_current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ package androidx.core.telecom {

package androidx.core.telecom.util {

@SuppressCompatibility @RequiresOptIn @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface ExperimentalAppActions {
@SuppressCompatibility @kotlin.RequiresOptIn @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public @interface ExperimentalAppActions {
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.core.telecom.internal.InCallServiceCompat
import androidx.core.telecom.internal.utils.Utils
import androidx.core.telecom.test.utils.BaseTelecomTest
import androidx.core.telecom.test.utils.TestUtils
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
Expand Down Expand Up @@ -67,6 +68,7 @@ import org.junit.runner.RunWith
*/
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.O)
@OptIn(ExperimentalAppActions::class)
@RunWith(AndroidJUnit4::class)
class CallCompatTest : BaseTelecomTest() {
private lateinit var callCompat: CallCompat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.core.telecom.extensions.voip.VoipExtensionManager
import androidx.core.telecom.internal.CallChannels
import androidx.core.telecom.internal.CallSession
import androidx.core.telecom.test.utils.BaseTelecomTest
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
import androidx.test.filters.SmallTest
Expand All @@ -43,7 +44,7 @@ import org.junit.runner.RunWith
* [androidx.core.telecom.internal.CallSession] object.
*/
@SdkSuppress(minSdkVersion = VERSION_CODES.UPSIDE_DOWN_CAKE /* api=34 */)
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class, ExperimentalAppActions::class)
@RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE)
@RunWith(AndroidJUnit4::class)
class CallSessionTest : BaseTelecomTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.core.telecom.test.utils.BaseTelecomTest
import androidx.core.telecom.test.utils.MockInCallServiceDelegate
import androidx.core.telecom.test.utils.TestUtils
import androidx.core.telecom.test.utils.TestUtils.waitOnInCallServiceToReachXCallCompats
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
Expand Down Expand Up @@ -59,6 +60,7 @@ import org.junit.runner.RunWith
*/
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.O)
@OptIn(ExperimentalAppActions::class)
@RunWith(AndroidJUnit4::class)
class E2ECallExtensionExtrasTests : BaseTelecomTest() {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.core.telecom.test.utils.BaseTelecomTest
import androidx.core.telecom.test.utils.InCallServiceType
import androidx.core.telecom.test.utils.MockInCallServiceDelegate
import androidx.core.telecom.test.utils.TestUtils
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
import androidx.test.platform.app.InstrumentationRegistry
Expand All @@ -44,6 +45,7 @@ import org.junit.Rule
import org.junit.Test

@RequiresApi(Build.VERSION_CODES.O)
@ExperimentalAppActions
class E2ECapabilityExchangeTests : BaseTelecomTest() {
@get:Rule val serviceRule: ServiceTestRule = ServiceTestRule()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.core.telecom.extensions.ICallDetailsListener
import androidx.core.telecom.extensions.ICapabilityExchange
import androidx.core.telecom.extensions.ICapabilityExchangeListener
import androidx.core.telecom.extensions.IParticipantStateListener
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import org.junit.Assert.assertEquals
Expand All @@ -33,6 +34,7 @@ import org.junit.runner.RunWith
* Not very useful for now, but tests the visibility of the AIDL files and ensures that they can
* be used as described.
*/
@OptIn(ExperimentalAppActions::class)
@RunWith(AndroidJUnit4::class)
class ExtensionAidlTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.core.telecom.test.utils.BaseTelecomTest
import androidx.core.telecom.test.utils.InCallServiceType
import androidx.core.telecom.test.utils.MockInCallServiceDelegate
import androidx.core.telecom.test.utils.TestUtils
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
Expand All @@ -53,6 +54,7 @@ import org.junit.runner.RunWith
*/
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.O)
@OptIn(ExperimentalAppActions::class)
@RunWith(AndroidJUnit4::class)
class InCallServiceCompatTest : BaseTelecomTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.core.telecom.test.utils.BaseTelecomTest
import androidx.core.telecom.test.utils.TestUtils
import androidx.core.telecom.test.utils.TestUtils.TEST_CALL_ATTRIB_NAME
import androidx.core.telecom.test.utils.TestUtils.TEST_PHONE_NUMBER_9001
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
import androidx.test.filters.SmallTest
Expand All @@ -45,6 +46,7 @@ import org.junit.runner.RunWith

@SdkSuppress(minSdkVersion = VERSION_CODES.O /* api=26 */)
@RequiresApi(VERSION_CODES.O)
@OptIn(ExperimentalAppActions::class)
@RunWith(AndroidJUnit4::class)
class JetpackConnectionServiceTest : BaseTelecomTest() {
private val callChannels = CallChannels()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.core.telecom.extensions.Capability
import androidx.core.telecom.extensions.Participant
import androidx.core.telecom.test.ITestAppControl
import androidx.core.telecom.test.utils.TestUtils
import androidx.core.telecom.util.ExperimentalAppActions
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand All @@ -40,7 +41,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking

@OptIn(ExperimentalCoroutinesApi::class)
@OptIn(ExperimentalCoroutinesApi::class, ExperimentalAppActions::class)
@RequiresApi(Build.VERSION_CODES.O)
class VoipAppWithExtensionsControl : Service() {
var mCallsManager: CallsManager? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.core.telecom.extensions.voip.raisedHandParticipants
import androidx.core.telecom.internal.utils.Utils
import androidx.core.telecom.test.utils.BaseTelecomTest
import androidx.core.telecom.test.utils.TestUtils
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import androidx.test.filters.SdkSuppress
Expand All @@ -47,6 +48,7 @@ import org.junit.runner.RunWith

@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.O)
@OptIn(ExperimentalAppActions::class)
@RunWith(AndroidJUnit4::class)
class VoipExtensionRegistrationTest : BaseTelecomTest() {
private lateinit var extensionRegistrationMap: Map<Int, (CallControlScope) -> Unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.core.telecom.CallControlScope
import androidx.core.telecom.CallsManager
import androidx.core.telecom.internal.JetpackConnectionService
import androidx.core.telecom.internal.utils.Utils
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.core.app.ApplicationProvider
import androidx.test.filters.SdkSuppress
import androidx.testutils.TestExecutor
Expand Down Expand Up @@ -129,6 +130,7 @@ abstract class BaseTelecomTest {
return mContext.packageManager.hasSystemFeature(PackageManager.FEATURE_TELECOM)
}

@OptIn(ExperimentalAppActions::class)
private suspend fun maybeCleanupStuckCalls() {
JetpackConnectionService.mPendingConnectionRequests.clear()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.core.telecom.extensions.addParticipantsSupport
import androidx.core.telecom.internal.CallCompat
import androidx.core.telecom.internal.InCallServiceCompat
import androidx.core.telecom.test.utils.TestUtils.printParticipants
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.core.app.ActivityScenario.launch
import java.util.Collections
import kotlinx.coroutines.CoroutineScope
Expand All @@ -45,6 +46,7 @@ import kotlinx.coroutines.withTimeout
@RequiresApi(Build.VERSION_CODES.O)
internal class MockInCallServiceDelegate : Service() {

@OptIn(ExperimentalAppActions::class)
class InCallServiceWoExtensions(context: Context) : InCallService() {
init {
// Icky hack, but since we are using a delegate, we need to attach the Context manually.
Expand All @@ -60,12 +62,14 @@ internal class MockInCallServiceDelegate : Service() {
mCalls.add(callCompat)
}
}

override fun onCallRemoved(call: Call) {
Log.i(LOG_TAG, String.format("ICS.onCallRemoved: call=[%s]", call))
mCalls.removeIf { c -> c.toCall() == call }
}
}

@ExperimentalAppActions
class InCallServiceWExtensions(context: Context) : InCallServiceCompat() {
init {
// Icky hack, but since we are using a delegate, we need to attach the Context manually.
Expand Down Expand Up @@ -98,11 +102,13 @@ internal class MockInCallServiceDelegate : Service() {

companion object {
const val LOG_TAG = "MockInCallServiceDelegate"
@OptIn(ExperimentalAppActions::class)
val mCalls = Collections.synchronizedList(ArrayList<CallCompat>())
var mIsServiceBound = false
var mInCallServiceType: InCallServiceType = InCallServiceType.ICS_WITHOUT_EXTENSIONS
val mServiceFlow = MutableStateFlow<InCallService?>(null)

@OptIn(ExperimentalAppActions::class)
@Suppress("deprecation")
suspend fun destroyAllCalls() {
Log.i(LOG_TAG, "destroyAllCalls: Calls.size=[${mCalls.size}]")
Expand All @@ -128,6 +134,7 @@ internal class MockInCallServiceDelegate : Service() {
}
}

@ExperimentalAppActions
fun getLastCall(): CallCompat? {
return if (mCalls.size == 0) {
null
Expand All @@ -136,6 +143,7 @@ internal class MockInCallServiceDelegate : Service() {
}
}

@OptIn(ExperimentalAppActions::class)
fun getCallCount(): Int {
return mCalls.size
}
Expand All @@ -147,12 +155,14 @@ internal class MockInCallServiceDelegate : Service() {
fun getService(): InCallService? {
return mServiceFlow.value
}
@ExperimentalAppActions
fun getServiceWithExtensions(): InCallServiceCompat? {
if (getService() !is InCallServiceCompat) return null
return getService() as InCallServiceCompat
}
}

@OptIn(ExperimentalAppActions::class)
override fun onCreate() {
Log.i(LOG_TAG, "Delegate service onCreate")
mServiceFlow.tryEmit(when (mInCallServiceType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import androidx.core.telecom.CallsManager
import androidx.core.telecom.extensions.Participant
import androidx.core.telecom.internal.CallCompat
import androidx.core.telecom.internal.utils.BuildVersionAdapter
import androidx.core.telecom.util.ExperimentalAppActions
import androidx.test.platform.app.InstrumentationRegistry
import java.io.FileInputStream
import kotlinx.coroutines.TimeoutCancellationException
Expand Down Expand Up @@ -273,6 +274,7 @@ object TestUtils {
Log.i(LOG_TAG, "defaultDialer=[${getDefaultDialer()}]")
}

@OptIn(ExperimentalAppActions::class)
@Suppress("deprecation")
suspend fun waitOnInCallServiceToReachXCalls(targetCallCount: Int): Call? {
var targetCall: Call?
Expand Down Expand Up @@ -325,6 +327,7 @@ object TestUtils {
}
}

@OptIn(ExperimentalAppActions::class)
internal suspend fun waitOnInCallServiceToReachXCallCompats(targetCallCompatCount: Int):
CallCompat? {
var targetCallCompat: CallCompat? = null
Expand Down Expand Up @@ -394,6 +397,7 @@ object TestUtils {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
}

@ExperimentalAppActions
fun getDefaultParticipant(): Participant {
val p = Participant()
p.id = 123
Expand All @@ -409,6 +413,7 @@ object TestUtils {
)
}

@ExperimentalAppActions
fun printParticipants(participants: Set<Participant>, tag: String) {
Log.i(LOG_TAG, tag + ": printParticipants: set size=${participants.size}")
for (v in participants) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ import androidx.core.telecom.internal.CallSessionLegacy
import androidx.core.telecom.internal.JetpackConnectionService
import androidx.core.telecom.internal.utils.Utils
import androidx.core.telecom.internal.utils.Utils.Companion.remapJetpackCapsToPlatformCaps
import androidx.core.telecom.util.ExperimentalAppActions
import java.util.UUID
import java.util.concurrent.CancellationException
import java.util.concurrent.Executor
import kotlin.coroutines.coroutineContext
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.job
import kotlinx.coroutines.withTimeout
Expand Down Expand Up @@ -71,6 +73,7 @@ class CallsManager constructor(context: Context) {
// A single declared constant for a direct [Executor], since the coroutines primitives we invoke
// from the associated callbacks will perform their own dispatch as needed.
private val mDirectExecutor = Executor { it.run() }
@ExperimentalAppActions
// Capabilities to be set by the VOIP app which will be used in addCall.
private var mCapabilities: MutableList<androidx.core.telecom.extensions.Capability> =
mutableListOf()
Expand Down Expand Up @@ -295,7 +298,7 @@ class CallsManager constructor(context: Context) {
* @throws CancellationException if the call failed to be added within 5000 milliseconds
*/
@RequiresPermission(value = "android.permission.MANAGE_OWN_CALLS")
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
@OptIn(ExperimentalCoroutinesApi::class, ExperimentalAppActions::class)
@Suppress("ClassVerificationFailure")
suspend fun addCall(
callAttributes: CallAttributesCompat,
Expand Down Expand Up @@ -435,6 +438,7 @@ class CallsManager constructor(context: Context) {
mCapabilities.clear()
}

@ExperimentalAppActions
private suspend fun pauseExecutionUntilCallIsReady_orTimeout(
openResult: CompletableDeferred<*>,
request: JetpackConnectionService.PendingConnectionRequest? = null
Expand Down Expand Up @@ -482,6 +486,7 @@ class CallsManager constructor(context: Context) {
return mPhoneAccount
}

@ExperimentalAppActions
internal fun setVoipCapabilities(
capabilities: List<androidx.core.telecom.extensions.Capability>
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ internal fun CallCompat.addParticipantsSupport(
}

// Allows the InCallService implementer to inspect state and perform requests to update state
@ExperimentalAppActions
internal interface ParticipantClientActions {
val negotiatedActions: Set<Int>
val isParticipantExtensionSupported: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ import androidx.core.telecom.CallsManager
import androidx.core.telecom.extensions.Capability
import androidx.core.telecom.extensions.ICapabilityExchange
import androidx.core.telecom.internal.CallChannels
import androidx.core.telecom.util.ExperimentalAppActions
import kotlin.coroutines.CoroutineContext

@RequiresApi(Build.VERSION_CODES.O)
@androidx.annotation.OptIn(androidx.core.telecom.util.ExperimentalAppActions::class)
@ExperimentalAppActions
internal class VoipExtensionManager(
private val context: Context,
private val coroutineContext: CoroutineContext?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,20 +321,18 @@ internal class VoipParticipantExtensionManager(
* be translated to backing fields so, internally, we need to resolve the APIs for each
* CallControlScope using a delegate to mimic this behavior.
*/
@ExperimentalAppActions
internal val CallControlScope.activeParticipant: MutableStateFlow<Participant?>?
@ExperimentalAppActions
@RequiresApi(Build.VERSION_CODES.O)
get() = CallControlScopeExtensionSingleton.getInstance()
.PARTICIPANT_DELEGATE[getCallId()]?.activeParticipantFlow

@ExperimentalAppActions
internal val CallControlScope.participants: MutableStateFlow<Set<Participant>>?
@ExperimentalAppActions
@RequiresApi(Build.VERSION_CODES.O)
get() = CallControlScopeExtensionSingleton.getInstance()
.PARTICIPANT_DELEGATE[getCallId()]?.participantsFlow

@ExperimentalAppActions
internal val CallControlScope.raisedHandParticipants: MutableStateFlow<Set<Participant>>?
@ExperimentalAppActions
@RequiresApi(Build.VERSION_CODES.O)
get() = CallControlScopeExtensionSingleton.getInstance()
.PARTICIPANT_DELEGATE[getCallId()]?.raisedHandParticipantsFlow
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ package androidx.core.telecom.internal

import androidx.core.telecom.CallEndpointCompat
import androidx.core.telecom.extensions.voip.VoipParticipantActionRequest
import androidx.core.telecom.util.ExperimentalAppActions
import kotlinx.coroutines.channels.Channel

@OptIn(ExperimentalAppActions::class)
internal class CallChannels(
val currentEndpointChannel: Channel<CallEndpointCompat> = Channel(Channel.UNLIMITED),
val availableEndpointChannel: Channel<List<CallEndpointCompat>> = Channel(Channel.UNLIMITED),
Expand Down
Loading

0 comments on commit 6a69101

Please sign in to comment.