Skip to content

A high-performance Android storage analyzer that bypasses MTP using a native C++ daemon, a Rust TCP bridge, and a React Treemap UI.

Rust

Bundle and select Android daemons for all supported ABIs (#147)

Vishnu Srivatsava6c26ad068cdd
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 852c189..a80a41f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -168,7 +168,7 @@ jobs:
# compiles the Rust bridge, and packages everything into native
# platform installers (.dmg / .deb / .AppImage / .msi / .exe).
- name: Build Tauri app
- run: npm run tauri build
+ run: npm run tauri -- build --verbose
- name: Test Rust bridge
run: cargo test --locked --manifest-path src-tauri/Cargo.toml --lib
@@ -254,7 +254,10 @@ jobs:
assert_mode 755 "$APPDIR/AppRun.wrapped"
fi
assert_mode 755 "$APPDIR/usr/lib/SocketSweep/bin/adb"
- assert_mode 755 "$APPDIR/usr/lib/SocketSweep/bin/daemon"
+ for daemon in daemon daemon-armeabi-v7a daemon-x86 daemon-x86_64; do
+ assert_mode 644 "$APPDIR/usr/share/SocketSweep/bin/$daemon"
+ cmp "src-tauri/bin/$daemon" "$APPDIR/usr/share/SocketSweep/bin/$daemon"
+ done
# Download appimagetool for repacking — pinned to 1.9.1 and
# checksum-verified (GitHub "continuous" builds are unpinned, and
diff --git a/.gitignore b/.gitignore
index 0db0ab7..47f2fcc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,7 @@ engine/daemon
/engine/daemon-armeabi-v7a
/engine/daemon-x86
/engine/daemon-x86_64
+/src-tauri/bin/daemon-*
/src-tauri/bin/adb
/src-tauri/bin/adb.exe
/src-tauri/bin/AdbWinApi.dll
diff --git a/README.md b/README.md
index 17d0c63..a0e9076 100644
--- a/README.md
+++ b/README.md
@@ -266,10 +266,12 @@ configured path fails explicitly rather than selecting a different toolchain.
copies it into `src-tauri/bin/daemon`, which Tauri bundles. Rebuild after changing
the daemon so local development uses the current protocol (v3).*
-For cross-compilation experiments, pass `--abi armeabi-v7a`, `--abi x86`,
-or `--abi x86_64` to the build command. These builds write
-`engine/daemon-<abi>` for Android API 31. The desktop app still bundles
-and runs the ARM64 daemon.
+The default build creates all four Android ABIs and copies them into the Tauri
+resources. Use `--abi arm64-v8a`, `--abi armeabi-v7a`, `--abi x86`, or
+`--abi x86_64` to rebuild one target. The app chooses the first supported ABI
+advertised by the selected device. All binaries target Android API 31
+(Android 12) or newer. ARMv7 support therefore covers 32-bit Android 12+
+systems; Android versions below 12 remain unsupported.
Ordinary storage scans use a bounded pool of four workers. For daemon-level
comparisons, append `--threads N` (1–8) after `PORT TOKEN_FILE`; one worker
diff --git a/docs/daemon-symbols.md b/docs/daemon-symbols.md
index 3390374..b73a013 100644
--- a/docs/daemon-symbols.md
+++ b/docs/daemon-symbols.md
@@ -1,6 +1,6 @@
# Daemon crash symbols
-CI builds an optimized Android ARM64 daemon with debug information, archives the
+CI builds optimized Android daemons for all four ABIs with debug information, archives the
unstripped executable, and strips a separate copy for Tauri to bundle. Debug
files stay outside `src-tauri/bin`; they are not pushed to the phone by the app.
This addresses [#15](https://github.com/VishnuSrivatsava/SocketSweep/issues/15).
@@ -11,6 +11,15 @@ Each macOS/Linux/Windows job uploads a separate workflow artifact:
daemon-symbols-<platform>-android-<full-workflow-commit-SHA>-attempt-<N>
socketsweep_daemon
metadata.json
+ armeabi-v7a/
+ socketsweep_daemon
+ metadata.json
+ x86/
+ socketsweep_daemon
+ metadata.json
+ x86_64/
+ socketsweep_daemon
+ metadata.json
```
`socketsweep_daemon` is the unstripped archive filename. Owned sessions execute
@@ -62,22 +71,27 @@ or other device details before sharing them publicly.
## What CI verifies
-`tests/check_daemon_symbols.py` uses the NDK's LLVM tools to require ARM64 ELF
-files, identical nonempty build IDs, debug/line/static symbol sections in the
+`tests/check_daemon_symbols.py` uses the NDK's LLVM tools to require the selected ABI's ELF class and machine,
+identical nonempty build IDs, debug/line/static symbol sections in the
archive, and their absence in the bundled binary. It compares the `.text` bytes
and virtual addresses before/after stripping, then resolves the actual `main`
address to `engine/daemon.cpp` with a nonzero source line. Only after those checks
does it write the artifact manifest. A missing tool or failed check fails CI.
These are host-side ELF checks: they neither run the Android daemon nor require
-a crash, ADB, a connected phone, or the desktop app. Local `engine/build.sh`
-continues its existing stripped build behavior; its broader build/provisioning
-work remains tracked in [#41](https://github.com/VishnuSrivatsava/SocketSweep/issues/41).
+a crash, ADB, a connected phone, or the desktop app. Local `engine/build.sh` builds all four stripped binaries by default.
+Pass `--abi <name>` to rebuild one ABI.
The build entry point also accepts `--abi armeabi-v7a`, `--abi x86`, or
-`--abi x86_64` with `--platform` and `--commit`. These experimental builds
-write `engine/daemon-<abi>`, with debug files under `daemon-symbols/<abi>/`.
+`--abi x86_64` with `--platform` and `--commit`. These builds
+write `src-tauri/bin/daemon-<abi>`, with debug files under `daemon-symbols/<abi>/`.
The checker validates the requested ELF class and machine as well as matching
build IDs, code bytes, and source lookup. Verification finishes before publishing
-the stripped binary. CI cross-builds and verifies all four ABIs. Desktop installers currently bundle ARM64; the other binaries and their symbols are retained for cross-build validation.
+the stripped binary. CI cross-builds and verifies all four ABIs. Desktop installers bundle all four stripped binaries. The selected device’s ABI list determines which binary is pushed.
+
+Linux packages store the Android ELF resources in
+`/usr/share/SocketSweep/bin/`. This keeps AppImage dependency discovery from
+treating x86 Android binaries as host Linux shared libraries. The native ADB
+resource stays under `/usr/lib/SocketSweep/bin/`. Linux debug builds resolve
+the daemon files directly from the development checkout.
diff --git a/engine/build_daemon.py b/engine/build_daemon.py
index d24b179..dac8c49 100644
--- a/engine/build_daemon.py
+++ b/engine/build_daemon.py
@@ -58,9 +58,11 @@ def toolchain(abi):
def build(platform, commit, abi):
compiler = toolchain(abi)
local = REPO / "engine/daemon"
- experimental = abi != "arm64-v8a"
- bundle = local.with_name(f"daemon-{abi}") if experimental else REPO / "src-tauri/bin/daemon"
- outputs = (bundle,) if platform or experimental else (bundle, local)
+ additional_abi = abi != "arm64-v8a"
+ if additional_abi:
+ local = local.with_name(f"daemon-{abi}")
+ bundle = REPO / "src-tauri/bin" / local.name
+ outputs = (bundle,) if platform else (bundle, local)
for output in outputs:
if output.exists() and not output.is_file():
raise ValueError(f"Output path is not a regular file: {output}")
@@ -77,7 +79,7 @@ def build(platform, commit, abi):
args.append("-D_FILE_OFFSET_BITS=64")
if platform:
symbols_dir = REPO / "daemon-symbols"
- if experimental:
+ if additional_abi:
symbols_dir = symbols_dir / abi
symbols = symbols_dir / "socketsweep_daemon"
symbols.parent.mkdir(parents=True, exist_ok=True)
@@ -89,11 +91,10 @@ def build(platform, commit, abi):
subprocess.run([str(strip), "--strip-all", "-o", str(staged), str(symbols)], check=True)
else:
subprocess.run([*args, "-s", "-o", str(staged), str(REPO / "engine/daemon.cpp")], check=True)
- if not experimental:
- with TemporaryDirectory(prefix=".daemon-build-", dir=local.parent) as local_stage:
- local_copy = Path(local_stage) / "daemon"
- shutil.copy2(staged, local_copy)
- local_copy.replace(local)
+ with TemporaryDirectory(prefix=".daemon-build-", dir=local.parent) as local_stage:
+ local_copy = Path(local_stage) / "daemon"
+ shutil.copy2(staged, local_copy)
+ local_copy.replace(local)
if platform:
subprocess.run([
sys.executable, str(REPO / "tests/check_daemon_symbols.py"),
@@ -108,12 +109,13 @@ def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--platform", choices=("linux", "macos", "windows"))
parser.add_argument("--commit", help="Commit for the CI symbol manifest")
- parser.add_argument("--abi", choices=TARGETS, default="arm64-v8a")
+ parser.add_argument("--abi", choices=TARGETS, help="Build one ABI; default builds all four")
args = parser.parse_args()
if bool(args.platform) != bool(args.commit):
parser.error("--platform and --commit must be passed together")
try:
- build(args.platform, args.commit, args.abi)
+ for abi in (args.abi,) if args.abi else TARGETS:
+ build(args.platform, args.commit, abi)
except (ValueError, OSError, subprocess.CalledProcessError) as error:
parser.exit(1, f"ERROR: {error}\n")
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 18e2c79..56ff1ee 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -96,6 +96,23 @@ fn get_bundled_binary(app: &tauri::AppHandle, name: &str) -> Result<std::path::P
}
}
+ // Android ELF resources must stay out of usr/lib in Linux packages:
+ // linuxdeploy otherwise treats x86 Android libraries as host dependencies.
+ #[cfg(target_os = "linux")]
+ if name == "daemon" {
+ #[cfg(debug_assertions)]
+ {
+ let development = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("bin/daemon");
+ if development.is_file() {
+ return Ok(development);
+ }
+ }
+ let shared = resource_dir.join("../../share/SocketSweep/bin/daemon");
+ if shared.is_file() {
+ return Ok(shared);
+ }
+ }
+
let path = resource_dir.join("bin").join(name);
if path.exists() {
Ok(path)
diff --git a/src-tauri/src/session.rs b/src-tauri/src/session.rs
index 247d6d5..5c0a43d 100644
--- a/src-tauri/src/session.rs
+++ b/src-tauri/src/session.rs
@@ -56,6 +56,23 @@ fn supports_shell_v2(output: &str) -> bool {
output.lines().any(|feature| feature.trim() == "shell_v2")
}
+fn bundled_daemon(arm64: &Path, abis: &str) -> Result<PathBuf, String> {
+ for abi in abis.trim().split(',').map(str::trim) {
+ let path = match abi {
+ "arm64-v8a" => arm64.to_path_buf(),
+ "armeabi-v7a" => arm64.with_file_name("daemon-armeabi-v7a"),
+ "x86" => arm64.with_file_name("daemon-x86"),
+ "x86_64" => arm64.with_file_name("daemon-x86_64"),
+ _ => continue,
+ };
+ if !path.is_file() {
+ return Err(format!("Bundled daemon for {abi} is missing. Rebuild all daemon ABIs."));
+ }
+ return Ok(path);
+ }
+ Err("The selected device does not advertise a supported Android ABI.".into())
+}
+
fn startup_stderr(mut pipe: impl Read + Send + 'static) -> Receiver<String> {
let (send, receive) = sync_channel(1);
std::thread::spawn(move || {
@@ -189,9 +206,7 @@ impl Session {
return Err("The connected device must support ADB shell v2 for owned sessions".into());
}
let abis = self.adb(&["shell", "getprop ro.product.cpu.abilist"], None, deadline)?;
- if !abis.trim().split(',').any(|abi| abi.trim() == "arm64-v8a") {
- return Err("This build requires an Android device that supports the arm64-v8a ABI.".into());
- }
+ let daemon = bundled_daemon(daemon, &abis)?;
self.privilege = select_privilege(root_mode, |args| self.adb(args, None, deadline))?;
// The directory is shell-owned even for su launches, so adb push can
// write into it. mkdir must succeed exclusively before cleanup owns it.
@@ -531,13 +546,55 @@ mod tests {
}
#[test]
- fn unsupported_device_abi_fails_before_creating_session_resources() {
+ fn device_abi_order_selects_only_the_matching_bundled_binary() {
+ let device = Device::new();
+ let directory = device.root.join("bundle");
+ fs::create_dir(&directory).unwrap();
+ let arm64 = directory.join("daemon");
+ for name in [
+ "daemon", "daemon-armeabi-v7a", "daemon-x86", "daemon-x86_64",
+ ] {
+ std::os::unix::fs::symlink(daemon(), directory.join(name)).unwrap();
+ }
+ for (index, (abis, name)) in [
+ ("arm64-v8a,armeabi-v7a", "daemon"),
+ ("armeabi-v7a,armeabi", "daemon-armeabi-v7a"),
+ ("x86_64,x86", "daemon-x86_64"),
+ ("unknown,x86", "daemon-x86"),
+ (" x86,arm64-v8a\r\n", "daemon-x86"),
+ ].into_iter().enumerate() {
+ let adb = device.client(&format!("abi-{index}"), "selected");
+ fs::write(adb.parent().unwrap().join("abis.txt"), abis).unwrap();
+ let (mut session, _) =
+ Session::start(adb.clone(), &arm64, "selected".into(), false).unwrap();
+ assert!(ping(&session).contains("\"status\":\"ok\""));
+ let calls = fs::read_to_string(adb.parent().unwrap().join("calls.jsonl")).unwrap();
+ let push = calls
+ .lines()
+ .map(|line| serde_json::from_str::<Vec<String>>(line).unwrap())
+ .find(|args| args[0] == "push")
+ .unwrap();
+ assert_eq!(Path::new(&push[1]), directory.join(name));
+ let errors = session.cleanup();
+ assert!(errors.is_empty(), "{errors:?}");
+ assert_eq!(device.rows().len(), 1);
+ }
+ for abis in ["", "arm64-v8ax", "mips", "../x86"] {
+ assert!(bundled_daemon(&arm64, abis).is_err());
+ }
+ fs::remove_file(directory.join("daemon-x86_64")).unwrap();
+ assert!(bundled_daemon(&arm64, "x86_64,x86")
+ .unwrap_err().contains("missing"));
+ }
+
+ #[test]
+ fn missing_device_abi_binary_fails_before_creating_session_resources() {
let device = Device::new();
let adb = device.client("x86", "emulator");
fs::write(adb.parent().unwrap().join("abis.txt"), "x86_64,x86\r\n").unwrap();
let error = Session::start(adb.clone(), daemon(), "emulator".into(), true)
.err().expect("unsupported ABI accepted");
- assert!(error.contains("arm64-v8a"), "{error}");
+ assert!(error.contains("x86_64") && error.contains("missing"), "{error}");
let calls = fs::read_to_string(adb.parent().unwrap().join("calls.jsonl")).unwrap();
assert!(!calls.contains("mkdir") && !calls.contains("push") && !calls.contains("su -c"));
assert_eq!(device.directories(), 0);
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index dead010..be3ebe1 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -26,7 +26,10 @@
"targets": "all",
"resources": [
"bin/adb",
- "bin/daemon"
+ "bin/daemon",
+ "bin/daemon-armeabi-v7a",
+ "bin/daemon-x86",
+ "bin/daemon-x86_64"
],
"icon": [
"icons/32x32.png",
diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json
new file mode 100644
index 0000000..f759ce3
--- /dev/null
+++ b/src-tauri/tauri.linux.conf.json
@@ -0,0 +1,33 @@
+{
+ "bundle": {
+ "resources": [
+ "bin/adb"
+ ],
+ "linux": {
+ "deb": {
+ "files": {
+ "/usr/share/SocketSweep/bin/daemon": "bin/daemon",
+ "/usr/share/SocketSweep/bin/daemon-armeabi-v7a": "bin/daemon-armeabi-v7a",
+ "/usr/share/SocketSweep/bin/daemon-x86": "bin/daemon-x86",
+ "/usr/share/SocketSweep/bin/daemon-x86_64": "bin/daemon-x86_64"
+ }
+ },
+ "rpm": {
+ "files": {
+ "/usr/share/SocketSweep/bin/daemon": "bin/daemon",
+ "/usr/share/SocketSweep/bin/daemon-armeabi-v7a": "bin/daemon-armeabi-v7a",
+ "/usr/share/SocketSweep/bin/daemon-x86": "bin/daemon-x86",
+ "/usr/share/SocketSweep/bin/daemon-x86_64": "bin/daemon-x86_64"
+ }
+ },
+ "appimage": {
+ "files": {
+ "/usr/share/SocketSweep/bin/daemon": "bin/daemon",
+ "/usr/share/SocketSweep/bin/daemon-armeabi-v7a": "bin/daemon-armeabi-v7a",
+ "/usr/share/SocketSweep/bin/daemon-x86": "bin/daemon-x86",
+ "/usr/share/SocketSweep/bin/daemon-x86_64": "bin/daemon-x86_64"
+ }
+ }
+ }
+ }
+}
diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json
index 2236652..6965909 100644
--- a/src-tauri/tauri.windows.conf.json
+++ b/src-tauri/tauri.windows.conf.json
@@ -4,7 +4,10 @@
"bin/adb.exe",
"bin/AdbWinApi.dll",
"bin/AdbWinUsbApi.dll",
- "bin/daemon"
+ "bin/daemon",
+ "bin/daemon-armeabi-v7a",
+ "bin/daemon-x86",
+ "bin/daemon-x86_64"
]
}
}
diff --git a/tests/test_engine_build.py b/tests/test_engine_build.py
index b3ed185..d1c296a 100644
--- a/tests/test_engine_build.py
+++ b/tests/test_engine_build.py
@@ -47,8 +47,9 @@ class EngineBuildTests(unittest.TestCase):
compiler.chmod(0o700)
return ndk
- def build(self, *args, **variables):
- return subprocess.run(["bash", str(self.engine / "build.sh"), *args], cwd=self.root,
+ def build(self, *args, default_abis=False, **variables):
+ return subprocess.run(["bash", str(self.engine / "build.sh"),
+ *([] if args or default_abis else ["--abi", "arm64-v8a"]), *args], cwd=self.root,
env={**self.environment, **{key: str(value) for key, value in variables.items()}},
capture_output=True, text=True, timeout=15)
@@ -128,7 +129,7 @@ class EngineBuildTests(unittest.TestCase):
self.assertFalse((self.ndks["explicit"] / "calls.json").exists())
- def test_experimental_32_bit_build_keeps_existing_arm64_artifacts(self):
+ def test_32_bit_build_keeps_existing_arm64_artifacts(self):
ndk = self.ndks["explicit"]
compiler = next(ndk.rglob("aarch64-linux-android31-clang++"))
compiler.rename(compiler.with_name("armv7a-linux-androideabi31-clang++"))
@@ -138,3 +139,16 @@ class EngineBuildTests(unittest.TestCase):
self.assertEqual((self.engine / "daemon").read_bytes(), b"existing engine")
self.assertEqual(self.bundled.read_bytes(), b"existing bundle")
self.assertIn("-D_FILE_OFFSET_BITS=64", json.loads((ndk / "calls.json").read_text()))
+ self.assertEqual((self.bundled.parent / "daemon-armeabi-v7a").read_bytes(), b"explicit")
+
+ def test_default_build_provisions_all_four_abis(self):
+ ndk = self.ndks["explicit"]
+ compiler = next(ndk.rglob("aarch64-linux-android31-clang++"))
+ for target in ("armv7a-linux-androideabi", "i686-linux-android", "x86_64-linux-android"):
+ shutil.copyfile(compiler, compiler.with_name(f"{target}31-clang++"))
+ compiler.with_name(f"{target}31-clang++").chmod(0o700)
+ result = self.build(default_abis=True, NDK=ndk)
+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
+ for name in ("daemon", "daemon-armeabi-v7a", "daemon-x86", "daemon-x86_64"):
+ self.assertEqual((self.engine / name).read_bytes(), b"explicit")
+ self.assertEqual((self.bundled.parent / name).read_bytes(), b"explicit")