brief description
C++ native service in AOSP, provide AIDL service
preparation for demo test
- open access to push apk and service to device
1 2 3
adb root adb remount adb reboot
- 关闭权限: setenforce 0
常用操作
-
查询服务是否存在: service list grep -i tbox - 安装和卸载 apk: adb install -r xxx.apk, adb uninstall com.xxx
日志
- 查看日志: adb logcat -s tbox
build
- 编译: source build/envsetup.sh && lunch blahblah && m -j8 binary
how app use the service
case1: app build in AOSP use Android.bp
- assume aidl_interface name is vendor.dog.cat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
aidl_interface { name: "vendor.dog.cat", vendor_available: true, owner: "aptiv", srcs: [ "vendor/dog/cat/ICute.aidl", ], stability: "vintf", backend: { ndk: { enabled: true, }, java: { enabled: true, platform_apis: true, }, cpp: { enabled: false, }, }, frozen: true, versions_with_info: [ { version: "1", imports: [], }, ], } - you will get things like vendor.dog.cat-java that can directly be used
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
android_app { name: "ClientApp", srcs: ["java/**/*.java"], resource_dirs: ["res"], manifest: "AndroidManifest.xml", // platform_apis:true gives access to @hide APIs such as ServiceManager. platform_apis: true, // Sign with the platform key and install to /system/priv-app so the // app has sufficient privilege to reach the vendor AIDL service. certificate: "platform", privileged: true, // Java stubs generated from the vendor.dog.cat aidl_interface (V1). static_libs: [ "vendor.dog.cat-V1-java", ], }
case 2: app not use AOSP
- you should give .jar
- where to find it
out/soong/.intermediates/vendor/dog/cat/aidl/vendor.dog.cat-V1-java/android_common/javac/vendor.dog.cat-V1-java.jar
- how to use: ```c // use it like a normal jar package in Android studio in gradle // give it some signs like date to track the version dependencies { implementation(files(“libs\vendor.dog.cat-V1-java-260407.jar”)) testImplementation(“junit:junit:4.13.2”) }
```
what can not work