• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 Ability from './@ohos.app.ability.Ability';
22import AbilityConstant from './@ohos.app.ability.AbilityConstant';
23import UIAbilityContext from './application/UIAbilityContext';
24import rpc from './@ohos.rpc';
25import Want from './@ohos.app.ability.Want';
26import window from './@ohos.window';
27
28/**
29 * The prototype of the listener function interface registered by the Caller.
30 *
31 * @typedef OnReleaseCallback
32 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
33 * @StageModelOnly
34 * @since 9
35 */
36export interface OnReleaseCallback {
37/**
38 * Defines the callback of OnRelease.
39 *
40 * @param { string } msg - The notification event string listened to by the OnRelease.
41 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
42 * @StageModelOnly
43 * @since 9
44 */
45  (msg: string): void;
46}
47
48/**
49 * The prototype of the listener function interface registered by the Caller.
50 *
51 * @typedef OnRemoteStateChangeCallback
52 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
53 * @StageModelOnly
54 * @since 10
55 */
56export interface OnRemoteStateChangeCallback {
57/**
58 * Defines the callback of OnRemoteStateChange.
59 *
60 * @param { string } msg - The notification event string listened to by the OnRemoteStateChange.
61 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
62 * @StageModelOnly
63 * @since 10
64 */
65  (msg: string): void;
66}
67
68/**
69 * The prototype of the message listener function interface registered by the Callee.
70 *
71 * @typedef CalleeCallback
72 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
73 * @StageModelOnly
74 * @since 9
75 */
76export interface CalleeCallback {
77/**
78 * Defines the callback of Callee.
79 *
80 * @param { rpc.MessageSequence } indata - Notification indata to the callee.
81 * @returns { rpc.Parcelable } Returns the callee's notification result indata.
82 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
83 * @StageModelOnly
84 * @since 9
85 */
86  (indata: rpc.MessageSequence): rpc.Parcelable;
87}
88
89/**
90 * The interface of a Caller.
91 *
92 * @interface Caller
93 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
94 * @StageModelOnly
95 * @since 9
96 */
97export interface Caller {
98  /**
99   * Notify the server of Parcelable type data.
100   *
101   * @param { string } method - The notification event string listened to by the callee.
102   * @param { rpc.Parcelable } data - Notification data to the callee.
103   * @returns { Promise<void> } The promise returned by the function.
104   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
105   * 2. Incorrect parameter types.
106   * @throws { BusinessError } 16200001 - Caller released. The caller has been released.
107   * @throws { BusinessError } 16200002 - Callee invalid. The callee does not exist.
108   * @throws { BusinessError } 16000050 - Internal error.
109   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
110   * @StageModelOnly
111   * @since 9
112   */
113  call(method: string, data: rpc.Parcelable): Promise<void>;
114
115  /**
116   * Notify the server of Parcelable type data and return the notification result.
117   *
118   * @param { string } method - The notification event string listened to by the callee.
119   * @param { rpc.Parcelable } data - Notification data to the callee.
120   * @returns { Promise<rpc.MessageSequence> } Returns the callee's notification result data.
121   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
122   * 2. Incorrect parameter types.
123   * @throws { BusinessError } 16200001 - Caller released. The caller has been released.
124   * @throws { BusinessError } 16200002 - Callee invalid. The callee does not exist.
125   * @throws { BusinessError } 16000050 - Internal error.
126   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
127   * @StageModelOnly
128   * @since 9
129   */
130  callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence>;
131
132  /**
133   * Register the generic component server Stub (stub) disconnect listening notification.
134   *
135   * @throws { BusinessError } 16200001 - Caller released. The caller has been released.
136   * @throws { BusinessError } 16200002 - Callee invalid. The callee does not exist.
137   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
138   * @StageModelOnly
139   * @since 9
140   */
141  release(): void;
142
143  /**
144   * Register death listener notification callback.
145   *
146   * @param { OnReleaseCallback } callback - Register a callback function for listening for notifications.
147   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
148   * 2. Incorrect parameter types.
149   * @throws { BusinessError } 16200001 - Caller released. The caller has been released.
150   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
151   * @StageModelOnly
152   * @since 9
153   */
154  onRelease(callback: OnReleaseCallback): void;
155
156  /**
157   * Register state changed listener notification callback of remote ability.
158   *
159   * @param { OnRemoteStateChangeCallback } callback - Register a callback function for listening for notifications.
160   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
161   * 2. Incorrect parameter types.
162   * @throws { BusinessError } 16200001 - Caller released. The caller has been released.
163   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
164   * @StageModelOnly
165   * @since 10
166   */
167  onRemoteStateChange(callback: OnRemoteStateChangeCallback): void;
168
169  /**
170   * Register death listener notification callback.
171   *
172   * @param { 'release' } type - release.
173   * @param { OnReleaseCallback } callback - Register a callback function for listening for notifications.
174   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
175   * 2. Incorrect parameter types; 3. Parameter verification failed.
176   * @throws { BusinessError } 16200001 - Caller released. The caller has been released.
177   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
178   * @StageModelOnly
179   * @since 9
180   */
181  on(type: 'release', callback: OnReleaseCallback): void;
182
183  /**
184   * Unregister death listener notification callback.
185   *
186   * @param { 'release' } type - release.
187   * @param { OnReleaseCallback } callback - Unregister a callback function for listening for notifications.
188   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
189   * 2. Incorrect parameter types; 3. Parameter verification failed.
190   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
191   * @StageModelOnly
192   * @since 9
193   */
194  off(type: 'release', callback: OnReleaseCallback): void;
195
196  /**
197   * Unregister all death listener notification callback.
198   *
199   * @param { 'release' } type - release.
200   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
201   * 2. Incorrect parameter types; 3. Parameter verification failed.
202   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
203   * @StageModelOnly
204   * @since 9
205   */
206  off(type: 'release'): void;
207}
208
209/**
210 * The interface of a Callee.
211 *
212 * @interface Callee
213 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
214 * @StageModelOnly
215 * @since 9
216 */
217export interface Callee {
218  /**
219   * Register data listener callback.
220   *
221   * @param { string } method - A string registered to listen for notification events.
222   * @param { CalleeCallback } callback - Register a callback function that listens for notification events.
223   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
224   * 2. Incorrect parameter types; 3. Parameter verification failed.
225   * @throws { BusinessError } 16200004 - Method registered. The method has registered.
226   * @throws { BusinessError } 16000050 - Internal error.
227   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
228   * @StageModelOnly
229   * @since 9
230   */
231  on(method: string, callback: CalleeCallback): void;
232
233  /**
234   * Unregister data listener callback.
235   *
236   * @param { string } method - A string registered to listen for notification events.
237   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
238   * 2. Incorrect parameter types; 3. Parameter verification failed.
239   * @throws { BusinessError } 16200005 - Method not registered. The method has not registered.
240   * @throws { BusinessError } 16000050 - Internal error.
241   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
242   * @StageModelOnly
243   * @since 9
244   */
245  off(method: string): void;
246}
247
248/**
249 * The class of a UI ability.
250 *
251 * @extends Ability
252 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
253 * @StageModelOnly
254 * @since 9
255 */
256/**
257 * The class of a UI ability.
258 *
259 * @extends Ability
260 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
261 * @StageModelOnly
262 * @crossplatform
263 * @since 10
264 */
265/**
266 * The class of a UI ability.
267 *
268 * @extends Ability
269 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
270 * @StageModelOnly
271 * @crossplatform
272 * @atomicservice
273 * @since 11
274 */
275export default class UIAbility extends Ability {
276  /**
277   * Indicates configuration information about an ability context.
278   *
279   * @type { UIAbilityContext }
280   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
281   * @StageModelOnly
282   * @since 9
283   */
284  /**
285   * Indicates configuration information about an ability context.
286   *
287   * @type { UIAbilityContext }
288   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
289   * @StageModelOnly
290   * @crossplatform
291   * @since 10
292   */
293  /**
294   * Indicates configuration information about an ability context.
295   *
296   * @type { UIAbilityContext }
297   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
298   * @StageModelOnly
299   * @crossplatform
300   * @atomicservice
301   * @since 11
302   */
303  context: UIAbilityContext;
304
305  /**
306   * Indicates ability launch want.
307   *
308   * @type { Want }
309   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
310   * @StageModelOnly
311   * @since 9
312   */
313  /**
314   * Indicates ability launch want.
315   *
316   * @type { Want }
317   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
318   * @StageModelOnly
319   * @atomicservice
320   * @since 11
321   */
322  launchWant: Want;
323
324  /**
325   * Indicates ability last request want.
326   *
327   * @type { Want }
328   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
329   * @StageModelOnly
330   * @since 9
331   */
332  /**
333   * Indicates ability last request want.
334   *
335   * @type { Want }
336   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
337   * @StageModelOnly
338   * @atomicservice
339   * @since 11
340   */
341  lastRequestWant: Want;
342
343  /**
344   * Call Service Stub Object.
345   *
346   * @type { Callee }
347   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
348   * @StageModelOnly
349   * @since 9
350   */
351  callee: Callee;
352
353  /**
354   * Called back when an ability is started for initialization.
355   *
356   * @param { Want } want - Indicates the want info of the created ability.
357   * @param { AbilityConstant.LaunchParam } launchParam - Indicates the launch param.
358   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
359   * @StageModelOnly
360   * @since 9
361   */
362  /**
363   * Called back when an ability is started for initialization.
364   *
365   * @param { Want } want - Indicates the want info of the created ability.
366   * @param { AbilityConstant.LaunchParam } launchParam - Indicates the launch param.
367   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
368   * @StageModelOnly
369   * @crossplatform
370   * @since 10
371   */
372  /**
373   * Called back when an ability is started for initialization.
374   *
375   * @param { Want } want - Indicates the want info of the created ability.
376   * @param { AbilityConstant.LaunchParam } launchParam - Indicates the launch param.
377   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
378   * @StageModelOnly
379   * @crossplatform
380   * @atomicservice
381   * @since 11
382   */
383  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void;
384
385  /**
386   * Called back when an ability window stage is created.
387   *
388   * @param { window.WindowStage } windowStage - Indicates the created WindowStage.
389   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
390   * @StageModelOnly
391   * @since 9
392   */
393  /**
394   * Called back when an ability window stage is created.
395   *
396   * @param { window.WindowStage } windowStage - Indicates the created WindowStage.
397   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
398   * @StageModelOnly
399   * @crossplatform
400   * @since 10
401   */
402  /**
403   * Called back when an ability window stage is created.
404   *
405   * @param { window.WindowStage } windowStage - Indicates the created WindowStage.
406   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
407   * @StageModelOnly
408   * @crossplatform
409   * @atomicservice
410   * @since 11
411   */
412  onWindowStageCreate(windowStage: window.WindowStage): void;
413
414  /**
415   * Called back when an ability window stage will destroy.
416   *
417   * @param { window.WindowStage } windowStage - Indicates the WindowStage that will be destroyed.
418   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
419   * @StageModelOnly
420   * @atomicservice
421   * @since 12
422   */
423  onWindowStageWillDestroy(windowStage: window.WindowStage): void;
424
425  /**
426   * Called back when an ability window stage is destroyed.
427   *
428   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
429   * @StageModelOnly
430   * @since 9
431   */
432  /**
433   * Called back when an ability window stage is destroyed.
434   *
435   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
436   * @StageModelOnly
437   * @crossplatform
438   * @since 10
439   */
440  /**
441   * Called back when an ability window stage is destroyed.
442   *
443   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
444   * @StageModelOnly
445   * @crossplatform
446   * @atomicservice
447   * @since 11
448   */
449  onWindowStageDestroy(): void;
450
451  /**
452   * Called back when an ability window stage is restored.
453   *
454   * @param { window.WindowStage } windowStage - window stage to restore
455   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
456   * @StageModelOnly
457   * @since 9
458   */
459  /**
460   * Called back when an ability window stage is restored.
461   *
462   * @param { window.WindowStage } windowStage - window stage to restore
463   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
464   * @StageModelOnly
465   * @atomicservice
466   * @since 11
467   */
468  onWindowStageRestore(windowStage: window.WindowStage): void;
469
470  /**
471   * Called back before an ability is destroyed.
472   *
473   * @returns { void | Promise<void> } the promise returned by the function.
474   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
475   * @StageModelOnly
476   * @since 9
477   */
478  /**
479   * Called back before an ability is destroyed.
480   *
481   * @returns { void | Promise<void> } the promise returned by the function.
482   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
483   * @StageModelOnly
484   * @crossplatform
485   * @since 10
486   */
487  /**
488   * Called back before an ability is destroyed.
489   *
490   * @returns { void | Promise<void> } the promise returned by the function.
491   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
492   * @StageModelOnly
493   * @crossplatform
494   * @atomicservice
495   * @since 11
496   */
497  onDestroy(): void | Promise<void>;
498
499  /**
500   * Called back when the state of an ability changes to foreground.
501   *
502   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
503   * @StageModelOnly
504   * @since 9
505   */
506  /**
507   * Called back when the state of an ability changes to foreground.
508   *
509   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
510   * @StageModelOnly
511   * @crossplatform
512   * @since 10
513   */
514  /**
515   * Called back when the state of an ability changes to foreground.
516   *
517   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
518   * @StageModelOnly
519   * @crossplatform
520   * @atomicservice
521   * @since 11
522   */
523  onForeground(): void;
524
525  /**
526   * Called back when the state of an ability changes to background.
527   *
528   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
529   * @StageModelOnly
530   * @since 9
531   */
532  /**
533   * Called back when the state of an ability changes to background.
534   *
535   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
536   * @StageModelOnly
537   * @crossplatform
538   * @since 10
539   */
540  /**
541   * Called back when the state of an ability changes to background.
542   *
543   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
544   * @StageModelOnly
545   * @crossplatform
546   * @atomicservice
547   * @since 11
548   */
549  onBackground(): void;
550
551  /**
552   * Called back when an ability prepares to continue.
553   *
554   * @param { object } wantParam - Indicates the want parameter.
555   * @returns { AbilityConstant.OnContinueResult } Return the result of onContinue.
556   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
557   * @StageModelOnly
558   * @since 9
559   */
560  /**
561   * Called back when an ability prepares to continue.
562   *
563   * @param { Record<string, Object> } wantParam - Indicates the want parameter.
564   * @returns { AbilityConstant.OnContinueResult } Return the result of onContinue.
565   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
566   * @StageModelOnly
567   * @atomicservice
568   * @since 11
569   */
570  /**
571   * Called back when an ability prepares to continue.
572   *
573   * @param { Record<string, Object> } wantParam - Indicates the want parameter.
574   * @returns { AbilityConstant.OnContinueResult | Promise<AbilityConstant.OnContinueResult> } Return the result of onContinue, support promise.
575   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
576   * @StageModelOnly
577   * @atomicservice
578   * @since 12
579   */
580  onContinue(wantParam: Record<string, Object>):
581    AbilityConstant.OnContinueResult | Promise<AbilityConstant.OnContinueResult>;
582
583  /**
584   * Called when the launch mode of an ability is set to singleton.
585   * This happens when you re-launch an ability that has been at the top of the ability stack.
586   *
587   * @param { Want } want - Indicates the want info of ability.
588   * @param { AbilityConstant.LaunchParam } launchParam - Indicates the launch parameters.
589   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
590   * @StageModelOnly
591   * @since 9
592   */
593  /**
594   * Called when the launch mode of an ability is set to singleton.
595   * This happens when you re-launch an ability that has been at the top of the ability stack.
596   *
597   * @param { Want } want - Indicates the want info of ability.
598   * @param { AbilityConstant.LaunchParam } launchParam - Indicates the launch parameters.
599   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
600   * @StageModelOnly
601   * @crossplatform
602   * @since 10
603   */
604  /**
605   * Called when the launch mode of an ability is set to singleton.
606   * This happens when you re-launch an ability that has been at the top of the ability stack.
607   *
608   * @param { Want } want - Indicates the want info of ability.
609   * @param { AbilityConstant.LaunchParam } launchParam - Indicates the launch parameters.
610   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
611   * @StageModelOnly
612   * @crossplatform
613   * @atomicservice
614   * @since 11
615   */
616  onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void;
617
618  /**
619   * Called when dump client information is required.
620   * It is recommended that developers don't DUMP sensitive information.
621   *
622   * @param { Array<string> } params - Indicates the params from command.
623   * @returns { Array<string> } Return the dump info array.
624   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
625   * @StageModelOnly
626   * @since 9
627   */
628  /**
629   * Called when dump client information is required.
630   * It is recommended that developers don't DUMP sensitive information.
631   *
632   * @param { Array<string> } params - Indicates the params from command.
633   * @returns { Array<string> } Return the dump info array.
634   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
635   * @StageModelOnly
636   * @atomicservice
637   * @since 11
638   */
639  onDump(params: Array<string>): Array<string>;
640
641  /**
642   * Called back when an ability prepares to save.
643   *
644   * @param { AbilityConstant.StateType } reason - state type when save.
645   * @param { object } wantParam - Indicates the want parameter.
646   * @returns { AbilityConstant.OnSaveResult } agree with the current UIAbility status or not.return 0 if ability
647   *                                           agrees to save data successfully, otherwise errcode.
648   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
649   * @StageModelOnly
650   * @since 9
651   */
652  /**
653   * Called back when an ability prepares to save.
654   *
655   * @param { AbilityConstant.StateType } reason - state type when save.
656   * @param { Record<string, Object> } wantParam - Indicates the want parameter.
657   * @returns { AbilityConstant.OnSaveResult } agree with the current UIAbility status or not.return 0 if ability
658   *                                           agrees to save data successfully, otherwise errcode.
659   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
660   * @StageModelOnly
661   * @atomicservice
662   * @since 11
663   */
664  onSaveState(reason: AbilityConstant.StateType, wantParam: Record<string, Object>): AbilityConstant.OnSaveResult;
665
666  /**
667   * Called back when an ability shares data.
668   *
669   * @param { object } wantParam - Indicates the want parameter.
670   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
671   * @StageModelOnly
672   * @since 10
673   */
674  /**
675   * Called back when an ability shares data.
676   *
677   * @param { Record<string, Object> } wantParam - Indicates the want parameter.
678   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
679   * @StageModelOnly
680   * @atomicservice
681   * @since 11
682   */
683  onShare(wantParam: Record<string, Object>): void;
684
685  /**
686   * Called back when an ability prepare to terminate.
687   *
688   * @permission ohos.permission.PREPARE_APP_TERMINATE
689   * @returns { boolean } Returns {@code true} if the ability need to top terminating; returns {@code false} if the
690   *          ability need to terminate.
691   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
692   * @StageModelOnly
693   * @since 10
694   */
695  /**
696   * Called back when an ability prepare to terminate.
697   *
698   * @permission ohos.permission.PREPARE_APP_TERMINATE
699   * @returns { boolean } Returns {@code true} if the ability need to top terminating; returns {@code false} if the
700   *          ability need to terminate.
701   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
702   * @StageModelOnly
703   * @atomicservice
704   * @since 11
705   */
706  onPrepareToTerminate(): boolean;
707
708  /**
709   * Called back when back press is dispatched.
710   *
711   * @returns { boolean } Returns {@code true} means the ability will move to background when back is pressed;
712   *          Returns {@code false} means the ability will be destroyed when back is pressed.
713   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
714   * @StageModelOnly
715   * @since 10
716   */
717  /**
718   * Called back when back press is dispatched.
719   *
720   * @returns { boolean } Returns {@code true} means the ability will move to background when back is pressed;
721   *          Returns {@code false} means the ability will be destroyed when back is pressed.
722   * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
723   * @StageModelOnly
724   * @atomicservice
725   * @since 11
726   */
727  onBackPressed(): boolean;
728}
729