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