Skip to main content

android/agent/
mod.rs

1//! The resident agent from the host side (design D2 and D3): deploying it,
2//! reusing or replacing a running one, and the connection a session drives.
3//!
4//! - [`AgentJar`] is the single-dex jar `agent-android/build.sh` writes and
5//!   the version its hello must name.
6//! - [`Deployer::attach`] reuses a running agent this host started when its
7//!   protocol and agent versions match, replaces one that does not, and
8//!   otherwise pushes the jar read-only, starts it detached as the shell user
9//!   with a per-launch socket name and token, and waits for its ready line.
10//!   Another holder of UI automation is reported as a [`Conflict`] naming the
11//!   likely holder, and taken over only with [`DeployOptions::force`].
12//! - [`Connection`] drives the protocol crate's `HostSession` over the
13//!   agent's abstract socket, opened as an adb service stream, on a reader
14//!   thread that answers pings and delivers responses and events.
15//!
16//! Nothing is installed on the device: no package, no instrumentation, no
17//! forward rule. The pushed jar is deleted once the agent has started, and
18//! the agent exits on `shutdown`, on its idle bound without a host, or when a
19//! host refuses its protocol version.
20
21mod connection;
22mod deploy;
23mod jar;
24mod launch;
25mod records;
26
27pub use connection::{Connection, EventSink};
28pub use deploy::{
29    AgentInfo, AgentState, Attached, Compatibility, Conflict, DeployError, DeployOptions, Deployer,
30    Incompatibility, Launched, Outcome, Replaced, Stopped, Timings, agent_state, compatibility,
31    push_jar,
32};
33pub use jar::{AGENT_NAME, AGENT_VERSION, AgentJar, JAR_VAR, JarError, default_jar_path};
34pub use launch::{
35    ConflictLine, Holder, JAR_MODE, MAIN_CLASS, PROCESS_NAME, PS_COMMAND, ReadyLine, RunningAgent,
36    SocketName, TOKEN_VARIABLE, launch_command, parse_agents, parse_conflict, parse_ready,
37    random_hex, remote_jar,
38};
39pub use records::{Record, Records};