• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 StartupConfig from './@ohos.app.appstartup.StartupConfig';
22
23/**
24 * Startup task manager.
25 *
26 * @namespace startupManager
27 * @syscap SystemCapability.Ability.AppStartup
28 * @stagemodelonly
29 * @since 12
30 */
31declare namespace startupManager {
32  /**
33   * Runs startup tasks.
34   *
35   * @param { Array<string> } startupTasks - Indicates all tasks ready to run.
36   * @param { StartupConfig } [config] - Indicates the configuration of startup tasks.
37   * @returns { Promise<void> } The promise returned by the function.
38   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
39   * 2. Incorrect parameter types.
40   * @throws { BusinessError } 16000050 - Internal error.
41   * @throws { BusinessError } 28800001 - Startup task or its dependency not found.
42   * @throws { BusinessError } 28800002 - The startup tasks have circular dependencies.
43   * @throws { BusinessError } 28800003 - An error occurred while running the startup tasks.
44   * @throws { BusinessError } 28800004 - Running startup tasks timeout.
45   *
46   * @syscap SystemCapability.Ability.AppStartup
47   * @stagemodelonly
48   * @since 12
49   */
50  function run(startupTasks: Array<string>, config?: StartupConfig): Promise<void>;
51
52  /**
53   * Removes all startup tasks result.
54   *
55   * @syscap SystemCapability.Ability.AppStartup
56   * @stagemodelonly
57   * @since 12
58   */
59  function removeAllStartupTaskResults(): void;
60
61  /**
62   * Obtains specific startup task result.
63   *
64   * @param { string } startupTask - Indicates name of specific startup task.
65   * @returns { Object } The result of specific startup task.
66   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
67   * 2. Incorrect parameter types.
68   * @syscap SystemCapability.Ability.AppStartup
69   * @stagemodelonly
70   * @since 12
71   */
72  function getStartupTaskResult(startupTask: string): Object;
73
74  /**
75   * Obtains whether specific startup task has already been initialized.
76   *
77   * @param { string } startupTask - Indicates name of specific startup task.
78   * @returns { boolean } Whether specific startup task has already been initialized.
79   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
80   * 2. Incorrect parameter types.
81   * @syscap SystemCapability.Ability.AppStartup
82   * @stagemodelonly
83   * @since 12
84   */
85  function isStartupTaskInitialized(startupTask: string): boolean;
86
87  /**
88   * Removes specific startup task result.
89   *
90   * @param { string } startupTask - Indicates name of specific startup task.
91   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
92   * 2. Incorrect parameter types.
93   * @syscap SystemCapability.Ability.AppStartup
94   * @stagemodelonly
95   * @since 12
96   */
97  function removeStartupTaskResult(startupTask: string): void;
98}
99
100export default startupManager;
101