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