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 { AsyncCallback } from './@ohos.base';
2261847f8eSopenharmony_ciimport type { BundleResourceInfo as _BundleResourceInfo } from './bundleManager/BundleResourceInfo';
2361847f8eSopenharmony_ciimport type { LauncherAbilityResourceInfo as _LauncherAbilityResourceInfo } from './bundleManager/LauncherAbilityResourceInfo';
2461847f8eSopenharmony_ci
2561847f8eSopenharmony_ci/**
2661847f8eSopenharmony_ci * This module is used to obtain bundle resource information of various applications installed on the current device.
2761847f8eSopenharmony_ci *
2861847f8eSopenharmony_ci * @namespace bundleResourceManager
2961847f8eSopenharmony_ci * @syscap SystemCapability.BundleManager.BundleFramework.Resource
3061847f8eSopenharmony_ci * @systemapi
3161847f8eSopenharmony_ci * @since 11
3261847f8eSopenharmony_ci */
3361847f8eSopenharmony_cideclare namespace bundleResourceManager {
3461847f8eSopenharmony_ci  /**
3561847f8eSopenharmony_ci   * Used to query the enumeration value of resource info. Multiple values can be passed in the form.
3661847f8eSopenharmony_ci   *
3761847f8eSopenharmony_ci   * @enum { number }
3861847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
3961847f8eSopenharmony_ci   * @systemapi
4061847f8eSopenharmony_ci   * @since 11
4161847f8eSopenharmony_ci   */
4261847f8eSopenharmony_ci  enum ResourceFlag {
4361847f8eSopenharmony_ci    /**
4461847f8eSopenharmony_ci     * Used to obtain the resource info contains label and icon.
4561847f8eSopenharmony_ci     *
4661847f8eSopenharmony_ci     * @syscap SystemCapability.BundleManager.BundleFramework.Resource
4761847f8eSopenharmony_ci     * @systemapi
4861847f8eSopenharmony_ci     * @since 11
4961847f8eSopenharmony_ci     */
5061847f8eSopenharmony_ci    GET_RESOURCE_INFO_ALL = 0x00000001,
5161847f8eSopenharmony_ci
5261847f8eSopenharmony_ci    /**
5361847f8eSopenharmony_ci     * Used to obtained the label resource info.
5461847f8eSopenharmony_ci     *
5561847f8eSopenharmony_ci     * @syscap SystemCapability.BundleManager.BundleFramework.Resource
5661847f8eSopenharmony_ci     * @systemapi
5761847f8eSopenharmony_ci     * @since 11
5861847f8eSopenharmony_ci     */
5961847f8eSopenharmony_ci    GET_RESOURCE_INFO_WITH_LABEL = 0x00000002,
6061847f8eSopenharmony_ci
6161847f8eSopenharmony_ci    /**
6261847f8eSopenharmony_ci     * Used to obtained the icon resource info.
6361847f8eSopenharmony_ci     *
6461847f8eSopenharmony_ci     * @syscap SystemCapability.BundleManager.BundleFramework.Resource
6561847f8eSopenharmony_ci     * @systemapi
6661847f8eSopenharmony_ci     * @since 11
6761847f8eSopenharmony_ci     */
6861847f8eSopenharmony_ci    GET_RESOURCE_INFO_WITH_ICON = 0x00000004,
6961847f8eSopenharmony_ci
7061847f8eSopenharmony_ci    /**
7161847f8eSopenharmony_ci     * Used to obtain the resource info sorted by label.
7261847f8eSopenharmony_ci     * It can't be used alone, it needs to be used with GET_RESOURCE_INFO_ALL or GET_RESOURCE_INFO_WITH_LABEL.
7361847f8eSopenharmony_ci     *
7461847f8eSopenharmony_ci     * @syscap SystemCapability.BundleManager.BundleFramework.Resource
7561847f8eSopenharmony_ci     * @systemapi
7661847f8eSopenharmony_ci     * @since 11
7761847f8eSopenharmony_ci     */
7861847f8eSopenharmony_ci    GET_RESOURCE_INFO_WITH_SORTED_BY_LABEL = 0x00000008,
7961847f8eSopenharmony_ci
8061847f8eSopenharmony_ci    /**
8161847f8eSopenharmony_ci     * Used to obtain bundle icon drawable descriptor.
8261847f8eSopenharmony_ci     *
8361847f8eSopenharmony_ci     * @syscap SystemCapability.BundleManager.BundleFramework.Resource
8461847f8eSopenharmony_ci     * @systemapi
8561847f8eSopenharmony_ci     * @since 12
8661847f8eSopenharmony_ci     */
8761847f8eSopenharmony_ci    GET_RESOURCE_INFO_WITH_DRAWABLE_DESCRIPTOR = 0x00000010
8861847f8eSopenharmony_ci  }
8961847f8eSopenharmony_ci
9061847f8eSopenharmony_ci  /**
9161847f8eSopenharmony_ci   * Obtains the BundleResourceInfo of a specified bundle. Default resourceFlag is GET_RESOURCE_INFO_ALL.
9261847f8eSopenharmony_ci   *
9361847f8eSopenharmony_ci   * @permission ohos.permission.GET_BUNDLE_RESOURCES
9461847f8eSopenharmony_ci   * @param { string } bundleName - Indicates the bundle name of the application.
9561847f8eSopenharmony_ci   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the BundleResourceInfo object that will be returned.
9661847f8eSopenharmony_ci   * @returns { BundleResourceInfo } Returns the BundleResourceInfo object.
9761847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
9861847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
9961847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
10061847f8eSopenharmony_ci   * @throws { BusinessError } 17700001 - The specified bundleName is not found.
10161847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
10261847f8eSopenharmony_ci   * @systemapi
10361847f8eSopenharmony_ci   * @since 11
10461847f8eSopenharmony_ci   */
10561847f8eSopenharmony_ci  function getBundleResourceInfo(bundleName: string, resourceFlags?: number): BundleResourceInfo;
10661847f8eSopenharmony_ci
10761847f8eSopenharmony_ci  /**
10861847f8eSopenharmony_ci   * Obtains the BundleResourceInfo of a specified bundle. Default resourceFlag is GET_RESOURCE_INFO_ALL.
10961847f8eSopenharmony_ci   *
11061847f8eSopenharmony_ci   * @permission ohos.permission.GET_BUNDLE_RESOURCES
11161847f8eSopenharmony_ci   * @param { string } bundleName - Indicates the bundle name of the application.
11261847f8eSopenharmony_ci   * @param { number } [resourceFlags] - Indicates the flag used to specify information contained in the BundleResourceInfo object that will be returned.
11361847f8eSopenharmony_ci   * @param { number } [appIndex] - Indicates the index of the bundle.
11461847f8eSopenharmony_ci   * @returns { BundleResourceInfo } Returns the BundleResourceInfo object.
11561847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
11661847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
11761847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
11861847f8eSopenharmony_ci   * @throws { BusinessError } 17700001 - The specified bundleName is not found.
11961847f8eSopenharmony_ci   * @throws { BusinessError } 17700061 - AppIndex not in valid range or not found.
12061847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
12161847f8eSopenharmony_ci   * @systemapi
12261847f8eSopenharmony_ci   * @since 12
12361847f8eSopenharmony_ci   */
12461847f8eSopenharmony_ci  function getBundleResourceInfo(bundleName: string, resourceFlags?: number, appIndex?: number): BundleResourceInfo;
12561847f8eSopenharmony_ci
12661847f8eSopenharmony_ci  /**
12761847f8eSopenharmony_ci   * Obtains the LauncherAbilityResourceInfo of a specified bundle. Default resourceFlag is GET_RESOURCE_INFO_ALL.
12861847f8eSopenharmony_ci   *
12961847f8eSopenharmony_ci   * @permission ohos.permission.GET_BUNDLE_RESOURCES
13061847f8eSopenharmony_ci   * @param { string } bundleName - Indicates the bundle name of the application.
13161847f8eSopenharmony_ci   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the LauncherAbilityResourceInfo object that will be returned.
13261847f8eSopenharmony_ci   * @returns { Array<LauncherAbilityResourceInfo> } Returns a list of LauncherAbilityResourceInfo objects.
13361847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
13461847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
13561847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
13661847f8eSopenharmony_ci   * @throws { BusinessError } 17700001 - The specified bundleName is not found.
13761847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
13861847f8eSopenharmony_ci   * @systemapi
13961847f8eSopenharmony_ci   * @since 11
14061847f8eSopenharmony_ci   */
14161847f8eSopenharmony_ci  function getLauncherAbilityResourceInfo(bundleName: string, resourceFlags?: number): Array<LauncherAbilityResourceInfo>;
14261847f8eSopenharmony_ci
14361847f8eSopenharmony_ci  /**
14461847f8eSopenharmony_ci   * Obtains the LauncherAbilityResourceInfo of a specified bundle. Default resourceFlag is GET_RESOURCE_INFO_ALL.
14561847f8eSopenharmony_ci   *
14661847f8eSopenharmony_ci   * @permission ohos.permission.GET_BUNDLE_RESOURCES
14761847f8eSopenharmony_ci   * @param { string } bundleName - Indicates the bundle name of the application.
14861847f8eSopenharmony_ci   * @param { number } [resourceFlags] - Indicates the flag used to specify information
14961847f8eSopenharmony_ci   * <br>contained in the LauncherAbilityResourceInfo object that will be returned.
15061847f8eSopenharmony_ci   * @param { number } [appIndex] - Indicates the index of the bundle.
15161847f8eSopenharmony_ci   * @returns { Array<LauncherAbilityResourceInfo> } Returns a list of LauncherAbilityResourceInfo objects.
15261847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
15361847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
15461847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
15561847f8eSopenharmony_ci   * @throws { BusinessError } 17700001 - The specified bundleName is not found.
15661847f8eSopenharmony_ci   * @throws { BusinessError } 17700061 - AppIndex not in valid range or not found.
15761847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
15861847f8eSopenharmony_ci   * @systemapi
15961847f8eSopenharmony_ci   * @since 12
16061847f8eSopenharmony_ci   */
16161847f8eSopenharmony_ci  function getLauncherAbilityResourceInfo(bundleName: string, resourceFlags?: number, appIndex?: number): Array<LauncherAbilityResourceInfo>;
16261847f8eSopenharmony_ci
16361847f8eSopenharmony_ci  /**
16461847f8eSopenharmony_ci   * Obtains BundleResourceInfo of all bundles available in the system.
16561847f8eSopenharmony_ci   *
16661847f8eSopenharmony_ci   * @permission ohos.permission.GET_INSTALLED_BUNDLE_LIST and ohos.permission.GET_BUNDLE_RESOURCES
16761847f8eSopenharmony_ci   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the BundleResourceInfo that will be returned.
16861847f8eSopenharmony_ci   * @param { AsyncCallback<Array<BundleResourceInfo>> } callback - The callback of getting a list of BundleResourceInfo objects.
16961847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
17061847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
17161847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
17261847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
17361847f8eSopenharmony_ci   * @systemapi
17461847f8eSopenharmony_ci   * @since 11
17561847f8eSopenharmony_ci   */
17661847f8eSopenharmony_ci  function getAllBundleResourceInfo(resourceFlags: number, callback: AsyncCallback<Array<BundleResourceInfo>>): void;
17761847f8eSopenharmony_ci
17861847f8eSopenharmony_ci  /**
17961847f8eSopenharmony_ci   * Obtains BundleResourceInfo of all bundles available in the system.
18061847f8eSopenharmony_ci   *
18161847f8eSopenharmony_ci   * @permission ohos.permission.GET_INSTALLED_BUNDLE_LIST and ohos.permission.GET_BUNDLE_RESOURCES
18261847f8eSopenharmony_ci   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the BundleResourceInfo that will be returned.
18361847f8eSopenharmony_ci   * @returns { Promise<Array<BundleResourceInfo>> } Returns a list of BundleResourceInfo objects.
18461847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
18561847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
18661847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
18761847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
18861847f8eSopenharmony_ci   * @systemapi
18961847f8eSopenharmony_ci   * @since 11
19061847f8eSopenharmony_ci   */
19161847f8eSopenharmony_ci  function getAllBundleResourceInfo(resourceFlags: number): Promise<Array<BundleResourceInfo>>;
19261847f8eSopenharmony_ci
19361847f8eSopenharmony_ci  /**
19461847f8eSopenharmony_ci   * Obtains LauncherAbilityResourceInfo of all launcher abilities available in the system.
19561847f8eSopenharmony_ci   *
19661847f8eSopenharmony_ci   * @permission ohos.permission.GET_INSTALLED_BUNDLE_LIST and ohos.permission.GET_BUNDLE_RESOURCES
19761847f8eSopenharmony_ci   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the LauncherAbilityResourceInfo that will be returned.
19861847f8eSopenharmony_ci   * @param { AsyncCallback<Array<LauncherAbilityResourceInfo>> } callback - The callback of getting a list of LauncherAbilityResourceInfo objects.
19961847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
20061847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
20161847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
20261847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
20361847f8eSopenharmony_ci   * @systemapi
20461847f8eSopenharmony_ci   * @since 11
20561847f8eSopenharmony_ci   */
20661847f8eSopenharmony_ci  function getAllLauncherAbilityResourceInfo(resourceFlags: number, callback: AsyncCallback<Array<LauncherAbilityResourceInfo>>): void;
20761847f8eSopenharmony_ci
20861847f8eSopenharmony_ci  /**
20961847f8eSopenharmony_ci   * Obtains LauncherAbilityResourceInfo of all launcher abilities available in the system.
21061847f8eSopenharmony_ci   *
21161847f8eSopenharmony_ci   * @permission ohos.permission.GET_INSTALLED_BUNDLE_LIST and ohos.permission.GET_BUNDLE_RESOURCES
21261847f8eSopenharmony_ci   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the LauncherAbilityResourceInfo that will be returned.
21361847f8eSopenharmony_ci   * @returns { Promise<Array<LauncherAbilityResourceInfo>> } Returns a list of LauncherAbilityResourceInfo objects.
21461847f8eSopenharmony_ci   * @throws { BusinessError } 201 - Permission denied.
21561847f8eSopenharmony_ci   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
21661847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
21761847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
21861847f8eSopenharmony_ci   * @systemapi
21961847f8eSopenharmony_ci   * @since 11
22061847f8eSopenharmony_ci   */
22161847f8eSopenharmony_ci  function getAllLauncherAbilityResourceInfo(resourceFlags: number): Promise<Array<LauncherAbilityResourceInfo>>;
22261847f8eSopenharmony_ci
22361847f8eSopenharmony_ci  /**
22461847f8eSopenharmony_ci   * Obtains resource info of a bundle.
22561847f8eSopenharmony_ci   *
22661847f8eSopenharmony_ci   * @typedef { _BundleResourceInfo }
22761847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
22861847f8eSopenharmony_ci   * @systemapi
22961847f8eSopenharmony_ci   * @since 11
23061847f8eSopenharmony_ci   */
23161847f8eSopenharmony_ci  export type BundleResourceInfo = _BundleResourceInfo;
23261847f8eSopenharmony_ci
23361847f8eSopenharmony_ci  /**
23461847f8eSopenharmony_ci   * Obtains resource info of a ability.
23561847f8eSopenharmony_ci   *
23661847f8eSopenharmony_ci   * @typedef { _LauncherAbilityResourceInfo }
23761847f8eSopenharmony_ci   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
23861847f8eSopenharmony_ci   * @systemapi
23961847f8eSopenharmony_ci   * @since 11
24061847f8eSopenharmony_ci   */
24161847f8eSopenharmony_ci  export type LauncherAbilityResourceInfo = _LauncherAbilityResourceInfo;
24261847f8eSopenharmony_ci}
24361847f8eSopenharmony_ci
24461847f8eSopenharmony_ciexport default bundleResourceManager;
245