diff mbox series

[meta-oe] android-tools: make usbgadget optional

Message ID 20261120154818.4037066-1-ecordonnier@snap.com
State Accepted
Headers show
Series [meta-oe] android-tools: make usbgadget optional | expand

Commit Message

Etienne Cordonnier Nov. 20, 2026, 3:48 p.m. UTC
From: Etienne Cordonnier <ecordonnier@snap.com>

adbd can also be used over TCP, so USB gadget support is optional.
android-tools-conf only contains the configfs USB gadget setup (scripts and
a systemd drop-in), but android-tools depends on it unconditionally. On a
machine without a USB device controller, android-gadget-setup fails and adbd
does not start, even if it is only meant to be reached over TCP.

Add a "usbgadget" PACKAGECONFIG, and make the dependency on
android-tools-conf, and the recommendation for the gadget kernel modules,
conditional on it. The dependency moves from android-tools to
android-tools-adbd, the package the drop-in belongs to.

Enable usbgadget by default for every machine, as before. Machines without
a USB device controller can remove it from PACKAGECONFIG.

AI-Generated: Uses Claude Code
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
 .../android-tools/android-tools_35.0.2.bb             | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb b/meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb
index 045642a683..38b522084d 100644
--- a/meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb
+++ b/meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb
@@ -239,9 +239,9 @@  do_install:append:class-native() {
 }
 
 PACKAGES =+ "${PN}-adbd"
-RDEPENDS:${PN}:class-target = "android-tools-conf-configfs 7zip android-libboringssl"
-RDEPENDS:${PN}-adbd += "${PN}"
-RRECOMMENDS:${PN}-adbd += "kernel-module-libcomposite kernel-module-usb-f-fs"
+RDEPENDS:${PN}:class-target = "7zip android-libboringssl"
+RDEPENDS:${PN}-adbd += "${PN} ${@bb.utils.contains('PACKAGECONFIG', 'usbgadget', 'android-tools-conf', '', d)}"
+RRECOMMENDS:${PN}-adbd += "${@bb.utils.contains('PACKAGECONFIG', 'usbgadget', 'kernel-module-libcomposite kernel-module-usb-f-fs', '', d)}"
 PRIVATE_LIBS:${PN} = "liblog.so.0 libbase.so.0 libcutils.so.0"
 
 inherit useradd
@@ -260,9 +260,12 @@  FILES:${PN}-adbd = " \
 
 BBCLASSEXTEND = "native"
 
-PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
+PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} usbgadget"
 # Apply Android's fs_config ownership/mode tables to files pushed by adbd to
 # /system, /vendor and /oem. Off by default: the tables describe Android
 # partition images and are meaningless on a generic Linux rootfs.
 PACKAGECONFIG[fs-config] = ""
 PACKAGECONFIG[systemd] = ",,systemd"
+# adbd over a USB gadget. Machines without a USB device controller (UDC) do not need them,
+# and can use adbd over TCP.
+PACKAGECONFIG[usbgadget] = ""