• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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
16import { AsyncCallback, Callback } from './basic';
17import { ApplicationInfo } from './bundle/applicationInfo';
18import { BundleInfo } from './bundle/bundleInfo';
19import { AbilityInfo } from './bundle/abilityInfo';
20import { Want } from './ability/want';
21import { BundleInstaller } from './bundle/bundleInstaller';
22import { ShortcutInfo } from './bundle/shortcutInfo';
23import { ModuleUsageRecord } from './bundle/moduleUsageRecord';
24
25/**
26 * bundle.
27 * @name bundle
28 * @since 7
29 * @sysCap SystemCapability.Appexecfwk
30 * @devices phone, tablet, tv, wearable
31 * @permission NA
32 */
33declare namespace bundle {
34
35/**
36 * @name BundleFlag
37 * @since 7
38 * @SysCap SystemCapability.Appexecfwk
39 * @import NA
40 * @permission NA
41 * @devices phone, tablet, tv, wearable
42 */
43  enum BundleFlag {
44    GET_BUNDLE_DEFAULT = 0x00000000,
45    GET_BUNDLE_WITH_ABILITIES = 0x00000001,
46    GET_APPLICATION_INFO_WITH_PERMISSION = 0x00000008,
47  }
48
49/**
50 * @name GrantStatus
51 * @since 7
52 * @SysCap SystemCapability.Appexecfwk
53 * @import NA
54 * @permission NA
55 * @devices phone, tablet, tv, wearable
56 */
57  export enum GrantStatus {
58    PERMISSION_DENIED = -1,
59    PERMISSION_GRANTED = 0,
60  }
61
62  /**
63   * @name AbilityType
64   * @since 7
65   * @SysCap SystemCapability.Appexecfwk
66   * @import NA
67   * @permission NA
68   * @devices phone, tablet, tv, wearable
69   */
70  export enum AbilityType {
71    /**
72      * @default Indicates an unknown ability type
73      * @since 7
74      * @SysCap SystemCapability.Appexecfwk
75      */
76    UNKNOWN,
77
78    /**
79      * @default Indicates that the ability has a UI
80      * @since 7
81      * @SysCap SystemCapability.Appexecfwk
82      */
83    PAGE,
84
85    /**
86      * @default Indicates that the ability does not have a UI
87      * @since 7
88      * @SysCap SystemCapability.Appexecfwk
89      */
90    SERVICE,
91
92    /**
93      * @default Indicates that the ability is used to provide data access services
94      * @since 7
95      * @SysCap SystemCapability.Appexecfwk
96      */
97    DATA,
98  }
99
100  /**
101   * @name AbilitySubType
102   * @since 7
103   * @SysCap SystemCapability.Appexecfwk
104   * @import NA
105   * @permission NA
106   * @devices phone, tablet, tv, wearable
107   */
108  export enum AbilitySubType {
109    UNSPECIFIED = 0,
110    CA = 1,
111  }
112
113  /**
114   * @name DisplayOrientation
115   * @since 7
116   * @SysCap SystemCapability.Appexecfwk
117   * @import NA
118   * @permission NA
119   * @devices phone, tablet, tv, wearable
120   */
121  export enum DisplayOrientation {
122    /**
123      * @default Indicates that the system automatically determines the display orientation
124      * @since 7
125      * @SysCap SystemCapability.Appexecfwk
126      */
127    UNSPECIFIED,
128
129    /**
130      * @default Indicates the landscape orientation
131      * @since 7
132      * @SysCap SystemCapability.Appexecfwk
133      */
134    LANDSCAPE,
135
136    /**
137      * @default Indicates the portrait orientation
138      * @since 7
139      * @SysCap SystemCapability.Appexecfwk
140      */
141    PORTRAIT,
142
143    /**
144      * @default Indicates the page ability orientation is the same as that of the nearest ability in the stack
145      * @since 7
146      * @SysCap SystemCapability.Appexecfwk
147      */
148    FOLLOW_RECENT,
149  }
150
151  /**
152   * @name LaunchMode
153   * @since 7
154   * @SysCap SystemCapability.Appexecfwk
155   * @import NA
156   * @permission NA
157   * @devices phone, tablet, tv, wearable
158   */
159  export enum LaunchMode {
160    /**
161      * @default Indicates that the ability has only one instance
162      * @since 7
163      * @SysCap SystemCapability.Appexecfwk
164      */
165    SINGLETON = 0,
166
167    /**
168      * @default Indicates that the ability can have multiple instances
169      * @since 7
170      * @SysCap SystemCapability.Appexecfwk
171      */
172    STANDARD = 1,
173  }
174
175  /**
176   * @name InstallErrorCode
177   * @since 7
178   * @SysCap SystemCapability.Appexecfwk
179   * @import NA
180   * @permission NA
181   * @devices phone, tablet, tv, wearable
182   */
183  export enum InstallErrorCode{
184    SUCCESS = 0,
185    STATUS_INSTALL_FAILURE = 1,
186    STATUS_INSTALL_FAILURE_ABORTED = 2,
187    STATUS_INSTALL_FAILURE_INVALID = 3,
188    STATUS_INSTALL_FAILURE_CONFLICT = 4,
189    STATUS_INSTALL_FAILURE_STORAGE = 5,
190    STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6,
191    STATUS_UNINSTALL_FAILURE = 7,
192    STATUS_UNINSTALL_FAILURE_BLOCKED = 8,
193    STATUS_UNINSTALL_FAILURE_ABORTED = 9,
194    STATUS_UNINSTALL_FAILURE_CONFLICT = 10,
195    STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B,
196    STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C,
197    STATUS_ABILITY_NOT_FOUND = 0x40,
198    STATUS_BMS_SERVICE_ERROR = 0x41
199  }
200
201  /**
202   * Obtains based on a given networkId and bundle name.
203   *
204   * @devices phone, tablet, tv, wearable
205   * @since 7
206   * @SysCap SystemCapability.Appexecfwk
207   * @param networkId Indicates the device networkId in area network.
208   * @param bundleName Indicates the application bundle name to be queried.
209   * @param flags Indicates the flag used to specify information contained in that will be
210   *              returned.
211   * @return Returns the BundleInfo object.
212   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED,ohos.permission.GET_BUNDLE_INFO
213   */
214   function getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback<BundleInfo>): void;
215   function getBundleInfo(bundleName: string, bundleFlags: number): Promise<BundleInfo>;
216
217  /**
218   * Obtains the interface used to install bundles.
219   *
220   * @devices phone, tablet, tv, wearable
221   * @since 7
222   * @SysCap SystemCapability.Appexecfwk
223   * @return Returns the IBundleInstaller interface.
224   * @permission ohos.permission.INSTALL_BUNDLE
225   */
226  function getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void;
227  function getBundleInstaller(): Promise<BundleInstaller>;
228
229  /**
230   * Obtains based on a given bundle name.
231   *
232   * @devices phone, tablet, tv, wearable
233   * @since 7
234   * @SysCap SystemCapability.Appexecfwk
235   * @param bundleName Indicates the application bundle name to be queried.
236   * @param flags Indicates the flag used to specify information contained in the ApplicationInfo object
237   *              that will be returned.
238   * @param userId Indicates the user ID.
239   * @return Returns the ApplicationInfo object.
240   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO
241   */
242  function getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback<ApplicationInfo>) : void;
243  function getApplicationInfo(bundleName: string, bundleFlags: number, userId: number) : Promise<ApplicationInfo>;
244
245  /**
246   * Checks whether a specified bundle has been granted a specific permission.
247   *
248   * @devices phone, tablet, tv, wearable
249   * @since 7
250   * @SysCap SystemCapability.Appexecfwk
251   * @param bundleName Indicates the name of the bundle to check.
252   * @param permission Indicates the permission to check.
253   * @return Returns 0 if the bundle has the permission; returns -1 otherwise.
254   */
255  function checkPermission(bundleName: string, permission: string, callback: AsyncCallback<GrantStatus>): void;
256  function checkPermission(bundleName: string, permission: string): Promise<GrantStatus>;
257
258  /**
259   * Query the AbilityInfo by the given Want.
260   *
261   * @devices phone, tablet, tv, wearable
262   * @since 7
263   * @SysCap SystemCapability.Appexecfwk
264   * @param intent Indicates the Intent containing the application bundle name to
265   *               be queried.
266   * @param flags Indicates the flag used to specify information contained in the AbilityInfo objects that
267   *              will be returned.
268   * @param userId Indicates the user ID.
269   * @return Returns a list of AbilityInfo objects.
270   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO
271   */
272  function queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback<Array<AbilityInfo>>): void;
273  function queryAbilityByWant(want: Want, bundleFlags: number, userId:number): Promise<Array<AbilityInfo>>;
274
275  /**
276   * Obtains BundleInfo of all bundles available in the system.
277   *
278   * @devices phone, tablet, tv, wearable
279   * @since 7
280   * @SysCap SystemCapability.Appexecfwk
281   * @param flags Indicates the flag used to specify information contained in the BundleInfo that will be
282   *              returned.
283   * @return Returns a list of BundleInfo objects.
284   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
285   */
286  function getAllBundleInfo(bundlelFlag: BundleFlag, callback: AsyncCallback<Array<BundleInfo>>) : void;
287  function getAllBundleInfo(bundlelFlag: BundleFlag) : Promise<Array<BundleInfo>>;
288
289  /**
290   * Obtains information about all installed applications of a specified user.
291   *
292   * @devices phone, tablet, tv, wearable
293   * @since 7
294   * @SysCap SystemCapability.Appexecfwk
295   * @param flags Indicates the flag used to specify information contained in the ApplicationInfo objects
296   *              that will be returned.
297   * @param userId Indicates the user ID.
298   * @return Returns a list of ApplicationInfo objects.
299   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
300   */
301  function getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback<Array<ApplicationInfo>>) : void;
302  function getAllApplicationInfo(bundleFlags: number, userId: number) : Promise<Array<ApplicationInfo>>;
303
304  /**
305   * Obtains information about an application bundle contained in an ohos Ability Package (HAP).
306   *
307   * @devices phone, tablet, tv, wearable
308   * @since 7
309   * @SysCap SystemCapability.Appexecfwk
310   * @param hapFilePath Indicates the path storing the HAP. The path should be the relative path to the data
311   *                    directory of the current application.
312   * @param flags Indicates the flag used to specify information contained in the BundleInfo object to be
313   *              returned.
314   * @return Returns the BundleInfo object.
315   */
316  function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback<BundleInfo>) : void
317  function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise<BundleInfo>;
318
319  /**
320
321  /**
322   * Obtains the Intent for starting the main ability of an application based on the
323   * given bundle name. The main ability of an application is the ability that has the
324   * #ACTION_HOME and #ENTITY_HOME intent
325   * filters set in the application's <b>config.json</b> file.
326   *
327   * @devices phone, tablet, tv, wearable
328   * @since 7
329   * @SysCap SystemCapability.Appexecfwk
330   * @param bundleName Indicates the bundle name of the application.
331   * @return Returns the Intent for starting the application's main ability if any; returns null if
332   *         the given bundle does not exist or does not contain any main ability.
333   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
334   */
335  function getLaunchWantForBundle(bundleName: string, callback: AsyncCallback<Want>): void;
336  function getLaunchWantForBundle(bundleName: string): Promise<Want>;
337
338  /**
339   * Obtains information about the shortcuts of the application.
340   *
341   * @devices phone, tablet, tv, wearable
342   * @since 7
343   * @SysCap SystemCapability.Appexecfwk
344   * @param bundleName Indicates the bundle name of the application.
345   * @return Returns a list of ShortcutInfo objects containing shortcut information about the application.
346   * @permission ohos.permission.MANAGE_SHORTCUTS
347   */
348  function getAllShortcutInfo(bundleName: string, callback: AsyncCallback<Array<ShortcutInfo>>): void;
349  function getAllShortcutInfo(bundleName: string): Promise<Array<ShortcutInfo>>;
350
351  /**
352   * get module usage record list in descending order of lastLaunchTime.
353   *
354   * @devices phone, tablet, tv, wearable
355   * @since 7
356   * @SysCap SystemCapability.Appexecfwk
357   * @param maxNum the return size of the records, must be in range of 1 to 1000.
358   * @return Returns ability usage record list.
359   * @systemapi hide this for inner system use
360   */
361  function getModuleUsageRecords(maxNum: number, callback: AsyncCallback<Array<ModuleUsageRecord>>): void;
362  function getModuleUsageRecords(maxNum: number): Promise<Array<ModuleUsageRecord>>;
363}
364
365export default bundle;
366