1/* 2 * Copyright (c) 2022-2023 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 16/** 17 * @file 18 * @kit AbilityKit 19 */ 20 21import AbilityConstant from './@ohos.app.ability.AbilityConstant'; 22import AbilityStageContext from './application/AbilityStageContext'; 23import Want from './@ohos.app.ability.Want'; 24import { Configuration } from './@ohos.app.ability.Configuration'; 25 26/** 27 * The class of an ability stage. 28 * 29 * @syscap SystemCapability.Ability.AbilityRuntime.Core 30 * @StageModelOnly 31 * @since 9 32 */ 33/** 34 * The class of an ability stage. 35 * 36 * @syscap SystemCapability.Ability.AbilityRuntime.Core 37 * @StageModelOnly 38 * @crossplatform 39 * @since 10 40 */ 41/** 42 * The class of an ability stage. 43 * 44 * @syscap SystemCapability.Ability.AbilityRuntime.Core 45 * @StageModelOnly 46 * @crossplatform 47 * @atomicservice 48 * @since 11 49 */ 50export default class AbilityStage { 51 /** 52 * Indicates configuration information about context. 53 * 54 * @type { AbilityStageContext } 55 * @syscap SystemCapability.Ability.AbilityRuntime.Core 56 * @StageModelOnly 57 * @since 9 58 */ 59 /** 60 * Indicates configuration information about context. 61 * 62 * @type { AbilityStageContext } 63 * @syscap SystemCapability.Ability.AbilityRuntime.Core 64 * @StageModelOnly 65 * @crossplatform 66 * @since 10 67 */ 68 /** 69 * Indicates configuration information about context. 70 * 71 * @type { AbilityStageContext } 72 * @syscap SystemCapability.Ability.AbilityRuntime.Core 73 * @StageModelOnly 74 * @crossplatform 75 * @atomicservice 76 * @since 11 77 */ 78 context: AbilityStageContext; 79 80 /** 81 * Called back when an ability stage is started for initialization. 82 * 83 * @syscap SystemCapability.Ability.AbilityRuntime.Core 84 * @StageModelOnly 85 * @since 9 86 */ 87 /** 88 * Called back when an ability stage is started for initialization. 89 * 90 * @syscap SystemCapability.Ability.AbilityRuntime.Core 91 * @StageModelOnly 92 * @crossplatform 93 * @since 10 94 */ 95 /** 96 * Called back when an ability stage is started for initialization. 97 * 98 * @syscap SystemCapability.Ability.AbilityRuntime.Core 99 * @StageModelOnly 100 * @crossplatform 101 * @atomicservice 102 * @since 11 103 */ 104 onCreate(): void; 105 106 /** 107 * Called back when start specified ability. 108 * 109 * @param { Want } want - Indicates the want info of started ability. 110 * @returns { string } The user returns an ability string ID. If the ability of this ID has been started before, 111 * do not create a new instance and pull it back to the top of the stack. 112 * Otherwise, create a new instance and start it. 113 * @syscap SystemCapability.Ability.AbilityRuntime.Core 114 * @StageModelOnly 115 * @since 9 116 */ 117 /** 118 * Called back when start specified ability. 119 * 120 * @param { Want } want - Indicates the want info of started ability. 121 * @returns { string } The user returns an ability string ID. If the ability of this ID has been started before, 122 * do not create a new instance and pull it back to the top of the stack. 123 * Otherwise, create a new instance and start it. 124 * @syscap SystemCapability.Ability.AbilityRuntime.Core 125 * @StageModelOnly 126 * @atomicservice 127 * @since 11 128 */ 129 onAcceptWant(want: Want): string; 130 131 /** 132 * Called back when start UIAbility in specified process. 133 * 134 * @param { Want } want - Indicates the want info of started ability. 135 * @returns { string } The user returns an process string ID. If the process of this ID has been created before, 136 * let the ability run in this process. Otherwise, create a new process. 137 * @syscap SystemCapability.Ability.AbilityRuntime.Core 138 * @StageModelOnly 139 * @since 11 140 */ 141 onNewProcessRequest(want: Want): string; 142 143 /** 144 * Called when the system configuration is updated. 145 * 146 * @param { Configuration } newConfig - Indicates the updated configuration. 147 * @syscap SystemCapability.Ability.AbilityRuntime.Core 148 * @StageModelOnly 149 * @since 9 150 */ 151 /** 152 * Called when the system configuration is updated. 153 * 154 * @param { Configuration } newConfig - Indicates the updated configuration. 155 * @syscap SystemCapability.Ability.AbilityRuntime.Core 156 * @StageModelOnly 157 * @crossplatform 158 * @since 10 159 */ 160 /** 161 * Called when the system configuration is updated. 162 * 163 * @param { Configuration } newConfig - Indicates the updated configuration. 164 * @syscap SystemCapability.Ability.AbilityRuntime.Core 165 * @StageModelOnly 166 * @crossplatform 167 * @atomicservice 168 * @since 11 169 */ 170 onConfigurationUpdate(newConfig: Configuration): void; 171 172 /** 173 * Called when the system has determined to trim the memory, for example, when the ability is running in the 174 * background and there is no enough memory for running as many background processes as possible. 175 * 176 * @param { AbilityConstant.MemoryLevel } level - Indicates the memory trim level, which shows the current memory usage status. 177 * @syscap SystemCapability.Ability.AbilityRuntime.Core 178 * @StageModelOnly 179 * @since 9 180 */ 181 /** 182 * Called when the system has determined to trim the memory, for example, when the ability is running in the 183 * background and there is no enough memory for running as many background processes as possible. 184 * 185 * @param { AbilityConstant.MemoryLevel } level - Indicates the memory trim level, which shows the current memory usage status. 186 * @syscap SystemCapability.Ability.AbilityRuntime.Core 187 * @StageModelOnly 188 * @atomicservice 189 * @since 11 190 */ 191 onMemoryLevel(level: AbilityConstant.MemoryLevel): void; 192 193 /** 194 * Called back when an ability stage is Destroyed. 195 * Will not call the onDestroy function when killing a process or crashing abnormally. 196 * 197 * @syscap SystemCapability.Ability.AbilityRuntime.Core 198 * @StageModelOnly 199 * @atomicservice 200 * @since 12 201 */ 202 onDestroy(): void; 203} 204