1e41f4b71Sopenharmony_ci# @ohos.telephony.sim (SIM卡管理)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciSIM卡管理模块提供了SIM卡管理的基础能力,包括获取指定卡槽SIM卡的ISO国家码、归属PLMN号、服务提供商名称、SIM卡状态、卡类型、是否插卡、是否激活等。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>**说明:** 
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci>本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## 导入模块
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```ts
13e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## sim.isSimActive<sup>7+</sup>
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ciisSimActive\(slotId: number, callback: AsyncCallback\<boolean\>\): void
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci获取指定卡槽SIM卡是否激活。使用callback异步回调。
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**参数:**
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明                                   |
27e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | -------------------------------------- |
28e41f4b71Sopenharmony_ci| slotId   | number                      | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
29e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回指定卡槽是否激活,如果激活返回true。                             |
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci**示例:**
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci```ts
34e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
35e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_cisim.isSimActive(0, (err: BusinessError, data: boolean) => {
38e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
39e41f4b71Sopenharmony_ci});
40e41f4b71Sopenharmony_ci```
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci## sim.isSimActive<sup>7+</sup>
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ciisSimActive\(slotId: number\): Promise\<boolean\>
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci获取指定卡槽SIM卡是否激活。使用Promise异步回调。
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci**参数:**
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
54e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
55e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci**返回值:**
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci| 类型                  | 说明                               |
60e41f4b71Sopenharmony_ci| --------------------- | ---------------------------------- |
61e41f4b71Sopenharmony_ci| Promise&lt;boolean&gt; | 以Promise形式返回指定卡槽是否激活,如果激活返回true。 |
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**示例:**
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci```ts
66e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
67e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_cisim.isSimActive(0).then((data: boolean) => {
70e41f4b71Sopenharmony_ci    console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`);
71e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
72e41f4b71Sopenharmony_ci    console.error(`isSimActive failed, promise: err->${JSON.stringify(err)}`);
73e41f4b71Sopenharmony_ci});
74e41f4b71Sopenharmony_ci```
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci## sim.isSimActiveSync<sup>10+</sup>
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ciisSimActiveSync\(slotId: number\): boolean
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci获取指定卡槽SIM卡是否激活。
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci**参数:**
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
87e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
88e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**返回值:**
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci| 类型                  | 说明                               |
93e41f4b71Sopenharmony_ci| --------------------- | ---------------------------------- |
94e41f4b71Sopenharmony_ci| boolean | 返回指定卡槽是否激活,如果激活返回true。 |
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci**示例:**
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci```ts
99e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_cilet isSimActive: boolean = sim.isSimActiveSync(0);
102e41f4b71Sopenharmony_ciconsole.log(`the sim is active:` + isSimActive);
103e41f4b71Sopenharmony_ci```
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci## sim.getDefaultVoiceSlotId<sup>7+</sup>
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_cigetDefaultVoiceSlotId\(callback: AsyncCallback\<number\>\): void
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci获取默认语音业务的卡槽ID。使用callback异步回调。
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci**参数:**
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明       |
117e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------- |
118e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。<br />- 0:卡槽1<br />- 1:卡槽2<br />- -1:未设置或服务不可用 |
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci**示例:**
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci```ts
123e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
124e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_cisim.getDefaultVoiceSlotId((err: BusinessError, data: number) => {
127e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
128e41f4b71Sopenharmony_ci});
129e41f4b71Sopenharmony_ci```
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci## sim.getDefaultVoiceSlotId<sup>7+</sup>
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_cigetDefaultVoiceSlotId\(\): Promise\<number\>
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci获取默认语音业务的卡槽ID。使用Promise异步回调。
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci**返回值:**
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci| 类型              | 说明                                    |
142e41f4b71Sopenharmony_ci| ----------------- | --------------------------------------- |
143e41f4b71Sopenharmony_ci| Promise\<number\> | 以Promise形式返回默认语音业务的卡槽ID。<br />- 0:卡槽1<br />- 1:卡槽2<br />- -1:未设置或服务不可用 |
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**示例:**
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci```ts
148e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
149e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_cisim.getDefaultVoiceSlotId().then((data: number) => {
152e41f4b71Sopenharmony_ci    console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`);
153e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
154e41f4b71Sopenharmony_ci    console.error(`getDefaultVoiceSlotId failed, promise: err->${JSON.stringify(err)}`);
155e41f4b71Sopenharmony_ci});
156e41f4b71Sopenharmony_ci```
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci## sim.hasOperatorPrivileges<sup>7+</sup>
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_cihasOperatorPrivileges\(slotId: number, callback: AsyncCallback\<boolean\>\): void
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci检查应用(调用者)是否已被授予运营商权限。使用callback异步回调。
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci**参数:**
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci| 参数名   | 类型                     | 必填 | 说明                                     |
169e41f4b71Sopenharmony_ci| -------- | ------------------------ | ---- | ---------------------------------------- |
170e41f4b71Sopenharmony_ci| slotId   | number                   | 是   | 卡槽ID。<br />- 0:卡槽1<br />- 1:卡槽2 |
171e41f4b71Sopenharmony_ci| callback | AsyncCallback\<boolean\> | 是   | 回调函数。 返回检查应用(调用者)是否已被授予运营商权限。                              |
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci**错误码:**
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
178e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
179e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
180e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
181e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
182e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
183e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci**示例:**
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci```ts
188e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
189e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_cisim.hasOperatorPrivileges(0, (err: BusinessError, data: boolean) => {
192e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
193e41f4b71Sopenharmony_ci});
194e41f4b71Sopenharmony_ci```
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci## sim.hasOperatorPrivileges<sup>7+</sup>
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_cihasOperatorPrivileges\(slotId: number\): Promise\<boolean\>
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci检查应用(调用者)是否已被授予运营商权限。使用Promise异步回调。
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci**参数:**
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                     |
207e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------------------- |
208e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br />- 0:卡槽1<br />- 1:卡槽2 |
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci**返回值:**
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci| 类型               | 说明                                                        |
213e41f4b71Sopenharmony_ci| :----------------- | :---------------------------------------------------------- |
214e41f4b71Sopenharmony_ci| Promise\<boolean\> | 以Promise形式返回检查应用(调用者)是否已被授予运营商权限。 |
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci**错误码:**
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
221e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
222e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
223e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
224e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
225e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
226e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci**示例:**
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci```ts
231e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
232e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_cisim.hasOperatorPrivileges(0).then((data: boolean) => {
235e41f4b71Sopenharmony_ci    console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`);
236e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
237e41f4b71Sopenharmony_ci    console.error(`hasOperatorPrivileges failed, promise: err->${JSON.stringify(err)}`);
238e41f4b71Sopenharmony_ci});
239e41f4b71Sopenharmony_ci```
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci## sim.getISOCountryCodeForSim
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_cigetISOCountryCodeForSim\(slotId: number, callback: AsyncCallback\<string\>\): void
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的ISO国家码。使用callback异步回调。
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci**参数:**
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci| 参数名   | 类型                    | 必填 | 说明                                     |
252e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | ---------------------------------------- |
253e41f4b71Sopenharmony_ci| slotId   | number                  | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2   |
254e41f4b71Sopenharmony_ci| callback | AsyncCallback\<string\> | 是   | 回调函数。返回国家码,例如:CN(中国)。 |
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci**错误码:**
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
261e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
262e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
263e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
264e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
265e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
266e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
267e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci**示例:**
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci```ts
272e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
273e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_cisim.getISOCountryCodeForSim(0, (err: BusinessError, data: string) => {
276e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
277e41f4b71Sopenharmony_ci});
278e41f4b71Sopenharmony_ci```
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci## sim.getISOCountryCodeForSim
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_cigetISOCountryCodeForSim\(slotId: number\): Promise\<string\>
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的ISO国家码。使用Promise异步回调。
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci**参数:**
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
292e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
293e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci**返回值:**
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci| 类型              | 说明                                                         |
298e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ |
299e41f4b71Sopenharmony_ci| Promise\<string\> | 以Promise形式返回获取指定卡槽SIM卡的ISO国家码,例如:CN(中国)。 |
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci**错误码:**
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
306e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
307e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
308e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
309e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
310e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
311e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
312e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci**示例:**
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci```ts
317e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
318e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_cisim.getISOCountryCodeForSim(0).then((data: string) => {
321e41f4b71Sopenharmony_ci    console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`);
322e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
323e41f4b71Sopenharmony_ci    console.error(`getISOCountryCodeForSim failed, promise: err->${JSON.stringify(err)}`);
324e41f4b71Sopenharmony_ci});
325e41f4b71Sopenharmony_ci```
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci## sim.getISOCountryCodeForSimSync<sup>10+</sup>
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_cigetISOCountryCodeForSimSync\(slotId: number\): string
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的ISO国家码。
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci**参数:**
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
338e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
339e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci**返回值:**
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci| 类型              | 说明                                                         |
344e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ |
345e41f4b71Sopenharmony_ci| string | 返回获取指定卡槽SIM卡的ISO国家码,例如:CN(中国)。 |
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci
348e41f4b71Sopenharmony_ci**示例:**
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ci```ts
351e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_cilet countryCode: string = sim.getISOCountryCodeForSimSync(0);
354e41f4b71Sopenharmony_ciconsole.log(`the country ISO is:` + countryCode);
355e41f4b71Sopenharmony_ci```
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci
358e41f4b71Sopenharmony_ci## sim.getSimOperatorNumeric
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_cigetSimOperatorNumeric\(slotId: number, callback: AsyncCallback\<string\>\): void
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的归属PLMN(Public Land Mobile Network)号。使用callback异步回调。
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci**参数:**
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci| 参数名   | 类型                    | 必填 | 说明                                   |
369e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | -------------------------------------- |
370e41f4b71Sopenharmony_ci| slotId   | number                  | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
371e41f4b71Sopenharmony_ci| callback | AsyncCallback\<string\> | 是   | 回调函数。返回指定卡槽SIM卡的归属PLMN号。                          |
372e41f4b71Sopenharmony_ci
373e41f4b71Sopenharmony_ci**错误码:**
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
378e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
379e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
380e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
381e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
382e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
383e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
384e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ci**示例:**
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci```ts
389e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
390e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_cisim.getSimOperatorNumeric(0, (err: BusinessError, data: string) => {
393e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
394e41f4b71Sopenharmony_ci});
395e41f4b71Sopenharmony_ci```
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ci## sim.getSimOperatorNumeric
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_cigetSimOperatorNumeric\(slotId: number\): Promise\<string\>
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的归属PLMN(Public Land Mobile Network)号。使用Promise异步回调。
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci**参数:**
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
409e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
410e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci**返回值:**
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci| 类型              | 说明                                             |
415e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------ |
416e41f4b71Sopenharmony_ci| Promise\<string\> | 以Promise形式返回获取指定卡槽SIM卡的归属PLMN号。 |
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci**错误码:**
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
423e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
424e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
425e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
426e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
427e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
428e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
429e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_ci**示例:**
432e41f4b71Sopenharmony_ci
433e41f4b71Sopenharmony_ci```ts
434e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
435e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_cisim.getSimOperatorNumeric(0).then((data: string) => {
438e41f4b71Sopenharmony_ci    console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`);
439e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
440e41f4b71Sopenharmony_ci    console.error(`getSimOperatorNumeric failed, promise: err->${JSON.stringify(err)}`);
441e41f4b71Sopenharmony_ci});
442e41f4b71Sopenharmony_ci```
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ci## sim.getSimOperatorNumericSync<sup>10+</sup>
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_cigetSimOperatorNumericSync\(slotId: number\): string
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的归属PLMN(Public Land Mobile Network)号。
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_ci**参数:**
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
455e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
456e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci**返回值:**
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci| 类型              | 说明                                             |
461e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------ |
462e41f4b71Sopenharmony_ci| string | 返回获取指定卡槽SIM卡的归属PLMN号。 |
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ci
465e41f4b71Sopenharmony_ci**示例:**
466e41f4b71Sopenharmony_ci
467e41f4b71Sopenharmony_ci```ts
468e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_cilet numeric: string = sim.getSimOperatorNumericSync(0);
471e41f4b71Sopenharmony_ciconsole.log(`the sim operator numeric is:` + numeric);
472e41f4b71Sopenharmony_ci```
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci
475e41f4b71Sopenharmony_ci## sim.getSimSpn
476e41f4b71Sopenharmony_ci
477e41f4b71Sopenharmony_cigetSimSpn\(slotId: number, callback: AsyncCallback\<string\>\): void
478e41f4b71Sopenharmony_ci
479e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的服务提供商名称(Service Provider Name,SPN)。使用callback异步回调。
480e41f4b71Sopenharmony_ci
481e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
482e41f4b71Sopenharmony_ci
483e41f4b71Sopenharmony_ci**参数:**
484e41f4b71Sopenharmony_ci
485e41f4b71Sopenharmony_ci| 参数名   | 类型                    | 必填 | 说明                                   |
486e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | -------------------------------------- |
487e41f4b71Sopenharmony_ci| slotId   | number                  | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
488e41f4b71Sopenharmony_ci| callback | AsyncCallback\<string\> | 是   | 回调函数。返回指定卡槽SIM卡的SPN。                             |
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci**错误码:**
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
495e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
496e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
497e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
498e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
499e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
500e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
501e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci**示例:**
504e41f4b71Sopenharmony_ci
505e41f4b71Sopenharmony_ci```ts
506e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
507e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_cisim.getSimSpn(0, (err: BusinessError, data: string) => {
510e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
511e41f4b71Sopenharmony_ci});
512e41f4b71Sopenharmony_ci```
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci## sim.getSimSpn
516e41f4b71Sopenharmony_ci
517e41f4b71Sopenharmony_cigetSimSpn\(slotId: number\): Promise\<string\>
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的服务提供商名称(Service Provider Name,SPN)。使用Promise异步回调。
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ci**参数:**
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
526e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
527e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci**返回值:**
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci| 类型              | 说明                                      |
532e41f4b71Sopenharmony_ci| ----------------- | ----------------------------------------- |
533e41f4b71Sopenharmony_ci| Promise\<string\> | 以Promise形式返回获取指定卡槽SIM卡的SPN。 |
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ci**错误码:**
536e41f4b71Sopenharmony_ci
537e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
540e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
541e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
542e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
543e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
544e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
545e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
546e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
547e41f4b71Sopenharmony_ci
548e41f4b71Sopenharmony_ci**示例:**
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ci```ts
551e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
552e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_cisim.getSimSpn(0).then((data: string) => {
555e41f4b71Sopenharmony_ci    console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`);
556e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
557e41f4b71Sopenharmony_ci    console.error(`getSimSpn failed, promise: err->${JSON.stringify(err)}`);
558e41f4b71Sopenharmony_ci});
559e41f4b71Sopenharmony_ci```
560e41f4b71Sopenharmony_ci
561e41f4b71Sopenharmony_ci## sim.getSimSpnSync<sup>10+</sup>
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_cigetSimSpnSync\(slotId: number\): string
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的服务提供商名称(Service Provider Name,SPN)。
566e41f4b71Sopenharmony_ci
567e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
568e41f4b71Sopenharmony_ci
569e41f4b71Sopenharmony_ci**参数:**
570e41f4b71Sopenharmony_ci
571e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
572e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
573e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ci**返回值:**
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci| 类型              | 说明                                      |
578e41f4b71Sopenharmony_ci| ----------------- | ----------------------------------------- |
579e41f4b71Sopenharmony_ci| string | 返回获取指定卡槽SIM卡的SPN。 |
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_ci
582e41f4b71Sopenharmony_ci**示例:**
583e41f4b71Sopenharmony_ci
584e41f4b71Sopenharmony_ci```ts
585e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_cilet spn: string = sim.getSimSpnSync(0);
588e41f4b71Sopenharmony_ciconsole.log(`the sim card spn is:` + spn);
589e41f4b71Sopenharmony_ci```
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci
592e41f4b71Sopenharmony_ci## sim.getSimState
593e41f4b71Sopenharmony_ci
594e41f4b71Sopenharmony_cigetSimState\(slotId: number, callback: AsyncCallback\<SimState\>\): void
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci获取指定卡槽的SIM卡状态。使用callback异步回调。
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_ci**参数:**
601e41f4b71Sopenharmony_ci
602e41f4b71Sopenharmony_ci| 参数名   | 类型                                   | 必填 | 说明                                   |
603e41f4b71Sopenharmony_ci| -------- | -------------------------------------- | ---- | -------------------------------------- |
604e41f4b71Sopenharmony_ci| slotId   | number                                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
605e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[SimState](#simstate)\> | 是   | 回调函数。参考[SimState](#simstate)。  |
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci**错误码:**
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
610e41f4b71Sopenharmony_ci
611e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
612e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
613e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
614e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
615e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
616e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
617e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
618e41f4b71Sopenharmony_ci
619e41f4b71Sopenharmony_ci**示例:**
620e41f4b71Sopenharmony_ci
621e41f4b71Sopenharmony_ci```ts
622e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
623e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
624e41f4b71Sopenharmony_ci
625e41f4b71Sopenharmony_cisim.getSimState(0, (err: BusinessError, data: sim.SimState) => {
626e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
627e41f4b71Sopenharmony_ci});
628e41f4b71Sopenharmony_ci```
629e41f4b71Sopenharmony_ci
630e41f4b71Sopenharmony_ci
631e41f4b71Sopenharmony_ci## sim.getSimState
632e41f4b71Sopenharmony_ci
633e41f4b71Sopenharmony_cigetSimState\(slotId: number\): Promise\<SimState\>
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_ci获取指定卡槽的SIM卡状态。使用Promise异步回调。
636e41f4b71Sopenharmony_ci
637e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
638e41f4b71Sopenharmony_ci
639e41f4b71Sopenharmony_ci**参数:**
640e41f4b71Sopenharmony_ci
641e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
642e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
643e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_ci**返回值:**
646e41f4b71Sopenharmony_ci
647e41f4b71Sopenharmony_ci| 类型                             | 说明                                       |
648e41f4b71Sopenharmony_ci| -------------------------------- | ------------------------------------------ |
649e41f4b71Sopenharmony_ci| Promise\<[SimState](#simstate)\> | 以Promise形式返回获取指定卡槽的SIM卡状态。 |
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_ci**错误码:**
652e41f4b71Sopenharmony_ci
653e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
654e41f4b71Sopenharmony_ci
655e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
656e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
657e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
658e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
659e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
660e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
661e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ci**示例:**
664e41f4b71Sopenharmony_ci
665e41f4b71Sopenharmony_ci```ts
666e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
667e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
668e41f4b71Sopenharmony_ci
669e41f4b71Sopenharmony_cisim.getSimState(0).then((data: sim.SimState) => {
670e41f4b71Sopenharmony_ci    console.log(`getSimState success, promise: data->${JSON.stringify(data)}`);
671e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
672e41f4b71Sopenharmony_ci    console.error(`getSimState failed, promise: err->${JSON.stringify(err)}`);
673e41f4b71Sopenharmony_ci});
674e41f4b71Sopenharmony_ci```
675e41f4b71Sopenharmony_ci
676e41f4b71Sopenharmony_ci## sim.getSimStateSync<sup>10+</sup>
677e41f4b71Sopenharmony_ci
678e41f4b71Sopenharmony_cigetSimStateSync\(slotId: number\): SimState
679e41f4b71Sopenharmony_ci
680e41f4b71Sopenharmony_ci获取指定卡槽的SIM卡状态。
681e41f4b71Sopenharmony_ci
682e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
683e41f4b71Sopenharmony_ci
684e41f4b71Sopenharmony_ci**参数:**
685e41f4b71Sopenharmony_ci
686e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
687e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
688e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
689e41f4b71Sopenharmony_ci
690e41f4b71Sopenharmony_ci**返回值:**
691e41f4b71Sopenharmony_ci
692e41f4b71Sopenharmony_ci| 类型                         | 说明                                       |
693e41f4b71Sopenharmony_ci| ---------------------------- | ------------------------------------------ |
694e41f4b71Sopenharmony_ci| [SimState](#simstate) | 返回获取指定卡槽的SIM卡状态。 |
695e41f4b71Sopenharmony_ci
696e41f4b71Sopenharmony_ci
697e41f4b71Sopenharmony_ci**示例:**
698e41f4b71Sopenharmony_ci
699e41f4b71Sopenharmony_ci```ts
700e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
701e41f4b71Sopenharmony_ci
702e41f4b71Sopenharmony_cilet simState: sim.SimState = sim.getSimStateSync(0);
703e41f4b71Sopenharmony_ciconsole.log(`The sim state is:` + simState);
704e41f4b71Sopenharmony_ci```
705e41f4b71Sopenharmony_ci
706e41f4b71Sopenharmony_ci## sim.getCardType<sup>7+</sup>
707e41f4b71Sopenharmony_ci
708e41f4b71Sopenharmony_cigetCardType\(slotId: number, callback: AsyncCallback\<CardType\>\): void
709e41f4b71Sopenharmony_ci
710e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的卡类型。使用callback异步回调。
711e41f4b71Sopenharmony_ci
712e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
713e41f4b71Sopenharmony_ci
714e41f4b71Sopenharmony_ci**参数:**
715e41f4b71Sopenharmony_ci
716e41f4b71Sopenharmony_ci| 参数名   | 类型                    | 必填 | 说明                                   |
717e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | -------------------------------------- |
718e41f4b71Sopenharmony_ci| slotId   | number                  | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
719e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[CardType](#cardtype7)\> | 是   | 回调函数。                             |
720e41f4b71Sopenharmony_ci
721e41f4b71Sopenharmony_ci**错误码:**
722e41f4b71Sopenharmony_ci
723e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
726e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
727e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
728e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
729e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
730e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
731e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
732e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
733e41f4b71Sopenharmony_ci
734e41f4b71Sopenharmony_ci**示例:**
735e41f4b71Sopenharmony_ci
736e41f4b71Sopenharmony_ci```ts
737e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
738e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
739e41f4b71Sopenharmony_ci
740e41f4b71Sopenharmony_cisim.getCardType(0, (err: BusinessError, data: sim.CardType) => {
741e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
742e41f4b71Sopenharmony_ci});
743e41f4b71Sopenharmony_ci```
744e41f4b71Sopenharmony_ci
745e41f4b71Sopenharmony_ci
746e41f4b71Sopenharmony_ci## sim.getCardType<sup>7+</sup>
747e41f4b71Sopenharmony_ci
748e41f4b71Sopenharmony_cigetCardType\(slotId: number\): Promise\<CardType\>
749e41f4b71Sopenharmony_ci
750e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的卡类型。使用Promise异步回调。
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_ci**参数:**
755e41f4b71Sopenharmony_ci
756e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
757e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
758e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
759e41f4b71Sopenharmony_ci
760e41f4b71Sopenharmony_ci**返回值:**
761e41f4b71Sopenharmony_ci
762e41f4b71Sopenharmony_ci| 类型              | 说明                                                         |
763e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ |
764e41f4b71Sopenharmony_ci| Promise\<[CardType](#cardtype7)\> | 以Promise形式返回指定卡槽SIM卡的卡类型。 |
765e41f4b71Sopenharmony_ci
766e41f4b71Sopenharmony_ci**错误码:**
767e41f4b71Sopenharmony_ci
768e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
769e41f4b71Sopenharmony_ci
770e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
771e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
772e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
773e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
774e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
775e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
776e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
777e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
778e41f4b71Sopenharmony_ci
779e41f4b71Sopenharmony_ci**示例:**
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci```ts
782e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
783e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
784e41f4b71Sopenharmony_ci
785e41f4b71Sopenharmony_cisim.getCardType(0).then((data: sim.CardType) => {
786e41f4b71Sopenharmony_ci    console.log(`getCardType success, promise: data->${JSON.stringify(data)}`);
787e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
788e41f4b71Sopenharmony_ci    console.error(`getCardType failed, promise: err->${JSON.stringify(err)}`);
789e41f4b71Sopenharmony_ci});
790e41f4b71Sopenharmony_ci```
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_ci## sim.getCardTypeSync<sup>10+</sup>
793e41f4b71Sopenharmony_ci
794e41f4b71Sopenharmony_cigetCardTypeSync\(slotId: number\): CardType
795e41f4b71Sopenharmony_ci
796e41f4b71Sopenharmony_ci获取指定卡槽SIM卡的卡类型。
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_ci**参数:**
801e41f4b71Sopenharmony_ci
802e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
803e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
804e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
805e41f4b71Sopenharmony_ci
806e41f4b71Sopenharmony_ci**返回值:**
807e41f4b71Sopenharmony_ci
808e41f4b71Sopenharmony_ci| 类型              | 说明                                                         |
809e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ |
810e41f4b71Sopenharmony_ci| [CardType](#cardtype7) | 返回指定卡槽SIM卡的卡类型。 |
811e41f4b71Sopenharmony_ci
812e41f4b71Sopenharmony_ci
813e41f4b71Sopenharmony_ci**示例:**
814e41f4b71Sopenharmony_ci
815e41f4b71Sopenharmony_ci```ts
816e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
817e41f4b71Sopenharmony_ci
818e41f4b71Sopenharmony_cilet cardType: sim.CardType = sim.getCardTypeSync(0);
819e41f4b71Sopenharmony_ciconsole.log(`the card type is:` + cardType);
820e41f4b71Sopenharmony_ci```
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci
823e41f4b71Sopenharmony_ci## sim.hasSimCard<sup>7+</sup>
824e41f4b71Sopenharmony_ci
825e41f4b71Sopenharmony_cihasSimCard\(slotId: number, callback: AsyncCallback\<boolean\>\): void
826e41f4b71Sopenharmony_ci
827e41f4b71Sopenharmony_ci获取指定卡槽SIM卡是否插卡。使用callback异步回调。
828e41f4b71Sopenharmony_ci
829e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
830e41f4b71Sopenharmony_ci
831e41f4b71Sopenharmony_ci**参数:**
832e41f4b71Sopenharmony_ci
833e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明                                   |
834e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | -------------------------------------- |
835e41f4b71Sopenharmony_ci| slotId   | number                      | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
836e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;boolean&gt; | 是  | 回调返回指定卡槽是否插卡,如果插卡返回true。                           |
837e41f4b71Sopenharmony_ci
838e41f4b71Sopenharmony_ci**错误码:**
839e41f4b71Sopenharmony_ci
840e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
843e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
844e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
845e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
846e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
847e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
848e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
849e41f4b71Sopenharmony_ci
850e41f4b71Sopenharmony_ci**示例:**
851e41f4b71Sopenharmony_ci
852e41f4b71Sopenharmony_ci```ts
853e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
854e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
855e41f4b71Sopenharmony_ci
856e41f4b71Sopenharmony_cisim.hasSimCard(0, (err: BusinessError, data: boolean) => {
857e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
858e41f4b71Sopenharmony_ci});
859e41f4b71Sopenharmony_ci```
860e41f4b71Sopenharmony_ci
861e41f4b71Sopenharmony_ci
862e41f4b71Sopenharmony_ci## sim.hasSimCard<sup>7+</sup>
863e41f4b71Sopenharmony_ci
864e41f4b71Sopenharmony_cihasSimCard\(slotId: number\): Promise\<boolean\>
865e41f4b71Sopenharmony_ci
866e41f4b71Sopenharmony_ci获取指定卡槽SIM卡是否插卡。使用Promise异步回调。
867e41f4b71Sopenharmony_ci
868e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
869e41f4b71Sopenharmony_ci
870e41f4b71Sopenharmony_ci**参数:**
871e41f4b71Sopenharmony_ci
872e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
873e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
874e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci**返回值:**
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci| 类型                  | 说明                               |
879e41f4b71Sopenharmony_ci| --------------------- | ---------------------------------- |
880e41f4b71Sopenharmony_ci| Promise&lt;boolean&gt; | 以Promise形式返回指定卡槽是否插卡,如果插卡返回true。 |
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ci**错误码:**
883e41f4b71Sopenharmony_ci
884e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
887e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
888e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
889e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
890e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
891e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
892e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
893e41f4b71Sopenharmony_ci
894e41f4b71Sopenharmony_ci**示例:**
895e41f4b71Sopenharmony_ci
896e41f4b71Sopenharmony_ci```ts
897e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
898e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
899e41f4b71Sopenharmony_ci
900e41f4b71Sopenharmony_cisim.hasSimCard(0).then((data: boolean) => {
901e41f4b71Sopenharmony_ci    console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`);
902e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
903e41f4b71Sopenharmony_ci    console.error(`hasSimCard failed, promise: err->${JSON.stringify(err)}`);
904e41f4b71Sopenharmony_ci});
905e41f4b71Sopenharmony_ci```
906e41f4b71Sopenharmony_ci
907e41f4b71Sopenharmony_ci## sim.hasSimCardSync<sup>10+</sup>
908e41f4b71Sopenharmony_ci
909e41f4b71Sopenharmony_cihasSimCardSync\(slotId: number\): boolean
910e41f4b71Sopenharmony_ci
911e41f4b71Sopenharmony_ci获取指定卡槽SIM卡是否插卡。
912e41f4b71Sopenharmony_ci
913e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
914e41f4b71Sopenharmony_ci
915e41f4b71Sopenharmony_ci**参数:**
916e41f4b71Sopenharmony_ci
917e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
918e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
919e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
920e41f4b71Sopenharmony_ci
921e41f4b71Sopenharmony_ci**返回值:**
922e41f4b71Sopenharmony_ci
923e41f4b71Sopenharmony_ci| 类型                  | 说明                               |
924e41f4b71Sopenharmony_ci| --------------------- | ---------------------------------- |
925e41f4b71Sopenharmony_ci| boolean | 返回指定卡槽是否插卡,如果插卡返回true。 |
926e41f4b71Sopenharmony_ci
927e41f4b71Sopenharmony_ci**示例:**
928e41f4b71Sopenharmony_ci
929e41f4b71Sopenharmony_ci```ts
930e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
931e41f4b71Sopenharmony_ci
932e41f4b71Sopenharmony_cilet hasSimCard: boolean = sim.hasSimCardSync(0);
933e41f4b71Sopenharmony_ciconsole.log(`has sim card: ` + hasSimCard);
934e41f4b71Sopenharmony_ci```
935e41f4b71Sopenharmony_ci
936e41f4b71Sopenharmony_ci## sim.getSimAccountInfo<sup>10+</sup>
937e41f4b71Sopenharmony_ci
938e41f4b71Sopenharmony_cigetSimAccountInfo\(slotId: number, callback: AsyncCallback\<IccAccountInfo\>\): void
939e41f4b71Sopenharmony_ci
940e41f4b71Sopenharmony_ci获取SIM卡帐户信息。使用callback异步回调。
941e41f4b71Sopenharmony_ci
942e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.GET_TELEPHONY_STATE
943e41f4b71Sopenharmony_ci
944e41f4b71Sopenharmony_ci>**说明:**
945e41f4b71Sopenharmony_ci>
946e41f4b71Sopenharmony_ci>仅需获取ICCID和号码信息时需要GET_TELEPHONY_STATE权限,ICCID和号码信息为敏感数据,不向三方应用开放。调用接口时,获取到的ICCID和号码信息为空。
947e41f4b71Sopenharmony_ci
948e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
949e41f4b71Sopenharmony_ci
950e41f4b71Sopenharmony_ci**参数:**
951e41f4b71Sopenharmony_ci
952e41f4b71Sopenharmony_ci| 参数名   | 类型                                                | 必填 | 说明                                   |
953e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | -------------------------------------- |
954e41f4b71Sopenharmony_ci| slotId   | number                                              | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
955e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[IccAccountInfo](#iccaccountinfo10)&gt; | 是   | 回调函数。返回指定卡槽SIM卡的帐户信息。                             |
956e41f4b71Sopenharmony_ci
957e41f4b71Sopenharmony_ci**错误码:**
958e41f4b71Sopenharmony_ci
959e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
960e41f4b71Sopenharmony_ci
961e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
962e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
963e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
964e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
965e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
966e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
967e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
968e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
969e41f4b71Sopenharmony_ci| 8301002  | The SIM card failed to read or update data.  |
970e41f4b71Sopenharmony_ci
971e41f4b71Sopenharmony_ci**示例:**
972e41f4b71Sopenharmony_ci
973e41f4b71Sopenharmony_ci```ts
974e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
975e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
976e41f4b71Sopenharmony_ci
977e41f4b71Sopenharmony_cisim.getSimAccountInfo(0, (err:BusinessError , data: sim.IccAccountInfo) => {
978e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
979e41f4b71Sopenharmony_ci});
980e41f4b71Sopenharmony_ci```
981e41f4b71Sopenharmony_ci
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ci## sim.getSimAccountInfo<sup>10+</sup>
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_cigetSimAccountInfo\(slotId: number\): Promise\<IccAccountInfo\>
986e41f4b71Sopenharmony_ci
987e41f4b71Sopenharmony_ci获取SIM卡帐户信息。使用Promise异步回调。
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.GET_TELEPHONY_STATE
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_ci>**说明:**
992e41f4b71Sopenharmony_ci>
993e41f4b71Sopenharmony_ci>仅需获取ICCID和号码信息时需要GET_TELEPHONY_STATE权限,ICCID和号码信息为敏感数据,不向三方应用开放。调用接口时,获取到的ICCID和号码信息为空。
994e41f4b71Sopenharmony_ci
995e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
996e41f4b71Sopenharmony_ci
997e41f4b71Sopenharmony_ci**参数:**
998e41f4b71Sopenharmony_ci
999e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
1000e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
1001e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ci**返回值:**
1004e41f4b71Sopenharmony_ci
1005e41f4b71Sopenharmony_ci| 类型                                         | 说明                                       |
1006e41f4b71Sopenharmony_ci| -------------------------------------------- | ------------------------------------------ |
1007e41f4b71Sopenharmony_ci| Promise&lt;[IccAccountInfo](#iccaccountinfo10)&gt; | 以Promise形式返回指定卡槽SIM卡的帐户信息。 |
1008e41f4b71Sopenharmony_ci
1009e41f4b71Sopenharmony_ci**错误码:**
1010e41f4b71Sopenharmony_ci
1011e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1012e41f4b71Sopenharmony_ci
1013e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1014e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1015e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
1016e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1017e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
1018e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1019e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
1020e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
1021e41f4b71Sopenharmony_ci| 8301002  | The SIM card failed to read or update data.  |
1022e41f4b71Sopenharmony_ci
1023e41f4b71Sopenharmony_ci**示例:**
1024e41f4b71Sopenharmony_ci
1025e41f4b71Sopenharmony_ci```ts
1026e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1027e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1028e41f4b71Sopenharmony_ci
1029e41f4b71Sopenharmony_cisim.getSimAccountInfo(0).then((data: sim.IccAccountInfo) => {
1030e41f4b71Sopenharmony_ci    console.log(`getSimAccountInfo success, promise: data->${JSON.stringify(data)}`);
1031e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1032e41f4b71Sopenharmony_ci    console.error(`getSimAccountInfo failed, promise: err->${JSON.stringify(err)}`);
1033e41f4b71Sopenharmony_ci});
1034e41f4b71Sopenharmony_ci```
1035e41f4b71Sopenharmony_ci
1036e41f4b71Sopenharmony_ci## sim.getActiveSimAccountInfoList<sup>10+</sup>
1037e41f4b71Sopenharmony_ci
1038e41f4b71Sopenharmony_cigetActiveSimAccountInfoList\(callback: AsyncCallback\<Array\<IccAccountInfo\>\>\): void
1039e41f4b71Sopenharmony_ci
1040e41f4b71Sopenharmony_ci获取激活SIM卡帐户信息列表。使用callback异步回调。
1041e41f4b71Sopenharmony_ci
1042e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.GET_TELEPHONY_STATE
1043e41f4b71Sopenharmony_ci
1044e41f4b71Sopenharmony_ci>**说明:**
1045e41f4b71Sopenharmony_ci>
1046e41f4b71Sopenharmony_ci>仅需获取ICCID和号码信息时需要GET_TELEPHONY_STATE权限,ICCID和号码信息为敏感数据,不向三方应用开放。调用接口时,获取到的ICCID和号码信息为空。
1047e41f4b71Sopenharmony_ci
1048e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1049e41f4b71Sopenharmony_ci
1050e41f4b71Sopenharmony_ci**参数:**
1051e41f4b71Sopenharmony_ci
1052e41f4b71Sopenharmony_ci| 参数名   | 类型                                                        | 必填 | 说明       |
1053e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------------- | ---- | ---------- |
1054e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;Array&lt;[IccAccountInfo](#iccaccountinfo10)&gt;&gt; | 是   | 回调函数。返回激活SIM卡帐户信息列表。 |
1055e41f4b71Sopenharmony_ci
1056e41f4b71Sopenharmony_ci**错误码:**
1057e41f4b71Sopenharmony_ci
1058e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1059e41f4b71Sopenharmony_ci
1060e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1061e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1062e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
1063e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1064e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
1065e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1066e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
1067e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
1068e41f4b71Sopenharmony_ci
1069e41f4b71Sopenharmony_ci**示例:**
1070e41f4b71Sopenharmony_ci
1071e41f4b71Sopenharmony_ci```ts
1072e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1073e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1074e41f4b71Sopenharmony_ci
1075e41f4b71Sopenharmony_cisim.getActiveSimAccountInfoList((err: BusinessError, data: Array<sim.IccAccountInfo>) => {
1076e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1077e41f4b71Sopenharmony_ci});
1078e41f4b71Sopenharmony_ci```
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_ci## sim.getMaxSimCount<sup>7+</sup>
1081e41f4b71Sopenharmony_ci
1082e41f4b71Sopenharmony_cigetMaxSimCount\(\): number
1083e41f4b71Sopenharmony_ci
1084e41f4b71Sopenharmony_ci获取卡槽数量。
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1087e41f4b71Sopenharmony_ci
1088e41f4b71Sopenharmony_ci**返回值:**
1089e41f4b71Sopenharmony_ci
1090e41f4b71Sopenharmony_ci| 类型              | 说明                                                         |
1091e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ |
1092e41f4b71Sopenharmony_ci| number | 卡槽数量。 |
1093e41f4b71Sopenharmony_ci
1094e41f4b71Sopenharmony_ci**示例:**
1095e41f4b71Sopenharmony_ci
1096e41f4b71Sopenharmony_ci```ts
1097e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1098e41f4b71Sopenharmony_ci
1099e41f4b71Sopenharmony_ciconsole.log("Result: "+ sim.getMaxSimCount());
1100e41f4b71Sopenharmony_ci```
1101e41f4b71Sopenharmony_ci
1102e41f4b71Sopenharmony_ci
1103e41f4b71Sopenharmony_ci## sim.getActiveSimAccountInfoList<sup>10+</sup>
1104e41f4b71Sopenharmony_ci
1105e41f4b71Sopenharmony_cigetActiveSimAccountInfoList\(\): Promise\<Array\<IccAccountInfo\>\>
1106e41f4b71Sopenharmony_ci
1107e41f4b71Sopenharmony_ci获取激活SIM卡帐户信息列表。使用Promise异步回调。
1108e41f4b71Sopenharmony_ci
1109e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.GET_TELEPHONY_STATE
1110e41f4b71Sopenharmony_ci
1111e41f4b71Sopenharmony_ci>**说明:**
1112e41f4b71Sopenharmony_ci>
1113e41f4b71Sopenharmony_ci>仅需获取ICCID和号码信息时需要GET_TELEPHONY_STATE权限,ICCID和号码信息为敏感数据,不向三方应用开放。调用接口时,获取到的ICCID和号码信息为空。
1114e41f4b71Sopenharmony_ci
1115e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1116e41f4b71Sopenharmony_ci
1117e41f4b71Sopenharmony_ci**返回值:**
1118e41f4b71Sopenharmony_ci
1119e41f4b71Sopenharmony_ci| 类型                                                 | 说明                                           |
1120e41f4b71Sopenharmony_ci| ---------------------------------------------------- | ---------------------------------------------- |
1121e41f4b71Sopenharmony_ci| Promise&lt;Array&lt;[IccAccountInfo](#iccaccountinfo10)&gt;&gt; | 以Promise形式返回激活卡槽SIM卡的帐户信息列表。 |
1122e41f4b71Sopenharmony_ci
1123e41f4b71Sopenharmony_ci**错误码:**
1124e41f4b71Sopenharmony_ci
1125e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1126e41f4b71Sopenharmony_ci
1127e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1128e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1129e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
1130e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1131e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
1132e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
1133e41f4b71Sopenharmony_ci
1134e41f4b71Sopenharmony_ci**示例:**
1135e41f4b71Sopenharmony_ci
1136e41f4b71Sopenharmony_ci```ts
1137e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1138e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1139e41f4b71Sopenharmony_ci
1140e41f4b71Sopenharmony_cisim.getActiveSimAccountInfoList().then((data: Array<sim.IccAccountInfo>) => {
1141e41f4b71Sopenharmony_ci    console.log(`getActiveSimAccountInfoList success, promise: data->${JSON.stringify(data)}`);
1142e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1143e41f4b71Sopenharmony_ci    console.error(`getActiveSimAccountInfoList failed, promise: err->${JSON.stringify(err)}`);
1144e41f4b71Sopenharmony_ci});
1145e41f4b71Sopenharmony_ci```
1146e41f4b71Sopenharmony_ci
1147e41f4b71Sopenharmony_ci
1148e41f4b71Sopenharmony_ci## sim.getOpKey<sup>9+</sup>
1149e41f4b71Sopenharmony_ci
1150e41f4b71Sopenharmony_cigetOpKey\(slotId: number, callback: AsyncCallback\<string\>): void
1151e41f4b71Sopenharmony_ci
1152e41f4b71Sopenharmony_ci获取指定卡槽中SIM卡的opkey。使用callback异步回调。
1153e41f4b71Sopenharmony_ci
1154e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1155e41f4b71Sopenharmony_ci
1156e41f4b71Sopenharmony_ci**参数:**
1157e41f4b71Sopenharmony_ci
1158e41f4b71Sopenharmony_ci| 参数名   | 类型                   | 必填 | 说明                                   |
1159e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | -------------------------------------- |
1160e41f4b71Sopenharmony_ci| slotId   | number                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1161e41f4b71Sopenharmony_ci| callback | AsyncCallback<string\> | 是   | 回调函数。                             |
1162e41f4b71Sopenharmony_ci
1163e41f4b71Sopenharmony_ci**错误码:**
1164e41f4b71Sopenharmony_ci
1165e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1166e41f4b71Sopenharmony_ci
1167e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1168e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1169e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
1170e41f4b71Sopenharmony_ci| 801      | Capability not supported.                    |
1171e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1172e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
1173e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1174e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
1175e41f4b71Sopenharmony_ci
1176e41f4b71Sopenharmony_ci**示例:**
1177e41f4b71Sopenharmony_ci
1178e41f4b71Sopenharmony_ci```ts
1179e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1180e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1181e41f4b71Sopenharmony_ci
1182e41f4b71Sopenharmony_citry {
1183e41f4b71Sopenharmony_ci    sim.getOpKey(0, (err: BusinessError, data: string) => {
1184e41f4b71Sopenharmony_ci    if (err) {
1185e41f4b71Sopenharmony_ci      console.error("getOpKey failed, err: " + JSON.stringify(err));
1186e41f4b71Sopenharmony_ci    } else {
1187e41f4b71Sopenharmony_ci      console.log('getOpKey successfully, data: ' + JSON.stringify(data));
1188e41f4b71Sopenharmony_ci    }
1189e41f4b71Sopenharmony_ci  });
1190e41f4b71Sopenharmony_ci} catch (err) {
1191e41f4b71Sopenharmony_ci  console.error("getOpKey err: " + JSON.stringify(err));
1192e41f4b71Sopenharmony_ci}
1193e41f4b71Sopenharmony_ci```
1194e41f4b71Sopenharmony_ci
1195e41f4b71Sopenharmony_ci
1196e41f4b71Sopenharmony_ci## sim.getOpKey<sup>9+</sup>
1197e41f4b71Sopenharmony_ci
1198e41f4b71Sopenharmony_cigetOpKey\(slotId: number\): Promise\<string\>
1199e41f4b71Sopenharmony_ci
1200e41f4b71Sopenharmony_ci获取指定卡槽中SIM卡的opkey。使用Promise异步回调。
1201e41f4b71Sopenharmony_ci
1202e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1203e41f4b71Sopenharmony_ci
1204e41f4b71Sopenharmony_ci**参数:**
1205e41f4b71Sopenharmony_ci
1206e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
1207e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
1208e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1209e41f4b71Sopenharmony_ci
1210e41f4b71Sopenharmony_ci**返回值:**
1211e41f4b71Sopenharmony_ci
1212e41f4b71Sopenharmony_ci| 类型             | 说明                                      |
1213e41f4b71Sopenharmony_ci| ---------------- | ----------------------------------------- |
1214e41f4b71Sopenharmony_ci| Promise<string\> | 以Promise形式返回指定卡槽中SIM卡的opkey。 |
1215e41f4b71Sopenharmony_ci
1216e41f4b71Sopenharmony_ci**错误码:**
1217e41f4b71Sopenharmony_ci
1218e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1219e41f4b71Sopenharmony_ci
1220e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1221e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1222e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
1223e41f4b71Sopenharmony_ci| 801      | Capability not supported.                    |
1224e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1225e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
1226e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1227e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
1228e41f4b71Sopenharmony_ci
1229e41f4b71Sopenharmony_ci**示例:**
1230e41f4b71Sopenharmony_ci
1231e41f4b71Sopenharmony_ci```ts
1232e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1233e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1234e41f4b71Sopenharmony_ci
1235e41f4b71Sopenharmony_cisim.getOpKey(0).then((data: string) => {
1236e41f4b71Sopenharmony_ci    console.log(`getOpKey success, promise: data->${JSON.stringify(data)}`);
1237e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1238e41f4b71Sopenharmony_ci    console.error(`getOpKey failed, promise: err->${JSON.stringify(err)}`);
1239e41f4b71Sopenharmony_ci});
1240e41f4b71Sopenharmony_ci```
1241e41f4b71Sopenharmony_ci
1242e41f4b71Sopenharmony_ci## sim.getOpKeySync<sup>10+</sup>
1243e41f4b71Sopenharmony_ci
1244e41f4b71Sopenharmony_cigetOpKeySync\(slotId: number\): string
1245e41f4b71Sopenharmony_ci
1246e41f4b71Sopenharmony_ci获取指定卡槽中SIM卡的opkey。
1247e41f4b71Sopenharmony_ci
1248e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1249e41f4b71Sopenharmony_ci
1250e41f4b71Sopenharmony_ci**参数:**
1251e41f4b71Sopenharmony_ci
1252e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
1253e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
1254e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1255e41f4b71Sopenharmony_ci
1256e41f4b71Sopenharmony_ci**返回值:**
1257e41f4b71Sopenharmony_ci
1258e41f4b71Sopenharmony_ci| 类型             | 说明                                      |
1259e41f4b71Sopenharmony_ci| ---------------- | ----------------------------------------- |
1260e41f4b71Sopenharmony_ci| string | 返回指定卡槽中SIM卡的opkey。 |
1261e41f4b71Sopenharmony_ci
1262e41f4b71Sopenharmony_ci
1263e41f4b71Sopenharmony_ci**示例:**
1264e41f4b71Sopenharmony_ci
1265e41f4b71Sopenharmony_ci```ts
1266e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1267e41f4b71Sopenharmony_ci
1268e41f4b71Sopenharmony_cilet data: string = sim.getOpKeySync(0);
1269e41f4b71Sopenharmony_ciconsole.log(`getOpKey success, promise: data->${JSON.stringify(data)}`);
1270e41f4b71Sopenharmony_ci```
1271e41f4b71Sopenharmony_ci
1272e41f4b71Sopenharmony_ci## sim.getOpName<sup>9+</sup>
1273e41f4b71Sopenharmony_ci
1274e41f4b71Sopenharmony_cigetOpName\(slotId: number, callback: AsyncCallback\<string\>\): void
1275e41f4b71Sopenharmony_ci
1276e41f4b71Sopenharmony_ci获取指定卡槽中SIM卡的OpName。使用callback异步回调。
1277e41f4b71Sopenharmony_ci
1278e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1279e41f4b71Sopenharmony_ci
1280e41f4b71Sopenharmony_ci**参数:**
1281e41f4b71Sopenharmony_ci
1282e41f4b71Sopenharmony_ci| 参数名   | 类型                   | 必填 | 说明                                   |
1283e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | -------------------------------------- |
1284e41f4b71Sopenharmony_ci| slotId   | number                 | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1285e41f4b71Sopenharmony_ci| callback | AsyncCallback<string\> | 是   | 回调函数。                               |
1286e41f4b71Sopenharmony_ci
1287e41f4b71Sopenharmony_ci**错误码:**
1288e41f4b71Sopenharmony_ci
1289e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1290e41f4b71Sopenharmony_ci
1291e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1292e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1293e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
1294e41f4b71Sopenharmony_ci| 801      | Capability not supported.                    |
1295e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1296e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
1297e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1298e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
1299e41f4b71Sopenharmony_ci
1300e41f4b71Sopenharmony_ci**示例:**
1301e41f4b71Sopenharmony_ci
1302e41f4b71Sopenharmony_ci```ts
1303e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1304e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1305e41f4b71Sopenharmony_ci
1306e41f4b71Sopenharmony_citry {
1307e41f4b71Sopenharmony_ci    sim.getOpName(0, (err: BusinessError, data: string) => {
1308e41f4b71Sopenharmony_ci    if (err) {
1309e41f4b71Sopenharmony_ci      console.error("getOpName failed, err: " + JSON.stringify(err));
1310e41f4b71Sopenharmony_ci    } else {
1311e41f4b71Sopenharmony_ci      console.log('getOpName successfully, data: ' + JSON.stringify(data));
1312e41f4b71Sopenharmony_ci    }
1313e41f4b71Sopenharmony_ci  });
1314e41f4b71Sopenharmony_ci} catch (err) {
1315e41f4b71Sopenharmony_ci  console.error("getOpName err: " + JSON.stringify(err));
1316e41f4b71Sopenharmony_ci}
1317e41f4b71Sopenharmony_ci```
1318e41f4b71Sopenharmony_ci
1319e41f4b71Sopenharmony_ci
1320e41f4b71Sopenharmony_ci## sim.getOpName<sup>9+</sup>
1321e41f4b71Sopenharmony_ci
1322e41f4b71Sopenharmony_cigetOpName\(slotId: number\): Promise\<string\>
1323e41f4b71Sopenharmony_ci
1324e41f4b71Sopenharmony_ci获取指定卡槽中SIM卡的OpName。使用Promise异步回调。
1325e41f4b71Sopenharmony_ci
1326e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1327e41f4b71Sopenharmony_ci
1328e41f4b71Sopenharmony_ci**参数:**
1329e41f4b71Sopenharmony_ci
1330e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
1331e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
1332e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1333e41f4b71Sopenharmony_ci
1334e41f4b71Sopenharmony_ci**返回值:**
1335e41f4b71Sopenharmony_ci
1336e41f4b71Sopenharmony_ci| 类型             | 说明                                       |
1337e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------ |
1338e41f4b71Sopenharmony_ci| Promise<string\> | 以Promise形式返回指定卡槽中SIM卡的OpName。 |
1339e41f4b71Sopenharmony_ci
1340e41f4b71Sopenharmony_ci**错误码:**
1341e41f4b71Sopenharmony_ci
1342e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1343e41f4b71Sopenharmony_ci
1344e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1345e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1346e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
1347e41f4b71Sopenharmony_ci| 801      | Capability not supported.                    |
1348e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1349e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
1350e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1351e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
1352e41f4b71Sopenharmony_ci
1353e41f4b71Sopenharmony_ci**示例:**
1354e41f4b71Sopenharmony_ci
1355e41f4b71Sopenharmony_ci```ts
1356e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1357e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1358e41f4b71Sopenharmony_ci
1359e41f4b71Sopenharmony_cisim.getOpName(0).then((data: string) => {
1360e41f4b71Sopenharmony_ci    console.log(`getOpName success, promise: data->${JSON.stringify(data)}`);
1361e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1362e41f4b71Sopenharmony_ci    console.error(`getOpName failed, promise: err->${JSON.stringify(err)}`);
1363e41f4b71Sopenharmony_ci});
1364e41f4b71Sopenharmony_ci```
1365e41f4b71Sopenharmony_ci
1366e41f4b71Sopenharmony_ci## sim.getOpNameSync<sup>10+</sup>
1367e41f4b71Sopenharmony_ci
1368e41f4b71Sopenharmony_cigetOpNameSync\(slotId: number\): string
1369e41f4b71Sopenharmony_ci
1370e41f4b71Sopenharmony_ci获取指定卡槽中SIM卡的OpName。
1371e41f4b71Sopenharmony_ci
1372e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1373e41f4b71Sopenharmony_ci
1374e41f4b71Sopenharmony_ci**参数:**
1375e41f4b71Sopenharmony_ci
1376e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                   |
1377e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- |
1378e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br/>- 0:卡槽1<br/>- 1:卡槽2 |
1379e41f4b71Sopenharmony_ci
1380e41f4b71Sopenharmony_ci**返回值:**
1381e41f4b71Sopenharmony_ci
1382e41f4b71Sopenharmony_ci| 类型             | 说明                                       |
1383e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------ |
1384e41f4b71Sopenharmony_ci| string | 返回指定卡槽中SIM卡的OpName。 |
1385e41f4b71Sopenharmony_ci
1386e41f4b71Sopenharmony_ci
1387e41f4b71Sopenharmony_ci**示例:**
1388e41f4b71Sopenharmony_ci
1389e41f4b71Sopenharmony_ci```ts
1390e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1391e41f4b71Sopenharmony_ci
1392e41f4b71Sopenharmony_cilet data: string = sim.getOpNameSync(0);
1393e41f4b71Sopenharmony_ciconsole.log(`getOpName success, promise: data->${JSON.stringify(data)}`);
1394e41f4b71Sopenharmony_ci```
1395e41f4b71Sopenharmony_ci
1396e41f4b71Sopenharmony_ci## sim.getDefaultVoiceSimId<sup>10+</sup>
1397e41f4b71Sopenharmony_ci
1398e41f4b71Sopenharmony_cigetDefaultVoiceSimId\(callback: AsyncCallback\<number\>\): void
1399e41f4b71Sopenharmony_ci
1400e41f4b71Sopenharmony_ci获取默认语音业务的SIM卡ID。使用callback异步回调。
1401e41f4b71Sopenharmony_ci
1402e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1403e41f4b71Sopenharmony_ci
1404e41f4b71Sopenharmony_ci**参数:**
1405e41f4b71Sopenharmony_ci
1406e41f4b71Sopenharmony_ci| 参数名   | 类型                        | 必填 | 说明       |
1407e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------- |
1408e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。<br/>与SIM卡绑定,从1开始递增。 |
1409e41f4b71Sopenharmony_ci
1410e41f4b71Sopenharmony_ci**错误码:**
1411e41f4b71Sopenharmony_ci
1412e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1413e41f4b71Sopenharmony_ci
1414e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1415e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1416e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
1417e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1418e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
1419e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1420e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
1421e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
1422e41f4b71Sopenharmony_ci| 8301001  | SIM card is not activated.                   |
1423e41f4b71Sopenharmony_ci
1424e41f4b71Sopenharmony_ci**示例:**
1425e41f4b71Sopenharmony_ci
1426e41f4b71Sopenharmony_ci```ts
1427e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1428e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1429e41f4b71Sopenharmony_ci
1430e41f4b71Sopenharmony_cisim.getDefaultVoiceSimId((err: BusinessError, data: number) => {
1431e41f4b71Sopenharmony_ci    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
1432e41f4b71Sopenharmony_ci});
1433e41f4b71Sopenharmony_ci```
1434e41f4b71Sopenharmony_ci
1435e41f4b71Sopenharmony_ci## sim.getDefaultVoiceSimId<sup>10+</sup>
1436e41f4b71Sopenharmony_ci
1437e41f4b71Sopenharmony_cigetDefaultVoiceSimId\(\): Promise\<number\>
1438e41f4b71Sopenharmony_ci
1439e41f4b71Sopenharmony_ci获取默认语音业务的SIM卡ID。使用Promise异步回调。
1440e41f4b71Sopenharmony_ci
1441e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1442e41f4b71Sopenharmony_ci
1443e41f4b71Sopenharmony_ci**返回值:**
1444e41f4b71Sopenharmony_ci
1445e41f4b71Sopenharmony_ci| 类型              | 说明                                    |
1446e41f4b71Sopenharmony_ci| ----------------- | --------------------------------------- |
1447e41f4b71Sopenharmony_ci| Promise\<number\> | 以Promise形式返回默认语音业务的SIM卡ID。<br/>与SIM卡绑定,从1开始递增。 |
1448e41f4b71Sopenharmony_ci
1449e41f4b71Sopenharmony_ci**错误码:**
1450e41f4b71Sopenharmony_ci
1451e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
1452e41f4b71Sopenharmony_ci
1453e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
1454e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
1455e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
1456e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
1457e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
1458e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
1459e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
1460e41f4b71Sopenharmony_ci| 8301001  | SIM card is not activated.                   |
1461e41f4b71Sopenharmony_ci
1462e41f4b71Sopenharmony_ci**示例:**
1463e41f4b71Sopenharmony_ci
1464e41f4b71Sopenharmony_ci```ts
1465e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1466e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit';
1467e41f4b71Sopenharmony_ci
1468e41f4b71Sopenharmony_cilet promise = sim.getDefaultVoiceSimId();
1469e41f4b71Sopenharmony_cipromise.then((data: number) => {
1470e41f4b71Sopenharmony_ci    console.log(`getDefaultVoiceSimId success, promise: data->${JSON.stringify(data)}`);
1471e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1472e41f4b71Sopenharmony_ci    console.error(`getDefaultVoiceSimId failed, promise: err->${JSON.stringify(err)}`);
1473e41f4b71Sopenharmony_ci});
1474e41f4b71Sopenharmony_ci```
1475e41f4b71Sopenharmony_ci
1476e41f4b71Sopenharmony_ci
1477e41f4b71Sopenharmony_ci## SimState
1478e41f4b71Sopenharmony_ci
1479e41f4b71Sopenharmony_ciSIM卡状态。
1480e41f4b71Sopenharmony_ci
1481e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1482e41f4b71Sopenharmony_ci
1483e41f4b71Sopenharmony_ci| 名称                  | 值   | 说明                                                       |
1484e41f4b71Sopenharmony_ci| --------------------- | ---- | ---------------------------------------------------------- |
1485e41f4b71Sopenharmony_ci| SIM_STATE_UNKNOWN     | 0    | SIM卡状态未知,即无法获取准确的状态。                      |
1486e41f4b71Sopenharmony_ci| SIM_STATE_NOT_PRESENT | 1    | 表示SIM卡处于not present状态,即卡槽中没有插入SIM卡。      |
1487e41f4b71Sopenharmony_ci| SIM_STATE_LOCKED      | 2    | 表示SIM卡处于locked状态,即SIM卡被PIN、PUK或网络锁锁定。   |
1488e41f4b71Sopenharmony_ci| SIM_STATE_NOT_READY   | 3    | 表示SIM卡处于not ready状态,即SIM卡在位但无法正常工作。    |
1489e41f4b71Sopenharmony_ci| SIM_STATE_READY       | 4    | 表示SIM卡处于ready状态,即SIM卡在位且工作正常。            |
1490e41f4b71Sopenharmony_ci| SIM_STATE_LOADED      | 5    | 表示SIM卡处于loaded状态,即SIM卡在位且所有卡文件加载完毕。 |
1491e41f4b71Sopenharmony_ci
1492e41f4b71Sopenharmony_ci## CardType<sup>7+</sup>
1493e41f4b71Sopenharmony_ci
1494e41f4b71Sopenharmony_ci卡类型。
1495e41f4b71Sopenharmony_ci
1496e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1497e41f4b71Sopenharmony_ci
1498e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
1499e41f4b71Sopenharmony_ci| ----- | ----- | ----- |
1500e41f4b71Sopenharmony_ci|UNKNOWN_CARD | -1 | 未知类型。 |
1501e41f4b71Sopenharmony_ci|SINGLE_MODE_SIM_CARD | 10 | 单SIM卡。 |
1502e41f4b71Sopenharmony_ci|SINGLE_MODE_USIM_CARD | 20 | 单USIM卡。 |
1503e41f4b71Sopenharmony_ci|SINGLE_MODE_RUIM_CARD | 30 | 单RUIM卡。 |
1504e41f4b71Sopenharmony_ci|DUAL_MODE_CG_CARD | 40 | 双卡模式C+G。 |
1505e41f4b71Sopenharmony_ci|CT_NATIONAL_ROAMING_CARD | 41 | 中国电信内部漫游卡。 |
1506e41f4b71Sopenharmony_ci|CU_DUAL_MODE_CARD | 42 | 中国联通双模卡。 |
1507e41f4b71Sopenharmony_ci|DUAL_MODE_TELECOM_LTE_CARD | 43 | 双模式电信LTE卡。 |
1508e41f4b71Sopenharmony_ci|DUAL_MODE_UG_CARD | 50 | 双模式UG卡。 |
1509e41f4b71Sopenharmony_ci|SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | 单一ISIM卡类型。 |
1510e41f4b71Sopenharmony_ci
1511e41f4b71Sopenharmony_ci## IccAccountInfo<sup>10+</sup>
1512e41f4b71Sopenharmony_ci
1513e41f4b71Sopenharmony_ciIcc帐户信息。
1514e41f4b71Sopenharmony_ci
1515e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CoreService
1516e41f4b71Sopenharmony_ci
1517e41f4b71Sopenharmony_ci| 名称       | 类型    | 必填 | 说明             |
1518e41f4b71Sopenharmony_ci| ---------- | ------- | ---- | ---------------- |
1519e41f4b71Sopenharmony_ci| simId      | number  |  是  | SIM卡ID。          |
1520e41f4b71Sopenharmony_ci| slotIndex  | number  |  是  | 卡槽ID。           |
1521e41f4b71Sopenharmony_ci| isEsim     | boolean |  是  | 标记卡是否是eSim。 |
1522e41f4b71Sopenharmony_ci| isActive   | boolean |  是  | 卡是否被激活。     |
1523e41f4b71Sopenharmony_ci| iccId      | string  |  是  | ICCID号码。        |
1524e41f4b71Sopenharmony_ci| showName   | string  |  是  | SIM卡显示名称。    |
1525e41f4b71Sopenharmony_ci| showNumber | string  |  是  | SIM卡显示号码。    |