1/* 2 * Copyright (c) 2022 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 { AsyncCallback } from './@ohos.base'; 22import { LauncherAbilityInfo as _LauncherAbilityInfo } from './bundleManager/LauncherAbilityInfo'; 23/*** if arkts 1.1 */ 24import AbilityConstant from './@ohos.app.ability.AbilityConstant'; 25/*** endif */ 26import { ShortcutInfo as _ShortcutInfo, ShortcutWant as _ShortcutWant, ParameterItem as _ParameterItem } from './bundleManager/ShortcutInfo'; 27import StartOptions from './@ohos.app.ability.StartOptions'; 28 29/** 30 * Launcher bundle manager. 31 * 32 * @namespace launcherBundleManager 33 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 34 * @since arkts {'1.1':'18', '1.2':'20'} 35 * @arkts 1.1&1.2 36 */ 37declare namespace launcherBundleManager { 38 /** 39 * Obtains launcher abilities info based on a given bundleName and userId. 40 * 41 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 42 * @param { string } bundleName - Indicates the application bundle name to be queried. 43 * @param { number } userId - Indicates the id for the user. 44 * @param { AsyncCallback<Array<LauncherAbilityInfo>> } callback -The callback of the LauncherAbilityInfo object result. 45 * @throws { BusinessError } 201 - Verify permission denied. 46 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 47 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 48 * @throws { BusinessError } 801 - Capability not support. 49 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 50 * @throws { BusinessError } 17700004 - The specified user ID is not found. 51 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 52 * @systemapi 53 * @since arkts {'1.1':'9', '1.2':'20'} 54 * @arkts 1.1&1.2 55 */ 56 function getLauncherAbilityInfo(bundleName: string, 57 userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>): void; 58 59 /** 60 * Obtains launcher abilities info based on a given bundleName and userId. 61 * 62 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 63 * @param { string } bundleName - Indicates the application bundle name to be queried. 64 * @param { number } userId - Indicates the id for the user. 65 * @returns { Promise<Array<LauncherAbilityInfo>> } the LauncherAbilityInfo object. 66 * @throws { BusinessError } 201 - Verify permission denied. 67 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 68 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 69 * @throws { BusinessError } 801 - Capability not support. 70 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 71 * @throws { BusinessError } 17700004 - The specified user ID is not found. 72 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 73 * @systemapi 74 * @since arkts {'1.1':'9', '1.2':'20'} 75 * @arkts 1.1&1.2 76 */ 77 function getLauncherAbilityInfo(bundleName: string, userId: number): Promise<Array<LauncherAbilityInfo>>; 78 79 /** 80 * Obtains launcher abilities info based on a given bundleName and userId. 81 * 82 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 83 * @param { string } bundleName - Indicates the application bundle name to be queried. 84 * @param { number } userId - Indicates the id for the user. 85 * @returns { Array<LauncherAbilityInfo> } the LauncherAbilityInfo object. 86 * @throws { BusinessError } 201 - Verify permission denied. 87 * @throws { BusinessError } 801 - Capability not support. 88 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 89 * @throws { BusinessError } 17700004 - The specified user ID is not found. 90 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 91 * @since arkts {'1.1':'18', '1.2':'20'} 92 * @arkts 1.1&1.2 93 */ 94 function getLauncherAbilityInfoSync(bundleName: string, userId: number): Array<LauncherAbilityInfo>; 95 96 /** 97 * Obtains launcher abilities info based on a given userId. 98 * 99 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 100 * @param { number } userId - Indicates the id for the user. 101 * @param { AsyncCallback<Array<LauncherAbilityInfo>> } callback -The callback of the LauncherAbilityInfo object result. 102 * @throws { BusinessError } 201 - Verify permission denied. 103 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 104 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 105 * @throws { BusinessError } 801 - Capability not support. 106 * @throws { BusinessError } 17700004 - The specified user ID is not found. 107 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 108 * @systemapi 109 * @since arkts {'1.1':'9', '1.2':'20'} 110 * @arkts 1.1&1.2 111 */ 112 function getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>): void; 113 114 /** 115 * Obtains launcher abilities info based on a given userId. 116 * 117 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 118 * @param { number } userId - Indicates the id for the user. 119 * @returns { Promise<Array<LauncherAbilityInfo>> } the LauncherAbilityInfo object. 120 * @throws { BusinessError } 201 - Verify permission denied. 121 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 122 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 123 * @throws { BusinessError } 801 - Capability not support. 124 * @throws { BusinessError } 17700004 - The specified user ID is not found. 125 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 126 * @systemapi 127 * @since arkts {'1.1':'9', '1.2':'20'} 128 * @arkts 1.1&1.2 129 */ 130 function getAllLauncherAbilityInfo(userId: number): Promise<Array<LauncherAbilityInfo>>; 131 132 /** 133 * Obtains shortcut info based on a given bundleName. 134 * 135 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 136 * @param { string } bundleName - Indicates the application bundle name to be queried. 137 * @param { AsyncCallback<Array<ShortcutInfo>> } callback -The callback of the ShortcutInfo object result. 138 * @throws { BusinessError } 201 - Verify permission denied. 139 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 140 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 141 * @throws { BusinessError } 801 - Capability not support. 142 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 143 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 144 * @systemapi 145 * @since arkts {'1.1':'9', '1.2':'20'} 146 * @arkts 1.1&1.2 147 */ 148 function getShortcutInfo(bundleName: string, callback: AsyncCallback<Array<ShortcutInfo>>): void; 149 150 /** 151 * Obtains shortcut info based on a given bundleName. 152 * 153 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 154 * @param { string } bundleName - Indicates the application bundle name to be queried. 155 * @returns { Promise<Array<ShortcutInfo>> } the LauncherShortcutInfo object. 156 * @throws { BusinessError } 201 - Verify permission denied. 157 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 158 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 159 * @throws { BusinessError } 801 - Capability not support. 160 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 161 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 162 * @systemapi 163 * @since arkts {'1.1':'9', '1.2':'20'} 164 * @arkts 1.1&1.2 165 */ 166 function getShortcutInfo(bundleName: string): Promise<Array<ShortcutInfo>>; 167 168 /** 169 * Obtains shortcut info based on a given bundleName. 170 * 171 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 172 * @param { string } bundleName - Indicates the application bundle name to be queried. 173 * @returns { Array<ShortcutInfo> } the LauncherShortcutInfo object. 174 * @throws { BusinessError } 201 - Verify permission denied. 175 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 176 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 177 * @throws { BusinessError } 801 - Capability not support. 178 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 179 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 180 * @systemapi 181 * @since arkts {'1.1':'10', '1.2':'20'} 182 * @arkts 1.1&1.2 183 */ 184 function getShortcutInfoSync(bundleName: string): Array<ShortcutInfo>; 185 186 187 /** 188 * Obtains shortcut info based on bundleName and userId. 189 * 190 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 191 * @param { string } bundleName - Indicates the application bundle name to be queried. 192 * @param { number } userId - Indicates the user ID. 193 * @returns { Array<ShortcutInfo> } the LauncherShortcutInfo object. 194 * @throws { BusinessError } 201 - Verify permission denied. 195 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 196 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 197 * @throws { BusinessError } 801 - Capability not support. 198 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 199 * @throws { BusinessError } 17700004 - The specified user ID is not found. 200 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 201 * @systemapi 202 * @since arkts {'1.1':'13', '1.2':'20'} 203 * @arkts 1.1&1.2 204 */ 205 function getShortcutInfoSync(bundleName: string, userId: number): Array<ShortcutInfo>; 206 207 /** 208 * Obtains shortcut info based on bundleName and appIndex. 209 * 210 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 211 * @param { string } bundleName - Indicates the application bundle name to be queried. 212 * @param { number } appIndex - Indicates the index of clone app. 213 * @returns { Array<ShortcutInfo> } the ShortcutInfo object. 214 * @throws { BusinessError } 201 - Verify permission denied. 215 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 216 * @throws { BusinessError } 801 - Capability not support. 217 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 218 * @throws { BusinessError } 17700061 - The specified app index is invalid. 219 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 220 * @systemapi 221 * @since 20 222 */ 223 function getShortcutInfoByAppIndex(bundleName: string, appIndex: number): Array<ShortcutInfo>; 224 225 /** 226 * Starts shortcut. 227 * 228 * @permission ohos.permission.START_SHORTCUT 229 * @param { ShortcutInfo } shortcutInfo - Indicates the shortcut info which contains shortcut want. 230 * @param { StartOptions } [options] - Indicates the start options. 231 * @returns { Promise<void> } the promise returned by the function. 232 * @throws { BusinessError } 201 - Verify permission denied. 233 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 234 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 235 * @throws { BusinessError } 801 - Capability not support. 236 * @throws { BusinessError } 17700065 - The specified shortcut want in shortcut info is not supported to be started. 237 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 238 * @systemapi 239 * @since arkts {'1.1':'12', '1.2':'20'} 240 * @arkts 1.1&1.2 241 */ 242 function startShortcut(shortcutInfo: ShortcutInfo, options?: StartOptions): Promise<void>; 243 244 /** 245 * Starts shortcut with start reason. 246 * 247 * @permission ohos.permission.START_SHORTCUT and ohos.permission.SET_LAUNCH_REASON_MESSAGE 248 * @param { ShortcutInfo } shortcutInfo - Indicates the shortcut info which contains shortcut want. 249 * @param { string } startReason {@link AbilityConstant} - Indicates the start reason. 250 * @param { StartOptions } [options] - Indicates the start options. 251 * @returns { Promise<void> } the promise returned by the function. 252 * @throws { BusinessError } 201 - Verify permission denied. 253 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 254 * @throws { BusinessError } 801 - Capability not support. 255 * @throws { BusinessError } 17700065 - The specified shortcut want in shortcut info is not supported to be started. 256 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 257 * @systemapi 258 * @since 20 259 */ 260 function startShortcutWithReason(shortcutInfo: ShortcutInfo, startReason: string, options?: StartOptions): Promise<void>; 261 262 /** 263 * Contains basic launcher Ability information, which uniquely identifies an LauncherAbilityInfo. 264 * 265 * @typedef { _LauncherAbilityInfo } 266 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 267 * @since arkts {'1.1':'18', '1.2':'20'} 268 * @arkts 1.1&1.2 269 */ 270 export type LauncherAbilityInfo = _LauncherAbilityInfo; 271 272 /** 273 * Provides information about a shortcut, including the shortcut ID and label. 274 * 275 * @typedef { _ShortcutInfo } 276 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 277 * @systemapi 278 * @since 9 279 */ 280 /** 281 * Provides information about a shortcut, including the shortcut ID and label. 282 * 283 * @typedef { _ShortcutInfo } 284 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 285 * @since 20 286 * @arkts 1.1&1.2 287 */ 288 export type ShortcutInfo = _ShortcutInfo; 289 /** 290 * Obtains information about the ability that a shortcut will start. 291 * 292 * @typedef { _ShortcutWant } 293 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 294 * @systemapi 295 * @since 9 296 */ 297 /** 298 * Obtains information about the ability that a shortcut will start. 299 * 300 * @typedef { _ShortcutWant } 301 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 302 * @since 20 303 * @arkts 1.1&1.2 304 */ 305 export type ShortcutWant = _ShortcutWant; 306 /** 307 * Indicates the custom parameters in shortcut want. 308 * 309 * @typedef { _ParameterItem } 310 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 311 * @systemapi 312 * @since 12 313 */ 314 /** 315 * Indicates the custom parameters in shortcut want. 316 * 317 * @typedef { _ParameterItem } 318 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher 319 * @since 20 320 * @arkts 1.1&1.2 321 */ 322 export type ParameterItem = _ParameterItem; 323} 324 325export default launcherBundleManager; 326