From 45c7631ab4e1470f6c9563188a320969ca1f2d74 Mon Sep 17 00:00:00 2001 From: jiangwensai Date: Thu, 10 Feb 2022 20:20:37 +0800 Subject: [PATCH] IssueNo: #I4TF8K Description: add interface. Sig: SIG_ApplicationFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: jiangwensai --- api/@ohos.application.ServiceExtAbility.d.ts | 120 +++++++++++++++++ api/application/AbilityStateData.d.ts | 10 ++ api/application/ApplicationStateObserver.d.ts | 11 -- api/application/ExtAbilityContext.d.ts | 38 ++++++ api/application/ServiceExtAbilityContext.d.ts | 127 ++++++++++++++++++ 5 files changed, 295 insertions(+), 11 deletions(-) create mode 100644 api/@ohos.application.ServiceExtAbility.d.ts create mode 100644 api/application/ExtAbilityContext.d.ts create mode 100644 api/application/ServiceExtAbilityContext.d.ts diff --git a/api/@ohos.application.ServiceExtAbility.d.ts b/api/@ohos.application.ServiceExtAbility.d.ts new file mode 100644 index 0000000000..57a549082f --- /dev/null +++ b/api/@ohos.application.ServiceExtAbility.d.ts @@ -0,0 +1,120 @@ +/* + * 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 rpc from "./@ohos.rpc"; +import ServiceExtAbilityContext from "./application/ServiceExtAbilityContext"; +import Want from './@ohos.application.Want'; + +/** + * class of service extension ability. + * + * @since 9 + * @sysCap AAFwk + * @devices phone, tablet, tv, wearable, car + * @systemapi hide for inner use. + * @StageModelOnly + */ +export default class ServiceExtAbility { + /** + * Indicates service extension ability context. + * + * @since 9 + * @sysCap AAFwk + * @systemapi hide for inner use. + * @StageModelOnly + */ + context: ServiceExtAbilityContext; + + /** + * Called back when a service extension is started for initialization. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @systemapi hide for inner use. + * @return - + * @StageModelOnly + */ + onCreate(want: Want): void; + + /** + * Called back before a service extension is destroyed. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @systemapi hide for inner use. + * @return - + * @StageModelOnly + */ + onDestroy(): void; + + /** + * Called back when a service extension is started. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @param want Indicates the want of service extension to start. + * @param startId Indicates the number of times the service extension has been started. The {@code startId} is + * incremented by 1 every time the service extension is started. For example, if the service extension + * has been started for six times. + * @systemapi hide for inner use. + * @return - + * @StageModelOnly + */ + onRequest(want: Want, startId: number): void; + + /** + * Called back when a service extension is first connected to an ability. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @param want Indicates connection information about the Service ability. + * @systemapi hide for inner use. + * @return Returns the proxy of the Service ability. + * @StageModelOnly + */ + onConnect(want: Want): rpc.RemoteObject; + + /** + * Called back when all abilities connected to a service extension are disconnected. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @param want Indicates disconnection information about the service extension. + * @systemapi hide for inner use. + * @return - + * @StageModelOnly + */ + onDisconnect(want: Want): void; + + /** + * Called when a new client attempts to connect to a service extension after all previous client connections to it + * are disconnected. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @param want Indicates the want of the service extension being connected. + * @systemapi hide for inner use. + * @return - + * @StageModelOnly + */ + onReconnect(want: Want): void; +} + diff --git a/api/application/AbilityStateData.d.ts b/api/application/AbilityStateData.d.ts index e9ef7709b5..653d556b05 100644 --- a/api/application/AbilityStateData.d.ts +++ b/api/application/AbilityStateData.d.ts @@ -66,4 +66,14 @@ export default class AbilityStateData { * @systemapi hide for inner use. */ state: number; + + /** + * The ability type, page or service and so on. + * + * @devices phone, tablet, tv, wearable, car + * @since 8 + * @sysCap appexecfwk + * @systemapi hide for inner use. + */ + abilityType: number; } \ No newline at end of file diff --git a/api/application/ApplicationStateObserver.d.ts b/api/application/ApplicationStateObserver.d.ts index 3392bbf00b..5ce1e00ba5 100644 --- a/api/application/ApplicationStateObserver.d.ts +++ b/api/application/ApplicationStateObserver.d.ts @@ -48,17 +48,6 @@ export default class ApplicationStateObserver { */ onAbilityStateChanged(abilityStateData: AbilityStateData): void; - /** - * Will be called when extension state changed. - * - * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core - * @param abilityStateData State changed extension info. - * @systemapi hide for inner use. - * @return - - */ - onExtensionStateChanged(abilityStateData: AbilityStateData): void; - /** * Will be called when process created. * diff --git a/api/application/ExtAbilityContext.d.ts b/api/application/ExtAbilityContext.d.ts new file mode 100644 index 0000000000..c8cccfb6b2 --- /dev/null +++ b/api/application/ExtAbilityContext.d.ts @@ -0,0 +1,38 @@ +/* + * 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 { HapModuleInfo } from "../bundle/hapModuleInfo"; +import Context from "./Context"; + +/** + * The context of an extension. It allows access to extension-specific resources. + * + * @since 9 + * @sysCap AAFwk + * @devices phone, tablet, tv, wearable, car + * @permission N/A + * @StageModelOnly + */ +export default class ExtAbilityContext extends Context { + + /** + * Indicates configuration information about an module. + * + * @since 9 + * @sysCap AAFwk + * @StageModelOnly + */ + currentHapModuleInfo: HapModuleInfo; +} \ No newline at end of file diff --git a/api/application/ServiceExtAbilityContext.d.ts b/api/application/ServiceExtAbilityContext.d.ts new file mode 100644 index 0000000000..6ffe342387 --- /dev/null +++ b/api/application/ServiceExtAbilityContext.d.ts @@ -0,0 +1,127 @@ +/* + * 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 { AsyncCallback } from "../basic"; +import { ConnectOptions } from "../ability/connectOptions"; +import ExtAbilityContext from "./ExtAbilityContext"; +import Want from "../@ohos.application.Want"; +import StartOptions from "../@ohos.application.StartOptions"; + +/** + * The context of service extension. It allows access to + * serviceExtension-specific resources. + * + * @since 9 + * @sysCap AAFwk + * @devices phone, tablet, tv, wearable, car + * @systemapi hide for inner use. + * @permission N/A + * @StageModelOnly + */ +export default class ServiceExtAbilityContext extends ExtAbilityContext { + /** + * Service extension uses this method to start a specific ability. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @param parameter Indicates the ability to start. + * @systemapi hide for inner use. + * @return - + * @StageModelOnly + */ + startAbility(want: Want, callback: AsyncCallback): void; + startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; + startAbility(want: Want, options?: StartOptions): Promise; + + /** + * Service extension uses this method to start a specific ability with account. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @param parameter Indicates the ability to start. + * @param parameter Indicates the accountId to start. + * @systemapi hide for inner use. + * @return - + * @StageModelOnly + */ + startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; + + /** + * Destroys this service extension. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @systemapi hide for inner use. + * @return - + * @StageModelOnly + */ + terminateSelf(callback: AsyncCallback): void; + terminateSelf(): Promise; + + /** + * Connects an ability to a Service extension. + * + *

This method can be called by an ability or service extension, but the destination of the connection must be a + * service extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target + * service extension when the Service extension is connected.

+ * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @param request Indicates the service extension to connect. + * @systemapi hide for inner use. + * @return connection id, int value. + * @StageModelOnly + */ + connectAbility(want: Want, options: ConnectOptions): number; + + /** + * Connects an ability to a Service extension with account. + * + *

This method can be called by an ability or service extension, but the destination of the connection must be a + * service extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target + * service extension when the Service extension is connected.

+ * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @param request Indicates the service extension to connect. + * @param request Indicates the account to connect. + * @systemapi hide for inner use. + * @return connection id, int value. + * @StageModelOnly + */ + connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + + /** + * Disconnects an ability to a service extension, in contrast to + * {@link connectAbility}. + * + * @devices phone, tablet, tv, wearable, car + * @since 9 + * @sysCap AAFwk + * @param connection the connection id returned from connectAbility api. + * @systemapi hide for inner use. + * @return - + * @StageModelOnly + */ + disconnectAbility(connection: number, callback:AsyncCallback): void; + disconnectAbility(connection: number): Promise; +} \ No newline at end of file -- Gitee