android-tools-conf-configs: revert deletion of the recipe

The commit 33c1e33d23 ("android-tools: remove android-tools 5.x from
meta-oe/recipes-devtools") blindly dropped all recipes from the
android-tools dir. Later commits moved the android-tools recipe and
other related recipes from the SELinux dynamic layer, bumping the
version to 29.x, but somehow the author of the patches didn't notice
that the resulting set of packages doesn't work out of box on any
upstream kernels, as the default android-tools-conf setup scripts use
Android-proprietary way of setting up the USB gadget
(/sys/class/android_usb).

Bring back the android-tools-conf-configs recipe, which uses upstream
mechanism (ConfigFS) to setup the USB gadget for ADB.

Fixes: 33c1e33d23 ("android-tools: remove android-tools 5.x from meta-oe/recipes-devtools")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Dmitry Baryshkov
2026-06-09 13:15:36 +03:00
committed by Khem Raj
parent c6722579be
commit 50efc66dcb
5 changed files with 113 additions and 0 deletions
@@ -0,0 +1,4 @@
[Service]
ExecStartPre=/usr/bin/android-gadget-setup
ExecStartPost=/usr/bin/android-gadget-start
ExecStopPost=/usr/bin/android-gadget-cleanup
@@ -0,0 +1,24 @@
#!/bin/sh
[ -d /sys/kernel/config/usb_gadget ] || exit 0
cd /sys/kernel/config/usb_gadget
cd adb
echo -n "" > UDC || true
killall adbd || true
umount /dev/usb-ffs/adb
rm configs/c.1/ffs.usb0
rmdir configs/c.1/strings/0x409
rmdir configs/c.1
rmdir functions/ffs.usb0
rmdir strings/0x409
cd ..
rmdir adb
@@ -0,0 +1,38 @@
#!/bin/sh
set -e
conf="Conf 1"
manufacturer=RPB
model="Android device"
product=0xd002
serial=0123456789ABCDEF
vendor=0x18d1
if [ -r /etc/android-gadget-setup.machine ] ; then
. /etc/android-gadget-setup.machine
fi
[ -d /sys/kernel/config/usb_gadget ] || modprobe libcomposite
cd /sys/kernel/config/usb_gadget
[ -d adb ] && /usr/bin/android-gadget-cleanup || true
mkdir adb
cd adb
mkdir configs/c.1
mkdir functions/ffs.usb0
mkdir strings/0x409
mkdir configs/c.1/strings/0x409
echo -n "$vendor" > idVendor
echo -n "$product" > idProduct
echo "$serial" > strings/0x409/serialnumber
echo "$manufacturer" > strings/0x409/manufacturer
echo "$model" > strings/0x409/product
echo "$conf" > configs/c.1/strings/0x409/configuration
ln -s functions/ffs.usb0 configs/c.1
mkdir -p /dev/usb-ffs/adb
mount -t functionfs usb0 /dev/usb-ffs/adb
@@ -0,0 +1,9 @@
#!/bin/sh
set -e
sleep 10
ls /sys/class/udc/ | head -n 1 | xargs echo -n > /sys/kernel/config/usb_gadget/adb/UDC
echo "Setting UDC $(ls /sys/class/udc/ | head -n 1) for USB ADB Gadget usage"
@@ -0,0 +1,38 @@
DESCRIPTION = "Different utilities from Android - corressponding configuration files for using ConfigFS"
SECTION = "console/utils"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
S = "${UNPACKDIR}"
SRC_URI = " \
file://android-gadget-setup \
file://android-gadget-start \
file://android-gadget-cleanup \
file://10-adbd-configfs.conf \
"
PACKAGE_ARCH = "${MACHINE_ARCH}"
do_install() {
install -d ${D}${bindir}
install -m 0755 ${UNPACKDIR}/android-gadget-setup ${D}${bindir}
install -m 0755 ${UNPACKDIR}/android-gadget-start ${D}${bindir}
install -m 0755 ${UNPACKDIR}/android-gadget-cleanup ${D}${bindir}
if [ -r ${UNPACKDIR}/android-gadget-setup.machine ] ; then
install -d ${D}${sysconfdir}
install -m 0644 ${UNPACKDIR}/android-gadget-setup.machine ${D}${sysconfdir}
fi
install -d ${D}${systemd_unitdir}/system/android-tools-adbd.service.d
install -m 0644 ${UNPACKDIR}/10-adbd-configfs.conf ${D}${systemd_unitdir}/system/android-tools-adbd.service.d
}
FILES:${PN} += " \
${systemd_unitdir}/system/ \
"
PROVIDES += "android-tools-conf"
RPROVIDES:${PN} = "android-tools-conf"
BBCLASSEXTEND = "native"