Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

绑定式HAL,java客户端能传对象吗? #2

Open
yunshuwanli opened this issue Apr 28, 2019 · 0 comments
Open

绑定式HAL,java客户端能传对象吗? #2

yunshuwanli opened this issue Apr 28, 2019 · 0 comments

Comments

@yunshuwanli
Copy link

绑定式HAL,java客户端调用Service和C++调用能传对象吗?

  1. 实现java调用hidl service的例子
    2.1 添加库:
    将以下内容添加到 Android.mk 中:
    LOCAL_JAVA_LIBRARIES += android.hardware.foo-V1.0-java

    将以下内容添加到 Android.bp 中:
    shared_libs: [
    /* … /
    "android.hardware.foo-V1.0-java",
    ],
    该库还存在静态版:android.hardware.foo-V1.0-java-static。
    2.2 将以下内容添加到您的 Java 文件中:
    import android.hardware.foo.V1_0.IFoo;
    ...
    // retry to wait until the service starts up if it is in the manifest
    IFoo server = IFoo.getService(true /
    retry /); // throws NoSuchElementException if not available
    IFoo anotherServer = IFoo.getService("second_impl", true /
    retry */);
    server.doSomething(…);

  2. 实现C++ 调用hidl service的例子
    首先将 HAL 库添加到 makefile 中:
    Make:LOCAL_SHARED_LIBRARIES += android.hardware.nfc@1.0
    Soong:shared_libs: [ …, android.hardware.nfc@1.0 ]
    接下来,添加 HAL 头文件:
    #include <android/hardware/nfc/1.0/IFoo.h>

    // in code:
    sp client = IFoo::getService();
    client->doThing();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant