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