IssueNo: #I5Y6PR

Description: 使用UIAbility
Sig: SIG_ApplicationFramework
Feature or Bugfix: Feature
Binary Source: No

Signed-off-by: yangzk <yangzhongkai@huawei.com>
Change-Id: I301000336a001c2b99c96b077654015c85933cb6
This commit is contained in:
yangzk 2022-10-28 10:39:13 +08:00
parent c56b2e0c1a
commit 122fe61878
11 changed files with 913 additions and 333 deletions

View File

@ -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<void> } 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<void>;
/**
* 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<rpc.MessageParcel> } 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<rpc.MessageParcel>;
/**
* 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<string> } params - Indicates the params from command.
* @returns { Array<string> } Return the dump info array.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @stagemodelonly
* @since 9
*/
onDump(params: Array<string>): Array<string>;
/**
* 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.

View File

@ -144,4 +144,4 @@ declare namespace AbilityConstant {
}
}
export default AbilityConstant
export default AbilityConstant;

View File

@ -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;
}

View File

@ -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;
}
export default class ExtensionAbility extends Ability {
}

292
api/@ohos.app.ability.UIAbility.d.ts vendored Executable file
View File

@ -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<void> } 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<void>;
/**
* 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<rpc.MessageParcel> } 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<rpc.MessageParcel>;
/**
* 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<string> } params - Indicates the params from command.
* @returns { Array<string> } Return the dump info array.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @stagemodelonly
* @since 9
*/
onDump(params: Array<string>): Array<string>;
}

View File

@ -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.

View File

@ -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 {
/**

View File

@ -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";

572
api/application/UIAbilityContext.d.ts vendored Executable file
View File

@ -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.
*/
/// <reference path="../../component/common_ts_ets_api.d.ts"/>
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<void> } 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>): void;
/**
* Starts a new ability.
* @param { Want } want - Indicates the ability to start.
* @param { StartOptions } options - Indicates the start options.
* @param { AsyncCallback<void> } 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>): void;
/**
* Starts a new ability.
* @param { Want } want - Indicates the ability to start.
* @param { StartOptions } options - Indicates the start options.
* @returns { Promise<void> } 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<void>;
/**
* Get the caller object of the startup capability
* @param { Want } want - Indicates the ability to start.
* @returns { Promise<Caller> } 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<Caller>;
/**
* 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<void> } 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>): 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<void> } 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>): 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<void> } 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<void>;
/**
* Starts an ability and returns the execution result when the ability is destroyed.
* @param { Want } want - Indicates the ability to start.
* @param { AsyncCallback<AbilityResult> } 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<AbilityResult>): 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<AbilityResult> } 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<AbilityResult>): 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<AbilityResult> } 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<AbilityResult>;
/**
* 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<AbilityResult> } 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<AbilityResult>): 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<AbilityResult> } 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>): 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<AbilityResult> } 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<AbilityResult>;
/**
* Starts a new service extension ability.
* @param { Want } want - Indicates the want info to start.
* @param { AsyncCallback<void> } 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>): void;
/**
* Starts a new service extension ability.
* @param { Want } want - Indicates the want info to start.
* @returns { Promise<void> } 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<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.
* @param { AsyncCallback<void> } 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>): 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<void> } 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<void>;
/**
* Stops a service within the same application.
* @param { Want } want - Indicates the want info to start.
* @param { AsyncCallback<void> } 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>): void;
/**
* Stops a service within the same application.
* @param { Want } want - Indicates the want info to start.
* @returns { Promise<void> } 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<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.
* @param { AsyncCallback<void> } 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>): 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<void> } 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<void>;
/**
* Destroys this Page ability.
* @param { AsyncCallback<void> } 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>): void;
/**
* Destroys this Page ability.
* @returns { Promise<void> } 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<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.
* @param { AsyncCallback<void> } 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>): 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<void> } 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<void>;
/**
* 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>): void;
disconnectAbility(connection: number): Promise<void>;
/**
* 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<void> } 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>): void;
/**
* The callback interface was connect successfully.
* @param { number } connection - The number code of the ability connected
* @returns { Promise<void> } 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<void>;
/**
* Set mission label of current ability.
* @param { string } label - The label of ability that showed in recent missions.
* @param { AsyncCallback<void> } 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>): void;
/**
* Set mission label of current ability.
* @param { string } label - The label of ability that showed in recent missions.
* @returns { Promise<void> } 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<void>;
/**
* Set mission icon of current ability.
* @param { image.PixelMap } icon - The icon of ability that showed in recent missions.
* @param { AsyncCallback<void> } 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>): void;
/**
* Set mission icon of current ability.
* @param { image.PixelMap } icon - The icon of ability that showed in recent missions.
* @returns { Promise<void> } 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<void>;
/**
* Requests certain permissions from the system.
* @param { Array<string> } permissions - Indicates the list of permissions to be requested. This parameter
* cannot be null or empty.
* @param { AsyncCallback<PermissionRequestResult> } 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<string>, requestCallback: AsyncCallback<PermissionRequestResult>): void;
/**
* Requests certain permissions from the system.
* @param { Array<string> } permissions - Indicates the list of permissions to be requested. This parameter
* cannot be null or empty.
* @returns { Promise<PermissionRequestResult> } 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<string>): Promise<PermissionRequestResult>;
/**
* 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;
}

View File

@ -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<Ability> } callback - The callback is used to return the Ability object.
* @param { AsyncCallback<UIAbility> } 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<Ability>): void;
waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback<UIAbility>): 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<Ability> } callback - The callback is used to return the Ability object.
* @param { AsyncCallback<UIAbility> } 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<Ability>): void;
waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback<UIAbility>): 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<Ability> } Returns the Ability object.
* @returns { Promise<UIAbility> } 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<Ability>;
waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise<UIAbility>;
/**
* 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<Ability> } callback - The callback is used to return the Ability object.
* @param { AsyncCallback<UIAbility> } 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<Ability>): void;
getCurrentTopAbility(callback: AsyncCallback<UIAbility>): void;
/**
* Obtain the ability that is currently being displayed.
* @returns { Promise<Ability> } Returns the Ability object.
* @returns { Promise<UIAbility> } Returns the Ability object.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @since 9
*/
getCurrentTopAbility(): Promise<Ability>
getCurrentTopAbility(): Promise<UIAbility>
/**
* 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<void> } 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>): void;
doAbilityForeground(ability: UIAbility, callback: AsyncCallback<void>): 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<void> } 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<void>;
doAbilityForeground(ability: UIAbility): Promise<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.
* @param { AsyncCallback<void> } 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>): void;
doAbilityBackground(ability: UIAbility, callback: AsyncCallback<void>): 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<void> } 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<void>;
doAbilityBackground(ability: UIAbility): Promise<void>;
/**
* Prints log information to the unit testing console.

View File

@ -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;