From 5c5664c61922b1f7ecd7103fa03e8a685c3fb840 Mon Sep 17 00:00:00 2001 From: caiminggang Date: Wed, 9 Mar 2022 17:36:17 +0800 Subject: [PATCH] Add API for enterpriseDeviceManager Signed-off-by: caiminggang --- api/@ohos.enterpriseDeviceManager.d.ts | 154 ++++++++++++++++++ .../DeviceSettingsManager.d.ts | 39 +++++ 2 files changed, 193 insertions(+) create mode 100644 api/@ohos.enterpriseDeviceManager.d.ts create mode 100644 api/enterpriseDeviceManager/DeviceSettingsManager.d.ts diff --git a/api/@ohos.enterpriseDeviceManager.d.ts b/api/@ohos.enterpriseDeviceManager.d.ts new file mode 100644 index 0000000000..a4b105912f --- /dev/null +++ b/api/@ohos.enterpriseDeviceManager.d.ts @@ -0,0 +1,154 @@ +/* + * 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. + */ + +import { AsyncCallback, Callback } from "./basic"; +import { DeviceSettingsManager } from "./enterpriseDeviceManager/DeviceSettingsManager"; +import { Want } from "./ability/want"; + +/** + * enterprise device manager. + * @name enterpriseDeviceManager + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + */ +declare namespace enterpriseDeviceManager { + + /** + * @name EnterpriseInfo + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @import NA + * @permission NA + */ + export interface EnterpriseInfo { + name: string; + description: string; + } + + /** + * @name AdminType + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @import NA + * @permission NA + */ + export enum AdminType { + ADMIN_TYPE_NORMAL = 0x00, + ADMIN_TYPE_SUPER = 0x01 + } + + /** + * Activates the given ability as a administrator of the device. + * + * Only apps with the ohos.permission.MANAGE_ADMIN permission or the shell uid can call this method. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @param enterpriseInfo Indicates the enterprise information of the calling application. + * @param type Indicates the type of administrator to set. + * @return {@code true} if activates administrator success. + * @permission ohos.permission.MANAGE_ADMIN + */ + function activateAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback): void; + function activateAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType): Promise; + + /** + * Deactivates a current normal administrator ability. + * + * Only apps with the ohos.permission.MANAGE_ADMIN permission or the shell uid can call this method. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @return {@code true} if deactivates administrator success. + * @permission ohos.permission.MANAGE_ADMIN + */ + function deactivateAdmin(admin: Want, callback: AsyncCallback): void; + function deactivateAdmin(admin: Want): Promise; + + /** + * Deactivates a current super administrator ability. + * + * Only the administrator app or apps with the shell uid can call this method. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param bundleName Indicates the administrator bundle information. + * @return {@code true} if deactivates super administrator success. + */ + function deactivateSuperAdmin(bundleName: String, callback: AsyncCallback): void; + function deactivateSuperAdmin(bundleName: String): Promise; + + /** + * Get whether the ability is activated as device administrator. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @return {@code true} if the administrator is active. + */ + function isAdminAppActive(admin: Want, callback: AsyncCallback): void; + function isAdminAppActive(admin: Want): Promise; + + /** + * Get information of the administrator's enterprise. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @return Returns the enterprise information of the administrator. + */ + function getEnterpriseInfo(admin: Want, callback: AsyncCallback): void; + function getEnterpriseInfo(admin: Want): Promise; + + /** + * Set the information of the administrator's enterprise. + * + * Only the administrator app can call this method. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @param enterpriseInfo Indicates the enterprise information of the calling application. + * @return {@code true} if sets enterprise information success. + */ + function setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback): void; + function setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise; + + /** + * Get whether the ability is activated as super device administrator. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param bundleName Indicates the administrator bundle information. + * @return {@code true} if the administrator is activated as super device administrator. + */ + function isSuperAdmin(bundleName: String, callback: AsyncCallback): void; + function isSuperAdmin(bundleName: String): Promise; + + /** + * Obtains the interface used to set device settings policy. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @return Returns the DeviceSettingsManager interface. + */ + function getDeviceSettingsManager(callback: AsyncCallback): void; + function getDeviceSettingsManager(): Promise; + +} + +export default enterpriseDeviceManager; \ No newline at end of file diff --git a/api/enterpriseDeviceManager/DeviceSettingsManager.d.ts b/api/enterpriseDeviceManager/DeviceSettingsManager.d.ts new file mode 100644 index 0000000000..b355a3647f --- /dev/null +++ b/api/enterpriseDeviceManager/DeviceSettingsManager.d.ts @@ -0,0 +1,39 @@ +/* + * 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. + */ + +import { AsyncCallback, Callback } from "./../basic"; +import { Want } from "./../ability/want"; + +/** + * @name Offers set settings policies on the devices. + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @permission NA + */ +export interface DeviceSettingsManager { + + /** + * Sets the system time.This function can be called by a super administrator. + * + * @since 9 + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @param admin Indicates the administrator ability information. + * @param time Target time stamp (ms) + * @return {@code true} if success. + * @permission ohos.permission.EDM_MANAGE_DATETIME + */ + setDateTime(admin: Want, time: number, callback: AsyncCallback): void; + setDateTime(admin: Want, time: number): Promise; +} \ No newline at end of file -- Gitee