• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2025 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 Context from './Context';
22import { AsyncCallback } from '../@ohos.base';
23import { ProcessInformation } from './ProcessInformation';
24import type ConfigurationConstant from '../@ohos.app.ability.ConfigurationConstant';
25import Want from '../@ohos.app.ability.Want';
26/*** if arkts 1.1 */
27import AbilityLifecycleCallback from '../@ohos.app.ability.AbilityLifecycleCallback';
28import EnvironmentCallback from '../@ohos.app.ability.EnvironmentCallback';
29import type ApplicationStateChangeCallback from '../@ohos.app.ability.ApplicationStateChangeCallback';
30/*** endif */
31
32/**
33 * The context of an application. It allows access to application-specific resources.
34 *
35 * @extends Context
36 * @syscap SystemCapability.Ability.AbilityRuntime.Core
37 * @stagemodelonly
38 * @since 9
39 */
40/**
41 * The context of an application. It allows access to application-specific resources.
42 *
43 * @extends Context
44 * @syscap SystemCapability.Ability.AbilityRuntime.Core
45 * @stagemodelonly
46 * @crossplatform
47 * @since 10
48 */
49/**
50 * The ApplicationContext module, inherited from Context, provides application-level context capabilities, including
51 * APIs for registering and unregistering the lifecycle of application components.
52 *
53 * @extends Context
54 * @syscap SystemCapability.Ability.AbilityRuntime.Core
55 * @stagemodelonly
56 * @crossplatform
57 * @atomicservice
58 * @since arkts {'1.1':'11', '1.2':'20'}
59 * @arkts 1.1&1.2
60 */
61declare class ApplicationContext extends Context {
62  /**
63   * Register ability lifecycle callback.
64   *
65   * @param { 'abilityLifecycle' } type - abilityLifecycle.
66   * @param { AbilityLifecycleCallback } callback - The ability lifecycle callback.
67   * @returns { number } Returns the number code of the callback.
68   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
69   * @syscap SystemCapability.Ability.AbilityRuntime.Core
70   * @stagemodelonly
71   * @since 9
72   */
73  /**
74   * Register ability lifecycle callback.
75   *
76   * @param { 'abilityLifecycle' } type - abilityLifecycle.
77   * @param { AbilityLifecycleCallback } callback - The ability lifecycle callback.
78   * @returns { number } Returns the number code of the callback.
79   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
80   * @syscap SystemCapability.Ability.AbilityRuntime.Core
81   * @stagemodelonly
82   * @crossplatform
83   * @since 10
84   */
85  /**
86   * Registers a listener to monitor the ability lifecycle of the application.
87   * This API uses an asynchronous callback to return the result.
88   *
89   * <p>**NOTE**:
90   * <br>It can be called only by the main thread.
91   * </p>
92   *
93   * @param { 'abilityLifecycle' } type - Event type.
94   * @param { AbilityLifecycleCallback } callback - Callback used to return the ID of the registered listener.
95   * @returns { number } Returns the number code of the callback.
96   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
97   * 2.Incorrect parameter types.
98   * @syscap SystemCapability.Ability.AbilityRuntime.Core
99   * @stagemodelonly
100   * @crossplatform
101   * @atomicservice
102   * @since 11
103   */
104  on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): number;
105
106  /**
107   * Unregister ability lifecycle callback.
108   *
109   * @param { 'abilityLifecycle' } type - abilityLifecycle.
110   * @param { number } callbackId - Indicates the number code of the callback.
111   * @param { AsyncCallback<void> } callback - The callback of off.
112   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
113   * @syscap SystemCapability.Ability.AbilityRuntime.Core
114   * @stagemodelonly
115   * @since 9
116   */
117  /**
118   * Unregister ability lifecycle callback.
119   *
120   * @param { 'abilityLifecycle' } type - abilityLifecycle.
121   * @param { number } callbackId - Indicates the number code of the callback.
122   * @param { AsyncCallback<void> } callback - The callback of off.
123   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
124   * @syscap SystemCapability.Ability.AbilityRuntime.Core
125   * @stagemodelonly
126   * @crossplatform
127   * @since 10
128   */
129  /**
130   * Unregisters the listener that monitors the ability lifecycle of the application.
131   * This API uses an asynchronous callback to return the result.
132   *
133   * <p>**NOTE**:
134   * <br>It can be called only by the main thread.
135   * </p>
136   *
137   * @param { 'abilityLifecycle' } type - Event type.
138   * @param { number } callbackId - ID of the listener to unregister.
139   * @param { AsyncCallback<void> } callback - Callback used to return the result. If the deregistration is successful,
140   * err is undefined. Otherwise, err is an error object.
141   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
142   * 2.Incorrect parameter types.
143   * @syscap SystemCapability.Ability.AbilityRuntime.Core
144   * @stagemodelonly
145   * @crossplatform
146   * @atomicservice
147   * @since 11
148   */
149  off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback<void>): void;
150
151  /**
152   * Unregister ability lifecycle callback.
153   *
154   * @param { 'abilityLifecycle' } type - abilityLifecycle.
155   * @param { number } callbackId - Indicates the number code of the callback.
156   * @returns { Promise<void> } The promise returned by the function.
157   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
158   * @syscap SystemCapability.Ability.AbilityRuntime.Core
159   * @stagemodelonly
160   * @since 9
161   */
162  /**
163   * Unregister ability lifecycle callback.
164   *
165   * @param { 'abilityLifecycle' } type - abilityLifecycle.
166   * @param { number } callbackId - Indicates the number code of the callback.
167   * @returns { Promise<void> } The promise returned by the function.
168   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
169   * @syscap SystemCapability.Ability.AbilityRuntime.Core
170   * @stagemodelonly
171   * @atomicservice
172   * @since 11
173   */
174  /**
175   * Unregisters the listener that monitors the ability lifecycle of the application.
176   * This API uses a promise to return the result.
177   *
178   * <p>**NOTE**:
179   * <br>It can be called only by the main thread.
180   * </p>
181   *
182   * @param { 'abilityLifecycle' } type - Event type.
183   * @param { number } callbackId - ID of the listener to unregister.
184   * @returns { Promise<void> } Promise that returns no value.
185   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
186   * 2.Incorrect parameter types.
187   * @syscap SystemCapability.Ability.AbilityRuntime.Core
188   * @stagemodelonly
189   * @crossplatform
190   * @atomicservice
191   * @since 12
192   */
193  off(type: 'abilityLifecycle', callbackId: number): Promise<void>;
194
195  /**
196   * Register environment callback.
197   *
198   * @param { 'environment' } type - environment.
199   * @param { EnvironmentCallback } callback - The environment callback.
200   * @returns { number } Returns the number code of the callback.
201   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
202   * @syscap SystemCapability.Ability.AbilityRuntime.Core
203   * @stagemodelonly
204   * @since 9
205   */
206  /**
207   * Registers a listener for system environment changes.
208   * This API uses an asynchronous callback to return the result.
209   *
210   * <p>**NOTE**:
211   * <br>It can be called only by the main thread.
212   * </p>
213   *
214   * @param { 'environment' } type - Event type.
215   * @param { EnvironmentCallback } callback - Callback used to return the system environment changes.
216   * @returns { number } ID of the registered listener. The ID is incremented by 1 each time the listener is
217   * registered. When the ID exceeds 2^63-1, -1 is returned.
218   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
219   * 2.Incorrect parameter types.
220   * @syscap SystemCapability.Ability.AbilityRuntime.Core
221   * @stagemodelonly
222   * @atomicservice
223   * @since 11
224   */
225  on(type: 'environment', callback: EnvironmentCallback): number;
226
227  /**
228   * Unregister environment callback.
229   *
230   * @param { 'environment' } type - environment.
231   * @param { number } callbackId - Indicates the number code of the callback.
232   * @param { AsyncCallback<void> } callback - The callback of unregisterEnvironmentCallback.
233   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
234   * @syscap SystemCapability.Ability.AbilityRuntime.Core
235   * @stagemodelonly
236   * @since 9
237   */
238  /**
239   * Unregisters the listener for system environment changes.
240   * This API uses an asynchronous callback to return the result.
241   *
242   * <p>**NOTE**:
243   * <br>It can be called only by the main thread.
244   * </p>
245   *
246   * @param { 'environment' } type - Event type.
247   * @param { number } callbackId - ID of the listener to unregister.
248   * @param { AsyncCallback<void> } callback - Callback used to return the result. If the deregistration is successful,
249   * err is undefined. Otherwise, err is an error object.
250   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
251   * 2.Incorrect parameter types.
252   * @syscap SystemCapability.Ability.AbilityRuntime.Core
253   * @stagemodelonly
254   * @atomicservice
255   * @since 11
256   */
257  off(type: 'environment', callbackId: number, callback: AsyncCallback<void>): void;
258
259  /**
260   * Unregister environment callback.
261   *
262   * @param { 'environment' } type - environment.
263   * @param { number } callbackId - Indicates the number code of the callback.
264   * @returns { Promise<void> } The promise returned by the function.
265   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
266   * @syscap SystemCapability.Ability.AbilityRuntime.Core
267   * @stagemodelonly
268   * @since 9
269   */
270  /**
271   * Unregisters the listener for system environment changes.
272   * This API uses a promise to return the result.
273   *
274   * <p>**NOTE**:
275   * <br>It can be called only by the main thread.
276   * </p>
277   *
278   * @param { 'environment' } type - Event type.
279   * @param { number } callbackId - ID of the listener to unregister.
280   * @returns { Promise<void> } Promise that returns no value.
281   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
282   * 2.Incorrect parameter types.
283   * @syscap SystemCapability.Ability.AbilityRuntime.Core
284   * @stagemodelonly
285   * @atomicservice
286   * @since 11
287   */
288  off(type: 'environment', callbackId: number): Promise<void>;
289
290  /**
291   * Register applicationStateChange callback.
292   *
293   * @param { 'applicationStateChange' } type - applicationStateChange.
294   * @param { ApplicationStateChangeCallback } callback - The applicationStateChange callback.
295   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
296   * @syscap SystemCapability.Ability.AbilityRuntime.Core
297   * @stagemodelonly
298   * @since 10
299   */
300  /**
301   * Register applicationStateChange callback.
302   *
303   * @param { 'applicationStateChange' } type - applicationStateChange.
304   * @param { ApplicationStateChangeCallback } callback - The applicationStateChange callback.
305   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
306   * @syscap SystemCapability.Ability.AbilityRuntime.Core
307   * @stagemodelonly
308   * @atomicservice
309   * @since 11
310   */
311  /**
312   * Registers a listener for application foreground/background state changes.
313   * This API uses an asynchronous callback to return the result.
314   *
315   * <p>**NOTE**:
316   * <br>It can be called only by the main thread.
317   * </p>
318   *
319   * @param { 'applicationStateChange' } type - Event type.
320   * @param { ApplicationStateChangeCallback } callback - Callback used to return the result. You can define a callback
321   * for switching from the background to the foreground and a callback for switching from the foreground to the
322   * background.
323   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
324   * 2.Incorrect parameter types.
325   * @syscap SystemCapability.Ability.AbilityRuntime.Core
326   * @stagemodelonly
327   * @crossplatform
328   * @atomicservice
329   * @since 18
330   */
331  on(type: 'applicationStateChange', callback: ApplicationStateChangeCallback): void;
332
333  /**
334   * Unregister applicationStateChange callback.
335   *
336   * @param { 'applicationStateChange' } type - applicationStateChange.
337   * @param { ApplicationStateChangeCallback } [callback] - The applicationStateChange callback.
338   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
339   * @syscap SystemCapability.Ability.AbilityRuntime.Core
340   * @stagemodelonly
341   * @since 10
342   */
343  /**
344   * Unregister applicationStateChange callback.
345   *
346   * @param { 'applicationStateChange' } type - applicationStateChange.
347   * @param { ApplicationStateChangeCallback } [callback] - The applicationStateChange callback.
348   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
349   * @syscap SystemCapability.Ability.AbilityRuntime.Core
350   * @stagemodelonly
351   * @atomicservice
352   * @since 11
353   */
354  /**
355   * Unregisters the listener for application foreground/background state changes.
356   * This API uses an asynchronous callback to return the result.
357   *
358   * <p>**NOTE**:
359   * <br>It can be called only by the main thread.
360   * <br>A listener must have been registered by calling <code>ApplicationContext.on('applicationStateChange')</code>.
361   * </p>
362   *
363   * @param { 'applicationStateChange' } type - Event type.
364   * @param { ApplicationStateChangeCallback } [callback] - Callback used to return the result.The value can be a
365   * callback defined by <code>ApplicationContext.on('applicationStateChange')</code> or empty.
366   * - If a defined callback is passed in, the listener for that callback is unregistered.
367   * - If no value is passed in, all the listeners for the corresponding event are unregistered.
368   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
369   * 2.Incorrect parameter types.
370   * @syscap SystemCapability.Ability.AbilityRuntime.Core
371   * @stagemodelonly
372   * @crossplatform
373   * @atomicservice
374   * @since 18
375   */
376  off(type: 'applicationStateChange', callback?: ApplicationStateChangeCallback): void;
377
378  /**
379   * Get information about running processes
380   *
381   * @returns { Promise<Array<ProcessInformation>> } Returns the array of {@link ProcessInformation}.
382   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
383   * @throws { BusinessError } 16000011 - The context does not exist.
384   * @throws { BusinessError } 16000050 - Internal error.
385   * @syscap SystemCapability.Ability.AbilityRuntime.Core
386   * @stagemodelonly
387   * @since 9
388   */
389  /**
390   * Get information about running processes
391   *
392   * @returns { Promise<Array<ProcessInformation>> } Returns the array of {@link ProcessInformation}.
393   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
394   * @throws { BusinessError } 16000011 - The context does not exist.
395   * @throws { BusinessError } 16000050 - Internal error.
396   * @syscap SystemCapability.Ability.AbilityRuntime.Core
397   * @stagemodelonly
398   * @crossplatform
399   * @since 10
400   */
401  /**
402   * Obtains information about the running processes.
403   * This API uses a promise to return the result.
404   *
405   * @returns { Promise<Array<ProcessInformation>> } Promise used to return the API call result and the process running
406   * information. You can perform error handling or custom processing in this callback.
407   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
408   * 2.Incorrect parameter types.
409   * @throws { BusinessError } 16000011 - The context does not exist.
410   * @throws { BusinessError } 16000050 - Internal error.
411   * @syscap SystemCapability.Ability.AbilityRuntime.Core
412   * @stagemodelonly
413   * @crossplatform
414   * @atomicservice
415   * @since arkts {'1.1':'11', '1.2':'20'}
416   * @arkts 1.1&1.2
417   */
418  getRunningProcessInformation(): Promise<Array<ProcessInformation>>;
419
420  /**
421   * Get information about running processes
422   *
423   * @param { AsyncCallback<Array<ProcessInformation>> } callback - The callback is used to return the array of {@link ProcessInformation}.
424   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
425   * @throws { BusinessError } 16000011 - The context does not exist.
426   * @throws { BusinessError } 16000050 - Internal error.
427   * @syscap SystemCapability.Ability.AbilityRuntime.Core
428   * @stagemodelonly
429   * @since 9
430   */
431  /**
432   * Get information about running processes
433   *
434   * @param { AsyncCallback<Array<ProcessInformation>> } callback - The callback is used to return the array of {@link ProcessInformation}.
435   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
436   * @throws { BusinessError } 16000011 - The context does not exist.
437   * @throws { BusinessError } 16000050 - Internal error.
438   * @syscap SystemCapability.Ability.AbilityRuntime.Core
439   * @stagemodelonly
440   * @crossplatform
441   * @since 10
442   */
443  /**
444   * Obtains information about the running processes.
445   * This API uses an asynchronous callback to return the result.
446   *
447   * @param { AsyncCallback<Array<ProcessInformation>> } callback - Callback used to return the information about the
448   * running processes.
449   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
450   * 2.Incorrect parameter types.
451   * @throws { BusinessError } 16000011 - The context does not exist.
452   * @throws { BusinessError } 16000050 - Internal error.
453   * @syscap SystemCapability.Ability.AbilityRuntime.Core
454   * @stagemodelonly
455   * @crossplatform
456   * @atomicservice
457   * @since arkts {'1.1':'11', '1.2':'20'}
458   * @arkts 1.1&1.2
459   */
460  getRunningProcessInformation(callback: AsyncCallback<Array<ProcessInformation>>): void;
461
462  /**
463   * Kill all processes of the application
464   *
465   * @returns { Promise<void> } The promise returned by the function.
466   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
467   * @throws { BusinessError } 16000011 - The context does not exist.
468   * @syscap SystemCapability.Ability.AbilityRuntime.Core
469   * @stagemodelonly
470   * @since 9
471   */
472  /**
473   * Kills all processes of this application.
474   * The application will not go through the normal lifecycle when exiting.
475   * This API uses a promise to return the result.
476   *
477   * <p>**NOTE**:
478   * <br>It can be called only by the main thread.
479   * <br>This API is used to forcibly exit an application in abnormal scenarios. To exit an application properly,
480   * call terminateSelf().
481   * </p>
482   *
483   * @returns { Promise<void> } The promise returned by the function.
484   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
485   * 2.Incorrect parameter types.
486   * @throws { BusinessError } 16000011 - The context does not exist.
487   * @syscap SystemCapability.Ability.AbilityRuntime.Core
488   * @stagemodelonly
489   * @atomicservice
490   * @since arkts {'1.1':'11', '1.2':'20'}
491   * @arkts 1.1&1.2
492   */
493  killAllProcesses(): Promise<void>;
494
495  /**
496   * Kills all processes of this application.
497   * The application will not go through the normal lifecycle when exiting.
498   * This API uses a promise to return the result.
499   *
500   * <p>**NOTE**:
501   * <br>It can be called only by the main thread.
502   * <br>This API is used to forcibly exit an application in abnormal scenarios. To exit an application properly,
503   * call terminateSelf().
504   * </p>
505   *
506   * @param { boolean } clearPageStack - Whether to clear the page stack. The value <code>true</code> means to clear
507   * the page stack, and <code>false</code> means the opposite.
508   * @returns { Promise<void> } Promise that returns no value.
509   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
510   * @throws { BusinessError } 16000011 - The context does not exist.
511   * @syscap SystemCapability.Ability.AbilityRuntime.Core
512   * @stagemodelonly
513   * @atomicservice
514   * @since arkts {'1.1':'14', '1.2':'20'}
515   * @arkts 1.1&1.2
516   */
517  killAllProcesses(clearPageStack: boolean): Promise<void>;
518
519  /**
520   * Kill all processes of the application
521   *
522   * @param { AsyncCallback<void> } callback - The callback of killAllProcesses.
523   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
524   * @throws { BusinessError } 16000011 - The context does not exist.
525   * @syscap SystemCapability.Ability.AbilityRuntime.Core
526   * @stagemodelonly
527   * @since 9
528   */
529  /**
530   * Kills all processes of this application.
531   * The application will not go through the normal lifecycle when exiting.
532   * This API uses an asynchronous callback to return the result.
533   *
534   * <p>**NOTE**:
535   * <br>It can be called only by the main thread.
536   * <br>This API is used to forcibly exit an application in abnormal scenarios. To exit an application properly,
537   * call terminateSelf().
538   * </p>
539   *
540   * @param { AsyncCallback<void> } callback - Callback used to return the result. If all the processes are killed,
541   * <code>err</code> is <code>undefined</code>. Otherwise, <code>err</code> is an error object.
542   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
543   * 2.Incorrect parameter types.
544   * @throws { BusinessError } 16000011 - The context does not exist.
545   * @syscap SystemCapability.Ability.AbilityRuntime.Core
546   * @stagemodelonly
547   * @atomicservice
548   * @since 11
549   */
550  killAllProcesses(callback: AsyncCallback<void>);
551
552  /**
553   * Set colorMode of the application
554   *
555   * @param { ConfigurationConstant.ColorMode } colorMode - Color mode.
556   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.
557   * @throws { BusinessError } 16000011 - The context does not exist.
558   * @syscap SystemCapability.Ability.AbilityRuntime.Core
559   * @stagemodelonly
560   * @atomicservice
561   * @since 11
562   */
563  /**
564   * Sets the color mode for the application.
565   *
566   * <p>**NOTE**:
567   * <br>It can be called only by the main thread.
568   * </p>
569   *
570   * @param { ConfigurationConstant.ColorMode } colorMode - Target color mode, including dark mode, light mode, and
571   * system theme mode (no setting).
572   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
573   * 2.Incorrect parameter types.
574   * @throws { BusinessError } 16000011 - The context does not exist.
575   * @syscap SystemCapability.Ability.AbilityRuntime.Core
576   * @stagemodelonly
577   * @crossplatform
578   * @atomicservice
579   * @since arkts {'1.1':'18', '1.2':'20'}
580   * @arkts 1.1&1.2
581   */
582  setColorMode(colorMode: ConfigurationConstant.ColorMode): void;
583
584  /**
585   * Sets the language for the application.
586   *
587   * <p>**NOTE**:
588   * <br>It can be called only by the main thread.
589   * </p>
590   *
591   * @param { string } language - Target language. The list of supported languages can be obtained by
592   * calling getSystemLanguages().
593   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
594   * 2.Incorrect parameter types.
595   * @throws { BusinessError } 16000011 - The context does not exist.
596   * @syscap SystemCapability.Ability.AbilityRuntime.Core
597   * @stagemodelonly
598   * @atomicservice
599   * @since arkts {'1.1':'11', '1.2':'20'}
600   * @arkts 1.1&1.2
601   */
602  setLanguage(language: string): void;
603
604  /**
605   * Clears up the application data and revokes the permissions that the application has requested from users.
606   * This API uses a promise to return the result.
607   *
608   * <p>**NOTE**:
609   * <br>It can be called only by the main thread.
610   * <br>This API stops the application process. After the application process is stopped, all subsequent callbacks
611   * will not be triggered.
612   * </p>
613   *
614   * @returns { Promise<void> } Promise that returns no value.
615   * @throws { BusinessError } 16000011 - The context does not exist.
616   * @throws { BusinessError } 16000050 - Internal error.
617   * @syscap SystemCapability.Ability.AbilityRuntime.Core
618   * @stagemodelonly
619   * @since arkts {'1.1':'11', '1.2':'20'}
620   * @arkts 1.1&1.2
621   */
622  clearUpApplicationData(): Promise<void>;
623
624  /**
625   * Clears up the application data and revokes the permissions that the application has requested from users.
626   * This API uses an asynchronous callback to return the result.
627   *
628   * <p>**NOTE**:
629   * <br>It can be called only by the main thread.
630   * <br>This API stops the application process. After the application process is stopped, all subsequent callbacks
631   * will not be triggered.
632   * </p>
633   *
634   * @param { AsyncCallback<void> } callback - Callback used to return the result. If the application data is cleared
635   * up, <code>error</code> is <code>undefined</code>; otherwise, <code>error</code> is an error object.
636   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
637   * 2.Incorrect parameter types.
638   * @throws { BusinessError } 16000011 - The context does not exist.
639   * @throws { BusinessError } 16000050 - Internal error.
640   * @syscap SystemCapability.Ability.AbilityRuntime.Core
641   * @stagemodelonly
642   * @since arkts {'1.1':'11', '1.2':'20'}
643   * @arkts 1.1&1.2
644   */
645  clearUpApplicationData(callback: AsyncCallback<void>): void;
646
647  /**
648   * Restarts the application and starts the specified UIAbility.
649   * The onDestroy callback is not triggered during the restart.
650   *
651   * <p>**NOTE**:
652   * <br>It can be called only by the main thread, and the application to restart must be active.
653   * </p>
654   *
655   * @param { Want } want - Want information about the UIAbility to start. No verification is performed on the bundle
656   * name passed in.
657   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
658   * 2.Incorrect parameter types.
659   * @throws { BusinessError } 16000050 - Internal error.
660   * @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
661   * @throws { BusinessError } 16000063 - The target to restart does not belong to the current application or is not a UIAbility.
662   * @throws { BusinessError } 16000064 - Restart too frequently. Try again at least 3s later.
663   * @syscap SystemCapability.Ability.AbilityRuntime.Core
664   * @stagemodelonly
665   * @atomicservice
666   * @since arkts {'1.1':'12', '1.2':'20'}
667   * @arkts 1.1&1.2
668   */
669  restartApp(want: Want): void;
670
671  /**
672   * The preloaded <code>UIExtensionAbility</code> instance is sent to the <code>onCreate</code> lifecycle of the
673   * UIExtensionAbility and waits to be loaded by the current application.
674   * A <code>UIExtensionAbility</code> instance can be preloaded for multiple times. Each time a preloaded
675   * <code>UIExtensionAbility</code> instance is loaded, the next preloaded <code>UIExtensionAbility</code>
676   * instance is sent to the <code>onCreate</code> lifecycle of the UIExtensionAbility.
677   *
678   * @permission ohos.permission.PRELOAD_UI_EXTENSION_ABILITY
679   * @param { Want } want - Want information of the UIExtensionAbility.
680   * @returns { Promise<void> } Promise that returns no value.
681   * @throws { BusinessError } 201 - The application does not have permission to call the interface.
682   * @throws { BusinessError } 202 - The application is not system-app, can not use system-api.
683   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
684   * 2.Incorrect parameter types.
685   * @throws { BusinessError } 16000001 - The specified ability does not exist.
686   * @throws { BusinessError } 16000002 - Incorrect ability type.
687   * @throws { BusinessError } 16000004 - Cannot start an invisible component.
688   * @throws { BusinessError } 16000011 - The context does not exist.
689   * @throws { BusinessError } 16000050 - Internal error.
690   * @syscap SystemCapability.Ability.AbilityRuntime.Core
691   * @systemapi
692   * @stagemodelonly
693   * @since arkts {'1.1':'12', '1.2':'20'}
694   * @arkts 1.1&1.2
695   */
696  preloadUIExtensionAbility(want: Want): Promise<void>;
697
698  /**
699   * Sets whether the application itself supports process cache, which enables quick startup after caching.
700   *
701   * <p>**NOTE**:
702   * <br>It can be called only by the main thread.
703   * <br>This API only sets the application to be ready for quick startup after caching. It does not mean that quick
704   * startup will be triggered. Other conditions must be considered to determine whether to trigger quick startup.
705   * <br>The process cache support status takes effect for a single application process instance. The setting does not
706   * affect other process instances. After a process instance is destroyed, the status is not retained and can be
707   * reset.
708   * <br>To support process cache, you must call this API, with <code>true</code> passed in, in the <code>onCreate()</code>
709   * lifecycle of all AbilityStages in the same process.
710   * </p>
711   *
712   * @param { boolean } isSupported - Whether process cache is supported. The value <code>true</code> means that
713   * process cache is supported, and <code>false</code> means the opposite.
714   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
715   * 2.Incorrect parameter types.
716   * @throws { BusinessError } 801 - Capability not supported.
717   * @throws { BusinessError } 16000011 - The context does not exist.
718   * @throws { BusinessError } 16000050 - Internal error.
719   * @syscap SystemCapability.Ability.AbilityRuntime.Core
720   * @stagemodelonly
721   * @since arkts {'1.1':'12', '1.2':'20'}
722   * @arkts 1.1&1.2
723   */
724  setSupportedProcessCache(isSupported : boolean): void;
725
726  /**
727   * Sets the font for this application.
728   *
729   * <p>**NOTE**:
730   * <br>This API can be called only by the main thread.
731   * </P>
732   *
733   * @param { string } font - Font, which can be registered by calling UIContext.registerFont.
734   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
735   * 2.Incorrect parameter types.
736   * @throws { BusinessError } 16000011 - The context does not exist.
737   * @throws { BusinessError } 16000050 - Internal error.
738   * @syscap SystemCapability.Ability.AbilityRuntime.Core
739   * @stagemodelonly
740   * @since arkts {'1.1':'12', '1.2':'20'}
741   * @arkts 1.1&1.2
742   */
743  setFont(font: string): void;
744
745  /**
746   * Obtains the index of the current application clone.
747   *
748   * @returns { number } Index of the current application clone.
749   * @throws { BusinessError } 16000011 - The context does not exist.
750   * @throws { BusinessError } 16000071 - App clone is not supported.
751   * @syscap SystemCapability.Ability.AbilityRuntime.Core
752   * @stagemodelonly
753   * @atomicservice
754   * @since 12
755   */
756  getCurrentAppCloneIndex(): number;
757
758  /**
759   * Sets the scale ratio for the font size of this application.
760   *
761   * <p>**NOTE**:
762   * <br>It can be called only by the main thread.
763   * </p>
764   *
765   * @param {number} fontSizeScale - Font scale ratio. The value is a non-negative number. When the application's
766   * {@link fontSizeScale} is set to <code>followSystem</code> and the value set here exceeds the value of
767   * fontSizeMaxScale, the value of fontSizeMaxScale takes effect.
768   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified.
769   * @syscap SystemCapability.Ability.AbilityRuntime.Core
770   * @stagemodelonly
771   * @atomicservice
772   * @since arkts {'1.1':'13', '1.2':'20'}
773   * @arkts 1.1&1.2
774   */
775  setFontSizeScale(fontSizeScale: number): void;
776
777  /**
778   * Obtains the unique instance ID of this application.
779   *
780   * <p>**NOTE**:
781   * <br>It can be called only by the main thread.
782   * <br>This API is valid only for 2-in-1 devices.
783   * </p>
784   *
785   * @returns { string } Unique instance ID of the application.
786   * @throws { BusinessError } 16000011 - The context does not exist.
787   * @throws { BusinessError } 16000078 - The multi-instance is not supported.
788   * @syscap SystemCapability.Ability.AbilityRuntime.Core
789   * @stagemodelonly
790   * @since 14
791   */
792  getCurrentInstanceKey(): string;
793
794  /**
795   * Obtains the unique instance IDs of all multi-instances of this application.
796   * This API uses a promise to return the result.
797   *
798   * <p>**NOTE**:
799   * <br>It can be called only by the main thread.
800   * <br>This API is valid only for 2-in-1 devices.
801   * </p>
802   *
803   * @returns { Promise<Array<string>> } Promise used to return the unique instance IDs of all multi-instances of the
804   * application.
805   * @throws { BusinessError } 16000011 - The context does not exist.
806   * @throws { BusinessError } 16000050 - Internal error.
807   * @throws { BusinessError } 16000078 - The multi-instance is not supported.
808   * @syscap SystemCapability.Ability.AbilityRuntime.Core
809   * @stagemodelonly
810   * @since 14
811   */
812    getAllRunningInstanceKeys(): Promise<Array<string>>;
813}
814
815export default ApplicationContext;