2022-10-12 06:15:16 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2023-12-11 09:08:03 +00:00
|
|
|
/**
|
|
|
|
* @file
|
2024-01-08 07:25:39 +00:00
|
|
|
* @kit AbilityKit
|
2023-12-11 09:08:03 +00:00
|
|
|
*/
|
|
|
|
|
2023-04-04 02:17:06 +00:00
|
|
|
import { Callback } from './@ohos.base';
|
2022-10-12 06:15:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Bundle monitor
|
2023-03-29 09:11:59 +00:00
|
|
|
*
|
2022-10-12 06:15:16 +00:00
|
|
|
* @namespace bundleMonitor
|
|
|
|
* @syscap SystemCapability.BundleManager.BundleFramework.Core
|
|
|
|
* @systemapi
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
declare namespace bundleMonitor {
|
|
|
|
/**
|
|
|
|
* This module defines the result information of monitoring install, update and uninstall.
|
2023-03-29 09:11:59 +00:00
|
|
|
*
|
2022-10-12 06:15:16 +00:00
|
|
|
* @typedef BundleChangedInfo
|
|
|
|
* @syscap SystemCapability.BundleManager.BundleFramework.Core
|
|
|
|
* @systemapi
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
interface BundleChangedInfo {
|
|
|
|
/**
|
|
|
|
* The bundle name
|
2023-03-29 09:11:59 +00:00
|
|
|
*
|
|
|
|
* @type { string }
|
2024-11-11 13:08:00 +00:00
|
|
|
* @readonly
|
2023-03-29 09:11:59 +00:00
|
|
|
* @syscap SystemCapability.BundleManager.BundleFramework.Core
|
2022-10-12 06:15:16 +00:00
|
|
|
* @systemapi
|
|
|
|
* @since 9
|
|
|
|
*/
|
2023-03-29 09:11:59 +00:00
|
|
|
readonly bundleName: string;
|
2022-10-12 06:15:16 +00:00
|
|
|
/**
|
|
|
|
* The user id
|
2023-03-29 09:11:59 +00:00
|
|
|
*
|
|
|
|
* @type { number }
|
2024-11-11 13:08:00 +00:00
|
|
|
* @readonly
|
2023-03-29 09:11:59 +00:00
|
|
|
* @syscap SystemCapability.BundleManager.BundleFramework.Core
|
2022-10-12 06:15:16 +00:00
|
|
|
* @systemapi
|
|
|
|
* @since 9
|
|
|
|
*/
|
2023-03-29 09:11:59 +00:00
|
|
|
readonly userId: number;
|
2024-06-01 02:16:15 +00:00
|
|
|
/**
|
|
|
|
* The app index of clone app
|
|
|
|
*
|
|
|
|
* @type { number }
|
2024-11-11 13:08:00 +00:00
|
|
|
* @readonly
|
2024-06-01 02:16:15 +00:00
|
|
|
* @syscap SystemCapability.BundleManager.BundleFramework.Core
|
|
|
|
* @systemapi
|
|
|
|
* @since 12
|
|
|
|
*/
|
|
|
|
readonly appIndex: number;
|
2022-10-12 06:15:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates the event type of bundle change
|
2023-03-29 09:11:59 +00:00
|
|
|
*
|
2024-07-13 07:07:02 +00:00
|
|
|
* @typedef { 'add' | 'update' | 'remove' }
|
2022-10-12 06:15:16 +00:00
|
|
|
* @syscap SystemCapability.BundleManager.BundleFramework.Core
|
|
|
|
* @systemapi
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
type BundleChangedEvent = 'add' | 'update' | 'remove';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register to monitor the installation status
|
2023-03-29 09:11:59 +00:00
|
|
|
*
|
2022-10-12 06:15:16 +00:00
|
|
|
* @permission ohos.permission.LISTEN_BUNDLE_CHANGE
|
|
|
|
* @param { BundleChangedEvent } type - Indicates the command should be implement.
|
|
|
|
* @param { Callback<BundleChangedInfo> } callback - Indicates the callback to be register.
|
2023-03-29 09:11:59 +00:00
|
|
|
* @throws { BusinessError } 201 - Verify permission denied.
|
|
|
|
* @throws { BusinessError } 202 - Permission denied, non-system app called system api.
|
2024-04-19 04:04:57 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
|
2022-10-12 06:15:16 +00:00
|
|
|
* @syscap SystemCapability.BundleManager.BundleFramework.Core
|
|
|
|
* @systemapi
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
function on(type: BundleChangedEvent, callback: Callback<BundleChangedInfo>): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister to monitor the installation status
|
2023-03-29 09:11:59 +00:00
|
|
|
*
|
2022-10-12 06:15:16 +00:00
|
|
|
* @permission ohos.permission.LISTEN_BUNDLE_CHANGE
|
|
|
|
* @param { BundleChangedEvent } type -type Indicates the command should be implement.
|
|
|
|
* @param { Callback<BundleChangedInfo> } callback - Indicates the callback to be unregister.
|
2023-03-29 09:11:59 +00:00
|
|
|
* @throws { BusinessError } 201 - Verify permission denied.
|
|
|
|
* @throws { BusinessError } 202 - Permission denied, non-system app called system api.
|
2024-04-19 04:04:57 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.
|
2022-10-12 06:15:16 +00:00
|
|
|
* @syscap SystemCapability.BundleManager.BundleFramework.Core
|
|
|
|
* @systemapi
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
function off(type: BundleChangedEvent, callback?: Callback<BundleChangedInfo>): void;
|
|
|
|
}
|
|
|
|
|
2023-03-29 09:11:59 +00:00
|
|
|
export default bundleMonitor;
|