1# @ohos.enterprise.telephonyManager(通话管理) 2<!--Kit: MDM Kit--> 3<!--Subsystem: Customization--> 4<!--Owner: @huanleima--> 5<!--Designer: @liuzuming--> 6<!--Tester: @lpw_work--> 7<!--Adviser: @Brilliantry_Rui--> 8 9本模块提供通话管理能力。 10 11> **说明**: 12> 13> 本模块首批接口从API version 20开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 14> 15> 本模块接口仅适用于Stage模型。 16> 17> 本模块接口仅对设备管理应用开放,调用接口前需激活该应用,详情请参考[MDM Kit开发指南](../../mdm/mdm-kit-guide.md)。 18> 19> 全局通用限制类策略由restrictions提供,若要全局禁用通话,请参考[@ohos.enterprise.restrictions(限制类策略)](js-apis-enterprise-restrictions.md)。 20 21## 导入模块 22 23```ts 24import { telephonyManager } from '@kit.MDMKit'; 25``` 26 27## telephonyManager.setSimDisabled 28setSimDisabled(admin: Want, slotId: number): void 29 30禁用指定卡槽的SIM卡。 31 32**需要权限:** ohos.permission.ENTERPRISE_MANAGE_TELEPHONY 33 34**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 35 36**模型约束:** 此接口仅可在Stage模型下使用。 37 38**参数:** 39 40| 参数名 | 类型 | 必填 | 说明 | 41| ------------ | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 42| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 企业设备管理扩展组件。 | 43| slotId | number | 是 | 卡槽ID,目前仅支持单卡槽设备和双卡槽设备,取值范围为0或1,其中0表示卡槽1,1表示卡槽2。 | 44 45**错误码**: 46 47请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。 48 49| 错误码ID | 错误信息 | 50| -------- | ------------------------------------------------------------ | 51| 9200001 | The application is not an administrator application of the device. | 52| 9200002 | The administrator application does not have permission to manage the device. | | 53| 201 | Permission verification failed. The application does not have the permission required to call the API. | 54 55**示例:** 56 57```ts 58import { Want } from '@kit.AbilityKit'; 59import { telephonyManager } from '@kit.MDMKit'; 60 61let wantTemp: Want = { 62 //需根据实际情况进行替换 63 bundleName: 'com.example.myapplication', 64 abilityName: 'EntryAbility' 65}; 66try { 67 let slotId: number = 0; 68 telephonyManager.setSimDisabled(wantTemp, slotId); 69 console.info(`Succeeded in setting slotId: ${slotId} disabled.`); 70} catch (err) { 71 console.error(`Failed to set slotId disabled. Code: ${err.code}, message: ${err.message}`); 72} 73``` 74 75## telephonyManager.setSimEnabled 76 77setSimEnabled(admin: Want, slotId: number): void 78 79解除指定卡槽的SIM卡禁用。 80 81**需要权限:** ohos.permission.ENTERPRISE_MANAGE_TELEPHONY 82 83**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 84 85**模型约束:** 此接口仅可在Stage模型下使用。 86 87**参数:** 88 89| 参数名 | 类型 | 必填 | 说明 | 90| ------------ | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 91| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 企业设备管理扩展组件。 | 92| slotId | number | 是 |卡槽ID,目前仅支持单卡槽设备和双卡槽设备,取值范围为0或1,其中0表示卡槽1,1表示卡槽2。 | 93 94**错误码**: 95 96请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。 97 98| 错误码ID | 错误信息 | 99| -------- | ------------------------------------------------------------ | 100| 9200001 | The application is not an administrator application of the device. | 101| 9200002 | The administrator application does not have permission to manage the device. | 102| 201 | Permission verification failed. The application does not have the permission required to call the API. | 103 104**示例:** 105 106```ts 107import { Want } from '@kit.AbilityKit'; 108import { telephonyManager } from '@kit.MDMKit'; 109 110let wantTemp: Want = { 111 //需根据实际情况进行替换 112 bundleName: 'com.example.myapplication', 113 abilityName: 'EntryAbility' 114}; 115try { 116 let slotId: number = 0; 117 telephonyManager.setSimEnabled(wantTemp, slotId); 118 console.info(`Succeeded in setting slotId: ${slotId} enabled.`); 119} catch (err) { 120 console.error(`Failed to set slotId enabled. Code: ${err.code}, message: ${err.message}`); 121} 122``` 123 124## telephonyManager.isSimDisabled 125 126isSimDisabled(admin: Want, slotId: number): boolean 127 128查询指定卡槽是否禁用。 129 130**需要权限:** ohos.permission.ENTERPRISE_MANAGE_TELEPHONY 131 132**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 133 134**模型约束:** 此接口仅可在Stage模型下使用。 135 136**参数:** 137 138| 参数名 | 类型 | 必填 | 说明 | 139| ------ | ------------------------------------------------------- | ---- | -------------------------------------- | 140| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 企业设备管理扩展组件。 | 141| slotId | number | 是 |卡槽ID,目前仅支持单卡槽设备和双卡槽设备,取值范围为0或1,其中0表示卡槽1,1表示卡槽2。 | 142 143**返回值:** 144 145| 类型 | 说明 | 146| ---------------------------------- | ------------------------- | 147| boolean | 指定卡槽的禁用状态。true表示已被禁用,false表示未被禁用。| 148 149**错误码**: 150 151请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。 152 153| 错误码ID | 错误信息 | 154| -------- | ------------------------------------------------------------ | 155| 9200001 | The application is not an administrator application of the device. | 156| 9200002 | The administrator application does not have permission to manage the device. | 157| 201 | Permission verification failed. The application does not have the permission required to call the API. | 158 159**示例:** 160 161```ts 162import { Want } from '@kit.AbilityKit'; 163import { telephonyManager } from '@kit.MDMKit'; 164 165let wantTemp: Want = { 166 //需根据实际情况进行替换 167 bundleName: 'com.example.myapplication', 168 abilityName: 'EntryAbility' 169}; 170try { 171 let slotId: number = 0; 172 let result: boolean = telephonyManager.isSimDisabled(wantTemp, slotId); 173 console.info(`Succeeded in querying slotId: ${slotId} is disabled or not, result: ${result}`); 174} catch (err) { 175 console.error(`Failed to query sim is disabled or not. Code: ${err.code}, message: ${err.message}`); 176} 177``` 178 179## telephonyManager.addOutgoingCallPolicyNumbers 180 181addOutgoingCallPolicyNumbers(admin: Want, policy: adminManager.Policy, numbers: Array\<string>): void 182 183添加通话呼出的允许或禁用名单,如果不添加名单,任意号码都可以呼出,添加后只有名单内的号码允许或禁止呼出。 184 185以下情况下,通过本接口添加通话呼出的允许或禁用名单,会报策略冲突: 186 1871. 已经通过[setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy)接口禁用了设备通话能力,再通过本接口添加通话呼出的禁用或允许名单,返回203错误码。通过[setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy)接口解除禁用设备通话能力后,可解除冲突。 1882. 已经通过本接口设置了通话呼出的禁用名单,再通过本接口添加通话呼出允许名单,返回9200010错误码。通过[removeOutgoingCallPolicyNumbers](#telephonymanagerremoveoutgoingcallpolicynumbers)接口将之前设置的通话呼出禁用名单移除后,可解除冲突。 1893. 已经通过本接口设置了通话呼出的允许名单,再通过本接口添加通话呼出禁用名单,返回9200010错误码。通过[removeOutgoingCallPolicyNumbers](#telephonymanagerremoveoutgoingcallpolicynumbers)接口将之前设置的通话呼出允许名单移除后,可解除冲突。 190 191 192**需要权限:** ohos.permission.ENTERPRISE_MANAGE_TELEPHONY 193 194**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 195 196**设备行为差异:** 该接口在Phone和Tablet设备中可正常调用,在其他设备中返回801错误码。 197 198**模型约束:** 此接口仅可在Stage模型下使用。 199 200 201**参数:** 202 203| 参数名 | 类型 | 必填 | 说明 | 204| --------- | ------------------------------------------------------- | ---- | -------------------------------------- | 205| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 企业设备管理扩展组件。 | 206| policy | [adminManager.Policy](js-apis-enterprise-adminManager.md#policy20) | 是 | 允许或禁用名单策略。BLOCK_LIST为禁用名单,TRUST_LIST为允许名单。 | 207| numbers | Array\<string> | 是 | 通话号码列表,当前仅支持全号码匹配。数组总长度不能超过1000。例如,若当前允许名单数组中已有100个号码,则最多支持通过该接口再添加900个。 | 208 209**错误码**: 210 211以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。 212 213| 错误码ID | 错误信息 | 214| -------- | ------------------------------------------------------------ | 215| 9200001 | The application is not an administrator application of the device. | 216| 9200002 | The administrator application does not have permission to manage the device. | 217| 9200010 | A conflict policy has been configured. | 218| 9200012 | Parameter verification failed. | 219| 201 | Permission verification failed. The application does not have the permission required to call the API. | 220| 203 | This function is prohibited by enterprise management policies. | 221| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 222 223**示例:** 224 225```ts 226import { Want } from '@kit.AbilityKit'; 227import { telephonyManager } from '@kit.MDMKit'; 228import { adminManager } from '@kit.MDMKit'; 229 230let wantTemp: Want = { 231 //需根据实际情况进行替换 232 bundleName: 'com.example.myapplication', 233 abilityName: 'EntryAbility' 234}; 235try { 236 let policy: adminManager.Policy = adminManager.Policy.BLOCK_LIST; 237 let numbers: Array<string> = [ 238 //需根据实际情况进行替换 239 "13112345678" 240 ]; 241 telephonyManager.addOutgoingCallPolicyNumbers(wantTemp, policy, numbers); 242 console.info('Succeeded in adding outgoing call policy.'); 243} catch (err) { 244 console.error(`Failed to add outgoing call policy. Code: ${err.code}, message: ${err.message}`); 245} 246``` 247 248## telephonyManager.removeOutgoingCallPolicyNumbers 249 250removeOutgoingCallPolicyNumbers(admin: Want, policy: adminManager.Policy, numbers: Array\<string>): void 251 252移除通话呼出的允许或禁用名单,若在该名单尚未设置时进行移除,则会移除失败。 253 254以下情况下,通过本接口移除通话呼出的允许或禁用名单,会报策略冲突: 255 256已经通过[setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy)接口禁用了设备通话能力,再通过本接口移除通话呼出的禁用或允许名单,返回203错误码。通过[setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy)接口解除禁用设备通话能力后,可解除冲突。 257 258 259**需要权限:** ohos.permission.ENTERPRISE_MANAGE_TELEPHONY 260 261**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 262 263**设备行为差异:** 该接口在Phone和Tablet设备中可正常调用,在其他设备中返回801错误码。 264 265**模型约束:** 此接口仅可在Stage模型下使用。 266 267**参数:** 268 269| 参数名 | 类型 | 必填 | 说明 | 270| ------ | ------------------------------------------------------- | ---- | -------------------------------------- | 271| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 企业设备管理扩展组件。 | 272| policy | [adminManager.Policy](js-apis-enterprise-adminManager.md#policy20) | 是 | 允许或禁用名单策略。BLOCK_LIST为禁用名单,TRUST_LIST为允许名单。 | 273| numbers | Array\<string> | 是 | 待移除的通话号码数组。数组总长度不能超过1000。 | 274 275 276**错误码**: 277 278以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。 279 280| 错误码ID | 错误信息 | 281| -------- | ------------------------------------------------------------ | 282| 9200001 | The application is not an administrator application of the device. | 283| 9200002 | The administrator application does not have permission to manage the device. | 284| 9200012 | Parameter verification failed. | 285| 201 | Permission verification failed. The application does not have the permission required to call the API. | 286| 203 | This function is prohibited by enterprise management policies. | 287| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 288 289**示例:** 290 291```ts 292import { Want } from '@kit.AbilityKit'; 293import { telephonyManager } from '@kit.MDMKit'; 294import { adminManager } from '@kit.MDMKit'; 295 296let wantTemp: Want = { 297 //需根据实际情况进行替换 298 bundleName: 'com.example.myapplication', 299 abilityName: 'EntryAbility' 300}; 301try { 302 let policy: adminManager.Policy = adminManager.Policy.BLOCK_LIST; 303 let numbers: Array<string> = [ 304 //需根据实际情况进行替换 305 "13112345678" 306 ]; 307 telephonyManager.removeOutgoingCallPolicyNumbers(wantTemp, policy, numbers); 308 console.info('Succeeded in removing outgoing call policy.'); 309} catch (err) { 310 console.error(`Failed to remove outgoing call policy. Code: ${err.code}, message: ${err.message}`); 311} 312``` 313 314## telephonyManager.getOutgoingCallPolicyNumbers 315 316getOutgoingCallPolicyNumbers(admin: Want, policy: adminManager.Policy): Array\<string> 317 318获取通话呼出的允许或禁用名单。 319 320 321**需要权限:** ohos.permission.ENTERPRISE_MANAGE_TELEPHONY 322 323**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 324 325**设备行为差异:** 该接口在Phone和Tablet设备中可正常调用,在其他设备中返回801错误码。 326 327**模型约束:** 此接口仅可在Stage模型下使用。 328 329**参数:** 330 331| 参数名 | 类型 | 必填 | 说明 | 332| ---------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 333| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 企业设备管理扩展组件。 | 334| policy | [adminManager.Policy](js-apis-enterprise-adminManager.md#policy20) | 是 | 允许或禁用名单策略。 BLOCK_LIST为禁用名单,TRUST_LIST为允许名单。 | 335 336 337**返回值:** 338 339| 类型 | 说明 | 340| ---------------------------------------- | ----------------------- | 341| Array\<string> | 通话呼出禁用或允许名单的号码数组。 | 342 343**错误码**: 344 345以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。 346 347| 错误码ID | 错误信息 | 348| -------- | ------------------------------------------------------------ | 349| 9200001 | The application is not an administrator application of the device. | 350| 9200002 | The administrator application does not have permission to manage the device. | | 351| 201 | Permission verification failed. The application does not have the permission required to call the API. | 352| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 353 354**示例:** 355 356```ts 357import { Want } from '@kit.AbilityKit'; 358import { telephonyManager } from '@kit.MDMKit'; 359import { adminManager } from '@kit.MDMKit'; 360 361let wantTemp: Want = { 362 //需根据实际情况进行替换 363 bundleName: 'com.example.myapplication', 364 abilityName: 'EntryAbility' 365}; 366try { 367 let policy: adminManager.Policy = adminManager.Policy.BLOCK_LIST; 368 let numbers: Array<string> = telephonyManager.getOutgoingCallPolicyNumbers(wantTemp, policy); 369 console.info(`Succeeded in getting outgoing call policy. result: ${JSON.stringify(numbers)}`); 370} catch (err) { 371 console.error(`Failed to get outgoing call policy. Code: ${err.code}, message: ${err.message}`); 372} 373``` 374 375## telephonyManager.addIncomingCallPolicyNumbers 376 377addIncomingCallPolicyNumbers(admin: Want, policy: adminManager.Policy, numbers: Array\<string>): void 378 379添加通话呼入的允许或禁用名单,如果不添加名单,则任意号码都可以呼入,添加后仅名单内的号码允许或禁止呼入。 380 381以下情况下,通过本接口添加通话呼入的允许或禁用名单,会报策略冲突: 382 3831. 已经通过[setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy)接口禁用了设备通话能力,再通过本接口添加通话呼入的禁用或允许名单,返回203错误码。通过[setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy)接口解除禁用设备通话能力后,可解除冲突。 3842. 已经通过本接口设置了通话呼入的禁用名单,再通过本接口添加通话呼入允许名单,返回9200010错误码。通过[removeIncomingCallPolicyNumbers](#telephonymanagerremoveincomingcallpolicynumbers)接口将之前设置的通话呼入禁用名单移除后,可解除冲突。 3853. 已经通过本接口设置了通话呼入的允许名单,再通过本接口添加通话呼入禁用名单,返回9200010错误码。通过[removeIncomingCallPolicyNumbers](#telephonymanagerremoveincomingcallpolicynumbers)接口将之前设置的通话呼入允许名单移除后,可解除冲突。 386 387**需要权限:** ohos.permission.ENTERPRISE_MANAGE_TELEPHONY 388 389**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 390 391**设备行为差异:** 该接口在Phone和Tablet设备中可正常调用,在其他设备中返回801错误码。 392 393**模型约束:** 此接口仅可在Stage模型下使用。 394 395**参数:** 396 397| 参数名 | 类型 | 必填 | 说明 | 398| --------- | ------------------------------------------------------- | ---- | -------------------------------------- | 399| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 企业设备管理扩展组件。 | 400| policy | [adminManager.Policy](js-apis-enterprise-adminManager.md#policy20) | 是 | 允许或禁用名单策略。BLOCK_LIST为禁用名单,TRUST_LIST为允许名单。 | 401| numbers | Array\<string> | 是 | 通话号码列表,当前仅支持全号码匹配。数组总长度不能超过1000。例如,若当前允许名单数组中已有100个号码,则最多支持通过该接口再添加900个。 | 402 403**错误码**: 404 405以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。 406 407| 错误码ID | 错误信息 | 408| -------- | ------------------------------------------------------------ | 409| 9200001 | The application is not an administrator application of the device. | 410| 9200002 | The administrator application does not have permission to manage the device. | 411| 9200010 | A conflict policy has been configured. | 412| 9200012 | Parameter verification failed. | 413| 201 | Permission verification failed. The application does not have the permission required to call the API. | 414| 203 | This function is prohibited by enterprise management policies. | 415| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 416 417**示例:** 418 419```ts 420import { Want } from '@kit.AbilityKit'; 421import { telephonyManager } from '@kit.MDMKit'; 422import { adminManager } from '@kit.MDMKit'; 423 424let wantTemp: Want = { 425 //需根据实际情况进行替换 426 bundleName: 'com.example.myapplication', 427 abilityName: 'EntryAbility' 428}; 429try { 430 let policy: adminManager.Policy = adminManager.Policy.BLOCK_LIST; 431 let numbers: Array<string> = [ 432 //需根据实际情况进行替换 433 "13112345678" 434 ]; 435 telephonyManager.addIncomingCallPolicyNumbers(wantTemp, policy, numbers); 436 console.info('Succeeded in adding incoming call policy.'); 437} catch (err) { 438 console.error(`Failed to add incoming call policy. Code: ${err.code}, message: ${err.message}`); 439} 440``` 441 442## telephonyManager.removeIncomingCallPolicyNumbers 443 444removeIncomingCallPolicyNumbers(admin: Want, policy: adminManager.Policy, numbers: Array\<string>): void 445 446移除通话呼入的允许或禁用名单,若在该名单尚未设置时进行移除,则会移除失败。 447 448以下情况下,通过本接口移除通话呼入的允许或禁用名单,会报策略冲突: 449 4501. 已经通过[setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy)接口禁用了设备通话能力,再通过本接口移除通话呼入的禁用或允许名单,返回203错误码。通过[setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy)接口解除禁用设备通话能力后,可解除冲突。 451 452 453**需要权限:** ohos.permission.ENTERPRISE_MANAGE_TELEPHONY 454 455**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 456 457**设备行为差异:** 该接口在Phone和Tablet设备中可正常调用,在其他设备中返回801错误码。 458 459**模型约束:** 此接口仅可在Stage模型下使用。 460 461**参数:** 462 463| 参数名 | 类型 | 必填 | 说明 | 464| ------ | ------------------------------------------------------- | ---- | -------------------------------------- | 465| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 企业设备管理扩展组件。 | 466| policy | [adminManager.Policy](js-apis-enterprise-adminManager.md#policy20) | 是 | 允许或禁用名单策略。BLOCK_LIST为禁用名单,TRUST_LIST为允许名单。 | 467| numbers | Array\<string> | 是 | 待移除的通话号码数组。数组总长度不能超过1000。 | 468 469 470**错误码**: 471 472以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。 473 474| 错误码ID | 错误信息 | 475| -------- | ------------------------------------------------------------ | 476| 9200001 | The application is not an administrator application of the device. | 477| 9200002 | The administrator application does not have permission to manage the device. | 478| 9200012 | Parameter verification failed. | 479| 201 | Permission verification failed. The application does not have the permission required to call the API. | 480| 203 | This function is prohibited by enterprise management policies. | 481| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 482 483**示例:** 484 485```ts 486import { Want } from '@kit.AbilityKit'; 487import { telephonyManager } from '@kit.MDMKit'; 488import { adminManager } from '@kit.MDMKit'; 489 490let wantTemp: Want = { 491 //需根据实际情况进行替换 492 bundleName: 'com.example.myapplication', 493 abilityName: 'EntryAbility' 494}; 495try { 496 let policy: adminManager.Policy = adminManager.Policy.BLOCK_LIST; 497 let numbers: Array<string> = [ 498 //需根据实际情况进行替换 499 "13112345678" 500 ]; 501 telephonyManager.removeIncomingCallPolicyNumbers(wantTemp, policy, numbers); 502 console.info('Succeeded in removing incoming call policy.'); 503} catch (err) { 504 console.error(`Failed to add remove incoming call policy. Code: ${err.code}, message: ${err.message}`); 505} 506``` 507 508## telephonyManager.getIncomingCallPolicyNumbers 509 510getIncomingCallPolicyNumbers(admin: Want, policy: adminManager.Policy): Array\<string> 511 512获取通话呼入的允许或禁用名单。 513 514 515**需要权限:** ohos.permission.ENTERPRISE_MANAGE_TELEPHONY 516 517**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 518 519**设备行为差异:** 该接口在Phone和Tablet设备中可正常调用,在其他设备中返回801错误码。 520 521**模型约束:** 此接口仅可在Stage模型下使用。 522 523**参数:** 524 525| 参数名 | 类型 | 必填 | 说明 | 526| ---------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 527| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 企业设备管理扩展组件。 | 528| policy | [adminManager.Policy](js-apis-enterprise-adminManager.md#policy20) | 是 | 允许或禁用名单策略。BLOCK_LIST为禁用名单,TRUST_LIST为允许名单。 | 529 530 531**返回值:** 532 533| 类型 | 说明 | 534| ---------------------------------------- | ----------------------- | 535| Array\<string> | 通话呼入禁用或允许名单的号码数组。 | 536 537**错误码**: 538 539以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。 540 541| 错误码ID | 错误信息 | 542| -------- | ------------------------------------------------------------ | 543| 9200001 | The application is not an administrator application of the device. | 544| 9200002 | The administrator application does not have permission to manage the device. | | 545| 201 | Permission verification failed. The application does not have the permission required to call the API. | 546| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 547 548**示例:** 549 550```ts 551import { Want } from '@kit.AbilityKit'; 552import { telephonyManager } from '@kit.MDMKit'; 553import { adminManager } from '@kit.MDMKit'; 554 555let wantTemp: Want = { 556 //需根据实际情况进行替换 557 bundleName: 'com.example.myapplication', 558 abilityName: 'EntryAbility' 559}; 560try { 561 let policy: adminManager.Policy = adminManager.Policy.BLOCK_LIST; 562 let numbers: Array<string> = telephonyManager.getIncomingCallPolicyNumbers(wantTemp, policy); 563 console.info(`Succeeded in getting incoming call policy. result: ${JSON.stringify(numbers)}`); 564} catch (err) { 565 console.error(`Failed to get incoming call policy. Code: ${err.code}, message: ${err.message}`); 566} 567```