From 282fdbadc2b308659ed1f0c82b937a46b2d47596 Mon Sep 17 00:00:00 2001 From: liujiahui Date: Sat, 20 Aug 2022 16:02:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=B3=BB=E7=BB=9F=E8=83=BD?= =?UTF-8?q?=E5=8A=9B=E9=85=8D=E7=BD=AE=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liujiahui --- .../device-dev/subsystems/subsys-build-all.md | 3 +- .../subsystems/subsys-build-syscap.md | 48 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 zh-cn/device-dev/subsystems/subsys-build-syscap.md diff --git a/zh-cn/device-dev/subsystems/subsys-build-all.md b/zh-cn/device-dev/subsystems/subsys-build-all.md index f298495244..c5b47d68a3 100644 --- a/zh-cn/device-dev/subsystems/subsys-build-all.md +++ b/zh-cn/device-dev/subsystems/subsys-build-all.md @@ -96,7 +96,7 @@ OpenHarmony编译子系统是以GN和Ninja构建为基座,对构建和配置 ## 配置规则 -为了实现芯片解决方案、产品解决方案与OpenHarmony是解耦的、可插拔的,子系统、产品、部件、芯片解决方案、模块和特性需遵循一定的规则,具体配置规则见如下链接: +为了实现芯片解决方案、产品解决方案与OpenHarmony是解耦的、可插拔的,子系统、产品、部件、芯片解决方案、模块、特性和系统能力需遵循一定的规则,具体配置规则见如下链接: - [产品配置规则](subsys-build-product.md#产品配置规则) - [子系统配置规则](subsys-build-subsystem.md#子系统配置规则) @@ -104,6 +104,7 @@ OpenHarmony编译子系统是以GN和Ninja构建为基座,对构建和配置 - [模块配置规则](subsys-build-module.md#模块配置规则) - [芯片解决方案配置规则](subsys-build-chip_solution.md#芯片解决方案配置规则) - [特性配置规则](subsys-build-feature.md#特性配置规则) +- [系统能力配置规则](subsys-build-syscap.md#如何按需配置部件的系统能力) ## 编译构建使用指导 diff --git a/zh-cn/device-dev/subsystems/subsys-build-syscap.md b/zh-cn/device-dev/subsystems/subsys-build-syscap.md new file mode 100644 index 0000000000..1e1cc9e41e --- /dev/null +++ b/zh-cn/device-dev/subsystems/subsys-build-syscap.md @@ -0,0 +1,48 @@ +# 如何按需配置部件的系统能力 +系统能力即SystemCapability,又称syscap,是部件向开发者提供的接口的集合。 +## 部件配置系统能力 +部件配置系统能力是为了方便某个特定部件是否要打开或关闭特定的系统能力。 + +部件配置系统能力的位置在部件目录下的bundle.json,配置示例如下所示: +```json + "component": { + "name": "wifi", + "subsystem": "communication", + "syscap": [ + "SystemCapability.Communication.WiFi.STA = true", + "SystemCapability.Communication.WiFi.AP = true", + "SystemCapability.Communication.WiFi.P2P = false", + "SystemCapability.Communication.WiFi.Core = false", + "SystemCapability.Communication.WiFi.HotspotExt" + ] + ], + ... + } + +``` +在component下加入syscap这一关键字,内部配置相应的系统能力,系统能力若无赋值,则默认为true,若有赋值,则按实际值为准。若值为true,则表示该部件默认开启此系统能力,若值为false,则表明该部件默认关闭此系统能力。 + +以上配置表明,WIFI的STA、AP、和HotspotExt三个系统能力是打开的,而P2P和Core是关闭的。 +## 产品配置系统能力 +产品配置系统能力是为了方便某个特定产品是否要打开或关闭特定的系统能力,若无配置,则以部件侧的配置为准,产品配置系统能力的位置在vender/{company}/{product}/config.json。 + +如果要对产品的系统能力进行精细化配置,可在产品配置中加入syscap关键字,并对要配置的系统能力赋值。产品侧的配置优先级大于部件系统能力默认配置,若某一个系统能力在部件侧默认配置为false,在产品侧配置为true,则这个系统能力的最终配置为true。示例如下: +```json +{ + "subsystem": "communication", + "components": [ + ... + { + "component": "wifi", + "features": [], + "syscap": [ + "SystemCapability.Communication.WiFi.AP = false", + "SystemCapability.Communication.WiFi.P2P = true", + "SystemCapability.Communication.WiFi.HotspotExt = false" + ] + }, + ... +``` +以上配置表明,WiFi的AP和HotspotExt系统能力是关闭的,而P2P是打开的。综合部件侧的配置,最终STA、P2P为打开系统能力,而AP、Core和HotspotExt为关闭的系统能力。 +## 部件侧配置和产品侧配置的作用 +一般来说,当产品没有特性化差异的时候,我们仅需在部件侧配置系统能力,部件侧配置的系统能力是我们的基础,只有当产品存在特性化差异,需要关闭某个默认打开的系统能力或打开某个系统默认关闭的系统能力时,我们才会需要在产品侧配置。 -- GitLab