Android-HAL (四) 2 AIDL 更新

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
相关推荐
哲伦贼稳妥13 分钟前
职场发展-遇到以下情况请直接准备后手吧
运维·经验分享·其他·职场和发展
Vaticann7 小时前
Claude Code From 0 to 1
其他
成都云希多肽生产厂家Gloria2 天前
Noopept N-(1-(苯基乙酰基)-L-脯氨酰)甘氨酸乙酯 CAS:157115-85-0
其他
闪闪发亮的小星星3 天前
主旋参数(四元数)与欧拉参数
笔记·其他
头发还没掉光光3 天前
翻译技巧总结
其他
qq_403742554 天前
Ubuntu 24.04 安装 LaTeX + VSCode 环境指南
vscode·其他
数据安全科普王4 天前
从 HTTP/1.1 到 HTTP/3:协议演进如何改变 Web 性能?
网络·其他
方安乐5 天前
命理学研究
其他
闪闪发亮的小星星7 天前
欧拉角的定义
其他
探序基因8 天前
R语言读取h5格式的文件
其他