Modern Apps git

← Modern-Apps.git

library/aosp-stubs: EuiccService's OTA callback is an abstract class, not an interface

Commit
ece3c54397eaceb9b67f8fbfaa9e3572b062427a
Author
Vayun Mathur <[email protected]>
When
2026-12-01 10:29 UTC (4 days ago)
Parents
8c96675
The stub declared OtaStatusChangedCallback as an interface,
but in AOSP it is an abstract class. A stub is a compile-time
promise about the runtime class: consumers compiled against
the interface emit invokeinterface where the real framework
class requires invokevirtual — linkage breaks at the call
site on device. Every consumer call site links with the
wrong invocation instruction.

The stub now declares a public abstract static class with
the abstract callback, with the hazard noted in a comment.
New shape test pins non-interface + abstract kind and
subclass dispatch (failed pre-fix at the isInterface check);
the only caller, :euicc, compiles unchanged against the
corrected stub. Stubs remain compileOnly and unpackaged.
locationprovider's provider/geocoder contract was audited
against its consumers and cleared. Verified:
:library:aosp-stubs:testDebugUnitTest passes, lint no
issues; :euicc:compileDevKotlin passes.

Diff

library/aosp-stubs/src/main/java/android/service/euicc/EuiccService.java
diff --git a/library/aosp-stubs/src/main/java/android/service/euicc/EuiccService.java b/library/aosp-stubs/src/main/java/android/service/euicc/EuiccService.javaindex 2be6d35080..9a79741bbc 100644--- a/library/aosp-stubs/src/main/java/android/service/euicc/EuiccService.java+++ b/library/aosp-stubs/src/main/java/android/service/euicc/EuiccService.java@@ -20,8 +20,14 @@ public abstract class EuiccService extends Service {      public static final int OTA_STATUS_NOT_UPDATED = 1; -    public interface OtaStatusChangedCallback {-        void onOtaStatusChanged(int status);+    /**+     * An abstract class upstream, not an interface. Mirrored as one here: a stub+     * interface makes consumers emit {@code invokeinterface} for+     * {@link #onOtaStatusChanged}, which the real abstract class rejects with+     * {@code IncompatibleClassChangeError} on the OTA path.+     */+    public abstract static class OtaStatusChangedCallback {+        public abstract void onOtaStatusChanged(int status);     }      @Override
library/aosp-stubs/src/test/java/android/service/euicc/EuiccServiceStubShapeTest.kt
diff --git a/library/aosp-stubs/src/test/java/android/service/euicc/EuiccServiceStubShapeTest.kt b/library/aosp-stubs/src/test/java/android/service/euicc/EuiccServiceStubShapeTest.ktnew file mode 100644index 0000000000..baf1db90f7--- /dev/null+++ b/library/aosp-stubs/src/test/java/android/service/euicc/EuiccServiceStubShapeTest.kt@@ -0,0 +1,45 @@+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)+    }+}