From 192ffada035563c945987b8b9d89b4e6d7c2486d Mon Sep 17 00:00:00 2001 From: caiminggang Date: Thu, 7 Jul 2022 14:35:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0EnterpriseAdminExtentionAbili?= =?UTF-8?q?ty=E6=A8=A1=E5=9D=97=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: caiminggang --- ...js-apis-EnterpriseAdminExtensionAbility.md | 25 +- .../apis/js-apis-enterprise-device-manager.md | 236 +++++++++--------- 2 files changed, 127 insertions(+), 134 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md index e8a0380bda..66134b703f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md @@ -1,11 +1,15 @@ # EnterpriseAdminExtentionAbility -EnterpriseAdminExtentionAbility模块提供企业管理员应用扩展相关接口。 +本模块提供企业管理员应用拓展能力。 + +企业管理员应用需要存在一个EnterpriseAdminExtentionAbility并重写相关接口,以此具备模块提供的各项能力,比如接收由系统发送的该应用被激活或者去激活的通知。 > **说明:** > -> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> > 本模块接口仅可在Stage模型下使用。 + ## 导入模块 ```ts @@ -22,12 +26,12 @@ onAdminEnabled(): void **示例:** - ```ts +```ts export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { - onAdminEnabled() { - } + onAdminEnabled() { + } }; - ``` +``` ## EnterpriseAdminExtentionAbility.onAdminDisabled @@ -38,11 +42,10 @@ onAdminDisabled(): void **系统能力**:SystemCapability.Customation.EnterpriseDeviceManager **示例:** - - ```ts +```ts export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { - onAdminDisabled() { - } + onAdminDisabled() { + } }; - ``` \ No newline at end of file +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md index 1a739fc62a..b7ed9ce4c2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md @@ -1,17 +1,17 @@ # 企业设备管理 +本模块提供企业设备管理能力,使设备具备企业场景下所需的定制能力。 + > **说明:** -> +> > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - ## 导入模块 ```js import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'; ``` - ## enterpriseDeviceManager.enableAdmin enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number, callback: AsyncCallback\): void @@ -26,24 +26,24 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ----------------------------------- | ---- | ----------------------------------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | -| type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ----------------------------------- | --- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | +| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | +| type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback\ | 是 | callback方式返回是否激活成功 | +| callback | AsyncCallback\ | 是 | callback方式返回是否激活成功 | **示例**: ```js let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility", }; let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" + name: "enterprise name", + description: "enterprise description" } enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100, (error, result) => { if (error != null) { @@ -68,11 +68,11 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ----------------------------------- | ---- | ----------------------------------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | -| type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ----------------------------------- | --- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | +| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | +| type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | **返回值:** @@ -85,18 +85,18 @@ SystemCapability.Customation.EnterpriseDeviceManager ```js let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility", }; let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" + name: "enterprise name", + description: "enterprise description" } enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100) .then((result) => { - console.log("result is " + result); + console.log("result is " + result); }).catch(error => { - console.log("error occurs" + error); + console.log("error occurs" + error); }); ``` @@ -114,18 +114,18 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------- | ---- | ----------------------------------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------- | --- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | +| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | **示例**: ```js let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", + bundleName: "bundleName", + abilityName: "abilityName", }; enterpriseDeviceManager.disableAdmin(wantTemp, 100, (error, result) => { if (error != null) { @@ -136,8 +136,6 @@ enterpriseDeviceManager.disableAdmin(wantTemp, 100, (error, result) => { }); ``` - - ## enterpriseDeviceManager.disableAdmin disableAdmin(admin: Want, userId?: number): Promise\ @@ -152,9 +150,9 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------------------------------- | ---- | ----------------------------------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------------------------------- | --- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | **返回值:** @@ -167,13 +165,13 @@ SystemCapability.Customation.EnterpriseDeviceManager ```js let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", + bundleName: "bundleName", + abilityName: "abilityName", }; enterpriseDeviceManager.disableAdmin(wantTemp, 100).then((result) => { - console.log("result is " + result); + console.log("result is " + result); }).catch(error => { - console.log("error occurs" + error); + console.log("error occurs" + error); }); ``` @@ -188,10 +186,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ----------------------- | ---- | ------------------- | -| bundleName | String | 是 | 超级设备管理员应用的包名 | -| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------- | --- | ------------------- | +| bundleName | String | 是 | 超级设备管理员应用的包名 | +| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | **示例**: @@ -217,9 +215,9 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------ | ---- | ------------ | -| bundleName | String | 是 | 超级设备管理员应用的包名 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | --- | ------------ | +| bundleName | String | 是 | 超级设备管理员应用的包名 | **返回值:** @@ -232,9 +230,9 @@ SystemCapability.Customation.EnterpriseDeviceManager ```js let bundleName = "com.example.myapplication"; enterpriseDeviceManager.disableSuperAdmin(bundleName).then((result) => { - console.log("result is " + result); + console.log("result is " + result); }).catch(error => { - console.log("error occurs" + error); + console.log("error occurs" + error); }); ``` @@ -249,18 +247,18 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------- | ---- | ----------------------------------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------- | --- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback\ | 是 | callback方式返回是否处于激活状态 | +| callback | AsyncCallback\ | 是 | callback方式返回是否处于激活状态 | **示例**: ```js let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", + bundleName: "bundleName", + abilityName: "abilityName", }; enterpriseDeviceManager.isAdminEnabled(wantTemp, 100, (error, result) => { if (error != null) { @@ -271,8 +269,6 @@ enterpriseDeviceManager.isAdminEnabled(wantTemp, 100, (error, result) => { }); ``` - - ## enterpriseDeviceManager.isAdminEnabled isAdminEnabled(admin: Want, userId?: number): Promise\ @@ -284,9 +280,9 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------------------------------- | ---- | ----------------------------------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------------------------------- | --- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | **返回值:** @@ -299,13 +295,13 @@ SystemCapability.Customation.EnterpriseDeviceManager ```js let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", + bundleName: "bundleName", + abilityName: "abilityName", }; enterpriseDeviceManager.isAdminEnabled(wantTemp, 100).then((result) => { - console.log("result is " + result); + console.log("result is " + result); }).catch(error => { - console.log("error occurs" + error); + console.log("error occurs" + error); }); ``` @@ -320,10 +316,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ----------------------- | ---- | -------------------- | -| bundleName | String | 是 | 设备管理员应用 | -| callback | AsyncCallback\ | 是 | callback方式返回是否处于激活状态 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------- | --- | -------------------- | +| bundleName | String | 是 | 设备管理员应用 | +| callback | AsyncCallback\ | 是 | callback方式返回是否处于激活状态 | **示例**: @@ -338,8 +334,6 @@ enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => { }); ``` - - ## enterpriseDeviceManager.isSuperAdmin isSuperAdmin(bundleName: String): Promise\ @@ -351,9 +345,9 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------ | ---- | --------- | -| bundleName | String | 是 | 超级设备管理员应用 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | --- | --------- | +| bundleName | String | 是 | 超级设备管理员应用 | **返回值:** @@ -366,9 +360,9 @@ SystemCapability.Customation.EnterpriseDeviceManager ```js let bundleName = "com.example.myapplication"; enterpriseDeviceManager.isSuperAdmin(bundleName).then((result) => { - console.log("result is " + result); + console.log("result is " + result); }).catch(error => { - console.log("error occurs" + error); + console.log("error occurs" + error); }); ``` @@ -383,16 +377,16 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------- | ---- | ----------------------------------- | -| callback | AsyncCallback { if (error != null) { @@ -409,7 +403,6 @@ enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => { }); ``` - ## enterpriseDeviceManager.getDeviceSettingsManager getDeviceSettingsManager(): Promise<DeviceSettingsManager> @@ -429,8 +422,8 @@ SystemCapability.Customation.EnterpriseDeviceManager ```js let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", + bundleName: "bundleName", + abilityName: "abilityName", }; mgr.getDeviceSettingsManager().then((mgr) => { mgr.setDateTime(wantTemp, 1526003846000).then((value) => { @@ -454,32 +447,31 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ----------------------------------- | ---- | ---------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | -| callback | AsyncCallback\ { - console.log("result is " + result); + console.log("result is " + result); }).catch(error => { - console.log("error occurs" + error); + console.log("error occurs" + error); }); ``` - ## enterpriseDeviceManager.setEnterpriseInfo setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise<boolean> @@ -491,10 +483,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ----------------------------------- | ---- | ------------ | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ----------------------------------- | --- | ------------ | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | +| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | **返回值:** @@ -506,18 +498,18 @@ SystemCapability.Customation.EnterpriseDeviceManager ```js let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility", }; let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" + name: "enterprise name", + description: "enterprise description" } enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) .then((result) => { - console.log("result is " + result); + console.log("result is " + result); }).catch(error => { - console.log("error occurs" + error); + console.log("error occurs" + error); }); ``` @@ -532,17 +524,17 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ------------------------ | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | -| callback | AsyncCallback<[EnterpriseInfo](#EnterpriseInfo)> | 是 | callback方式返回设备管理员应用的企业信息 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------ | --- | ------------------------ | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | +| callback | AsyncCallback<[EnterpriseInfo](#EnterpriseInfo)> | 是 | callback方式返回设备管理员应用的企业信息 | **示例:** ```js let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility", }; enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => { if (error != null) { @@ -550,11 +542,10 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => { return; } console.log(result.name); - console.log(result.description); + console.log(result.description); }); ``` - ## enterpriseDeviceManager.getEnterpriseInfo getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> @@ -566,28 +557,28 @@ SystemCapability.Customation.EnterpriseDeviceManager **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | --- | ------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ------------------------- | +| 类型 | 说明 | +| ------------------------------------------------ | ------------------------- | | Promise<[EnterpriseInfo](#EnterpriseInfo)> | Promise方式返回设备管理员应用的企业信息对象 | **示例:** ```js let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility", }; enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { - console.log(result.name); - console.log(result.description); + console.log(result.name); + console.log(result.description); }).catch(error => { - console.log("error occurs" + error); + console.log("error occurs" + error); }); ``` @@ -602,7 +593,6 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { | name | 只读 | string | 是 | 表示设备管理员应用所属企业的名称。 | | description | 只读 | string | 是 | 表示设备管理员应用所属企业的描述。 | - ## AdminType 设备管理员应用的管理员类型。 -- GitLab