161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"),
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit AbilityKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport type { AutoStartupCallback } from './application/AutoStartupCallback';
2261847f8eSopenharmony_ciimport type { AutoStartupInfo } from './application/AutoStartupInfo';
2361847f8eSopenharmony_ciimport type { AsyncCallback } from './@ohos.base';
2461847f8eSopenharmony_ci
2561847f8eSopenharmony_ci/**
2661847f8eSopenharmony_ci * The class of auto startup manager.
2761847f8eSopenharmony_ci *
2861847f8eSopenharmony_ci * @namespace autoStartupManager
2961847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core
3061847f8eSopenharmony_ci * @systemapi
3161847f8eSopenharmony_ci * @since 11
3261847f8eSopenharmony_ci */
3361847f8eSopenharmony_cideclare namespace autoStartupManager {
3461847f8eSopenharmony_ci  /**
3561847f8eSopenharmony_ci   * Register the listener that watches for all applications auto startup state.
3661847f8eSopenharmony_ci   *
3761847f8eSopenharmony_ci   * @permission ohos.permission.MANAGE_APP_BOOT
3861847f8eSopenharmony_ci   * @param { 'systemAutoStartup' } type - Indicates the type of event.
3961847f8eSopenharmony_ci   * @param { AutoStartupCallback } callback - Auto startup callback.
4061847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission
4161847f8eSopenharmony_ci   *                                 "ohos.permission.MANAGE_APP_BOOT".
4261847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
4361847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified;
4461847f8eSopenharmony_ci   * <br>2. Incorrect parameters types.
4561847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
4661847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
4761847f8eSopenharmony_ci   * @systemapi
4861847f8eSopenharmony_ci   * @StageModelOnly
4961847f8eSopenharmony_ci   * @since 11
5061847f8eSopenharmony_ci   */
5161847f8eSopenharmony_ci  function on(type: 'systemAutoStartup', callback: AutoStartupCallback): void;
5261847f8eSopenharmony_ci
5361847f8eSopenharmony_ci  /**
5461847f8eSopenharmony_ci   * Unregister listener that watches for all applications auto startup state.
5561847f8eSopenharmony_ci   *
5661847f8eSopenharmony_ci   * @permission ohos.permission.MANAGE_APP_BOOT
5761847f8eSopenharmony_ci   * @param { 'systemAutoStartup' } type - Indicates the type of event.
5861847f8eSopenharmony_ci   * @param { AutoStartupCallback } [callback] - Auto startup callback.
5961847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission
6061847f8eSopenharmony_ci   *                                 "ohos.permission.MANAGE_APP_BOOT".
6161847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
6261847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified;
6361847f8eSopenharmony_ci   * <br>2. Incorrect parameters types.
6461847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
6561847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
6661847f8eSopenharmony_ci   * @systemapi
6761847f8eSopenharmony_ci   * @StageModelOnly
6861847f8eSopenharmony_ci   * @since 11
6961847f8eSopenharmony_ci   */
7061847f8eSopenharmony_ci  function off(type: 'systemAutoStartup', callback?: AutoStartupCallback): void;
7161847f8eSopenharmony_ci
7261847f8eSopenharmony_ci  /**
7361847f8eSopenharmony_ci   * Set application auto startup state.
7461847f8eSopenharmony_ci   *
7561847f8eSopenharmony_ci   * @permission ohos.permission.MANAGE_APP_BOOT
7661847f8eSopenharmony_ci   * @param { AutoStartupInfo } info - The application info.
7761847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of setApplicationAutoStartup.
7861847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission
7961847f8eSopenharmony_ci   *                                 "ohos.permission.MANAGE_APP_BOOT".
8061847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
8161847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified;
8261847f8eSopenharmony_ci   * <br>2. Incorrect parameters types.
8361847f8eSopenharmony_ci   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
8461847f8eSopenharmony_ci   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
8561847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
8661847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
8761847f8eSopenharmony_ci   * @systemapi
8861847f8eSopenharmony_ci   * @StageModelOnly
8961847f8eSopenharmony_ci   * @since 11
9061847f8eSopenharmony_ci   */
9161847f8eSopenharmony_ci  function setApplicationAutoStartup(info: AutoStartupInfo, callback: AsyncCallback<void>): void;
9261847f8eSopenharmony_ci
9361847f8eSopenharmony_ci  /**
9461847f8eSopenharmony_ci   * Set application auto startup state.
9561847f8eSopenharmony_ci   *
9661847f8eSopenharmony_ci   * @permission ohos.permission.MANAGE_APP_BOOT
9761847f8eSopenharmony_ci   * @param { AutoStartupInfo } info - The application info.
9861847f8eSopenharmony_ci   * @returns { Promise<void> } The promise returned by the function.
9961847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission
10061847f8eSopenharmony_ci   *                                 "ohos.permission.MANAGE_APP_BOOT".
10161847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
10261847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified;
10361847f8eSopenharmony_ci   * <br>2. Incorrect parameters types.
10461847f8eSopenharmony_ci   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
10561847f8eSopenharmony_ci   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
10661847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
10761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
10861847f8eSopenharmony_ci   * @systemapi
10961847f8eSopenharmony_ci   * @StageModelOnly
11061847f8eSopenharmony_ci   * @since 11
11161847f8eSopenharmony_ci   */
11261847f8eSopenharmony_ci  function setApplicationAutoStartup(info: AutoStartupInfo): Promise<void>;
11361847f8eSopenharmony_ci
11461847f8eSopenharmony_ci  /**
11561847f8eSopenharmony_ci   * Cancel application auto startup state.
11661847f8eSopenharmony_ci   *
11761847f8eSopenharmony_ci   * @permission ohos.permission.MANAGE_APP_BOOT
11861847f8eSopenharmony_ci   * @param { AutoStartupInfo } info - The application info.
11961847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of cancelApplicationAutoStartup.
12061847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission
12161847f8eSopenharmony_ci   *                                 "ohos.permission.MANAGE_APP_BOOT".
12261847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
12361847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified;
12461847f8eSopenharmony_ci   * <br>2. Incorrect parameters types.
12561847f8eSopenharmony_ci   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
12661847f8eSopenharmony_ci   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
12761847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
12861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
12961847f8eSopenharmony_ci   * @systemapi
13061847f8eSopenharmony_ci   * @StageModelOnly
13161847f8eSopenharmony_ci   * @since 11
13261847f8eSopenharmony_ci   */
13361847f8eSopenharmony_ci  function cancelApplicationAutoStartup(info: AutoStartupInfo, callback: AsyncCallback<void>): void;
13461847f8eSopenharmony_ci
13561847f8eSopenharmony_ci  /**
13661847f8eSopenharmony_ci   * Cancel application auto startup state.
13761847f8eSopenharmony_ci   *
13861847f8eSopenharmony_ci   * @permission ohos.permission.MANAGE_APP_BOOT
13961847f8eSopenharmony_ci   * @param { AutoStartupInfo } info - The application info.
14061847f8eSopenharmony_ci   * @returns { Promise<void> } The promise returned by the function.
14161847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission
14261847f8eSopenharmony_ci   *                                 "ohos.permission.MANAGE_APP_BOOT".
14361847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
14461847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified;
14561847f8eSopenharmony_ci   * <br>2. Incorrect parameters types.
14661847f8eSopenharmony_ci   * @throws { BusinessError } 16000004 - Failed to start the invisible ability.
14761847f8eSopenharmony_ci   * @throws { BusinessError } 16000013 - The application is controlled by EDM.
14861847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
14961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
15061847f8eSopenharmony_ci   * @systemapi
15161847f8eSopenharmony_ci   * @StageModelOnly
15261847f8eSopenharmony_ci   * @since 11
15361847f8eSopenharmony_ci   */
15461847f8eSopenharmony_ci  function cancelApplicationAutoStartup(info: AutoStartupInfo): Promise<void>;
15561847f8eSopenharmony_ci
15661847f8eSopenharmony_ci  /**
15761847f8eSopenharmony_ci   * Query the current auto startup status of all applications.
15861847f8eSopenharmony_ci   *
15961847f8eSopenharmony_ci   * @permission ohos.permission.MANAGE_APP_BOOT
16061847f8eSopenharmony_ci   * @param { AsyncCallback<Array<AutoStartupInfo>> } callback - The callback is used to return the array of
16161847f8eSopenharmony_ci   *                                                             AutoStartupInfo.
16261847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission
16361847f8eSopenharmony_ci   *                                 "ohos.permission.MANAGE_APP_BOOT".
16461847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
16561847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified;
16661847f8eSopenharmony_ci   * <br>2. Incorrect parameters types.
16761847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
16861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
16961847f8eSopenharmony_ci   * @systemapi
17061847f8eSopenharmony_ci   * @StageModelOnly
17161847f8eSopenharmony_ci   * @since 11
17261847f8eSopenharmony_ci   */
17361847f8eSopenharmony_ci  function queryAllAutoStartupApplications(callback: AsyncCallback<Array<AutoStartupInfo>>): void;
17461847f8eSopenharmony_ci
17561847f8eSopenharmony_ci  /**
17661847f8eSopenharmony_ci   * Query the current auto startup status of all applications.
17761847f8eSopenharmony_ci   *
17861847f8eSopenharmony_ci   * @permission ohos.permission.MANAGE_APP_BOOT
17961847f8eSopenharmony_ci   * @returns { Promise<Array<AutoStartupInfo>> } The promise returned by the function.
18061847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied, interface caller does not have permission
18161847f8eSopenharmony_ci   *                                 "ohos.permission.MANAGE_APP_BOOT".
18261847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
18361847f8eSopenharmony_ci   * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1. Mandatory parameters are left unspecified;
18461847f8eSopenharmony_ci   * <br>2. Incorrect parameters types.
18561847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
18661847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
18761847f8eSopenharmony_ci   * @systemapi
18861847f8eSopenharmony_ci   * @StageModelOnly
18961847f8eSopenharmony_ci   * @since 11
19061847f8eSopenharmony_ci   */
19161847f8eSopenharmony_ci  function queryAllAutoStartupApplications(): Promise<Array<AutoStartupInfo>>;
19261847f8eSopenharmony_ci}
19361847f8eSopenharmony_ci
19461847f8eSopenharmony_ciexport default autoStartupManager;
195