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 UIAbility from './@ohos.app.ability.UIAbility'; 22import dataAbility from './@ohos.data.dataAbility'; 23import window from './@ohos.window'; 24 25/** 26 * The ability lifecycle callback. 27 * 28 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 29 * @StageModelOnly 30 * @since 9 31 */ 32/** 33 * The ability lifecycle callback. 34 * 35 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 36 * @StageModelOnly 37 * @crossplatform 38 * @since 10 39 */ 40/** 41 * The ability lifecycle callback. 42 * 43 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 44 * @StageModelOnly 45 * @crossplatform 46 * @atomicservice 47 * @since 11 48 */ 49export default class AbilityLifecycleCallback { 50 /** 51 * Called back when an ability is started for initialization. 52 * 53 * @param { UIAbility } ability - Indicates the ability to register for listening. 54 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 55 * @StageModelOnly 56 * @since 9 57 */ 58 /** 59 * Called back when an ability is started for initialization. 60 * 61 * @param { UIAbility } ability - Indicates the ability to register for listening. 62 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 63 * @StageModelOnly 64 * @crossplatform 65 * @since 10 66 */ 67 /** 68 * Called back when an ability is started for initialization. 69 * 70 * @param { UIAbility } ability - Indicates the ability to register for listening. 71 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 72 * @StageModelOnly 73 * @crossplatform 74 * @atomicservice 75 * @since 11 76 */ 77 onAbilityCreate(ability: UIAbility): void; 78 79 /** 80 * Called back before an ability is started for initialization. 81 * 82 * @param { UIAbility } ability - Indicates the ability to register for listening. 83 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 84 * @stagemodelonly 85 * @atomicservice 86 * @since 12 87 */ 88 onAbilityWillCreate?(ability: UIAbility): void; 89 90 /** 91 * Called back when a window stage is created. 92 * 93 * @param { UIAbility } ability - Indicates the ability to register for listening. 94 * @param { window.WindowStage } windowStage - window stage to create 95 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 96 * @StageModelOnly 97 * @since 9 98 */ 99 /** 100 * Called back when a window stage is created. 101 * 102 * @param { UIAbility } ability - Indicates the ability to register for listening. 103 * @param { window.WindowStage } windowStage - window stage to create 104 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 105 * @StageModelOnly 106 * @crossplatform 107 * @since 10 108 */ 109 /** 110 * Called back when a window stage is created. 111 * 112 * @param { UIAbility } ability - Indicates the ability to register for listening. 113 * @param { window.WindowStage } windowStage - window stage to create 114 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 115 * @StageModelOnly 116 * @crossplatform 117 * @atomicservice 118 * @since 11 119 */ 120 onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void; 121 122 /** 123 * Called back before a window stage is created. 124 * 125 * @param { UIAbility } ability - Indicates the ability to register for listening. 126 * @param { window.WindowStage } windowStage - window stage to create 127 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 128 * @stagemodelonly 129 * @atomicservice 130 * @since 12 131 */ 132 onWindowStageWillCreate?(ability: UIAbility, windowStage: window.WindowStage): void; 133 134 /** 135 * Called back before the UIAbility will called onNewWant. 136 * 137 * @param { UIAbility } ability - Indicates the ability to register for listening. 138 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 139 * @stagemodelonly 140 * @atomicservice 141 * @since 12 142 */ 143 onWillNewWant?(ability: UIAbility): void; 144 145 /** 146 * Called back after the UIAbility called onNewWant. 147 * 148 * @param { UIAbility } ability - Indicates the ability to register for listening. 149 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 150 * @stagemodelonly 151 * @atomicservice 152 * @since 12 153 */ 154 onNewWant?(ability: UIAbility): void; 155 156 /** 157 * Called back when a window stage is active. 158 * 159 * @param { UIAbility } ability - Indicates the ability to register for listening. 160 * @param { window.WindowStage } windowStage - window stage to active 161 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 162 * @StageModelOnly 163 * @since 9 164 */ 165 /** 166 * Called back when a window stage is active. 167 * 168 * @param { UIAbility } ability - Indicates the ability to register for listening. 169 * @param { window.WindowStage } windowStage - window stage to active 170 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 171 * @StageModelOnly 172 * @atomicservice 173 * @since 11 174 */ 175 onWindowStageActive(ability: UIAbility, windowStage: window.WindowStage): void; 176 177 /** 178 * Called back when a window stage is inactive. 179 * 180 * @param { UIAbility } ability - Indicates the ability to register for listening. 181 * @param { window.WindowStage } windowStage - window stage to inactive 182 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 183 * @StageModelOnly 184 * @since 9 185 */ 186 /** 187 * Called back when a window stage is inactive. 188 * 189 * @param { UIAbility } ability - Indicates the ability to register for listening. 190 * @param { window.WindowStage } windowStage - window stage to inactive 191 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 192 * @StageModelOnly 193 * @atomicservice 194 * @since 11 195 */ 196 onWindowStageInactive(ability: UIAbility, windowStage: window.WindowStage): void; 197 198 /** 199 * Called back when a window stage is destroyed. 200 * 201 * @param { UIAbility } ability - Indicates the ability to register for listening. 202 * @param { window.WindowStage } windowStage - window stage to destroy 203 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 204 * @StageModelOnly 205 * @since 9 206 */ 207 /** 208 * Called back when a window stage is destroyed. 209 * 210 * @param { UIAbility } ability - Indicates the ability to register for listening. 211 * @param { window.WindowStage } windowStage - window stage to destroy 212 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 213 * @StageModelOnly 214 * @crossplatform 215 * @since 10 216 */ 217 /** 218 * Called back when a window stage is destroyed. 219 * 220 * @param { UIAbility } ability - Indicates the ability to register for listening. 221 * @param { window.WindowStage } windowStage - window stage to destroy 222 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 223 * @StageModelOnly 224 * @crossplatform 225 * @atomicservice 226 * @since 11 227 */ 228 onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void; 229 230 /** 231 * Called back before a window stage is destroyed. 232 * 233 * @param { UIAbility } ability - Indicates the ability to register for listening. 234 * @param { window.WindowStage } windowStage - window stage to destroy 235 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 236 * @stagemodelonly 237 * @atomicservice 238 * @since 12 239 */ 240 onWindowStageWillDestroy?(ability: UIAbility, windowStage: window.WindowStage): void; 241 242 /** 243 * Called back when an ability is destroyed. 244 * 245 * @param { UIAbility } ability - Indicates the ability to register for listening. 246 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 247 * @StageModelOnly 248 * @since 9 249 */ 250 /** 251 * Called back when an ability is destroyed. 252 * 253 * @param { UIAbility } ability - Indicates the ability to register for listening. 254 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 255 * @StageModelOnly 256 * @crossplatform 257 * @since 10 258 */ 259 /** 260 * Called back when an ability is destroyed. 261 * 262 * @param { UIAbility } ability - Indicates the ability to register for listening. 263 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 264 * @StageModelOnly 265 * @crossplatform 266 * @atomicservice 267 * @since 11 268 */ 269 onAbilityDestroy(ability: UIAbility): void; 270 271 /** 272 * Called back before an ability is destroyed. 273 * 274 * @param { UIAbility } ability - Indicates the ability to register for listening. 275 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 276 * @stagemodelonly 277 * @atomicservice 278 * @since 12 279 */ 280 onAbilityWillDestroy?(ability: UIAbility): void; 281 282 /** 283 * Called back when the state of an ability changes to foreground. 284 * 285 * @param { UIAbility } ability - Indicates the ability to register for listening. 286 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 287 * @StageModelOnly 288 * @since 9 289 */ 290 /** 291 * Called back when the state of an ability changes to foreground. 292 * 293 * @param { UIAbility } ability - Indicates the ability to register for listening. 294 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 295 * @StageModelOnly 296 * @crossplatform 297 * @since 10 298 */ 299 /** 300 * Called back when the state of an ability changes to foreground. 301 * 302 * @param { UIAbility } ability - Indicates the ability to register for listening. 303 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 304 * @StageModelOnly 305 * @crossplatform 306 * @atomicservice 307 * @since 11 308 */ 309 onAbilityForeground(ability: UIAbility): void; 310 311 /** 312 * Called back before the state of an ability changes to foreground. 313 * 314 * @param { UIAbility } ability - Indicates the ability to register for listening. 315 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 316 * @stagemodelonly 317 * @atomicservice 318 * @since 12 319 */ 320 onAbilityWillForeground?(ability: UIAbility): void; 321 322 /** 323 * Called back when the state of an ability changes to background. 324 * 325 * @param { UIAbility } ability - Indicates the ability to register for listening. 326 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 327 * @StageModelOnly 328 * @since 9 329 */ 330 /** 331 * Called back when the state of an ability changes to background. 332 * 333 * @param { UIAbility } ability - Indicates the ability to register for listening. 334 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 335 * @StageModelOnly 336 * @crossplatform 337 * @since 10 338 */ 339 /** 340 * Called back when the state of an ability changes to background. 341 * 342 * @param { UIAbility } ability - Indicates the ability to register for listening. 343 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 344 * @StageModelOnly 345 * @crossplatform 346 * @atomicservice 347 * @since 11 348 */ 349 onAbilityBackground(ability: UIAbility): void; 350 351 /** 352 * Called back before the state of an ability changes to background. 353 * 354 * @param { UIAbility } ability - Indicates the ability to register for listening. 355 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 356 * @stagemodelonly 357 * @atomicservice 358 * @since 12 359 */ 360 onAbilityWillBackground?(ability: UIAbility): void; 361 362 /** 363 * Called back when an ability prepares to continue. 364 * 365 * @param { UIAbility } ability - Indicates the ability to register for listening. 366 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 367 * @StageModelOnly 368 * @since 9 369 */ 370 /** 371 * Called back when an ability prepares to continue. 372 * 373 * @param { UIAbility } ability - Indicates the ability to register for listening. 374 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 375 * @StageModelOnly 376 * @atomicservice 377 * @since 11 378 */ 379 onAbilityContinue(ability: UIAbility): void; 380 381 /** 382 * Called back when the ability prepares to call onContinue. 383 * 384 * @param { UIAbility } ability - Indicates the ability to register for listening. 385 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 386 * @stagemodelonly 387 * @atomicservice 388 * @since 12 389 */ 390 onAbilityWillContinue?(ability: UIAbility): void; 391 392 /** 393 * Called back when the ability prepares to call onWindowStageRestore. 394 * 395 * @param { UIAbility } ability - Indicates the ability to register for listening. 396 * @param { window.WindowStage } windowStage - window stage to restore. 397 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 398 * @stagemodelonly 399 * @atomicservice 400 * @since 12 401 */ 402 onWindowStageWillRestore?(ability: UIAbility, windowStage: window.WindowStage): void; 403 404 /** 405 * Called back when the ability has called onWindowStageRestore. 406 * 407 * @param { UIAbility } ability - Indicates the ability to register for listening. 408 * @param { window.WindowStage } windowStage - window stage to restore. 409 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 410 * @stagemodelonly 411 * @atomicservice 412 * @since 12 413 */ 414 onWindowStageRestore?(ability: UIAbility, windowStage: window.WindowStage): void; 415 416 /** 417 * Called back when the ability prepares to call onSaveState. 418 * 419 * @param { UIAbility } ability - Indicates the ability to register for listening. 420 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 421 * @stagemodelonly 422 * @atomicservice 423 * @since 12 424 */ 425 onAbilityWillSaveState?(ability: UIAbility): void; 426 427 /** 428 * Called back when the ability has called onSaveState. 429 * 430 * @param { UIAbility } ability - Indicates the ability to register for listening. 431 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 432 * @stagemodelonly 433 * @atomicservice 434 * @since 12 435 */ 436 onAbilitySaveState?(ability: UIAbility): void; 437} 438