1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"), 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import AbilityConstant from "./@ohos.app.ability.AbilityConstant"; 17import AbilityStageContext from "./application/AbilityStageContext"; 18import Want from './@ohos.app.ability.Want'; 19import { Configuration } from './@ohos.app.ability.Configuration'; 20 21/** 22 * The class of an ability stage. 23 * @syscap SystemCapability.Ability.AbilityRuntime.Core 24 * @StageModelOnly 25 * @since 9 26 */ 27export default class AbilityStage { 28 /** 29 * Indicates configuration information about context. 30 * @type { AbilityStageContext } 31 * @syscap SystemCapability.Ability.AbilityRuntime.Core 32 * @StageModelOnly 33 * @since 9 34 */ 35 context: AbilityStageContext; 36 37 /** 38 * Called back when an ability stage is started for initialization. 39 * @syscap SystemCapability.Ability.AbilityRuntime.Core 40 * @StageModelOnly 41 * @since 9 42 */ 43 onCreate(): void; 44 45 /** 46 * Called back when start specified ability. 47 * @param { Want } want - Indicates the want info of started ability. 48 * @returns { string } The user returns an ability string ID. If the ability of this ID has been started before, 49 * do not create a new instance and pull it back to the top of the stack. 50 * Otherwise, create a new instance and start it. 51 * @syscap SystemCapability.Ability.AbilityRuntime.Core 52 * @StageModelOnly 53 * @since 9 54 */ 55 onAcceptWant(want: Want): string; 56 57 /** 58 * Called when the system configuration is updated. 59 * @param { Configuration } newConfig - Indicates the updated configuration. 60 * @syscap SystemCapability.Ability.AbilityRuntime.Core 61 * @StageModelOnly 62 * @since 9 63 */ 64 onConfigurationUpdate(newConfig: Configuration): void; 65 66 /** 67 * Called when the system has determined to trim the memory, for example, when the ability is running in the 68 * background and there is no enough memory for running as many background processes as possible. 69 * @param { AbilityConstant.MemoryLevel } level - Indicates the memory trim level, which shows the current memory usage status. 70 * @syscap SystemCapability.Ability.AbilityRuntime.Core 71 * @StageModelOnly 72 * @since 9 73 */ 74 onMemoryLevel(level: AbilityConstant.MemoryLevel): void; 75} 76