Skip to content

Commit c266563

Browse files
xaionaro@dx.centerxaionaro@dx.center
authored andcommitted
fix(spec2readme): correct gadb runner and vibrator examples in README template
Fix the spec2readme generator templates that produce README sections: - Vibrator: use actual HAL proxy (vibrator.NewVibratorProxy) instead of nonexistent genOs.NewVibratorServiceProxy - gadb runner: fix Run() signature to (command, timeout) returning *RunResult with Stdout field - gadb proxy session: replace broken sess.Transport() call (field is unexported) with accurate comment about session lifecycle
1 parent 73ff80e commit c266563

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,7 +2295,7 @@ and run commands programmatically:
22952295
dr, _ := runner.NewDeviceRunner("SERIAL")
22962296
dr.PushBinary(ctx, "build/mybinary", "/data/local/tmp/mybinary")
22972297
result, _ := dr.Run(ctx, "/data/local/tmp/mybinary", 30*time.Second)
2298-
fmt.Println(result.Output)
2298+
fmt.Println(result.Stdout)
22992299
```
23002300

23012301
For remote binder access from a host machine, `interop/gadb/proxy/`
@@ -2304,8 +2304,8 @@ sets up a forwarded session:
23042304
```go
23052305
sess, _ := proxy.NewSession(ctx, "SERIAL")
23062306
defer sess.Close(ctx)
2307-
transport := sess.Transport() // *RemoteTransport
2308-
reply, _ := transport.Transact(ctx, descriptor, code, 0, data)
2307+
// Session manages the daemon lifecycle and port forwarding;
2308+
// binder calls are routed through the remote transport.
23092309
```
23102310

23112311
</details>

tools/cmd/spec2readme/main.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -669,18 +669,19 @@ The examples above cover specific subsystems, but the library supports **all** A
669669
670670
` + "```bash" + `
671671
# Find the proxy for a known AIDL interface
672-
grep -r 'DescriptorI.*= "android.os.IVibratorService"' android/
672+
grep -r 'DescriptorI.*= "android.hardware.vibrator.IVibrator"' android/
673673
` + "```" + `
674674
675675
3. **Connect and call methods:**
676676
677677
` + "```go" + `
678-
svc, err := sm.GetService(ctx, servicemanager.VibratorService)
678+
svc, err := sm.GetService(ctx, servicemanager.ServiceName(
679+
vibrator.DescriptorIVibrator+"/default"))
679680
if err != nil {
680681
log.Fatal(err)
681682
}
682-
proxy := genOs.NewVibratorServiceProxy(svc)
683-
result, err := proxy.SomeMethod(ctx, args...)
683+
proxy := vibrator.NewVibratorProxy(svc)
684+
caps, err := proxy.GetCapabilities(ctx)
684685
` + "```" + `
685686
686687
4. **For HAL services** (hardware abstraction layers), the service name is the AIDL descriptor plus ` + "`/default`" + `:
@@ -939,7 +940,8 @@ and run commands programmatically:
939940
` + "```go" + `
940941
dr, _ := runner.NewDeviceRunner("SERIAL")
941942
dr.PushBinary(ctx, "build/mybinary", "/data/local/tmp/mybinary")
942-
output, _ := dr.Run(ctx, "/data/local/tmp/mybinary", "--flag")
943+
result, _ := dr.Run(ctx, "/data/local/tmp/mybinary", 30*time.Second)
944+
fmt.Println(result.Stdout)
943945
` + "```" + `
944946
945947
For remote binder access from a host machine, ` + "`interop/gadb/proxy/`" + `
@@ -948,8 +950,8 @@ sets up a forwarded session:
948950
` + "```go" + `
949951
sess, _ := proxy.NewSession(ctx, "SERIAL")
950952
defer sess.Close(ctx)
951-
sm := servicemanager.New(sess.Transport())
952-
// Use sm as if running on-device
953+
// Session manages the daemon lifecycle and port forwarding;
954+
// binder calls are routed through the remote transport.
953955
` + "```" + `
954956
955957
</details>

0 commit comments

Comments
 (0)