Skip to contentSkip to conversation

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

PATCH New Dmitry Baryshkov 1 participant 1 message Jun 9

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 android-tools-conf-configs: revert deletion of the recipe

The commit 33c1e33d2303 ("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 33c1e33d2303 ("android-tools: remove android-tools 5.x from meta-oe/recipes-devtools")
---
 .../10-adbd-configfs.conf                     |  4 ++
 .../android-gadget-cleanup                    | 24 ++++++++++++
 .../android-gadget-setup                      | 38 +++++++++++++++++++
 .../android-gadget-start                      |  9 +++++
 .../android-tools-conf-configfs_1.0.bb        | 38 +++++++++++++++++++
 5 files changed, 113 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/10-adbd-configfs.conf
 create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-cleanup
 create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-setup
 create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-start
 create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs_1.0.bb
meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/10-adbd-configfs.conf new file +4 -0
new file mode 100644
index 000000000000..ddf155a907bc
@@ -0,0 +1,4 @@
+[Service]
+ExecStartPre=/usr/bin/android-gadget-setup
+ExecStartPost=/usr/bin/android-gadget-start
+ExecStopPost=/usr/bin/android-gadget-cleanup
meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-cleanup new file +24 -0
new file mode 100644
index 000000000000..f27d77df5120
@@ -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
meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-setup new file +38 -0
new file mode 100644
index 000000000000..47e4edb9beef
@@ -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
meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-start new file +9 -0
new file mode 100644
index 000000000000..76b5e29624ba
@@ -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"
meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs_1.0.bb new file +38 -0
new file mode 100644
index 000000000000..342e7fd1a56b
@@ -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"
Signature · 1 line
2.47.3