package android.service.euicc import java.lang.reflect.Modifier import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertTrue /** * Plain-JVM (no Robolectric): Robolectric loads the framework's real * `android.service.euicc` classes from android-all, which would shadow this * module's stub. On a plain classpath the module class wins, so the stub's * shape is directly observable here (same reasoning as locationprovider's * GeocoderParamsJvmTest). * * The framework's `EuiccService.OtaStatusChangedCallback` is an abstract * class, not an interface (euicc's ServicesTest documents this from the * runtime class). A stub interface makes consumers emit `invokeinterface` * for `onOtaStatusChanged`, which the real abstract class rejects with * IncompatibleClassChangeError on the OTA path. */ class EuiccServiceStubShapeTest { @Test fun otaStatusChangedCallbackIsAbstractClassNotInterface() { val callback = EuiccService.OtaStatusChangedCallback::class.java assertFalse(callback.isInterface, "OtaStatusChangedCallback must not be an interface") assertTrue(Modifier.isAbstract(callback.modifiers), "OtaStatusChangedCallback must be abstract") val method = callback.getDeclaredMethod("onOtaStatusChanged", Int::class.javaPrimitiveType) assertTrue(Modifier.isAbstract(method.modifiers), "onOtaStatusChanged must be abstract") assertTrue(Modifier.isPublic(method.modifiers), "onOtaStatusChanged must be public") } @Test fun otaStatusChangedCallbackSubclassDispatches() { var received = -1 val callback = object : EuiccService.OtaStatusChangedCallback() { override fun onOtaStatusChanged(status: Int) { received = status } } callback.onOtaStatusChanged(EuiccService.OTA_STATUS_NOT_UPDATED) assertEquals(EuiccService.OTA_STATUS_NOT_UPDATED, received) } }