• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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';
23import { ShortcutInfo as _ShortcutInfo, ShortcutWant as _ShortcutWant, ParameterItem as _ParameterItem } from './bundleManager/ShortcutInfo';
24import { StartOptions } from './@ohos.app.ability.StartOptions';
25
26/**
27 * Launcher bundle manager.
28 *
29 * @namespace launcherBundleManager
30 * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
31 * @systemapi
32 * @since 9
33 */
34declare namespace launcherBundleManager {
35  /**
36   * Obtains launcher abilities info based on a given bundleName and userId.
37   *
38   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
39   * @param { string } bundleName - Indicates the application bundle name to be queried.
40   * @param { number } userId - Indicates the id for the user.
41   * @param { AsyncCallback<Array<LauncherAbilityInfo>> } callback -The callback of the LauncherAbilityInfo object result.
42   * @throws { BusinessError } 201 - Verify permission denied.
43   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
44   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
45   * @throws { BusinessError } 801 - Capability not support.
46   * @throws { BusinessError } 17700001 - The specified bundle name is not found.
47   * @throws { BusinessError } 17700004 - The specified user ID is not found.
48   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
49   * @systemapi
50   * @since 9
51   */
52  function getLauncherAbilityInfo(bundleName: string,
53    userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>): void;
54
55  /**
56   * Obtains launcher abilities info based on a given bundleName and userId.
57   *
58   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
59   * @param { string } bundleName - Indicates the application bundle name to be queried.
60   * @param { number } userId - Indicates the id for the user.
61   * @returns { Promise<Array<LauncherAbilityInfo>> } the LauncherAbilityInfo object.
62   * @throws { BusinessError } 201 - Verify permission denied.
63   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
64   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
65   * @throws { BusinessError } 801 - Capability not support.
66   * @throws { BusinessError } 17700001 - The specified bundle name is not found.
67   * @throws { BusinessError } 17700004 - The specified user ID is not found.
68   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
69   * @systemapi
70   * @since 9
71   */
72  function getLauncherAbilityInfo(bundleName: string, userId: number): Promise<Array<LauncherAbilityInfo>>;
73
74  /**
75   * Obtains launcher abilities info based on a given bundleName and userId.
76   *
77   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
78   * @param { string } bundleName - Indicates the application bundle name to be queried.
79   * @param { number } userId - Indicates the id for the user.
80   * @returns { Array<LauncherAbilityInfo> } the LauncherAbilityInfo object.
81   * @throws { BusinessError } 201 - Verify permission denied.
82   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
83   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
84   * @throws { BusinessError } 801 - Capability not support.
85   * @throws { BusinessError } 17700001 - The specified bundle name is not found.
86   * @throws { BusinessError } 17700004 - The specified user ID is not found.
87   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
88   * @systemapi
89   * @since 10
90   */
91  function getLauncherAbilityInfoSync(bundleName: string, userId: number): Array<LauncherAbilityInfo>;
92
93  /**
94   * Obtains launcher abilities info based on a given userId.
95   *
96   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
97   * @param { number } userId - Indicates the id for the user.
98   * @param { AsyncCallback<Array<LauncherAbilityInfo>> } callback -The callback of the LauncherAbilityInfo object result.
99   * @throws { BusinessError } 201 - Verify permission denied.
100   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
101   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
102   * @throws { BusinessError } 801 - Capability not support.
103   * @throws { BusinessError } 17700004 - The specified user ID is not found.
104   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
105   * @systemapi
106   * @since 9
107   */
108  function getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>): void;
109
110  /**
111   * Obtains launcher abilities info based on a given userId.
112   *
113   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
114   * @param { number } userId - Indicates the id for the user.
115   * @returns { Promise<Array<LauncherAbilityInfo>> } the LauncherAbilityInfo object.
116   * @throws { BusinessError } 201 - Verify permission denied.
117   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
118   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
119   * @throws { BusinessError } 801 - Capability not support.
120   * @throws { BusinessError } 17700004 - The specified user ID is not found.
121   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
122   * @systemapi
123   * @since 9
124   */
125  function getAllLauncherAbilityInfo(userId: number): Promise<Array<LauncherAbilityInfo>>;
126
127  /**
128   * Obtains shortcut info based on a given bundleName.
129   *
130   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
131   * @param { string } bundleName - Indicates the application bundle name to be queried.
132   * @param { AsyncCallback<Array<ShortcutInfo>> } callback -The callback of the ShortcutInfo object result.
133   * @throws { BusinessError } 201 - Verify 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 } 801 - Capability not support.
137   * @throws { BusinessError } 17700001 - The specified bundle name is not found.
138   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
139   * @systemapi
140   * @since 9
141   */
142  function getShortcutInfo(bundleName: string, callback: AsyncCallback<Array<ShortcutInfo>>): void;
143
144  /**
145   * Obtains shortcut info based on a given bundleName.
146   *
147   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
148   * @param { string } bundleName - Indicates the application bundle name to be queried.
149   * @returns { Promise<Array<ShortcutInfo>> } the LauncherShortcutInfo object.
150   * @throws { BusinessError } 201 - Verify permission denied.
151   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
152   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
153   * @throws { BusinessError } 801 - Capability not support.
154   * @throws { BusinessError } 17700001 - The specified bundle name is not found.
155   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
156   * @systemapi
157   * @since 9
158   */
159  function getShortcutInfo(bundleName: string): Promise<Array<ShortcutInfo>>;
160
161  /**
162   * Obtains shortcut info based on a given bundleName.
163   *
164   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
165   * @param { string } bundleName - Indicates the application bundle name to be queried.
166   * @returns { Array<ShortcutInfo> } the LauncherShortcutInfo object.
167   * @throws { BusinessError } 201 - Verify permission denied.
168   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
169   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
170   * @throws { BusinessError } 801 - Capability not support.
171   * @throws { BusinessError } 17700001 - The specified bundle name is not found.
172   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
173   * @systemapi
174   * @since 10
175   */
176  function getShortcutInfoSync(bundleName: string): Array<ShortcutInfo>;
177
178
179  /**
180   * Obtains shortcut info based on bundleName and userId.
181   *
182   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
183   * @param { string } bundleName - Indicates the application bundle name to be queried.
184   * @param { number } userId - Indicates the user ID.
185   * @returns { Array<ShortcutInfo> } the LauncherShortcutInfo object.
186   * @throws { BusinessError } 201 - Verify permission denied.
187   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
188   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
189   * @throws { BusinessError } 801 - Capability not support.
190   * @throws { BusinessError } 17700001 - The specified bundle name is not found.
191   * @throws { BusinessError } 17700004 - The specified user ID is not found.
192   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
193   * @systemapi
194   * @since 13
195   */
196  function getShortcutInfoSync(bundleName: string, userId: number): Array<ShortcutInfo>;
197
198  /**
199   * Starts shortcut.
200   *
201   * @permission ohos.permission.START_SHORTCUT
202   * @param { ShortcutInfo } shortcutInfo - Indicates the shortcut info which contains shortcut want.
203   * @param { StartOptions } [options] - Indicates the start options.
204   * @returns { Promise<void> } the promise returned by the function.
205   * @throws { BusinessError } 201 - Verify permission denied.
206   * @throws { BusinessError } 202 - Permission denied, non-system app called system api.
207   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
208   * @throws { BusinessError } 801 - Capability not support.
209   * @throws { BusinessError } 17700065 - The specified shortcut want in shortcut info is not supported to be started.
210   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
211   * @systemapi
212   * @since 12
213   */
214  function startShortcut(shortcutInfo: ShortcutInfo, options?: StartOptions): Promise<void>;
215
216  /**
217   * Contains basic launcher Ability information, which uniquely identifies an LauncherAbilityInfo.
218   *
219   * @typedef { _LauncherAbilityInfo }
220   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
221   * @systemapi
222   * @since 9
223   */
224  export type LauncherAbilityInfo = _LauncherAbilityInfo;
225
226  /**
227   * Provides information about a shortcut, including the shortcut ID and label.
228   *
229   * @typedef { _ShortcutInfo }
230   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
231   * @systemapi
232   * @since 9
233   */
234  export type ShortcutInfo = _ShortcutInfo;
235  /**
236   * Obtains information about the ability that a shortcut will start.
237   *
238   * @typedef { _ShortcutWant }
239   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
240   * @systemapi
241   * @since 9
242   */
243  export type ShortcutWant = _ShortcutWant;
244  /**
245   * Indicates the custom parameters in shortcut want.
246   *
247   * @typedef { _ParameterItem }
248   * @syscap SystemCapability.BundleManager.BundleFramework.Launcher
249   * @systemapi
250   * @since 12
251   */
252  export type ParameterItem = _ParameterItem;
253}
254
255export default launcherBundleManager;
256