• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 { AsyncCallback } from './@ohos.base';
22import type { BundleResourceInfo as _BundleResourceInfo } from './bundleManager/BundleResourceInfo';
23import type { LauncherAbilityResourceInfo as _LauncherAbilityResourceInfo } from './bundleManager/LauncherAbilityResourceInfo';
24
25/**
26 * This module is used to obtain bundle resource information of various applications installed on the current device.
27 *
28 * @namespace bundleResourceManager
29 * @syscap SystemCapability.BundleManager.BundleFramework.Resource
30 * @systemapi
31 * @since 11
32 */
33declare namespace bundleResourceManager {
34  /**
35   * Used to query the enumeration value of resource info. Multiple values can be passed in the form.
36   *
37   * @enum { number }
38   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
39   * @systemapi
40   * @since 11
41   */
42  enum ResourceFlag {
43    /**
44     * Used to obtain the resource info contains label and icon.
45     *
46     * @syscap SystemCapability.BundleManager.BundleFramework.Resource
47     * @systemapi
48     * @since 11
49     */
50    GET_RESOURCE_INFO_ALL = 0x00000001,
51
52    /**
53     * Used to obtained the label resource info.
54     *
55     * @syscap SystemCapability.BundleManager.BundleFramework.Resource
56     * @systemapi
57     * @since 11
58     */
59    GET_RESOURCE_INFO_WITH_LABEL = 0x00000002,
60
61    /**
62     * Used to obtained the icon resource info.
63     *
64     * @syscap SystemCapability.BundleManager.BundleFramework.Resource
65     * @systemapi
66     * @since 11
67     */
68    GET_RESOURCE_INFO_WITH_ICON = 0x00000004,
69
70    /**
71     * Used to obtain the resource info sorted by label.
72     * It can't be used alone, it needs to be used with GET_RESOURCE_INFO_ALL or GET_RESOURCE_INFO_WITH_LABEL.
73     *
74     * @syscap SystemCapability.BundleManager.BundleFramework.Resource
75     * @systemapi
76     * @since 11
77     */
78    GET_RESOURCE_INFO_WITH_SORTED_BY_LABEL = 0x00000008,
79
80    /**
81     * Used to obtain bundle icon drawable descriptor.
82     *
83     * @syscap SystemCapability.BundleManager.BundleFramework.Resource
84     * @systemapi
85     * @since 12
86     */
87    GET_RESOURCE_INFO_WITH_DRAWABLE_DESCRIPTOR = 0x00000010
88  }
89
90  /**
91   * Obtains the BundleResourceInfo of a specified bundle. Default resourceFlag is GET_RESOURCE_INFO_ALL.
92   *
93   * @permission ohos.permission.GET_BUNDLE_RESOURCES
94   * @param { string } bundleName - Indicates the bundle name of the application.
95   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the BundleResourceInfo object that will be returned.
96   * @returns { BundleResourceInfo } Returns the BundleResourceInfo object.
97   * @throws { BusinessError } 201 - Permission denied.
98   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
99   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
100   * @throws { BusinessError } 17700001 - The specified bundleName is not found.
101   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
102   * @systemapi
103   * @since 11
104   */
105  function getBundleResourceInfo(bundleName: string, resourceFlags?: number): BundleResourceInfo;
106
107  /**
108   * Obtains the BundleResourceInfo of a specified bundle. Default resourceFlag is GET_RESOURCE_INFO_ALL.
109   *
110   * @permission ohos.permission.GET_BUNDLE_RESOURCES
111   * @param { string } bundleName - Indicates the bundle name of the application.
112   * @param { number } [resourceFlags] - Indicates the flag used to specify information contained in the BundleResourceInfo object that will be returned.
113   * @param { number } [appIndex] - Indicates the index of the bundle.
114   * @returns { BundleResourceInfo } Returns the BundleResourceInfo object.
115   * @throws { BusinessError } 201 - Permission denied.
116   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
117   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
118   * @throws { BusinessError } 17700001 - The specified bundleName is not found.
119   * @throws { BusinessError } 17700061 - AppIndex not in valid range or not found.
120   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
121   * @systemapi
122   * @since 12
123   */
124  function getBundleResourceInfo(bundleName: string, resourceFlags?: number, appIndex?: number): BundleResourceInfo;
125
126  /**
127   * Obtains the LauncherAbilityResourceInfo of a specified bundle. Default resourceFlag is GET_RESOURCE_INFO_ALL.
128   *
129   * @permission ohos.permission.GET_BUNDLE_RESOURCES
130   * @param { string } bundleName - Indicates the bundle name of the application.
131   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the LauncherAbilityResourceInfo object that will be returned.
132   * @returns { Array<LauncherAbilityResourceInfo> } Returns a list of LauncherAbilityResourceInfo objects.
133   * @throws { BusinessError } 201 - Permission denied.
134   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
135   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
136   * @throws { BusinessError } 17700001 - The specified bundleName is not found.
137   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
138   * @systemapi
139   * @since 11
140   */
141  function getLauncherAbilityResourceInfo(bundleName: string, resourceFlags?: number): Array<LauncherAbilityResourceInfo>;
142
143  /**
144   * Obtains the LauncherAbilityResourceInfo of a specified bundle. Default resourceFlag is GET_RESOURCE_INFO_ALL.
145   *
146   * @permission ohos.permission.GET_BUNDLE_RESOURCES
147   * @param { string } bundleName - Indicates the bundle name of the application.
148   * @param { number } [resourceFlags] - Indicates the flag used to specify information
149   * <br>contained in the LauncherAbilityResourceInfo object that will be returned.
150   * @param { number } [appIndex] - Indicates the index of the bundle.
151   * @returns { Array<LauncherAbilityResourceInfo> } Returns a list of LauncherAbilityResourceInfo objects.
152   * @throws { BusinessError } 201 - Permission denied.
153   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
154   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
155   * @throws { BusinessError } 17700001 - The specified bundleName is not found.
156   * @throws { BusinessError } 17700061 - AppIndex not in valid range or not found.
157   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
158   * @systemapi
159   * @since 12
160   */
161  function getLauncherAbilityResourceInfo(bundleName: string, resourceFlags?: number, appIndex?: number): Array<LauncherAbilityResourceInfo>;
162
163  /**
164   * Obtains BundleResourceInfo of all bundles available in the system.
165   *
166   * @permission ohos.permission.GET_INSTALLED_BUNDLE_LIST and ohos.permission.GET_BUNDLE_RESOURCES
167   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the BundleResourceInfo that will be returned.
168   * @param { AsyncCallback<Array<BundleResourceInfo>> } callback - The callback of getting a list of BundleResourceInfo objects.
169   * @throws { BusinessError } 201 - Permission denied.
170   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
171   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
172   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
173   * @systemapi
174   * @since 11
175   */
176  function getAllBundleResourceInfo(resourceFlags: number, callback: AsyncCallback<Array<BundleResourceInfo>>): void;
177
178  /**
179   * Obtains BundleResourceInfo of all bundles available in the system.
180   *
181   * @permission ohos.permission.GET_INSTALLED_BUNDLE_LIST and ohos.permission.GET_BUNDLE_RESOURCES
182   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the BundleResourceInfo that will be returned.
183   * @returns { Promise<Array<BundleResourceInfo>> } Returns a list of BundleResourceInfo objects.
184   * @throws { BusinessError } 201 - Permission denied.
185   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
186   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
187   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
188   * @systemapi
189   * @since 11
190   */
191  function getAllBundleResourceInfo(resourceFlags: number): Promise<Array<BundleResourceInfo>>;
192
193  /**
194   * Obtains LauncherAbilityResourceInfo of all launcher abilities available in the system.
195   *
196   * @permission ohos.permission.GET_INSTALLED_BUNDLE_LIST and ohos.permission.GET_BUNDLE_RESOURCES
197   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the LauncherAbilityResourceInfo that will be returned.
198   * @param { AsyncCallback<Array<LauncherAbilityResourceInfo>> } callback - The callback of getting a list of LauncherAbilityResourceInfo objects.
199   * @throws { BusinessError } 201 - Permission denied.
200   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
201   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
202   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
203   * @systemapi
204   * @since 11
205   */
206  function getAllLauncherAbilityResourceInfo(resourceFlags: number, callback: AsyncCallback<Array<LauncherAbilityResourceInfo>>): void;
207
208  /**
209   * Obtains LauncherAbilityResourceInfo of all launcher abilities available in the system.
210   *
211   * @permission ohos.permission.GET_INSTALLED_BUNDLE_LIST and ohos.permission.GET_BUNDLE_RESOURCES
212   * @param { number } resourceFlags - Indicates the flag used to specify information contained in the LauncherAbilityResourceInfo that will be returned.
213   * @returns { Promise<Array<LauncherAbilityResourceInfo>> } Returns a list of LauncherAbilityResourceInfo objects.
214   * @throws { BusinessError } 201 - Permission denied.
215   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
216   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
217   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
218   * @systemapi
219   * @since 11
220   */
221  function getAllLauncherAbilityResourceInfo(resourceFlags: number): Promise<Array<LauncherAbilityResourceInfo>>;
222
223  /**
224   * Obtains resource info of a bundle.
225   *
226   * @typedef { _BundleResourceInfo }
227   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
228   * @systemapi
229   * @since 11
230   */
231  export type BundleResourceInfo = _BundleResourceInfo;
232
233  /**
234   * Obtains resource info of a ability.
235   *
236   * @typedef { _LauncherAbilityResourceInfo }
237   * @syscap SystemCapability.BundleManager.BundleFramework.Resource
238   * @systemapi
239   * @since 11
240   */
241  export type LauncherAbilityResourceInfo = _LauncherAbilityResourceInfo;
242}
243
244export default bundleResourceManager;
245