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