Merge changes from topic "serializablelambda" into main
* changes: Revert "Force CtsNetTestCases to compile with Kotlin 1.9" Annotate lambdas capturing newer-framework classes
This commit is contained in:
commit
544df81acf
2 changed files with 20 additions and 11 deletions
|
|
@ -24,9 +24,6 @@ java_defaults {
|
|||
"framework-connectivity-test-defaults",
|
||||
],
|
||||
|
||||
// TODO(b/391766151): remove when NetworkAgentTest passes with Kotlin 2.
|
||||
kotlin_lang_version: "1.9",
|
||||
|
||||
// Include both the 32 and 64 bit versions
|
||||
compile_multilib: "both",
|
||||
|
||||
|
|
|
|||
|
|
@ -722,9 +722,15 @@ class NetworkAgentTest {
|
|||
|
||||
val cv = ConditionVariable()
|
||||
val cpb = PrivilegeWaiterCallback(cv)
|
||||
tryTest {
|
||||
// The lambda below is capturing |cpb|, whose type inherits from a class that appeared in
|
||||
// T. This means the lambda will compile as a private method of this class taking a
|
||||
// PrivilegeWaiterCallback argument. As JUnit uses reflection to enumerate all methods
|
||||
// including private methods, this would fail with a link error when running on S-.
|
||||
// To solve this, make the lambda serializable, which causes the compiler to emit a
|
||||
// synthetic class instead of a synthetic method.
|
||||
tryTest @JvmSerializableLambda {
|
||||
val slotIndex = SubscriptionManager.getSlotIndex(subId)!!
|
||||
runAsShell(READ_PRIVILEGED_PHONE_STATE) {
|
||||
runAsShell(READ_PRIVILEGED_PHONE_STATE) @JvmSerializableLambda {
|
||||
tm.registerCarrierPrivilegesCallback(slotIndex, { it.run() }, cpb)
|
||||
}
|
||||
// Wait for the callback to be registered
|
||||
|
|
@ -747,8 +753,8 @@ class NetworkAgentTest {
|
|||
carrierConfigRule.cleanUpNow()
|
||||
}
|
||||
assertTrue(cv.block(DEFAULT_TIMEOUT_MS), "Can't change carrier privilege")
|
||||
} cleanup {
|
||||
runAsShell(READ_PRIVILEGED_PHONE_STATE) {
|
||||
} cleanup @JvmSerializableLambda {
|
||||
runAsShell(READ_PRIVILEGED_PHONE_STATE) @JvmSerializableLambda {
|
||||
tm.unregisterCarrierPrivilegesCallback(cpb)
|
||||
}
|
||||
}
|
||||
|
|
@ -762,9 +768,15 @@ class NetworkAgentTest {
|
|||
|
||||
val cv = ConditionVariable()
|
||||
val cpb = CarrierServiceChangedWaiterCallback(cv)
|
||||
tryTest {
|
||||
// The lambda below is capturing |cpb|, whose type inherits from a class that appeared in
|
||||
// T. This means the lambda will compile as a private method of this class taking a
|
||||
// PrivilegeWaiterCallback argument. As JUnit uses reflection to enumerate all methods
|
||||
// including private methods, this would fail with a link error when running on S-.
|
||||
// To solve this, make the lambda serializable, which causes the compiler to emit a
|
||||
// synthetic class instead of a synthetic method.
|
||||
tryTest @JvmSerializableLambda {
|
||||
val slotIndex = SubscriptionManager.getSlotIndex(subId)!!
|
||||
runAsShell(READ_PRIVILEGED_PHONE_STATE) {
|
||||
runAsShell(READ_PRIVILEGED_PHONE_STATE) @JvmSerializableLambda {
|
||||
tm.registerCarrierPrivilegesCallback(slotIndex, { it.run() }, cpb)
|
||||
}
|
||||
// Wait for the callback to be registered
|
||||
|
|
@ -786,8 +798,8 @@ class NetworkAgentTest {
|
|||
}
|
||||
}
|
||||
assertTrue(cv.block(DEFAULT_TIMEOUT_MS), "Can't modify carrier service package")
|
||||
} cleanup {
|
||||
runAsShell(READ_PRIVILEGED_PHONE_STATE) {
|
||||
} cleanup @JvmSerializableLambda {
|
||||
runAsShell(READ_PRIVILEGED_PHONE_STATE) @JvmSerializableLambda {
|
||||
tm.unregisterCarrierPrivilegesCallback(cpb)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue