godv/hardware/interface/mytest/aidl/android/hardware/mytest/IMyTest.aidl
在这里新增一个函数
package android.hardware.mytest;
import android.hardware.mytest.MyTestObj;
@VintfStability
interface IMyTest {
MyTestObj test();
void addTest(int a, int b);
}
编译报错
Which is: "@VintfStability\ninterface IMyTest {\n android.hardware.mytest.MyTestObj test();\n void addTest(int a, int b);\n}\n"
With diff:
@@ +2,4 @@
interface IMyTest {
android.hardware.mytest.MyTestObj test();
- void addTest(int a, int b);
}\n
m android.hardware.mytest-update-api
mmm vendor/godv/hardware/interface/mytest/
soong/.intermediates/vendor/godv/hardware/interface/mytest/aidl
在这个路径下新增了V2版本
bash
godv@godv-OptiPlex-7070:~/ass/godv/code/lineage/out/soong/.intermediates/vendor/godv/hardware/interface/mytest/aidl$ ls -la
total 52
drwxrwxr-x 13 godv godv 4096 12月 25 21:17 .
drwxrwxr-x 3 godv godv 4096 12月 25 20:56 ..
drwxrwxr-x 3 godv godv 4096 12月 25 22:11 android.hardware.mytest_interface
drwxrwxr-x 3 godv godv 4096 12月 25 20:56 android.hardware.mytest-V1-java
drwxrwxr-x 3 godv godv 4096 12月 25 20:56 android.hardware.mytest-V1-java-source
drwxrwxr-x 14 godv godv 4096 12月 25 20:56 android.hardware.mytest-V1-ndk
drwxrwxr-x 3 godv godv 4096 12月 25 20:56 android.hardware.mytest-V1-ndk-source
drwxrwxr-x 3 godv godv 4096 12月 25 21:17 android.hardware.mytest-V2-java
drwxrwxr-x 3 godv godv 4096 12月 25 21:17 android.hardware.mytest-V2-java-source
drwxrwxr-x 14 godv godv 4096 12月 25 21:17 android.hardware.mytest-V2-ndk
drwxrwxr-x 3 godv godv 4096 12月 25 21:17 android.hardware.mytest-V2-ndk-source
drwxrwxr-x 3 godv godv 4096 12月 25 20:56 default
drwxrwxr-x 3 godv godv 4096 12月 25 21:17 test
godv/hardware/interface/mytest/aidl/default/Android.bp
把这里面原本以来的"android.hardware.mytest-V1-ndk", 换成V2
cc_binary {
name: "android.hardware.mytest-service",
init_rc: ["android.hardware.mytest.rc"],
vintf_fragments: ["mytest-default.xml"],
vendor: true,
srcs: [
"MyTestImpl.cpp",
"main.cpp",
],
relative_install_path: "hw",
shared_libs: [
"libbase",
"libbinder_ndk",
"liblog",
"libutils",
"libcutils",
"android.hardware.mytest-V2-ndk",
],
}
参考soong/.intermediates/vendor/godv/hardware/interface/mytest/aidl/android.hardware.mytest-V2-ndk-source/gen/include/aidl/android/hardware/mytest/BpMyTest.h
将服务端代码补全
godv/hardware/interface/mytest/aidl/default/MyTestImpl.h
cpp
#pragma once
#include "aidl/android/hardware/mytest/BnMyTest.h"
namespace aidl {
namespace android {
namespace hardware {
namespace mytest {
class MyTestImpl : public BnMyTest {
MyTestObj mTestObj = {"test", 66};
::ndk::ScopedAStatus test(::aidl::android::hardware::mytest::MyTestObj* _aidl_return) override;
::ndk::ScopedAStatus addTest(int32_t in_a, int32_t in_b) override;
};
} // namespace mytest
} // namespace hardware
} // namespace android
} // namespace aidl
godv/hardware/interface/mytest/aidl/default/MyTestImpl.cpp
cpp
#define LOG_TAG "MyTestImpl"
#include "MyTestImpl.h"
#include <android-base/logging.h>
using ndk::ScopedAStatus;
namespace aidl {
namespace android {
namespace hardware {
namespace mytest {
ScopedAStatus MyTestImpl::test(MyTestObj* _aidl_return) {
*_aidl_return = mTestObj;
LOG(INFO) << "Computing shared secret";
return ScopedAStatus::ok();
}
ScopedAStatus MyTestImpl::addTest(int32_t in_a, int32_t in_b) {
LOG(INFO) << "Adding test " << in_a << " and " << in_b;
return ScopedAStatus::ok();
}
} // namespace MyTestImpl
} // namespace hardware
} // namespace android
} // namespace aidl