161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"),
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit AbilityKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport AbilityConstant from './@ohos.app.ability.AbilityConstant';
2261847f8eSopenharmony_ciimport AbilityStageContext from './application/AbilityStageContext';
2361847f8eSopenharmony_ciimport Want from './@ohos.app.ability.Want';
2461847f8eSopenharmony_ciimport { Configuration } from './@ohos.app.ability.Configuration';
2561847f8eSopenharmony_ci
2661847f8eSopenharmony_ci/**
2761847f8eSopenharmony_ci * The class of an ability stage.
2861847f8eSopenharmony_ci *
2961847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core
3061847f8eSopenharmony_ci * @StageModelOnly
3161847f8eSopenharmony_ci * @since 9
3261847f8eSopenharmony_ci */
3361847f8eSopenharmony_ci/**
3461847f8eSopenharmony_ci * The class of an ability stage.
3561847f8eSopenharmony_ci *
3661847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core
3761847f8eSopenharmony_ci * @StageModelOnly
3861847f8eSopenharmony_ci * @crossplatform
3961847f8eSopenharmony_ci * @since 10
4061847f8eSopenharmony_ci */
4161847f8eSopenharmony_ci/**
4261847f8eSopenharmony_ci * The class of an ability stage.
4361847f8eSopenharmony_ci *
4461847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core
4561847f8eSopenharmony_ci * @StageModelOnly
4661847f8eSopenharmony_ci * @crossplatform
4761847f8eSopenharmony_ci * @atomicservice
4861847f8eSopenharmony_ci * @since 11
4961847f8eSopenharmony_ci */
5061847f8eSopenharmony_ciexport default class AbilityStage {
5161847f8eSopenharmony_ci  /**
5261847f8eSopenharmony_ci   * Indicates configuration information about context.
5361847f8eSopenharmony_ci   *
5461847f8eSopenharmony_ci   * @type { AbilityStageContext }
5561847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
5661847f8eSopenharmony_ci   * @StageModelOnly
5761847f8eSopenharmony_ci   * @since 9
5861847f8eSopenharmony_ci   */
5961847f8eSopenharmony_ci  /**
6061847f8eSopenharmony_ci   * Indicates configuration information about context.
6161847f8eSopenharmony_ci   *
6261847f8eSopenharmony_ci   * @type { AbilityStageContext }
6361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
6461847f8eSopenharmony_ci   * @StageModelOnly
6561847f8eSopenharmony_ci   * @crossplatform
6661847f8eSopenharmony_ci   * @since 10
6761847f8eSopenharmony_ci   */
6861847f8eSopenharmony_ci  /**
6961847f8eSopenharmony_ci   * Indicates configuration information about context.
7061847f8eSopenharmony_ci   *
7161847f8eSopenharmony_ci   * @type { AbilityStageContext }
7261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
7361847f8eSopenharmony_ci   * @StageModelOnly
7461847f8eSopenharmony_ci   * @crossplatform
7561847f8eSopenharmony_ci   * @atomicservice
7661847f8eSopenharmony_ci   * @since 11
7761847f8eSopenharmony_ci   */
7861847f8eSopenharmony_ci  context: AbilityStageContext;
7961847f8eSopenharmony_ci
8061847f8eSopenharmony_ci  /**
8161847f8eSopenharmony_ci   * Called back when an ability stage is started for initialization.
8261847f8eSopenharmony_ci   *
8361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
8461847f8eSopenharmony_ci   * @StageModelOnly
8561847f8eSopenharmony_ci   * @since 9
8661847f8eSopenharmony_ci   */
8761847f8eSopenharmony_ci  /**
8861847f8eSopenharmony_ci   * Called back when an ability stage is started for initialization.
8961847f8eSopenharmony_ci   *
9061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
9161847f8eSopenharmony_ci   * @StageModelOnly
9261847f8eSopenharmony_ci   * @crossplatform
9361847f8eSopenharmony_ci   * @since 10
9461847f8eSopenharmony_ci   */
9561847f8eSopenharmony_ci  /**
9661847f8eSopenharmony_ci   * Called back when an ability stage is started for initialization.
9761847f8eSopenharmony_ci   *
9861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
9961847f8eSopenharmony_ci   * @StageModelOnly
10061847f8eSopenharmony_ci   * @crossplatform
10161847f8eSopenharmony_ci   * @atomicservice
10261847f8eSopenharmony_ci   * @since 11
10361847f8eSopenharmony_ci   */
10461847f8eSopenharmony_ci  onCreate(): void;
10561847f8eSopenharmony_ci
10661847f8eSopenharmony_ci  /**
10761847f8eSopenharmony_ci   * Called back when start specified ability.
10861847f8eSopenharmony_ci   *
10961847f8eSopenharmony_ci   * @param { Want } want - Indicates the want info of started ability.
11061847f8eSopenharmony_ci   * @returns { string } The user returns an ability string ID. If the ability of this ID has been started before,
11161847f8eSopenharmony_ci   *         do not create a new instance and pull it back to the top of the stack.
11261847f8eSopenharmony_ci   *         Otherwise, create a new instance and start it.
11361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
11461847f8eSopenharmony_ci   * @StageModelOnly
11561847f8eSopenharmony_ci   * @since 9
11661847f8eSopenharmony_ci   */
11761847f8eSopenharmony_ci  /**
11861847f8eSopenharmony_ci   * Called back when start specified ability.
11961847f8eSopenharmony_ci   *
12061847f8eSopenharmony_ci   * @param { Want } want - Indicates the want info of started ability.
12161847f8eSopenharmony_ci   * @returns { string } The user returns an ability string ID. If the ability of this ID has been started before,
12261847f8eSopenharmony_ci   *         do not create a new instance and pull it back to the top of the stack.
12361847f8eSopenharmony_ci   *         Otherwise, create a new instance and start it.
12461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
12561847f8eSopenharmony_ci   * @StageModelOnly
12661847f8eSopenharmony_ci   * @atomicservice
12761847f8eSopenharmony_ci   * @since 11
12861847f8eSopenharmony_ci   */
12961847f8eSopenharmony_ci  onAcceptWant(want: Want): string;
13061847f8eSopenharmony_ci
13161847f8eSopenharmony_ci  /**
13261847f8eSopenharmony_ci   * Called back when start UIAbility in specified process.
13361847f8eSopenharmony_ci   *
13461847f8eSopenharmony_ci   * @param { Want } want - Indicates the want info of started ability.
13561847f8eSopenharmony_ci   * @returns { string } The user returns an process string ID. If the process of this ID has been created before,
13661847f8eSopenharmony_ci   *         let the ability run in this process. Otherwise, create a new process.
13761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
13861847f8eSopenharmony_ci   * @StageModelOnly
13961847f8eSopenharmony_ci   * @since 11
14061847f8eSopenharmony_ci   */
14161847f8eSopenharmony_ci  onNewProcessRequest(want: Want): string;
14261847f8eSopenharmony_ci
14361847f8eSopenharmony_ci  /**
14461847f8eSopenharmony_ci   * Called when the system configuration is updated.
14561847f8eSopenharmony_ci   *
14661847f8eSopenharmony_ci   * @param { Configuration } newConfig - Indicates the updated configuration.
14761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
14861847f8eSopenharmony_ci   * @StageModelOnly
14961847f8eSopenharmony_ci   * @since 9
15061847f8eSopenharmony_ci   */
15161847f8eSopenharmony_ci  /**
15261847f8eSopenharmony_ci   * Called when the system configuration is updated.
15361847f8eSopenharmony_ci   *
15461847f8eSopenharmony_ci   * @param { Configuration } newConfig - Indicates the updated configuration.
15561847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
15661847f8eSopenharmony_ci   * @StageModelOnly
15761847f8eSopenharmony_ci   * @crossplatform
15861847f8eSopenharmony_ci   * @since 10
15961847f8eSopenharmony_ci   */
16061847f8eSopenharmony_ci  /**
16161847f8eSopenharmony_ci   * Called when the system configuration is updated.
16261847f8eSopenharmony_ci   *
16361847f8eSopenharmony_ci   * @param { Configuration } newConfig - Indicates the updated configuration.
16461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
16561847f8eSopenharmony_ci   * @StageModelOnly
16661847f8eSopenharmony_ci   * @crossplatform
16761847f8eSopenharmony_ci   * @atomicservice
16861847f8eSopenharmony_ci   * @since 11
16961847f8eSopenharmony_ci   */
17061847f8eSopenharmony_ci  onConfigurationUpdate(newConfig: Configuration): void;
17161847f8eSopenharmony_ci
17261847f8eSopenharmony_ci  /**
17361847f8eSopenharmony_ci   * Called when the system has determined to trim the memory, for example, when the ability is running in the
17461847f8eSopenharmony_ci   * background and there is no enough memory for running as many background processes as possible.
17561847f8eSopenharmony_ci   *
17661847f8eSopenharmony_ci   * @param { AbilityConstant.MemoryLevel } level - Indicates the memory trim level, which shows the current memory usage status.
17761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
17861847f8eSopenharmony_ci   * @StageModelOnly
17961847f8eSopenharmony_ci   * @since 9
18061847f8eSopenharmony_ci   */
18161847f8eSopenharmony_ci  /**
18261847f8eSopenharmony_ci   * Called when the system has determined to trim the memory, for example, when the ability is running in the
18361847f8eSopenharmony_ci   * background and there is no enough memory for running as many background processes as possible.
18461847f8eSopenharmony_ci   *
18561847f8eSopenharmony_ci   * @param { AbilityConstant.MemoryLevel } level - Indicates the memory trim level, which shows the current memory usage status.
18661847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
18761847f8eSopenharmony_ci   * @StageModelOnly
18861847f8eSopenharmony_ci   * @atomicservice
18961847f8eSopenharmony_ci   * @since 11
19061847f8eSopenharmony_ci   */
19161847f8eSopenharmony_ci  onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
19261847f8eSopenharmony_ci
19361847f8eSopenharmony_ci  /**
19461847f8eSopenharmony_ci   * Called back when an ability stage is Destroyed.
19561847f8eSopenharmony_ci   * Will not call the onDestroy function when killing a process or crashing abnormally.
19661847f8eSopenharmony_ci   *
19761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
19861847f8eSopenharmony_ci   * @StageModelOnly
19961847f8eSopenharmony_ci   * @atomicservice
20061847f8eSopenharmony_ci   * @since 12
20161847f8eSopenharmony_ci   */
20261847f8eSopenharmony_ci  onDestroy(): void;
20361847f8eSopenharmony_ci}
204