CHRE:IContexthub的具体实现contexthub@1.0-impl.generic

IContexthub.hal 生成的是个abstract class: interface还没有具体的实现

public static abstract class Stub extends android.os.HwBinder implements IContexthub{}

system/chre/Android.bp
cc_library_shared {
    name: "android.hardware.contexthub@1.0-impl.generic",
    vendor: true,
    relative_install_path: "hw",
    srcs: [
        "host/hal_generic/generic_context_hub.cc",
    ],
    cflags: ["-Wall", "-Werror"],
    cpp_std: "c++17",
    shared_libs: [
        "libcutils",
        "liblog",
        "libhidlbase",
        "libhidltransport",
        "libutils",
        "android.hardware.contexthub@1.0",
    ],
    static_libs: ["chre_client"],
    tags: ["optional"],
}
cc_library_static {
    name: "chre_client",
    vendor: true,
    export_include_dirs: [
        "host/common/include",
        "platform/shared/include",
        "util/include",
    ],
    srcs: [
        "host/common/fragmented_load_transaction.cc",
        "host/common/host_protocol_host.cc",
        "host/common/socket_client.cc",
        "platform/shared/host_protocol_common.cc",
    ],
    header_libs: ["chre_flatbuffers"],
    export_header_lib_headers: ["chre_flatbuffers"],
    shared_libs: [
        "libcutils",
        "liblog",
        "libutils",
    ],
    cflags: ["-Wall", "-Werror"],
}

generic_context_hub.cc

Return<void> GenericContextHub::getHubs(getHubs_cb _hidl_cb) {
  std::vector<ContextHub> hubs;
  ALOGV("%s", __func__);  

  if (!mClient.isConnected()) {
    ALOGE("Couldn't connect to hub daemon");
  }

  {
    // We haven't cached the hub details yet, so send a request and block
    // waiting on a response
    std::unique_lock<std::mutex> lock(mHubInfoMutex);
    FlatBufferBuilder builder;
    HostProtocolHost::encodeHubInfoRequest(builder);

    ALOGD("Sending hub info request");
    if (!mClient.sendMessage(builder.GetBufferPointer(), builder.GetSize())) {
      ALOGE("Couldn't send hub info request");
    }
  }

  _hidl_cb(hubs);
  return Void();
}

这里的mClient是什么?和谁连接?

GenericContextHub实现了IContecthub 并且通过SocketClient (chre): mClient 和 chre通信。

IContexthub的具体实现

创建FlatBufferBuilder, 使用具体的协议如HubInfo对Buffer编码(encode), 最后通过socket: chre 发送数据.

IContexthubCallback

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值