1e41f4b71Sopenharmony_ci# @ohos.telephony.data (蜂窝数据)(系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci蜂窝数据提供了移动数据管理能力,包括设置默认移动数据的SIM卡,启用、禁用蜂窝数据服务和蜂窝数据漫游。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>**说明:**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci>本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci>当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.telephony.data (蜂窝数据)](js-apis-telephony-data.md)
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## 导入模块
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci```ts
15e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
16e41f4b71Sopenharmony_ci```
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci## data.setDefaultCellularDataSlotId
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_cisetDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\<void\>): void 
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci设置默认移动数据的SIM卡,使用callback方式作为异步方法。 
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CellularData
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci**参数:**
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci| 参数名   | 类型                  | 必填 | 说明                                                         |
34e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ------------------------------------------------------------ |
35e41f4b71Sopenharmony_ci| slotId   | number                | 是   | SIM卡槽ID。<br/>- 0:卡槽1。<br/>- 1:卡槽2。 |
36e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | 是   | 以callback形式异步返回结果。                                                   |
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci**错误码:**
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
43e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
44e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
45e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
46e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
47e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
48e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
49e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
50e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
51e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
52e41f4b71Sopenharmony_ci| 8301001  | SIM card is not activated.                   |
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci**示例:**
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci```ts
57e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
58e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_cidata.setDefaultCellularDataSlotId(0, (err: BusinessError) => {
61e41f4b71Sopenharmony_ci    if(err){
62e41f4b71Sopenharmony_ci        console.error(`setDefaultCellularDataSlotId fail,callback: err->${JSON.stringify(err)}.`);
63e41f4b71Sopenharmony_ci    }else{
64e41f4b71Sopenharmony_ci        console.log(`setDefaultCellularDataSlotId success`);
65e41f4b71Sopenharmony_ci    }
66e41f4b71Sopenharmony_ci});
67e41f4b71Sopenharmony_ci```
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci## data.setDefaultCellularDataSlotId
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_cisetDefaultCellularDataSlotId(slotId: number): Promise\<void\> 
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci设置默认移动数据的SIM卡,使用Promise方式作为异步方法。 
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CellularData
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci**参数:**
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                                         |
84e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ |
85e41f4b71Sopenharmony_ci| slotId | number | 是   | SIM卡槽ID。<br/>- 0:卡槽1。<br/>- 1:卡槽2。 |
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci**返回值:**
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci| 类型            | 说明                            |
90e41f4b71Sopenharmony_ci| --------------- | ------------------------------- |
91e41f4b71Sopenharmony_ci| Promise\<void\> | 以Promise形式异步返回设置结果。 |
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci**错误码:**
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci| 错误码ID |                 错误信息                     |
98e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
99e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
100e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
101e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                            |
102e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
103e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
104e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
105e41f4b71Sopenharmony_ci| 8300004  | No SIM card found.                           |
106e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
107e41f4b71Sopenharmony_ci| 8301001  | SIM card is not activated.                   |
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci**示例:**
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci```ts
112e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
113e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_cidata.setDefaultCellularDataSlotId(0).then(() => {
116e41f4b71Sopenharmony_ci    console.log(`setDefaultCellularDataSlotId success.`);
117e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
118e41f4b71Sopenharmony_ci    console.error(`setDefaultCellularDataSlotId fail, promise: err->${JSON.stringify(err)}`);
119e41f4b71Sopenharmony_ci});
120e41f4b71Sopenharmony_ci```
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci## data.enableCellularData
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_cienableCellularData(callback: AsyncCallback\<void\>): void
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci启用蜂窝数据服务,使用callback方式作为异步方法。
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CellularData
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci**参数:**
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci| 参数名   | 类型                  | 必填 | 说明       |
138e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------- |
139e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | 是   | 以callback形式异步返回结果。 |
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci**错误码:**
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
146e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
147e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
148e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
149e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
150e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
151e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
152e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
153e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci**示例:**
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci```ts
158e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
159e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_cidata.enableCellularData((err: BusinessError) => {
162e41f4b71Sopenharmony_ci    if(err){
163e41f4b71Sopenharmony_ci        console.error(`enableCellularData fail,callback: callback: err->${JSON.stringify(err)}`);
164e41f4b71Sopenharmony_ci    }else{
165e41f4b71Sopenharmony_ci        console.log(`enableCellularData success`);
166e41f4b71Sopenharmony_ci    }
167e41f4b71Sopenharmony_ci});
168e41f4b71Sopenharmony_ci```
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci## data.enableCellularData
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_cienableCellularData(): Promise\<void\>
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci启用蜂窝数据服务,使用Promise方式作为异步方法。
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CellularData
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci**返回值:**
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci| 类型            | 说明                    |
185e41f4b71Sopenharmony_ci| --------------- | ----------------------- |
186e41f4b71Sopenharmony_ci| Promise\<void\> | 以Promise形式返回结果。 |
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci**错误码:**
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
193e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
194e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
195e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
196e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
197e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
198e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci**示例:**
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci```ts
203e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
204e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_cidata.enableCellularData().then(() => {
207e41f4b71Sopenharmony_ci    console.log(`enableCellularData success.`);
208e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
209e41f4b71Sopenharmony_ci    console.error(`enableCellularData fail, promise: err->${JSON.stringify(err)}`);
210e41f4b71Sopenharmony_ci});
211e41f4b71Sopenharmony_ci```
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci## data.disableCellularData
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_cidisableCellularData(callback: AsyncCallback\<void\>): void
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci禁用蜂窝数据服务,使用callback方式作为异步方法。
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CellularData
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci**参数:**
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci| 参数名   | 类型                  | 必填 | 说明       |
228e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------- |
229e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | 是   | 以callback形式异步返回结果。 |
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**错误码:**
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
236e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
237e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
238e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
239e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
240e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
241e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
242e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
243e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci**示例:**
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci```ts
248e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
249e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_cidata.disableCellularData((err: BusinessError) => {
252e41f4b71Sopenharmony_ci    if(err){
253e41f4b71Sopenharmony_ci        console.error(`disableCellularData fail,callback: callback: err->${JSON.stringify(err)}`);
254e41f4b71Sopenharmony_ci    }else{
255e41f4b71Sopenharmony_ci        console.log(`disableCellularData success`);
256e41f4b71Sopenharmony_ci    }
257e41f4b71Sopenharmony_ci});
258e41f4b71Sopenharmony_ci```
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci## data.disableCellularData
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_cidisableCellularData(): Promise\<void\>
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci禁用蜂窝数据服务,使用Promise方式作为异步方法。
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CellularData
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ci**返回值:**
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci| 类型            | 说明                        |
275e41f4b71Sopenharmony_ci| --------------- | --------------------------- |
276e41f4b71Sopenharmony_ci| Promise\<void\> | 以Promise形式返回禁用结果。 |
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci**错误码:**
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
283e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
284e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
285e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
286e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
287e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
288e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci**示例:**
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci```ts
293e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
294e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_cidata.disableCellularData().then(() => {
297e41f4b71Sopenharmony_ci    console.log(`disableCellularData success.`);
298e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
299e41f4b71Sopenharmony_ci    console.error(`disableCellularData fail, promise: err->${JSON.stringify(err)}`);
300e41f4b71Sopenharmony_ci});
301e41f4b71Sopenharmony_ci```
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci## data.enableCellularDataRoaming
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_cienableCellularDataRoaming(slotId: number, callback: AsyncCallback\<void\>): void
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ci启用蜂窝数据漫游,使用callback方式作为异步方法。
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CellularData
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ci**参数:**
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci| 参数名   | 类型                  | 必填 | 说明                                     |
318e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------------------------------------- |
319e41f4b71Sopenharmony_ci| slotId   | number                | 是   | 卡槽ID。<br />0:卡槽1。<br />1:卡槽2。 |
320e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | 是   | 以callback形式异步返回结果。                               |
321e41f4b71Sopenharmony_ci
322e41f4b71Sopenharmony_ci**错误码:**
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
327e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
328e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
329e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
330e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
331e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
332e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
333e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
334e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci**示例:**
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_ci```ts
339e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
340e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
341e41f4b71Sopenharmony_ci
342e41f4b71Sopenharmony_cidata.enableCellularDataRoaming(0, (err: BusinessError) => {
343e41f4b71Sopenharmony_ci    if(err){
344e41f4b71Sopenharmony_ci        console.error(`enableCellularDataRoaming fail,callback: err->${JSON.stringify(err)}`);
345e41f4b71Sopenharmony_ci    }else{
346e41f4b71Sopenharmony_ci        console.log(`enableCellularDataRoaming success`);
347e41f4b71Sopenharmony_ci    }
348e41f4b71Sopenharmony_ci});
349e41f4b71Sopenharmony_ci```
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ci## data.enableCellularDataRoaming
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_cienableCellularDataRoaming(slotId: number): Promise\<void\>
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci启用蜂窝数据漫游,使用Promise方式作为异步方法。
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
360e41f4b71Sopenharmony_ci
361e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CellularData
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_ci**参数:**
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                     |
366e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------------------- |
367e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br />0:卡槽1。<br />1:卡槽2。 |
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_ci**返回值:**
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ci| 类型            | 说明                      |
372e41f4b71Sopenharmony_ci| --------------- | ------------------------- |
373e41f4b71Sopenharmony_ci| Promise\<void\> | 以Promise形式返回启用结果 |
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci**错误码:**
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
380e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
381e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
382e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
383e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
384e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
385e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
386e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
387e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ci**示例:**
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_ci```ts
392e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
393e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_cidata.enableCellularDataRoaming(0).then(() => {
396e41f4b71Sopenharmony_ci    console.log(`enableCellularDataRoaming success.`);
397e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
398e41f4b71Sopenharmony_ci    console.error(`enableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`);
399e41f4b71Sopenharmony_ci});
400e41f4b71Sopenharmony_ci```
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ci## data.disableCellularDataRoaming
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_cidisableCellularDataRoaming(slotId: number, callback: AsyncCallback\<void\>): void
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci禁用蜂窝数据漫游,使用callback方式作为异步方法。
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CellularData
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci**参数:**
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci| 参数名   | 类型                  | 必填 | 说明                                     |
417e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------------------------------------- |
418e41f4b71Sopenharmony_ci| slotId   | number                | 是   | 卡槽ID。<br />0:卡槽1。<br />1:卡槽2。 |
419e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | 是   | 以callback形式异步返回结果。                               |
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci**错误码:**
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
426e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
427e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
428e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
429e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
430e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
431e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
432e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
433e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
434e41f4b71Sopenharmony_ci
435e41f4b71Sopenharmony_ci**示例:**
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci```ts
438e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
439e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_cidata.disableCellularDataRoaming(0, (err: BusinessError) => {
442e41f4b71Sopenharmony_ci    if(err){
443e41f4b71Sopenharmony_ci        console.error(`disableCellularDataRoaming fail,callback: err->${JSON.stringify(err)}`);
444e41f4b71Sopenharmony_ci    }else{
445e41f4b71Sopenharmony_ci        console.log(`disableCellularDataRoaming success`);
446e41f4b71Sopenharmony_ci    }
447e41f4b71Sopenharmony_ci});
448e41f4b71Sopenharmony_ci```
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci## data.disableCellularDataRoaming
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_cidisableCellularDataRoaming(slotId: number): Promise\<void\>
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci禁用蜂窝数据漫游,使用Promise方式作为异步方法。
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.SET_TELEPHONY_STATE
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Telephony.CellularData
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci**参数:**
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                     |
465e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------------------- |
466e41f4b71Sopenharmony_ci| slotId | number | 是   | 卡槽ID。<br />0:卡槽1。<br />1:卡槽2。 |
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci**返回值:**
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ci| 类型            | 说明                      |
471e41f4b71Sopenharmony_ci| --------------- | ------------------------- |
472e41f4b71Sopenharmony_ci| Promise\<void\> | 以Promise形式返回禁用结果 |
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci**错误码:**
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[ohos.telephony(电话子系统)错误码](errorcode-telephony.md)。
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ci| 错误码ID |                  错误信息                    |
479e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
480e41f4b71Sopenharmony_ci| 201      | Permission denied.                           |
481e41f4b71Sopenharmony_ci| 202      | Non-system applications use system APIs.     |
482e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.                             |
483e41f4b71Sopenharmony_ci| 8300001  | Invalid parameter value.                     |
484e41f4b71Sopenharmony_ci| 8300002  | Service connection failed.                   |
485e41f4b71Sopenharmony_ci| 8300003  | System internal error.                       |
486e41f4b71Sopenharmony_ci| 8300999  | Unknown error.                               |
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ci**示例:**
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci```ts
491e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit';
492e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_cidata.disableCellularDataRoaming(0).then(() => {
495e41f4b71Sopenharmony_ci    console.log(`disableCellularDataRoaming success.`);
496e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
497e41f4b71Sopenharmony_ci    console.error(`disableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`);
498e41f4b71Sopenharmony_ci});
499e41f4b71Sopenharmony_ci```
500