Skip to content

Commit 7be21c8

Browse files
xaionaro@dx.centerxaionaro@dx.center
authored andcommitted
regenerate proto/grpc/cli, fix Looper NPE, Context auto-fill, and add E2E service tests
Regenerate all proto, gRPC server/client, and CLI code from updated specs using the full generation pipeline (proto → protoc → grpc → cli). Fixes: - Add gRPC Looper interceptor that pins handler goroutines to OS threads, attaches to the JVM, and calls Looper.prepare() before handlers execute. Fixes NPEs in InputMethodManager, WindowManager, and other services that create Handlers internally. Use prepareMainLooper() in initAndroidContext. - Auto-fill android.content.Context parameters in generated server code from s.Ctx.Obj instead of requiring a client-side handle. Fixes NPE in DownloadManager.getMaxBytesOverMobile and similar static methods. - Fall back to /data/local/tmp/ in microphone/camera record commands when getCacheDir() fails (package "android" has no data directory). Add comprehensive E2E service tests (tests/e2e-grpc/services_test.go) covering 32 working services, expected-error cases, and unimplemented service detection.
1 parent cee77c2 commit 7be21c8

373 files changed

Lines changed: 248208 additions & 113098 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ cover.out
66
examples/test_results/
77
go.work
88
go.work.sum
9+
jnicli
10+
build/

.golangci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "2"
2+
3+
run:
4+
timeout: 5m
5+
6+
linters:
7+
enable:
8+
- govet
9+
- staticcheck
10+
- errcheck
11+
- ineffassign
12+
- unused

Makefile

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
1-
.PHONY: generate callbacks clean lint test test-e2e test-emulator \
1+
.PHONY: generate callbacks proto protoc grpc cli clean lint test test-tools test-e2e test-emulator \
22
build build-server list-commands dist dist-jnicli-linux dist-jnicli-android dist-jniserviceadmin dist-jniservice dist-dex \
33
magisk apk deploy push start-server stop-server forward
44

5+
# Path to the jni repo checkout (sibling directory by default).
6+
JNI_DIR ?= ../jni
7+
58
# Android SDK platform JAR for specgen.
69
ANDROID_JAR ?= $(ANDROID_HOME)/platforms/android-36/android.jar
710

8-
# Run callbackgen — generates Java callback adapter classes
9-
generate: callbacks
11+
# Run all generators
12+
generate: callbacks proto protoc grpc cli
1013

1114
# Run callbackgen — generates Java callback adapter classes
1215
callbacks:
1316
go run ./tools/cmd/callbackgen/
1417

18+
# Run protogen — generates .proto files from Java API specs
19+
proto:
20+
go run ./tools/cmd/protogen/ -specs $(JNI_DIR)/spec/java/ -overlays $(JNI_DIR)/spec/overlays/java/ -output proto/ -go-module github.com/AndroidGoLab/jni-proxy
21+
@mkdir -p proto/handlestore
22+
@cp $(JNI_DIR)/spec/handlestore.proto proto/handlestore/handlestore.proto
23+
24+
# Run protoc — compiles .proto files to Go stubs
25+
protoc: proto
26+
@command -v protoc >/dev/null 2>&1 || { echo "protoc not found. Install: https://grpc.io/docs/protoc-installation/"; exit 1; }
27+
@for dir in proto/*/; do \
28+
pkg=$$(basename "$$dir"); \
29+
protoc -I. --go_out=. --go_opt=paths=source_relative \
30+
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
31+
"$$dir$$pkg.proto"; \
32+
done
33+
34+
# Run grpcgen — generates gRPC server and client wrappers
35+
grpc: protoc
36+
go run ./tools/cmd/grpcgen/ -specs $(JNI_DIR)/spec/java/ -overlays $(JNI_DIR)/spec/overlays/java/ -output . -go-module github.com/AndroidGoLab/jni-proxy -jni-module github.com/AndroidGoLab/jni
37+
38+
# Run cligen — generates jnicli cobra commands from Java API specs
39+
cli: grpc
40+
go run ./tools/cmd/cligen/ -specs $(JNI_DIR)/spec/java/ -overlays $(JNI_DIR)/spec/overlays/java/ -output cmd/jnicli/ -go-module github.com/AndroidGoLab/jni-proxy
41+
42+
# Run only tool tests (no JDK needed)
43+
test-tools:
44+
go test ./tools/...
45+
1546
# List all jnicli leaf commands as full paths
1647
list-commands:
1748
@go run ./cmd/jnicli/ list-commands

cmd/jnicli/accounts.go

Lines changed: 104 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/jnicli/admin.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)