提交 b9adacdd 编写于 作者: E ester.zhou

Update docs (10398)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 5b2e96b6
...@@ -14,7 +14,7 @@ import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'; ...@@ -14,7 +14,7 @@ import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager';
## enterpriseDeviceManager.enableAdmin ## enterpriseDeviceManager.enableAdmin
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\<boolean>): void enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\<void>): void
Enables a device administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result. Enables a device administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
...@@ -22,6 +22,8 @@ Enables a device administrator application based on the specified bundle name an ...@@ -22,6 +22,8 @@ Enables a device administrator application based on the specified bundle name an
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -29,7 +31,15 @@ Enables a device administrator application based on the specified bundle name an ...@@ -29,7 +31,15 @@ Enables a device administrator application based on the specified bundle name an
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. | | enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. |
| type | [AdminType](#admintype) | Yes | Type of the device administrator to enable. | | type | [AdminType](#admintype) | Yes | Type of the device administrator to enable. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
| Type | Description |
| ------- | --------------------------------------------------------------- |
| 9200003 | The administrator ability component is invalid. |
| 9200004 | Failed to activate the administrator application of the device. |
| 9200007 | The system ability work abnormally. |
**Example** **Example**
...@@ -42,18 +52,18 @@ let enterpriseInfo = { ...@@ -42,18 +52,18 @@ let enterpriseInfo = {
name: "enterprise name", name: "enterprise name",
description: "enterprise description" description: "enterprise description"
} }
enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, (error, result) => { enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, error => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
} }
console.log("result is " + result); console.log("enableAdmin success");
}); });
``` ```
## enterpriseDeviceManager.enableAdmin ## enterpriseDeviceManager.enableAdmin
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\<boolean>): void enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\<void>): void
Enables a device administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result. Enables a device administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
...@@ -61,6 +71,8 @@ Enables a device administrator application based on the specified bundle name an ...@@ -61,6 +71,8 @@ Enables a device administrator application based on the specified bundle name an
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -69,7 +81,15 @@ Enables a device administrator application based on the specified bundle name an ...@@ -69,7 +81,15 @@ Enables a device administrator application based on the specified bundle name an
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. | | enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. |
| type | [AdminType](#admintype) | Yes | Type of the device administrator to enable. | | type | [AdminType](#admintype) | Yes | Type of the device administrator to enable. |
| userId | number | Yes | User ID The default value is the user ID of the caller. The value must be greater than or equal to 0.| | userId | number | Yes | User ID The default value is the user ID of the caller. The value must be greater than or equal to 0.|
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Error codes**
| Type | Description |
| ------- | --------------------------------------------------------------- |
| 9200003 | The administrator ability component is invalid. |
| 9200004 | Failed to activate the administrator application of the device. |
| 9200007 | The system ability work abnormally. |
**Example** **Example**
...@@ -82,18 +102,18 @@ let enterpriseInfo = { ...@@ -82,18 +102,18 @@ let enterpriseInfo = {
name: "enterprise name", name: "enterprise name",
description: "enterprise description" description: "enterprise description"
} }
enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100, (error, result) => { enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100, error => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
} }
console.log("result is " + result); console.log("enableAdmin success");
}); });
``` ```
## enterpriseDeviceManager.enableAdmin ## enterpriseDeviceManager.enableAdmin
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\<boolean> enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\<void>
Enables a device administrator application based on the specified bundle name and class name. This API uses a promise to return the result. Enables a device administrator application based on the specified bundle name and class name. This API uses a promise to return the result.
...@@ -101,6 +121,8 @@ Enables a device administrator application based on the specified bundle name an ...@@ -101,6 +121,8 @@ Enables a device administrator application based on the specified bundle name an
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -114,7 +136,15 @@ Enables a device administrator application based on the specified bundle name an ...@@ -114,7 +136,15 @@ Enables a device administrator application based on the specified bundle name an
| Type | Description | | Type | Description |
| ----------------- | ----------------- | | ----------------- | ----------------- |
| Promise\<boolean> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Error codes**
| Type | Description |
| ------- | --------------------------------------------------------------- |
| 9200003 | The administrator ability component is invalid. |
| 9200004 | Failed to activate the administrator application of the device. |
| 9200007 | The system ability work abnormally. |
**Example** **Example**
...@@ -128,16 +158,14 @@ let enterpriseInfo = { ...@@ -128,16 +158,14 @@ let enterpriseInfo = {
description: "enterprise description" description: "enterprise description"
} }
enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100) enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100)
.then((result) => { .catch(error => {
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
``` ```
## enterpriseDeviceManager.disableAdmin ## enterpriseDeviceManager.disableAdmin
disableAdmin(admin: Want, callback: AsyncCallback\<boolean>): void disableAdmin(admin: Want, callback: AsyncCallback\<void>): void
Disables a device common administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result. Disables a device common administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
...@@ -145,12 +173,20 @@ Disables a device common administrator application based on the specified bundle ...@@ -145,12 +173,20 @@ Disables a device common administrator application based on the specified bundle
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------------- | ---- | ------------------- | | -------- | ----------------------------------- | ---- | ------------------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
| Type | Description |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
**Example** **Example**
...@@ -159,18 +195,18 @@ let wantTemp = { ...@@ -159,18 +195,18 @@ let wantTemp = {
bundleName: "bundleName", bundleName: "bundleName",
abilityName: "abilityName", abilityName: "abilityName",
}; };
enterpriseDeviceManager.disableAdmin(wantTemp, (error, result) => { enterpriseDeviceManager.disableAdmin(wantTemp, error => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
} }
console.log("result is " + result); console.log("disableAdmin success ");
}); });
``` ```
## enterpriseDeviceManager.disableAdmin ## enterpriseDeviceManager.disableAdmin
disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<boolean>): void disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<void>): void
Disables a device common administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result. Disables a device common administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
...@@ -178,13 +214,21 @@ Disables a device common administrator application based on the specified bundle ...@@ -178,13 +214,21 @@ Disables a device common administrator application based on the specified bundle
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------------- | ---- | ---------------------------- | | -------- | ----------------------------------- | ---- | ---------------------------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. |
| userId | number | Yes | User ID The default value is the user ID of the caller. The value must be greater than or equal to 0.| | userId | number | Yes | User ID The default value is the user ID of the caller. The value must be greater than or equal to 0.|
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Error codes**
| Type | Description |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
**Example** **Example**
...@@ -193,18 +237,18 @@ let wantTemp = { ...@@ -193,18 +237,18 @@ let wantTemp = {
bundleName: "bundleName", bundleName: "bundleName",
abilityName: "abilityName", abilityName: "abilityName",
}; };
enterpriseDeviceManager.disableAdmin(wantTemp, 100, (error, result) => { enterpriseDeviceManager.disableAdmin(wantTemp, 100, error => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
} }
console.log("result is " + result); console.log("disableAdmin success ");
}); });
``` ```
## enterpriseDeviceManager.disableAdmin ## enterpriseDeviceManager.disableAdmin
disableAdmin(admin: Want, userId?: number): Promise\<boolean> disableAdmin(admin: Want, userId?: number): Promise\<void>
Disables a device common administrator application based on the specified bundle name and class name. This API uses a promise to return the result. Disables a device common administrator application based on the specified bundle name and class name. This API uses a promise to return the result.
...@@ -212,6 +256,8 @@ Disables a device common administrator application based on the specified bundle ...@@ -212,6 +256,8 @@ Disables a device common administrator application based on the specified bundle
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -223,7 +269,13 @@ Disables a device common administrator application based on the specified bundle ...@@ -223,7 +269,13 @@ Disables a device common administrator application based on the specified bundle
| Type | Description | | Type | Description |
| ----------------- | ----------------- | | ----------------- | ----------------- |
| Promise\<boolean> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Error codes**
| Type | Description |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
**Example** **Example**
...@@ -232,49 +284,61 @@ let wantTemp = { ...@@ -232,49 +284,61 @@ let wantTemp = {
bundleName: "bundleName", bundleName: "bundleName",
abilityName: "abilityName", abilityName: "abilityName",
}; };
enterpriseDeviceManager.disableAdmin(wantTemp, 100).then((result) => { enterpriseDeviceManager.disableAdmin(wantTemp, 100).catch(error => {
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
``` ```
## enterpriseDeviceManager.disableSuperAdmin ## enterpriseDeviceManager.disableSuperAdmin
disableSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void
Disables a device super administrator application based on the specified bundle name. This API uses an asynchronous callback to return the result. Disables a device super administrator application based on the specified bundle name. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ----------------------- | ---- | ------------------- | | ---------- | ----------------------- | ---- | ------------------- |
| bundleName | String | Yes | Bundle name of the device super administrator application. | | bundleName | String | Yes | Bundle name of the device super administrator application. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
| Type | Description |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
**Example** **Example**
```js ```js
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
enterpriseDeviceManager.disableSuperAdmin(bundleName, (error, result) => { enterpriseDeviceManager.disableSuperAdmin(bundleName, error => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
} }
console.log("result is " + result); console.log("disableSuperAdmin success");
}); });
``` ```
## enterpriseDeviceManager.disableSuperAdmin ## enterpriseDeviceManager.disableSuperAdmin
disableSuperAdmin(bundleName: String): Promise\<boolean> disableSuperAdmin(bundleName: String): Promise\<void>
Disables a device super administrator application based on the specified bundle name. This API uses a promise to return the result. Disables a device super administrator application based on the specified bundle name. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -285,15 +349,19 @@ Disables a device super administrator application based on the specified bundle ...@@ -285,15 +349,19 @@ Disables a device super administrator application based on the specified bundle
| Type | Description | | Type | Description |
| ----------------- | ----------------- | | ----------------- | ----------------- |
| Promise\<boolean> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Error codes**
| Type | Description |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
**Example** **Example**
```js ```js
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
enterpriseDeviceManager.disableSuperAdmin(bundleName).then((result) => { enterpriseDeviceManager.disableSuperAdmin(bundleName).catch(error => {
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
``` ```
...@@ -306,6 +374,8 @@ Checks whether a device administrator application is enabled based on the specif ...@@ -306,6 +374,8 @@ Checks whether a device administrator application is enabled based on the specif
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -313,6 +383,12 @@ Checks whether a device administrator application is enabled based on the specif ...@@ -313,6 +383,12 @@ Checks whether a device administrator application is enabled based on the specif
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.| | callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.|
**Error codes**
| Type | Description |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
**Example** **Example**
```js ```js
...@@ -337,6 +413,8 @@ Checks whether a device administrator application is enabled based on the specif ...@@ -337,6 +413,8 @@ Checks whether a device administrator application is enabled based on the specif
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -369,6 +447,8 @@ Checks whether a device administrator application is enabled based on the specif ...@@ -369,6 +447,8 @@ Checks whether a device administrator application is enabled based on the specif
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -404,6 +484,8 @@ Checks whether a device super administrator application is enabled based on the ...@@ -404,6 +484,8 @@ Checks whether a device super administrator application is enabled based on the
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -432,6 +514,8 @@ Checks whether a device super administrator application is enabled based on the ...@@ -432,6 +514,8 @@ Checks whether a device super administrator application is enabled based on the
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -469,6 +553,13 @@ Obtains a **DeviceSettingsManager** object. This API uses an asynchronous callba ...@@ -469,6 +553,13 @@ Obtains a **DeviceSettingsManager** object. This API uses an asynchronous callba
| -------- | --------------------------------------- | ---- | ----------------------------------- | | -------- | --------------------------------------- | ---- | ----------------------------------- |
| callback | AsyncCallback<[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)&gt; | Yes | Callback used to return the **DeviceSettingsManager** object obtained.| | callback | AsyncCallback<[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)&gt; | Yes | Callback used to return the **DeviceSettingsManager** object obtained.|
**Error codes**
| Type | Description |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**Example** **Example**
```js ```js
...@@ -478,14 +569,12 @@ let wantTemp = { ...@@ -478,14 +569,12 @@ let wantTemp = {
}; };
enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => { enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error code:" + error.code);
return; return;
} }
mgr.setDateTime(wantTemp, 1526003846000, (error, value) => { mgr.setDateTime(wantTemp, 1526003846000, (error) => {
if (error != null) { if (error != null) {
console.log(error); console.log("error code:" + error.code);
} else {
console.log(value);
} }
}); });
}); });
...@@ -505,6 +594,13 @@ Obtains a **DeviceSettingsManager** object. This API uses a promise to return th ...@@ -505,6 +594,13 @@ Obtains a **DeviceSettingsManager** object. This API uses a promise to return th
| ------------------------------------ | ---------------------------------- | | ------------------------------------ | ---------------------------------- |
| Promise&lt;[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)&gt; | Promise used to return the **DeviceSettingsManager** object obtained.| | Promise&lt;[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)&gt; | Promise used to return the **DeviceSettingsManager** object obtained.|
**Error codes**
| Type | Description |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**Example** **Example**
```js ```js
...@@ -513,31 +609,39 @@ let wantTemp = { ...@@ -513,31 +609,39 @@ let wantTemp = {
abilityName: "abilityName", abilityName: "abilityName",
}; };
enterpriseDeviceManager.getDeviceSettingsManager().then((mgr) => { enterpriseDeviceManager.getDeviceSettingsManager().then((mgr) => {
mgr.setDateTime(wantTemp, 1526003846000).then((value) => { mgr.setDateTime(wantTemp, 1526003846000).catch((error) => {
console.log(value); console.log("error code:" + error.code);
}).catch((error) => {
console.log(error);
}) })
}).catch((error) => { }).catch((error) => {
console.log(error); console.log("error code:" + error.code);
}) })
``` ```
## enterpriseDeviceManager.setEnterpriseInfo ## enterpriseDeviceManager.setEnterpriseInfo
setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback&lt;boolean&gt;): void setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback\<void>;): void
Sets the enterprise information of a device administrator application. This API uses an asynchronous callback to return the result. Sets the enterprise information of a device administrator application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.SET_ENTERPRISE_INFO
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------- | ----------------------------------- | ---- | ---------------------- | | -------------- | ----------------------------------- | ---- | ---------------------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. | | enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. |
| callback | AsyncCallback\<boolean&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback\<void>; | Yes | Callback used to return the result.|
**Error codes**
| Type | Description |
| ------- | ----------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
**Example** **Example**
...@@ -550,22 +654,27 @@ let enterpriseInfo = { ...@@ -550,22 +654,27 @@ let enterpriseInfo = {
name: "enterprise name", name: "enterprise name",
description: "enterprise description" description: "enterprise description"
} }
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo, error => {
.then((result) => { if (error != null) {
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
return;
}
console.log("setEnterpriseInfo success");
}); });
``` ```
## enterpriseDeviceManager.setEnterpriseInfo ## enterpriseDeviceManager.setEnterpriseInfo
setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise&lt;boolean&gt; setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\<void>;
Sets the enterprise information of a device administrator application. This API uses a promise to return the result. Sets the enterprise information of a device administrator application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.SET_ENTERPRISE_INFO
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -577,7 +686,13 @@ Sets the enterprise information of a device administrator application. This API ...@@ -577,7 +686,13 @@ Sets the enterprise information of a device administrator application. This API
| Type | Description | | Type | Description |
| ----------------- | --------------------- | | ----------------- | --------------------- |
| Promise\<boolean> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Error codes**
| Type | Description |
| ------- | ----------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
**Example** **Example**
...@@ -590,10 +705,7 @@ let enterpriseInfo = { ...@@ -590,10 +705,7 @@ let enterpriseInfo = {
name: "enterprise name", name: "enterprise name",
description: "enterprise description" description: "enterprise description"
} }
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo).catch(error => {
.then((result) => {
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
``` ```
...@@ -606,6 +718,8 @@ Obtains the enterprise information of a device administrator application. This A ...@@ -606,6 +718,8 @@ Obtains the enterprise information of a device administrator application. This A
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -613,6 +727,12 @@ Obtains the enterprise information of a device administrator application. This A ...@@ -613,6 +727,12 @@ Obtains the enterprise information of a device administrator application. This A
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. |
| callback | AsyncCallback&lt;[EnterpriseInfo](#enterpriseinfo)&gt; | Yes | Callback used to return the enterprise information of the device administrator application.| | callback | AsyncCallback&lt;[EnterpriseInfo](#enterpriseinfo)&gt; | Yes | Callback used to return the enterprise information of the device administrator application.|
**Error codes**
| Type | Description |
| ------- | ----------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
**Example** **Example**
```js ```js
...@@ -638,6 +758,8 @@ Obtains the enterprise information of a device administrator application. This A ...@@ -638,6 +758,8 @@ Obtains the enterprise information of a device administrator application. This A
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -650,6 +772,12 @@ Obtains the enterprise information of a device administrator application. This A ...@@ -650,6 +772,12 @@ Obtains the enterprise information of a device administrator application. This A
| ---------------------------------------- | ------------------------- | | ---------------------------------------- | ------------------------- |
| Promise&lt;[EnterpriseInfo](#enterpriseinfo)&gt; | Promise used to return the enterprise information of the device administrator application.| | Promise&lt;[EnterpriseInfo](#enterpriseinfo)&gt; | Promise used to return the enterprise information of the device administrator application.|
**Error codes**
| Type | Description |
| ------- | ----------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
**Example** **Example**
```js ```js
...@@ -665,6 +793,154 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { ...@@ -665,6 +793,154 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => {
}); });
``` ```
## enterpriseDeviceManager.subscribeManagedEvent
subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void
Subscribes to system management events. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.|
| managedEvents | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to subscribe to.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the subscription is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Example**
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
let events = [0, 1];
enterpriseDeviceManager.subscribeManagedEvent(wantTemp, events, (error) => {
if (error) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## enterpriseDeviceManager.subscribeManagedEvent
subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void>
Subscribes to system management events. This API uses a promise to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.|
| managedEvents | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to subscribe to.|
**Return value**
| Type | Description |
| ----- | ----------------------------------- |
| Promise\<void> | Promise used to return the result. Promise that returns no value.|
**Example**
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
let events = [0, 1];
enterpriseDeviceManager.subscribeManagedEvent(wantTemp, events).then(() => {
}).catch((error) => {
console.log("error code:" + error.code + " error message:" + error.message);
})
```
## enterpriseDeviceManager.unsubscribeManagedEvent
unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void
Unsubscribes from system management events. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.|
| managedEvents | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to unsubscribe from.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the unsubscription is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Example**
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
let events = [0, 1];
enterpriseDeviceManager.unsubscribeManagedEvent(wantTemp, events, (error) => {
if (error) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## enterpriseDeviceManager.unsubscribeManagedEvent
unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void>
Unsubscribes from system management events. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.|
| managedEvents | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to unsubscribe from.|
**Return value**
| Type | Description |
| ----- | ----------------------------------- |
| Promise\<void> | Promise used to return the result. Promise that returns no value.|
**Example**
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
let events = [0, 1];
enterpriseDeviceManager.unsubscribeManagedEvent(wantTemp, events).then(() => {
}).catch((error) => {
console.log("error code:" + error.code + " error message:" + error.message);
})
```
## EnterpriseInfo ## EnterpriseInfo
Describes the enterprise information of a device administrator application. Describes the enterprise information of a device administrator application.
...@@ -686,3 +962,14 @@ Enumerates the administrator types of the device administrator application. ...@@ -686,3 +962,14 @@ Enumerates the administrator types of the device administrator application.
| ----------------- | ---- | ----- | | ----------------- | ---- | ----- |
| ADMIN_TYPE_NORMAL | 0x00 | Common administrator.| | ADMIN_TYPE_NORMAL | 0x00 | Common administrator.|
| ADMIN_TYPE_SUPER | 0x01 | Super administrator.| | ADMIN_TYPE_SUPER | 0x01 | Super administrator.|
## ManagedEvent
Enumerates the system management events that can be subscribed to.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
| Name | Default Value | Description |
| ----------------- | ---- | ----- |
| MANAGED_EVENT_BUNDLE_ADDED | 0 | Application installation event.|
| MANAGED_EVENT_BUNDLE_REMOVED | 1 | Application uninstallation event.|
...@@ -28,10 +28,12 @@ setDateTime(admin: Want, time: number, callback: AsyncCallback\<void>): void ...@@ -28,10 +28,12 @@ setDateTime(admin: Want, time: number, callback: AsyncCallback\<void>): void
Sets the system time. This API uses an asynchronous callback to return the result. Sets the system time. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.EDM_MANAGE_DATETIME **Required permissions**: ohos.permission.ENTERPRISE_SET_DATETIME
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -40,6 +42,13 @@ Sets the system time. This API uses an asynchronous callback to return the resul ...@@ -40,6 +42,13 @@ Sets the system time. This API uses an asynchronous callback to return the resul
| time | number | Yes| Timestamp (ms).| | time | number | Yes| Timestamp (ms).|
| callback | AsyncCallback\<void> | Yes| Callback used to the result. If the system time is set successfully, **err** is **null**; otherwise, **err** is an error object.| | callback | AsyncCallback\<void> | Yes| Callback used to the result. If the system time is set successfully, **err** is **null**; otherwise, **err** is an error object.|
**Error codes**
| Type | Description |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**Example** **Example**
```js ```js
...@@ -68,10 +77,12 @@ setDateTime(admin: Want, time: number): Promise\<void> ...@@ -68,10 +77,12 @@ setDateTime(admin: Want, time: number): Promise\<void>
Sets the system time. This API uses a promise to return the result. Sets the system time. This API uses a promise to return the result.
**Required permissions**: ohos.permission.EDM_MANAGE_DATETIME **Required permissions**: ohos.permission.ENTERPRISE_SET_DATETIME
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -85,6 +96,13 @@ Sets the system time. This API uses a promise to return the result. ...@@ -85,6 +96,13 @@ Sets the system time. This API uses a promise to return the result.
| ----- | ----------------------------------- | | ----- | ----------------------------------- |
| Promise\<void> | Promise that returns no value.| | Promise\<void> | Promise that returns no value.|
**Error codes**
| Type | Description |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**Example** **Example**
```js ```js
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册