harmony 鸿蒙MDM Kit Development
MDM Kit Development
Introduction
An device administrator application is an application with the EnterpriseAdminExtensionAbility. It implements functions such as enterprise device management and event listening, application management, feature restriction management, security management, device settings, device control, device information acquisition, hardware peripheral management, system management, and network management. For details about the APIs, see MDM Kit.
How to Develop
To develop a device administrator application, perform the following steps:
Create an EnterpriseAdminExtensionAbility instance.
Declare the permissions required by the device administrator application.
Develop and debug MDM functionalities.
Creating an EnterpriseAdminExtensionAbility Instance
For details, see EnterpriseAdminExtensionAbility Development.
Declaring Required Permissions
Before declaring the required permissions, ensure that the basic principles for using permissions are met. Then, declare the permissions required by the application under requestPermissions in the module.json5 file of the module of the project.
Example:
"requestPermissions": [
{
"name": "ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN"
},
]
NOTE
The required permissions vary with the API to call. For details, see Enterprise Device Management and other related APIs.
Developing MDM Functionalities
- Import modules.
MDM Kit provides a wide variety of of APIs for application management, communication management, security management, feature restriction management, intra-system management, device settings and query, device control, and more. Import related modules based on service requirements. In this example, adminManager and restrictions are imported.
import { adminManager, restrictions } from '@kit.MDMKit';
- Call APIs to implement related functionalities. For example, disable Wi-Fi for devices.
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.xxx',
abilityName: 'EnterpriseAdminAbility',
};
try {
restrictions.setDisallowedPolicy(wantTemp, "wifi", true);
console.info("disable wifi success.");
} catch (error) {
console.info("disable wifi fail.");
}
Debugging
The MDM APIs can be called only after the EnterpriseAdminExtensionAbility is enabled. During the debugging process, you can use the following hdc commands to enable and disable an EnterpriseAdminExtensionAbility:
:: Enable an EnterpriseAdminExtensionAbility.
hdc shell edm enable-admin -n Bundle_name -a EnterpriseAdminExtensionAbility class name
:: Disable an EnterpriseAdminExtensionAbility.
hdc shell edm disable-admin -n Bundle_name
NOTE
Only one super device administrator application can be enabled on a device.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙MDM Kit (Enterprise Device Management)
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦