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