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