# @ohos.enterprise.browser(æµè§ˆå™¨ç®¡ç†ï¼‰ æœ¬æ¨¡å—æä¾›æµè§ˆå™¨ç®¡ç†èƒ½åŠ›ï¼ŒåŒ…æ‹¬è®¾ç½®/å–æ¶ˆæµè§ˆå™¨ç–ç•¥ã€èŽ·å–æµè§ˆå™¨ç–ç•¥ç‰ã€‚ > **说明:** > > 本模å—首批接å£ä»ŽAPI version 12开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„æ–°å¢žæŽ¥å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > > æœ¬æ¨¡å—æŽ¥å£ä»…å¯åœ¨Stage模型下使用。 > > æœ¬æ¨¡å—æŽ¥å£ä»…对[设备管ç†åº”用](../../mdm/mdm-kit-guide.md#功能介ç»)开放,需将设备管ç†åº”用激活åŽè°ƒç”¨ï¼Œå®žçŽ°ç›¸åº”åŠŸèƒ½ã€‚ ## å¯¼å…¥æ¨¡å— ```ts import { browser } from '@kit.MDMKit'; ``` ## browser.setPolicySync setPolicySync(admin: Want, appId: string, policyName: string, policyValue: string): void 指定设备管ç†åº”用为指定的æµè§ˆå™¨è®¾ç½®æµè§ˆå™¨åç–略。 **éœ€è¦æƒé™ï¼š** ohos.permission.ENTERPRISE_SET_BROWSER_POLICY **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | ----------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | | admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 设备管ç†åº”用。 | | appId | string | 是 | 应用ID,用于指定æµè§ˆå™¨ã€‚ | | policyName | string | 是 | æµè§ˆå™¨åç–ç•¥å。当æ¤å€¼ä¸ºç©ºå—符串时,表示设置应用ID对应的æµè§ˆå™¨ç–略。 | | policyValue | string | 是 | æµè§ˆå™¨åç–略值。当æ¤å€¼ä¸ºç©ºå—ç¬¦ä¸²æ—¶ï¼Œè¡¨ç¤ºå–æ¶ˆæµè§ˆå™¨ç–ç•¥å对应æµè§ˆå™¨åç–略。 | **错误ç **: 以下错误ç 的详细介ç»è¯·å‚è§[ä¼ä¸šè®¾å¤‡ç®¡ç†é”™è¯¯ç ](errorcode-enterpriseDeviceManager.md)å’Œ[通用错误ç ](../errorcode-universal.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | ------------------------------------------------------------ | | 9200001 | The application is not an administrator application of the device. | | 9200002 | The administrator application does not have permission to manage the device. | | 201 | Permission verification failed. The application does not have the permission required to call the API. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | **示例:** ```ts import { Want } from '@kit.AbilityKit'; let wantTemp: Want = { bundleName: 'com.example.myapplication', abilityName: 'EntryAbility', }; let appId: string = 'com.example.myapplication'; let policyName: string = 'InsecurePrivateNetworkRequestsAllowed'; let policyValue: string = '{"level":"mandatory","scope":"machine","source":"platform","value":true}'; try { browser.setPolicySync(wantTemp, appId, policyName, policyValue); console.info('Succeeded in setting browser policies.'); } catch (err) { console.error(`Failed to set browser policies. Code is ${err.code}, message is ${err.message}`); } ``` ## browser.getPoliciesSync getPoliciesSync(admin: Want, appId: string): string 指定管ç†å‘˜åº”ç”¨èŽ·å–æŒ‡å®šæµè§ˆå™¨çš„ç–略。 **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | ------ | ------------------------------------------------------- | ---- | ------------------------ | | admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 设备管ç†åº”用。 | | appId | string | 是 | 应用ID,用于指定æµè§ˆå™¨ã€‚ | **返回值:** | 类型 | 说明 | | ------ | ------------ | | string | æµè§ˆå™¨ç–略。 | **错误ç **: 以下错误ç 的详细介ç»è¯·å‚è§[ä¼ä¸šè®¾å¤‡ç®¡ç†é”™è¯¯ç ](errorcode-enterpriseDeviceManager.md)å’Œ[通用错误ç ](../errorcode-universal.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | ------------------------------------------------------------ | | 9200001 | The application is not an administrator application of the device. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | **示例:** ```ts import { Want } from '@kit.AbilityKit'; let wantTemp: Want = { bundleName: 'com.example.myapplication', abilityName: 'EntryAbility', }; let appId: string = 'com.example.myapplication'; try { let result: string = browser.getPoliciesSync(wantTemp, appId); console.info(`Succeeded in getting browser policies, result : ${JSON.stringify(result)}`); } catch(err) { console.error(`Failed to get browser policies. Code is ${err.code}, message is ${err.message}`); } ```