Thanks to visit codestin.com
Credit goes to github.com

Skip to content

adb: add Android Debug Bridge backend - fixes #2956#9409

Open
ferrumclaudepilgrim wants to merge 1 commit into
rclone:masterfrom
ferrumclaudepilgrim:adb-backend-revival
Open

adb: add Android Debug Bridge backend - fixes #2956#9409
ferrumclaudepilgrim wants to merge 1 commit into
rclone:masterfrom
ferrumclaudepilgrim:adb-backend-revival

Conversation

@ferrumclaudepilgrim
Copy link
Copy Markdown
Contributor

What is the purpose of this change?

Adds Android Debug Bridge as an rclone backend. Forward-ports B4dM4n's 2019 implementation to current master, swaps the dead thinkhy/go-adb for electricbubble/gadb (vendored subset to access exec:), and adds Move, Copy, Purge, About, DirMove.

Was the change discussed in an issue or in the forum before?

Closes #2956.

Known (potential) Issues

  • Toybox 0.7.3 on API 26 (Galaxy S7 with /data/media) does not preserve modtime on cp -p. TestServerSideCopy family fails there. Toybox 0.8.0 and up (API 29+) preserves correctly.
  • Vendored gadb uses ADB SYNC V1. File size is carried as uint32, so files at or above 4 GiB have their reported size wrap modulo 2^32. AOSP defines V2 with a 64-bit size field; not implemented here.
  • Context cancel returns rclone immediately but does not abort the in-flight device-side shell command.

Devices tested

Pixel 10 Pro (API 37), Galaxy S26 Ultra (API 36), Moto G7 Power (API 29), Galaxy S7 (API 26).

Fork CI green here

Adds an rclone backend for Android devices over the ADB protocol.
Forward-ports the 2019 implementation by B4dM4n on
ncw/rclone#adb-remote to current master, swaps the dead
`thinkhy/go-adb` for `electricbubble/gadb` (vendored as a subset
because gadb upstream does not expose the `exec:` service required
for range reads), and adds the operations the original beta did
not have:

- Move (server-side mv with destination-parent mkdir)
- Copy (server-side cp -p with destination-parent mkdir)
- Purge (server-side rm -rf)
- About (df -k parsing for /data/media and /dev/fuse layouts)
- DirMove (with proper fs.ErrorDirExists semantics)

The default encoder mask covers Windows-reserved characters, leading
and trailing whitespace and dots, control characters, and percent so
fstest's TestFsEncoding subtests pass on every device class probed.

Tested on Galaxy S7 (API 26), Moto G7 Power (API 29), Galaxy S26
Ultra (API 36), and Pixel 10 Pro (API 37).
@ferrumclaudepilgrim
Copy link
Copy Markdown
Contributor Author

I'll have to say this was quite the experience. A few things I left out of the PR Body for presumed etiquette:

  • the ADB library swap was intentional to gather a more recently maintained ADB Go library
  • root was considered but left out on purpose. Precedent is mixed and path is supplied on each invocation which works for use case. Wondering if there is any feedback?

The Android API differences surfaced some genuinely useful, and time consuming debugging such as

  • Toybox 0.7.3 on API 26 doesn't honor cp -p for modtime preservation
  • overall fun times with encoder.Standard
  • Android directory related quirks.

The last 70ish hours of work have been strictly dedicated to this and the notes are long and full. Android/ ADB continues to amaze me rather regularly, in a good way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

adb as storage provider

1 participant