3 Commits

Author SHA1 Message Date
Claus Stovgaard da27b5fb74 android-tools: fix native build
The native tools include compilation of zip_writter, where it include
gtest/gtest_prod.h. So native build need to depend on gtest-native.

Signed-off-by: Claus Stovgaard <claus@stovgaard.com>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
2026-07-07 00:29:00 -07:00
Khem Raj f7352f131c android-tools: fix build with libstdc++ and current C++ frontends
Two build failures occur with the default clang/lld toolchain (and with
gcc) when compiling android-tools 35.0.2:

1. The bundled fmtlib 10.2.0 validates FMT_STRING() inside a consteval
   basic_format_string constructor whose parse path evaluates
   "format_str_.remove_prefix(detail::to_unsigned(it - begin()))". Current
   C++ frontends reject that iterator subtraction as a non-constant
   subexpression:

     error: call to consteval function
       'fmt::basic_format_string<...>::basic_format_string<FMT_COMPILE_STRING,0>'
       is not a constant expression

   Define FMT_CONSTEVAL to empty so fmt drops the consteval qualifier and
   validates format strings via its runtime path instead.

2. adb's IOVector::coalesce() static_asserts that its Block collection type
   is standard-layout. Block holds a std::unique_ptr<char[]>, which is
   standard-layout under LLVM libc++ (AOSP's runtime) but not under GNU
   libstdc++, so the assertion fails for libstdc++ based toolchains:

     packages/modules/adb/types.h:235:27: error: static assertion failed due
     to requirement 'std::is_standard_layout<Block>()'

   The assertion does not protect the memcpy it guards (which writes into
   plain char storage), so drop it.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2026-06-28 00:59:27 -07:00
Etienne Cordonnier b94dcd3256 android-tools: upgrade 29.0.6.r14 -> 35.0.2
Upgrade from 29.0.6.r14 to 35.0.2, switching to the Debian
android-platform-tools source package layout which ships Debian-maintained
make fragments and patch series under debian/system/.

The old recipe carried a hand-maintained patch stack on top of a
custom build system (rules_yocto.mk). The new recipe delegates to
Debian's make fragments and applies only the OE-specific patches needed
on top.

Notable upstream changes between 29.0.6 and 35.0.2 (see release notes at
https://developer.android.com/tools/releases/platform-tools):
- adb: libusb is now the default USB backend on Linux (35.0.0)
- adb: receive windowing for better throughput on high-latency links (33.0.3)
- adb: graceful USB interface release on shutdown (35.0.2)
- adb: wireless pairing and incremental APK installation support (30.0.0)
- adb: adb transport-id for safe scripted device waits (30.0.2)
- adb: fix shell exit code when device disconnects (35.0.0)
- fastboot: download speed improvements up to 980MB/s on SuperSpeed+ (35.0.0)

OE-specific changes:
- adbd now drops privileges to a dedicated "adb" system user (matching
  Android's production security model); use "adb root" to escalate
- adbd root/unroot/remount support added for non-Android targets
- android-gadget-setup updated to mount functionfs with uid/gid ownership
  so the unprivileged adbd can access the FunctionFS endpoints
- Depends on new android-libboringssl recipe for BoringSSL shared libraries
- android-tools-adbd.service uses Type=notify so systemd waits for adbd's
  sd_notify READY=1 before proceeding with ExecStartPost
- android-gadget-start now respects ANDROID_GADGET_UDC_DELAY (default 10s
  for non-systemd paths); the configfs drop-in sets it to 0 since adbd has
  already signalled readiness before ExecStartPost runs, eliminating the
  fixed delay on restart

Tested on Raspberry Pi 4B (MACHINE=raspberrypi4-64) with USB-C OTG port,
openembedded-core main branch, meta-openembedded master-next, kernel 6.12:
- adb devices: device enumerated as 18d1:d002
- adb shell: connection as unprivileged adb user
- adb root / adb unroot: privilege escalation and drop
- adb reboot: device reboot via adb
- adb forward: SSH tunnel through ADB verified
- oe-run-native android-tools-native adb / fastboot: native host tools build

Note: adbd only starts when /etc/usb-debugging-enabled exists on the target
(ConditionPathExists in the service file). This is intentional — ADB is
disabled by default for security. Create the file at image build time or
at runtime to enable it.

Requires kernel config for USB gadget support (e.g. via a .cfg fragment):
  CONFIG_USB_DWC2_DUAL_ROLE=y
  CONFIG_USB_GADGET=y
  CONFIG_USB_CONFIGFS=y
  CONFIG_USB_F_FS=y
  CONFIG_USB_CONFIGFS_F_FS=y

Requires in local.conf for RPi4:
  RPI_EXTRA_CONFIG = "dtoverlay=dwc2,dr_mode=peripheral"

AI-Generated: Uses GitHub Copilot (Claude Sonnet 4.6)

Signed-off-by: Mihajlo Marinkovic <mmarinkovic@snap.com>
Tested-by: Etienne Cordonnier <ecordonnier@snap.com>
Co-authored-by: Etienne Cordonnier <ecordonnier@snap.com>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
2026-06-20 23:41:37 -07:00