Skip to content

A rootless Android app that boots Alpine Linux: run containers (Podman/Docker/LXC) and GUI desktop apps.

feat(avf): probe custom-VM builder API support

ExTva2829defeb90
diff --git a/app/src/main/java/com/excp/podroid/engine/avf/AvfDiagnostics.kt b/app/src/main/java/com/excp/podroid/engine/avf/AvfDiagnostics.kt
index e88cdef..e3b960f 100644
--- a/app/src/main/java/com/excp/podroid/engine/avf/AvfDiagnostics.kt
+++ b/app/src/main/java/com/excp/podroid/engine/avf/AvfDiagnostics.kt
@@ -30,6 +30,7 @@ data class AvfReport(
val virtApexPresent: Boolean,
val managerClassPresent: Boolean,
val serviceReachable: Boolean,
+ val customVmConfigSupported: Boolean = false,
val smokeTestResult: String?,
val capabilitiesRaw: Int = 0,
val capabilitiesDecoded: String = "n/a",
@@ -57,6 +58,9 @@ data class AvfReport(
appendLine("Service")
appendLine(" reachable via system service = $serviceReachable")
appendLine()
+ appendLine("Custom-VM API")
+ appendLine(" builder present = $customVmConfigSupported")
+ appendLine()
appendLine("Hypervisor capabilities")
appendLine(" raw = $capabilitiesRaw ($capabilitiesDecoded)")
if (smokeTestResult != null) {
@@ -102,6 +106,22 @@ object AvfDiagnostics {
}.isSuccess
}
+ /**
+ * True only if this device's AVF build exposes the custom-VM builder API
+ * Podroid drives (raw kernel + initrd). A vendor build that ships AVF for
+ * system use but omits the custom-image config will return false, so
+ * EngineHolder.pick() can fall back to QEMU at selection time instead of
+ * erroring at VM start. Never throws: a missing class is a normal "no".
+ */
+ fun customVmConfigSupported(): Boolean = runCatching {
+ val builder = Class.forName("$CLS_CUSTOM_CFG\$Builder")
+ builder.getDeclaredMethod("setKernelPath", String::class.java)
+ builder.getDeclaredMethod("setInitrdPath", String::class.java)
+ Class.forName("$CLS_CONFIG\$Builder")
+ .getDeclaredMethod("setCustomImageConfig", Class.forName(CLS_CUSTOM_CFG))
+ true
+ }.getOrDefault(false)
+
/**
* Read-only probe — never blocks, never touches the system service for
* real (just checks reachability). Safe to call from anywhere.
@@ -129,6 +149,7 @@ object AvfDiagnostics {
virtApexPresent = virtApexPresent,
managerClassPresent = managerClassPresent,
serviceReachable = serviceReachable,
+ customVmConfigSupported = customVmConfigSupported(),
smokeTestResult = null,
capabilitiesRaw = capabilitiesRaw,
capabilitiesDecoded = AvfCapabilities.decode(capabilitiesRaw),
diff --git a/app/src/test/java/com/excp/podroid/engine/avf/AvfDiagnosticsSupportTest.kt b/app/src/test/java/com/excp/podroid/engine/avf/AvfDiagnosticsSupportTest.kt
new file mode 100644
index 0000000..2747181
--- /dev/null
+++ b/app/src/test/java/com/excp/podroid/engine/avf/AvfDiagnosticsSupportTest.kt
@@ -0,0 +1,11 @@
+package com.excp.podroid.engine.avf
+
+import org.junit.Assert.assertFalse
+import org.junit.Test
+
+class AvfDiagnosticsSupportTest {
+ @Test fun `customVmConfigSupported is false when AVF classes absent`() {
+ // JVM unit test: android.system.virtualmachine.* is not on the classpath.
+ assertFalse(AvfDiagnostics.customVmConfigSupported())
+ }
+}