1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit MDMKit 19 */ 20 21import type { AsyncCallback } from './@ohos.base'; 22import type Want from './@ohos.app.ability.Want'; 23 24/** 25 * This module provides the capability to manage the browser policies of the enterprise devices. 26 * 27 * @namespace browser 28 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 29 * @since 10 30 */ 31declare namespace browser { 32 /** 33 * Allow the administrator to set the browser policies. 34 * This function can be called by a super administrator. 35 * 36 * @permission ohos.permission.ENTERPRISE_SET_BROWSER_POLICY 37 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 38 * The admin must have the corresponding permission. 39 * @param { string } appId - id of the bundle that need to set policies. It cannot be empty. 40 * @param { string } policies - browser policies that need to set. It must be a correct JSON character string that 41 * can be converted into browser policies. 42 * @param { AsyncCallback<void> } callback - the callback of setPolicies. 43 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 44 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 45 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 46 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 47 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 48 * 2. Incorrect parameter types; 3. Parameter verification failed. 49 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 50 * @systemapi 51 * @StageModelOnly 52 * @since 10 53 */ 54 function setPolicies(admin: Want, appId: string, policies: string, callback: AsyncCallback<void>): void; 55 56 /** 57 * Allow the administrator to set the browser policies. 58 * This function can be called by a super administrator. 59 * 60 * @permission ohos.permission.ENTERPRISE_SET_BROWSER_POLICY 61 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 62 * The admin must have the corresponding permission. 63 * @param { string } appId - id of the bundle that need to set policies. It cannot be empty. 64 * @param { string } policies - browser policies that need to set. It must be a correct JSON character string that 65 * can be converted into browser policies. 66 * @returns { Promise<void> } the promise returned by the setPolicies. 67 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 68 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 69 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 70 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 71 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 72 * 2. Incorrect parameter types; 3. Parameter verification failed. 73 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 74 * @systemapi 75 * @StageModelOnly 76 * @since 10 77 */ 78 function setPolicies(admin: Want, appId: string, policies: string): Promise<void>; 79 80 /** 81 * Allow the administrator to get the browser policies. 82 * This function can be called by a super administrator. 83 * 84 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 85 * The admin must have the corresponding permission. 86 * @param { string } appId - id of the bundle that need to set policies. It cannot be empty. 87 * @param { AsyncCallback<string> } callback - the callback carries the browser policies returned by the getPolicies. 88 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 89 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 90 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 91 * 2. Incorrect parameter types; 3. Parameter verification failed. 92 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 93 * @systemapi 94 * @StageModelOnly 95 * @since 10 96 */ 97 function getPolicies(admin: Want, appId: string, callback: AsyncCallback<string>): void; 98 99 /** 100 * Allow the administrator to get the browser policies. 101 * This function can be called by a super administrator. 102 * 103 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 104 * The admin must have the corresponding permission. 105 * @param { string } appId - id of the bundle that need to set policies. It cannot be empty. 106 * @returns { Promise<string> } the promise carries the browser policies returned by the getPolicies. 107 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 108 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 109 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 110 * 2. Incorrect parameter types; 3. Parameter verification failed. 111 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 112 * @systemapi 113 * @StageModelOnly 114 * @since 10 115 */ 116 function getPolicies(admin: Want, appId: string): Promise<string>; 117 118 /** 119 * Sets the browser policy. 120 * This function can be called by a super administrator. 121 * 122 * @permission ohos.permission.ENTERPRISE_SET_BROWSER_POLICY 123 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 124 * The admin must have the corresponding permission. 125 * @param { string } appId - appId indicates the id of the bundle that need to set policy. It cannot be empty. 126 * @param { string } policyName - policyName indicates the browser policy name that need to set. 127 * @param { string } policyValue - policyValue indicates the browser policy value that need to set. It must be a 128 * correct JSON character string that can be converted into browser policies. 129 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 130 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 131 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 132 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 133 * 2. Incorrect parameter types; 3. Parameter verification failed. 134 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 135 * @stagemodelonly 136 * @since 12 137 */ 138 function setPolicySync(admin: Want, appId: string, policyName: string, policyValue: string): void; 139 140 /** 141 * Gets the browser policies. 142 * This function can be called by a super administrator. 143 * 144 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 145 * The admin must have the corresponding permission. 146 * @param { string } appId - id of the bundle that need to get policies. It cannot be empty. 147 * @returns { string } the browser policies returned by the getPolicies. 148 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 149 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 150 * 2. Incorrect parameter types; 3. Parameter verification failed. 151 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 152 * @stagemodelonly 153 * @since 12 154 */ 155 function getPoliciesSync(admin: Want, appId: string): string; 156} 157 158export default browser; 159