• 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 } from './basic';
17import { ApplicationInfo } from './bundle/applicationInfo';
18import { AbilityInfo } from './bundle/abilityInfo';
19import { PermissionDef } from  './bundle/PermissionDef';
20import Want from './@ohos.app.ability.Want';
21import image from './@ohos.multimedia.image';
22import { BundleInfo } from './bundle/bundleInfo';
23import { BundleInstaller } from './bundle/bundleInstaller';
24
25/**
26 * bundle.
27 * @name bundle
28 * @since 7
29 * @syscap SystemCapability.BundleManager.BundleFramework
30 * @deprecated since 9
31 * @useinstead ohos.bundle.bundleManager
32 */
33declare namespace bundle {
34
35/**
36 * @name BundleFlag
37 * @since 7
38 * @syscap SystemCapability.BundleManager.BundleFramework
39 * @deprecated since 9
40 * @useinstead ohos.bundle.bundleManager.BundleFlag, ohos.bundle.bundleManager.ApplicationFlag or
41 *          ohos.bundle.bundleManager.AbilityFlag
42 */
43  enum BundleFlag {
44    GET_BUNDLE_DEFAULT = 0x00000000,
45    GET_BUNDLE_WITH_ABILITIES = 0x00000001,
46    GET_ABILITY_INFO_WITH_PERMISSION = 0x00000002,
47    GET_ABILITY_INFO_WITH_APPLICATION = 0x00000004,
48    GET_APPLICATION_INFO_WITH_PERMISSION = 0x00000008,
49    GET_BUNDLE_WITH_REQUESTED_PERMISSION = 0x00000010,
50    GET_ALL_APPLICATION_INFO = 0xFFFF0000,
51    /**
52     * @since 8
53     */
54    GET_ABILITY_INFO_WITH_METADATA = 0x00000020,
55    /**
56     * @since 8
57     */
58     GET_APPLICATION_INFO_WITH_METADATA = 0x00000040,
59    /**
60     * @since 8
61     */
62    GET_ABILITY_INFO_SYSTEMAPP_ONLY = 0x00000080,
63    /**
64     * @since 8
65     */
66    GET_ABILITY_INFO_WITH_DISABLE = 0x00000100,
67    /**
68     * @since 8
69     */
70    GET_APPLICATION_INFO_WITH_DISABLE = 0x00000200,
71  }
72
73/**
74 * @name ColorMode
75 * @since 7
76 * @syscap SystemCapability.BundleManager.BundleFramework
77 * @deprecated since 9
78 */
79  export enum ColorMode {
80    AUTO_MODE = -1,
81    DARK_MODE = 0,
82    LIGHT_MODE = 1,
83  }
84
85/**
86 * @name GrantStatus
87 * @since 7
88 * @syscap SystemCapability.BundleManager.BundleFramework
89 * @deprecated since 9
90 * @useinstead ohos.bundle.bundleManager.PermissionGrantState
91 */
92  export enum GrantStatus {
93    PERMISSION_DENIED = -1,
94    PERMISSION_GRANTED = 0,
95  }
96
97  /**
98   * @name AbilityType
99   * @since 7
100   * @syscap SystemCapability.BundleManager.BundleFramework
101   * @deprecated since 9
102   * @useinstead ohos.bundle.bundleManager.AbilityType
103   */
104  export enum AbilityType {
105    /**
106     * @default Indicates an unknown ability type
107     * @since 7
108     * @syscap SystemCapability.BundleManager.BundleFramework
109     */
110    UNKNOWN,
111
112    /**
113     * @default Indicates that the ability has a UI
114     * @since 7
115     * @syscap SystemCapability.BundleManager.BundleFramework
116     */
117    PAGE,
118
119    /**
120     * @default Indicates that the ability does not have a UI
121     * @since 7
122     * @syscap SystemCapability.BundleManager.BundleFramework
123     */
124    SERVICE,
125
126    /**
127     * @default Indicates that the ability is used to provide data access services
128     * @since 7
129     * @syscap SystemCapability.BundleManager.BundleFramework
130     */
131    DATA,
132  }
133
134  /**
135   * @name AbilitySubType
136   * @since 7
137   * @syscap SystemCapability.BundleManager.BundleFramework
138   * @deprecated since 9
139   */
140  export enum AbilitySubType {
141    UNSPECIFIED = 0,
142    CA = 1,
143  }
144
145  /**
146   * @name DisplayOrientation
147   * @since 7
148   * @syscap SystemCapability.BundleManager.BundleFramework
149   * @deprecated since 9
150   * @useinstead ohos.bundle.bundleManager.DisplayOrientation
151   */
152  export enum DisplayOrientation {
153    /**
154     * @default Indicates that the system automatically determines the display orientation
155     * @since 7
156     * @syscap SystemCapability.BundleManager.BundleFramework
157     */
158    UNSPECIFIED,
159
160    /**
161     * @default Indicates the landscape orientation
162     * @since 7
163     * @syscap SystemCapability.BundleManager.BundleFramework
164     */
165    LANDSCAPE,
166
167    /**
168     * @default Indicates the portrait orientation
169     * @since 7
170     * @syscap SystemCapability.BundleManager.BundleFramework
171     */
172    PORTRAIT,
173
174    /**
175     * @default Indicates the page ability orientation is the same as that of the nearest ability in the stack
176     * @since 7
177     * @syscap SystemCapability.BundleManager.BundleFramework
178     */
179    FOLLOW_RECENT,
180  }
181
182  /**
183   * @name LaunchMode
184   * @since 7
185   * @syscap SystemCapability.BundleManager.BundleFramework
186   * @deprecated since 9
187   * @useinstead ohos.bundle.bundleManager.LaunchType
188   */
189  export enum LaunchMode {
190    /**
191     * @default Indicates that the ability has only one instance
192     * @since 7
193     * @syscap SystemCapability.BundleManager.BundleFramework
194     */
195    SINGLETON = 0,
196
197    /**
198     * @default Indicates that the ability can have multiple instances
199     * @since 7
200     * @syscap SystemCapability.BundleManager.BundleFramework
201     */
202    STANDARD = 1,
203  }
204
205  /**
206   * @name BundleOptions
207   * @since 7
208   * @syscap SystemCapability.BundleManager.BundleFramework
209   * @deprecated since 9
210   */
211  export interface BundleOptions {
212    /**
213     * @default Indicates the user id
214     * @since 7
215     * @syscap SystemCapability.BundleManager.BundleFramework
216     */
217    userId?: number;
218  }
219
220  /**
221   * @name InstallErrorCode
222   * @since 7
223   * @syscap SystemCapability.BundleManager.BundleFramework
224   * @deprecated since 9
225   */
226  export enum InstallErrorCode{
227    SUCCESS = 0,
228    STATUS_INSTALL_FAILURE = 1,
229    STATUS_INSTALL_FAILURE_ABORTED = 2,
230    STATUS_INSTALL_FAILURE_INVALID = 3,
231    STATUS_INSTALL_FAILURE_CONFLICT = 4,
232    STATUS_INSTALL_FAILURE_STORAGE = 5,
233    STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6,
234    STATUS_UNINSTALL_FAILURE = 7,
235    STATUS_UNINSTALL_FAILURE_BLOCKED = 8,
236    STATUS_UNINSTALL_FAILURE_ABORTED = 9,
237    STATUS_UNINSTALL_FAILURE_CONFLICT = 10,
238    STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B,
239    STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C,
240    /**
241      * @since 8
242      */
243    STATUS_RECOVER_FAILURE_INVALID = 0x0D,
244    /**
245      * @since 7
246      */
247    STATUS_ABILITY_NOT_FOUND = 0x40,
248    /**
249      * @since 7
250      */
251    STATUS_BMS_SERVICE_ERROR = 0x41,
252    /**
253      * @since 8
254      */
255    STATUS_FAILED_NO_SPACE_LEFT = 0x42,
256    /**
257      * @since 8
258      */
259    STATUS_GRANT_REQUEST_PERMISSIONS_FAILED = 0x43,
260    /**
261     * @since 8
262     */
263    STATUS_INSTALL_PERMISSION_DENIED = 0x44,
264    /**
265     * @since 8
266     */
267    STATUS_UNINSTALL_PERMISSION_DENIED = 0x45,
268  }
269
270  /**
271   * Obtains bundleInfo based on bundleName, bundleFlags and options.
272   *
273   * @since 7
274   * @syscap SystemCapability.BundleManager.BundleFramework
275   * @param bundleName Indicates the application bundle name to be queried.
276   * @param bundleFlags Indicates the application bundle flags to be queried.
277   * @param options Indicates the bundle options object.
278   * @returns Returns the BundleInfo object.
279   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
280   * @deprecated since 9
281   * @useinstead ohos.bundle.bundleManager#getBundleInfo
282   */
283   function getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback<BundleInfo>): void;
284   function getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback<BundleInfo>): void;
285   function getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise<BundleInfo>;
286
287  /**
288   * Obtains the interface used to install bundles.
289   *
290   * @since 7
291   * @syscap SystemCapability.BundleManager.BundleFramework
292   * @returns Returns the IBundleInstaller interface.
293   * @permission ohos.permission.INSTALL_BUNDLE
294   * @systemapi Hide this for inner system use
295   * @deprecated since 9
296   * @useinstead ohos.bundle.installer#getBundleInstaller
297   */
298  function getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void;
299  function getBundleInstaller(): Promise<BundleInstaller>;
300
301  /**
302   * Obtains information about the current ability.
303   *
304   * @since 7
305   * @syscap SystemCapability.BundleManager.BundleFramework
306   * @param bundleName Indicates the application bundle name to be queried.
307   * @param abilityName Indicates the ability name.
308   * @returns Returns the AbilityInfo object for the current ability.
309   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
310   * @deprecated since 9
311   * @useinstead ohos.bundle.bundleManager#queryAbilityInfo
312   */
313  function getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback<AbilityInfo>): void;
314  function getAbilityInfo(bundleName: string, abilityName: string): Promise<AbilityInfo>;
315
316  /**
317   * Obtains based on a given bundle name.
318   *
319   * @since 7
320   * @syscap SystemCapability.BundleManager.BundleFramework
321   * @param bundleName Indicates the application bundle name to be queried.
322   * @param bundleFlags Indicates the flag used to specify information contained in the ApplicationInfo object
323   *              that will be returned.
324   * @param userId Indicates the user ID or do not pass user ID.
325   * @returns Returns the ApplicationInfo object.
326   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
327   * @deprecated since 9
328   * @useinstead ohos.bundle.bundleManager#getApplicationInfo
329   */
330  function getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback<ApplicationInfo>) : void;
331  function getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback<ApplicationInfo>) : void;
332  function getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number) : Promise<ApplicationInfo>;
333
334  /**
335   * Query the AbilityInfo by the given Want.
336   *
337   * @since 7
338   * @syscap SystemCapability.BundleManager.BundleFramework
339   * @param want Indicates the Want containing the application bundle name to
340   *               be queried.
341   * @param bundleFlags Indicates the flag used to specify information contained in the AbilityInfo objects that
342   *              will be returned.
343   * @param userId Indicates the user ID.
344   * @returns Returns a list of AbilityInfo objects.
345   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
346   * @deprecated since 9
347   * @useinstead ohos.bundle.bundleManager#queryAbilityInfo
348   */
349  function queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback<Array<AbilityInfo>>): void;
350  function queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback<Array<AbilityInfo>>): void;
351  function queryAbilityByWant(want: Want, bundleFlags: number, userId?:number): Promise<Array<AbilityInfo>>;
352
353  /**
354   * Obtains BundleInfo of all bundles available in the system.
355   *
356   * @since 7
357   * @syscap SystemCapability.BundleManager.BundleFramework
358   * @param bundleFlag Indicates the flag used to specify information contained in the BundleInfo that will be
359   *              returned.
360   * @param userId Indicates the user id.
361   * @returns Returns a list of BundleInfo objects.
362   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
363   * @deprecated since 9
364   * @useinstead ohos.bundle.bundleManager#getAllBundleInfo
365   */
366  function getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback<Array<BundleInfo>>) : void;
367  function getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback<Array<BundleInfo>>) : void;
368  function getAllBundleInfo(bundleFlag: BundleFlag, userId?: number) : Promise<Array<BundleInfo>>;
369
370  /**
371   * Obtains information about all installed applications of a specified user.
372   *
373   * @since 7
374   * @syscap SystemCapability.BundleManager.BundleFramework
375   * @param bundleFlags Indicates the flag used to specify information contained in the ApplicationInfo objects
376   *              that will be returned.
377   * @param userId Indicates the user ID or do not pass user ID.
378   * @returns Returns a list of ApplicationInfo objects.
379   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
380   * @deprecated since 9
381   * @useinstead ohos.bundle.bundleManager#getAllApplicationInfo
382   */
383  function getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback<Array<ApplicationInfo>>) : void;
384  function getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback<Array<ApplicationInfo>>) : void;
385  function getAllApplicationInfo(bundleFlags: number, userId?: number) : Promise<Array<ApplicationInfo>>;
386
387  /**
388   * Obtains bundle name by the given uid.
389   *
390   * @since 8
391   * @syscap SystemCapability.BundleManager.BundleFramework
392   * @param uid Indicates the UID of an application.
393   * @returns Returns the bundle name.
394   * @deprecated since 9
395   * @useinstead ohos.bundle.bundleManager#getNameForUid
396   */
397   function getNameForUid(uid: number, callback: AsyncCallback<string>) : void
398   function getNameForUid(uid: number) : Promise<string>;
399
400  /**
401   * Obtains information about an application bundle contained in an ohos Ability Package (HAP).
402   *
403   * @since 7
404   * @syscap SystemCapability.BundleManager.BundleFramework
405   * @param hapFilePath Indicates the path storing the HAP. The path should be the relative path to the data
406   *                    directory of the current application.
407   * @param bundleFlags Indicates the flag used to specify information contained in the BundleInfo object to be
408   *              returned.
409   * @returns Returns the BundleInfo object.
410   * @deprecated since 9
411   * @useinstead ohos.bundle.bundleManager#getBundleArchiveInfo
412   */
413  function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback<BundleInfo>) : void
414  function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise<BundleInfo>;
415
416  /**
417   * Obtains the Want for starting the main ability of an application based on the
418   * given bundle name. The main ability of an application is the ability that has the
419   * #ACTION_HOME and #ENTITY_HOME Want
420   * filters set in the application's <b>config.json</b> file.
421   *
422   * @since 7
423   * @syscap SystemCapability.BundleManager.BundleFramework
424   * @param bundleName Indicates the bundle name of the application.
425   * @returns Returns the Want for starting the application's main ability if any; returns null if
426   *         the given bundle does not exist or does not contain any main ability.
427   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
428   * @deprecated since 9
429   * @useinstead ohos.bundle.bundleManager#getLaunchWantForBundle
430   */
431  function getLaunchWantForBundle(bundleName: string, callback: AsyncCallback<Want>): void;
432  function getLaunchWantForBundle(bundleName: string): Promise<Want>;
433
434  /**
435   * Clears cache data of a specified application.
436   *
437   * @since 8
438   * @syscap SystemCapability.BundleManager.BundleFramework
439   * @param bundleName Indicates the bundle name of the application whose cache data is to be cleared.
440   * @param callback Indicates the callback to be invoked for returning the operation result.
441   * @permission ohos.permission.REMOVE_CACHE_FILES
442   * @systemapi Hide this for inner system use
443   * @deprecated since 9
444   * @useinstead ohos.bundle.bundleManager#cleanBundleCacheFiles
445   */
446  function cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback<void>): void;
447  function cleanBundleCacheFiles(bundleName: string): Promise<void>;
448
449  /**
450   * Sets whether to enable a specified application.
451   *
452   * @since 8
453   * @syscap SystemCapability.BundleManager.BundleFramework
454   * @param bundleName Indicates the bundle name of the application.
455   * @param isEnable Specifies whether to enable the application. The value true means to enable it, and the
456   *                  value false means to disable it.
457   * @permission ohos.permission.CHANGE_ABILITY_ENABLED_STATE
458   * @systemapi Hide this for inner system use
459   * @deprecated since 9
460   * @useinstead ohos.bundle.bundleManager#setApplicationEnabled
461   */
462  function setApplicationEnabled(bundleName: string, isEnable: boolean, callback: AsyncCallback<void>): void;
463  function setApplicationEnabled(bundleName: string, isEnable: boolean): Promise<void>;
464
465  /**
466   * Sets whether to enable a specified ability.
467   *
468   * @since 8
469   * @syscap SystemCapability.BundleManager.BundleFramework
470   * @param abilityInfo Indicates information about the ability to set.
471   * @param isEnable Specifies whether to enable the ability. The value true means to enable it, and the
472   *                  value false means to disable it..
473   * @permission ohos.permission.CHANGE_ABILITY_ENABLED_STATE
474   * @systemapi Hide this for inner system use
475   * @deprecated since 9
476   * @useinstead ohos.bundle.bundleManager#setAbilityEnabled
477   */
478  function setAbilityEnabled(info: AbilityInfo, isEnable: boolean, callback: AsyncCallback<void>): void;
479  function setAbilityEnabled(info: AbilityInfo, isEnable: boolean): Promise<void>;
480
481  /**
482   * Get the permission details by permissionName.
483   *
484   * @since 8
485   * @syscap SystemCapability.BundleManager.BundleFramework
486   * @param permissionName Indicates permission name.
487   * @returns Returns permissionDef object.
488   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
489   * @systemapi
490   * @deprecated since 9
491   * @useinstead ohos.bundle.bundleManager#getPermissionDef
492   */
493  function getPermissionDef(permissionName: string, callback: AsyncCallback<PermissionDef>): void;
494  function getPermissionDef(permissionName: string): Promise<PermissionDef>;
495
496  /**
497   * Obtains the label of a specified ability.
498   *
499   * @since 8
500   * @syscap SystemCapability.BundleManager.BundleFramework
501   * @param bundleName Indicates the bundle name of the application to which the ability belongs.
502   * @param abilityName Indicates the ability name.
503   * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
504   * @returns Returns the label representing the label of the specified ability.
505   * @deprecated since 9
506   * @useinstead ohos.bundle.bundleManager#getAbilityLabel
507   */
508  function getAbilityLabel(bundleName: string, abilityName: string, callback: AsyncCallback<string>): void;
509  function getAbilityLabel(bundleName: string, abilityName: string): Promise<string>;
510
511  /**
512    * Obtains the icon of a specified ability.
513    *
514    * @since 8
515    * @syscap SystemCapability.BundleManager.BundleFramework
516    * @param bundleName Indicates the bundle name of the application to which the ability belongs.
517    * @param abilityName Indicates the ability name.
518    * @returns Returns the PixelMap object representing the icon of the specified ability.
519    * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
520    * @deprecated since 9
521    * @useinstead ohos.resourceManager#getMediaContent
522    */
523  function getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback<image.PixelMap>): void;
524  function getAbilityIcon(bundleName: string, abilityName: string): Promise<image.PixelMap>;
525
526  /**
527    * Checks whether a specified ability is enabled.
528    *
529    * @since 8
530    * @syscap SystemCapability.BundleManager.BundleFramework
531    * @param info Indicates information about the ability to check.
532    * @returns Returns true if the ability is enabled; returns false otherwise.
533    * @deprecated since 9
534    * @useinstead ohos.bundle.bundleManager#isAbilityEnabled
535    */
536  function isAbilityEnabled(info: AbilityInfo, callback: AsyncCallback<boolean>): void;
537  function isAbilityEnabled(info: AbilityInfo): Promise<boolean>;
538
539  /**
540    * Checks whether a specified application is enabled.
541    *
542    * @since 8
543    * @syscap SystemCapability.BundleManager.BundleFramework
544    * @param bundleName Indicates the bundle name of the application.
545    * @returns Returns true if the application is enabled; returns false otherwise.
546    * @deprecated since 9
547    * @useinstead ohos.bundle.bundleManager#isApplicationEnabled
548    */
549  function isApplicationEnabled(bundleName: string, callback: AsyncCallback<boolean>): void;
550  function isApplicationEnabled(bundleName: string): Promise<boolean>;
551}
552
553export default bundle;
554