跳转至

components capabilities

组件能力

组件通过能力(capability)获得访问更广泛系统的各个部分的权限。每个组件都可以声明其提供给系统的新能力,以及其运行所需的由其他组件(或框架)提供的能力。

如您所见,runner 是一个声明组件运行时所需能力的例子。其它常见能力类型的例子是访问文件系统资源的 directory 和与其它组件通信的 protocol

开发者在组件清单声明组件所需要的能力类型。以下是请求两个能力的组件清单示例:对 example-data 目录的读权限和以 FIDL 协议 fuchsia.example.Foo 描述的服务。

use: [
    {
        directory: "example-data",
        rights: [ "r*" ],
        path: "/example/data",
    },
    {
        protocol: "fuchsia.example.Foo",
    },
]

组件管理器依据能力声明将必需的目录句柄填入各个组件的命名空间。对于本例而言,组件将在其命名空间中接收到 /example/data/svc/fuchsia.example.Foo


最后更新: 2022 年 12 月 31 日(Saturday) 21:07 CST