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