From 122fe618783796a4c8dea36408442be164670639 Mon Sep 17 00:00:00 2001 From: yangzk Date: Fri, 28 Oct 2022 10:39:13 +0800 Subject: [PATCH] =?UTF-8?q?IssueNo:=20#I5Y6PR=20Description:=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8UIAbility=20Sig:=20SIG=5FApplicationFramework=20Featur?= =?UTF-8?q?e=20or=20Bugfix:=20Feature=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangzk Change-Id: I301000336a001c2b99c96b077654015c85933cb6 --- api/@ohos.app.ability.Ability.d.ts | 267 -------- api/@ohos.app.ability.AbilityConstant.d.ts | 2 +- ....app.ability.AbilityLifecycleCallback.d.ts | 20 +- api/@ohos.app.ability.ExtensionAbility.d.ts | 25 +- api/@ohos.app.ability.UIAbility.d.ts | 292 +++++++++ api/@ohos.app.ability.common.d.ts | 4 +- api/application/AbilityContext.d.ts | 4 +- api/application/ServiceExtensionContext.d.ts | 2 +- api/application/UIAbilityContext.d.ts | 572 ++++++++++++++++++ api/application/abilityDelegator.d.ts | 42 +- api/application/abilityMonitor.d.ts | 16 +- 11 files changed, 913 insertions(+), 333 deletions(-) create mode 100755 api/@ohos.app.ability.UIAbility.d.ts create mode 100755 api/application/UIAbilityContext.d.ts diff --git a/api/@ohos.app.ability.Ability.d.ts b/api/@ohos.app.ability.Ability.d.ts index a3efd8a404..a29250be37 100644 --- a/api/@ohos.app.ability.Ability.d.ts +++ b/api/@ohos.app.ability.Ability.d.ts @@ -14,147 +14,8 @@ */ import AbilityConstant from "./@ohos.app.ability.AbilityConstant"; -import AbilityContext from "./application/AbilityContext"; -import rpc from './@ohos.rpc'; -import Want from './@ohos.app.ability.Want'; -import window from './@ohos.window'; import { Configuration } from './@ohos.app.ability.Configuration'; -/** - * The prototype of the listener function interface registered by the Caller. - * @typedef OnReleaseCallback - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ -export interface OnReleaseCallback { - (msg: string): void; -} - -/** - * The prototype of the message listener function interface registered by the Callee. - * @typedef CalleeCallback - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ -export interface CalleeCallback { - (indata: rpc.MessageParcel): rpc.Sequenceable; -} - -/** - * The interface of a Caller. - * @interface - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ -export interface Caller { - /** - * Notify the server of Sequenceable type data. - * @param { string } method - The notification event string listened to by the callee. - * @param { rpc.Sequenceable } data - Notification data to the callee. - * @returns { Promise } The promise returned by the function. - * @throws { BusinessError } 401 - If the input parameter is not valid parameter. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - call(method: string, data: rpc.Sequenceable): Promise; - - /** - * Notify the server of Sequenceable type data and return the notification result. - * @param { string } method - The notification event string listened to by the callee. - * @param { rpc.Sequenceable } data - Notification data to the callee. - * @returns { Promise } Returns the callee's notification result data. - * @throws { BusinessError } 401 - If the input parameter is not valid parameter. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - callWithResult(method: string, data: rpc.Sequenceable): Promise; - - /** - * Clear service records. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - release(): void; - - /** - * Register death listener notification callback. - * @param { OnReleaseCallback } callback - Register a callback function for listening for notifications. - * @throws { BusinessError } 401 - If the input parameter is not valid parameter. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onRelease(callback: OnReleaseCallback): void; - - /** - * Register death listener notification callback. - * @param { string } type - release. - * @param { OnReleaseCallback } callback - Register a callback function for listening for notifications. - * @throws { BusinessError } 401 - If the input parameter is not valid parameter. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - on(type: "release", callback: OnReleaseCallback): void; - - /** - * Unregister death listener notification callback. - * @param { string } type - release. - * @param { OnReleaseCallback } callback - Unregister a callback function for listening for notifications. - * @throws { BusinessError } 401 - If the input parameter is not valid parameter. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - off(type: "release", callback: OnReleaseCallback): void; - - /** - * Unregister all death listener notification callback. - * @param { string } type - release. - * @throws { BusinessError } 401 - If the input parameter is not valid parameter. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - off(type: "release"): void; -} - -/** - * The interface of a Callee. - * @interface - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ -export interface Callee { - /** - * Register data listener callback. - * @param { string } method - A string registered to listen for notification events. - * @param { CalleeCallback } callback - Register a callback function that listens for notification events. - * @throws { BusinessError } 401 - If the input parameter is not valid parameter. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - on(method: string, callback: CalleeCallback): void; - - /** - * Unregister data listener callback. - * @param { string } method - A string registered to listen for notification events. - * @throws { BusinessError } 401 - If the input parameter is not valid parameter. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - off(method: string): void; -} - /** * The class of an ability. * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore @@ -162,123 +23,6 @@ export interface Callee { * @since 9 */ export default class Ability { - /** - * Indicates configuration information about an ability context. - * @type { AbilityContext } - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - context: AbilityContext; - - /** - * Indicates ability launch want. - * @type { Want } - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - launchWant: Want; - - /** - * Indicates ability last request want. - * @type { Want } - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - lastRequestWant: Want; - - /** - * Call Service Stub Object. - * @type { Callee } - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - callee: Callee; - - /** - * Called back when an ability is started for initialization. - * @param { Want } want - Indicates the want info of the created ability. - * @param { AbilityConstant.LaunchParam } param - Indicates the launch param. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onCreate(want: Want, param: AbilityConstant.LaunchParam): void; - - /** - * Called back when an ability window stage is created. - * @param { window.WindowStage } windowStage - Indicates the created WindowStage. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onWindowStageCreate(windowStage: window.WindowStage): void; - - /** - * Called back when an ability window stage is destroyed. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onWindowStageDestroy(): void; - - /** - * Called back when an ability window stage is restored. - * @param { window.WindowStage } windowStage - window stage to restore - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onWindowStageRestore(windowStage: window.WindowStage): void; - - /** - * Called back before an ability is destroyed. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onDestroy(): void; - - /** - * Called back when the state of an ability changes to foreground. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onForeground(): void; - - /** - * Called back when the state of an ability changes to background. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onBackground(): void; - - /** - * Called back when an ability prepares to continue. - * @param { {[key: string]: any} } wantParam - Indicates the want parameter. - * @returns { AbilityConstant.OnContinueResult } Return the result of onContinue. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onContinue(wantParam: { [key: string]: any }): AbilityConstant.OnContinueResult; - - /** - * Called when the launch mode of an ability is set to singleton. - * This happens when you re-launch an ability that has been at the top of the ability stack. - * @param { Want } want - Indicates the want info of ability. - * @param { AbilityConstant.LaunchParam } launchParams - Indicates the launch parameters. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void; - /** * Called when the system configuration is updated. * @param { Configuration } newConfig - Indicates the updated configuration. @@ -288,17 +32,6 @@ export default class Ability { */ onConfigurationUpdate(newConfig: Configuration): void; - /** - * Called when dump client information is required. - * It is recommended that developers don't DUMP sensitive information. - * @param { Array } params - Indicates the params from command. - * @returns { Array } Return the dump info array. - * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @stagemodelonly - * @since 9 - */ - onDump(params: Array): Array; - /** * Called when the system has determined to trim the memory, for example, when the ability is running in the * background and there is no enough memory for running as many background processes as possible. diff --git a/api/@ohos.app.ability.AbilityConstant.d.ts b/api/@ohos.app.ability.AbilityConstant.d.ts index b02c97e86e..3709949ca5 100644 --- a/api/@ohos.app.ability.AbilityConstant.d.ts +++ b/api/@ohos.app.ability.AbilityConstant.d.ts @@ -144,4 +144,4 @@ declare namespace AbilityConstant { } } -export default AbilityConstant +export default AbilityConstant; diff --git a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts index a94e3e71d4..7f62e30fea 100644 --- a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts +++ b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import Ability from "./@ohos.app.ability.Ability"; +import UIAbility from "./@ohos.app.ability.UIAbility"; import dataAbility from "./@ohos.data.dataAbility"; import window from './@ohos.window'; @@ -31,7 +31,7 @@ export default class AbilityLifecycleCallback { * @stagemodelonly * @since 9 */ - onAbilityCreate(ability: Ability): void; + onAbilityCreate(ability: UIAbility): void; /** * Called back when a window stage is created. @@ -41,7 +41,7 @@ export default class AbilityLifecycleCallback { * @stagemodelonly * @since 9 */ - onWindowStageCreate(ability: Ability, windowStage: window.WindowStage): void; + onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void; /** * Called back when a window stage is actived. @@ -51,7 +51,7 @@ export default class AbilityLifecycleCallback { * @stagemodelonly * @since 9 */ - onWindowStageActive(ability: Ability, windowStage: window.WindowStage): void; + onWindowStageActive(ability: UIAbility, windowStage: window.WindowStage): void; /** * Called back when a window stage is inactived. @@ -61,7 +61,7 @@ export default class AbilityLifecycleCallback { * @stagemodelonly * @since 9 */ - onWindowStageInactive(ability: Ability, windowStage: window.WindowStage): void; + onWindowStageInactive(ability: UIAbility, windowStage: window.WindowStage): void; /** * Called back when a window stage is destroyed. @@ -71,7 +71,7 @@ export default class AbilityLifecycleCallback { * @stagemodelonly * @since 9 */ - onWindowStageDestroy(ability: Ability, windowStage: window.WindowStage): void; + onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void; /** * Called back when an ability is destroyed. @@ -80,7 +80,7 @@ export default class AbilityLifecycleCallback { * @stagemodelonly * @since 9 */ - onAbilityDestroy(ability: Ability): void; + onAbilityDestroy(ability: UIAbility): void; /** * Called back when the state of an ability changes to foreground. @@ -89,7 +89,7 @@ export default class AbilityLifecycleCallback { * @stagemodelonly * @since 9 */ - onAbilityForeground(ability: Ability): void; + onAbilityForeground(ability: UIAbility): void; /** * Called back when the state of an ability changes to background. @@ -98,7 +98,7 @@ export default class AbilityLifecycleCallback { * @stagemodelonly * @since 9 */ - onAbilityBackground(ability: Ability): void; + onAbilityBackground(ability: UIAbility): void; /** * Called back when an ability prepares to continue. @@ -107,5 +107,5 @@ export default class AbilityLifecycleCallback { * @stagemodelonly * @since 9 */ - onAbilityContinue(ability: Ability): void; + onAbilityContinue(ability: UIAbility): void; } \ No newline at end of file diff --git a/api/@ohos.app.ability.ExtensionAbility.d.ts b/api/@ohos.app.ability.ExtensionAbility.d.ts index 6f27489e3f..a64ecb161e 100644 --- a/api/@ohos.app.ability.ExtensionAbility.d.ts +++ b/api/@ohos.app.ability.ExtensionAbility.d.ts @@ -13,8 +13,7 @@ * limitations under the License. */ -import AbilityConstant from "./@ohos.app.ability.AbilityConstant"; -import { Configuration } from './@ohos.app.ability.Configuration'; +import Ability from "./@ohos.app.ability.Ability"; /** * class of extension. @@ -22,23 +21,5 @@ import { Configuration } from './@ohos.app.ability.Configuration'; * @stagemodelonly * @since 9 */ -export default class ExtensionAbility { - /** - * Called when the system configuration is updated. - * @param { Configuration } newConfig - Indicates the updated configuration. - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @stagemodelonly - * @since 9 - */ - onConfigurationUpdate(newConfig: Configuration): void; - - /** - * Called when the system has determined to trim the memory, for example, when the ability is running in the - * background and there is no enough memory for running as many background processes as possible. - * @param { AbilityConstant.MemoryLevel } level - Indicates the memory trim level, which shows the current memory usage status. - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @stagemodelonly - * @since 9 - */ - onMemoryLevel(level: AbilityConstant.MemoryLevel): void; -} \ No newline at end of file +export default class ExtensionAbility extends Ability { +} diff --git a/api/@ohos.app.ability.UIAbility.d.ts b/api/@ohos.app.ability.UIAbility.d.ts new file mode 100755 index 0000000000..2f1612dc5c --- /dev/null +++ b/api/@ohos.app.ability.UIAbility.d.ts @@ -0,0 +1,292 @@ +/* + * Copyright (c) 2022 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 Ability from "./@ohos.app.ability.Ability"; +import AbilityConstant from "./@ohos.app.ability.AbilityConstant"; +import UIAbilityContext from "./application/UIAbilityContext"; +import rpc from './@ohos.rpc'; +import Want from './@ohos.app.ability.Want'; +import window from './@ohos.window'; + +/** + * The prototype of the listener function interface registered by the Caller. + * @typedef OnReleaseCallback + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export interface OnReleaseCallback { + (msg: string): void; +} + +/** + * The prototype of the message listener function interface registered by the Callee. + * @typedef CalleeCallback + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export interface CalleeCallback { + (indata: rpc.MessageParcel): rpc.Sequenceable; +} + +/** + * The interface of a Caller. + * @interface + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export interface Caller { + /** + * Notify the server of Sequenceable type data. + * @param { string } method - The notification event string listened to by the callee. + * @param { rpc.Sequenceable } data - Notification data to the callee. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + call(method: string, data: rpc.Sequenceable): Promise; + + /** + * Notify the server of Sequenceable type data and return the notification result. + * @param { string } method - The notification event string listened to by the callee. + * @param { rpc.Sequenceable } data - Notification data to the callee. + * @returns { Promise } Returns the callee's notification result data. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + callWithResult(method: string, data: rpc.Sequenceable): Promise; + + /** + * Clear service records. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + release(): void; + + /** + * Register death listener notification callback. + * @param { OnReleaseCallback } callback - Register a callback function for listening for notifications. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onRelease(callback: OnReleaseCallback): void; + + /** + * Register death listener notification callback. + * @param { string } type - release. + * @param { OnReleaseCallback } callback - Register a callback function for listening for notifications. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + on(type: "release", callback: OnReleaseCallback): void; + + /** + * Unregister death listener notification callback. + * @param { string } type - release. + * @param { OnReleaseCallback } callback - Unregister a callback function for listening for notifications. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + off(type: "release", callback: OnReleaseCallback): void; + + /** + * Unregister all death listener notification callback. + * @param { string } type - release. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + off(type: "release"): void; +} + +/** + * The interface of a Callee. + * @interface + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export interface Callee { + /** + * Register data listener callback. + * @param { string } method - A string registered to listen for notification events. + * @param { CalleeCallback } callback - Register a callback function that listens for notification events. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + on(method: string, callback: CalleeCallback): void; + + /** + * Unregister data listener callback. + * @param { string } method - A string registered to listen for notification events. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + off(method: string): void; +} + +/** + * The class of a UI ability. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export default class UIAbility extends Ability { + /** + * Indicates configuration information about an ability context. + * @type { UIAbilityContext } + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + context: UIAbilityContext; + + /** + * Indicates ability launch want. + * @type { Want } + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + launchWant: Want; + + /** + * Indicates ability last request want. + * @type { Want } + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + lastRequestWant: Want; + + /** + * Call Service Stub Object. + * @type { Callee } + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + callee: Callee; + + /** + * Called back when an ability is started for initialization. + * @param { Want } want - Indicates the want info of the created ability. + * @param { AbilityConstant.LaunchParam } param - Indicates the launch param. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onCreate(want: Want, param: AbilityConstant.LaunchParam): void; + + /** + * Called back when an ability window stage is created. + * @param { window.WindowStage } windowStage - Indicates the created WindowStage. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onWindowStageCreate(windowStage: window.WindowStage): void; + + /** + * Called back when an ability window stage is destroyed. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onWindowStageDestroy(): void; + + /** + * Called back when an ability window stage is restored. + * @param { window.WindowStage } windowStage - window stage to restore + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onWindowStageRestore(windowStage: window.WindowStage): void; + + /** + * Called back before an ability is destroyed. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onDestroy(): void; + + /** + * Called back when the state of an ability changes to foreground. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onForeground(): void; + + /** + * Called back when the state of an ability changes to background. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onBackground(): void; + + /** + * Called back when an ability prepares to continue. + * @param { {[key: string]: any} } wantParam - Indicates the want parameter. + * @returns { AbilityConstant.OnContinueResult } Return the result of onContinue. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onContinue(wantParam: { [key: string]: any }): AbilityConstant.OnContinueResult; + + /** + * Called when the launch mode of an ability is set to singleton. + * This happens when you re-launch an ability that has been at the top of the ability stack. + * @param { Want } want - Indicates the want info of ability. + * @param { AbilityConstant.LaunchParam } launchParams - Indicates the launch parameters. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void; + + /** + * Called when dump client information is required. + * It is recommended that developers don't DUMP sensitive information. + * @param { Array } params - Indicates the params from command. + * @returns { Array } Return the dump info array. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onDump(params: Array): Array; +} diff --git a/api/@ohos.app.ability.common.d.ts b/api/@ohos.app.ability.common.d.ts index 1716916ce8..cd0a1046cb 100755 --- a/api/@ohos.app.ability.common.d.ts +++ b/api/@ohos.app.ability.common.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import * as _AbilityContext from './application/AbilityContext'; +import * as _UIAbilityContext from './application/UIAbilityContext'; import * as _AbilityStageContext from './application/AbilityStageContext'; import * as _ApplicationContext from './application/ApplicationContext'; import * as _BaseContext from './application/BaseContext'; @@ -40,7 +40,7 @@ declare namespace common { * @stagemodelonly * @since 9 */ - export type AbilityContext = _AbilityContext.default + export type UIAbilityContext = _UIAbilityContext.default /** * The context of an abilityStage. It allows access to abilityStage-specific resources. diff --git a/api/application/AbilityContext.d.ts b/api/application/AbilityContext.d.ts index a0a0452916..ac3b1f1f12 100755 --- a/api/application/AbilityContext.d.ts +++ b/api/application/AbilityContext.d.ts @@ -25,7 +25,7 @@ import Want from "../@ohos.application.Want"; import StartOptions from "../@ohos.app.ability.StartOptions"; import PermissionRequestResult from "./PermissionRequestResult"; import { Configuration } from '../@ohos.app.ability.Configuration'; -import { Caller } from '../@ohos.app.ability.Ability'; +import { Caller } from '../@ohos.app.ability.UIAbility'; import { LocalStorage } from 'StateManagement'; import image from '../@ohos.multimedia.image'; @@ -34,6 +34,8 @@ import image from '../@ohos.multimedia.image'; * @syscap SystemCapability.Ability.AbilityRuntime.Core * @stagemodelonly * @since 9 + * @deprecated since 9 + * @useinstead UIAbilityContext */ export default class AbilityContext extends Context { /** diff --git a/api/application/ServiceExtensionContext.d.ts b/api/application/ServiceExtensionContext.d.ts index e6326f414e..acc02d4176 100644 --- a/api/application/ServiceExtensionContext.d.ts +++ b/api/application/ServiceExtensionContext.d.ts @@ -15,7 +15,7 @@ import { AsyncCallback } from "../basic"; import { ConnectOptions } from "../ability/connectOptions"; -import { Caller } from '../@ohos.app.ability.Ability'; +import { Caller } from '../@ohos.app.ability.UIAbility'; import ExtensionContext from "./ExtensionContext"; import Want from "../@ohos.application.Want"; import StartOptions from "../@ohos.app.ability.StartOptions"; diff --git a/api/application/UIAbilityContext.d.ts b/api/application/UIAbilityContext.d.ts new file mode 100755 index 0000000000..1f49caaba1 --- /dev/null +++ b/api/application/UIAbilityContext.d.ts @@ -0,0 +1,572 @@ +/* + * Copyright (c) 2021-2022 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 { AbilityInfo } from "../bundle/abilityInfo"; +import { AbilityResult } from "../ability/abilityResult"; +import { AsyncCallback } from "../basic"; +import { ConnectOptions } from "../ability/connectOptions"; +import { HapModuleInfo } from "../bundle/hapModuleInfo"; +import Context from "./Context"; +import Want from "../@ohos.application.Want"; +import StartOptions from "../@ohos.app.ability.StartOptions"; +import PermissionRequestResult from "./PermissionRequestResult"; +import { Configuration } from '../@ohos.app.ability.Configuration'; +import { Caller } from '../@ohos.app.ability.UIAbility'; +import { LocalStorage } from 'StateManagement'; +import image from '../@ohos.multimedia.image'; + +/** + * The context of an ability. It allows access to ability-specific resources. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ +export default class UIAbilityContext extends Context { + /** + * Indicates configuration information about an ability. + * @type { AbilityInfo } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + abilityInfo: AbilityInfo; + + /** + * Indicates configuration information about the module. + * @type { HapModuleInfo } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + currentHapModuleInfo: HapModuleInfo; + + /** + * Indicates configuration information. + * @type { Configuration } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + config: Configuration; + + /** + * Starts a new ability. + * @param want { Want } - Indicates the ability to start. + * @param { AsyncCallback } callback - The callback of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbility(want: Want, callback: AsyncCallback): void; + + /** + * Starts a new ability. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts a new ability. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbility(want: Want, options?: StartOptions): Promise; + + /** + * Get the caller object of the startup capability + * @param { Want } want - Indicates the ability to start. + * @returns { Promise } Returns the Caller interface. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityByCall(want: Want): Promise; + + /** + * Starts a new ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { AsyncCallback } callback - The callback of startAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Starts a new ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback of startAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts a new ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; + + /** + * Starts an ability and returns the execution result when the ability is destroyed. + * @param { Want } want - Indicates the ability to start. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbilityForResult(want: Want, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } Returns the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbilityForResult(want: Want, options?: StartOptions): Promise; + + /** + * Starts an ability and returns the execution result when the ability is destroyed with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } Returns the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; + + /** + * Starts a new service extension ability. + * @param { Want } want - Indicates the want info to start. + * @param { AsyncCallback } callback - The callback of startServiceExtensionAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startServiceExtensionAbility(want: Want, callback: AsyncCallback): void; + + /** + * Starts a new service extension ability. + * @param { Want } want - Indicates the want info to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startServiceExtensionAbility(want: Want): Promise; + + /** + * Starts a new service extension ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { AsyncCallback } callback - The callback of startServiceExtensionAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Starts a new service extension ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; + + /** + * Stops a service within the same application. + * @param { Want } want - Indicates the want info to start. + * @param { AsyncCallback } callback - The callback of stopServiceExtensionAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + stopServiceExtensionAbility(want: Want, callback: AsyncCallback): void; + + /** + * Stops a service within the same application. + * @param { Want } want - Indicates the want info to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + stopServiceExtensionAbility(want: Want): Promise; + + /** + * Stops a service within the same application with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the accountId to start. + * @param { AsyncCallback } callback - The callback of stopServiceExtensionAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Stops a service within the same application with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the accountId to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; + + /** + * Destroys this Page ability. + * @param { AsyncCallback } callback - The callback of terminateSelf. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + terminateSelf(callback: AsyncCallback): void; + + /** + * Destroys this Page ability. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + terminateSelf(): Promise; + + /** + * Sets the result code and data to be returned by this Page ability to the caller + * and destroys this Page ability. + * @param { AbilityResult } parameter - Indicates the result to return. + * @param { AsyncCallback } callback - The callback of terminateSelfWithResult. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback): void; + + /** + * Sets the result code and data to be returned by this Page ability to the caller + * and destroys this Page ability. + * @param { AbilityResult } parameter - Indicates the result to return. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + terminateSelfWithResult(parameter: AbilityResult): Promise; + + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want The element name of the service ability + * @param options The remote object instance + * @systemapi Hide this for inner system use. + * @return Returns the number code of the ability connected + * @StageModelOnly + * @deprecated since 9 + * @useinstead connectServiceExtensionAbility + */ + connectAbility(want: Want, options: ConnectOptions): number; + + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template with account. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want The element name of the service ability + * @param accountId The account to connect + * @param options The remote object instance + * @systemapi hide for inner use. + * @return Returns the number code of the ability connected + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @StageModelOnly + * @deprecated since 9 + * @useinstead connectServiceExtensionAbilityWithAccount + */ + connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + + /** + * The callback interface was connect successfully. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param connection The number code of the ability connected + * @systemapi Hide this for inner system use. + * @StageModelOnly + * @deprecated since 9 + * @useinstead disconnectServiceExtensionAbility + */ + disconnectAbility(connection: number, callback:AsyncCallback): void; + disconnectAbility(connection: number): Promise; + + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. + * @param { Want } want - The element name of the service ability + * @param { ConnectOptions } options - The remote object instance + * @returns { number } Returns the number code of the ability connected + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; + + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - The element name of the service ability + * @param { number } accountId - The account to connect + * @param { ConnectOptions } options - The remote object instance + * @returns { number } Returns the number code of the ability connected + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + + /** + * The callback interface was connect successfully. + * @param { number } connection - The number code of the ability connected + * @param { AsyncCallback } callback - The callback of disconnectAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + disconnectServiceExtensionAbility(connection: number, callback: AsyncCallback): void; + + /** + * The callback interface was connect successfully. + * @param { number } connection - The number code of the ability connected + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + disconnectServiceExtensionAbility(connection: number): Promise; + + /** + * Set mission label of current ability. + * @param { string } label - The label of ability that showed in recent missions. + * @param { AsyncCallback } callback - The callback of setMissionLabel. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + setMissionLabel(label: string, callback: AsyncCallback): void; + + /** + * Set mission label of current ability. + * @param { string } label - The label of ability that showed in recent missions. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + setMissionLabel(label: string): Promise; + + /** + * Set mission icon of current ability. + * @param { image.PixelMap } icon - The icon of ability that showed in recent missions. + * @param { AsyncCallback } callback - The callback of setMissionIcon. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + setMissionIcon(icon: image.PixelMap, callback: AsyncCallback): void; + + /** + * Set mission icon of current ability. + * @param { image.PixelMap } icon - The icon of ability that showed in recent missions. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + setMissionIcon(icon: image.PixelMap): Promise; + + /** + * Requests certain permissions from the system. + * @param { Array } permissions - Indicates the list of permissions to be requested. This parameter + * cannot be null or empty. + * @param { AsyncCallback } requestCallback - The callback is used to return the permission + * request result. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + requestPermissionsFromUser(permissions: Array, requestCallback: AsyncCallback): void; + + /** + * Requests certain permissions from the system. + * @param { Array } permissions - Indicates the list of permissions to be requested. This parameter + * cannot be null or empty. + * @returns { Promise } Returns the permission request result. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + requestPermissionsFromUser(permissions: Array): Promise; + + /** + * Restore window stage data in ability continuation + * @param { LocalStorage } localStorage - the storage data used to restore window stage + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + restoreWindowStage(localStorage: LocalStorage): void; + + /** + * check to see ability is in terminating state. + * @returns { boolean } Returns true when ability is in terminating state, else returns false. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + isTerminating(): boolean; +} diff --git a/api/application/abilityDelegator.d.ts b/api/application/abilityDelegator.d.ts index 72ac4c9d98..e6b90885dd 100644 --- a/api/application/abilityDelegator.d.ts +++ b/api/application/abilityDelegator.d.ts @@ -14,7 +14,7 @@ */ import { AsyncCallback } from '../basic'; -import Ability from '../@ohos.app.ability.Ability'; +import UIAbility from '../@ohos.app.ability.UIAbility'; import AbilityStage from '../@ohos.app.ability.AbilityStage'; import { AbilityMonitor } from './abilityMonitor'; import { AbilityStageMonitor } from './abilityStageMonitor'; @@ -112,34 +112,34 @@ export interface AbilityDelegator { /** * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. * @param { AbilityMonitor } monitor - AbilityMonitor object. - * @param { AsyncCallback } callback - The callback is used to return the Ability object. + * @param { AsyncCallback } callback - The callback is used to return the Ability object. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 */ - waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; + waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; /** * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. * @param { AbilityMonitor } monitor - AbilityMonitor object. * @param { number } timeout - Maximum wait time, in milliseconds. - * @param { AsyncCallback } callback - The callback is used to return the Ability object. + * @param { AsyncCallback } callback - The callback is used to return the Ability object. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 */ - waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback): void; + waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback): void; /** * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. * @param { AbilityMonitor } monitor - AbilityMonitor object. * @param { number } timeout - Maximum wait time, in milliseconds. - * @returns { Promise } Returns the Ability object. + * @returns { Promise } Returns the Ability object. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 */ - waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise; + waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise; /** * Wait for and returns the AbilityStage object that matches the conditions set in the given AbilityStageMonitor. @@ -183,30 +183,30 @@ export interface AbilityDelegator { /** * Obtain the lifecycle state of a specified ability. - * @param { Ability } ability - The Ability object. + * @param { UIAbility } ability - The Ability object. * @returns { number } Returns the state of the Ability object. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 */ - getAbilityState(ability: Ability): number; + getAbilityState(ability: UIAbility): number; /** * Obtain the ability that is currently being displayed. - * @param { AsyncCallback } callback - The callback is used to return the Ability object. + * @param { AsyncCallback } callback - The callback is used to return the Ability object. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 */ - getCurrentTopAbility(callback: AsyncCallback): void; + getCurrentTopAbility(callback: AsyncCallback): void; /** * Obtain the ability that is currently being displayed. - * @returns { Promise } Returns the Ability object. + * @returns { Promise } Returns the Ability object. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 */ - getCurrentTopAbility(): Promise + getCurrentTopAbility(): Promise /** * Start a new ability. @@ -230,43 +230,43 @@ export interface AbilityDelegator { /** * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. - * @param { Ability } ability - The ability object. + * @param { UIAbility } ability - The ability object. * @param { AsyncCallback } callback - The callback of doAbilityForeground. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 */ - doAbilityForeground(ability: Ability, callback: AsyncCallback): void; + doAbilityForeground(ability: UIAbility, callback: AsyncCallback): void; /** * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. - * @param { Ability } ability - The ability object. + * @param { UIAbility } ability - The ability object. * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 */ - doAbilityForeground(ability: Ability): Promise; + doAbilityForeground(ability: UIAbility): Promise; /** * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. - * @param { Ability } ability - The ability object. + * @param { UIAbility } ability - The ability object. * @param { AsyncCallback } callback - The callback of doAbilityBackground. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 */ - doAbilityBackground(ability: Ability, callback: AsyncCallback): void; + doAbilityBackground(ability: UIAbility, callback: AsyncCallback): void; /** * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. - * @param { Ability } ability - The ability object. + * @param { UIAbility } ability - The ability object. * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 */ - doAbilityBackground(ability: Ability): Promise; + doAbilityBackground(ability: UIAbility): Promise; /** * Prints log information to the unit testing console. diff --git a/api/application/abilityMonitor.d.ts b/api/application/abilityMonitor.d.ts index dd0a1989f1..0e37ca308d 100644 --- a/api/application/abilityMonitor.d.ts +++ b/api/application/abilityMonitor.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import Ability from '../@ohos.app.ability.Ability'; +import UIAbility from '../@ohos.app.ability.UIAbility'; /** * Provide methods for matching monitored Ability objects that meet specified conditions. @@ -47,7 +47,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onAbilityCreate?:(ability: Ability) => void; + onAbilityCreate?:(ability: UIAbility) => void; /** * Called back when the state of the ability changes to foreground. @@ -55,7 +55,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onAbilityForeground?:(ability: Ability) => void; + onAbilityForeground?:(ability: UIAbility) => void; /** * Called back when the state of the ability changes to background. @@ -63,7 +63,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onAbilityBackground?:(ability: Ability) => void; + onAbilityBackground?:(ability: UIAbility) => void; /** * Called back before the ability is destroyed. @@ -71,7 +71,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onAbilityDestroy?:(ability: Ability) => void; + onAbilityDestroy?:(ability: UIAbility) => void; /** * Called back when an ability window stage is created. @@ -79,7 +79,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onWindowStageCreate?:(ability: Ability) => void; + onWindowStageCreate?:(ability: UIAbility) => void; /** * Called back when an ability window stage is restored. @@ -87,7 +87,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onWindowStageRestore?:(ability: Ability) => void; + onWindowStageRestore?:(ability: UIAbility) => void; /** * Called back when an ability window stage is destroyed. @@ -95,7 +95,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onWindowStageDestroy?:(ability: Ability) => void; + onWindowStageDestroy?:(ability: UIAbility) => void; } export default AbilityMonitor; \ No newline at end of file