1/* 2 * Copyright (c) 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 type { AutoStartupCallback } from './application/AutoStartupCallback'; 22import type { AutoStartupInfo } from './application/AutoStartupInfo'; 23import type { AsyncCallback } from './@ohos.base'; 24 25/** 26 * The class of auto startup manager. 27 * 28 * @namespace autoStartupManager 29 * @syscap SystemCapability.Ability.AbilityRuntime.Core 30 * @systemapi 31 * @since 11 32 */ 33declare namespace autoStartupManager { 34 /** 35 * Register the listener that watches for all applications auto startup state. 36 * 37 * @permission ohos.permission.MANAGE_APP_BOOT 38 * @param { 'systemAutoStartup' } type - Indicates the type of event. 39 * @param { AutoStartupCallback } callback - Auto startup callback. 40 * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission 41 * "ohos.permission.MANAGE_APP_BOOT". 42 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 43 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified; 44 * <br>2. Incorrect parameters types. 45 * @throws { BusinessError } 16000050 - Internal error. 46 * @syscap SystemCapability.Ability.AbilityRuntime.Core 47 * @systemapi 48 * @StageModelOnly 49 * @since 11 50 */ 51 function on(type: 'systemAutoStartup', callback: AutoStartupCallback): void; 52 53 /** 54 * Unregister listener that watches for all applications auto startup state. 55 * 56 * @permission ohos.permission.MANAGE_APP_BOOT 57 * @param { 'systemAutoStartup' } type - Indicates the type of event. 58 * @param { AutoStartupCallback } [callback] - Auto startup callback. 59 * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission 60 * "ohos.permission.MANAGE_APP_BOOT". 61 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 62 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified; 63 * <br>2. Incorrect parameters types. 64 * @throws { BusinessError } 16000050 - Internal error. 65 * @syscap SystemCapability.Ability.AbilityRuntime.Core 66 * @systemapi 67 * @StageModelOnly 68 * @since 11 69 */ 70 function off(type: 'systemAutoStartup', callback?: AutoStartupCallback): void; 71 72 /** 73 * Set application auto startup state. 74 * 75 * @permission ohos.permission.MANAGE_APP_BOOT 76 * @param { AutoStartupInfo } info - The application info. 77 * @param { AsyncCallback<void> } callback - The callback of setApplicationAutoStartup. 78 * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission 79 * "ohos.permission.MANAGE_APP_BOOT". 80 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 81 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified; 82 * <br>2. Incorrect parameters types. 83 * @throws { BusinessError } 16000004 - Cannot start an invisible component. 84 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 85 * @throws { BusinessError } 16000050 - Internal error. 86 * @syscap SystemCapability.Ability.AbilityRuntime.Core 87 * @systemapi 88 * @StageModelOnly 89 * @since 11 90 */ 91 function setApplicationAutoStartup(info: AutoStartupInfo, callback: AsyncCallback<void>): void; 92 93 /** 94 * Set application auto startup state. 95 * 96 * @permission ohos.permission.MANAGE_APP_BOOT 97 * @param { AutoStartupInfo } info - The application info. 98 * @returns { Promise<void> } The promise returned by the function. 99 * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission 100 * "ohos.permission.MANAGE_APP_BOOT". 101 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 102 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified; 103 * <br>2. Incorrect parameters types. 104 * @throws { BusinessError } 16000004 - Cannot start an invisible component. 105 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 106 * @throws { BusinessError } 16000050 - Internal error. 107 * @syscap SystemCapability.Ability.AbilityRuntime.Core 108 * @systemapi 109 * @StageModelOnly 110 * @since 11 111 */ 112 function setApplicationAutoStartup(info: AutoStartupInfo): Promise<void>; 113 114 /** 115 * Cancel application auto startup state. 116 * 117 * @permission ohos.permission.MANAGE_APP_BOOT 118 * @param { AutoStartupInfo } info - The application info. 119 * @param { AsyncCallback<void> } callback - The callback of cancelApplicationAutoStartup. 120 * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission 121 * "ohos.permission.MANAGE_APP_BOOT". 122 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 123 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified; 124 * <br>2. Incorrect parameters types. 125 * @throws { BusinessError } 16000004 - Cannot start an invisible component. 126 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 127 * @throws { BusinessError } 16000050 - Internal error. 128 * @syscap SystemCapability.Ability.AbilityRuntime.Core 129 * @systemapi 130 * @StageModelOnly 131 * @since 11 132 */ 133 function cancelApplicationAutoStartup(info: AutoStartupInfo, callback: AsyncCallback<void>): void; 134 135 /** 136 * Cancel application auto startup state. 137 * 138 * @permission ohos.permission.MANAGE_APP_BOOT 139 * @param { AutoStartupInfo } info - The application info. 140 * @returns { Promise<void> } The promise returned by the function. 141 * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission 142 * "ohos.permission.MANAGE_APP_BOOT". 143 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 144 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified; 145 * <br>2. Incorrect parameters types. 146 * @throws { BusinessError } 16000004 - Cannot start an invisible component. 147 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 148 * @throws { BusinessError } 16000050 - Internal error. 149 * @syscap SystemCapability.Ability.AbilityRuntime.Core 150 * @systemapi 151 * @StageModelOnly 152 * @since 11 153 */ 154 function cancelApplicationAutoStartup(info: AutoStartupInfo): Promise<void>; 155 156 /** 157 * Query the current auto startup status of all applications. 158 * 159 * @permission ohos.permission.MANAGE_APP_BOOT 160 * @param { AsyncCallback<Array<AutoStartupInfo>> } callback - The callback is used to return the array of 161 * AutoStartupInfo. 162 * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission 163 * "ohos.permission.MANAGE_APP_BOOT". 164 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 165 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified; 166 * <br>2. Incorrect parameters types. 167 * @throws { BusinessError } 16000050 - Internal error. 168 * @syscap SystemCapability.Ability.AbilityRuntime.Core 169 * @systemapi 170 * @StageModelOnly 171 * @since 11 172 */ 173 function queryAllAutoStartupApplications(callback: AsyncCallback<Array<AutoStartupInfo>>): void; 174 175 /** 176 * Query the current auto startup status of all applications. 177 * 178 * @permission ohos.permission.MANAGE_APP_BOOT 179 * @returns { Promise<Array<AutoStartupInfo>> } The promise returned by the function. 180 * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission 181 * "ohos.permission.MANAGE_APP_BOOT". 182 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 183 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified; 184 * <br>2. Incorrect parameters types. 185 * @throws { BusinessError } 16000050 - Internal error. 186 * @syscap SystemCapability.Ability.AbilityRuntime.Core 187 * @systemapi 188 * @StageModelOnly 189 * @since 11 190 */ 191 function queryAllAutoStartupApplications(): Promise<Array<AutoStartupInfo>>; 192} 193 194export default autoStartupManager; 195