diff --git a/api/@ohos.ability.featureAbility.d.ts b/api/@ohos.ability.featureAbility.d.ts index e6a0b227b8fdac90f73ea2fd2494b7108bfd1fca..9a9170e063ce5aeffa4e30aa65db24d543c714c2 100644 --- a/api/@ohos.ability.featureAbility.d.ts +++ b/api/@ohos.ability.featureAbility.d.ts @@ -18,6 +18,8 @@ import { StartAbilityParameter } from './ability/startAbilityParameter'; import { AbilityResult } from './ability/abilityResult'; import { Context } from './app/context'; import { DataAbilityHelper } from './ability/dataAbilityHelper'; +import { ConnectOptions } from './ability/connectOptions'; + /** * A Feature Ability represents an ability with a UI and is designed to interact with users. * @name featureAbility @@ -117,6 +119,29 @@ declare namespace featureAbility { function hasWindowFocus(callback: AsyncCallback): void; function hasWindowFocus(): Promise; + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param request The element name of the service ability + * @param options The remote object instance + * @return Returns the number code of the ability connected + */ + function connectAbility(request: Want, options:ConnectOptions ): number; + + /** + * The callback interface was connect successfully. + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param connection The number code of the ability connected + */ + function disconnectAbility(connection: number, callback:AsyncCallback): void; + function disconnectAbility(connection: number): Promise; + export enum AbilityWindowConfiguration { WINDOW_MODE_UNDEFINED = 0, WINDOW_MODE_FULLSCREEN = 1, diff --git a/api/ability/connectOptions.d.ts b/api/ability/connectOptions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c718f678c3b1a8efde126c16d3378e9e0a91ebf8 --- /dev/null +++ b/api/ability/connectOptions.d.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ElementName } from '../bundle/elementName'; +import rpc from './../@ohos.rpc'; + +export interface ConnectOptions { + /** + * The callback interface was connect successfully. + * + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param elementName The element name of the service ability + * @param remoteObject The remote object instance + */ + onConnect: (elementName: ElementName, remoteObject: RemoteObject) => void; + + /** + * The callback interface was disconnect successfully. + * + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param elementName The element name of the service ability + */ + onDisconnect: (elementName: ElementName) => void; + + /** + * The callback interface was connect failed. + * + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param code The error code of the failed. + */ + onFailed: (code: number) => void; +}