• 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
16import { Callback } from './basic';
17
18/**
19 * Bundle monitor
20 * @namespace bundleMonitor
21 * @syscap SystemCapability.BundleManager.BundleFramework.Core
22 * @systemapi
23 * @since 9
24 */
25declare namespace bundleMonitor {
26  /**
27   * This module defines the result information of monitoring install, update and uninstall.
28   * @typedef BundleChangedInfo
29   * @syscap SystemCapability.BundleManager.BundleFramework.Core
30   * @systemapi
31   * @since 9
32   */
33  interface BundleChangedInfo {
34    /**
35     * The bundle name
36     * @type {string}
37     * @systemapi
38     * @since 9
39     */
40     readonly bundleName: string;
41    /**
42     * The user id
43     * @type {number}
44     * @systemapi
45     * @since 9
46     */
47     readonly userId: number;
48  }
49
50  /**
51   * Indicates the event type of bundle change
52   * @syscap SystemCapability.BundleManager.BundleFramework.Core
53   * @systemapi
54   * @since 9
55   */
56  type BundleChangedEvent = 'add' | 'update' | 'remove';
57
58  /**
59   * Register to monitor the installation status
60   * @permission ohos.permission.LISTEN_BUNDLE_CHANGE
61   * @param { BundleChangedEvent } type - Indicates the command should be implement.
62   * @param { Callback<BundleChangedInfo> } callback - Indicates the callback to be register.
63   * @throws {BusinessError} 201 - Verify permission denied.
64   * @throws {BusinessError} 202 - Permission denied, non-system app called system api.
65   * @throws {BusinessError} 401 - The parameter check failed.
66   * @syscap SystemCapability.BundleManager.BundleFramework.Core
67   * @systemapi
68   * @since 9
69   */
70  function on(type: BundleChangedEvent, callback: Callback<BundleChangedInfo>): void;
71
72  /**
73   * Unregister to monitor the installation status
74   * @permission ohos.permission.LISTEN_BUNDLE_CHANGE
75   * @param { BundleChangedEvent } type -type Indicates the command should be implement.
76   * @param { Callback<BundleChangedInfo> } callback - Indicates the callback to be unregister.
77   * @throws {BusinessError} 201 - Verify permission denied.
78   * @throws {BusinessError} 202 - Permission denied, non-system app called system api.
79   * @throws {BusinessError} 401 - The parameter check failed.
80   * @syscap SystemCapability.BundleManager.BundleFramework.Core
81   * @systemapi
82   * @since 9
83   */
84  function off(type: BundleChangedEvent, callback?: Callback<BundleChangedInfo>): void;
85}
86
87export default bundleMonitor
88