2023-07-24 12:30:40 +00:00
|
|
|
/*
|
2024-03-28 04:01:59 +00:00
|
|
|
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
2023-07-24 12:30:40 +00:00
|
|
|
* 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 MDMKit
|
2023-12-11 09:08:03 +00:00
|
|
|
*/
|
|
|
|
|
2023-07-24 12:30:40 +00:00
|
|
|
import type { AsyncCallback } from './@ohos.base';
|
|
|
|
import type Want from './@ohos.app.ability.Want';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This module provides the capability to manage the usb of the enterprise devices.
|
|
|
|
*
|
|
|
|
* @namespace usbManager
|
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @since 10
|
|
|
|
*/
|
|
|
|
declare namespace usbManager {
|
|
|
|
/**
|
|
|
|
* Usb policy
|
|
|
|
*
|
|
|
|
* @enum { number }
|
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-07-24 12:30:40 +00:00
|
|
|
*/
|
|
|
|
export enum UsbPolicy {
|
|
|
|
/**
|
|
|
|
* Policy read write
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-07-24 12:30:40 +00:00
|
|
|
*/
|
|
|
|
READ_WRITE = 0,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Policy read only
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-07-24 12:30:40 +00:00
|
|
|
*/
|
2023-11-16 09:26:05 +00:00
|
|
|
READ_ONLY = 1,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Policy disabled
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-11-16 09:26:05 +00:00
|
|
|
*/
|
|
|
|
DISABLED = 2
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* USB device ID.
|
|
|
|
*
|
|
|
|
* @typedef UsbDeviceId
|
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-11-16 09:26:05 +00:00
|
|
|
*/
|
|
|
|
export interface UsbDeviceId {
|
|
|
|
/**
|
|
|
|
* The vendor ID of the USB device.
|
|
|
|
*
|
|
|
|
* @type { number }
|
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-11-16 09:26:05 +00:00
|
|
|
*/
|
|
|
|
vendorId: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The product ID of the USB device.
|
|
|
|
*
|
|
|
|
* @type { number }
|
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-11-16 09:26:05 +00:00
|
|
|
*/
|
|
|
|
productId: number;
|
2023-07-24 12:30:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set usb policy by {@link UsbPolicy}.
|
|
|
|
* This function can be called by a super administrator.
|
|
|
|
*
|
|
|
|
* @permission ohos.permission.ENTERPRISE_MANAGE_USB
|
2024-04-26 08:46:39 +00:00
|
|
|
* @param { Want } admin - admin indicates the enterprise admin extension ability information.
|
|
|
|
* The admin must have the corresponding permission.
|
2023-07-24 12:30:40 +00:00
|
|
|
* @param { UsbPolicy } usbPolicy - usb policy code.
|
|
|
|
* @param { AsyncCallback<void> } callback - the callback of setUsbPolicy.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
|
2024-05-28 09:05:58 +00:00
|
|
|
* @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
|
|
|
|
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
|
2024-04-26 08:46:39 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
|
|
|
|
* 2. Incorrect parameter types; 3. Parameter verification failed.
|
2023-07-24 12:30:40 +00:00
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @systemapi
|
|
|
|
* @stagemodelonly
|
|
|
|
* @since 10
|
|
|
|
*/
|
|
|
|
function setUsbPolicy(admin: Want, usbPolicy: UsbPolicy, callback: AsyncCallback<void>): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set usb policy by {@link UsbPolicy}.
|
|
|
|
* This function can be called by a super administrator.
|
|
|
|
*
|
|
|
|
* @permission ohos.permission.ENTERPRISE_MANAGE_USB
|
2024-04-26 08:46:39 +00:00
|
|
|
* @param { Want } admin - admin indicates the enterprise admin extension ability information.
|
|
|
|
* The admin must have the corresponding permission.
|
2023-07-24 12:30:40 +00:00
|
|
|
* @param { UsbPolicy } usbPolicy - usb policy code.
|
|
|
|
* @returns { Promise<void> } the promise returned setUsbPolicy.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
|
2024-05-28 09:05:58 +00:00
|
|
|
* @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
|
|
|
|
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
|
2024-04-26 08:46:39 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
|
|
|
|
* 2. Incorrect parameter types; 3. Parameter verification failed.
|
2023-07-24 12:30:40 +00:00
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @systemapi
|
|
|
|
* @stagemodelonly
|
|
|
|
* @since 10
|
|
|
|
*/
|
|
|
|
function setUsbPolicy(admin: Want, usbPolicy: UsbPolicy): Promise<void>;
|
2023-11-16 09:26:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Disables USB.
|
|
|
|
* This function can be called by a super administrator.
|
|
|
|
*
|
|
|
|
* @permission ohos.permission.ENTERPRISE_MANAGE_USB
|
2024-04-26 08:46:39 +00:00
|
|
|
* @param { Want } admin - admin indicates the enterprise admin extension ability information.
|
|
|
|
* The admin must have the corresponding permission.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @param { boolean } disable - true if disable USB, otherwise false.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
|
2024-05-28 09:05:58 +00:00
|
|
|
* @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200010 - A conflict policy has been configured.
|
|
|
|
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
|
|
|
|
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
|
2024-04-26 08:46:39 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
|
|
|
|
* 2. Incorrect parameter types; 3. Parameter verification failed.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @systemapi
|
|
|
|
* @stagemodelonly
|
|
|
|
* @since 11
|
|
|
|
*/
|
|
|
|
function disableUsb(admin: Want, disable: boolean): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Queries whether USB is disabled.
|
|
|
|
* This function can be called by a super administrator.
|
|
|
|
*
|
2023-12-21 03:41:41 +00:00
|
|
|
* @permission ohos.permission.ENTERPRISE_MANAGE_USB
|
2024-04-26 08:46:39 +00:00
|
|
|
* @param { Want } admin - admin indicates the enterprise admin extension ability information.
|
|
|
|
* If the admin is not empty, it must have the corresponding permission.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @returns { boolean } true if USB is disabled, otherwise false.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
|
2024-05-28 09:05:58 +00:00
|
|
|
* @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
|
|
|
|
* @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
|
2024-04-26 08:46:39 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
|
|
|
|
* 2. Incorrect parameter types; 3. Parameter verification failed.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @systemapi
|
|
|
|
* @stagemodelonly
|
|
|
|
* @since 11
|
|
|
|
*/
|
|
|
|
function isUsbDisabled(admin: Want): boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the available USB device trust list by {@link UsbDeviceId} array.
|
|
|
|
* This function can be called by a super administrator.
|
|
|
|
*
|
|
|
|
* @permission ohos.permission.ENTERPRISE_MANAGE_USB
|
2024-04-26 08:46:39 +00:00
|
|
|
* @param { Want } admin - admin indicates the enterprise admin extension ability information.
|
|
|
|
* The admin must have the corresponding permission.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @param { Array<UsbDeviceId> } usbDeviceIds - an array of added USB device ids.
|
2024-04-26 08:46:39 +00:00
|
|
|
* The size of the array after setting cannot be greater 1000.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
|
2024-05-28 09:05:58 +00:00
|
|
|
* @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200010 - A conflict policy has been configured.
|
|
|
|
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
|
2024-04-26 08:46:39 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
|
|
|
|
* 2. Incorrect parameter types; 3. Parameter verification failed.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-11-16 09:26:05 +00:00
|
|
|
*/
|
|
|
|
function addAllowedUsbDevices(admin: Want, usbDeviceIds: Array<UsbDeviceId>): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the available USB device trust list by {@link UsbDeviceId} array.
|
|
|
|
* This function can be called by a super administrator.
|
|
|
|
*
|
|
|
|
* @permission ohos.permission.ENTERPRISE_MANAGE_USB
|
2024-04-26 08:46:39 +00:00
|
|
|
* @param { Want } admin - admin indicates the enterprise admin extension ability information.
|
|
|
|
* The admin must have the corresponding permission.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @param { Array<UsbDeviceId> } usbDeviceIds - an array of removed USB device ids.
|
2024-04-26 08:46:39 +00:00
|
|
|
* The size of the array after setting cannot be greater 1000.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
|
2024-05-28 09:05:58 +00:00
|
|
|
* @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
|
2024-04-26 08:46:39 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
|
|
|
|
* 2. Incorrect parameter types; 3. Parameter verification failed.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-11-16 09:26:05 +00:00
|
|
|
*/
|
|
|
|
function removeAllowedUsbDevices(admin: Want, usbDeviceIds: Array<UsbDeviceId>): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the available USB device trust list.
|
|
|
|
* This function can be called by a super administrator.
|
|
|
|
*
|
|
|
|
* @permission ohos.permission.ENTERPRISE_MANAGE_USB
|
2024-04-26 08:46:39 +00:00
|
|
|
* @param { Want } admin - admin indicates the enterprise admin extension ability information.
|
|
|
|
* The admin must have the corresponding permission.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @returns { Array<UsbDeviceId> } an array of the available USB device trust list.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
|
2024-05-28 09:05:58 +00:00
|
|
|
* @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
|
2024-04-26 08:46:39 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
|
|
|
|
* 2. Incorrect parameter types; 3. Parameter verification failed.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-11-16 09:26:05 +00:00
|
|
|
*/
|
|
|
|
function getAllowedUsbDevices(admin: Want): Array<UsbDeviceId>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets USB storage device access policy by {@link UsbPolicy}.
|
|
|
|
* This function can be called by a super administrator.
|
|
|
|
*
|
|
|
|
* @permission ohos.permission.ENTERPRISE_MANAGE_USB
|
2024-04-26 08:46:39 +00:00
|
|
|
* @param { Want } admin - admin indicates the enterprise admin extension ability information.
|
|
|
|
* The admin must have the corresponding permission.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @param { UsbPolicy } usbPolicy - USB policy of storage device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
|
2024-05-28 09:05:58 +00:00
|
|
|
* @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200010 - A conflict policy has been configured.
|
|
|
|
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
|
2024-04-26 08:46:39 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
|
|
|
|
* 2. Incorrect parameter types; 3. Parameter verification failed.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-11-16 09:26:05 +00:00
|
|
|
*/
|
|
|
|
function setUsbStorageDeviceAccessPolicy(admin: Want, usbPolicy: UsbPolicy): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets USB storage device access policy.
|
|
|
|
* This function can be called by a super administrator.
|
|
|
|
*
|
|
|
|
* @permission ohos.permission.ENTERPRISE_MANAGE_USB
|
2024-04-26 08:46:39 +00:00
|
|
|
* @param { Want } admin - admin indicates the enterprise admin extension ability information.
|
|
|
|
* The admin must have the corresponding permission.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @returns { UsbPolicy } USB policy of storage device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
|
2024-05-28 09:05:58 +00:00
|
|
|
* @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
|
2024-05-21 13:38:33 +00:00
|
|
|
* @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
|
2024-04-26 08:46:39 +00:00
|
|
|
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
|
|
|
|
* 2. Incorrect parameter types; 3. Parameter verification failed.
|
2023-11-16 09:26:05 +00:00
|
|
|
* @syscap SystemCapability.Customization.EnterpriseDeviceManager
|
|
|
|
* @stagemodelonly
|
2024-03-28 04:01:59 +00:00
|
|
|
* @since 12
|
2023-11-16 09:26:05 +00:00
|
|
|
*/
|
|
|
|
function getUsbStorageDeviceAccessPolicy(admin: Want): UsbPolicy;
|
2023-07-24 12:30:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default usbManager;
|