summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-devtools/android-tools
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-devtools/android-tools')
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/10-adbd-configfs.conf4
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-setup38
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-start9
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs_1.0.bb38
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools-conf/10-adbd-configfs.conf7
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-cleanup (renamed from meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-cleanup)0
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup63
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-start16
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools-conf_1.0.bb36
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/0001-libbacktrace.mk-Link-against-staged-lib7z.patch38
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/0002-debian-makefiles-yocto-compat.patch240
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/0003-gcc-nullability-and-thread-annotation-compat.patch34
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/0004-fastboot-super_flash_helper-include-climits.patch41
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/0005-adb-host-usb-compat.patch34
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/0006-adbd-enable-root-and-remount-support.patch466
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/0007-libcutils-guard-Android-private-header-with-addition.patch36
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/0008-adb-GCC-compatibility-fixes-for-usb_linux-and-sysdep.patch197
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/0009-libbase-include-stdint.h-in-hex.cpp.patch26
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/0010-adbd-make-systemd-sd_notify-conditional-on-HAVE_SYSTEMD.patch54
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/adb.mk72
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/adbd.mk164
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service2
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/build/0001-Riscv-Add-risc-v-Android-config-header.patch361
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0001-adb-remove-selinux-extensions.patch44
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0001-memory.h-Always-define-strlcpy-for-glibc-based-syste.patch35
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0002-adb-Use-local-sockets-where-appropriate.patch70
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0003-adb-define-shell-command.patch29
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0004-adb-Fix-build-on-big-endian-systems.patch47
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0005-adb-add-base64-implementation.patch350
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0006-adb-Musl-fixes.patch130
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0007-adb-usb_linux.c-fix-build-with-glibc-2.28.patch26
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0008-adb-Allow-adbd-to-be-ran-as-root.patch23
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0009-mkbootimg-Add-dt-parameter-to-specify-DT-image.patch110
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0010-Use-linux-capability.h-on-linux-systems-too.patch23
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0011-Remove-bionic-specific-calls.patch64
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0012-Fix-implicit-declaration-of-stlcat-strlcopy-function.patch50
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0013-adb-Support-riscv64.patch191
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0014-add-u3-ss-descriptor-support-for-adb.patch344
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0015-libsparse-Split-off-most-of-sparse_file_read_normal-.patch60
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0016-libsparse-Add-hole-mode-to-sparse_file_read.patch188
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/0017-img2simg-Add-support-for-converting-holes-to-don-t-c.patch114
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff48
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/core/b64_pton_function_decl.patch14
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-allow-notifying-systemd.patch41
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-allow-usb-on-linux.patch28
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-don-t-require-authorization-on-Linux.patch27
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-usb-drop-property-monitor.patch57
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-dev-typos.patch16
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-Nullable.patch14
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-stdatomic.patch68
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-workaround__builtin_available.patch148
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Added-missing-headers.patch15
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Drop-gki-dependency-from-mkbootimg.patch114
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Implement-const_iterator-operator.patch37
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-add-missing-headers.patch13
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-hard-code-build-number.patch57
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-libusb-header-path.patch17
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-move-log-file-to-proper-dir.patch19
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-stub-out-fastdeploy.patch99
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-throw-exception-on-unknown-os.patch17
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-unwindstack-porting.patch14
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/ext4_utils.mk103
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/extras/0001-ext4_utils-remove-selinux-extensions.patch39
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/extras/0002-ext4_utils-add-o-argument-to-preserve-ownership.patch78
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/extras/0003-ext4_utils-drop-unused-parameter-from-allocate_inode.patch69
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/fastboot.mk89
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/gitignore59
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-Remove-bionic-specific-calls.patch25
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch51
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools/mkbootimg.mk29
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb237
-rw-r--r--meta-oe/recipes-devtools/android-tools/android-tools_5.1.1.r37.bb189
72 files changed, 2288 insertions, 3417 deletions
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/10-adbd-configfs.conf b/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/10-adbd-configfs.conf
deleted file mode 100644
index ddf155a907..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/10-adbd-configfs.conf
+++ /dev/null
@@ -1,4 +0,0 @@
1[Service]
2ExecStartPre=/usr/bin/android-gadget-setup
3ExecStartPost=/usr/bin/android-gadget-start
4ExecStopPost=/usr/bin/android-gadget-cleanup
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-setup b/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-setup
deleted file mode 100644
index 47e4edb9be..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-setup
+++ /dev/null
@@ -1,38 +0,0 @@
1#!/bin/sh
2
3set -e
4
5conf="Conf 1"
6manufacturer=RPB
7model="Android device"
8product=0xd002
9serial=0123456789ABCDEF
10vendor=0x18d1
11
12if [ -r /etc/android-gadget-setup.machine ] ; then
13 . /etc/android-gadget-setup.machine
14fi
15
16[ -d /sys/kernel/config/usb_gadget ] || modprobe libcomposite
17
18cd /sys/kernel/config/usb_gadget
19
20[ -d adb ] && /usr/bin/android-gadget-cleanup || true
21
22mkdir adb
23cd adb
24
25mkdir configs/c.1
26mkdir functions/ffs.usb0
27mkdir strings/0x409
28mkdir configs/c.1/strings/0x409
29echo -n "$vendor" > idVendor
30echo -n "$product" > idProduct
31echo "$serial" > strings/0x409/serialnumber
32echo "$manufacturer" > strings/0x409/manufacturer
33echo "$model" > strings/0x409/product
34echo "$conf" > configs/c.1/strings/0x409/configuration
35ln -s functions/ffs.usb0 configs/c.1
36
37mkdir -p /dev/usb-ffs/adb
38mount -t functionfs usb0 /dev/usb-ffs/adb
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-start b/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-start
deleted file mode 100644
index 76b5e29624..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-start
+++ /dev/null
@@ -1,9 +0,0 @@
1#!/bin/sh
2
3set -e
4
5sleep 10
6
7ls /sys/class/udc/ | head -n 1 | xargs echo -n > /sys/kernel/config/usb_gadget/adb/UDC
8
9echo "Setting UDC $(ls /sys/class/udc/ | head -n 1) for USB ADB Gadget usage"
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs_1.0.bb b/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs_1.0.bb
deleted file mode 100644
index 342e7fd1a5..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs_1.0.bb
+++ /dev/null
@@ -1,38 +0,0 @@
1DESCRIPTION = "Different utilities from Android - corressponding configuration files for using ConfigFS"
2SECTION = "console/utils"
3LICENSE = "MIT"
4LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
5
6S = "${UNPACKDIR}"
7
8SRC_URI = " \
9 file://android-gadget-setup \
10 file://android-gadget-start \
11 file://android-gadget-cleanup \
12 file://10-adbd-configfs.conf \
13"
14
15PACKAGE_ARCH = "${MACHINE_ARCH}"
16
17do_install() {
18 install -d ${D}${bindir}
19 install -m 0755 ${UNPACKDIR}/android-gadget-setup ${D}${bindir}
20 install -m 0755 ${UNPACKDIR}/android-gadget-start ${D}${bindir}
21 install -m 0755 ${UNPACKDIR}/android-gadget-cleanup ${D}${bindir}
22
23 if [ -r ${UNPACKDIR}/android-gadget-setup.machine ] ; then
24 install -d ${D}${sysconfdir}
25 install -m 0644 ${UNPACKDIR}/android-gadget-setup.machine ${D}${sysconfdir}
26 fi
27
28 install -d ${D}${systemd_unitdir}/system/android-tools-adbd.service.d
29 install -m 0644 ${UNPACKDIR}/10-adbd-configfs.conf ${D}${systemd_unitdir}/system/android-tools-adbd.service.d
30}
31
32FILES:${PN} += " \
33 ${systemd_unitdir}/system/ \
34"
35
36PROVIDES += "android-tools-conf"
37RPROVIDES:${PN} = "android-tools-conf"
38BBCLASSEXTEND = "native"
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf/10-adbd-configfs.conf b/meta-oe/recipes-devtools/android-tools/android-tools-conf/10-adbd-configfs.conf
new file mode 100644
index 0000000000..7971f319c3
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools-conf/10-adbd-configfs.conf
@@ -0,0 +1,7 @@
1[Service]
2# adbd uses sd_notify to signal readiness; ExecStartPost runs only after
3# READY=1 is sent, so no delay is needed before activating the UDC.
4Environment=ANDROID_GADGET_UDC_DELAY=0
5ExecStartPre=/usr/bin/android-gadget-setup
6ExecStartPost=/usr/bin/android-gadget-start
7ExecStopPost=/usr/bin/android-gadget-cleanup
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-cleanup b/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-cleanup
index f27d77df51..f27d77df51 100644
--- a/meta-oe/recipes-devtools/android-tools/android-tools-conf-configfs/android-gadget-cleanup
+++ b/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-cleanup
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup b/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup
index 26cf30eddd..2744d1e98e 100644
--- a/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup
+++ b/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup
@@ -1,37 +1,40 @@
1#!/bin/sh 1#!/bin/sh
2 2
3[ ! -e /dev/pts ] && mkdir -p /dev/pts 3set -e
4[ ! -e /dev/pts/0 ] && mount devpts /dev/pts -t devpts 4
5 5conf="Conf 1"
6# TODO enable the lines below once we have support for getprop 6manufacturer=RPB
7# retrieve the product info from Android 7model="Android device"
8# manufacturer=$(getprop ro.product.manufacturer Android) 8product=0xd002
9# model=$(getprop ro.product.model Android) 9serial=0123456789ABCDEF
10# serial=$(getprop ro.serialno 0123456789ABCDEF) 10vendor=0x18d1
11 11
12#below are now needed in order to use FunctionFS for ADB, tested to work with 3.4+ kernels 12if [ -r /etc/android-gadget-setup.machine ] ; then
13if grep -q functionfs /proc/filesystems; then 13 . /etc/android-gadget-setup.machine
14 mkdir -p /dev/usb-ffs/adb
15 mount -t functionfs adb /dev/usb-ffs/adb
16 #android-gadget-setup doesn't provide below 2 and without them it won't work, so we provide them here.
17 echo adb > /sys/class/android_usb/android0/f_ffs/aliases
18 echo ffs > /sys/class/android_usb/android0/functions
19fi 14fi
20 15
21manufacturer="$(cat /system/build.prop | grep -o 'ro.product.manufacturer=.*' | cut -d'=' -f 2)" 16[ -d /sys/kernel/config/usb_gadget ] || modprobe libcomposite
22model="$(cat /system/build.prop | grep -o 'ro.product.model=.*' | cut -d'=' -f 2)" 17
23# get the device serial number from /proc/cmdline directly(since we have no getprop on 18cd /sys/kernel/config/usb_gadget
24# GNU/Linux) 19
25serial="$(cat /proc/cmdline | sed 's/.*androidboot.serialno=//' | sed 's/ .*//')" 20[ -d adb ] && /usr/bin/android-gadget-cleanup || true
26 21
27echo $serial > /sys/class/android_usb/android0/iSerial 22mkdir adb
28echo $manufacturer > /sys/class/android_usb/android0/iManufacturer 23cd adb
29echo $model > /sys/class/android_usb/android0/iProduct
30 24
31echo "0" > /sys/class/android_usb/android0/enable 25mkdir configs/c.1
32echo "18d1" > /sys/class/android_usb/android0/idVendor 26mkdir functions/ffs.usb0
33echo "D002" > /sys/class/android_usb/android0/idProduct 27mkdir strings/0x409
34echo "adb" > /sys/class/android_usb/android0/functions 28mkdir configs/c.1/strings/0x409
35echo "1" > /sys/class/android_usb/android0/enable 29echo -n "$vendor" > idVendor
30echo -n "$product" > idProduct
31echo "$serial" > strings/0x409/serialnumber
32echo "$manufacturer" > strings/0x409/manufacturer
33echo "$model" > strings/0x409/product
34echo "$conf" > configs/c.1/strings/0x409/configuration
35ln -s functions/ffs.usb0 configs/c.1
36 36
37sleep 4 37mkdir -p /dev/usb-ffs/adb
38ADB_UID=$(id -u adb)
39ADB_GID=$(id -g adb)
40mount -t functionfs usb0 /dev/usb-ffs/adb -o "uid=$ADB_UID,gid=$ADB_GID"
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-start b/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-start
new file mode 100644
index 0000000000..4ea688accb
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-start
@@ -0,0 +1,16 @@
1#!/bin/sh
2
3set -e
4
5# Wait for adbd to open ep0 before activating the UDC. Without systemd
6# sd_notify synchronisation there is no other signal that adbd is ready, so
7# a fixed delay is used. When this script is invoked via ExecStartPost in a
8# Type=notify service, adbd has already sent READY=1 before this runs and
9# no delay is needed; set ANDROID_GADGET_UDC_DELAY=0 in that case (e.g. via
10# a systemd drop-in Environment= line).
11ANDROID_GADGET_UDC_DELAY="${ANDROID_GADGET_UDC_DELAY:-10}"
12sleep "$ANDROID_GADGET_UDC_DELAY"
13
14ls /sys/class/udc/ | head -n 1 | xargs echo -n > /sys/kernel/config/usb_gadget/adb/UDC
15
16echo "Setting UDC $(ls /sys/class/udc/ | head -n 1) for USB ADB Gadget usage"
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf_1.0.bb b/meta-oe/recipes-devtools/android-tools/android-tools-conf_1.0.bb
index 764d6b404f..bb55b3599f 100644
--- a/meta-oe/recipes-devtools/android-tools/android-tools-conf_1.0.bb
+++ b/meta-oe/recipes-devtools/android-tools/android-tools-conf_1.0.bb
@@ -1,22 +1,40 @@
1DESCRIPTION = "Different utilities from Android - corressponding configuration files" 1DESCRIPTION = "Different utilities from Android - corresponding configuration files for using ConfigFS"
2SECTION = "console/utils" 2SECTION = "console/utils"
3LICENSE = "MIT" 3LICENSE = "MIT"
4LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" 4LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
5 5
6SRC_URI = "file://android-gadget-setup"
7
8S = "${UNPACKDIR}" 6S = "${UNPACKDIR}"
9 7
8SRC_URI = " \
9 file://android-gadget-setup \
10 file://android-gadget-start \
11 file://android-gadget-cleanup \
12 file://10-adbd-configfs.conf \
13"
14
10PACKAGE_ARCH = "${MACHINE_ARCH}" 15PACKAGE_ARCH = "${MACHINE_ARCH}"
11 16
12do_install() { 17do_install() {
13 install -d ${D}${bindir} 18 install -d ${D}${bindir}
14 install -m 0755 ${UNPACKDIR}/android-gadget-setup ${D}${bindir} 19 install -m 0755 ${UNPACKDIR}/android-gadget-setup ${D}${bindir}
15} 20 install -m 0755 ${UNPACKDIR}/android-gadget-start ${D}${bindir}
21 install -m 0755 ${UNPACKDIR}/android-gadget-cleanup ${D}${bindir}
16 22
17python () { 23 if [ -r ${UNPACKDIR}/android-gadget-setup.machine ] ; then
18 pn = d.getVar('PN') 24 install -d ${D}${sysconfdir}
19 profprov = d.getVar("PREFERRED_PROVIDER_" + pn) 25 install -m 0644 ${UNPACKDIR}/android-gadget-setup.machine ${D}${sysconfdir}
20 if profprov and pn != profprov: 26 fi
21 raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (pn, profprov, pn)) 27
28 install -d ${D}${systemd_unitdir}/system/android-tools-adbd.service.d
29 install -m 0644 ${UNPACKDIR}/10-adbd-configfs.conf ${D}${systemd_unitdir}/system/android-tools-adbd.service.d
22} 30}
31
32FILES:${PN} += " \
33 ${systemd_unitdir}/system/ \
34"
35
36PROVIDES += "android-tools-conf-configfs"
37RPROVIDES:${PN} = "android-tools-conf-configfs"
38RREPLACES:${PN} = "android-tools-conf-configfs"
39RCONFLICTS:${PN} = "android-tools-conf-configfs"
40BBCLASSEXTEND = "native"
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0001-libbacktrace.mk-Link-against-staged-lib7z.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0001-libbacktrace.mk-Link-against-staged-lib7z.patch
new file mode 100644
index 0000000000..845e267c41
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/0001-libbacktrace.mk-Link-against-staged-lib7z.patch
@@ -0,0 +1,38 @@
1From 1eab8bc4974c887c09d6b444c5198ec4c0932b36 Mon Sep 17 00:00:00 2001
2From: Mihajlo Marinkovic <mmarinkovic@snap.com>
3Date: Fri, 8 May 2026 12:10:00 +0000
4Subject: [PATCH] libbacktrace.mk: Link against staged lib7z
5
6In the Yocto target sysroot, p7zip installs `lib7z.so` under `/usr/lib`.
7The Debian make fragment hardcodes `/usr/lib/7zip` and links `-l:7z.so`,
8which does not exist in this environment and causes link failure.
9
10Use the standard sysroot library search path and link against `-l7z`
11instead.
12
13Upstream-Status: Inappropriate [OE-specific]
14
15Signed-off-by: Mihajlo Marinkovic <mmarinkovic@snap.com>
16---
17 debian/system/libbacktrace.mk | 4 +---
18 1 file changed, 1 insertion(+), 3 deletions(-)
19
20diff --git a/debian/system/libbacktrace.mk b/debian/system/libbacktrace.mk
21index b106c24..0f798d4 100644
22--- a/debian/system/libbacktrace.mk
23+++ b/debian/system/libbacktrace.mk
24@@ -64,13 +64,11 @@ CPPFLAGS += \
25 -Isystem/unwinding/libunwindstack/include \
26
27 LDFLAGS += \
28- -L/usr/lib/7zip \
29 -Ldebian/out/external \
30 -Ldebian/out/system \
31 -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
32- -Wl,-rpath=/usr/lib/7zip \
33 -Wl,-soname,$(NAME).so.0 \
34- -l:7z.so \
35+ -l7z \
36 -lbase \
37 -llog \
38 -lpthread \
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0002-debian-makefiles-yocto-compat.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0002-debian-makefiles-yocto-compat.patch
new file mode 100644
index 0000000000..a7c8dcf946
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/0002-debian-makefiles-yocto-compat.patch
@@ -0,0 +1,240 @@
1From 14058ff506910f19c6e6a49e2bb081c398a7acf0 Mon Sep 17 00:00:00 2001
2From: Mihajlo Marinkovic <mmarinkovic@snap.com>
3Date: Sun, 10 May 2026 15:20:00 +0000
4Subject: [PATCH] debian makefiles: adapt for cross-compilation in Yocto
5
6The Debian make fragments hardcode several assumptions that only work on
7a Debian build host:
8 - include /usr/share/dpkg/architecture.mk (shells out to dpkg-architecture)
9 - /usr/include/android (host path, not sysroot)
10 - /usr/lib/$(DEB_HOST_MULTIARCH)/android (host rpath)
11 - -lcrypto / -lssl (links against system OpenSSL instead of BoringSSL)
12 - -Wexit-time-destructors (Clang-only, rejected by GCC)
13
14Replace each with its Yocto-compatible equivalent: use $(SYSROOT) for
15include paths, rpath relative to $ORIGIN for installed libraries, exact
16soname matching for the staged BoringSSL shared objects, and drop the
17Clang-only warning flag.
18
19Upstream-Status: Inappropriate [OE-specific]
20
21Signed-off-by: Mihajlo Marinkovic <mmarinkovic@snap.com>
22---
23 debian/system/adb.mk | 9 ++++-----
24 debian/system/adbd.mk | 10 ++++------
25 debian/system/extras/libext4_utils.mk | 4 ++--
26 debian/system/fastboot.mk | 13 ++++++-------
27 debian/system/libadb.mk | 3 +--
28 debian/system/libbacktrace.mk | 2 +-
29 debian/system/libbase.mk | 2 +-
30 debian/system/libcrypto_utils.mk | 2 +-
31 debian/system/libcutils.mk | 2 +-
32 debian/system/liblog.mk | 1 +
33 debian/system/libutils.mk | 3 +--
34 11 files changed, 23 insertions(+), 28 deletions(-)
35
36diff --git a/debian/system/adb.mk b/debian/system/adb.mk
37index 89530b0..90a816f 100644
38--- a/debian/system/adb.mk
39+++ b/debian/system/adb.mk
40@@ -82,22 +82,21 @@ CPPFLAGS += \
41 -Isystem/libbase/include \
42 -Isystem/libziparchive/include \
43 \
44- -I/usr/include/android \
45+ -I$(SYSROOT)/usr/include/android \
46
47 LDFLAGS += \
48 -Ldebian/out/system \
49- -L/usr/lib/$(DEB_HOST_MULTIARCH)/android \
50- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
51+ -Wl,-rpath='$$ORIGIN/../lib/android' \
52 -lbase \
53 -lbrotlidec \
54 -lbrotlienc \
55- -lcrypto \
56+ -l:libcrypto.so.0 \
57 -lcutils \
58 -llog \
59 -llz4 \
60 -lprotobuf \
61 -lpthread \
62- -lssl \
63+ -l:libssl.so.0 \
64 -lusb-1.0 \
65 -lziparchive \
66 -lzstd \
67diff --git a/debian/system/adbd.mk b/debian/system/adbd.mk
68index 9d6abd7..73e49a4 100644
69--- a/debian/system/adbd.mk
70+++ b/debian/system/adbd.mk
71@@ -81,23 +81,21 @@ CPPFLAGS += \
72 -Isystem/libbase/include \
73 -Isystem/logging/liblog/include \
74 \
75- -I/usr/include/android \
76+ -I$(SYSROOT)/usr/include/android \
77
78 LDFLAGS += \
79 -Ldebian/out/system \
80- -L/usr/lib/$(DEB_HOST_MULTIARCH)/android \
81- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
82+ -Wl,-rpath='$$ORIGIN/../lib/android' \
83 -lbase \
84 -lbrotlidec \
85 -lbrotlienc \
86- -lcrypto \
87+ -l:libcrypto.so.0 \
88 -lcutils \
89 -llog \
90 -llz4 \
91 -lprotobuf \
92 -lresolv \
93- -lssl \
94- -lsystemd \
95+ -l:libssl.so.0 \
96 -lzstd \
97 -pie \
98
99diff --git a/debian/system/extras/libext4_utils.mk b/debian/system/extras/libext4_utils.mk
100index 77455f4..5bfc950 100644
101--- a/debian/system/extras/libext4_utils.mk
102+++ b/debian/system/extras/libext4_utils.mk
103@@ -26,8 +26,8 @@ CPPFLAGS += \
104 -D_LARGEFILE64_SOURCE \
105 -DFEC_NO_KLOG \
106 -DSQUASHFS_NO_KLOG \
107- -I/usr/include/android \
108- -I/usr/include/squashfuse \
109+ -I$(SYSROOT)/usr/include/android \
110+ -I$(SYSROOT)/usr/include/squashfuse \
111 -Isystem/core/libcutils/include \
112 -Isystem/core/libsparse/include \
113 -Isystem/extras/ext4_utils/include \
114diff --git a/debian/system/fastboot.mk b/debian/system/fastboot.mk
115index d68a99a..52f5d8b 100644
116--- a/debian/system/fastboot.mk
117+++ b/debian/system/fastboot.mk
118@@ -56,16 +56,15 @@ CPPFLAGS += \
119 -Isystem/libziparchive/include \
120 -Isystem/tools/mkbootimg/include/bootimg \
121 \
122- -I/usr/include/android \
123+ -I$(SYSROOT)/usr/include/android \
124
125 LDFLAGS += \
126 -Ldebian/out/system \
127- -L/usr/lib/$(DEB_HOST_MULTIARCH)/android \
128- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
129- -lbase \
130- -lcrypto \
131- -lcutils \
132- -llog \
133+ -Wl,-rpath='$$ORIGIN/../lib/android' \
134+ debian/out/system/libbase.so.0 \
135+ -l:libcrypto.so.0 \
136+ debian/out/system/libcutils.so.0 \
137+ debian/out/system/liblog.so.0 \
138 -lpthread \
139 -lprotobuf \
140 -lsparse \
141diff --git a/debian/system/libadb.mk b/debian/system/libadb.mk
142index 52f2838..ebd52aa 100644
143--- a/debian/system/libadb.mk
144+++ b/debian/system/libadb.mk
145@@ -73,7 +73,6 @@ SOURCES_CC = $(filter %.cc,$(SOURCES))
146 OBJECTS_CC = $(SOURCES_CC:.cc=.o)
147
148 CXXFLAGS += \
149- -Wexit-time-destructors \
150 -Wno-non-virtual-dtor \
151 -Wno-unused-parameter \
152 -Wno-missing-field-initializers \
153@@ -96,7 +95,7 @@ CPPFLAGS += \
154 -Isystem/core/libcutils/include \
155 -Isystem/libbase/include \
156 \
157- -I/usr/include/android \
158+ -I$(SYSROOT)/usr/include/android \
159
160 debian/out/system/$(NAME).a: $(OBJECTS_CC) $(OBJECTS_CPP)
161 ar -rcs $@ $^
162diff --git a/debian/system/libbacktrace.mk b/debian/system/libbacktrace.mk
163index 0f798d4..f004061 100644
164--- a/debian/system/libbacktrace.mk
165+++ b/debian/system/libbacktrace.mk
166@@ -1,4 +1,4 @@
167-include /usr/share/dpkg/architecture.mk
168+DEB_HOST_MULTIARCH ?=
169
170 NAME = libbacktrace
171
172diff --git a/debian/system/libbase.mk b/debian/system/libbase.mk
173index f04d3f9..61f71c6 100644
174--- a/debian/system/libbase.mk
175+++ b/debian/system/libbase.mk
176@@ -42,7 +42,7 @@ CPPFLAGS += \
177
178 LDFLAGS += \
179 -Ldebian/out/system \
180- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
181+ -Wl,-rpath='$$ORIGIN' \
182 -Wl,-soname,$(NAME).so.0 \
183 -llog \
184 -lpthread \
185diff --git a/debian/system/libcrypto_utils.mk b/debian/system/libcrypto_utils.mk
186index 39fd8a7..82ae46c 100644
187--- a/debian/system/libcrypto_utils.mk
188+++ b/debian/system/libcrypto_utils.mk
189@@ -7,7 +7,7 @@ CPPFLAGS += \
190 -Isystem/core/include \
191 -Isystem/core/libcrypto_utils/include \
192 \
193- -I/usr/include/android \
194+ -I$(SYSROOT)/usr/include/android \
195
196 debian/out/system/$(NAME).a: $(OBJECTS)
197 ar -rcs $@ $^
198diff --git a/debian/system/libcutils.mk b/debian/system/libcutils.mk
199index 596ebd8..ff9e911 100644
200--- a/debian/system/libcutils.mk
201+++ b/debian/system/libcutils.mk
202@@ -50,7 +50,7 @@ CPPFLAGS += \
203
204 LDFLAGS += \
205 -Ldebian/out/system \
206- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
207+ -Wl,-rpath='$$ORIGIN' \
208 -Wl,-soname,$(NAME).so.0 \
209 -lbase \
210 -llog \
211diff --git a/debian/system/liblog.mk b/debian/system/liblog.mk
212index b08a50c..091ccad 100644
213--- a/debian/system/liblog.mk
214+++ b/debian/system/liblog.mk
215@@ -27,6 +27,7 @@ CPPFLAGS += \
216 -Isystem/logging/liblog/include \
217
218 LDFLAGS += \
219+ -Wl,-rpath='$$ORIGIN' \
220 -Wl,-soname,$(NAME).so.0 \
221 -lpthread \
222 -shared
223diff --git a/debian/system/libutils.mk b/debian/system/libutils.mk
224index 6218c73..c7948e7 100644
225--- a/debian/system/libutils.mk
226+++ b/debian/system/libutils.mk
227@@ -1,4 +1,3 @@
228-include /usr/share/dpkg/architecture.mk
229
230 NAME = libutils
231
232@@ -42,7 +41,7 @@ CPPFLAGS += \
233
234 LDFLAGS += \
235 -Ldebian/out/system \
236- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
237+ -Wl,-rpath='$$ORIGIN' \
238 -Wl,-soname,$(NAME).so.0 \
239 -lbacktrace \
240 -lcutils \
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0003-gcc-nullability-and-thread-annotation-compat.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0003-gcc-nullability-and-thread-annotation-compat.patch
new file mode 100644
index 0000000000..c3cf572ebd
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/0003-gcc-nullability-and-thread-annotation-compat.patch
@@ -0,0 +1,34 @@
1From 793ad99196c5b9cf2922689d993b8f798e87174c Mon Sep 17 00:00:00 2001
2From: Mihajlo Marinkovic <mmarinkovic@snap.com>
3Date: Sun, 10 May 2026 12:00:00 +0200
4Subject: [PATCH] GCC nullability and thread annotation compat
5
6GCC does not understand the Clang-only nullability markers used in adb,
7and it rejects function-definition attributes emitted by the thread
8annotation macros. The nullability markers are injected from the Yocto
9recipe flags, while thread annotation attributes are made Clang-only so
10the sources parse under Yocto's GCC toolchain.
11
12Upstream-Status: Inappropriate [OE-specific]
13
14Signed-off-by: Mihajlo Marinkovic <mmarinkovic@snap.com>
15---
16 system/libbase/include/android-base/thread_annotations.h | 4 ++++
17 1 file changed, 4 insertions(+)
18
19diff --git a/system/libbase/include/android-base/thread_annotations.h b/system/libbase/include/android-base/thread_annotations.h
20index 53fe6da..5523521 100644
21--- a/system/libbase/include/android-base/thread_annotations.h
22+++ b/system/libbase/include/android-base/thread_annotations.h
23@@ -18,7 +18,11 @@
24
25 #include <mutex>
26
27+#if defined(__clang__)
28 #define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
29+#else
30+#define THREAD_ANNOTATION_ATTRIBUTE__(x)
31+#endif
32
33 #define CAPABILITY(x) \
34 THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0004-fastboot-super_flash_helper-include-climits.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0004-fastboot-super_flash_helper-include-climits.patch
new file mode 100644
index 0000000000..2b155e6a71
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/0004-fastboot-super_flash_helper-include-climits.patch
@@ -0,0 +1,41 @@
1From fe7c2aa9a9032d11cb14ff7ab2a1a000237edaa3 Mon Sep 17 00:00:00 2001
2From: Mihajlo Marinkovic <mmarinkovic@snap.com>
3Date: Tue, 26 May 2026 17:41:00 +0200
4Subject: [PATCH] adb: include <climits> for missing integer constants
5
6GCC rejects builds where IOV_MAX (sysdeps/uio.h) or UINT_MAX
7(super_flash_helper.cpp) are used without the header that defines them.
8Add #include <climits> in both files.
9
10Upstream-Status: Inappropriate [OE-specific sysroot compat]
11
12Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
13---
14 packages/modules/adb/sysdeps/uio.h | 1 +
15 system/core/fastboot/super_flash_helper.cpp | 1 +
16 2 files changed, 2 insertions(+)
17
18diff --git a/packages/modules/adb/sysdeps/uio.h b/packages/modules/adb/sysdeps/uio.h
19index f3ace64..163b4a8 100644
20--- a/packages/modules/adb/sysdeps/uio.h
21+++ b/packages/modules/adb/sysdeps/uio.h
22@@ -35,6 +35,7 @@ ssize_t adb_writev(borrowed_fd fd, const adb_iovec* iov, int iovcnt);
23 #else
24
25 #include <sys/uio.h>
26+#include <climits>
27 using adb_iovec = struct iovec;
28 inline ssize_t adb_writev(borrowed_fd fd, const adb_iovec* iov, int iovcnt) {
29 return writev(fd.get(), iov, std::min(iovcnt, IOV_MAX));
30diff --git a/system/core/fastboot/super_flash_helper.cpp b/system/core/fastboot/super_flash_helper.cpp
31index b617ce8..8c1edde 100644
32--- a/system/core/fastboot/super_flash_helper.cpp
33+++ b/system/core/fastboot/super_flash_helper.cpp
34@@ -16,6 +16,7 @@
35
36 #include "super_flash_helper.h"
37
38+#include <climits>
39 #include <android-base/logging.h>
40
41 #include "util.h"
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0005-adb-host-usb-compat.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0005-adb-host-usb-compat.patch
new file mode 100644
index 0000000000..6f396b7e9d
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/0005-adb-host-usb-compat.patch
@@ -0,0 +1,34 @@
1From da0746f90c80bb5621d01f35d505412cd26898e2 Mon Sep 17 00:00:00 2001
2From: Mihajlo Marinkovic <mmarinkovic@snap.com>
3Date: Thu, 21 May 2026 14:10:00 +0200
4Subject: [PATCH] adb: replace socket_get_local_port with inline getsockname
5
6The libcutils socket_get_local_port helper is not available in the native
7libcutils build. Replace the call with an inline getsockname implementation.
8
9Upstream-Status: Inappropriate [OE-specific]
10
11Signed-off-by: Mihajlo Marinkovic <mmarinkovic@snap.com>
12---
13 packages/modules/adb/sysdeps.h | 8 +++++++-
14 1 file changed, 7 insertions(+), 1 deletion(-)
15
16diff --git a/packages/modules/adb/sysdeps.h b/packages/modules/adb/sysdeps.h
17index 99f6b74..9a99295 100644
18--- a/packages/modules/adb/sysdeps.h
19+++ b/packages/modules/adb/sysdeps.h
20@@ -626,7 +626,13 @@ inline int adb_getsockname(borrowed_fd fd, struct sockaddr* sockaddr, socklen_t*
21 }
22
23 inline int adb_socket_get_local_port(borrowed_fd fd) {
24- return socket_get_local_port(fd.get());
25+ sockaddr_storage addr;
26+ socklen_t addr_size = sizeof(addr);
27+
28+ if (getsockname(fd.get(), reinterpret_cast<sockaddr*>(&addr), &addr_size) == 0) {
29+ return ntohs(reinterpret_cast<sockaddr_in*>(&addr)->sin_port);
30+ }
31+ return -1;
32 }
33
34 // Operate on a file descriptor returned from unix_open() or a well-known file
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0006-adbd-enable-root-and-remount-support.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0006-adbd-enable-root-and-remount-support.patch
new file mode 100644
index 0000000000..700e64f06d
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/0006-adbd-enable-root-and-remount-support.patch
@@ -0,0 +1,466 @@
1From d247444cf5ef0c8ee2fcf207febe09f5101c2215 Mon Sep 17 00:00:00 2001
2From: Mihajlo Marinkovic <mmarinkovic@snap.com>
3Date: Fri, 29 May 2026 12:10:00 +0200
4Subject: [PATCH] adbd: enable root and remount support
5
6Enable root/unroot and remount support for the non-Android adbd build.
7
8Upstream-Status: Inappropriate [embedded Linux integration]
9
10Signed-off-by: Mihajlo Marinkovic <mmarinkovic@snap.com>
11---
12 debian/system/adbd.mk | 3 +
13 .../modules/adb/daemon/framebuffer_service.h | 2 +-
14 packages/modules/adb/daemon/main.cpp | 93 +++++++++++++++----
15 .../modules/adb/daemon/restart_service.cpp | 40 +++++++-
16 packages/modules/adb/daemon/restart_service.h | 2 +-
17 packages/modules/adb/daemon/services.cpp | 81 ++++++++++++++--
18 packages/modules/adb/sockets.cpp | 20 +++-
19 packages/modules/adb/transport.cpp | 1 -
20 8 files changed, 204 insertions(+), 38 deletions(-)
21
22diff --git a/debian/system/adbd.mk b/debian/system/adbd.mk
23index 73e49a4..beb412e 100644
24--- a/debian/system/adbd.mk
25+++ b/debian/system/adbd.mk
26@@ -17,6 +17,8 @@ ADBD_SRC_FILES = \
27 daemon/jdwp_service.cpp \
28 daemon/logging.cpp \
29 daemon/main.cpp \
30+ daemon/framebuffer_service.cpp \
31+ daemon/restart_service.cpp \
32 daemon/transport_local.cpp \
33 daemon/usb.cpp \
34 daemon/usb_ffs.cpp \
35@@ -64,6 +66,7 @@ CPPFLAGS += \
36 -DPLATFORM_TOOLS_VERSION='"$(PLATFORM_TOOLS_VERSION)"' \
37 -DADB_HOST=0 \
38 -DADB_VERSION='"$(DEB_VERSION)"' \
39+ -DALLOW_ADBD_ROOT=1 \
40 -DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION=1 \
41 -DPAGE_SIZE=4096 \
42 -Iframeworks/native/libs/adbd_auth/include/ \
43diff --git a/packages/modules/adb/daemon/framebuffer_service.h b/packages/modules/adb/daemon/framebuffer_service.h
44index bab44be..0a8c822 100644
45--- a/packages/modules/adb/daemon/framebuffer_service.h
46+++ b/packages/modules/adb/daemon/framebuffer_service.h
47@@ -18,6 +18,6 @@
48
49 #include "adb_unique_fd.h"
50
51-#if defined(__ANDROID__)
52+#if !defined(__ANDROID_RECOVERY__)
53 void framebuffer_service(unique_fd fd);
54 #endif
55diff --git a/packages/modules/adb/daemon/main.cpp b/packages/modules/adb/daemon/main.cpp
56index 83905d3..f177abf 100644
57--- a/packages/modules/adb/daemon/main.cpp
58+++ b/packages/modules/adb/daemon/main.cpp
59@@ -19,11 +19,15 @@
60 #include "sysdeps.h"
61
62 #include <errno.h>
63+#include <fcntl.h>
64 #include <getopt.h>
65+#include <grp.h>
66 #include <malloc.h>
67+#include <pwd.h>
68 #include <signal.h>
69 #include <stdio.h>
70 #include <stdlib.h>
71+#include <string.h>
72 #include <sys/capability.h>
73 #include <sys/prctl.h>
74
75@@ -61,6 +65,13 @@
76 #include "daemon/mdns.h"
77 #include "daemon/watchdog.h"
78
79+namespace {
80+constexpr char kAdbRootStatePath[] = "/run/.adb.root";
81+constexpr char kRootMagic[] = "#ROOT#";
82+constexpr char kNoRootMagic[] = "#NOROOT#";
83+constexpr size_t kRootMagicSize = sizeof(kRootMagic) - 1;
84+}
85+
86 #if defined(__ANDROID__)
87 static const char* root_seclabel = nullptr;
88
89@@ -75,24 +86,16 @@ static bool should_drop_privileges() {
90 //
91 // ro.secure:
92 // Drop privileges by default. Set to 1 on userdebug and user builds.
93- bool ro_secure = android::base::GetBoolProperty("ro.secure", true);
94- bool ro_debuggable = __android_log_is_debuggable();
95-
96- // Drop privileges if ro.secure is set...
97- bool drop = ro_secure;
98-
99- // ... except "adb root" lets you keep privileges in a debuggable build.
100- std::string prop = android::base::GetProperty("service.adb.root", "");
101- bool adb_root = (prop == "1");
102- bool adb_unroot = (prop == "0");
103- if (ro_debuggable && adb_root) {
104- drop = false;
105+ int f = unix_open(kAdbRootStatePath, O_RDONLY | O_CLOEXEC);
106+ if (f < 0) {
107+ return true;
108 }
109- // ... and "adb unroot" lets you explicitly drop privileges.
110- if (adb_unroot) {
111- drop = true;
112+ char buf[kRootMagicSize];
113+ bool drop = true;
114+ if (unix_read(f, buf, sizeof(buf)) != -1 && !strncmp(buf, kRootMagic, kRootMagicSize)) {
115+ drop = false;
116 }
117-
118+ unix_close(f);
119 return drop;
120 }
121
122@@ -122,6 +125,17 @@ static void drop_privileges(int server_port) {
123 // Don't listen on a port (default 5037) if running in secure mode.
124 // Don't run as root if running in secure mode.
125 if (should_drop_privileges()) {
126+ int f = unix_open(kAdbRootStatePath, O_WRONLY | O_CREAT | O_CLOEXEC, 0666);
127+ if (f >= 0) {
128+ if (fchmod(f, 0666) == -1) {
129+ PLOG(ERROR) << "failed to set root state permissions";
130+ }
131+ if (unix_write(f, kNoRootMagic, sizeof(kNoRootMagic) - 1) == -1) {
132+ PLOG(ERROR) << "failed to initialize root state";
133+ }
134+ unix_close(f);
135+ }
136+
137 const bool should_drop_caps = !__android_log_is_debuggable();
138
139 if (should_drop_caps) {
140@@ -182,6 +196,51 @@ static void drop_privileges(int server_port) {
141 }
142 #endif
143
144+#if !defined(__ANDROID__)
145+static bool should_drop_privileges() {
146+ int f = unix_open(kAdbRootStatePath, O_RDONLY | O_CLOEXEC);
147+ if (f < 0) {
148+ return true;
149+ }
150+ char buf[kRootMagicSize];
151+ bool drop = true;
152+ if (unix_read(f, buf, sizeof(buf)) != -1 && !strncmp(buf, kRootMagic, kRootMagicSize)) {
153+ drop = false;
154+ }
155+ unix_close(f);
156+ return drop;
157+}
158+
159+static void drop_privileges(int) {
160+ if (!should_drop_privileges()) {
161+ return;
162+ }
163+ int f = unix_open(kAdbRootStatePath, O_WRONLY | O_CREAT | O_CLOEXEC, 0666);
164+ if (f >= 0) {
165+ if (fchmod(f, 0666) == -1) {
166+ PLOG(ERROR) << "failed to set root state permissions";
167+ }
168+ if (unix_write(f, kNoRootMagic, sizeof(kNoRootMagic) - 1) == -1) {
169+ PLOG(ERROR) << "failed to initialize root state";
170+ }
171+ unix_close(f);
172+ }
173+ passwd* adb_user = getpwnam("adb");
174+ if (adb_user == nullptr) {
175+ PLOG(FATAL) << "getpwnam(adb) failed";
176+ }
177+ if (initgroups(adb_user->pw_name, adb_user->pw_gid) != 0) {
178+ PLOG(FATAL) << "initgroups(adb) failed";
179+ }
180+ if (setgid(adb_user->pw_gid) != 0) {
181+ PLOG(FATAL) << "setgid(adb) failed";
182+ }
183+ if (setuid(adb_user->pw_uid) != 0) {
184+ PLOG(FATAL) << "setuid(adb) failed";
185+ }
186+}
187+#endif
188+
189 static void setup_adb(const std::vector<std::string>& addrs) {
190 #if defined(__ANDROID__)
191 // Get the first valid port from addrs and setup mDNS.
192@@ -242,9 +301,7 @@ int adbd_main(int server_port) {
193 " unchanged.\n");
194 }
195
196-#if defined(__ANDROID__)
197 drop_privileges(server_port);
198-#endif
199
200 #if defined(__ANDROID__)
201 // A thread gets spawned as a side-effect of initializing the watchdog, so it needs to happen
202diff --git a/packages/modules/adb/daemon/restart_service.cpp b/packages/modules/adb/daemon/restart_service.cpp
203index 16d2627..fcba9c8 100644
204--- a/packages/modules/adb/daemon/restart_service.cpp
205+++ b/packages/modules/adb/daemon/restart_service.cpp
206@@ -18,6 +18,9 @@
207
208 #include "sysdeps.h"
209
210+#include <errno.h>
211+#include <fcntl.h>
212+#include <string.h>
213 #include <unistd.h>
214
215 #include <android-base/logging.h>
216@@ -28,6 +31,26 @@
217 #include "adb_io.h"
218 #include "adb_unique_fd.h"
219
220+namespace {
221+constexpr char kAdbRootStatePath[] = "/run/.adb.root";
222+constexpr char kRootMagic[] = "#ROOT#";
223+constexpr char kNoRootMagic[] = "#NOROOT#";
224+constexpr size_t kRootMagicSize = sizeof(kRootMagic) - 1;
225+
226+bool write_root_state(const char* value, size_t size) {
227+ int f = unix_open(kAdbRootStatePath, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0666);
228+ if (f < 0) {
229+ return false;
230+ }
231+ bool ok = unix_write(f, value, size) == static_cast<int>(size);
232+ if (ok) {
233+ ok = fsync(f) == 0;
234+ }
235+ unix_close(f);
236+ return ok;
237+}
238+}
239+
240 void restart_root_service(unique_fd fd) {
241 if (getuid() == 0) {
242 WriteFdExactly(fd.get(), "adbd is already running as root\n");
243@@ -38,9 +61,15 @@ void restart_root_service(unique_fd fd) {
244 return;
245 }
246
247- LOG(INFO) << "adbd restarting as root";
248- android::base::SetProperty("service.adb.root", "1");
249- WriteFdExactly(fd.get(), "restarting adbd as root\n");
250+ for (int retry = 5; retry-- > 0;) {
251+ if (write_root_state(kRootMagic, kRootMagicSize)) {
252+ LOG(INFO) << "adbd restarting as root";
253+ WriteFdExactly(fd.get(), "restarting adbd as root\n");
254+ return;
255+ }
256+ usleep(100000);
257+ }
258+ WriteFdExactly(fd.get(), "failed to switch adbd to root\n");
259 }
260
261 void restart_unroot_service(unique_fd fd) {
262@@ -49,8 +78,11 @@ void restart_unroot_service(unique_fd fd) {
263 return;
264 }
265
266+ if (!write_root_state(kNoRootMagic, sizeof(kNoRootMagic) - 1)) {
267+ PLOG(ERROR) << "failed to write root state";
268+ return;
269+ }
270 LOG(INFO) << "adbd restarting as nonroot";
271- android::base::SetProperty("service.adb.root", "0");
272 WriteFdExactly(fd.get(), "restarting adbd as non root\n");
273 }
274
275diff --git a/packages/modules/adb/daemon/restart_service.h b/packages/modules/adb/daemon/restart_service.h
276index 19840bd..2d239db 100644
277--- a/packages/modules/adb/daemon/restart_service.h
278+++ b/packages/modules/adb/daemon/restart_service.h
279@@ -18,7 +18,7 @@
280
281 #include "adb_unique_fd.h"
282
283-#if defined(__ANDROID__)
284+#if !defined(__ANDROID_RECOVERY__)
285 void restart_root_service(unique_fd fd);
286 void restart_unroot_service(unique_fd fd);
287 void restart_tcp_service(unique_fd fd, int port);
288diff --git a/packages/modules/adb/daemon/services.cpp b/packages/modules/adb/daemon/services.cpp
289index 5090441..1b27314 100644
290--- a/packages/modules/adb/daemon/services.cpp
291+++ b/packages/modules/adb/daemon/services.cpp
292@@ -19,12 +19,18 @@
293 #include "sysdeps.h"
294
295 #include <errno.h>
296+#include <fcntl.h>
297+#include <linux/fs.h>
298+#include <linux/reboot.h>
299+#include <mntent.h>
300 #include <netdb.h>
301 #include <netinet/in.h>
302 #include <stddef.h>
303 #include <stdio.h>
304 #include <stdlib.h>
305 #include <string.h>
306+#include <sys/mount.h>
307+#include <sys/syscall.h>
308 #include <sys/ioctl.h>
309 #include <sys/socket.h>
310 #include <sys/un.h>
311@@ -40,7 +46,6 @@
312 #include <android-base/stringprintf.h>
313 #include <android-base/strings.h>
314 #include <android-base/unique_fd.h>
315-#include <cutils/android_reboot.h>
316 #include <cutils/sockets.h>
317 #include <log/log_properties.h>
318
319@@ -143,6 +148,60 @@ static void spin_service(unique_fd fd) {
320 WriteFdExactly(fd.get(), "spinning\n");
321 }
322
323+static std::string find_mount(std::string_view dir) {
324+ std::unique_ptr<FILE, int (*)(FILE*)> fp(setmntent("/proc/mounts", "r"), endmntent);
325+ if (!fp) {
326+ return {};
327+ }
328+ while (mntent* entry = getmntent(fp.get())) {
329+ if (dir == entry->mnt_dir) {
330+ return entry->mnt_fsname;
331+ }
332+ }
333+ return {};
334+}
335+
336+static bool make_block_device_writable(const std::string& dev) {
337+ android::base::unique_fd fd(unix_open(dev.c_str(), O_RDONLY | O_CLOEXEC));
338+ if (fd == -1) {
339+ return false;
340+ }
341+ int off = 0;
342+ return ioctl(fd.get(), BLKROSET, &off) != -1;
343+}
344+
345+static bool remount_partition(unique_fd& fd, std::string_view dir) {
346+ std::string mount_point(dir);
347+ if (!directory_exists(mount_point)) {
348+ return true;
349+ }
350+ std::string dev = find_mount(dir);
351+ if (dev.empty()) {
352+ WriteFdFmt(fd.get(), "remount of %.*s failed; mount not found\n",
353+ static_cast<int>(dir.size()), dir.data());
354+ return false;
355+ }
356+ if (!make_block_device_writable(dev)) {
357+ WriteFdFmt(fd.get(), "remount of %.*s failed; couldn't make block device %s writable: %s\n",
358+ static_cast<int>(dir.size()), dir.data(), dev.c_str(), strerror(errno));
359+ return false;
360+ }
361+ if (mount(dev.c_str(), mount_point.c_str(), "none", MS_REMOUNT, nullptr) == -1) {
362+ WriteFdFmt(fd.get(), "remount of %.*s failed: %s\n", static_cast<int>(dir.size()), dir.data(), strerror(errno));
363+ return false;
364+ }
365+ return true;
366+}
367+
368+static void remount_service(unique_fd fd) {
369+ if (getuid() != 0) {
370+ WriteFdExactly(fd.get(), "Not running as root. Try \"adb root\" first.\n");
371+ return;
372+ }
373+ bool success = remount_partition(fd, "/");
374+ WriteFdExactly(fd.get(), success ? "remount succeeded\n" : "remount failed\n");
375+}
376+
377 [[maybe_unused]] static unique_fd reboot_device(const std::string& name) {
378 #if defined(__ANDROID_RECOVERY__)
379 if (!__android_log_is_debuggable()) {
380@@ -157,10 +216,16 @@ static void spin_service(unique_fd fd) {
381 return create_service_thread("reboot", reboot_service);
382 }
383 #endif
384- // Fall through
385- std::string cmd = "/system/bin/reboot ";
386- cmd += name;
387- return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone);
388+ auto reboot_service = [name](unique_fd fd) {
389+ sync();
390+ if (syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
391+ LINUX_REBOOT_CMD_RESTART2, "adb") != 0) {
392+ WriteFdFmt(fd.get(), "reboot (%s) failed: %s\n", name.c_str(), strerror(errno));
393+ return;
394+ }
395+ while (true) pause();
396+ };
397+ return create_service_thread("reboot", reboot_service);
398 }
399
400 struct ServiceSocket : public asocket {
401@@ -281,13 +346,11 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) {
402 }
403 #endif
404
405-#if defined(__ANDROID__)
406+#if !defined(__ANDROID_RECOVERY__)
407 if (name.starts_with("framebuffer:")) {
408 return create_service_thread("fb", framebuffer_service);
409 } else if (android::base::ConsumePrefix(&name, "remount:")) {
410- std::string cmd = "/system/bin/remount ";
411- cmd += name;
412- return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone);
413+ return create_service_thread("remount", remount_service);
414 } else if (android::base::ConsumePrefix(&name, "reboot:")) {
415 return reboot_device(std::string(name));
416 } else if (name.starts_with("root:")) {
417diff --git a/packages/modules/adb/sockets.cpp b/packages/modules/adb/sockets.cpp
418index f766f7e..8aa1e2b 100644
419--- a/packages/modules/adb/sockets.cpp
420+++ b/packages/modules/adb/sockets.cpp
421@@ -337,7 +337,7 @@ static void local_socket_destroy(asocket* s) {
422
423 if (exit_on_close) {
424 D("local_socket_destroy: exiting");
425- exit(0);
426+ exit(exit_on_close - 1);
427 }
428 }
429
430@@ -473,9 +473,21 @@ asocket* create_local_service_socket(std::string_view name, atransport* transpor
431 LOG(VERBOSE) << "LS(" << s->id << "): bound to '" << name << "' via " << fd_value;
432
433 #if !ADB_HOST
434- if ((name.starts_with("root:") && getuid() != 0 && __android_log_is_debuggable()) ||
435- (name.starts_with("unroot:") && getuid() == 0) || name.starts_with("usb:") ||
436- name.starts_with("tcpip:")) {
437+ bool exit_on_close = false;
438+#if defined(__ANDROID__)
439+ exit_on_close = (name.starts_with("root:") && getuid() != 0 &&
440+ __android_log_is_debuggable()) ||
441+ (name.starts_with("unroot:") && getuid() == 0);
442+#else
443+ exit_on_close = (name.starts_with("root:") && getuid() != 0) ||
444+ (name.starts_with("unroot:") && getuid() == 0);
445+#endif
446+ // exit_on_close == 2: exit(1) — triggers Restart=on-failure (root/unroot)
447+ // exit_on_close == 1: exit(0) — clean exit (usb/tcpip)
448+ if (exit_on_close) {
449+ D("LS(%d): enabling exit_on_close", s->id);
450+ s->exit_on_close = 2;
451+ } else if (name.starts_with("usb:") || name.starts_with("tcpip:")) {
452 D("LS(%d): enabling exit_on_close", s->id);
453 s->exit_on_close = 1;
454 }
455diff --git a/packages/modules/adb/transport.cpp b/packages/modules/adb/transport.cpp
456index b99e8bc..b89f495 100644
457--- a/packages/modules/adb/transport.cpp
458+++ b/packages/modules/adb/transport.cpp
459@@ -1200,7 +1200,6 @@ const FeatureSet& supported_features() {
460 kFeatureAbb,
461 kFeatureFixedPushSymlinkTimestamp,
462 kFeatureAbbExec,
463- kFeatureRemountShell,
464 kFeatureTrackApp,
465 kFeatureSendRecv2,
466 kFeatureSendRecv2Brotli,
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0007-libcutils-guard-Android-private-header-with-addition.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0007-libcutils-guard-Android-private-header-with-addition.patch
new file mode 100644
index 0000000000..aa5ffc2825
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/0007-libcutils-guard-Android-private-header-with-addition.patch
@@ -0,0 +1,36 @@
1From 35e41ab351e03abcd2709f136c57df7bc4855532 Mon Sep 17 00:00:00 2001
2From: Etienne Cordonnier <ecordonnier@snap.com>
3Date: Wed, 10 Jun 2026 00:00:00 +0000
4Subject: [PATCH] libcutils: guard Android-private header with additional
5 __has_include check
6
7The properties.cpp file uses __has_include(<sys/system_properties.h>) to
8conditionally compile the Android bionic property system implementation.
9However, some Linux host environments (e.g. those with Android SDK headers
10installed in /usr/local/include) have sys/system_properties.h without the
11accompanying private header sys/_system_properties.h.
12
13Guard both the public and private header inclusion to prevent a fatal error
14on such hosts.
15
16Upstream-Status: Inappropriate [OE-specific, guards against host header contamination]
17
18Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
19---
20 system/core/libcutils/properties.cpp | 3 ++-
21 1 file changed, 2 insertions(+), 1 deletion(-)
22
23diff --git a/system/core/libcutils/properties.cpp b/system/core/libcutils/properties.cpp
24index 03f0496..fd0f6c3 100644
25--- a/system/core/libcutils/properties.cpp
26+++ b/system/core/libcutils/properties.cpp
27@@ -91,7 +91,8 @@ int property_get(const char* key, char* value, const char* default_value) {
28 return len;
29 }
30
31-#if __has_include(<sys/system_properties.h>)
32+#if __has_include(<sys/system_properties.h>) && \
33+ __has_include(<sys/_system_properties.h>)
34
35 #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
36 #include <sys/_system_properties.h>
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0008-adb-GCC-compatibility-fixes-for-usb_linux-and-sysdep.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0008-adb-GCC-compatibility-fixes-for-usb_linux-and-sysdep.patch
new file mode 100644
index 0000000000..ae7de97e49
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/0008-adb-GCC-compatibility-fixes-for-usb_linux-and-sysdep.patch
@@ -0,0 +1,197 @@
1From 67a400310c07fad8f9ecc0058203942237ab6325 Mon Sep 17 00:00:00 2001
2From: Etienne Cordonnier <ecordonnier@snap.com>
3Date: Wed, 10 Jun 2026 00:00:00 +0000
4Subject: [PATCH] adb: GCC compatibility fixes for usb_linux, sysdeps, and adbd
5
6GCC-specific issues when building adb/adbd with GCC instead of Clang:
7
81. usb_linux.cpp embeds usbdevfs_urb (which ends in a flexible array member
9 iso_frame_desc[]) in a non-last position inside struct usb_handle. GCC
10 rejects this as a hard error. Introduce usbdevfs_urb_bulk, a copy of the
11 struct without the FAM, for use in embedding contexts.
12
132. sysdeps.h uses #define write/pwrite to redirect callers to adb_write/
14 adb_pwrite. GCC's newer abseil in the native sysroot calls ostream::write()
15 which gets incorrectly macro-expanded. Replace the #define redirects with
16 #pragma GCC poison.
17
183. adbd.mk links -lprotobuf but with protobuf 6.x the abseil log helpers are
19 no longer pulled in transitively. Add -labsl_log_internal_message and
20 -labsl_log_internal_check_op explicitly.
21
22Upstream-Status: Inappropriate [OE-specific, GCC compat]
23
24Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
25---
26 debian/system/adb.mk | 2 ++
27 debian/system/adbd.mk | 2 ++
28 packages/modules/adb/client/usb_linux.cpp | 44 ++++++++++++++++-------
29 packages/modules/adb/sysdeps.h | 11 ++----
30 4 files changed, 37 insertions(+), 22 deletions(-)
31
32diff --git a/debian/system/adb.mk b/debian/system/adb.mk
33index 90a816f..6c9b4ce 100644
34--- a/debian/system/adb.mk
35+++ b/debian/system/adb.mk
36@@ -95,6 +95,8 @@ LDFLAGS += \
37 -llog \
38 -llz4 \
39 -lprotobuf \
40+ -labsl_log_internal_message \
41+ -labsl_log_internal_check_op \
42 -lpthread \
43 -l:libssl.so.0 \
44 -lusb-1.0 \
45diff --git a/debian/system/adbd.mk b/debian/system/adbd.mk
46index beb412e..e755f20 100644
47--- a/debian/system/adbd.mk
48+++ b/debian/system/adbd.mk
49@@ -97,6 +97,8 @@ LDFLAGS += \
50 -llog \
51 -llz4 \
52 -lprotobuf \
53+ -labsl_log_internal_message \
54+ -labsl_log_internal_check_op \
55 -lresolv \
56 -l:libssl.so.0 \
57 -lzstd \
58diff --git a/packages/modules/adb/client/usb_linux.cpp b/packages/modules/adb/client/usb_linux.cpp
59index 96d7a8a..ecc1035 100644
60--- a/packages/modules/adb/client/usb_linux.cpp
61+++ b/packages/modules/adb/client/usb_linux.cpp
62@@ -57,6 +57,27 @@ using namespace std::literals;
63 /* usb scan debugging is waaaay too verbose */
64 #define DBGX(x...)
65
66+// usbdevfs_urb embeds a flexible array member iso_frame_desc[]. Embedding this
67+// struct in another struct in a non-last position is a hard GCC error. Since
68+// ADB only uses bulk endpoints (never ISO), define a wrapper type without the
69+// FAM to use for struct embedding.
70+struct usbdevfs_urb_bulk {
71+ unsigned char type;
72+ unsigned char endpoint;
73+ int status;
74+ unsigned int flags;
75+ void* buffer;
76+ int buffer_length;
77+ int actual_length;
78+ int start_frame;
79+ union { int number_of_packets; unsigned int stream_id; };
80+ int error_count;
81+ unsigned int signr;
82+ void* usercontext;
83+};
84+static_assert(sizeof(usbdevfs_urb_bulk) == sizeof(usbdevfs_urb),
85+ "usbdevfs_urb_bulk size mismatch");
86+
87 struct usb_handle {
88 ~usb_handle() {
89 if (fd != -1) unix_close(fd);
90@@ -74,11 +95,8 @@ struct usb_handle {
91 // The usbdevfs_urb structure ends in a variable length array of
92 // usbdevfs_iso_packet_desc. Since none of the usb calls ever attempt
93 // to fill in those values, ignore this warning.
94-#pragma clang diagnostic push
95-#pragma clang diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
96- usbdevfs_urb urb_in;
97- usbdevfs_urb urb_out;
98-#pragma clang diagnostic pop
99+ usbdevfs_urb_bulk urb_in;
100+ usbdevfs_urb_bulk urb_out;
101
102 bool urb_in_busy = false;
103 bool urb_out_busy = false;
104@@ -316,7 +334,7 @@ static int usb_bulk_write(usb_handle* h, const void* data, int len) {
105 std::unique_lock<std::mutex> lock(h->mutex);
106 D("++ usb_bulk_write ++");
107
108- usbdevfs_urb* urb = &h->urb_out;
109+ usbdevfs_urb_bulk* urb = &h->urb_out;
110 memset(urb, 0, sizeof(*urb));
111 urb->type = USBDEVFS_URB_TYPE_BULK;
112 urb->endpoint = h->ep_out;
113@@ -329,7 +347,7 @@ static int usb_bulk_write(usb_handle* h, const void* data, int len) {
114 return -1;
115 }
116
117- if (TEMP_FAILURE_RETRY(ioctl(h->fd, USBDEVFS_SUBMITURB, urb)) == -1) {
118+ if (TEMP_FAILURE_RETRY(ioctl(h->fd, USBDEVFS_SUBMITURB, reinterpret_cast<usbdevfs_urb*>(urb))) == -1) {
119 return -1;
120 }
121
122@@ -355,7 +373,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) {
123 std::unique_lock<std::mutex> lock(h->mutex);
124 D("++ usb_bulk_read ++");
125
126- usbdevfs_urb* urb = &h->urb_in;
127+ usbdevfs_urb_bulk* urb = &h->urb_in;
128 memset(urb, 0, sizeof(*urb));
129 urb->type = USBDEVFS_URB_TYPE_BULK;
130 urb->endpoint = h->ep_in;
131@@ -368,7 +386,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) {
132 return -1;
133 }
134
135- if (TEMP_FAILURE_RETRY(ioctl(h->fd, USBDEVFS_SUBMITURB, urb)) == -1) {
136+ if (TEMP_FAILURE_RETRY(ioctl(h->fd, USBDEVFS_SUBMITURB, reinterpret_cast<usbdevfs_urb*>(urb))) == -1) {
137 return -1;
138 }
139
140@@ -400,7 +418,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) {
141 }
142 D("[ urb @%p status = %d, actual = %d ]", out, out->status, out->actual_length);
143
144- if (out == &h->urb_in) {
145+ if (out == reinterpret_cast<usbdevfs_urb*>(&h->urb_in)) {
146 D("[ reap urb - IN complete ]");
147 h->urb_in_busy = false;
148 if (urb->status != 0) {
149@@ -409,7 +427,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) {
150 }
151 return urb->actual_length;
152 }
153- if (out == &h->urb_out) {
154+ if (out == reinterpret_cast<usbdevfs_urb*>(&h->urb_out)) {
155 D("[ reap urb - OUT compelete ]");
156 h->urb_out_busy = false;
157 h->cv.notify_all();
158@@ -513,8 +531,8 @@ void usb_kick(usb_handle* h) {
159 ** but this ensures that a reader blocked on REAPURB
160 ** will get unblocked
161 */
162- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_in);
163- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_out);
164+ ioctl(h->fd, USBDEVFS_DISCARDURB, reinterpret_cast<usbdevfs_urb*>(&h->urb_in));
165+ ioctl(h->fd, USBDEVFS_DISCARDURB, reinterpret_cast<usbdevfs_urb*>(&h->urb_out));
166 h->urb_in.status = -ENODEV;
167 h->urb_out.status = -ENODEV;
168 h->urb_in_busy = false;
169diff --git a/packages/modules/adb/sysdeps.h b/packages/modules/adb/sysdeps.h
170index 9a99295..b364a47 100644
171--- a/packages/modules/adb/sysdeps.h
172+++ b/packages/modules/adb/sysdeps.h
173@@ -141,11 +141,7 @@ static inline int unix_read(borrowed_fd fd, void* buf, size_t len) {
174 static inline int unix_write(borrowed_fd fd, const void* buf, size_t len) {
175 return write(fd.get(), buf, len);
176 }
177-#undef write
178-#define write ___xxx_write
179-
180-#undef pwrite
181-#define pwrite ___xxx_pwrite
182+// (write and pwrite macros omitted: incompatible with GCC/abseil compat)
183
184 // See the comments for the !defined(_WIN32) version of unix_lseek().
185 static inline int unix_lseek(borrowed_fd fd, int pos, int where) {
186@@ -549,10 +545,7 @@ static inline int adb_pwrite(int fd, const void* buf, size_t len, off64_t offset
187 #endif
188 }
189
190-#undef write
191-#define write ___xxx_write
192-#undef pwrite
193-#define pwrite ___xxx_pwrite
194+// (write and pwrite macros omitted: incompatible with GCC/abseil compat)
195
196 static inline int64_t adb_lseek(borrowed_fd fd, int64_t pos, int where) {
197 #if defined(__APPLE__)
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0009-libbase-include-stdint.h-in-hex.cpp.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0009-libbase-include-stdint.h-in-hex.cpp.patch
new file mode 100644
index 0000000000..179f97363f
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/0009-libbase-include-stdint.h-in-hex.cpp.patch
@@ -0,0 +1,26 @@
1From 164b4261fd5abd851a432c7d56280b1b1adc7f2b Mon Sep 17 00:00:00 2001
2From: Etienne Cordonnier <ecordonnier@snap.com>
3Date: Wed, 10 Jun 2026 00:00:00 +0000
4Subject: [PATCH] libbase: include stdint.h in hex.cpp
5
6hex.cpp uses uint8_t but neither the file nor its transitive headers
7always pull in <stdint.h> on every sysroot. Add an explicit include.
8
9Upstream-Status: Inappropriate [OE-specific sysroot compat]
10Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
11---
12 system/libbase/hex.cpp | 1 +
13 1 file changed, 1 insertion(+)
14
15diff --git a/system/libbase/hex.cpp b/system/libbase/hex.cpp
16index a4b7715..857ff29 100644
17--- a/system/libbase/hex.cpp
18+++ b/system/libbase/hex.cpp
19@@ -15,6 +15,7 @@
20 */
21
22 #include "android-base/hex.h"
23+#include <stdint.h>
24
25 #include "android-base/logging.h"
26
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0010-adbd-make-systemd-sd_notify-conditional-on-HAVE_SYSTEMD.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0010-adbd-make-systemd-sd_notify-conditional-on-HAVE_SYSTEMD.patch
new file mode 100644
index 0000000000..a8c16a41d4
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/0010-adbd-make-systemd-sd_notify-conditional-on-HAVE_SYSTEMD.patch
@@ -0,0 +1,54 @@
1From 8874be8b9a3906c5720d75320b176b51523b6c15 Mon Sep 17 00:00:00 2001
2From: Etienne Cordonnier <ecordonnier@snap.com>
3Date: Fri, 12 Jun 2026 15:54:47 +0200
4Subject: [PATCH] adbd: make systemd sd_notify conditional on HAVE_SYSTEMD
5
6Guard the sd-daemon.h include and sd_notify() call behind HAVE_SYSTEMD
7instead of __linux__, so the feature is opt-in via a recipe PACKAGECONFIG.
8Add a corresponding ifeq block in debian/system/adbd.mk to pass
9-DHAVE_SYSTEMD and -lsystemd only when the flag is set.
10
11Upstream-Status: Inappropriate [OE-specific]
12---
13 debian/system/adbd.mk | 5 +++++
14 packages/modules/adb/daemon/main.cpp | 4 ++--
15 2 files changed, 7 insertions(+), 2 deletions(-)
16
17diff --git a/debian/system/adbd.mk b/debian/system/adbd.mk
18index e755f20..a3f88f1 100644
19--- a/debian/system/adbd.mk
20+++ b/debian/system/adbd.mk
21@@ -104,6 +104,11 @@ LDFLAGS += \
22 -lzstd \
23 -pie \
24
25+ifeq ($(HAVE_SYSTEMD),1)
26+LDFLAGS += -lsystemd
27+CPPFLAGS += -DHAVE_SYSTEMD
28+endif
29+
30 STATIC_LIBS = \
31 debian/out/system/libadb.a \
32 debian/out/system/libcrypto_utils.a \
33diff --git a/packages/modules/adb/daemon/main.cpp b/packages/modules/adb/daemon/main.cpp
34index f177abf..789c25b 100644
35--- a/packages/modules/adb/daemon/main.cpp
36+++ b/packages/modules/adb/daemon/main.cpp
37@@ -49,7 +49,7 @@
38 #include "selinux/android.h"
39 #endif
40
41-#if defined(__linux__)
42+#if defined(HAVE_SYSTEMD)
43 #include <systemd/sd-daemon.h>
44 #endif
45
46@@ -365,7 +365,7 @@ int adbd_main(int server_port) {
47 init_jdwp();
48 D("adbd_main(): post init_jdwp()");
49
50-#if defined(__linux__)
51+#if defined(HAVE_SYSTEMD)
52 sd_notify(1, "READY=1");
53 #endif
54
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/adb.mk b/meta-oe/recipes-devtools/android-tools/android-tools/adb.mk
deleted file mode 100644
index 0687c22c17..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/adb.mk
+++ /dev/null
@@ -1,72 +0,0 @@
1# Makefile for adb
2
3SRCDIR ?= $(S)
4
5VPATH += $(SRCDIR)/system/core/adb
6adb_SRC_FILES += adb.c
7adb_SRC_FILES += console.c
8adb_SRC_FILES += transport.c
9adb_SRC_FILES += transport_local.c
10adb_SRC_FILES += transport_usb.c
11adb_SRC_FILES += commandline.c
12adb_SRC_FILES += adb_client.c
13adb_SRC_FILES += adb_auth_host.c
14adb_SRC_FILES += sockets.c
15adb_SRC_FILES += services.c
16adb_SRC_FILES += file_sync_client.c
17adb_SRC_FILES += get_my_path_linux.c
18adb_SRC_FILES += usb_linux.c
19adb_SRC_FILES += usb_vendors.c
20adb_SRC_FILES += fdevent.c
21adb_OBJS := $(adb_SRC_FILES:.c=.o)
22
23VPATH += $(SRCDIR)/system/core/libcutils
24libcutils_SRC_FILES += atomic.c
25libcutils_SRC_FILES += hashmap.c
26libcutils_SRC_FILES += native_handle.c
27libcutils_SRC_FILES += config_utils.c
28libcutils_SRC_FILES += cpu_info.c
29libcutils_SRC_FILES += load_file.c
30# libcutils_SRC_FILES += open_memstream.c
31# libcutils_SRC_FILES += strdup16to8.c
32# libcutils_SRC_FILES += strdup8to16.c
33# libcutils_SRC_FILES += record_stream.c
34# libcutils_SRC_FILES += process_name.c
35# libcutils_SRC_FILES += threads.c
36# libcutils_SRC_FILES += sched_policy.c
37# libcutils_SRC_FILES += iosched_policy.c
38libcutils_SRC_FILES += str_parms.c
39libcutils_SRC_FILES += fs.c
40libcutils_SRC_FILES += multiuser.c
41libcutils_SRC_FILES += socket_inaddr_any_server.c
42libcutils_SRC_FILES += socket_local_client.c
43libcutils_SRC_FILES += socket_local_server.c
44libcutils_SRC_FILES += socket_loopback_client.c
45libcutils_SRC_FILES += socket_loopback_server.c
46libcutils_SRC_FILES += socket_network_client.c
47libcutils_SRC_FILES += sockets.c
48libcutils_SRC_FILES += ashmem-host.c
49libcutils_SRC_FILES += dlmalloc_stubs.c
50libcutils_OBJS := $(libcutils_SRC_FILES:.c=.o)
51
52CFLAGS += -DANDROID
53CFLAGS += -DWORKAROUND_BUG6558362
54CFLAGS += -DADB_HOST=1
55CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
56CFLAGS += -DANDROID_SMP=0
57CFLAGS += -I$(SRCDIR)/system/core/adb
58CFLAGS += -I$(SRCDIR)/system/core/include
59CFLAGS += -include $(SRCDIR)/build/core/combo/include/arch/$(android_arch)/AndroidConfig.h
60
61LIBS += libcutils.a -lpthread -lcrypto
62
63all: adb
64
65adb: libcutils.a $(adb_OBJS)
66 $(CC) -o $@ $(LDFLAGS) $(adb_OBJS) $(LIBS)
67
68libcutils.a: $(libcutils_OBJS)
69 $(AR) rcs $@ $(libcutils_OBJS)
70
71clean:
72 $(RM) $(adb_OBJS) $(libcutils_OBJS) adb *.a
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/adbd.mk b/meta-oe/recipes-devtools/android-tools/android-tools/adbd.mk
deleted file mode 100644
index 31452ae104..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/adbd.mk
+++ /dev/null
@@ -1,164 +0,0 @@
1# Makefile for adbd
2
3SRCDIR ?= $(S)
4
5VPATH += $(SRCDIR)/system/core/adb
6adbd_SRC_FILES += adb.c
7adbd_SRC_FILES += fdevent.c
8adbd_SRC_FILES += transport.c
9adbd_SRC_FILES += transport_local.c
10adbd_SRC_FILES += transport_usb.c
11adbd_SRC_FILES += adb_auth_client.c
12adbd_SRC_FILES += sockets.c
13adbd_SRC_FILES += services.c
14adbd_SRC_FILES += file_sync_service.c
15adbd_SRC_FILES += jdwp_service.c
16adbd_SRC_FILES += framebuffer_service.c
17adbd_SRC_FILES += remount_service.c
18adbd_SRC_FILES += disable_verity_service.c
19adbd_SRC_FILES += base64.c
20adbd_SRC_FILES += usb_linux_client.c
21adbd_OBJS := $(adbd_SRC_FILES:.c=.o)
22
23VPATH += $(SRCDIR)/system/core/liblog
24liblog_SRC_FILES += logd_write.c
25liblog_SRC_FILES += log_event_write.c
26liblog_SRC_FILES += logprint.c
27liblog_SRC_FILES += event_tag_map.c
28liblog_SRC_FILES += fake_log_device.c
29liblog_OBJS := $(liblog_SRC_FILES:.c=.o)
30
31VPATH += $(SRCDIR)/system/core/fs_mgr
32fs_mgr_SRC_FILES += fs_mgr_fstab.c
33fs_mgr_OBJS := $(fs_mgr_SRC_FILES:.c=.o)
34
35VPATH += $(SRCDIR)/system/core/libcutils
36libcutils_SRC_FILES += atomic.c
37libcutils_SRC_FILES += hashmap.c
38libcutils_SRC_FILES += native_handle.c
39libcutils_SRC_FILES += config_utils.c
40libcutils_SRC_FILES += cpu_info.c
41libcutils_SRC_FILES += load_file.c
42# libcutils_SRC_FILES += open_memstream.c
43# libcutils_SRC_FILES += strdup16to8.c
44# libcutils_SRC_FILES += strdup8to16.c
45# libcutils_SRC_FILES += record_stream.c
46# libcutils_SRC_FILES += process_name.c
47# libcutils_SRC_FILES += threads.c
48# libcutils_SRC_FILES += sched_policy.c
49# libcutils_SRC_FILES += iosched_policy.c
50libcutils_SRC_FILES += str_parms.c
51libcutils_SRC_FILES += fs.c
52libcutils_SRC_FILES += multiuser.c
53libcutils_SRC_FILES += socket_inaddr_any_server.c
54libcutils_SRC_FILES += socket_local_client.c
55libcutils_SRC_FILES += socket_local_server.c
56libcutils_SRC_FILES += socket_loopback_client.c
57libcutils_SRC_FILES += socket_loopback_server.c
58libcutils_SRC_FILES += socket_network_client.c
59libcutils_SRC_FILES += sockets.c
60libcutils_SRC_FILES += ashmem-host.c
61libcutils_SRC_FILES += dlmalloc_stubs.c
62libcutils_SRC_FILES += klog.c
63libcutils_SRC_FILES += properties.c
64libcutils_OBJS := $(libcutils_SRC_FILES:.c=.o)
65
66VPATH += $(SRCDIR)/external/libselinux/src
67libselinux_SRC_FILES += booleans.c
68libselinux_SRC_FILES += canonicalize_context.c
69libselinux_SRC_FILES += disable.c
70libselinux_SRC_FILES += enabled.c
71libselinux_SRC_FILES += fgetfilecon.c
72libselinux_SRC_FILES += fsetfilecon.c
73libselinux_SRC_FILES += getenforce.c
74libselinux_SRC_FILES += getfilecon.c
75libselinux_SRC_FILES += getpeercon.c
76libselinux_SRC_FILES += lgetfilecon.c
77libselinux_SRC_FILES += load_policy.c
78libselinux_SRC_FILES += lsetfilecon.c
79libselinux_SRC_FILES += policyvers.c
80libselinux_SRC_FILES += procattr.c
81libselinux_SRC_FILES += setenforce.c
82libselinux_SRC_FILES += setfilecon.c
83libselinux_SRC_FILES += context.c
84libselinux_SRC_FILES += mapping.c
85libselinux_SRC_FILES += stringrep.c
86libselinux_SRC_FILES += compute_create.c
87libselinux_SRC_FILES += compute_av.c
88libselinux_SRC_FILES += avc.c
89libselinux_SRC_FILES += avc_internal.c
90libselinux_SRC_FILES += avc_sidtab.c
91libselinux_SRC_FILES += get_initial_context.c
92libselinux_SRC_FILES += checkAccess.c
93libselinux_SRC_FILES += sestatus.c
94libselinux_SRC_FILES += deny_unknown.c
95
96libselinux_SRC_FILES += callbacks.c
97libselinux_SRC_FILES += check_context.c
98libselinux_SRC_FILES += freecon.c
99libselinux_SRC_FILES += init.c
100libselinux_SRC_FILES += label.c
101libselinux_SRC_FILES += label_file.c
102libselinux_SRC_FILES += label_android_property.c
103libselinux_OBJS := $(libselinux_SRC_FILES:.c=.o)
104
105VPATH += $(SRCDIR)/system/extras/ext4_utils
106libext4_utils_SRC_FILES += make_ext4fs.c
107libext4_utils_SRC_FILES += ext4fixup.c
108libext4_utils_SRC_FILES += ext4_utils.c
109libext4_utils_SRC_FILES += allocate.c
110libext4_utils_SRC_FILES += contents.c
111libext4_utils_SRC_FILES += extent.c
112libext4_utils_SRC_FILES += indirect.c
113libext4_utils_SRC_FILES += uuid.c
114libext4_utils_SRC_FILES += sha1.c
115libext4_utils_SRC_FILES += wipe.c
116libext4_utils_SRC_FILES += crc16.c
117libext4_utils_SRC_FILES += ext4_sb.c
118libext4_utils_OBJS := $(libext4_utils_SRC_FILES:.c=.o)
119
120CFLAGS += -std=gnu11
121CFLAGS += -DANDROID
122CFLAGS += -DADB_HOST=0
123CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
124CFLAGS += -DALLOW_ADBD_ROOT=1
125CFLAGS += -DALLOW_ADBD_DISABLE_VERITY=1
126CFLAGS += -DPROP_NAME_MAX=32
127CFLAGS += -DPROP_VALUE_MAX=92
128CFLAGS += -DAUDITD_LOG_TAG=1003
129# CFLAGS += -DHOST
130CFLAGS += -DANDROID_SMP=0
131CFLAGS += -I$(SRCDIR)/system/core/adb
132CFLAGS += -I$(SRCDIR)/system/core/include
133CFLAGS += -I$(SRCDIR)/system/core/libsparse/include
134CFLAGS += -I$(SRCDIR)/system/extras/ext4_utils
135CFLAGS += -I$(SRCDIR)/system/core/fs_mgr/include
136CFLAGS += -I$(SRCDIR)/hardware/libhardware/include
137CFLAGS += -I$(SRCDIR)/external/libselinux/include
138CFLAGS += -include $(SRCDIR)/build/core/combo/include/arch/$(android_arch)/AndroidConfig.h
139
140LIBS += liblog.a libfs_mgr.a libcutils.a libselinux.a libext4_utils.a -lpthread -lbsd -lpcre -lresolv -lcrypto
141
142all: adbd
143
144adbd: liblog.a libfs_mgr.a libcutils.a libselinux.a libext4_utils.a $(adbd_OBJS)
145 $(CC) -o $@ $(LDFLAGS) $(adbd_OBJS) $(LIBS)
146
147liblog.a: $(liblog_OBJS)
148 $(AR) rcs $@ $(liblog_OBJS)
149
150libfs_mgr.a: $(fs_mgr_OBJS)
151 $(AR) rcs $@ $(fs_mgr_OBJS)
152
153libcutils.a: $(libcutils_OBJS)
154 $(AR) rcs $@ $(libcutils_OBJS)
155
156libselinux.a: $(libselinux_OBJS)
157 export CFLAGS="-DANDROID -DHOST"
158 $(AR) rcs $@ $(libselinux_OBJS)
159
160libext4_utils.a: $(libext4_utils_OBJS)
161 $(AR) rcs $@ $(libext4_utils_OBJS)
162
163clean:
164 $(RM) *.o *.a adbd
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service b/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service
index b6661f2e39..7c16b5cea2 100644
--- a/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service
@@ -4,7 +4,7 @@ ConditionPathExists=/etc/usb-debugging-enabled
4Before=android-system.service 4Before=android-system.service
5 5
6[Service] 6[Service]
7Type=simple 7Type=notify
8Restart=on-failure 8Restart=on-failure
9ExecStartPre=-/usr/bin/android-gadget-setup adb 9ExecStartPre=-/usr/bin/android-gadget-setup adb
10ExecStart=/usr/bin/adbd 10ExecStart=/usr/bin/adbd
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/build/0001-Riscv-Add-risc-v-Android-config-header.patch b/meta-oe/recipes-devtools/android-tools/android-tools/build/0001-Riscv-Add-risc-v-Android-config-header.patch
deleted file mode 100644
index c091fd404b..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/build/0001-Riscv-Add-risc-v-Android-config-header.patch
+++ /dev/null
@@ -1,361 +0,0 @@
1From 82dce13ea7b5b31c63851bd67f66072413917e73 Mon Sep 17 00:00:00 2001
2From: Chenxi Mao <maochenxi@eswin.com>
3Date: Mon, 20 Apr 2020 15:32:40 +0800
4Subject: [PATCH 1/1] Riscv: Add risc-v Android config header
5
6---
7Upstream-Status: Pending
8
9 .../arch/linux-riscv64/AndroidConfig.h | 340 ++++++++++++++++++
10 1 file changed, 340 insertions(+)
11 create mode 100644 core/combo/include/arch/linux-riscv64/AndroidConfig.h
12
13diff --git a/core/combo/include/arch/linux-riscv64/AndroidConfig.h b/core/combo/include/arch/linux-riscv64/AndroidConfig.h
14new file mode 100644
15index 0000000000..bcbda8f87f
16--- /dev/null
17+++ b/core/combo/include/arch/linux-riscv64/AndroidConfig.h
18@@ -0,0 +1,340 @@
19+/*
20+ * Copyright (C) 2013 The Android Open Source Project
21+ *
22+ * Licensed under the Apache License, Version 2.0 (the "License");
23+ * you may not use this file except in compliance with the License.
24+ * You may obtain a copy of the License at
25+ *
26+ * http://www.apache.org/licenses/LICENSE-2.0
27+ *
28+ * Unless required by applicable law or agreed to in writing, software
29+ * distributed under the License is distributed on an "AS IS" BASIS,
30+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31+ * See the License for the specific language governing permissions and
32+ * limitations under the License.
33+ */
34+
35+/*
36+ * Android config -- "android-aarch64". Used for ARM aarch64 device builds.
37+ */
38+#ifndef _ANDROID_CONFIG_H
39+#define _ANDROID_CONFIG_H
40+
41+/*
42+ * ===========================================================================
43+ * !!! IMPORTANT !!!
44+ * ===========================================================================
45+ *
46+ * This file is included by ALL C/C++ source files. Don't put anything in
47+ * here unless you are absolutely certain it can't go anywhere else.
48+ *
49+ * Any C++ stuff must be wrapped with "#ifdef __cplusplus". Do not use "//"
50+ * comments.
51+ */
52+
53+/*
54+ * Threading model. Choose one:
55+ *
56+ * HAVE_PTHREADS - use the pthreads library.
57+ * HAVE_WIN32_THREADS - use Win32 thread primitives.
58+ * -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX
59+ */
60+#define HAVE_PTHREADS
61+
62+/*
63+ * Do we have pthread_setname_np()?
64+ *
65+ * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
66+ * the same name but different parameters, so we can't use that here.)
67+ */
68+#define HAVE_ANDROID_PTHREAD_SETNAME_NP
69+
70+/*
71+ * Do we have the futex syscall?
72+ */
73+#define HAVE_FUTEX
74+
75+/*
76+ * Process creation model. Choose one:
77+ *
78+ * HAVE_FORKEXEC - use fork() and exec()
79+ * HAVE_WIN32_PROC - use CreateProcess()
80+ */
81+#define HAVE_FORKEXEC
82+
83+/*
84+ * Process out-of-memory adjustment. Set if running on Linux,
85+ * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory
86+ * badness adjustment.
87+ */
88+#define HAVE_OOM_ADJ
89+
90+/*
91+ * IPC model. Choose one:
92+ *
93+ * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget).
94+ * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap).
95+ * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping).
96+ * HAVE_ANDROID_IPC - use Android versions (?, mmap).
97+ */
98+#define HAVE_ANDROID_IPC
99+
100+/*
101+ * Memory-mapping model. Choose one:
102+ *
103+ * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h
104+ * HAVE_WIN32_FILEMAP - use Win32 filemaps
105+ */
106+#define HAVE_POSIX_FILEMAP
107+
108+/*
109+ * Define this if you have <termio.h>
110+ */
111+#define HAVE_TERMIO_H 1
112+
113+/*
114+ * Define this if you have <sys/sendfile.h>
115+ */
116+#define HAVE_SYS_SENDFILE_H 1
117+
118+/*
119+ * Define this if you build against MSVCRT.DLL
120+ */
121+/* #define HAVE_MS_C_RUNTIME */
122+
123+/*
124+ * Define this if you have sys/uio.h
125+ */
126+#define HAVE_SYS_UIO_H 1
127+
128+/*
129+ * Define this if your platforms implements symbolic links
130+ * in its filesystems
131+ */
132+#define HAVE_SYMLINKS
133+
134+/*
135+ * Define this if we have localtime_r().
136+ */
137+/* #define HAVE_LOCALTIME_R 1 */
138+
139+/*
140+ * Define this if we have gethostbyname_r().
141+ */
142+/* #define HAVE_GETHOSTBYNAME_R */
143+
144+/*
145+ * Define this if we have ioctl().
146+ */
147+#define HAVE_IOCTL
148+
149+/*
150+ * Define this if we want to use WinSock.
151+ */
152+/* #define HAVE_WINSOCK */
153+
154+/*
155+ * Define this if have clock_gettime() and friends
156+ */
157+#define HAVE_POSIX_CLOCKS
158+
159+/*
160+ * Define this if we have linux style epoll()
161+ */
162+#define HAVE_EPOLL
163+
164+/*
165+ * Endianness of the target machine. Choose one:
166+ *
167+ * HAVE_ENDIAN_H -- have endian.h header we can include.
168+ * HAVE_LITTLE_ENDIAN -- we are little endian.
169+ * HAVE_BIG_ENDIAN -- we are big endian.
170+ */
171+#define HAVE_ENDIAN_H
172+#define HAVE_LITTLE_ENDIAN
173+
174+#define _FILE_OFFSET_BITS 64
175+/* #define _LARGEFILE_SOURCE 1 */
176+
177+/*
178+ * Define if platform has off64_t (and lseek64 and other xxx64 functions)
179+ */
180+#define HAVE_OFF64_T
181+
182+/*
183+ * Defined if we have the backtrace() call for retrieving a stack trace.
184+ * Needed for CallStack to operate; if not defined, CallStack is
185+ * non-functional.
186+ */
187+#define HAVE_BACKTRACE 0
188+
189+/*
190+ * Defined if we have the cxxabi.h header for demangling C++ symbols. If
191+ * not defined, stack crawls will be displayed with raw mangled symbols
192+ */
193+#define HAVE_CXXABI 0
194+
195+/*
196+ * Defined if we have the gettid() system call.
197+ */
198+#define HAVE_GETTID
199+
200+/*
201+ * Defined if we have the sched_setscheduler() call
202+ */
203+#define HAVE_SCHED_SETSCHEDULER
204+
205+/*
206+ * Add any extra platform-specific defines here.
207+ */
208+#ifndef __linux__
209+#define __linux__
210+#endif
211+
212+/*
213+ * Define if we have <malloc.h> header
214+ */
215+#define HAVE_MALLOC_H
216+
217+/*
218+ * Define if we're running on *our* linux on device or emulator.
219+ */
220+#define HAVE_ANDROID_OS 1
221+
222+/*
223+ * Define if we have Linux-style non-filesystem Unix Domain Sockets
224+ */
225+#define HAVE_LINUX_LOCAL_SOCKET_NAMESPACE 1
226+
227+/*
228+ * Define if we have Linux's inotify in <sys/inotify.h>.
229+ */
230+#define HAVE_INOTIFY 1
231+
232+/*
233+ * Define if we have madvise() in <sys/mman.h>
234+ */
235+#define HAVE_MADVISE 1
236+
237+/*
238+ * Define if tm struct has tm_gmtoff field
239+ */
240+#define HAVE_TM_GMTOFF 1
241+
242+/*
243+ * Define if dirent struct has d_type field
244+ */
245+#define HAVE_DIRENT_D_TYPE 1
246+
247+/*
248+ * Define if libc includes Android system properties implementation.
249+ */
250+#define HAVE_LIBC_SYSTEM_PROPERTIES 1
251+
252+/*
253+ * Define if system provides a system property server (should be
254+ * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES).
255+ */
256+/* #define HAVE_SYSTEM_PROPERTY_SERVER */
257+
258+/*
259+ * What CPU architecture does this platform use?
260+ */
261+#define ARCH_AARCH64
262+
263+/*
264+ * Define if the size of enums is as short as possible,
265+ */
266+/* #define HAVE_SHORT_ENUMS */
267+
268+/*
269+ * sprintf() format string for shared library naming.
270+ */
271+#define OS_SHARED_LIB_FORMAT_STR "lib%s.so"
272+
273+/*
274+ * type for the third argument to mincore().
275+ */
276+#define MINCORE_POINTER_TYPE unsigned char *
277+
278+/*
279+ * The default path separator for the platform
280+ */
281+#define OS_PATH_SEPARATOR '/'
282+
283+/*
284+ * Is the filesystem case sensitive?
285+ */
286+#define OS_CASE_SENSITIVE
287+
288+/*
289+ * Define if <sys/socket.h> exists.
290+ */
291+#define HAVE_SYS_SOCKET_H 1
292+
293+/*
294+ * Define if the strlcpy() function exists on the system.
295+ */
296+#define HAVE_STRLCPY 1
297+
298+/*
299+ * Define if the open_memstream() function exists on the system.
300+ */
301+/* #define HAVE_OPEN_MEMSTREAM 1 */
302+
303+/*
304+ * Define if the BSD funopen() function exists on the system.
305+ */
306+#define HAVE_FUNOPEN 1
307+
308+/*
309+ * Define if prctl() exists
310+ */
311+#define HAVE_PRCTL 1
312+
313+/*
314+ * Define if writev() exists
315+ */
316+#define HAVE_WRITEV 1
317+
318+/*
319+ * Define if <stdint.h> exists.
320+ */
321+#define HAVE_STDINT_H 1
322+
323+/*
324+ * Define if <stdbool.h> exists.
325+ */
326+#define HAVE_STDBOOL_H 1
327+
328+/*
329+ * Define if <sched.h> exists.
330+ */
331+#define HAVE_SCHED_H 1
332+
333+/*
334+ * Define if pread() exists
335+ */
336+#define HAVE_PREAD 1
337+
338+/*
339+ * Define if we have st_mtim in struct stat
340+ */
341+#define HAVE_STAT_ST_MTIM 1
342+
343+/*
344+ * Define if printf() supports %zd for size_t arguments
345+ */
346+#define HAVE_PRINTF_ZD 1
347+
348+/*
349+ * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
350+ */
351+#define HAVE_BSD_QSORT_R 0
352+
353+/*
354+ * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
355+ */
356+#define HAVE_GNU_QSORT_R 0
357+
358+#endif /* _ANDROID_CONFIG_H */
359--
3602.17.1
361
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-adb-remove-selinux-extensions.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-adb-remove-selinux-extensions.patch
deleted file mode 100644
index 7d20c50680..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-adb-remove-selinux-extensions.patch
+++ /dev/null
@@ -1,44 +0,0 @@
1From 7b7200727413ca4a9bb132221c543ec033dffafa Mon Sep 17 00:00:00 2001
2From: Sergio Schvezov <sergio.schvezov@canonical.com>
3Date: Wed, 7 Sep 2016 12:58:47 +0300
4Subject: [PATCH] adb: remove selinux extensions
5
6* drop useless includes of Android SELINUX extensions
7* avoids having to clone another module
8* this should be sent upstream
9
10Upstream-Status: Inappropriate
11
12Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
13---
14 adb/file_sync_service.c | 3 ---
15 1 file changed, 3 deletions(-)
16
17diff --git a/adb/file_sync_service.c b/adb/file_sync_service.c
18index 7933858516..3cbd0cd863 100644
19--- a/adb/file_sync_service.c
20+++ b/adb/file_sync_service.c
21@@ -26,7 +26,6 @@
22
23 #include <errno.h>
24 #include <private/android_filesystem_config.h>
25-#include <selinux/android.h>
26 #include "sysdeps.h"
27
28 #define TRACE_TAG TRACE_SYNC
29@@ -73,7 +72,6 @@ static int mkdirs(char *name)
30 *x = '/';
31 return ret;
32 }
33- selinux_android_restorecon(name, 0);
34 }
35 *x++ = '/';
36 }
37@@ -251,7 +249,6 @@ static int handle_send_file(int s, char *path, uid_t uid,
38 if(fd >= 0) {
39 struct utimbuf u;
40 adb_close(fd);
41- selinux_android_restorecon(path, 0);
42 u.actime = timestamp;
43 u.modtime = timestamp;
44 utime(path, &u);
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-memory.h-Always-define-strlcpy-for-glibc-based-syste.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-memory.h-Always-define-strlcpy-for-glibc-based-syste.patch
deleted file mode 100644
index 82e97152be..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0001-memory.h-Always-define-strlcpy-for-glibc-based-syste.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1From db3a3714be07c8ab51b9ae7b035e4afe9f39c645 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 7 Sep 2022 13:20:22 -0700
4Subject: [PATCH] memory.h: Always define strlcpy for glibc based systems
5
6android-config.h file includes on compiler cmdline sets HAVE_STRLCPY
7unconditionally, since bionic supports it, its no big deal on android
8and also no problem when using musl since implementation exists for musl
9too, but glibc does not provide this. So either we include libbsd or use
10the implementation provided by android-tools here. We are currently
11using the in tree implementation for systems which do not provide it
12
13Upstream-Status: Pending
14
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 include/cutils/memory.h | 2 +-
18 1 file changed, 1 insertion(+), 1 deletion(-)
19
20diff --git a/include/cutils/memory.h b/include/cutils/memory.h
21index e725cdd032..9e99353c58 100644
22--- a/include/cutils/memory.h
23+++ b/include/cutils/memory.h
24@@ -30,7 +30,7 @@ void android_memset16(uint16_t* dst, uint16_t value, size_t size);
25 /* size is given in bytes and must be multiple of 4 */
26 void android_memset32(uint32_t* dst, uint32_t value, size_t size);
27
28-#if !HAVE_STRLCPY
29+#if !HAVE_STRLCPY || defined(__GLIBC__)
30 /* Declaration of strlcpy() for platforms that don't already have it. */
31 size_t strlcpy(char *dst, const char *src, size_t size);
32 #endif
33--
342.37.3
35
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0002-adb-Use-local-sockets-where-appropriate.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0002-adb-Use-local-sockets-where-appropriate.patch
deleted file mode 100644
index 3627110ad8..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0002-adb-Use-local-sockets-where-appropriate.patch
+++ /dev/null
@@ -1,70 +0,0 @@
1From d855f042ca09a358cebe2d3c1d29d512afd7ebb8 Mon Sep 17 00:00:00 2001
2From: Hilko Bengen <bengen@debian.org>
3Date: Wed, 7 Sep 2016 12:58:47 +0300
4Subject: [PATCH] adb: Use local sockets where appropriate
5
6Upstream-Status: Inappropriate
7---
8 adb/adb.c | 6 +++++-
9 adb/adb_client.c | 5 +++--
10 adb/transport_local.c | 3 ++-
11 3 files changed, 10 insertions(+), 4 deletions(-)
12
13diff --git a/adb/adb.c b/adb/adb.c
14index 10a1e0da26..027edd9359 100644
15--- a/adb/adb.c
16+++ b/adb/adb.c
17@@ -1230,7 +1230,11 @@ int launch_server(int server_port)
18 */
19 void build_local_name(char* target_str, size_t target_size, int server_port)
20 {
21- snprintf(target_str, target_size, "tcp:%d", server_port);
22+ if (gListenAll > 0) {
23+ snprintf(target_str, target_size, "tcp:%d", server_port);
24+ } else {
25+ snprintf(target_str, target_size, "local:%d", server_port);
26+ }
27 }
28
29 #if !ADB_HOST
30diff --git a/adb/adb_client.c b/adb/adb_client.c
31index eb1720d22c..a383faefe3 100644
32--- a/adb/adb_client.c
33+++ b/adb/adb_client.c
34@@ -185,12 +185,12 @@ int _adb_connect(const char *service)
35 strcpy(__adb_error, "service name too long");
36 return -1;
37 }
38- snprintf(tmp, sizeof tmp, "%04x", len);
39+ snprintf(tmp, sizeof tmp, "%d", __adb_server_port);
40
41 if (__adb_server_name)
42 fd = socket_network_client(__adb_server_name, __adb_server_port, SOCK_STREAM);
43 else
44- fd = socket_loopback_client(__adb_server_port, SOCK_STREAM);
45+ fd = socket_local_client(tmp, ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
46
47 if(fd < 0) {
48 strcpy(__adb_error, "cannot connect to daemon");
49@@ -201,6 +201,7 @@ int _adb_connect(const char *service)
50 return -1;
51 }
52
53+ snprintf(tmp, sizeof tmp, "%04x", len);
54 if(writex(fd, tmp, 4) || writex(fd, service, len)) {
55 strcpy(__adb_error, "write failure during connection");
56 adb_close(fd);
57diff --git a/adb/transport_local.c b/adb/transport_local.c
58index 948cc15812..71582a8c88 100644
59--- a/adb/transport_local.c
60+++ b/adb/transport_local.c
61@@ -121,7 +121,8 @@ int local_connect_arbitrary_ports(int console_port, int adb_port)
62 }
63 #endif
64 if (fd < 0) {
65- fd = socket_loopback_client(adb_port, SOCK_STREAM);
66+ snprintf(buf, sizeof buf, "%d", adb_port);
67+ fd = socket_local_client(buf, ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
68 }
69
70 if (fd >= 0) {
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0003-adb-define-shell-command.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0003-adb-define-shell-command.patch
deleted file mode 100644
index cf1d9cbc3d..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0003-adb-define-shell-command.patch
+++ /dev/null
@@ -1,29 +0,0 @@
1From 4421c2e19946dcd651fd8ac022b96627fc526149 Mon Sep 17 00:00:00 2001
2From: Fathi Boudra <fabo@debian.org>
3Date: Wed, 7 Sep 2016 12:58:47 +0300
4Subject: [PATCH] adb: define shell command
5
6we intend to run on Linux system so the shell is always /bin/sh,
7for the host or the target.
8
9Upstream-Status: Inappropriate
10---
11 adb/services.c | 4 ----
12 1 file changed, 4 deletions(-)
13
14diff --git a/adb/services.c b/adb/services.c
15index 21b08dc201..d44b0c5068 100644
16--- a/adb/services.c
17+++ b/adb/services.c
18@@ -299,11 +299,7 @@ static int create_subproc_raw(const char *cmd, const char *arg0, const char *arg
19 }
20 #endif /* !ABD_HOST */
21
22-#if ADB_HOST
23 #define SHELL_COMMAND "/bin/sh"
24-#else
25-#define SHELL_COMMAND "/system/bin/sh"
26-#endif
27
28 #if !ADB_HOST
29 static void subproc_waiter_service(int fd, void *cookie)
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0004-adb-Fix-build-on-big-endian-systems.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0004-adb-Fix-build-on-big-endian-systems.patch
deleted file mode 100644
index 7f03cd2beb..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0004-adb-Fix-build-on-big-endian-systems.patch
+++ /dev/null
@@ -1,47 +0,0 @@
1From 548b8ca62c64a16305929e2eaf3d546d48de9c25 Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3Date: Tue, 21 Feb 2017 19:46:24 +0100
4Subject: [PATCH] adb: Fix build on big endian systems
5
6The usb_linux_client.c file defines cpu_to_le16/32 by using the C
7library htole16/32 function calls. However, cpu_to_le16/32 are used
8when initializing structures, i.e in a context where a function call
9is not allowed.
10
11It works fine on little endian systems because htole16/32 are defined
12by the C library as no-ops. But on big-endian systems, they are
13actually doing something, which might involve calling a function,
14causing build failures.
15
16To solve this, we simply open-code cpu_to_le16/32 in a way that allows
17them to be used when initializing structures.
18
19Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
20---
21Upstream-Status: Pending
22
23 adb/usb_linux_client.c | 11 +++++++++--
24 1 file changed, 9 insertions(+), 2 deletions(-)
25
26diff --git a/adb/usb_linux_client.c b/adb/usb_linux_client.c
27index 8426e0ea14..6e8b5bbbd2 100644
28--- a/adb/usb_linux_client.c
29+++ b/adb/usb_linux_client.c
30@@ -34,8 +34,15 @@
31 #define MAX_PACKET_SIZE_FS 64
32 #define MAX_PACKET_SIZE_HS 512
33
34-#define cpu_to_le16(x) htole16(x)
35-#define cpu_to_le32(x) htole32(x)
36+#if __BYTE_ORDER == __LITTLE_ENDIAN
37+# define cpu_to_le16(x) (x)
38+# define cpu_to_le32(x) (x)
39+#else
40+# define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
41+# define cpu_to_le32(x) \
42+ ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
43+ (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
44+#endif
45
46 struct usb_handle
47 {
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0005-adb-add-base64-implementation.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0005-adb-add-base64-implementation.patch
deleted file mode 100644
index 4827ffe042..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0005-adb-add-base64-implementation.patch
+++ /dev/null
@@ -1,350 +0,0 @@
1From 753bcb5971401b82fb2e6197d31c9e386f6d0392 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 15 Sep 2017 15:46:38 -0700
4Subject: [PATCH] adb: add base64 implementation
5
6musl needs it
7
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10Upstream-Status: Pending
11
12 adb/adb_auth_client.c | 2 +-
13 adb/base64.c | 315 ++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 316 insertions(+), 1 deletion(-)
15 create mode 100644 adb/base64.c
16
17diff --git a/adb/adb_auth_client.c b/adb/adb_auth_client.c
18index 55e9dcad19..104b413b8b 100644
19--- a/adb/adb_auth_client.c
20+++ b/adb/adb_auth_client.c
21@@ -75,7 +75,7 @@ static void read_keys(const char *file, struct listnode *list)
22 if (sep)
23 *sep = '\0';
24
25- ret = __b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
26+ ret = b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
27 if (ret != sizeof(key->key)) {
28 D("%s: Invalid base64 data ret=%d\n", file, ret);
29 free(key);
30diff --git a/adb/base64.c b/adb/base64.c
31new file mode 100644
32index 0000000000..95da284d0d
33--- /dev/null
34+++ b/adb/base64.c
35@@ -0,0 +1,315 @@
36+/*
37+ * Copyright (c) 1996-1999 by Internet Software Consortium.
38+ *
39+ * Permission to use, copy, modify, and distribute this software for any
40+ * purpose with or without fee is hereby granted, provided that the above
41+ * copyright notice and this permission notice appear in all copies.
42+ *
43+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
44+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
45+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
46+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
47+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
48+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
49+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
50+ * SOFTWARE.
51+ */
52+
53+/*
54+ * Portions Copyright (c) 1995 by International Business Machines, Inc.
55+ *
56+ * International Business Machines, Inc. (hereinafter called IBM) grants
57+ * permission under its copyrights to use, copy, modify, and distribute this
58+ * Software with or without fee, provided that the above copyright notice and
59+ * all paragraphs of this notice appear in all copies, and that the name of IBM
60+ * not be used in connection with the marketing of any product incorporating
61+ * the Software or modifications thereof, without specific, written prior
62+ * permission.
63+ *
64+ * To the extent it has a right to do so, IBM grants an immunity from suit
65+ * under its patents, if any, for the use, sale or manufacture of products to
66+ * the extent that such products are used for performing Domain Name System
67+ * dynamic updates in TCP/IP networks by means of the Software. No immunity is
68+ * granted for any product per se or for any other function of any product.
69+ *
70+ * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
71+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
72+ * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
73+ * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
74+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
75+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
76+ */
77+
78+#if !defined(LINT) && !defined(CODECENTER)
79+static const char rcsid[] = "$BINDId: base64.c,v 8.7 1999/10/13 16:39:33 vixie Exp $";
80+#endif /* not lint */
81+
82+#include <sys/types.h>
83+#include <sys/param.h>
84+#include <sys/socket.h>
85+
86+#include <netinet/in.h>
87+#include <arpa/inet.h>
88+#include <arpa/nameser.h>
89+
90+#include <ctype.h>
91+#include <resolv.h>
92+#include <stdio.h>
93+#include <stdlib.h>
94+#include <stdint.h>
95+#include <string.h>
96+
97+#define Assert(Cond) if (!(Cond)) abort()
98+
99+static const char Base64[] =
100+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
101+static const char Pad64 = '=';
102+
103+/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
104+ The following encoding technique is taken from RFC 1521 by Borenstein
105+ and Freed. It is reproduced here in a slightly edited form for
106+ convenience.
107+
108+ A 65-character subset of US-ASCII is used, enabling 6 bits to be
109+ represented per printable character. (The extra 65th character, "=",
110+ is used to signify a special processing function.)
111+
112+ The encoding process represents 24-bit groups of input bits as output
113+ strings of 4 encoded characters. Proceeding from left to right, a
114+ 24-bit input group is formed by concatenating 3 8-bit input groups.
115+ These 24 bits are then treated as 4 concatenated 6-bit groups, each
116+ of which is translated into a single digit in the base64 alphabet.
117+
118+ Each 6-bit group is used as an index into an array of 64 printable
119+ characters. The character referenced by the index is placed in the
120+ output string.
121+
122+ Table 1: The Base64 Alphabet
123+
124+ Value Encoding Value Encoding Value Encoding Value Encoding
125+ 0 A 17 R 34 i 51 z
126+ 1 B 18 S 35 j 52 0
127+ 2 C 19 T 36 k 53 1
128+ 3 D 20 U 37 l 54 2
129+ 4 E 21 V 38 m 55 3
130+ 5 F 22 W 39 n 56 4
131+ 6 G 23 X 40 o 57 5
132+ 7 H 24 Y 41 p 58 6
133+ 8 I 25 Z 42 q 59 7
134+ 9 J 26 a 43 r 60 8
135+ 10 K 27 b 44 s 61 9
136+ 11 L 28 c 45 t 62 +
137+ 12 M 29 d 46 u 63 /
138+ 13 N 30 e 47 v
139+ 14 O 31 f 48 w (pad) =
140+ 15 P 32 g 49 x
141+ 16 Q 33 h 50 y
142+
143+ Special processing is performed if fewer than 24 bits are available
144+ at the end of the data being encoded. A full encoding quantum is
145+ always completed at the end of a quantity. When fewer than 24 input
146+ bits are available in an input group, zero bits are added (on the
147+ right) to form an integral number of 6-bit groups. Padding at the
148+ end of the data is performed using the '=' character.
149+
150+ Since all base64 input is an integral number of octets, only the
151+ -------------------------------------------------
152+ following cases can arise:
153+
154+ (1) the final quantum of encoding input is an integral
155+ multiple of 24 bits; here, the final unit of encoded
156+ output will be an integral multiple of 4 characters
157+ with no "=" padding,
158+ (2) the final quantum of encoding input is exactly 8 bits;
159+ here, the final unit of encoded output will be two
160+ characters followed by two "=" padding characters, or
161+ (3) the final quantum of encoding input is exactly 16 bits;
162+ here, the final unit of encoded output will be three
163+ characters followed by one "=" padding character.
164+ */
165+
166+int
167+b64_ntop(const uint8_t* src, size_t srclength, char* target, size_t targsize)
168+{
169+ size_t datalength = 0;
170+ uint8_t input[3];
171+ uint8_t output[4];
172+ size_t i;
173+
174+ while (2 < srclength) {
175+ input[0] = *src++;
176+ input[1] = *src++;
177+ input[2] = *src++;
178+ srclength -= 3;
179+
180+ output[0] = input[0] >> 2;
181+ output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
182+ output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
183+ output[3] = input[2] & 0x3f;
184+ Assert(output[0] < 64);
185+ Assert(output[1] < 64);
186+ Assert(output[2] < 64);
187+ Assert(output[3] < 64);
188+
189+ if (datalength + 4 > targsize)
190+ return (-1);
191+ target[datalength++] = Base64[output[0]];
192+ target[datalength++] = Base64[output[1]];
193+ target[datalength++] = Base64[output[2]];
194+ target[datalength++] = Base64[output[3]];
195+ }
196+
197+ /* Now we worry about padding. */
198+ if (0 != srclength) {
199+ /* Get what's left. */
200+ input[0] = input[1] = input[2] = '\0';
201+ for (i = 0; i < srclength; i++)
202+ input[i] = *src++;
203+
204+ output[0] = input[0] >> 2;
205+ output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
206+ output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
207+ Assert(output[0] < 64);
208+ Assert(output[1] < 64);
209+ Assert(output[2] < 64);
210+
211+ if (datalength + 4 > targsize)
212+ return (-1);
213+ target[datalength++] = Base64[output[0]];
214+ target[datalength++] = Base64[output[1]];
215+ if (srclength == 1)
216+ target[datalength++] = Pad64;
217+ else
218+ target[datalength++] = Base64[output[2]];
219+ target[datalength++] = Pad64;
220+ }
221+ if (datalength >= targsize)
222+ return (-1);
223+ target[datalength] = '\0'; /* Returned value doesn't count \0. */
224+ return (datalength);
225+}
226+
227+/* skips all whitespace anywhere.
228+ converts characters, four at a time, starting at (or after)
229+ src from base - 64 numbers into three 8 bit bytes in the target area.
230+ it returns the number of data bytes stored at the target, or -1 on error.
231+ */
232+
233+int b64_pton(const char* src, uint8_t* target, size_t targsize)
234+{
235+ int tarindex, state, ch;
236+ char *pos;
237+
238+ state = 0;
239+ tarindex = 0;
240+
241+ while ((ch = *src++) != '\0') {
242+ if (isspace(ch)) /* Skip whitespace anywhere. */
243+ continue;
244+
245+ if (ch == Pad64)
246+ break;
247+
248+ pos = strchr(Base64, ch);
249+ if (pos == 0) /* A non-base64 character. */
250+ return (-1);
251+
252+ switch (state) {
253+ case 0:
254+ if (target) {
255+ if ((size_t)tarindex >= targsize)
256+ return (-1);
257+ target[tarindex] = (pos - Base64) << 2;
258+ }
259+ state = 1;
260+ break;
261+ case 1:
262+ if (target) {
263+ if ((size_t)tarindex + 1 >= targsize)
264+ return (-1);
265+ target[tarindex] |= (pos - Base64) >> 4;
266+ target[tarindex+1] = ((pos - Base64) & 0x0f)
267+ << 4 ;
268+ }
269+ tarindex++;
270+ state = 2;
271+ break;
272+ case 2:
273+ if (target) {
274+ if ((size_t)tarindex + 1 >= targsize)
275+ return (-1);
276+ target[tarindex] |= (pos - Base64) >> 2;
277+ target[tarindex+1] = ((pos - Base64) & 0x03)
278+ << 6;
279+ }
280+ tarindex++;
281+ state = 3;
282+ break;
283+ case 3:
284+ if (target) {
285+ if ((size_t)tarindex >= targsize)
286+ return (-1);
287+ target[tarindex] |= (pos - Base64);
288+ }
289+ tarindex++;
290+ state = 0;
291+ break;
292+ default:
293+ abort();
294+ }
295+ }
296+
297+ /*
298+ * We are done decoding Base-64 chars. Let's see if we ended
299+ * on a byte boundary, and/or with erroneous trailing characters.
300+ */
301+
302+ if (ch == Pad64) { /* We got a pad char. */
303+ ch = *src++; /* Skip it, get next. */
304+ switch (state) {
305+ case 0: /* Invalid = in first position */
306+ case 1: /* Invalid = in second position */
307+ return (-1);
308+
309+ case 2: /* Valid, means one byte of info */
310+ /* Skip any number of spaces. */
311+ for ((void)NULL; ch != '\0'; ch = *src++)
312+ if (!isspace(ch))
313+ break;
314+ /* Make sure there is another trailing = sign. */
315+ if (ch != Pad64)
316+ return (-1);
317+ ch = *src++; /* Skip the = */
318+ /* Fall through to "single trailing =" case. */
319+ /* FALLTHROUGH */
320+
321+ case 3: /* Valid, means two bytes of info */
322+ /*
323+ * We know this char is an =. Is there anything but
324+ * whitespace after it?
325+ */
326+ for ((void)NULL; ch != '\0'; ch = *src++)
327+ if (!isspace(ch))
328+ return (-1);
329+
330+ /*
331+ * Now make sure for cases 2 and 3 that the "extra"
332+ * bits that slopped past the last full byte were
333+ * zeros. If we don't check them, they become a
334+ * subliminal channel.
335+ */
336+ if (target && target[tarindex] != 0)
337+ return (-1);
338+ }
339+ } else {
340+ /*
341+ * We ended by seeing the end of the string. Make sure we
342+ * have no partial bytes lying around.
343+ */
344+ if (state != 0)
345+ return (-1);
346+ }
347+
348+ return (tarindex);
349+}
350+
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0006-adb-Musl-fixes.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0006-adb-Musl-fixes.patch
deleted file mode 100644
index 182b1eb29e..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0006-adb-Musl-fixes.patch
+++ /dev/null
@@ -1,130 +0,0 @@
1From 62d957a1271c88ec08d67984fbe31601f0bd41a9 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 15 Sep 2017 15:50:57 -0700
4Subject: [PATCH] adb: Musl fixes
5
6__nonnull is gcc specific
7include sys/types.h for size_t
8Do not redefine close() and lseek()
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12Upstream-Status: Pending
13
14 adb/adb.h | 2 ++
15 adb/disable_verity_service.c | 13 ++++++++-----
16 adb/framebuffer_service.c | 7 ++++---
17 adb/sysdeps.h | 12 ++++++------
18 4 files changed, 20 insertions(+), 14 deletions(-)
19
20--- a/adb/adb.h
21+++ b/adb/adb.h
22@@ -18,7 +18,9 @@
23 #define __ADB_H
24
25 #include <limits.h>
26+#include <sys/types.h>
27
28+#include "fdevent.h"
29 #include "adb_trace.h"
30 #include "transport.h" /* readx(), writex() */
31
32--- a/adb/disable_verity_service.c
33+++ b/adb/disable_verity_service.c
34@@ -14,25 +14,32 @@
35 * limitations under the License.
36 */
37
38-#include "sysdeps.h"
39
40 #define TRACE_TAG TRACE_ADB
41 #include "adb.h"
42+#include "sysdeps.h"
43+#include "cutils/properties.h"
44+#include "ext4_sb.h"
45+#include <fs_mgr.h>
46
47 #include <stdio.h>
48 #include <stdarg.h>
49 #include <sys/stat.h>
50 #include <fcntl.h>
51 #include <inttypes.h>
52-
53-#include "cutils/properties.h"
54-#include "ext4_sb.h"
55-#include <fs_mgr.h>
56+#include <unistd.h>
57+#include <errno.h>
58+#include <stdbool.h>
59+
60+#if defined(__linux__) && !defined(__GLIBC__)
61+#define lseek64 lseek
62+#define off64_t off_t
63+#endif
64
65 #define FSTAB_PREFIX "/fstab."
66 struct fstab *fstab;
67
68-__attribute__((__format__(printf, 2, 3))) __nonnull((2))
69+__attribute__((__format__(printf, 2, 3))) __attribute__((nonnull((2))))
70 static void write_console(int fd, const char* format, ...)
71 {
72 char buffer[256];
73--- a/adb/framebuffer_service.c
74+++ b/adb/framebuffer_service.c
75@@ -14,6 +14,10 @@
76 * limitations under the License.
77 */
78
79+#include "fdevent.h"
80+#include "adb.h"
81+#include "sysdeps.h"
82+
83 #include <stdlib.h>
84 #include <stdio.h>
85 #include <unistd.h>
86@@ -23,9 +27,6 @@
87 #include <sys/types.h>
88 #include <sys/wait.h>
89
90-#include "fdevent.h"
91-#include "adb.h"
92-
93 #include <linux/fb.h>
94 #include <sys/ioctl.h>
95 #include <sys/mman.h>
96--- a/adb/sysdeps.h
97+++ b/adb/sysdeps.h
98@@ -123,8 +123,8 @@ static __inline__ int unix_close(int fd
99 {
100 return close(fd);
101 }
102-#undef close
103-#define close ____xxx_close
104+//#undef close
105+//#define close ____xxx_close
106
107 static __inline__ int unix_read(int fd, void* buf, size_t len)
108 {
109@@ -369,8 +369,8 @@ static __inline__ int adb_close(int fd)
110 {
111 return close(fd);
112 }
113-#undef close
114-#define close ____xxx_close
115+//#undef close
116+//#define close ____xxx_close
117
118
119 static __inline__ int adb_read(int fd, void* buf, size_t len)
120@@ -392,8 +392,8 @@ static __inline__ int adb_lseek(int f
121 {
122 return lseek(fd, pos, where);
123 }
124-#undef lseek
125-#define lseek ___xxx_lseek
126+//#undef lseek
127+//#define lseek ___xxx_lseek
128
129 static __inline__ int adb_unlink(const char* path)
130 {
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0007-adb-usb_linux.c-fix-build-with-glibc-2.28.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0007-adb-usb_linux.c-fix-build-with-glibc-2.28.patch
deleted file mode 100644
index 64fbce4cbe..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0007-adb-usb_linux.c-fix-build-with-glibc-2.28.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1From de393bba41c8feff932c77d6c30233945f380d42 Mon Sep 17 00:00:00 2001
2From: Martin Jansa <Martin.Jansa@gmail.com>
3Date: Sat, 11 Aug 2018 13:23:37 +0000
4Subject: [PATCH] adb: usb_linux.c: fix build with glibc-2.28
5
6* include sysmacros for major, minor
7
8Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
9---
10Upstream-Status: Pending
11
12 adb/usb_linux.c | 1 +
13 1 file changed, 1 insertion(+)
14
15diff --git a/adb/usb_linux.c b/adb/usb_linux.c
16index f16bdd0361..c8a7732441 100644
17--- a/adb/usb_linux.c
18+++ b/adb/usb_linux.c
19@@ -22,6 +22,7 @@
20 #include <sys/ioctl.h>
21 #include <sys/types.h>
22 #include <sys/time.h>
23+#include <sys/sysmacros.h>
24 #include <dirent.h>
25 #include <fcntl.h>
26 #include <errno.h>
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0008-adb-Allow-adbd-to-be-ran-as-root.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0008-adb-Allow-adbd-to-be-ran-as-root.patch
deleted file mode 100644
index ad21b5aaa6..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0008-adb-Allow-adbd-to-be-ran-as-root.patch
+++ /dev/null
@@ -1,23 +0,0 @@
1From 3a788e9168c9b9eac66c4fa479413f4a95c61be4 Mon Sep 17 00:00:00 2001
2From: Florent Revest <revestflo@gmail.com>
3Date: Mon, 30 Oct 2017 21:05:46 +0100
4Subject: [PATCH] adb: Allow adbd to be ran as root
5
6---
7Upstream-Status: Pending
8
9 adb/adb.c | 1 +
10 1 file changed, 1 insertion(+)
11
12diff --git a/adb/adb.c b/adb/adb.c
13index 027edd9359..e0f7ecde45 100644
14--- a/adb/adb.c
15+++ b/adb/adb.c
16@@ -1271,6 +1271,7 @@ static int should_drop_privileges() {
17 int secure = 0;
18 char value[PROPERTY_VALUE_MAX];
19
20+ return 0;
21 /* run adbd in secure mode if ro.secure is set and
22 ** we are not in the emulator
23 */
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0009-mkbootimg-Add-dt-parameter-to-specify-DT-image.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0009-mkbootimg-Add-dt-parameter-to-specify-DT-image.patch
deleted file mode 100644
index a4dc6e1e35..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0009-mkbootimg-Add-dt-parameter-to-specify-DT-image.patch
+++ /dev/null
@@ -1,110 +0,0 @@
1From dd195778a9930b7967b21a3b8eb390b70253dbad Mon Sep 17 00:00:00 2001
2From: David Ng <dave@codeaurora.org>
3Date: Fri, 27 Jul 2012 17:15:03 -0700
4Subject: [PATCH] mkbootimg: Add --dt parameter to specify DT image
5
6New optional --dt parameter to specify a kernel device
7tree image.
8
9Upstream-Status: Inappropriate
10---
11 mkbootimg/bootimg.h | 7 +++++--
12 mkbootimg/mkbootimg.c | 21 +++++++++++++++++++++
13 2 files changed, 26 insertions(+), 2 deletions(-)
14
15diff --git a/mkbootimg/bootimg.h b/mkbootimg/bootimg.h
16index 9171d85a7b..308c537d6b 100644
17--- a/mkbootimg/bootimg.h
18+++ b/mkbootimg/bootimg.h
19@@ -41,8 +41,8 @@ struct boot_img_hdr
20
21 unsigned tags_addr; /* physical addr for kernel tags */
22 unsigned page_size; /* flash page size we assume */
23- unsigned unused[2]; /* future expansion: should be 0 */
24-
25+ unsigned dt_size; /* device tree in bytes */
26+ unsigned unused; /* future expansion: should be 0 */
27 unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
28
29 unsigned char cmdline[BOOT_ARGS_SIZE];
30@@ -64,10 +64,13 @@ struct boot_img_hdr
31 ** +-----------------+
32 ** | second stage | o pages
33 ** +-----------------+
34+** | device tree | p pages
35+** +-----------------+
36 **
37 ** n = (kernel_size + page_size - 1) / page_size
38 ** m = (ramdisk_size + page_size - 1) / page_size
39 ** o = (second_size + page_size - 1) / page_size
40+** p = (dt_size + page_size - 1) / page_size
41 **
42 ** 0. all entities are page_size aligned in flash
43 ** 1. kernel and ramdisk are required (size != 0)
44diff --git a/mkbootimg/mkbootimg.c b/mkbootimg/mkbootimg.c
45index fc92b4dc30..658052cdf2 100644
46--- a/mkbootimg/mkbootimg.c
47+++ b/mkbootimg/mkbootimg.c
48@@ -65,6 +65,7 @@ int usage(void)
49 " [ --board <boardname> ]\n"
50 " [ --base <address> ]\n"
51 " [ --pagesize <pagesize> ]\n"
52+ " [ --dt <filename> ]\n"
53 " -o|--output <filename>\n"
54 );
55 return 1;
56@@ -105,6 +106,8 @@ int main(int argc, char **argv)
57 char *cmdline = "";
58 char *bootimg = 0;
59 char *board = "";
60+ char *dt_fn = 0;
61+ void *dt_data = 0;
62 unsigned pagesize = 2048;
63 int fd;
64 SHA_CTX ctx;
65@@ -158,6 +161,8 @@ int main(int argc, char **argv)
66 fprintf(stderr,"error: unsupported page size %d\n", pagesize);
67 return -1;
68 }
69+ } else if(!strcmp(arg, "--dt")) {
70+ dt_fn = val;
71 } else {
72 return usage();
73 }
74@@ -232,6 +237,14 @@ int main(int argc, char **argv)
75 }
76 }
77
78+ if(dt_fn) {
79+ dt_data = load_file(dt_fn, &hdr.dt_size);
80+ if (dt_data == 0) {
81+ fprintf(stderr,"error: could not load device tree image '%s'\n", dt_fn);
82+ return 1;
83+ }
84+ }
85+
86 /* put a hash of the contents in the header so boot images can be
87 * differentiated based on their first 2k.
88 */
89@@ -242,6 +255,10 @@ int main(int argc, char **argv)
90 SHA_update(&ctx, &hdr.ramdisk_size, sizeof(hdr.ramdisk_size));
91 SHA_update(&ctx, second_data, hdr.second_size);
92 SHA_update(&ctx, &hdr.second_size, sizeof(hdr.second_size));
93+ if(dt_data) {
94+ SHA_update(&ctx, dt_data, hdr.dt_size);
95+ SHA_update(&ctx, &hdr.dt_size, sizeof(hdr.dt_size));
96+ }
97 sha = SHA_final(&ctx);
98 memcpy(hdr.id, sha,
99 SHA_DIGEST_SIZE > sizeof(hdr.id) ? sizeof(hdr.id) : SHA_DIGEST_SIZE);
100@@ -266,6 +283,10 @@ int main(int argc, char **argv)
101 if(write_padding(fd, pagesize, hdr.second_size)) goto fail;
102 }
103
104+ if(dt_data) {
105+ if(write(fd, dt_data, hdr.dt_size) != (ssize_t) hdr.dt_size) goto fail;
106+ if(write_padding(fd, pagesize, hdr.dt_size)) goto fail;
107+ }
108 return 0;
109
110 fail:
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0010-Use-linux-capability.h-on-linux-systems-too.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0010-Use-linux-capability.h-on-linux-systems-too.patch
deleted file mode 100644
index 2c607ff67c..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0010-Use-linux-capability.h-on-linux-systems-too.patch
+++ /dev/null
@@ -1,23 +0,0 @@
1From ef743c9c3c7452ae904a5c343ee2b759ab3a87cb Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Lo=C3=AFc=20Minier?= <loic.minier@ubuntu.com>
3Date: Wed, 7 Sep 2016 12:58:47 +0300
4Subject: [PATCH] Use linux/capability.h on linux systems too
5
6Upstream-Status: Inappropriate
7---
8 include/private/android_filesystem_config.h | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
12index 2f528b95c8..3e0b00928e 100644
13--- a/include/private/android_filesystem_config.h
14+++ b/include/private/android_filesystem_config.h
15@@ -27,7 +27,7 @@
16 #include <sys/types.h>
17 #include <stdint.h>
18
19-#ifdef HAVE_ANDROID_OS
20+#if defined(HAVE_ANDROID_OS) || defined(__linux__)
21 #include <linux/capability.h>
22 #else
23 #include "android_filesystem_capability.h"
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0011-Remove-bionic-specific-calls.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0011-Remove-bionic-specific-calls.patch
deleted file mode 100644
index 5b18f461a3..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0011-Remove-bionic-specific-calls.patch
+++ /dev/null
@@ -1,64 +0,0 @@
1From 9eff8799831961c0edf6e37e5d4cbf43baa7c748 Mon Sep 17 00:00:00 2001
2From: Fathi Boudra <fabo@debian.org>
3Date: Wed, 7 Sep 2016 12:58:47 +0300
4Subject: [PATCH] Remove bionic specific calls
5
6Upstream-Status: Inappropriate
7---
8 include/cutils/properties.h | 1 -
9 libcutils/properties.c | 2 +-
10 liblog/logd_write.c | 5 +++++
11 3 files changed, 6 insertions(+), 2 deletions(-)
12
13diff --git a/include/cutils/properties.h b/include/cutils/properties.h
14index 798db8b36f..7d01f28d6e 100644
15--- a/include/cutils/properties.h
16+++ b/include/cutils/properties.h
17@@ -19,7 +19,6 @@
18
19 #include <sys/cdefs.h>
20 #include <stddef.h>
21-#include <sys/system_properties.h>
22 #include <stdint.h>
23
24 #ifdef __cplusplus
25diff --git a/libcutils/properties.c b/libcutils/properties.c
26index b283658aa4..4151e7882c 100644
27--- a/libcutils/properties.c
28+++ b/libcutils/properties.c
29@@ -104,10 +104,10 @@ int32_t property_get_int32(const char *key, int32_t default_value) {
30 return (int32_t)property_get_imax(key, INT32_MIN, INT32_MAX, default_value);
31 }
32
33+#undef HAVE_LIBC_SYSTEM_PROPERTIES
34 #ifdef HAVE_LIBC_SYSTEM_PROPERTIES
35
36 #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
37-#include <sys/_system_properties.h>
38
39 int property_set(const char *key, const char *value)
40 {
41diff --git a/liblog/logd_write.c b/liblog/logd_write.c
42index b2668cedb7..f5a44fe901 100644
43--- a/liblog/logd_write.c
44+++ b/liblog/logd_write.c
45@@ -23,6 +23,7 @@
46 #include <stdlib.h>
47 #include <string.h>
48 #include <sys/stat.h>
49+#include <sys/syscall.h>
50 #include <sys/types.h>
51 #if (FAKE_LOG_DEVICE == 0)
52 #include <sys/socket.h>
53@@ -205,7 +206,11 @@ static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec, size_t nr)
54 realtime_ts.tv_nsec = ts.tv_nsec;
55
56 log_id_buf = log_id;
57+#ifdef __BIONIC__
58 tid = gettid();
59+#else
60+ tid = (pid_t) syscall(__NR_gettid);
61+#endif
62
63 newVec[0].iov_base = (unsigned char *) &log_id_buf;
64 newVec[0].iov_len = sizeof_log_id_t;
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0012-Fix-implicit-declaration-of-stlcat-strlcopy-function.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0012-Fix-implicit-declaration-of-stlcat-strlcopy-function.patch
deleted file mode 100644
index b0feb65921..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0012-Fix-implicit-declaration-of-stlcat-strlcopy-function.patch
+++ /dev/null
@@ -1,50 +0,0 @@
1From cd4525d760c6f88c9bf85f7bf488da79cd0d3264 Mon Sep 17 00:00:00 2001
2From: Fathi Boudra <fabo@debian.org>
3Date: Wed, 7 Sep 2016 12:58:47 +0300
4Subject: [PATCH] Fix implicit declaration of stlcat/strlcopy functions
5
6Upstream-Status: Inappropriate
7---
8 adb/adb.c | 1 +
9 fs_mgr/fs_mgr_fstab.c | 2 +-
10 include/cutils/sockets.h | 2 +-
11 3 files changed, 3 insertions(+), 2 deletions(-)
12
13diff --git a/adb/adb.c b/adb/adb.c
14index e0f7ecde45..aaefd9b401 100644
15--- a/adb/adb.c
16+++ b/adb/adb.c
17@@ -41,6 +41,7 @@
18 #include <sys/prctl.h>
19 #include <getopt.h>
20 #include <selinux/selinux.h>
21+#include <grp.h>
22 #else
23 #include "usb_vendors.h"
24 #endif
25diff --git a/fs_mgr/fs_mgr_fstab.c b/fs_mgr/fs_mgr_fstab.c
26index edd9591164..9ddb4643b5 100644
27--- a/fs_mgr/fs_mgr_fstab.c
28+++ b/fs_mgr/fs_mgr_fstab.c
29@@ -17,7 +17,7 @@
30 #include <ctype.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33-#include <string.h>
34+#include <bsd/string.h>
35 #include <sys/mount.h>
36
37 #include "fs_mgr_priv.h"
38diff --git a/include/cutils/sockets.h b/include/cutils/sockets.h
39index daf43ec944..d3270c69e7 100644
40--- a/include/cutils/sockets.h
41+++ b/include/cutils/sockets.h
42@@ -19,7 +19,7 @@
43
44 #include <errno.h>
45 #include <stdlib.h>
46-#include <string.h>
47+#include <bsd/string.h>
48 #include <stdbool.h>
49
50 #ifdef HAVE_WINSOCK
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0013-adb-Support-riscv64.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0013-adb-Support-riscv64.patch
deleted file mode 100644
index 5138556d63..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0013-adb-Support-riscv64.patch
+++ /dev/null
@@ -1,191 +0,0 @@
1From 48ddf4fb999931942c359350fb31cd557514e1c6 Mon Sep 17 00:00:00 2001
2From: Chenxi Mao <maochenxi@eswin.com>
3Date: Mon, 20 Apr 2020 15:27:22 +0800
4Subject: [PATCH 1/1] adb: Support riscv64
5
6---
7Upstream-Status: Pending
8
9 include/cutils/atomic-inline.h | 2 +
10 include/cutils/atomic-riscv64.h | 156 ++++++++++++++++++++++++++++++++
11 2 files changed, 158 insertions(+)
12 create mode 100644 include/cutils/atomic-riscv64.h
13
14diff --git a/include/cutils/atomic-inline.h b/include/cutils/atomic-inline.h
15index a31e913579..b5dc38209c 100644
16--- a/include/cutils/atomic-inline.h
17+++ b/include/cutils/atomic-inline.h
18@@ -55,6 +55,8 @@ extern "C" {
19 #include <cutils/atomic-mips64.h>
20 #elif defined(__mips__)
21 #include <cutils/atomic-mips.h>
22+#elif defined(__riscv) && __riscv_xlen == 64
23+#include <cutils/atomic-riscv64.h>
24 #else
25 #error atomic operations are unsupported
26 #endif
27diff --git a/include/cutils/atomic-riscv64.h b/include/cutils/atomic-riscv64.h
28new file mode 100644
29index 0000000000..2664db5a86
30--- /dev/null
31+++ b/include/cutils/atomic-riscv64.h
32@@ -0,0 +1,156 @@
33+/*
34+ * Copyright (C) 2014 The Android Open Source Project
35+ * All rights reserved.
36+ *
37+ * Redistribution and use in source and binary forms, with or without
38+ * modification, are permitted provided that the following conditions
39+ * are met:
40+ * * Redistributions of source code must retain the above copyright
41+ * notice, this list of conditions and the following disclaimer.
42+ * * Redistributions in binary form must reproduce the above copyright
43+ * notice, this list of conditions and the following disclaimer in
44+ * the documentation and/or other materials provided with the
45+ * distribution.
46+ *
47+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
50+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
51+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
52+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
53+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
54+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
55+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
56+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
57+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58+ * SUCH DAMAGE.
59+ */
60+
61+#ifndef ANDROID_CUTILS_ATOMIC_RISCV64_H
62+#define ANDROID_CUTILS_ATOMIC_RISCV64_H
63+
64+#include <stdint.h>
65+
66+#ifndef ANDROID_ATOMIC_INLINE
67+#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline))
68+#endif
69+
70+/*
71+ TODOAArch64: Revisit the below functions and check for potential
72+ optimizations using assembly code or otherwise.
73+*/
74+
75+extern ANDROID_ATOMIC_INLINE
76+void android_compiler_barrier(void)
77+{
78+ __asm__ __volatile__ ("" : : : "memory");
79+}
80+
81+extern ANDROID_ATOMIC_INLINE
82+void android_memory_barrier(void)
83+{
84+ __asm__ __volatile__ ("fence rw,rw" : : : "memory");
85+}
86+
87+extern ANDROID_ATOMIC_INLINE
88+int32_t android_atomic_acquire_load(volatile const int32_t *ptr)
89+{
90+ int32_t value = *ptr;
91+ android_memory_barrier();
92+ return value;
93+}
94+
95+extern ANDROID_ATOMIC_INLINE
96+int32_t android_atomic_release_load(volatile const int32_t *ptr)
97+{
98+ android_memory_barrier();
99+ return *ptr;
100+}
101+
102+extern ANDROID_ATOMIC_INLINE
103+void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr)
104+{
105+ *ptr = value;
106+ android_memory_barrier();
107+}
108+
109+extern ANDROID_ATOMIC_INLINE
110+void android_atomic_release_store(int32_t value, volatile int32_t *ptr)
111+{
112+ android_memory_barrier();
113+ *ptr = value;
114+}
115+
116+extern ANDROID_ATOMIC_INLINE
117+int android_atomic_cas(int32_t old_value, int32_t new_value,
118+ volatile int32_t *ptr)
119+{
120+ return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value;
121+}
122+
123+extern ANDROID_ATOMIC_INLINE
124+int android_atomic_acquire_cas(int32_t old_value, int32_t new_value,
125+ volatile int32_t *ptr)
126+{
127+ int status = android_atomic_cas(old_value, new_value, ptr);
128+ android_memory_barrier();
129+ return status;
130+}
131+
132+extern ANDROID_ATOMIC_INLINE
133+int android_atomic_release_cas(int32_t old_value, int32_t new_value,
134+ volatile int32_t *ptr)
135+{
136+ android_memory_barrier();
137+ return android_atomic_cas(old_value, new_value, ptr);
138+}
139+
140+extern ANDROID_ATOMIC_INLINE
141+int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr)
142+{
143+ int32_t prev, status;
144+ android_memory_barrier();
145+ do {
146+ prev = *ptr;
147+ status = android_atomic_cas(prev, prev + increment, ptr);
148+ } while (__builtin_expect(status != 0, 0));
149+ return prev;
150+}
151+
152+extern ANDROID_ATOMIC_INLINE
153+int32_t android_atomic_inc(volatile int32_t *addr)
154+{
155+ return android_atomic_add(1, addr);
156+}
157+
158+extern ANDROID_ATOMIC_INLINE
159+int32_t android_atomic_dec(volatile int32_t *addr)
160+{
161+ return android_atomic_add(-1, addr);
162+}
163+
164+extern ANDROID_ATOMIC_INLINE
165+int32_t android_atomic_and(int32_t value, volatile int32_t *ptr)
166+{
167+ int32_t prev, status;
168+ android_memory_barrier();
169+ do {
170+ prev = *ptr;
171+ status = android_atomic_cas(prev, prev & value, ptr);
172+ } while (__builtin_expect(status != 0, 0));
173+ return prev;
174+}
175+
176+extern ANDROID_ATOMIC_INLINE
177+int32_t android_atomic_or(int32_t value, volatile int32_t *ptr)
178+{
179+ int32_t prev, status;
180+ android_memory_barrier();
181+ do {
182+ prev = *ptr;
183+ status = android_atomic_cas(prev, prev | value, ptr);
184+ } while (__builtin_expect(status != 0, 0));
185+ return prev;
186+}
187+
188+#endif /* ANDROID_CUTILS_ATOMIC_RISCV_H */
189--
1902.17.1
191
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0014-add-u3-ss-descriptor-support-for-adb.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0014-add-u3-ss-descriptor-support-for-adb.patch
deleted file mode 100644
index cf23f3c251..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0014-add-u3-ss-descriptor-support-for-adb.patch
+++ /dev/null
@@ -1,344 +0,0 @@
1From dae9a11f3a158357966399aef97c48b5f16934d9 Mon Sep 17 00:00:00 2001
2From: Jiacheng Liu <jiacheng.liu@mediatek.com>
3Date: Sat, 24 Jul 2021 11:01:18 +0800
4Subject: [PATCH] android-tools: adb: add u3 ss descriptor support
5
6Porting u3 Superspeed descriptor support to open-embedded android-tools package.
7This patch origins from the the patch in android project [1], but has been
8modified for backporting to android-tools_5.1.1.r37.
9
10[1] https://android.googlesource.com/platform/system/core/+/d6ee9f26a5163af4121f4380264fcbd4e6851a17%5E%21
11
12Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
13Signed-off-by: Jiacheng Liu <jiacheng.liu@mediatek.com>
14---
15Upstream-Status: Pending
16
17 adb/usb_linux_client.c | 275 +++++++++++++++++++++++++++++++----------
18 1 file changed, 207 insertions(+), 68 deletions(-)
19
20diff --git a/adb/usb_linux_client.c b/adb/usb_linux_client.c
21index 6e8b5bb..884e85e 100644
22--- a/adb/usb_linux_client.c
23+++ b/adb/usb_linux_client.c
24@@ -31,8 +31,10 @@
25 #define TRACE_TAG TRACE_USB
26 #include "adb.h"
27
28+#define USB_EXT_PROP_UNICODE 1
29 #define MAX_PACKET_SIZE_FS 64
30 #define MAX_PACKET_SIZE_HS 512
31+#define MAX_PACKET_SIZE_SS 1024
32
33 #if __BYTE_ORDER == __LITTLE_ENDIAN
34 # define cpu_to_le16(x) (x)
35@@ -62,74 +64,185 @@ struct usb_handle
36 int bulk_in; /* "in" from the host's perspective => sink for adbd */
37 };
38
39-static const struct {
40- struct usb_functionfs_descs_head header;
41- struct {
42- struct usb_interface_descriptor intf;
43- struct usb_endpoint_descriptor_no_audio source;
44- struct usb_endpoint_descriptor_no_audio sink;
45- } __attribute__((packed)) fs_descs, hs_descs;
46-} __attribute__((packed)) descriptors = {
47- .header = {
48- .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC),
49- .length = cpu_to_le32(sizeof(descriptors)),
50- .fs_count = 3,
51- .hs_count = 3,
52+struct func_desc {
53+ struct usb_interface_descriptor intf;
54+ struct usb_endpoint_descriptor_no_audio source;
55+ struct usb_endpoint_descriptor_no_audio sink;
56+} __attribute__((packed));
57+
58+struct ss_func_desc {
59+ struct usb_interface_descriptor intf;
60+ struct usb_endpoint_descriptor_no_audio source;
61+ struct usb_ss_ep_comp_descriptor source_comp;
62+ struct usb_endpoint_descriptor_no_audio sink;
63+ struct usb_ss_ep_comp_descriptor sink_comp;
64+} __attribute__((packed));
65+
66+struct desc_v1 {
67+ struct usb_functionfs_descs_head_v1 {
68+ __le32 magic;
69+ __le32 length;
70+ __le32 fs_count;
71+ __le32 hs_count;
72+ } __attribute__((packed)) header;
73+ struct func_desc fs_descs, hs_descs;
74+} __attribute__((packed));
75+
76+struct usb_os_desc_ext_prop {
77+ uint32_t dwSize;
78+ uint32_t dwPropertyDataType;
79+
80+ // Property name and value are transmitted as UTF-16, but the kernel only
81+ // accepts ASCII values and performs the conversion for us.
82+ uint16_t wPropertyNameLength;
83+ char bPropertyName[20];
84+
85+ uint32_t dwPropertyDataLength;
86+ char bProperty[39];
87+} __attribute__((packed)) os_desc_guid = {
88+ .dwSize = sizeof(struct usb_os_desc_ext_prop),
89+ .dwPropertyDataType = cpu_to_le32(USB_EXT_PROP_UNICODE),
90+ .wPropertyNameLength = cpu_to_le16(20),
91+ .bPropertyName = "DeviceInterfaceGUID",
92+ .dwPropertyDataLength = cpu_to_le32(39),
93+ .bProperty = "{F72FE0D4-CBCB-407D-8814-9ED673D0DD6B}",
94+};
95+
96+struct usb_ext_prop_values {
97+ struct usb_os_desc_ext_prop guid;
98+} __attribute__((packed));
99+
100+struct desc_v2 {
101+ struct usb_functionfs_descs_head_v2 header;
102+ // The rest of the structure depends on the flags in the header.
103+ __le32 fs_count;
104+ __le32 hs_count;
105+ __le32 ss_count;
106+ __le32 os_count;
107+ struct func_desc fs_descs, hs_descs;
108+ struct ss_func_desc ss_descs;
109+ struct usb_os_desc_header os_header;
110+ struct usb_ext_compat_desc os_desc;
111+ struct usb_os_desc_header os_prop_header;
112+ struct usb_ext_prop_values os_prop_values;
113+} __attribute__((packed));
114+
115+static struct func_desc fs_descriptors = {
116+ .intf = {
117+ .bLength = sizeof(fs_descriptors.intf),
118+ .bDescriptorType = USB_DT_INTERFACE,
119+ .bInterfaceNumber = 0,
120+ .bNumEndpoints = 2,
121+ .bInterfaceClass = ADB_CLASS,
122+ .bInterfaceSubClass = ADB_SUBCLASS,
123+ .bInterfaceProtocol = ADB_PROTOCOL,
124+ .iInterface = 1, /* first string from the provided table */
125+ },
126+ .source = {
127+ .bLength = sizeof(fs_descriptors.source),
128+ .bDescriptorType = USB_DT_ENDPOINT,
129+ .bEndpointAddress = 1 | USB_DIR_OUT,
130+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
131+ .wMaxPacketSize = MAX_PACKET_SIZE_FS,
132+ },
133+ .sink = {
134+ .bLength = sizeof(fs_descriptors.sink),
135+ .bDescriptorType = USB_DT_ENDPOINT,
136+ .bEndpointAddress = 2 | USB_DIR_IN,
137+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
138+ .wMaxPacketSize = MAX_PACKET_SIZE_FS,
139+ },
140+};
141+
142+static struct func_desc hs_descriptors = {
143+ .intf = {
144+ .bLength = sizeof(hs_descriptors.intf),
145+ .bDescriptorType = USB_DT_INTERFACE,
146+ .bInterfaceNumber = 0,
147+ .bNumEndpoints = 2,
148+ .bInterfaceClass = ADB_CLASS,
149+ .bInterfaceSubClass = ADB_SUBCLASS,
150+ .bInterfaceProtocol = ADB_PROTOCOL,
151+ .iInterface = 1, /* first string from the provided table */
152+ },
153+ .source = {
154+ .bLength = sizeof(hs_descriptors.source),
155+ .bDescriptorType = USB_DT_ENDPOINT,
156+ .bEndpointAddress = 1 | USB_DIR_OUT,
157+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
158+ .wMaxPacketSize = MAX_PACKET_SIZE_HS,
159+ },
160+ .sink = {
161+ .bLength = sizeof(hs_descriptors.sink),
162+ .bDescriptorType = USB_DT_ENDPOINT,
163+ .bEndpointAddress = 2 | USB_DIR_IN,
164+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
165+ .wMaxPacketSize = MAX_PACKET_SIZE_HS,
166+ },
167+};
168+
169+static struct ss_func_desc ss_descriptors = {
170+ .intf = {
171+ .bLength = sizeof(ss_descriptors.intf),
172+ .bDescriptorType = USB_DT_INTERFACE,
173+ .bInterfaceNumber = 0,
174+ .bNumEndpoints = 2,
175+ .bInterfaceClass = ADB_CLASS,
176+ .bInterfaceSubClass = ADB_SUBCLASS,
177+ .bInterfaceProtocol = ADB_PROTOCOL,
178+ .iInterface = 1, /* first string from the provided table */
179+ },
180+ .source = {
181+ .bLength = sizeof(ss_descriptors.source),
182+ .bDescriptorType = USB_DT_ENDPOINT,
183+ .bEndpointAddress = 1 | USB_DIR_OUT,
184+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
185+ .wMaxPacketSize = MAX_PACKET_SIZE_SS,
186+ },
187+ .source_comp = {
188+ .bLength = sizeof(ss_descriptors.source_comp),
189+ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
190+ .bMaxBurst = 4,
191 },
192- .fs_descs = {
193- .intf = {
194- .bLength = sizeof(descriptors.fs_descs.intf),
195- .bDescriptorType = USB_DT_INTERFACE,
196- .bInterfaceNumber = 0,
197- .bNumEndpoints = 2,
198- .bInterfaceClass = ADB_CLASS,
199- .bInterfaceSubClass = ADB_SUBCLASS,
200- .bInterfaceProtocol = ADB_PROTOCOL,
201- .iInterface = 1, /* first string from the provided table */
202- },
203- .source = {
204- .bLength = sizeof(descriptors.fs_descs.source),
205- .bDescriptorType = USB_DT_ENDPOINT,
206- .bEndpointAddress = 1 | USB_DIR_OUT,
207- .bmAttributes = USB_ENDPOINT_XFER_BULK,
208- .wMaxPacketSize = MAX_PACKET_SIZE_FS,
209- },
210- .sink = {
211- .bLength = sizeof(descriptors.fs_descs.sink),
212- .bDescriptorType = USB_DT_ENDPOINT,
213- .bEndpointAddress = 2 | USB_DIR_IN,
214- .bmAttributes = USB_ENDPOINT_XFER_BULK,
215- .wMaxPacketSize = MAX_PACKET_SIZE_FS,
216- },
217+ .sink = {
218+ .bLength = sizeof(ss_descriptors.sink),
219+ .bDescriptorType = USB_DT_ENDPOINT,
220+ .bEndpointAddress = 2 | USB_DIR_IN,
221+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
222+ .wMaxPacketSize = MAX_PACKET_SIZE_SS,
223 },
224- .hs_descs = {
225- .intf = {
226- .bLength = sizeof(descriptors.hs_descs.intf),
227- .bDescriptorType = USB_DT_INTERFACE,
228- .bInterfaceNumber = 0,
229- .bNumEndpoints = 2,
230- .bInterfaceClass = ADB_CLASS,
231- .bInterfaceSubClass = ADB_SUBCLASS,
232- .bInterfaceProtocol = ADB_PROTOCOL,
233- .iInterface = 1, /* first string from the provided table */
234- },
235- .source = {
236- .bLength = sizeof(descriptors.hs_descs.source),
237- .bDescriptorType = USB_DT_ENDPOINT,
238- .bEndpointAddress = 1 | USB_DIR_OUT,
239- .bmAttributes = USB_ENDPOINT_XFER_BULK,
240- .wMaxPacketSize = MAX_PACKET_SIZE_HS,
241- },
242- .sink = {
243- .bLength = sizeof(descriptors.hs_descs.sink),
244- .bDescriptorType = USB_DT_ENDPOINT,
245- .bEndpointAddress = 2 | USB_DIR_IN,
246- .bmAttributes = USB_ENDPOINT_XFER_BULK,
247- .wMaxPacketSize = MAX_PACKET_SIZE_HS,
248- },
249+ .sink_comp = {
250+ .bLength = sizeof(ss_descriptors.sink_comp),
251+ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
252+ .bMaxBurst = 4,
253 },
254 };
255
256+struct usb_ext_compat_desc os_desc_compat = {
257+ .bFirstInterfaceNumber = 0,
258+ .Reserved1 = cpu_to_le32(1),
259+ .CompatibleID = { 'W', 'I', 'N', 'U', 'S', 'B', '\0', '\0'},
260+ .SubCompatibleID = {0},
261+ .Reserved2 = {0},
262+};
263+
264+static struct usb_os_desc_header os_desc_header = {
265+ .interface = cpu_to_le32(0),
266+ .dwLength = cpu_to_le32(sizeof(os_desc_header) + sizeof(os_desc_compat)),
267+ .bcdVersion = cpu_to_le32(1),
268+ .wIndex = cpu_to_le32(4),
269+ .bCount = cpu_to_le32(1),
270+ .Reserved = cpu_to_le32(0),
271+};
272+
273+static struct usb_os_desc_header os_prop_header = {
274+ .interface = cpu_to_le32(0),
275+ .dwLength = cpu_to_le32(sizeof(os_desc_header) + sizeof(struct usb_ext_prop_values)),
276+ .bcdVersion = cpu_to_le32(1),
277+ .wIndex = cpu_to_le32(5),
278+ .wCount = cpu_to_le16(1),
279+};
280+
281 #define STR_INTERFACE_ "ADB Interface"
282
283 static const struct {
284@@ -151,8 +264,6 @@ static const struct {
285 },
286 };
287
288-
289-
290 static void *usb_adb_open_thread(void *x)
291 {
292 struct usb_handle *usb = (struct usb_handle *)x;
293@@ -270,6 +381,24 @@ static void usb_adb_init()
294 static void init_functionfs(struct usb_handle *h)
295 {
296 ssize_t ret;
297+ struct desc_v1 v1_descriptor = {};
298+ struct desc_v2 v2_descriptor = {};
299+
300+ v2_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2);
301+ v2_descriptor.header.length = cpu_to_le32(sizeof(v2_descriptor));
302+ v2_descriptor.header.flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC |
303+ FUNCTIONFS_HAS_SS_DESC | FUNCTIONFS_HAS_MS_OS_DESC;
304+ v2_descriptor.fs_count = 3;
305+ v2_descriptor.hs_count = 3;
306+ v2_descriptor.ss_count = 5;
307+ v2_descriptor.os_count = 2;
308+ v2_descriptor.fs_descs = fs_descriptors;
309+ v2_descriptor.hs_descs = hs_descriptors;
310+ v2_descriptor.ss_descs = ss_descriptors;
311+ v2_descriptor.os_header = os_desc_header;
312+ v2_descriptor.os_desc = os_desc_compat;
313+ v2_descriptor.os_prop_header = os_prop_header;
314+ v2_descriptor.os_prop_values.guid = os_desc_guid;
315
316 if (h->control < 0) { // might have already done this before
317 D("OPENING %s\n", USB_FFS_ADB_EP0);
318@@ -279,10 +408,20 @@ static void init_functionfs(struct usb_handle *h)
319 goto err;
320 }
321
322- ret = adb_write(h->control, &descriptors, sizeof(descriptors));
323+ ret = adb_write(h->control, &v2_descriptor, sizeof(v2_descriptor));
324 if (ret < 0) {
325- D("[ %s: write descriptors failed: errno=%d ]\n", USB_FFS_ADB_EP0, errno);
326- goto err;
327+ D("[ %s: write v2_descriptor failed: errno=%d ]\n", USB_FFS_ADB_EP0, errno);
328+ v1_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC);
329+ v1_descriptor.header.length = cpu_to_le32(sizeof(v1_descriptor));
330+ v1_descriptor.header.fs_count = 3;
331+ v1_descriptor.header.hs_count = 3;
332+ v1_descriptor.fs_descs = fs_descriptors;
333+ v1_descriptor.hs_descs = hs_descriptors;
334+ ret = adb_write(h->control, &v1_descriptor, sizeof(v1_descriptor));
335+ if (ret < 0) {
336+ D("[ %s: failed to write USB descriptors]\n", USB_FFS_ADB_EP0);
337+ goto err;
338+ }
339 }
340
341 ret = adb_write(h->control, &strings, sizeof(strings));
342--
3432.18.0
344
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0015-libsparse-Split-off-most-of-sparse_file_read_normal-.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0015-libsparse-Split-off-most-of-sparse_file_read_normal-.patch
deleted file mode 100644
index 5009c73a05..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0015-libsparse-Split-off-most-of-sparse_file_read_normal-.patch
+++ /dev/null
@@ -1,60 +0,0 @@
1From 7b74d23ed955206a789a96bdc3288593e702afac Mon Sep 17 00:00:00 2001
2From: Sean Anderson <sean.anderson@seco.com>
3Date: Thu, 30 Dec 2021 15:16:08 -0500
4Subject: [PATCH] libsparse: Split off most of sparse_file_read_normal into a
5 helper function
6
7This carves out the core of sparse_file_read_normal and splits it off so
8it can be reused in the next patch. No functional change intended.
9
10Change-Id: Id00491fd7e5bb6fa28c517a0bb32b8b506539d4d
11Upstream-Status: Backport [95657f3e5976d96073f7bbfe3a49192509999d1d]
12Signed-off-by: Sean Anderson <sean.anderson@seco.com>
13---
14 libsparse/sparse_read.c | 21 ++++++++++++++++-----
15 1 file changed, 16 insertions(+), 5 deletions(-)
16
17diff --git a/libsparse/sparse_read.c b/libsparse/sparse_read.c
18index 8e188e9a4..ee4abd86a 100644
19--- a/libsparse/sparse_read.c
20+++ b/libsparse/sparse_read.c
21@@ -353,13 +353,11 @@ static int sparse_file_read_sparse(struct sparse_file *s, int fd, bool crc)
22 return 0;
23 }
24
25-static int sparse_file_read_normal(struct sparse_file *s, int fd)
26+static int do_sparse_file_read_normal(struct sparse_file *s, int fd, uint32_t* buf, int64_t offset,
27+ int64_t remain)
28 {
29 int ret;
30- uint32_t *buf = malloc(s->block_size);
31- unsigned int block = 0;
32- int64_t remain = s->len;
33- int64_t offset = 0;
34+ unsigned int block = offset / s->block_size;
35 unsigned int to_read;
36 unsigned int i;
37 bool sparse_block;
38@@ -403,6 +401,19 @@ static int sparse_file_read_normal(struct sparse_file *s, int fd)
39 return 0;
40 }
41
42+static int sparse_file_read_normal(struct sparse_file* s, int fd)
43+{
44+ int ret;
45+ uint32_t* buf = (uint32_t*)malloc(s->block_size);
46+
47+ if (!buf)
48+ return -ENOMEM;
49+
50+ ret = do_sparse_file_read_normal(s, fd, buf, 0, s->len);
51+ free(buf);
52+ return ret;
53+}
54+
55 int sparse_file_read(struct sparse_file *s, int fd, bool sparse, bool crc)
56 {
57 if (crc && !sparse) {
58--
592.35.1.1320.gc452695387.dirty
60
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0016-libsparse-Add-hole-mode-to-sparse_file_read.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0016-libsparse-Add-hole-mode-to-sparse_file_read.patch
deleted file mode 100644
index e5221d2b4c..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0016-libsparse-Add-hole-mode-to-sparse_file_read.patch
+++ /dev/null
@@ -1,188 +0,0 @@
1From 41574b628ec4229c24dfe289af7b6978edcca4ed Mon Sep 17 00:00:00 2001
2From: Sean Anderson <sean.anderson@seco.com>
3Date: Thu, 30 Dec 2021 15:19:41 -0500
4Subject: [PATCH] libsparse: Add "hole" mode to sparse_file_read
5
6This adds support for filesystem-level sparse files. These files have
7holes which are not stored in the filesystem and when read are full of
8zeros. While these zeros may be significant in some types of files,
9other types of files may not care about the contents of holes. For
10example, most filesystem creation tools write to all the blocks they
11care about. Those blocks not written to will remain holes, and can be
12safely represented by "don't care" chunks. Using "don't care" chunks
13instead of fill chunks can result in a substantial reduction of the time
14it takes to program a sparse image.
15
16To accomplish this, we extend the existing "sparse" boolean parameter to
17be an enum of mode types. This enum represents the strategy we take when
18reading in a file. For the most part the implementation is
19straightforward. We use lseek to determine where the holes in the file
20are, and then use do_sparse_file_read_normal to create chunks for the
21data section. Note that every file has an implicit hole at its end.
22
23Change-Id: I0cfbf08886fca9a91cb753ec8734c84fcbe52c9f
24Upstream-Status: Backport [f96466b05543b984ef7315d830bab4a409228d35]
25Signed-off-by: Sean Anderson <sean.anderson@seco.com>
26---
27 libsparse/img2simg.c | 2 +-
28 libsparse/include/sparse/sparse.h | 32 +++++++++++---
29 libsparse/sparse_read.c | 71 +++++++++++++++++++++++++++++--
30 3 files changed, 93 insertions(+), 12 deletions(-)
31
32diff --git a/libsparse/img2simg.c b/libsparse/img2simg.c
33index a0db36f45..2e171b613 100644
34--- a/libsparse/img2simg.c
35+++ b/libsparse/img2simg.c
36@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
37 }
38
39 sparse_file_verbose(s);
40- ret = sparse_file_read(s, in, false, false);
41+ ret = sparse_file_read(s, in, SPARSE_READ_MODE_NORMAL, false);
42 if (ret) {
43 fprintf(stderr, "Failed to read file\n");
44 exit(-1);
45diff --git a/libsparse/include/sparse/sparse.h b/libsparse/include/sparse/sparse.h
46index 8b757d22a..b68aa21a8 100644
47--- a/libsparse/include/sparse/sparse.h
48+++ b/libsparse/include/sparse/sparse.h
49@@ -196,23 +196,41 @@ int64_t sparse_file_len(struct sparse_file *s, bool sparse, bool crc);
50 int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc,
51 int (*write)(void *priv, const void *data, int len), void *priv);
52
53+/**
54+ * enum sparse_read_mode - The method to use when reading in files
55+ * @SPARSE_READ_MODE_NORMAL: The input is a regular file. Constant chunks of
56+ * data (including holes) will be be converted to
57+ * fill chunks.
58+ * @SPARSE_READ_MODE_SPARSE: The input is an Android sparse file.
59+ * @SPARSE_READ_MODE_HOLE: The input is a regular file. Holes will be converted
60+ * to "don't care" chunks. Other constant chunks will
61+ * be converted to fill chunks.
62+ */
63+enum sparse_read_mode {
64+ SPARSE_READ_MODE_NORMAL = false,
65+ SPARSE_READ_MODE_SPARSE = true,
66+ SPARSE_READ_MODE_HOLE,
67+};
68+
69 /**
70 * sparse_file_read - read a file into a sparse file cookie
71 *
72 * @s - sparse file cookie
73 * @fd - file descriptor to read from
74- * @sparse - read a file in the Android sparse file format
75+ * @mode - mode to use when reading the input file
76 * @crc - verify the crc of a file in the Android sparse file format
77 *
78- * Reads a file into a sparse file cookie. If sparse is true, the file is
79- * assumed to be in the Android sparse file format. If sparse is false, the
80- * file will be sparsed by looking for block aligned chunks of all zeros or
81- * another 32 bit value. If crc is true, the crc of the sparse file will be
82- * verified.
83+ * Reads a file into a sparse file cookie. If @mode is
84+ * %SPARSE_READ_MODE_SPARSE, the file is assumed to be in the Android sparse
85+ * file format. If @mode is %SPARSE_READ_MODE_NORMAL, the file will be sparsed
86+ * by looking for block aligned chunks of all zeros or another 32 bit value. If
87+ * @mode is %SPARSE_READ_MODE_HOLE, the file will be sparsed like
88+ * %SPARSE_READ_MODE_NORMAL, but holes in the file will be converted to "don't
89+ * care" chunks. If crc is true, the crc of the sparse file will be verified.
90 *
91 * Returns 0 on success, negative errno on error.
92 */
93-int sparse_file_read(struct sparse_file *s, int fd, bool sparse, bool crc);
94+int sparse_file_read(struct sparse_file *s, int fd, enum sparse_read_mode mode, bool crc);
95
96 /**
97 * sparse_file_import - import an existing sparse file
98diff --git a/libsparse/sparse_read.c b/libsparse/sparse_read.c
99index ee4abd86a..81f48cc13 100644
100--- a/libsparse/sparse_read.c
101+++ b/libsparse/sparse_read.c
102@@ -414,16 +414,79 @@ static int sparse_file_read_normal(struct sparse_file* s, int fd)
103 return ret;
104 }
105
106-int sparse_file_read(struct sparse_file *s, int fd, bool sparse, bool crc)
107+#ifdef __linux__
108+static int sparse_file_read_hole(struct sparse_file* s, int fd)
109 {
110- if (crc && !sparse) {
111+ int ret;
112+ uint32_t* buf = (uint32_t*)malloc(s->block_size);
113+ int64_t end = 0;
114+ int64_t start = 0;
115+
116+ if (!buf) {
117+ return -ENOMEM;
118+ }
119+
120+ do {
121+ start = lseek(fd, end, SEEK_DATA);
122+ if (start < 0) {
123+ if (errno == ENXIO)
124+ /* The rest of the file is a hole */
125+ break;
126+
127+ error("could not seek to data");
128+ free(buf);
129+ return -errno;
130+ } else if (start > s->len) {
131+ break;
132+ }
133+
134+ end = lseek(fd, start, SEEK_HOLE);
135+ if (end < 0) {
136+ error("could not seek to end");
137+ free(buf);
138+ return -errno;
139+ }
140+ end = min(end, s->len);
141+
142+ start = ALIGN_DOWN(start, s->block_size);
143+ end = ALIGN(end, s->block_size);
144+ if (lseek(fd, start, SEEK_SET) < 0) {
145+ free(buf);
146+ return -errno;
147+ }
148+
149+ ret = do_sparse_file_read_normal(s, fd, buf, start, end - start);
150+ if (ret) {
151+ free(buf);
152+ return ret;
153+ }
154+ } while (end < s->len);
155+
156+ free(buf);
157+ return 0;
158+}
159+#else
160+static int sparse_file_read_hole(struct sparse_file* s __unused, int fd __unused)
161+{
162+ return -ENOTSUP;
163+}
164+#endif
165+
166+int sparse_file_read(struct sparse_file *s, int fd, enum sparse_read_mode mode, bool crc)
167+{
168+ if (crc && mode != SPARSE_READ_MODE_SPARSE) {
169 return -EINVAL;
170 }
171
172- if (sparse) {
173+ switch (mode) {
174+ case SPARSE_READ_MODE_SPARSE:
175 return sparse_file_read_sparse(s, fd, crc);
176- } else {
177+ case SPARSE_READ_MODE_NORMAL:
178 return sparse_file_read_normal(s, fd);
179+ case SPARSE_READ_MODE_HOLE:
180+ return sparse_file_read_hole(s, fd);
181+ default:
182+ return -EINVAL;
183 }
184 }
185
186--
1872.35.1.1320.gc452695387.dirty
188
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/0017-img2simg-Add-support-for-converting-holes-to-don-t-c.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/0017-img2simg-Add-support-for-converting-holes-to-don-t-c.patch
deleted file mode 100644
index 9d19f58095..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/0017-img2simg-Add-support-for-converting-holes-to-don-t-c.patch
+++ /dev/null
@@ -1,114 +0,0 @@
1From 00cce57eff1a0de3b93efa5da225e9eb33d19659 Mon Sep 17 00:00:00 2001
2From: Sean Anderson <sean.anderson@seco.com>
3Date: Thu, 30 Dec 2021 15:34:28 -0500
4Subject: [PATCH] img2simg: Add support for converting holes to "don't care"
5 chunks
6
7This adds support for converting files with holes to "don't care"
8chunks. This can result in a substantial reduction in the time it takes
9to program an image if it has many holes.
10
11Generally, constants compared to argc have been reduced by one, since we
12no longer have the program name as the first argument.
13
14Change-Id: I00750edc07d6415dcc07ae0351e9397b0222b7ba
15Upstream-Status: Backport [6150b00b6025918da8c28e5c2f929ecdf480a9d6]
16Signed-off-by: Sean Anderson <sean.anderson@seco.com>
17---
18 libsparse/img2simg.c | 41 ++++++++++++++++++++++++++++++-----------
19 1 file changed, 30 insertions(+), 11 deletions(-)
20
21diff --git a/libsparse/img2simg.c b/libsparse/img2simg.c
22index 2e171b613..c985d5449 100644
23--- a/libsparse/img2simg.c
24+++ b/libsparse/img2simg.c
25@@ -40,25 +40,42 @@
26
27 void usage()
28 {
29- fprintf(stderr, "Usage: img2simg <raw_image_file> <sparse_image_file> [<block_size>]\n");
30+ fprintf(stderr, "Usage: img2simg [-s] <raw_image_file> <sparse_image_file> [<block_size>]\n");
31 }
32
33 int main(int argc, char *argv[])
34 {
35+ char *arg_in;
36+ char *arg_out;
37+ enum sparse_read_mode mode = SPARSE_READ_MODE_NORMAL;
38+ int extra;
39 int in;
40+ int opt;
41 int out;
42 int ret;
43 struct sparse_file *s;
44 unsigned int block_size = 4096;
45 off64_t len;
46
47- if (argc < 3 || argc > 4) {
48+ while ((opt = getopt(argc, argv, "s")) != -1) {
49+ switch (opt) {
50+ case 's':
51+ mode = SPARSE_READ_MODE_HOLE;
52+ break;
53+ default:
54+ usage();
55+ exit(-1);
56+ }
57+ }
58+
59+ extra = argc - optind;
60+ if (extra < 2 || extra > 3) {
61 usage();
62 exit(-1);
63 }
64
65- if (argc == 4) {
66- block_size = atoi(argv[3]);
67+ if (extra == 3) {
68+ block_size = atoi(argv[optind + 2]);
69 }
70
71 if (block_size < 1024 || block_size % 4 != 0) {
72@@ -66,22 +83,24 @@ int main(int argc, char *argv[])
73 exit(-1);
74 }
75
76- if (strcmp(argv[1], "-") == 0) {
77+ arg_in = argv[optind];
78+ if (strcmp(arg_in, "-") == 0) {
79 in = STDIN_FILENO;
80 } else {
81- in = open(argv[1], O_RDONLY | O_BINARY);
82+ in = open(arg_in, O_RDONLY | O_BINARY);
83 if (in < 0) {
84- fprintf(stderr, "Cannot open input file %s\n", argv[1]);
85+ fprintf(stderr, "Cannot open input file %s\n", arg_in);
86 exit(-1);
87 }
88 }
89
90- if (strcmp(argv[2], "-") == 0) {
91+ arg_out = argv[optind + 1];
92+ if (strcmp(arg_out, "-") == 0) {
93 out = STDOUT_FILENO;
94 } else {
95- out = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0664);
96+ out = open(arg_out, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0664);
97 if (out < 0) {
98- fprintf(stderr, "Cannot open output file %s\n", argv[2]);
99+ fprintf(stderr, "Cannot open output file %s\n", arg_out);
100 exit(-1);
101 }
102 }
103@@ -96,7 +115,7 @@ int main(int argc, char *argv[])
104 }
105
106 sparse_file_verbose(s);
107- ret = sparse_file_read(s, in, SPARSE_READ_MODE_NORMAL, false);
108+ ret = sparse_file_read(s, in, mode, false);
109 if (ret) {
110 fprintf(stderr, "Failed to read file\n");
111 exit(-1);
112--
1132.35.1.1320.gc452695387.dirty
114
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff b/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff
deleted file mode 100644
index ddb41ea4b0..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/adb_libssl_11.diff
+++ /dev/null
@@ -1,48 +0,0 @@
1Description: adb: Make compatible with openssl 1.1
2 OpenSSL version 1.1 brought some API changes which broke the build here,
3 fix that by accessing rsa->n (and e) directly, using RSA_get0_key instead.
4Author: Chirayu Desai <chirayudesai1@gmail.com
5Last-Update: 2016-11-10
6---
7Upstream-Status: Pending
8
9This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
10---
11Upstream-Status: Pending
12
13 system/core/adb/adb_auth_host.c | 5 +++--
14 1 file changed, 3 insertions(+), 2 deletions(-)
15
16--- a/adb/adb_auth_host.c
17+++ b/adb/adb_auth_host.c
18@@ -75,6 +75,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa,
19 BIGNUM* rem = BN_new();
20- BIGNUM* n = BN_new();
21+ const BIGNUM* n;
22 BIGNUM* n0inv = BN_new();
23+ const BIGNUM* e;
24
25 if (RSA_size(rsa) != RSANUMBYTES) {
26 ret = 0;
27@@ -82,7 +83,7 @@ static int RSA_to_RSAPublicKey(RSA *rsa,
28 }
29
30 BN_set_bit(r32, 32);
31- BN_copy(n, rsa->n);
32+ RSA_get0_key(rsa, &n, &e, NULL);
33 BN_set_bit(r, RSANUMWORDS * 32);
34 BN_mod_sqr(rr, r, n, ctx);
35 BN_div(NULL, rem, n, r32, ctx);
36@@ -96,11 +97,10 @@ static int RSA_to_RSAPublicKey(RSA *rsa,
37 BN_div(n, rem, n, r32, ctx);
38 pkey->n[i] = BN_get_word(rem);
39 }
40- pkey->exponent = BN_get_word(rsa->e);
41+ pkey->exponent = BN_get_word(e);
42
43 out:
44 BN_free(n0inv);
45- BN_free(n);
46 BN_free(rem);
47 BN_free(r);
48 BN_free(rr);
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/core/b64_pton_function_decl.patch b/meta-oe/recipes-devtools/android-tools/android-tools/core/b64_pton_function_decl.patch
deleted file mode 100644
index 80410f1d2b..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/core/b64_pton_function_decl.patch
+++ /dev/null
@@ -1,14 +0,0 @@
1Add protoype declaration for b64_pton
2
3Upstream-Status: Pending
4Signed-off-by: Khem Raj <raj.khem@gmail.com>
5--- a/adb/adb_auth_client.c
6+++ b/adb/adb_auth_client.c
7@@ -29,6 +29,7 @@
8
9 #define TRACE_TAG TRACE_AUTH
10
11+extern int b64_pton(const char* src, uint8_t* target, size_t targsize);
12
13 struct adb_public_key {
14 struct listnode node;
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-allow-notifying-systemd.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-allow-notifying-systemd.patch
new file mode 100644
index 0000000000..a5caf39c80
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-allow-notifying-systemd.patch
@@ -0,0 +1,41 @@
1From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
2Date: Fri, 30 Sep 2022 16:54:02 +0200
3Subject: adb: daemon: allow notifying systemd when ready
4
5When using `systemd` on Linux, we should allow `adbd` to notify
6`systemd` once it has started and configured its USB/network interface.
7This allows us to (for example) wait for the daemon to bind to the
8FunctionFS endpoints, then activate the USB gadget.
9
10Forwarded: https://android-review.googlesource.com/c/platform/packages/modules/adb/+/2238429
11Upstream-Status: Inappropriate [Debian-specific]
12---
13 packages/modules/adb/daemon/main.cpp | 8 ++++++++
14 1 file changed, 8 insertions(+)
15
16diff --git a/packages/modules/adb/daemon/main.cpp b/packages/modules/adb/daemon/main.cpp
17index d1b999b..deba593 100644
18--- a/packages/modules/adb/daemon/main.cpp
19+++ b/packages/modules/adb/daemon/main.cpp
20@@ -49,6 +49,10 @@
21 #include "selinux/android.h"
22 #endif
23
24+#if defined(__linux__)
25+#include <systemd/sd-daemon.h>
26+#endif
27+
28 #include "adb.h"
29 #include "adb_auth.h"
30 #include "adb_listeners.h"
31@@ -302,6 +306,10 @@ int adbd_main(int server_port) {
32 init_jdwp();
33 D("adbd_main(): post init_jdwp()");
34
35+#if defined(__linux__)
36+ sd_notify(1, "READY=1");
37+#endif
38+
39 D("Event loop starting");
40 fdevent_loop();
41
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-allow-usb-on-linux.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-allow-usb-on-linux.patch
new file mode 100644
index 0000000000..76e2427fc2
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-allow-usb-on-linux.patch
@@ -0,0 +1,28 @@
1From: Julien Massot <julien.massot@collabora.com>
2Date: Mon, 5 Sep 2022 16:00:12 +0200
3Subject: adb: daemon: allow binding to USB on Linux systems
4
5Linux systems are also capable of using FunctionFS for USB gadget
6configurations. This requires creating a specific gadget configuration
7using ConfigFS (including an `ffs.adb` function) and mounting
8FunctionFS to `/dev/usb-ffs/adb`.
9
10Forwarded: https://android-review.googlesource.com/c/platform/packages/modules/adb/+/2238428
11Upstream-Status: Inappropriate [Debian-specific]
12---
13 packages/modules/adb/daemon/main.cpp | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-)
15
16diff --git a/packages/modules/adb/daemon/main.cpp b/packages/modules/adb/daemon/main.cpp
17index 188272a..6c949c1 100644
18--- a/packages/modules/adb/daemon/main.cpp
19+++ b/packages/modules/adb/daemon/main.cpp
20@@ -251,7 +251,7 @@ int adbd_main(int server_port) {
21
22 bool is_usb = false;
23
24-#if defined(__ANDROID__)
25+#if defined(__linux__)
26 if (access(USB_FFS_ADB_EP0, F_OK) == 0) {
27 // Listen on USB.
28 usb_init();
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-don-t-require-authorization-on-Linux.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-don-t-require-authorization-on-Linux.patch
new file mode 100644
index 0000000000..5d3ed124bc
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-don-t-require-authorization-on-Linux.patch
@@ -0,0 +1,27 @@
1From 2427e520751b13a6e0a409f427f1ec9b23e63447 Mon Sep 17 00:00:00 2001
2From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
3Date: Wed, 3 May 2023 18:36:06 +0200
4Subject: [PATCH] adb: daemon: don't require authorization on Linux
5
6Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
7Upstream-Status: Inappropriate [Debian-specific]
8---
9 packages/modules/adb/daemon/main.cpp | 2 ++
10 1 file changed, 2 insertions(+)
11
12diff --git a/packages/modules/adb/daemon/main.cpp b/packages/modules/adb/daemon/main.cpp
13index 188272ae3..02a57f4e2 100644
14--- a/packages/modules/adb/daemon/main.cpp
15+++ b/packages/modules/adb/daemon/main.cpp
16@@ -224,6 +224,8 @@ int adbd_main(int server_port) {
17 auth_required = android::base::GetBoolProperty("ro.adb.secure", false);
18 #endif
19 }
20+#else
21+ auth_required = false;
22 #endif
23
24 // Our external storage path may be different than apps, since
25--
262.39.2
27
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-usb-drop-property-monitor.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-usb-drop-property-monitor.patch
new file mode 100644
index 0000000000..0f1d3f7a6f
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-adbd-adbd-usb-drop-property-monitor.patch
@@ -0,0 +1,57 @@
1From ba56ee6f092601932f9146eeb4f8b057da157be2 Mon Sep 17 00:00:00 2001
2From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
3Date: Tue, 2 May 2023 17:16:22 +0200
4Subject: [PATCH] adb: daemon: usb: drop property monitor
5
6This is an Android-only feature not available on Linux.
7Upstream-Status: Inappropriate [Debian-specific]
8---
9 packages/modules/adb/daemon/usb.cpp | 6 ++++++
10 1 file changed, 6 insertions(+)
11
12diff --git a/packages/modules/adb/daemon/usb.cpp b/packages/modules/adb/daemon/usb.cpp
13index ec22f6661..e904a7629 100644
14--- a/packages/modules/adb/daemon/usb.cpp
15+++ b/packages/modules/adb/daemon/usb.cpp
16@@ -48,7 +48,9 @@
17
18 #include "adb_unique_fd.h"
19 #include "adb_utils.h"
20+#if defined(__ANDROID__)
21 #include "daemon/property_monitor.h"
22+#endif
23 #include "daemon/usb_ffs.h"
24 #include "sysdeps/chrono.h"
25 #include "transfer_id.h"
26@@ -744,6 +746,7 @@ struct UsbFfsConnection : public Connection {
27 static void usb_ffs_open_thread() {
28 adb_thread_setname("usb ffs open");
29
30+#if defined(__ANDROID__)
31 // When the device is acting as a USB host, we'll be unable to bind to the USB gadget on kernels
32 // that don't carry a downstream patch to enable that behavior.
33 //
34@@ -757,6 +760,7 @@ static void usb_ffs_open_thread() {
35 // Return false (i.e. break out of PropertyMonitor::Run) when the property != 1.
36 return android::base::ParseBool(value) == android::base::ParseBoolResult::kTrue;
37 });
38+#endif
39
40 while (true) {
41 unique_fd control;
42@@ -767,11 +771,13 @@ static void usb_ffs_open_thread() {
43 continue;
44 }
45
46+#if defined(__ANDROID__)
47 if (android::base::GetBoolProperty(kPropertyUsbDisabled, false)) {
48 LOG(INFO) << "pausing USB due to " << kPropertyUsbDisabled;
49 prop_mon.Run();
50 LOG(INFO) << "resuming USB";
51 }
52+#endif
53
54 atransport* transport = new atransport();
55 transport->serial = "UsbFfs";
56--
572.39.2
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-dev-typos.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-dev-typos.patch
new file mode 100644
index 0000000000..2ac7d66bd4
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-dev-typos.patch
@@ -0,0 +1,16 @@
1Description: Fix typos
2Author: Kai-Chung Yan (殷啟聰)
3Last-Update: 2016-10-01
4Forwarded: not-needed
5Upstream-Status: Inappropriate [Debian-specific]
6--- a/development/tools/etc1tool/etc1tool.cpp
7+++ b/development/tools/etc1tool/etc1tool.cpp
8@@ -56,7 +56,7 @@
9 "\t\t image to difffile. (Only valid when encoding).\n");
10 fprintf(stderr,
11 "\tIf outfile is not specified, an outfile path is constructed from infile,\n");
12- fprintf(stderr, "\twith the apropriate suffix (.pkm or .png).\n");
13+ fprintf(stderr, "\twith the appropriate suffix (.pkm or .png).\n");
14 exit(1);
15 }
16
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-Nullable.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-Nullable.patch
new file mode 100644
index 0000000000..e9a9a91bfb
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-Nullable.patch
@@ -0,0 +1,14 @@
1Description: Bring Clang's _Nullable keyword to GCC
2 This patch is for gcc only, no need for clang.
3Forwarded: not-needed
4Upstream-Status: Inappropriate [Debian-specific]
5--- a/libnativehelper/file_descriptor_jni.c
6+++ b/libnativehelper/file_descriptor_jni.c
7@@ -22,6 +22,7 @@
8 #include "ALog-priv.h"
9
10 #include "JniConstants.h"
11+#define _Nullable
12
13 static void EnsureArgumentIsFileDescriptor(JNIEnv* env, jobject instance) {
14 ALOG_ALWAYS_FATAL_IF(instance == NULL, "FileDescriptor is NULL");
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-stdatomic.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-stdatomic.patch
new file mode 100644
index 0000000000..ed670eacf4
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-stdatomic.patch
@@ -0,0 +1,68 @@
1Description: Fix incompatibility between <stdatomic.h> and <atomic>
2 This 2 headers combined will cause errors for both GCC and Clang. This patch
3 makes sure only one of them is present at any time.
4 .
5 This patch is for gcc only, no need for clang.
6Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932
7Bug: https://reviews.llvm.org/D45470
8Forwarded: not-needed
9Upstream-Status: Inappropriate [Debian-specific]
10--- a/system/core/libcutils/include/cutils/atomic.h
11+++ b/system/core/libcutils/include/cutils/atomic.h
12@@ -19,7 +19,23 @@
13
14 #include <stdint.h>
15 #include <sys/types.h>
16+#ifdef __cplusplus
17+#include <atomic>
18+using std::atomic_compare_exchange_strong_explicit;
19+using std::atomic_fetch_add_explicit;
20+using std::atomic_fetch_or_explicit;
21+using std::atomic_fetch_sub_explicit;
22+using std::atomic_int_least32_t;
23+using std::atomic_load_explicit;
24+using std::atomic_store_explicit;
25+using std::atomic_thread_fence;
26+using std::memory_order::memory_order_acquire;
27+using std::memory_order::memory_order_relaxed;
28+using std::memory_order::memory_order_release;
29+using std::memory_order::memory_order_seq_cst;
30+#else
31 #include <stdatomic.h>
32+#endif
33
34 #ifndef ANDROID_ATOMIC_INLINE
35 #define ANDROID_ATOMIC_INLINE static inline
36--- a/system/core/libcutils/include/cutils/trace.h
37+++ b/system/core/libcutils/include/cutils/trace.h
38@@ -18,7 +18,14 @@
39 #define _LIBS_CUTILS_TRACE_H
40
41 #include <inttypes.h>
42+#ifdef __cplusplus
43+#include <atomic>
44+using std::atomic_bool;
45+using std::atomic_load_explicit;
46+using std::memory_order_acquire;
47+#else
48 #include <stdatomic.h>
49+#endif
50 #include <stdbool.h>
51 #include <stdint.h>
52 #include <stdio.h>
53--- a/system/logging/liblog/logger.h
54+++ b/system/logging/liblog/logger.h
55@@ -16,7 +16,13 @@
56
57 #pragma once
58
59+#ifdef __cplusplus
60+#include <atomic>
61+using std::atomic_int;
62+using std::atomic_uintptr_t;
63+#else
64 #include <stdatomic.h>
65+#endif
66 #include <sys/cdefs.h>
67
68 #include <log/log.h>
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-workaround__builtin_available.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-workaround__builtin_available.patch
new file mode 100644
index 0000000000..60ca08cc24
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-gcc-workaround__builtin_available.patch
@@ -0,0 +1,148 @@
1Description: Workaround Clang's __builtin_available keyword
2 This patch is for gcc only, no need for clang.
3Forwarded: not-needed
4Upstream-Status: Inappropriate [Debian-specific]
5--- a/system/libbase/logging.cpp
6+++ b/system/libbase/logging.cpp
7@@ -209,8 +209,9 @@ static std::recursive_mutex& TagLock() {
8 static std::string* gDefaultTag;
9
10 void SetDefaultTag(const std::string& tag) {
11- if (__builtin_available(android 30, *)) {
12+// if (__builtin_available(android 30, *)) {
13 __android_log_set_default_tag(tag.c_str());
14+#if 0
15 } else {
16 std::lock_guard<std::recursive_mutex> lock(TagLock());
17 if (gDefaultTag != nullptr) {
18@@ -221,6 +222,7 @@ void SetDefaultTag(const std::string& tag) {
19 gDefaultTag = new std::string(tag);
20 }
21 }
22+#endif
23 }
24
25 static bool gInitialized = false;
26@@ -314,13 +316,15 @@ static void LogdLogChunk(LogId id, LogSeverity severity, const char* tag, const
27 int32_t lg_id = LogIdTolog_id_t(id);
28 int32_t priority = LogSeverityToPriority(severity);
29
30- if (__builtin_available(android 30, *)) {
31+// if (__builtin_available(android 30, *)) {
32 __android_log_message log_message = {sizeof(__android_log_message), lg_id, priority, tag,
33 static_cast<const char*>(nullptr), 0, message};
34 __android_log_logd_logger(&log_message);
35+#if 0
36 } else {
37 __android_log_buf_print(lg_id, priority, tag, "%s", message);
38 }
39+#endif
40 }
41
42 LogdLogger::LogdLogger(LogId default_log_id) : default_log_id_(default_log_id) {}
43@@ -396,7 +400,7 @@ LogFunction SetLogger(LogFunction&& logger) {
44 LogFunction old_logger = std::move(Logger());
45 Logger() = std::move(logger);
46
47- if (__builtin_available(android 30, *)) {
48+// if (__builtin_available(android 30, *)) {
49 __android_log_set_logger([](const struct __android_log_message* log_message) {
50 auto log_id = log_id_tToLogId(log_message->buffer_id);
51 auto severity = PriorityToLogSeverity(log_message->priority);
52@@ -404,7 +408,7 @@ LogFunction SetLogger(LogFunction&& logger) {
53 Logger()(log_id, severity, log_message->tag, log_message->file, log_message->line,
54 log_message->message);
55 });
56- }
57+// }
58 return old_logger;
59 }
60
61@@ -412,9 +416,9 @@ AbortFunction SetAborter(AbortFunction&& aborter) {
62 AbortFunction old_aborter = std::move(Aborter());
63 Aborter() = std::move(aborter);
64
65- if (__builtin_available(android 30, *)) {
66+// if (__builtin_available(android 30, *)) {
67 __android_log_set_aborter([](const char* abort_message) { Aborter()(abort_message); });
68- }
69+// }
70 return old_aborter;
71 }
72
73@@ -500,11 +504,13 @@ LogMessage::~LogMessage() {
74
75 // Abort if necessary.
76 if (data_->GetSeverity() == FATAL) {
77- if (__builtin_available(android 30, *)) {
78+// if (__builtin_available(android 30, *)) {
79 __android_log_call_aborter(msg.c_str());
80+#if 0
81 } else {
82 Aborter()(msg.c_str());
83 }
84+#endif
85 }
86 }
87
88@@ -515,10 +521,11 @@ std::ostream& LogMessage::stream() {
89 void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity severity, const char* tag,
90 const char* message) {
91 int32_t priority = LogSeverityToPriority(severity);
92- if (__builtin_available(android 30, *)) {
93+// if (__builtin_available(android 30, *)) {
94 __android_log_message log_message = {
95 sizeof(__android_log_message), LOG_ID_DEFAULT, priority, tag, file, line, message};
96 __android_log_write_log_message(&log_message);
97+#if 0
98 } else {
99 if (tag == nullptr) {
100 std::lock_guard<std::recursive_mutex> lock(TagLock());
101@@ -531,37 +538,44 @@ void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity severi
102 Logger()(DEFAULT, severity, tag, file, line, message);
103 }
104 }
105+#endif
106 }
107
108 LogSeverity GetMinimumLogSeverity() {
109- if (__builtin_available(android 30, *)) {
110+// if (__builtin_available(android 30, *)) {
111 return PriorityToLogSeverity(__android_log_get_minimum_priority());
112+#if 0
113 } else {
114 return gMinimumLogSeverity;
115 }
116+#endif
117 }
118
119 bool ShouldLog(LogSeverity severity, const char* tag) {
120 // Even though we're not using the R liblog functions in this function, if we're running on Q,
121 // we need to fall back to using gMinimumLogSeverity, since __android_log_is_loggable() will not
122 // take into consideration the value from SetMinimumLogSeverity().
123- if (__builtin_available(android 30, *)) {
124+// if (__builtin_available(android 30, *)) {
125 int32_t priority = LogSeverityToPriority(severity);
126 return __android_log_is_loggable(priority, tag, ANDROID_LOG_INFO);
127+#if 0
128 } else {
129 return severity >= gMinimumLogSeverity;
130 }
131+#endif
132 }
133
134 LogSeverity SetMinimumLogSeverity(LogSeverity new_severity) {
135- if (__builtin_available(android 30, *)) {
136+// if (__builtin_available(android 30, *)) {
137 int32_t priority = LogSeverityToPriority(new_severity);
138 return PriorityToLogSeverity(__android_log_set_minimum_priority(priority));
139+#if 0
140 } else {
141 LogSeverity old_severity = gMinimumLogSeverity;
142 gMinimumLogSeverity = new_severity;
143 return old_severity;
144 }
145+#endif
146 }
147
148 ScopedLogSeverity::ScopedLogSeverity(LogSeverity new_severity) {
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Added-missing-headers.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Added-missing-headers.patch
new file mode 100644
index 0000000000..38ff305870
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Added-missing-headers.patch
@@ -0,0 +1,15 @@
1Description: Added missing headers causing compile errors
2Author: Umang Parmar <umangjparmar@gmail.com>
3Forwarded: not-needed
4
5Upstream-Status: Inappropriate [Debian-specific]
6--- a/packages/modules/adb/pairing_connection/pairing_server.cpp
7+++ b/packages/modules/adb/pairing_connection/pairing_server.cpp
8@@ -20,6 +20,7 @@
9 #include <sys/eventfd.h>
10
11 #include <atomic>
12+#include <condition_variable>
13 #include <deque>
14 #include <iomanip>
15 #include <mutex>
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Drop-gki-dependency-from-mkbootimg.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Drop-gki-dependency-from-mkbootimg.patch
new file mode 100644
index 0000000000..6b940df707
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Drop-gki-dependency-from-mkbootimg.patch
@@ -0,0 +1,114 @@
1Description: Drop gki dependency from mkbootimg
2 `mkbootimg` is currently unusable due to a missing `gki` python
3 module. This module is only needed for signing GKI boot images, which
4 is deprecated as the argument group description implies.
5 This patch disables this (deprecated) signature feature entirely as
6 it's unlikely Debian users will actually need it.
7Author: Arnaud Ferraris <aferraris@debian.org>
8Forwarded: not-needed
9Upstream-Status: Inappropriate [Debian-specific]
10--- a/system/tools/mkbootimg/mkbootimg.py
11+++ b/system/tools/mkbootimg/mkbootimg.py
12@@ -28,8 +28,6 @@ import os
13 import re
14 import tempfile
15
16-from gki.generate_gki_certificate import generate_gki_certificate
17-
18 # Constant and structure definition is in
19 # system/tools/mkbootimg/include/bootimg/bootimg.h
20 BOOT_MAGIC = 'ANDROID!'
21@@ -105,12 +103,6 @@ def get_recovery_dtbo_offset(args):
22 return dtbo_offset
23
24
25-def should_add_legacy_gki_boot_signature(args):
26- if args.gki_signing_key and args.gki_signing_algorithm:
27- return True
28- return False
29-
30-
31 def write_header_v3_and_above(args):
32 if args.header_version > 3:
33 boot_header_size = BOOT_IMAGE_HEADER_V4_SIZE
34@@ -134,8 +126,6 @@ def write_header_v3_and_above(args):
35 if args.header_version >= 4:
36 # The signature used to verify boot image v4.
37 boot_signature_size = 0
38- if should_add_legacy_gki_boot_signature(args):
39- boot_signature_size = BOOT_IMAGE_V4_SIGNATURE_SIZE
40 args.output.write(pack('I', boot_signature_size))
41 pad_file(args.output, BOOT_IMAGE_HEADER_V3_PAGESIZE)
42
43@@ -549,19 +539,6 @@ def parse_cmdline():
44 parser.add_argument('--vendor_bootconfig', type=FileType('rb'),
45 help='path to the vendor bootconfig file')
46
47- gki_2_0_signing_args = parser.add_argument_group(
48- '[DEPRECATED] GKI 2.0 signing arguments')
49- gki_2_0_signing_args.add_argument(
50- '--gki_signing_algorithm', help='GKI signing algorithm to use')
51- gki_2_0_signing_args.add_argument(
52- '--gki_signing_key', help='path to RSA private key file')
53- gki_2_0_signing_args.add_argument(
54- '--gki_signing_signature_args', default='',
55- help='other hash arguments passed to avbtool')
56- gki_2_0_signing_args.add_argument(
57- '--gki_signing_avbtool_path', default='avbtool',
58- help='path to avbtool for boot signature generation')
59-
60 args, extra_args = parser.parse_known_args()
61 if args.vendor_boot is not None and args.header_version > 3:
62 extra_args = parse_vendor_ramdisk_args(args, extra_args)
63@@ -577,42 +554,6 @@ def parse_cmdline():
64 return args
65
66
67-def add_boot_image_signature(args, pagesize):
68- """Adds the boot image signature.
69-
70- Note that the signature will only be verified in VTS to ensure a
71- generic boot.img is used. It will not be used by the device
72- bootloader at boot time. The bootloader should only verify
73- the boot vbmeta at the end of the boot partition (or in the top-level
74- vbmeta partition) via the Android Verified Boot process, when the
75- device boots.
76- """
77- # Flush the buffer for signature calculation.
78- args.output.flush()
79-
80- # Outputs the signed vbmeta to a separate file, then append to boot.img
81- # as the boot signature.
82- with tempfile.TemporaryDirectory() as temp_out_dir:
83- boot_signature_output = os.path.join(temp_out_dir, 'boot_signature')
84- generate_gki_certificate(
85- image=args.output.name, avbtool=args.gki_signing_avbtool_path,
86- name='boot', algorithm=args.gki_signing_algorithm,
87- key=args.gki_signing_key, salt='d00df00d',
88- additional_avb_args=args.gki_signing_signature_args.split(),
89- output=boot_signature_output,
90- )
91- with open(boot_signature_output, 'rb') as boot_signature:
92- boot_signature_bytes = boot_signature.read()
93- if len(boot_signature_bytes) > BOOT_IMAGE_V4_SIGNATURE_SIZE:
94- raise ValueError(
95- f'boot sigature size is > {BOOT_IMAGE_V4_SIGNATURE_SIZE}')
96- boot_signature_bytes += b'\x00' * (
97- BOOT_IMAGE_V4_SIGNATURE_SIZE - len(boot_signature_bytes))
98- assert len(boot_signature_bytes) == BOOT_IMAGE_V4_SIGNATURE_SIZE
99- args.output.write(boot_signature_bytes)
100- pad_file(args.output, pagesize)
101-
102-
103 def write_data(args, pagesize):
104 write_padded_file(args.output, args.kernel, pagesize)
105 write_padded_file(args.output, args.ramdisk, pagesize)
106@@ -622,8 +563,6 @@ def write_data(args, pagesize):
107 write_padded_file(args.output, args.recovery_dtbo, pagesize)
108 if args.header_version == 2:
109 write_padded_file(args.output, args.dtb, pagesize)
110- if args.header_version >= 4 and should_add_legacy_gki_boot_signature(args):
111- add_boot_image_signature(args, pagesize)
112
113
114 def write_vendor_boot_data(args):
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Implement-const_iterator-operator.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Implement-const_iterator-operator.patch
new file mode 100644
index 0000000000..4679edd537
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-Implement-const_iterator-operator.patch
@@ -0,0 +1,37 @@
1Description: Implement const_iterator::operator--
2Forwarded: not-needed
3
4Needed for
5android-platform-frameworks-base/libs/androidfw/LoadedArsc.cpp
6when compiling against libstdc++.
7Upstream-Status: Inappropriate [Debian-specific]
8---
9--- a/system/incremental_delivery/incfs/util/include/util/map_ptr.h
10+++ b/system/incremental_delivery/incfs/util/include/util/map_ptr.h
11@@ -180,6 +180,11 @@ public:
12 return *this;
13 }
14
15+ const const_iterator& operator--() {
16+ safe_ptr_--;
17+ return *this;
18+ }
19+
20 const_iterator& operator+=(int n) {
21 safe_ptr_ = safe_ptr_ + n;
22 return *this;
23@@ -321,6 +326,14 @@ public:
24 return temp;
25 }
26
27+ template <typename T1 = T, NotVoid<T1> = 0>
28+ const map_ptr<T1> operator--(int) {
29+ map_ptr<T1> temp = *this;
30+ LIBINCFS_MAP_PTR_DEBUG_CODE(verified_ = false);
31+ --ptr_;
32+ return temp;
33+ }
34+
35 template <typename S, typename T1 = T, NotVoid<T1> = 0>
36 map_ptr<T1> operator+(const S n) const {
37 return map_ptr<T1>(map_, ptr_ + n, verified_block_);
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-add-missing-headers.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-add-missing-headers.patch
new file mode 100644
index 0000000000..b0bac72320
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-add-missing-headers.patch
@@ -0,0 +1,13 @@
1Description: add missing headers
2Forwarded: not-needed
3Upstream-Status: Inappropriate [Debian-specific]
4--- a/system/core/fastboot/fastboot_driver_interface.h
5+++ b/system/core/fastboot/fastboot_driver_interface.h
6@@ -17,6 +17,7 @@
7
8 #include <string>
9
10+#include <stdint.h>
11 #include "android-base/unique_fd.h"
12
13 class Transport;
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-hard-code-build-number.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-hard-code-build-number.patch
new file mode 100644
index 0000000000..7555ba6406
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-hard-code-build-number.patch
@@ -0,0 +1,57 @@
1Description: just hard code rather than deal with circular deps
2Forwarded: not-needed
3Upstream-Status: Inappropriate [Debian-specific]
4--- a/packages/modules/adb/adb.cpp
5+++ b/packages/modules/adb/adb.cpp
6@@ -47,9 +47,6 @@
7 #include <android-base/utf8.h>
8 #include <diagnose_usb.h>
9
10-#include <build/version.h>
11-#include <platform_tools_version.h>
12-
13 #include "adb_auth.h"
14 #include "adb_io.h"
15 #include "adb_listeners.h"
16@@ -100,7 +97,7 @@
17 "Installed as %s\n"
18 "Running on %s\n",
19 ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION, PLATFORM_TOOLS_VERSION,
20- android::build::GetBuildNumber().c_str(), android::base::GetExecutablePath().c_str(),
21+ "debian", android::base::GetExecutablePath().c_str(),
22 GetOSVersion().c_str());
23 }
24
25@@ -1339,7 +1339,7 @@ HostRequestResult handle_host_request(std::string_view service, TransportType ty
26 status.set_mdns_backend_forced(getenv("ADB_MDNS_OPENSCREEN") != nullptr);
27
28 status.set_version(std::string(PLATFORM_TOOLS_VERSION));
29- status.set_build(android::build::GetBuildNumber());
30+ status.set_build("debian");
31 status.set_executable_absolute_path(android::base::GetExecutablePath());
32 status.set_log_absolute_path(GetLogFilePath());
33 status.set_os(GetOSVersion());
34--- a/system/core/fastboot/fastboot.cpp
35+++ b/system/core/fastboot/fastboot.cpp
36@@ -64,11 +64,9 @@
37 #include <android-base/stringprintf.h>
38 #include <android-base/strings.h>
39 #include <android-base/unique_fd.h>
40-#include <build/version.h>
41 #include <libavb/libavb.h>
42 #include <liblp/liblp.h>
43 #include <liblp/super_layout_builder.h>
44-#include <platform_tools_version.h>
45 #include <sparse/sparse.h>
46 #include <ziparchive/zip_archive.h>
47
48@@ -1962,8 +1960,7 @@
49 setvbuf(stdout, nullptr, _IONBF, 0);
50 setvbuf(stderr, nullptr, _IONBF, 0);
51 } else if (name == "version") {
52- fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION,
53- android::build::GetBuildNumber().c_str());
54+ fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, "debian");
55 fprintf(stdout, "Installed as %s\n", android::base::GetExecutablePath().c_str());
56 return 0;
57 } else {
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-libusb-header-path.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-libusb-header-path.patch
new file mode 100644
index 0000000000..9a15ec1a19
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-libusb-header-path.patch
@@ -0,0 +1,17 @@
1Description: libusb.h comes from different location
2Author: Umang Parmar <umangjparmar@gmail.com>
3Forwarded: not-needed
4Last-Update: 2018-05-26
5
6Upstream-Status: Inappropriate [Debian-specific]
7--- a/packages/modules/adb/client/usb_libusb.cpp
8+++ b/packages/modules/adb/client/usb_libusb.cpp
9@@ -36,7 +36,7 @@
10 #include <unordered_map>
11 #include <vector>
12
13-#include <libusb/libusb.h>
14+#include <libusb-1.0/libusb.h>
15
16 #include <android-base/file.h>
17 #include <android-base/logging.h>
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-move-log-file-to-proper-dir.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-move-log-file-to-proper-dir.patch
new file mode 100644
index 0000000000..201ec62bca
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-move-log-file-to-proper-dir.patch
@@ -0,0 +1,19 @@
1Description: Update log file directory.
2Author: Umang Parmar <umangjparmar@gmail.com>
3Last Updated: 2018-05-17
4
5Upstream-Status: Inappropriate [Debian-specific]
6--- a/packages/modules/adb/adb_utils.cpp
7+++ b/packages/modules/adb/adb_utils.cpp
8@@ -343,6 +343,11 @@
9
10 return temp_path_utf8 + log_name;
11 #else
12+ std::string log_dir = android::base::StringPrintf("/run/user/%u/adb.log", getuid());
13+ struct stat st = {0};
14+ if (stat(log_dir.c_str(), &st) == 0) {
15+ return log_dir;
16+ }
17 const char* tmp_dir = getenv("TMPDIR");
18 if (tmp_dir == nullptr) tmp_dir = "/tmp";
19 return android::base::StringPrintf("%s/adb.%u.log", tmp_dir, getuid());
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-stub-out-fastdeploy.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-stub-out-fastdeploy.patch
new file mode 100644
index 0000000000..fb16cff79a
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-stub-out-fastdeploy.patch
@@ -0,0 +1,99 @@
1Description: Defer packaging fastdeploy with adb for 29.x.x tags.
2Forwarded: not-needed
3Upstream-Status: Inappropriate [Debian-specific]
4--- a/packages/modules/adb/client/adb_install.cpp
5+++ b/packages/modules/adb/client/adb_install.cpp
6@@ -185,14 +185,6 @@
7 }
8
9 if (use_fastdeploy) {
10- auto metadata = extract_metadata(file);
11- if (metadata.has_value()) {
12- // pass all but 1st (command) and last (apk path) parameters through to pm for
13- // session creation
14- std::vector<const char*> pm_args{argv + 1, argv + argc - 1};
15- auto patchFd = install_patch(pm_args.size(), pm_args.data());
16- return stream_patch(file, std::move(metadata.value()), std::move(patchFd));
17- }
18 }
19
20 struct stat sb;
21@@ -280,16 +272,6 @@
22 argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */
23
24 if (use_fastdeploy) {
25- auto metadata = extract_metadata(apk_file[0]);
26- if (metadata.has_value()) {
27- auto patchFd = apply_patch_on_device(apk_dest.c_str());
28- int status = stream_patch(apk_file[0], std::move(metadata.value()), std::move(patchFd));
29-
30- result = pm_command(argc, argv);
31- delete_device_file(apk_dest);
32-
33- return status;
34- }
35 }
36
37 if (do_sync_push(apk_file, apk_dest.c_str(), false, CompressionType::Any, false, false)) {
38@@ -457,7 +439,6 @@
39 std::vector<const char*> argv, bool* use_fastdeploy,
40 FastDeploy_AgentUpdateStrategy* agent_update_strategy) {
41 *use_fastdeploy = false;
42- *agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion;
43
44 std::vector<const char*> passthrough;
45 for (auto&& arg : argv) {
46@@ -466,11 +447,8 @@
47 } else if (arg == "--no-fastdeploy"sv) {
48 *use_fastdeploy = false;
49 } else if (arg == "--force-agent"sv) {
50- *agent_update_strategy = FastDeploy_AgentUpdateAlways;
51 } else if (arg == "--date-check-agent"sv) {
52- *agent_update_strategy = FastDeploy_AgentUpdateNewerTimeStamp;
53 } else if (arg == "--version-check-agent"sv) {
54- *agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion;
55 } else {
56 passthrough.push_back(arg);
57 }
58@@ -484,12 +462,11 @@
59 bool incremental_wait = false;
60
61 bool use_fastdeploy = false;
62- FastDeploy_AgentUpdateStrategy agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion;
63
64 auto unused_argv = parse_install_mode({argv, argv + argc}, &install_mode, &incremental_request,
65 &incremental_wait);
66 auto passthrough_argv =
67- parse_fast_deploy_mode(std::move(unused_argv), &use_fastdeploy, &agent_update_strategy);
68+ parse_fast_deploy_mode(std::move(unused_argv), &use_fastdeploy, nullptr);
69
70 auto [primary_mode, fallback_mode] =
71 calculate_install_mode(install_mode, use_fastdeploy, incremental_request);
72@@ -499,14 +476,11 @@
73 error_exit("Attempting to use streaming install on unsupported device");
74 }
75
76- if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) {
77- fprintf(stderr,
78- "Fast Deploy is only compatible with devices of API version %d or higher, "
79- "ignoring.\n",
80- kFastDeployMinApi);
81+ if (use_fastdeploy) {
82+ printf("Fast Deploy is unavailable in this build of adb, "
83+ "ignoring.\n");
84 use_fastdeploy = false;
85 }
86- fastdeploy_set_agent_update_strategy(agent_update_strategy);
87
88 if (passthrough_argv.size() < 2) {
89 error_exit("install requires an apk argument");
90--- a/packages/modules/adb/client/commandline.cpp
91+++ b/packages/modules/adb/client/commandline.cpp
92@@ -63,7 +63,6 @@
93 #include "bugreport.h"
94 #include "client/file_sync_client.h"
95 #include "commandline.h"
96-#include "fastdeploy.h"
97 #include "incremental_server.h"
98 #include "services.h"
99 #include "shell_protocol.h"
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-throw-exception-on-unknown-os.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-throw-exception-on-unknown-os.patch
new file mode 100644
index 0000000000..2e254e0d46
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-throw-exception-on-unknown-os.patch
@@ -0,0 +1,17 @@
1Description: Turn #error into exceptions
2 So the library can be built on non-Linux platforms too, although can't
3 guarauntee its functionality regarding that piece of code.
4Forwarded: not-needed
5Upstream-Status: Inappropriate [Debian-specific]
6--- a/system/libbase/file.cpp
7+++ b/system/libbase/file.cpp
8@@ -461,7 +461,8 @@
9 #elif defined(__EMSCRIPTEN__)
10 abort();
11 #else
12-#error unknown OS
13+#include <stdexcept>
14+ throw std::runtime_error(std::string("Unknown OS!"));
15 #endif
16 }
17
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-unwindstack-porting.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-unwindstack-porting.patch
new file mode 100644
index 0000000000..8bcfa8fe27
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/deb-sys-unwindstack-porting.patch
@@ -0,0 +1,14 @@
1Description: unwindstack porting
2Forwarded: not-needed
3Upstream-Status: Inappropriate [Debian-specific]
4--- a/system/unwinding/libunwindstack/include/unwindstack/RegsGetLocal.h
5+++ b/system/unwinding/libunwindstack/include/unwindstack/RegsGetLocal.h
6@@ -123,7 +123,7 @@
7 : "t1", "memory");
8 }
9
10-#elif defined(__i386__) || defined(__x86_64__)
11+#else
12
13 // Do not change this, some libraries depend on this function existing on
14 // these architectures.
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/ext4_utils.mk b/meta-oe/recipes-devtools/android-tools/android-tools/ext4_utils.mk
deleted file mode 100644
index c18aa9c4d2..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/ext4_utils.mk
+++ /dev/null
@@ -1,103 +0,0 @@
1# Makefile for ext4_utils
2
3SRCDIR ?= $(S)
4
5VPATH += $(SRCDIR)/system/extras/ext4_utils
6make_ext4fs_SRC_FILES += make_ext4fs_main.c
7make_ext4fs_SRC_FILES += canned_fs_config.c
8make_ext4fs_OBJS := $(make_ext4fs_SRC_FILES:.c=.o)
9
10ext2simg_SRC_FILES += ext2simg.c
11ext2simg_OBJS := $(ext2simg_SRC_FILES:.c=.o)
12
13ext4fixup_SRC_FILES += ext4fixup_main.c
14ext4fixup_OBJS := $(ext4fixup_SRC_FILES:.c=.o)
15
16libext4_utils_SRC_FILES += make_ext4fs.c
17libext4_utils_SRC_FILES += ext4fixup.c
18libext4_utils_SRC_FILES += ext4_utils.c
19libext4_utils_SRC_FILES += allocate.c
20libext4_utils_SRC_FILES += contents.c
21libext4_utils_SRC_FILES += extent.c
22libext4_utils_SRC_FILES += indirect.c
23libext4_utils_SRC_FILES += uuid.c
24libext4_utils_SRC_FILES += sha1.c
25libext4_utils_SRC_FILES += wipe.c
26libext4_utils_SRC_FILES += crc16.c
27libext4_utils_SRC_FILES += ext4_sb.c
28libext4_utils_OBJS := $(libext4_utils_SRC_FILES:.c=.o)
29
30VPATH += $(SRCDIR)/system/core/libsparse
31simg2img_SRC_FILES += simg2img.c
32simg2img_SRC_FILES += sparse_crc32.c
33simg2img_OBJS := $(simg2img_SRC_FILES:.c=.o)
34
35img2simg_SRC_FILES += img2simg.c
36img2simg_OBJS := $(img2simg_SRC_FILES:.c=.o)
37
38simg2simg_SRC_FILES += simg2simg.c
39simg2simg_SRC_FILES += sparse_crc32.c
40simg2simg_OBJS := $(simg2simg_SRC_FILES:.c=.o)
41
42libsparse_SRC_FILES += backed_block.c
43libsparse_SRC_FILES += output_file.c
44libsparse_SRC_FILES += sparse.c
45libsparse_SRC_FILES += sparse_crc32.c
46libsparse_SRC_FILES += sparse_err.c
47libsparse_SRC_FILES += sparse_read.c
48libsparse_OBJS := $(libsparse_SRC_FILES:.c=.o)
49
50VPATH += $(SRCDIR)/external/libselinux/src
51libselinux_SRC_FILES += callbacks.c
52libselinux_SRC_FILES += check_context.c
53libselinux_SRC_FILES += freecon.c
54libselinux_SRC_FILES += init.c
55libselinux_SRC_FILES += label.c
56libselinux_SRC_FILES += label_file.c
57libselinux_SRC_FILES += label_android_property.c
58libselinux_OBJS := $(libselinux_SRC_FILES:.c=.o)
59
60CFLAGS += -DANDROID
61CFLAGS += -DHOST
62CFLAGS += -I$(SRCDIR)/system/extras/ext4_utils
63CFLAGS += -I$(SRCDIR)/system/core/include
64CFLAGS += -I$(SRCDIR)/system/core/libsparse/include
65CFLAGS += -I$(SRCDIR)/external/libselinux/include
66CFLAGS += -include $(SRCDIR)/build/core/combo/include/arch/$(android_arch)/AndroidConfig.h
67
68all: make_ext4fs ext2simg ext4fixup simg2img img2simg simg2simg
69
70make_ext4fs: libext4_utils.a libsparse.a libselinux.a $(make_ext4fs_OBJS)
71 $(CC) -o $@ $(LDFLAGS) $(make_ext4fs_OBJS) \
72 libext4_utils.a libsparse.a libselinux.a -lz -lpcre
73
74ext2simg: libext4_utils.a libselinux.a libsparse.a $(ext2simg_OBJS)
75 $(CC) -o $@ $(LDFLAGS) $(ext2simg_OBJS) \
76 libext4_utils.a libselinux.a libsparse.a -lz -lpcre
77
78ext4fixup: libext4_utils.a libsparse.a $(ext4fixup_OBJS)
79 $(CC) -o $@ $(LDFLAGS) $(ext4fixup_OBJS) libext4_utils.a libsparse.a -lz
80
81simg2img: libsparse.a $(simg2img_OBJS)
82 $(CC) -o $@ $(LDFLAGS) $(simg2img_OBJS) libsparse.a -lz
83
84img2simg: libsparse.a $(img2simg_OBJS)
85 $(CC) -o $@ $(LDFLAGS) $(img2simg_OBJS) libsparse.a -lz
86
87simg2simg: libsparse.a $(simg2simg_OBJS)
88 $(CC) -o $@ $(LDFLAGS) $(simg2simg_OBJS) libsparse.a -lz
89
90libext4_utils.a: $(libext4_utils_OBJS)
91 $(AR) rcs $@ $(libext4_utils_OBJS)
92
93libsparse.a: $(libsparse_OBJS)
94 $(AR) rcs $@ $(libsparse_OBJS)
95
96libselinux.a: $(libselinux_OBJS)
97 $(AR) rcs $@ $(libselinux_OBJS)
98
99clean:
100 $(RM) $(make_ext4fs_OBJS) $(ext2simg_OBJS) $(ext4fixup_OBJS) \
101 $(simg2img_OBJS) $(img2simg_OBJS) $(simg2simg_OBJS) \
102 $(libext4_utils_OBJS) $(libsparse_OBJS) $(libselinux_OBJS) \
103 make_ext4fs ext2simg ext4fixup simg2img img2simg simg2simg *.a
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/extras/0001-ext4_utils-remove-selinux-extensions.patch b/meta-oe/recipes-devtools/android-tools/android-tools/extras/0001-ext4_utils-remove-selinux-extensions.patch
deleted file mode 100644
index 4a19a5d65a..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/extras/0001-ext4_utils-remove-selinux-extensions.patch
+++ /dev/null
@@ -1,39 +0,0 @@
1From 354604da9d152f1931e91991d3f34197fc8fc759 Mon Sep 17 00:00:00 2001
2From: Sergio Schvezov <sergio.schvezov@canonical.com>
3Date: Tue, 2 Oct 2018 16:36:54 +0000
4Subject: [PATCH] ext4_utils: remove selinux extensions
5
6* drop useless includes of Android SELINUX extensions
7* avoids having to clone another module
8* this should be sent upstream
9
10Upstream-Status: Inappropriate
11---
12 ext4_utils/make_ext4fs.c | 1 -
13 ext4_utils/make_ext4fs_main.c | 1 -
14 2 files changed, 2 deletions(-)
15
16diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
17index 2f89ae8a0..732afbed7 100644
18--- a/ext4_utils/make_ext4fs.c
19+++ b/ext4_utils/make_ext4fs.c
20@@ -62,7 +62,6 @@
21
22 #include <selinux/selinux.h>
23 #include <selinux/label.h>
24-#include <selinux/android.h>
25
26 #define O_BINARY 0
27
28diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c
29index a6c5f6160..f8e7b9da9 100644
30--- a/ext4_utils/make_ext4fs_main.c
31+++ b/ext4_utils/make_ext4fs_main.c
32@@ -32,7 +32,6 @@
33 #ifndef USE_MINGW
34 #include <selinux/selinux.h>
35 #include <selinux/label.h>
36-#include <selinux/android.h>
37 #else
38 struct selabel_handle;
39 #endif
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/extras/0002-ext4_utils-add-o-argument-to-preserve-ownership.patch b/meta-oe/recipes-devtools/android-tools/android-tools/extras/0002-ext4_utils-add-o-argument-to-preserve-ownership.patch
deleted file mode 100644
index 3b50ffbf36..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/extras/0002-ext4_utils-add-o-argument-to-preserve-ownership.patch
+++ /dev/null
@@ -1,78 +0,0 @@
1From b9254539811ce912bfd16dd1d185eba7a10cceff Mon Sep 17 00:00:00 2001
2From: Markus Mayer <mmayer@mmayer.net>
3Date: Wed, 7 Sep 2016 12:58:47 +0300
4Subject: [PATCH] ext4_utils: add -o argument to preserve ownership
5
6See also https://android-review.googlesource.com/#/c/100312/
7
8Upstream-Status: Inappropriate
9---
10 ext4_utils/make_ext4fs.c | 6 ++++++
11 ext4_utils/make_ext4fs_main.c | 10 ++++++++--
12 2 files changed, 14 insertions(+), 2 deletions(-)
13
14diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
15index 732afbed7..2cbf04399 100644
16--- a/ext4_utils/make_ext4fs.c
17+++ b/ext4_utils/make_ext4fs.c
18@@ -67,6 +67,8 @@
19
20 #endif
21
22+int preserve_owner = 0;
23+
24 /* TODO: Not implemented:
25 Allocating blocks in the same block group as the file inode
26 Hash or binary tree directories
27@@ -185,6 +187,10 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
28 } else {
29 dentries[i].mtime = fixed_time;
30 }
31+ if (preserve_owner) {
32+ dentries[i].uid = stat.st_uid;
33+ dentries[i].gid = stat.st_gid;
34+ }
35 uint64_t capabilities;
36 if (fs_config_func != NULL) {
37 #ifdef ANDROID
38diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c
39index f8e7b9da9..e82d43277 100644
40--- a/ext4_utils/make_ext4fs_main.c
41+++ b/ext4_utils/make_ext4fs_main.c
42@@ -47,13 +47,15 @@ struct selabel_handle;
43 extern struct fs_info info;
44
45
46+extern int preserve_owner;
47+
48 static void usage(char *path)
49 {
50 fprintf(stderr, "%s [ -l <len> ] [ -j <journal size> ] [ -b <block_size> ]\n", basename(path));
51 fprintf(stderr, " [ -g <blocks per group> ] [ -i <inodes> ] [ -I <inode size> ]\n");
52 fprintf(stderr, " [ -L <label> ] [ -f ] [ -a <android mountpoint> ]\n");
53 fprintf(stderr, " [ -S file_contexts ] [ -C fs_config ] [ -T timestamp ]\n");
54- fprintf(stderr, " [ -z | -s ] [ -w ] [ -c ] [ -J ] [ -v ] [ -B <block_list_file> ]\n");
55+ fprintf(stderr, " [ -z | -s ] [ -w ] [ -c ] [ -J ] [ -o ] [ -v ] [ -B <block_list_file> ]\n");
56 fprintf(stderr, " <filename> [<directory>]\n");
57 }
58
59@@ -79,7 +81,7 @@ int main(int argc, char **argv)
60 struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "" } };
61 #endif
62
63- while ((opt = getopt(argc, argv, "l:j:b:g:i:I:L:a:S:T:C:B:fwzJsctv")) != -1) {
64+ while ((opt = getopt(argc, argv, "l:j:b:g:i:I:L:a:S:T:C:B:fwzJsctov")) != -1) {
65 switch (opt) {
66 case 'l':
67 info.len = parse_num(optarg);
68@@ -142,6 +144,10 @@ int main(int argc, char **argv)
69 }
70 #endif
71 break;
72+ case 'o':
73+ preserve_owner = 1;
74+ printf("Warning: Enabling 'preserve ownership', this is an unofficial feature!\n");
75+ break;
76 case 'v':
77 verbose = 1;
78 break;
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/extras/0003-ext4_utils-drop-unused-parameter-from-allocate_inode.patch b/meta-oe/recipes-devtools/android-tools/android-tools/extras/0003-ext4_utils-drop-unused-parameter-from-allocate_inode.patch
deleted file mode 100644
index b77c0ebc13..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/extras/0003-ext4_utils-drop-unused-parameter-from-allocate_inode.patch
+++ /dev/null
@@ -1,69 +0,0 @@
1From c9f8cb184a7218c97ff966db44da6dd814c0e273 Mon Sep 17 00:00:00 2001
2From: Martin Jansa <martin.jansa@gmail.com>
3Date: Fri, 21 Mar 2025 09:49:32 +0000
4Subject: [PATCH] ext4_utils: drop unused parameter from allocate_inode()
5
6* fixes build with gcc-15:
7 http://errors.yoctoproject.org/Errors/Details/848455/
8
9TOPDIR/tmp/work/core2-64-oe-linux/android-tools/5.1.1.r37/git/system/extras/ext4_utils/contents.c: In function 'make_directory':
10TOPDIR/tmp/work/core2-64-oe-linux/android-tools/5.1.1.r37/git/system/extras/ext4_utils/contents.c:115:29: error: too many arguments to function 'allocate_inode'; expected 0, have 1
11 115 | inode_num = allocate_inode(info);
12 | ^~~~~~~~~~~~~~ ~~~~
13In file included from TOPDIR/tmp/work/core2-64-oe-linux/android-tools/5.1.1.r37/git/system/extras/ext4_utils/contents.c:32:
14TOPDIR/tmp/work/core2-64-oe-linux/android-tools/5.1.1.r37/git/system/extras/ext4_utils/allocate.h:61:5: note: declared here
15 61 | u32 allocate_inode();
16 | ^~~~~~~~~~~~~~
17TOPDIR/tmp/work/core2-64-oe-linux/android-tools/5.1.1.r37/git/system/extras/ext4_utils/contents.c: In function 'make_file':
18TOPDIR/tmp/work/core2-64-oe-linux/android-tools/5.1.1.r37/git/system/extras/ext4_utils/contents.c:183:21: error: too many arguments to function 'allocate_inode'; expected 0, have 1
19 183 | inode_num = allocate_inode(info);
20 | ^~~~~~~~~~~~~~ ~~~~
21TOPDIR/tmp/work/core2-64-oe-linux/android-tools/5.1.1.r37/git/system/extras/ext4_utils/allocate.h:61:5: note: declared here
22 61 | u32 allocate_inode();
23 | ^~~~~~~~~~~~~~
24TOPDIR/tmp/work/core2-64-oe-linux/android-tools/5.1.1.r37/git/system/extras/ext4_utils/contents.c: In function 'make_link':
25TOPDIR/tmp/work/core2-64-oe-linux/android-tools/5.1.1.r37/git/system/extras/ext4_utils/contents.c:218:21: error: too many arguments to function 'allocate_inode'; expected 0, have 1
26 218 | inode_num = allocate_inode(info);
27 | ^~~~~~~~~~~~~~ ~~~~
28TOPDIR/tmp/work/core2-64-oe-linux/android-tools/5.1.1.r37/git/system/extras/ext4_utils/allocate.h:61:5: note: declared here
29 61 | u32 allocate_inode();
30 | ^~~~~~~~~~~~~~
31make: *** [<builtin>: contents.o] Error 1
32
33Upstream-Status: Pending [this whole code was removed in newer version android-9.0.0_r1 https://android.googlesource.com/platform/system/extras/+/7a837fcd6e9c0e0219f743052c78cc1c5988dfaf]
34Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
35---
36 ext4_utils/contents.c | 6 +++---
37 1 file changed, 3 insertions(+), 3 deletions(-)
38
39diff --git a/ext4_utils/contents.c b/ext4_utils/contents.c
40index 3144de93f..ac1b71706 100644
41--- a/ext4_utils/contents.c
42+++ b/ext4_utils/contents.c
43@@ -112,7 +112,7 @@ u32 make_directory(u32 dir_inode_num, u32 entries, struct dentry *dentries,
44 len = blocks * info.block_size;
45
46 if (dir_inode_num) {
47- inode_num = allocate_inode(info);
48+ inode_num = allocate_inode();
49 } else {
50 dir_inode_num = EXT4_ROOT_INO;
51 inode_num = EXT4_ROOT_INO;
52@@ -180,7 +180,7 @@ u32 make_file(const char *filename, u64 len)
53 struct ext4_inode *inode;
54 u32 inode_num;
55
56- inode_num = allocate_inode(info);
57+ inode_num = allocate_inode();
58 if (inode_num == EXT4_ALLOCATE_FAILED) {
59 error("failed to allocate inode\n");
60 return EXT4_ALLOCATE_FAILED;
61@@ -215,7 +215,7 @@ u32 make_link(const char *link)
62 u32 inode_num;
63 u32 len = strlen(link);
64
65- inode_num = allocate_inode(info);
66+ inode_num = allocate_inode();
67 if (inode_num == EXT4_ALLOCATE_FAILED) {
68 error("failed to allocate inode\n");
69 return EXT4_ALLOCATE_FAILED;
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/fastboot.mk b/meta-oe/recipes-devtools/android-tools/android-tools/fastboot.mk
deleted file mode 100644
index b9ba95f38a..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/fastboot.mk
+++ /dev/null
@@ -1,89 +0,0 @@
1# Makefile for fastboot
2
3SRCDIR ?= $(S)
4
5VPATH += $(SRCDIR)/system/core/fastboot
6fastboot_SRC_FILES += protocol.c
7fastboot_SRC_FILES += engine.c
8fastboot_SRC_FILES += bootimg.c
9fastboot_SRC_FILES += fastboot.c
10fastboot_SRC_FILES += util.c
11fastboot_SRC_FILES += fs.c
12fastboot_SRC_FILES += usb_linux.c
13fastboot_SRC_FILES += util_linux.c
14fastboot_OBJS := $(fastboot_SRC_FILES:.c=.o)
15
16VPATH += $(SRCDIR)/system/core/libzipfile
17libzipfile_SRC_FILES += centraldir.c
18libzipfile_SRC_FILES += zipfile.c
19libzipfile_OBJS := $(libzipfile_SRC_FILES:.c=.o)
20
21VPATH += $(SRCDIR)/system/extras/ext4_utils
22libext4_utils_SRC_FILES += make_ext4fs.c
23libext4_utils_SRC_FILES += ext4fixup.c
24libext4_utils_SRC_FILES += ext4_utils.c
25libext4_utils_SRC_FILES += allocate.c
26libext4_utils_SRC_FILES += contents.c
27libext4_utils_SRC_FILES += extent.c
28libext4_utils_SRC_FILES += indirect.c
29libext4_utils_SRC_FILES += uuid.c
30libext4_utils_SRC_FILES += sha1.c
31libext4_utils_SRC_FILES += wipe.c
32libext4_utils_SRC_FILES += crc16.c
33libext4_utils_SRC_FILES += ext4_sb.c
34libext4_utils_OBJS := $(libext4_utils_SRC_FILES:.c=.o)
35
36VPATH += $(SRCDIR)/system/core/libsparse
37libsparse_SRC_FILES += backed_block.c
38libsparse_SRC_FILES += output_file.c
39libsparse_SRC_FILES += sparse.c
40libsparse_SRC_FILES += sparse_crc32.c
41libsparse_SRC_FILES += sparse_err.c
42libsparse_SRC_FILES += sparse_read.c
43libsparse_OBJS := $(libsparse_SRC_FILES:.c=.o)
44
45VPATH += $(SRCDIR)/external/libselinux/src
46libselinux_SRC_FILES += callbacks.c
47libselinux_SRC_FILES += check_context.c
48libselinux_SRC_FILES += freecon.c
49libselinux_SRC_FILES += init.c
50libselinux_SRC_FILES += label.c
51libselinux_SRC_FILES += label_file.c
52libselinux_SRC_FILES += label_android_property.c
53libselinux_OBJS := $(libselinux_SRC_FILES:.c=.o)
54
55CFLAGS += -std=gnu11
56CFLAGS += -DANDROID
57# CFLAGS += -DUSE_F2FS
58CFLAGS += -DHOST
59CFLAGS += -I$(SRCDIR)/system/core/fastboot
60CFLAGS += -I$(SRCDIR)/system/core/include
61CFLAGS += -I$(SRCDIR)/system/core/mkbootimg
62CFLAGS += -I$(SRCDIR)/system/extras/ext4_utils
63CFLAGS += -I$(SRCDIR)/system/extras/f2fs_utils
64CFLAGS += -I$(SRCDIR)/system/core/libsparse/include
65CFLAGS += -I$(SRCDIR)/external/libselinux/include
66CFLAGS += -include $(SRCDIR)/build/core/combo/include/arch/$(android_arch)/AndroidConfig.h
67
68LIBS += libzipfile.a libext4_utils.a libsparse.a libselinux.a -lz -lpcre
69
70all: fastboot
71
72fastboot: libzipfile.a libext4_utils.a libsparse.a libselinux.a $(fastboot_OBJS)
73 $(CC) -o $@ $(LDFLAGS) $(fastboot_OBJS) $(LIBS)
74
75libzipfile.a: $(libzipfile_OBJS)
76 $(AR) rcs $@ $(libzipfile_OBJS)
77
78libext4_utils.a: $(libext4_utils_OBJS)
79 $(AR) rcs $@ $(libext4_utils_OBJS)
80
81libsparse.a: $(libsparse_OBJS)
82 $(AR) rcs $@ $(libsparse_OBJS)
83
84libselinux.a: $(libselinux_OBJS)
85 $(AR) rcs $@ $(libselinux_OBJS)
86
87clean:
88 $(RM) $(fastboot_OBJS) $(libzipfile_OBJS) $(libext4_utils_OBJS) \
89 $(libsparse_OBJS) $(libselinux_OBJS) fastboot *.a
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/gitignore b/meta-oe/recipes-devtools/android-tools/android-tools/gitignore
deleted file mode 100644
index b034c10a1e..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/gitignore
+++ /dev/null
@@ -1,59 +0,0 @@
1*
2!.gitignore
3!*.indirectionsymlink
4!*.[ch]
5!*.mk
6!*.patch
7!*.service
8!NOTICE
9!MODULE_LICENSE_*
10!/system/
11!/system/core/
12!/system/core/adb/
13!/system/core/fastboot/
14!/system/core/fs_mgr/
15!/system/core/fs_mgr/include/
16!/system/core/include/
17!/system/core/include/android/
18!/system/core/include/cutils/
19!/system/core/include/log/
20!/system/core/include/mincrypt/
21!/system/core/include/private/
22!/system/core/include/utils/
23!/system/core/include/zipfile/
24!/system/core/liblog/
25!/system/core/liblog/tests/
26!/system/core/libcutils/
27!/system/core/libmincrypt/
28!/system/core/libzipfile/
29!/system/core/libsparse/
30!/system/core/libsparse/include/
31!/system/core/libsparse/include/sparse/
32!/system/core/libsparse/simg_dump.py
33!/system/core/mkbootimg/
34!/system/extras/
35!/system/extras/ext4_utils/
36!/system/extras/ext4_utils/mkuserimg.sh
37!/system/extras/ext4_utils/test_ext4fixup
38!/system/extras/f2fs_utils/
39!/hardware/
40!/hardware/libhardware/
41!/hardware/libhardware/include/
42!/hardware/libhardware/include/hardware/
43!/external/
44!/external/libselinux/
45!/external/libselinux/include/
46!/external/libselinux/include/selinux/
47!/external/libselinux/src/
48!/external/f2fs-tools/
49!/external/f2fs-tools/include/
50!/external/f2fs-tools/lib/
51!/external/f2fs-tools/mkfs/
52!/build/
53!/build/core/
54!/build/core/version_defaults.mk
55!/build/core/combo/
56!/build/core/combo/include/
57!/build/core/combo/include/arch/
58!/build/core/combo/include/arch/linux-*/
59!/build/core/combo/include/arch/linux-*/AndroidConfig.h
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-Remove-bionic-specific-calls.patch b/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-Remove-bionic-specific-calls.patch
deleted file mode 100644
index 9de2593df8..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-Remove-bionic-specific-calls.patch
+++ /dev/null
@@ -1,25 +0,0 @@
1From 36654a4484117e5f4d63a810c0d94bc9c7ee3a83 Mon Sep 17 00:00:00 2001
2From: Fathi Boudra <fabo@debian.org>
3Date: Tue, 2 Oct 2018 16:36:54 +0000
4Subject: [PATCH] Remove bionic specific calls
5
6Upstream-Status: Inappropriate
7
8Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
9---
10 src/procattr.c | 2 +-
11 1 file changed, 1 insertion(+), 1 deletion(-)
12
13diff --git a/src/procattr.c b/src/procattr.c
14index f350808..761cf8e 100644
15--- a/src/procattr.c
16+++ b/src/procattr.c
17@@ -8,7 +8,7 @@
18 #include "selinux_internal.h"
19 #include "policy.h"
20
21-#ifdef HOST
22+#ifndef __BIONIC__
23 static pid_t gettid(void)
24 {
25 return syscall(__NR_gettid);
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch b/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch
deleted file mode 100644
index 8b5e4cf999..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch
+++ /dev/null
@@ -1,51 +0,0 @@
1From f4f9d24860e1b5cd4f6a014f3fda7cd33ebe5be7 Mon Sep 17 00:00:00 2001
2From: Petr Lautrbach <plautrba@redhat.com>
3Date: Sat, 27 Jul 2019 08:20:20 -0700
4Subject: [PATCH] libselinux: Do not define gettid() if glibc >= 2.30 is used
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Since version 2.30 glibc implements gettid() system call wrapper, see
10https://sourceware.org/bugzilla/show_bug.cgi?id=6399
11
12Fixes:
13cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -c -o procattr.o procattr.c
14procattr.c:28:14: error: static declaration of ‘gettid’ follows non-static declaration
15 28 | static pid_t gettid(void)
16 | ^~~~~~
17In file included from /usr/include/unistd.h:1170,
18 from procattr.c:2:
19/usr/include/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ was here
20 34 | extern __pid_t gettid (void) __THROW;
21 | ^~~~~~
22
23Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
24Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
25Signed-off-by: Khem Raj <raj.khem@gmail.com>
26---
27Upstream-Status: Pending
28
29 src/procattr.c | 14 +++++++++++++-
30 1 file changed, 13 insertions(+), 1 deletion(-)
31
32--- a/src/procattr.c
33+++ b/src/procattr.c
34@@ -8,12 +8,16 @@
35 #include "selinux_internal.h"
36 #include "policy.h"
37
38-#ifndef __BIONIC__
39+/* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and
40+ * has a definition for it */
41+#if defined(__GLIBC_)
42+#if !__GLIBC_PREREQ(2,30)
43 static pid_t gettid(void)
44 {
45 return syscall(__NR_gettid);
46 }
47 #endif
48+#endif
49
50 static int getprocattrcon(char ** context,
51 pid_t pid, const char *attr)
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/mkbootimg.mk b/meta-oe/recipes-devtools/android-tools/android-tools/mkbootimg.mk
deleted file mode 100644
index 519f609fd2..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools/mkbootimg.mk
+++ /dev/null
@@ -1,29 +0,0 @@
1# Makefile for mkbootimg
2
3SRCDIR ?= $(S)
4
5VPATH += $(SRCDIR)/system/core/mkbootimg
6mkbootimg_SRC_FILES += mkbootimg.c
7mkbootimg_OBJS := $(mkbootimg_SRC_FILES:.c=.o)
8
9VPATH += $(SRCDIR)/system/core/libmincrypt
10libmincrypt_SRC_FILES := dsa_sig.c p256.c p256_ec.c p256_ecdsa.c rsa.c sha.c sha256.c
11libmincrypt_OBJS := $(libmincrypt_SRC_FILES:.c=.o)
12
13CFLAGS += -DANDROID
14CFLAGS += -I$(SRCDIR)/system/core/mkbootimg
15CFLAGS += -I$(SRCDIR)/system/core/include
16CFLAGS += -include $(SRCDIR)/build/core/combo/include/arch/$(android_arch)/AndroidConfig.h
17
18LIBS += libmincrypt.a
19
20all: mkbootimg
21
22mkbootimg: libmincrypt.a $(mkbootimg_OBJS)
23 $(CC) -o $@ $(LDFLAGS) $(mkbootimg_OBJS) $(LIBS)
24
25libmincrypt.a: $(libmincrypt_OBJS)
26 $(AR) rcs $@ $(libmincrypt_OBJS)
27
28clean:
29 $(RM) $(mkbootimg_OBJS) $(libmincrypt_OBJS) mkbootimg *.a
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
new file mode 100644
index 0000000000..3a277cd4b5
--- /dev/null
+++ b/meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb
@@ -0,0 +1,237 @@
1DESCRIPTION = "Various utilities from Android"
2SECTION = "console/utils"
3LICENSE = "Apache-2.0 & GPL-2.0-only & BSD-2-Clause & BSD-3-Clause"
4LIC_FILES_CHKSUM = " \
5 file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \
6 file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 \
7 file://${COMMON_LICENSE_DIR}/BSD-2-Clause;md5=cb641bc04cda31daea161b1bc15da69f \
8 file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \
9"
10
11DEPENDS = " \
12 android-libboringssl \
13 brotli \
14 libcap \
15 7zip \
16 protobuf \
17 protobuf-native \
18 libusb \
19 squashfs-tools \
20 zlib \
21"
22
23# The debian/ patches are copied from android-platform-tools/debian/patches and
24# applied in the order defined by debian/patches/series. Listing them as
25# first-class SRC_URI entries (rather than running quilt inside do_patch) makes
26# the recipe work correctly with devtool.
27SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/android-platform-tools_35.0.2.orig.tar.xz;name=orig;subdir=android-platform-tools-${PV} \
28 https://deb.debian.org/debian/pool/main/a/android-platform-tools/android-platform-tools_35.0.2-1~exp6.debian.tar.xz;name=debian;subdir=android-platform-tools-${PV} \
29 file://android-tools-adbd.service \
30 file://debian/deb-gcc-stdatomic.patch \
31 file://debian/deb-gcc-workaround__builtin_available.patch \
32 file://debian/deb-gcc-Nullable.patch \
33 file://debian/deb-sys-unwindstack-porting.patch \
34 file://debian/deb-sys-move-log-file-to-proper-dir.patch \
35 file://debian/deb-sys-Added-missing-headers.patch \
36 file://debian/deb-sys-libusb-header-path.patch \
37 file://debian/deb-sys-throw-exception-on-unknown-os.patch \
38 file://debian/deb-sys-hard-code-build-number.patch \
39 file://debian/deb-sys-stub-out-fastdeploy.patch \
40 file://debian/deb-sys-Implement-const_iterator-operator.patch \
41 file://debian/deb-sys-Drop-gki-dependency-from-mkbootimg.patch \
42 file://debian/deb-sys-add-missing-headers.patch \
43 file://debian/deb-dev-typos.patch \
44 file://debian/deb-adbd-adbd-allow-usb-on-linux.patch \
45 file://debian/deb-adbd-adbd-allow-notifying-systemd.patch \
46 file://debian/deb-adbd-adbd-usb-drop-property-monitor.patch \
47 file://debian/deb-adbd-adbd-don-t-require-authorization-on-Linux.patch \
48 file://0001-libbacktrace.mk-Link-against-staged-lib7z.patch \
49 file://0002-debian-makefiles-yocto-compat.patch \
50 file://0003-gcc-nullability-and-thread-annotation-compat.patch \
51 file://0004-fastboot-super_flash_helper-include-climits.patch \
52 file://0005-adb-host-usb-compat.patch \
53 file://0006-adbd-enable-root-and-remount-support.patch \
54 file://0007-libcutils-guard-Android-private-header-with-addition.patch \
55 file://0008-adb-GCC-compatibility-fixes-for-usb_linux-and-sysdep.patch \
56 file://0009-libbase-include-stdint.h-in-hex.cpp.patch \
57 file://0010-adbd-make-systemd-sd_notify-conditional-on-HAVE_SYSTEMD.patch \
58 "
59
60SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
61SRC_URI[orig.sha256sum] = "ec1d317608db3328bfbddf7152c8d7f185c7c87b2175081416344434546a43da"
62SRC_URI[debian.md5sum] = "1de890bd272da9e8cd35bc9579802f1f"
63SRC_URI[debian.sha256sum] = "f03a89b82ea8dfbe3cb77d5326eedf0d15984f5896885e8c5df64cf421819579"
64
65S = "${UNPACKDIR}/android-platform-tools-${PV}"
66B = "${UNPACKDIR}/${BPN}"
67
68# http://errors.yoctoproject.org/Errors/Details/1debian881/
69ARM_INSTRUCTION_SET:armv4 = "arm"
70ARM_INSTRUCTION_SET:armv5 = "arm"
71
72COMPATIBLE_HOST:powerpc = "(null)"
73COMPATIBLE_HOST:powerpc64 = "(null)"
74COMPATIBLE_HOST:powerpc64le = "(null)"
75
76inherit systemd
77
78SYSTEMD_PACKAGES = "${PN}-adbd"
79SYSTEMD_SERVICE:${PN}-adbd = "android-tools-adbd.service"
80
81CFLAGS:append = " -fPIC -std=gnu2x"
82CXXFLAGS:append = " -fPIC -std=gnu++20 -D_Nonnull= -D_Nullable= -I${STAGING_INCDIR}/boringssl"
83LDFLAGS:append = " -fPIC -L${STAGING_LIBDIR}/android"
84
85
86CC:append:class-native = " -I${STAGING_INCDIR}"
87CC:append:class-nativesdk = " -I${STAGING_INCDIR}"
88
89PREREQUISITE_core = ""
90PREREQUISITE_core:class-target = "liblog libbase libcutils libcrypto_utils libadb"
91PREREQUISITE_core:class-native = "liblog libbase libcutils libziparchive libsparse libcrypto_utils libadb"
92
93TOOLS_TO_BUILD = ""
94TOOLS_TO_BUILD:class-target = "adbd"
95TOOLS_TO_BUILD:class-native = "adb fastboot img2simg simg2img"
96
97BUILD_SYSROOT = "${RECIPE_SYSROOT}"
98BUILD_SYSROOT:class-native = "${RECIPE_SYSROOT_NATIVE}"
99
100do_compile() {
101 case "${HOST_ARCH}" in
102 arm)
103 export android_arch=linux-arm
104 cpu=arm
105 deb_host_arch=arm
106 ;;
107 aarch64)
108 export android_arch=linux-arm64
109 cpu=arm64
110 deb_host_arch=arm64
111 ;;
112 riscv64)
113 export android_arch=linux-riscv64
114 cpu=riscv64
115 deb_host_arch=riscv64
116 ;;
117 mips|mipsel)
118 export android_arch=linux-mips
119 cpu=mips
120 deb_host_arch=mips
121 ;;
122 mips64|mips64el)
123 export android_arch=linux-mips64
124 cpu=mips64
125 deb_host_arch=mips64
126 ;;
127 powerpc|powerpc64)
128 export android_arch=linux-ppc
129 cpu=ppc
130 deb_host_arch=ppc64
131 ;;
132 i586|i686)
133 export android_arch=linux-x86
134 cpu=x86
135 deb_host_arch=i386
136 ;;
137 x86_64)
138 export android_arch=linux-x86
139 cpu=x86_64
140 deb_host_arch=amd64
141 ;;
142 *)
143 bbfatal "Unsupported HOST_ARCH=${HOST_ARCH}"
144 ;;
145 esac
146
147 export SRCDIR=${S}
148 export DEB_HOST_ARCH=${deb_host_arch}
149 export DEB_HOST_MULTIARCH=
150 export SYSROOT=${BUILD_SYSROOT}
151
152 if echo " ${TOOLS_TO_BUILD} " | grep -Eq " (adb|fastboot) "; then
153 # Native host tools should use the host system's ELF interpreter, not
154 # Yocto's uninative loader under /workdir.
155 export LDFLAGS="$(printf '%s\n' "${LDFLAGS}" | \
156 sed -E 's@-Wl,--dynamic-linker=[^[:space:]]+@@g; s@[[:space:]]+@ @g; s@^[[:space:]]+@@; s@[[:space:]]+$@@')"
157 fi
158
159 # Debian's make fragments expect generated protobuf sources to already be
160 # present under packages/modules/adb/proto, but the orig tarball only ships
161 # the .proto inputs.
162 for proto in adb_host adb_known_hosts app_processes key_type pairing; do
163 ${STAGING_BINDIR_NATIVE}/protoc \
164 --proto_path=${S}/packages/modules/adb/proto \
165 --cpp_out=${S}/packages/modules/adb/proto \
166 ${S}/packages/modules/adb/proto/${proto}.proto
167 done
168
169 if [ -d ${S}/packages/modules/adb/fastdeploy/proto ]; then
170 for proto in ${S}/packages/modules/adb/fastdeploy/proto/*.proto; do
171 [ -e "$proto" ] || continue
172 ${STAGING_BINDIR_NATIVE}/protoc \
173 --proto_path=${S}/packages/modules/adb \
174 --cpp_out=${S}/packages/modules/adb \
175 "$proto"
176 done
177 fi
178
179 # Debian's make fragments write archives and binaries under debian/out/*
180 # but do not consistently create parent directories before invoking ar.
181 install -d ${S}/debian/out/system/extras
182
183 # Debian replaces Android's Soong build system with hand-written GNU make
184 # fragments under debian/system/ and debian/external/.
185 for tool in ${PREREQUISITE_core}; do
186 oe_runmake -f ${S}/debian/system/${tool}.mk -C ${S}
187 done
188
189 if echo " ${TOOLS_TO_BUILD} " | grep -q " fastboot "; then
190 # Debian's fastboot.mk links against the ext4_utils static archive from
191 # debian/out/system/extras, so build that helper archive first.
192 oe_runmake -f ${S}/debian/system/extras/libext4_utils.mk -C ${S}
193 fi
194
195 for tool in ${TOOLS_TO_BUILD}; do
196 oe_runmake -f ${S}/debian/system/${tool}.mk -C ${S} \
197 ${@'HAVE_SYSTEMD=1' if bb.utils.contains('PACKAGECONFIG', 'systemd', True, False, d) else ''}
198 done
199}
200
201do_install() {
202 for tool in ${TOOLS_TO_BUILD}; do
203 install -D -p -m0755 ${S}/debian/out/system/${tool} ${D}${bindir}/${tool}
204 done
205
206 if echo " ${TOOLS_TO_BUILD} " | grep -q " adbd "; then
207 install -D -p -m0644 ${UNPACKDIR}/android-tools-adbd.service \
208 ${D}${systemd_unitdir}/system/android-tools-adbd.service
209 fi
210
211 install -d ${D}${libdir}/android/
212 install -m0755 ${S}/debian/out/system/lib*.so.* ${D}${libdir}/android/
213}
214
215PACKAGES =+ "${PN}-adbd"
216RDEPENDS:${PN}:class-target = "android-tools-conf-configfs 7zip android-libboringssl"
217RDEPENDS:${PN}-adbd += "${PN}"
218PRIVATE_LIBS:${PN} = "liblog.so.0 libbase.so.0 libcutils.so.0"
219
220inherit useradd
221USERADD_PACKAGES = "${PN}-adbd"
222USERADD_PARAM:${PN}-adbd = "--system --no-create-home --shell /bin/false --user-group adb"
223
224FILES:${PN} += " \
225 ${libdir}/android \
226 ${libdir}/android/* \
227"
228
229FILES:${PN}-adbd = " \
230 ${bindir}/adbd \
231 ${systemd_unitdir}/system/android-tools-adbd.service \
232"
233
234BBCLASSEXTEND = "native"
235
236PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
237PACKAGECONFIG[systemd] = ",,systemd"
diff --git a/meta-oe/recipes-devtools/android-tools/android-tools_5.1.1.r37.bb b/meta-oe/recipes-devtools/android-tools/android-tools_5.1.1.r37.bb
deleted file mode 100644
index c04a1ef8c4..0000000000
--- a/meta-oe/recipes-devtools/android-tools/android-tools_5.1.1.r37.bb
+++ /dev/null
@@ -1,189 +0,0 @@
1DESCRIPTION = "Different utilities from Android"
2SECTION = "console/utils"
3LICENSE = "Apache-2.0 & GPL-2.0-only & BSD-2-Clause & BSD-3-Clause"
4LIC_FILES_CHKSUM = " \
5 file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \
6 file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 \
7 file://${COMMON_LICENSE_DIR}/BSD-2-Clause;md5=cb641bc04cda31daea161b1bc15da69f \
8 file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \
9"
10DEPENDS = "libbsd libpcre zlib libcap"
11DEPENDS:append:class-target = " openssl"
12
13ANDROID_MIRROR = "android.googlesource.com"
14
15# matches with android-5.1.1_r37
16SRCREV_core = "2314b110bdebdbfd2d94c502282f9e57c849897e"
17SRCREV_extras = "3ecbe8d841df96127d7855661293e5ab6ba6c205"
18SRCREV_libhardware = "be55eb1f4d840c82ffaf7c47460df17ff5bc4d9b"
19SRCREV_libselinux = "07e9e1339ad1ba608acfba9dce2d0f474b252feb"
20SRCREV_build = "16e987def3d7d8f7d30805eb95cef69e52a87dbc"
21
22SRCREV_FORMAT = "core_extras_libhardware_libselinux_build"
23SRC_URI = " \
24 git://${ANDROID_MIRROR}/platform/system/core;name=core;protocol=https;nobranch=1;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/system/core \
25 git://${ANDROID_MIRROR}/platform/system/extras;name=extras;protocol=https;nobranch=1;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/system/extras \
26 git://${ANDROID_MIRROR}/platform/hardware/libhardware;name=libhardware;protocol=https;nobranch=1;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/hardware/libhardware \
27 git://${ANDROID_MIRROR}/platform/external/libselinux;name=libselinux;protocol=https;nobranch=1;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/external/libselinux \
28 git://${ANDROID_MIRROR}/platform/build;name=build;protocol=https;nobranch=1;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/build \
29 file://core/0001-adb-remove-selinux-extensions.patch;patchdir=system/core \
30 file://core/0002-adb-Use-local-sockets-where-appropriate.patch;patchdir=system/core \
31 file://core/0003-adb-define-shell-command.patch;patchdir=system/core \
32 file://core/0004-adb-Fix-build-on-big-endian-systems.patch;patchdir=system/core \
33 file://core/0005-adb-add-base64-implementation.patch;patchdir=system/core \
34 file://core/0006-adb-Musl-fixes.patch;patchdir=system/core \
35 file://core/0007-adb-usb_linux.c-fix-build-with-glibc-2.28.patch;patchdir=system/core \
36 file://core/0008-adb-Allow-adbd-to-be-ran-as-root.patch;patchdir=system/core \
37 file://core/0009-mkbootimg-Add-dt-parameter-to-specify-DT-image.patch;patchdir=system/core \
38 file://core/0010-Use-linux-capability.h-on-linux-systems-too.patch;patchdir=system/core \
39 file://core/0011-Remove-bionic-specific-calls.patch;patchdir=system/core \
40 file://core/0012-Fix-implicit-declaration-of-stlcat-strlcopy-function.patch;patchdir=system/core \
41 file://core/adb_libssl_11.diff;patchdir=system/core \
42 file://core/b64_pton_function_decl.patch;patchdir=system/core \
43 file://core/0013-adb-Support-riscv64.patch;patchdir=system/core \
44 file://core/0014-add-u3-ss-descriptor-support-for-adb.patch;patchdir=system/core \
45 file://core/0015-libsparse-Split-off-most-of-sparse_file_read_normal-.patch;patchdir=system/core \
46 file://core/0016-libsparse-Add-hole-mode-to-sparse_file_read.patch;patchdir=system/core \
47 file://core/0017-img2simg-Add-support-for-converting-holes-to-don-t-c.patch;patchdir=system/core \
48 file://core/0001-memory.h-Always-define-strlcpy-for-glibc-based-syste.patch;patchdir=system/core \
49 file://extras/0001-ext4_utils-remove-selinux-extensions.patch;patchdir=system/extras \
50 file://extras/0002-ext4_utils-add-o-argument-to-preserve-ownership.patch;patchdir=system/extras \
51 file://extras/0003-ext4_utils-drop-unused-parameter-from-allocate_inode.patch;patchdir=system/extras \
52 file://libselinux/0001-Remove-bionic-specific-calls.patch;patchdir=external/libselinux \
53 file://libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch;patchdir=external/libselinux \
54 file://android-tools-adbd.service \
55 file://build/0001-Riscv-Add-risc-v-Android-config-header.patch;patchdir=build \
56 file://gitignore \
57 file://adb.mk;subdir=${BPN} \
58 file://adbd.mk;subdir=${BPN} \
59 file://ext4_utils.mk;subdir=${BPN} \
60 file://fastboot.mk;subdir=${BPN} \
61 file://mkbootimg.mk;subdir=${BPN} \
62"
63
64
65B = "${WORKDIR}/${BPN}"
66
67# http://errors.yoctoproject.org/Errors/Details/133881/
68ARM_INSTRUCTION_SET:armv4 = "arm"
69ARM_INSTRUCTION_SET:armv5 = "arm"
70
71COMPATIBLE_HOST:powerpc = "(null)"
72COMPATIBLE_HOST:powerpc64 = "(null)"
73COMPATIBLE_HOST:powerpc64le = "(null)"
74
75inherit systemd
76
77SYSTEMD_PACKAGES = "${PN}-adbd"
78SYSTEMD_SERVICE:${PN}-adbd = "android-tools-adbd.service"
79
80# Find libbsd headers during native builds
81CC:append:class-native = " -I${STAGING_INCDIR}"
82CC:append:class-nativesdk = " -I${STAGING_INCDIR}"
83
84TOOLS = "adb fastboot ext4_utils mkbootimg adbd"
85
86# Adb needs sys/capability.h, which is not available for native*
87TOOLS:class-native = "fastboot ext4_utils mkbootimg"
88TOOLS:class-nativesdk = "fastboot ext4_utils mkbootimg"
89
90do_compile() {
91 cp ${UNPACKDIR}/gitignore ${S}/.gitignore
92
93 # Setting both variables below causing our makefiles to not work with
94 # implicit make rules
95 CFLAGS="-ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR}"
96 unset CPPFLAGS
97
98 export SRCDIR=${S}
99
100 case "${HOST_ARCH}" in
101 arm)
102 export android_arch=linux-arm
103 ;;
104 aarch64)
105 export android_arch=linux-arm64
106 ;;
107 riscv64)
108 export android_arch=linux-riscv64
109 ;;
110 mips|mipsel)
111 export android_arch=linux-mips
112 ;;
113 mips64|mips64el)
114 export android_arch=linux-mips64
115 ;;
116 powerpc|powerpc64)
117 export android_arch=linux-ppc
118 ;;
119 i586|i686|x86_64)
120 export android_arch=linux-x86
121 ;;
122 esac
123
124 for tool in ${TOOLS}; do
125 mkdir -p ${B}/${tool}
126 oe_runmake -f ${UNPACKDIR}/${BPN}/${tool}.mk -C ${B}/${tool}
127 done
128}
129
130do_install() {
131 if echo ${TOOLS} | grep -q "ext4_utils" ; then
132 install -D -p -m0755 ${S}/system/core/libsparse/simg_dump.py ${D}${bindir}/simg_dump
133 install -D -p -m0755 ${S}/system/extras/ext4_utils/mkuserimg.sh ${D}${bindir}/mkuserimg
134
135 install -m0755 ${B}/ext4_utils/ext2simg ${D}${bindir}
136 install -m0755 ${B}/ext4_utils/ext4fixup ${D}${bindir}
137 install -m0755 ${B}/ext4_utils/img2simg ${D}${bindir}
138 install -m0755 ${B}/ext4_utils/make_ext4fs ${D}${bindir}
139 install -m0755 ${B}/ext4_utils/simg2img ${D}${bindir}
140 install -m0755 ${B}/ext4_utils/simg2simg ${D}${bindir}
141 fi
142
143 if echo ${TOOLS} | grep -q "adb\>" ; then
144 install -d ${D}${bindir}
145 install -m0755 ${B}/adb/adb ${D}${bindir}
146 fi
147
148 if echo ${TOOLS} | grep -q "adbd" ; then
149 install -d ${D}${bindir}
150 install -m0755 ${B}/adbd/adbd ${D}${bindir}
151 fi
152
153 # Outside the if statement to avoid errors during do_package
154 install -D -p -m0644 ${UNPACKDIR}/android-tools-adbd.service \
155 ${D}${systemd_unitdir}/system/android-tools-adbd.service
156
157 if echo ${TOOLS} | grep -q "fastboot" ; then
158 install -d ${D}${bindir}
159 install -m0755 ${B}/fastboot/fastboot ${D}${bindir}
160 fi
161
162 if echo ${TOOLS} | grep -q "mkbootimg" ; then
163 install -d ${D}${bindir}
164 install -m0755 ${B}/mkbootimg/mkbootimg ${D}${bindir}
165 fi
166}
167
168PACKAGES =+ "${PN}-fstools ${PN}-adbd"
169
170RDEPENDS:${PN}-adbd = "${PN}-conf"
171RDEPENDS:${PN}-fstools = "bash"
172
173FILES:${PN}-adbd = "\
174 ${bindir}/adbd \
175 ${systemd_unitdir}/system/android-tools-adbd.service \
176"
177
178FILES:${PN}-fstools = "\
179 ${bindir}/ext2simg \
180 ${bindir}/ext4fixup \
181 ${bindir}/img2simg \
182 ${bindir}/make_ext4fs \
183 ${bindir}/simg2img \
184 ${bindir}/simg2simg \
185 ${bindir}/simg_dump \
186 ${bindir}/mkuserimg \
187"
188
189BBCLASSEXTEND = "native"