From 73ffc278bb068d3c571db2d1bb7f3a1a14d5a075 Mon Sep 17 00:00:00 2001 From: renqing Date: Mon, 14 Aug 2023 11:14:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99uiExtensionContext=E6=B7=BB=E5=8A=A0co?= =?UTF-8?q?nnectServiceExtensionAbility=E5=92=8CdisconnectServiceExtension?= =?UTF-8?q?Ability=E6=8E=A5=E5=8F=A3=E6=96=87=E6=A1=A3=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: renqing Change-Id: If3864bf45eefb697da53aec6741959ae8b4e7beb --- ...is-inner-application-uiExtensionContext.md | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiExtensionContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiExtensionContext.md index f05ce2ccb1..ffa33ea792 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiExtensionContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiExtensionContext.md @@ -288,3 +288,97 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes | 16200001 | The caller has been released. | 错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + + +## UIExtensionContext.connectServiceExtensionAbility + +connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; + +将当前Ability连接到一个使用AbilityInfo.AbilityType.SERVICE模板的Ability。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-want.md) | 是 | 连接ServiceExtensionAbility的want信息。 | +| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | 是 | 与ServiceExtensionAbility建立连接后回调函数的实例。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 返回Ability连接的结果code。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + + + +## UIExtensionContext.disconnectServiceExtensionAbility + +disconnectServiceExtensionAbility(connection: number): Promise\; + +断开与ServiceExtensionAbility的连接,断开连接之后需要将连接成功时返回的remote对象置空(promise形式)。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| connection | number | 是 | 连接的ServiceExtensionAbility的数字代码,即connectServiceExtensionAbility返回的connectionId。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise\ | 返回执行结果。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + +## UIExtensionContext.disconnectServiceExtensionAbility + +disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\): void; + +断开与ServiceExtensionAbility的连接,断开连接之后需要将连接成功时返回的remote对象置空(callback形式)。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| connection | number | 是 | 连接的ServiceExtensionAbility的数字代码,即connectServiceExtensionAbility返回的connectionId。 | +| callback | AsyncCallback\ | 是 | callback形式返回断开连接的结果。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) -- GitLab