Skip to content

Commit ccd0f24

Browse files
xaionaro@dx.centerxaionaro@dx.center
authored andcommitted
Update README.md
1 parent 363b83f commit ccd0f24

1 file changed

Lines changed: 35 additions & 10 deletions

File tree

README.md

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,39 @@ Call Android system services from pure Go. Provides ~12000 type-safe Go methods
1010

1111
Includes a complete AIDL compiler that parses Android Interface Definition Language files and generates the Go proxies, a version-aware runtime that adapts transaction codes across Android API levels, and a CLI tool (`bindercli`) for interactive service discovery and invocation.
1212

13+
## What can it do?
14+
15+
- **Query system services** — battery level, GPS location, thermal status, running processes, installed packages
16+
- **Control hardware** — connect to WiFi, toggle flashlight, manage Bluetooth, configure audio
17+
- **Interact with any binder service** — ActivityManager, PowerManager, SurfaceFlinger, camera/sensor HALs, and 600+ more
18+
- **No Java, no cgo** — pure Go, cross-compiles to a static binary, runs on Android or any Linux with `/dev/binder`
19+
- **CLI tool included**`bindercli` for interactive service discovery, method invocation, and debugging
20+
21+
## Quick start
22+
23+
**CLI** — download from [releases](https://github.com/xaionaro-go/binder/releases) and push to device:
24+
25+
```bash
26+
adb push bindercli /data/local/tmp/ && adb shell chmod 755 /data/local/tmp/bindercli
27+
adb shell /data/local/tmp/bindercli service list # list all services
28+
adb shell /data/local/tmp/bindercli battery level # check battery
29+
adb shell /data/local/tmp/bindercli location providers # list GPS providers
30+
```
31+
32+
**Go library**`go get github.com/xaionaro-go/binder` and call any service:
33+
34+
```go
35+
driver, _ := kernelbinder.Open(ctx, binder.WithMapSize(128*1024))
36+
defer driver.Close(ctx)
37+
sm := servicemanager.New(driver)
38+
svc, _ := sm.GetService(ctx, "activity")
39+
am := app.NewActivityManagerProxy(svc)
40+
limit, _ := am.GetProcessLimit(ctx)
41+
```
42+
43+
<details>
44+
<summary>Related projects: ndk, jni, binder (click to expand)</summary>
45+
1346
## Android Interfaces for Go
1447

1548
This project is part of a family of three Go libraries that cover the major Android interface surfaces. Each wraps a different layer of the Android platform:
@@ -69,6 +102,8 @@ All three libraries talk to the same Android system services, but through differ
69102
- The **Java SDK** uses binder IPC internally for system service access (BluetoothManager, LocationManager, etc.), routing calls through the Android Runtime (ART/Dalvik). The `jni` library calls into these Java APIs via the JNI C interface and cgo.
70103
- The **AIDL binder protocol** is the underlying IPC mechanism that system-facing NDK and Java SDK APIs use. The `binder` library implements this protocol directly in pure Go, bypassing both C and Java layers entirely.
71104

105+
</details>
106+
72107
## Usage Examples
73108

74109
### List Binder Services
@@ -1750,16 +1785,6 @@ Each binder method has a numeric transaction code that can differ between Androi
17501785

17511786
Methods 2 and 3 exist only for extra reliability in edge cases (e.g. no read access to `/system/framework/`). The `genversions` tool builds the version tables by checking out AOSP revision tags and recording method→code mappings.
17521787

1753-
The resolved table can be cached to disk for fast subsequent startups by passing `OptionCachePath`:
1754-
1755-
```go
1756-
transport, err := versionaware.NewTransport(ctx, driver, 0,
1757-
versionaware.OptionCachePath("/data/local/tmp/binder-codes.json"),
1758-
)
1759-
```
1760-
1761-
Caching is disabled by default. The cache is fingerprinted and automatically invalidated when the device firmware changes.
1762-
17631788
## Testing and Verification
17641789

17651790
The project is verified at four levels:

0 commit comments

Comments
 (0)