提交 37b60b37 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 3522b713
...@@ -66,25 +66,7 @@ To learn more about the APIs for obtaining device location information, see [Geo ...@@ -66,25 +66,7 @@ To learn more about the APIs for obtaining device location information, see [Geo
If your application needs to access the device location information when running on the background, it must be configured to be able to run on the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background. If your application needs to access the device location information when running on the background, it must be configured to be able to run on the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background.
To allow your application to access device location information, declare the required permissions in the **module.json** file of your application. The sample code is as follows: You can declare the required permission in your application's configuration file. For details, see [Access Control (Permission) Development](../security/accesstoken-guidelines.md).
```
{
"module": {
"reqPermissions": [
"name": "ohos.permission.LOCATION",
"reason": "$string:reason_description",
"usedScene": {
"ability": ["com.myapplication.LocationAbility"],
"when": "inuse"
}
]
}
}
```
For details about these fields, see [Application Package Structure Configuration File](../quick-start/stage-structure.md).
2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities. 2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities.
......
...@@ -120,12 +120,12 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -120,12 +120,12 @@ The following uses a one-time event watcher as an example to illustrate the deve
// Obtain the event package based on the configured size threshold. If returned event package is null, all event data has been obtained. // Obtain the event package based on the configured size threshold. If returned event package is null, all event data has been obtained.
while ((eventPkg = holder.takeNext()) != null) { while ((eventPkg = holder.takeNext()) != null) {
// Parse the obtained event package and display the result on the Log page. // Parse the obtained event package and display the result on the Log page.
console.info('HiAppEvent eventPkg.packageId=' + eventPkg.packageId); console.info(`HiAppEvent eventPkg.packageId=${eventPkg.packageId}`);
console.info('HiAppEvent eventPkg.row=' + eventPkg.row); console.info(`HiAppEvent eventPkg.row=${eventPkg.row}`);
console.info('HiAppEvent eventPkg.size=' + eventPkg.size); console.info(`HiAppEvent eventPkg.size=${eventPkg.size}`);
// Traverse and parse event string arrays in the obtained event package. // Traverse and parse event string arrays in the obtained event package.
for (const eventInfo of eventPkg.data) { for (const eventInfo of eventPkg.data) {
console.info('HiAppEvent eventPkg.data=' + eventInfo); console.info(`HiAppEvent eventPkg.data=${eventInfo}`);
} }
} }
} }
......
...@@ -403,7 +403,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. ...@@ -403,7 +403,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
**Example** **Example**
```js ```js
call.formatPhoneNumber("138xxxxxxxx",{ call.formatPhoneNumber("138xxxxxxxx", {
countryCode: "CN" countryCode: "CN"
}, (err, data) => { }, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -468,7 +468,7 @@ The phone number must match the specified country code. For example, for a China ...@@ -468,7 +468,7 @@ The phone number must match the specified country code. For example, for a China
**Example** **Example**
```js ```js
call.formatPhoneNumberToE164("138xxxxxxxx",{ call.formatPhoneNumberToE164("138xxxxxxxx", {
countryCode: "CN" countryCode: "CN"
}, (err, data) => { }, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -800,7 +800,7 @@ call.reject(rejectMessageOptions, (err, data) => { ...@@ -800,7 +800,7 @@ call.reject(rejectMessageOptions, (err, data) => {
## call.reject<sup>7+</sup> ## call.reject<sup>7+</sup>
reject(callId: number, callback: AsyncCallback<void\>): <void\> reject(callId: number, callback: AsyncCallback\<void>): void
Rejects a call based on the specified call ID. This API uses an asynchronous callback to return the result. Rejects a call based on the specified call ID. This API uses an asynchronous callback to return the result.
...@@ -815,20 +815,11 @@ This is a system API. ...@@ -815,20 +815,11 @@ This is a system API.
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.| | callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```js ```js
let promise = call.reject(1); call.reject(1, (err, data) => {
promise.then(data => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
console.log(`reject success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`reject fail, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1628,8 +1619,8 @@ This is a system API. ...@@ -1628,8 +1619,8 @@ This is a system API.
**Example** **Example**
```js ```js
call.on('callDetailsChange', (err, data) => { call.on('callDetailsChange', data => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1653,8 +1644,8 @@ This is a system API. ...@@ -1653,8 +1644,8 @@ This is a system API.
**Example** **Example**
```js ```js
call.on('callEventChange', (err, data) => { call.on('callEventChange', data => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1678,8 +1669,8 @@ This is a system API. ...@@ -1678,8 +1669,8 @@ This is a system API.
**Example** **Example**
```js ```js
call.on('callDisconnectedCause', (err, data) => { call.on('callDisconnectedCause', data => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1703,8 +1694,8 @@ This is a system API. ...@@ -1703,8 +1694,8 @@ This is a system API.
**Example** **Example**
```js ```js
isNewCallAllowedcall.on('mmiCodeResult', (err, data) => { call.on('mmiCodeResult', data => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1728,8 +1719,8 @@ This is a system API. ...@@ -1728,8 +1719,8 @@ This is a system API.
**Example** **Example**
```js ```js
call.off('callDetailsChange', (err, data) => { call.off('callDetailsChange', data => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1753,8 +1744,8 @@ This is a system API. ...@@ -1753,8 +1744,8 @@ This is a system API.
**Example** **Example**
```js ```js
call.off('callEventChange', (err, data) => { call.off('callEventChange', data => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1778,8 +1769,8 @@ This is a system API. ...@@ -1778,8 +1769,8 @@ This is a system API.
**Example** **Example**
```js ```js
call.off('callDisconnectedCause', (err, data) => { call.off('callDisconnectedCause', data => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1803,8 +1794,8 @@ This is a system API. ...@@ -1803,8 +1794,8 @@ This is a system API.
**Example** **Example**
```js ```js
call.off('mmiCodeResult', (err, data) => { call.off('mmiCodeResult', data => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -2399,7 +2390,7 @@ This is a system API. ...@@ -2399,7 +2390,7 @@ This is a system API.
let audioDeviceOptions={ let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014" bluetoothAddress: "IEEE 802-2014"
} }
call.setAudioDevice(1, bluetoothAddress, (err, value) => { call.setAudioDevice(1, audioDeviceOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
......
...@@ -304,16 +304,13 @@ hiAppEvent.addWatcher({ ...@@ -304,16 +304,13 @@ hiAppEvent.addWatcher({
console.error("holder is null"); console.error("holder is null");
return; return;
} }
while (true) { let eventPkg = null;
let eventPkg = holder.takeNext(); while ((eventPkg = holder.takeNext()) != null) {
if (eventPkg == null) { console.info(`eventPkg.packageId=${eventPkg.packageId}`);
return; console.info(`eventPkg.row=${eventPkg.row}`);
} console.info(`eventPkg.size=${eventPkg.size}`);
console.info("eventPkg.packageId=" + eventPkg.packageId);
console.info("eventPkg.row=" + eventPkg.row);
console.info("eventPkg.size=" + eventPkg.size);
for (const eventInfo of eventPkg.data) { for (const eventInfo of eventPkg.data) {
console.info("eventPkg.data=" + eventInfo); console.info(`eventPkg.data=${eventInfo}`);
} }
} }
} }
...@@ -324,15 +321,14 @@ let holder = hiAppEvent.addWatcher({ ...@@ -324,15 +321,14 @@ let holder = hiAppEvent.addWatcher({
name: "watcher2", name: "watcher2",
}); });
if (holder != null) { if (holder != null) {
let eventPkg = holder.takeNext(); let eventPkg = null;
if (eventPkg == null) { while ((eventPkg = holder.takeNext()) != null) {
return; console.info(`eventPkg.packageId=${eventPkg.packageId}`);
} console.info(`eventPkg.row=${eventPkg.row}`);
console.info("eventPkg.packageId=" + eventPkg.packageId); console.info(`eventPkg.size=${eventPkg.size}`);
console.info("eventPkg.row=" + eventPkg.row); for (const eventInfo of eventPkg.data) {
console.info("eventPkg.size=" + eventPkg.size); console.info(`eventPkg.data=${eventInfo}`);
for (const eventInfo of eventPkg.data) { }
console.info("eventPkg.data=" + eventInfo);
} }
} }
``` ```
......
...@@ -73,12 +73,15 @@ function listener(data) { ...@@ -73,12 +73,15 @@ function listener(data) {
console.log("type: " + data.type + ", deviceId: " + data.deviceId); console.log("type: " + data.type + ", deviceId: " + data.deviceId);
} }
// Enable the listener for listening to hot swap events of an input device.
inputDevice.on("change", listener);
// Disable this listener. // Disable this listener.
inputDevice.off("change", listener); inputDevice.off("change", listener);
// Disable all listeners. // Disable all listeners.
inputDevice.off("change"); inputDevice.off("change");
// By default, the soft keyboard is closed when listening is disabled. // By default, the soft keyboard is closed when all listeners are disabled.
``` ```
## inputDevice.getDeviceIds ## inputDevice.getDeviceIds
......
...@@ -16,7 +16,7 @@ import connection from '@ohos.net.connection' ...@@ -16,7 +16,7 @@ import connection from '@ohos.net.connection'
getDefaultNet(callback: AsyncCallback\<NetHandle>): void getDefaultNet(callback: AsyncCallback\<NetHandle>): void
Obtains the default active data network. This API uses an asynchronous callback to return the result. Obtains the default active data network. This API uses an asynchronous callback to return the result. You can use [getNetCapabilities](#connectiongetnetcapabilities) to obtain information such as the network type and capabilities.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
...@@ -41,13 +41,13 @@ connection.getDefaultNet(function (error, netHandle) { ...@@ -41,13 +41,13 @@ connection.getDefaultNet(function (error, netHandle) {
getDefaultNet(): Promise\<NetHandle> getDefaultNet(): Promise\<NetHandle>
Obtains the default active data network. This API uses a promise to return the result. Obtains the default active data network. This API uses a promise to return the result. You can use [getNetCapabilities](#connectiongetnetcapabilities) to obtain information such as the network type and capabilities.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Return Value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------- | ------------------------------------- | | --------------------------------- | ------------------------------------- |
...@@ -61,11 +61,34 @@ connection.getDefaultNet().then(function (netHandle) { ...@@ -61,11 +61,34 @@ connection.getDefaultNet().then(function (netHandle) {
}) })
``` ```
## connection.getDefaultNetSync
getDefaultNetSync(): NetHandle;
Obtains the default active data network in synchronous mode. You can use [getNetCapabilities](#connectiongetnetcapabilities) to obtain information such as the network type and capabilities.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Return value**
| Type | Description |
| --------- | ---------------------------------- |
| NetHandle | Handle of the default active data network.|
**Example**
```js
let netHandle = connection.getDefaultNetSync();
```
## connection.hasDefaultNet ## connection.hasDefaultNet
hasDefaultNet(callback: AsyncCallback\<boolean>): void hasDefaultNet(callback: AsyncCallback\<boolean>): void
Checks whether the default data network is activated. This API uses an asynchronous callback to return the result. Checks whether the default data network is activated. This API uses an asynchronous callback to return the result. You can use [getDefaultNet](#connectiongetdefaultnet) to obtain the default data network, if any.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
...@@ -90,13 +113,13 @@ connection.hasDefaultNet(function (error, has) { ...@@ -90,13 +113,13 @@ connection.hasDefaultNet(function (error, has) {
hasDefaultNet(): Promise\<boolean> hasDefaultNet(): Promise\<boolean>
Checks whether the default data network is activated. This API uses a promise to return the result. Checks whether the default data network is activated. This API uses a promise to return the result. You can use [getDefaultNet](#connectiongetdefaultnet) to obtain the default data network, if any.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ----------------------------------------------- | | ----------------- | ----------------------------------------------- |
...@@ -121,6 +144,7 @@ Obtains the list of all active data networks. This API uses an asynchronous call ...@@ -121,6 +144,7 @@ Obtains the list of all active data networks. This API uses an asynchronous call
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;[NetHandle](#nethandle)&gt;&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;Array&lt;[NetHandle](#nethandle)&gt;&gt; | Yes| Callback used to return the result.|
...@@ -145,7 +169,8 @@ Obtains the list of all active data networks. This API uses a promise to return ...@@ -145,7 +169,8 @@ Obtains the list of all active data networks. This API uses a promise to return
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Return Value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[NetHandle](#nethandle)&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;[NetHandle](#nethandle)&gt;&gt; | Promise used to return the result.|
...@@ -162,7 +187,7 @@ connection.getAllNets().then(function (nets) { ...@@ -162,7 +187,7 @@ connection.getAllNets().then(function (nets) {
getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<ConnectionProperties>): void getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<ConnectionProperties>): void
Obtains connection properties of the network corresponding to given network handle. This API uses an asynchronous callback to return the result. Obtains connection properties of the network corresponding to the given network handle. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permission**: ohos.permission.GET_NETWORK_INFO
...@@ -202,7 +227,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi ...@@ -202,7 +227,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi
| --------- | ----------------------- | ---- | ---------------- | | --------- | ----------------------- | ---- | ---------------- |
| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| | netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------------------- | --------------------------------- | | ------------------------------------------------------- | --------------------------------- |
...@@ -262,7 +287,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th ...@@ -262,7 +287,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th
| --------- | ----------------------- | ---- | ---------------- | | --------- | ----------------------- | ---- | ---------------- |
| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| | netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------------- | --------------------------------- | | --------------------------------------------- | --------------------------------- |
...@@ -289,6 +314,7 @@ Reports connection of the data network. This API uses an asynchronous callback t ...@@ -289,6 +314,7 @@ Reports connection of the data network. This API uses an asynchronous callback t
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).|
...@@ -316,11 +342,13 @@ Reports connection of the data network. This API uses a promise to return the re ...@@ -316,11 +342,13 @@ Reports connection of the data network. This API uses a promise to return the re
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).|
**Return Value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
...@@ -347,6 +375,7 @@ Reports disconnection of the data network. This API uses an asynchronous callbac ...@@ -347,6 +375,7 @@ Reports disconnection of the data network. This API uses an asynchronous callbac
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).|
...@@ -374,11 +403,13 @@ Reports disconnection of the data network. This API uses a promise to return the ...@@ -374,11 +403,13 @@ Reports disconnection of the data network. This API uses a promise to return the
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).|
**Return Value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
...@@ -436,7 +467,7 @@ Resolves the host name by using the default network to obtain all IP addresses. ...@@ -436,7 +467,7 @@ Resolves the host name by using the default network to obtain all IP addresses.
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| host | string | Yes | Host name to be resolved.| | host | string | Yes | Host name to be resolved.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------- | ----------------------------- | | ------------------------------------------- | ----------------------------- |
...@@ -565,7 +596,7 @@ Obtains the handle of the network specified by **netSpecifier**. ...@@ -565,7 +596,7 @@ Obtains the handle of the network specified by **netSpecifier**.
| netSpecifier | [NetSpecifier](#netspecifier) | No | Network specifier. If this parameter is not set, the default network is used. | | netSpecifier | [NetSpecifier](#netspecifier) | No | Network specifier. If this parameter is not set, the default network is used. |
| timeout | number | No | Timeout interval for obtaining the network specified by **netSpecifier**. This parameter is valid only when **netSpecifier** is set.| | timeout | number | No | Timeout interval for obtaining the network specified by **netSpecifier**. This parameter is valid only when **netSpecifier** is set.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------- | -------------------- | | ------------------------------- | -------------------- |
...@@ -788,6 +819,108 @@ Before invoking NetHandle APIs, call **getNetHandle** to obtain a **NetHandle** ...@@ -788,6 +819,108 @@ Before invoking NetHandle APIs, call **getNetHandle** to obtain a **NetHandle**
| ------ | ------ | ------------------------- | | ------ | ------ | ------------------------- |
| netId | number | Network ID. The value must be greater than or equal to 100.| | netId | number | Network ID. The value must be greater than or equal to 100.|
### bindSocket
bindSocket(socketParam: TCPSocket \| UDPSocket, callback: AsyncCallback\<void>): void;
Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------------------------ | ---- | -------------------------------|
| socketParam | [TCPSocket](js-apis-socket.md#tcpsocket) \| [UDPSocket](js-apis-socket.md#udpsocket) | Yes| **TCPSocket** or **UDPSocket** object.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```js
connection.getDefaultNet().then(function (netHandle) {
var tcp = socket.constructTCPSocketInstance();
var udp = socket.constructUDPSocketInstance();
let socketType = "xxxx";
if (socketType == "TCPSocket") {
tcp.bind({
address: "xxxx", port: xxxx, family: xxxx
}, err => {
netHandle.bindSocket(tcp, function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
} else {
udp.on('message', callback);
udp.bind({
address: "xxxx", port: xxxx, family: xxxx
}, err => {
udp.on('message', (data) => {
console.log(JSON.stringify(data))
});
netHandle.bindSocket(udp, function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
});
})
}
}
```
### bindSocket
bindSocket(socketParam: TCPSocket \| UDPSocket): Promise\<void>;
Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------------- | --------------------- | ---- | ------------------------------ |
| socketParam | [TCPSocket](js-apis-socket.md#tcpsocket) \| [UDPSocket](js-apis-socket.md#udpsocket) | Yes | **TCPSocket** or **UDPSocket** object.|
**Return value**
| Type | Description |
| -------------- | ---------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
connection.getDefaultNet().then(function (netHandle) {
var tcp = socket.constructTCPSocketInstance();
var udp = socket.constructUDPSocketInstance();
let socketType = "xxxx";
if(socketType == "TCPSocket") {
tcp.bind({
address: "xxxx", port: xxxx, family: xxxx
}, err => {
netHandle.bindSocket(tcp).then(err, data) {
console.log(JSON.stringify(data))
})
} else {
udp.on('message', callback);
udp.bind({
address: "xxxx", port: xxxx, family: xxxx
}, err => {
udp.on('message', (data) => {
console.log(JSON.stringify(data))
});
netHandle.bindSocket(tcp).then(err, data) {
console.log(JSON.stringify(data))
});
})
}
}
```
### getAddressesByName ### getAddressesByName
getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>): void getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>): void
...@@ -833,7 +966,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre ...@@ -833,7 +966,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| host | string | Yes | Host name to be resolved.| | host | string | Yes | Host name to be resolved.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------- | ----------------------------- | | ------------------------------------------- | ----------------------------- |
...@@ -895,7 +1028,7 @@ Resolves the host name by using the corresponding network to obtain the first IP ...@@ -895,7 +1028,7 @@ Resolves the host name by using the corresponding network to obtain the first IP
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| host | string | Yes | Host name to be resolved.| | host | string | Yes | Host name to be resolved.|
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------------- | ------------------------------- | | ----------------------------------- | ------------------------------- |
......
...@@ -403,7 +403,7 @@ Checks whether the current device supports 5G \(NR\). ...@@ -403,7 +403,7 @@ Checks whether the current device supports 5G \(NR\).
```js ```js
let result = radio.isNrSupported(); let result = radio.isNrSupported();
console.log("Result: "+ result); console.log("Result: "+ result);
`` ```
## radio.isNrSupported<sup>8+</sup> ## radio.isNrSupported<sup>8+</sup>
...@@ -1121,12 +1121,12 @@ Sets the network selection mode. This API uses an asynchronous callback to retur ...@@ -1121,12 +1121,12 @@ Sets the network selection mode. This API uses an asynchronous callback to retur
let networkInformation={ let networkInformation={
operatorName: "China Mobile", operatorName: "China Mobile",
operatorNumeric: "898600", operatorNumeric: "898600",
state: 1, state: radio.NetworkInformationState.NETWORK_AVAILABLE,
radioTech: "CS" radioTech: "CS"
} }
let networkSelectionModeOptions={ let networkSelectionModeOptions={
slotid: 0, slotId: 0,
selectMode: 1, selectMode: radio.NetworkSelectionMode.NETWORK_SELECTION_AUTOMATIC,
networkInformation: networkInformation, networkInformation: networkInformation,
resumeSelection: true resumeSelection: true
} }
...@@ -1165,12 +1165,12 @@ Sets the network selection mode. This API uses a promise to return the result. ...@@ -1165,12 +1165,12 @@ Sets the network selection mode. This API uses a promise to return the result.
let networkInformation={ let networkInformation={
operatorName: "China Mobile", operatorName: "China Mobile",
operatorNumeric: "898600", operatorNumeric: "898600",
state: 1, state: radio.NetworkInformationState.NETWORK_AVAILABLE,
radioTech: "CS" radioTech: "CS"
} }
let networkSelectionModeOptions={ let networkSelectionModeOptions={
slotid: 0, slotId: 0,
selectMode: 1, selectMode: radio.NetworkSelectionMode.NETWORK_SELECTION_AUTOMATIC,
networkInformation: networkInformation, networkInformation: networkInformation,
resumeSelection: true resumeSelection: true
} }
...@@ -1211,7 +1211,7 @@ radio.getNetworkSearchInformation(0, (err, data) => { ...@@ -1211,7 +1211,7 @@ radio.getNetworkSearchInformation(0, (err, data) => {
## radio.getNetworkSearchInformation ## radio.getNetworkSearchInformation
getNetworkSearchInformation\(slotId: number\): Promise<void\> getNetworkSearchInformation\(slotId: number\): Promise<NetworkSearchResult\>
Obtains network search information for the SIM card in the specified slot. This API uses a promise to return the result. Obtains network search information for the SIM card in the specified slot. This API uses a promise to return the result.
...@@ -1607,7 +1607,7 @@ radio.getPreferredNetwork(0, (err, data) => { ...@@ -1607,7 +1607,7 @@ radio.getPreferredNetwork(0, (err, data) => {
## radio.getPreferredNetwork<sup>8+</sup> ## radio.getPreferredNetwork<sup>8+</sup>
getPreferredNetwork(slotId: number): Promise<void\> getPreferredNetwork(slotId: number): Promise<PreferredNetworkMode\>
Obtains the preferred network for the SIM card in the specified slot. This API uses a promise to return the result. Obtains the preferred network for the SIM card in the specified slot. This API uses a promise to return the result.
...@@ -1663,7 +1663,7 @@ Obtains the IMS registration status of the specified IMS service type for the SI ...@@ -1663,7 +1663,7 @@ Obtains the IMS registration status of the specified IMS service type for the SI
**Example** **Example**
```js ```js
radio.getImsRegInfo(0, 1, (err, data) => { radio.getImsRegInfo(0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1696,7 +1696,7 @@ Obtains the IMS registration status of the specified IMS service type for the SI ...@@ -1696,7 +1696,7 @@ Obtains the IMS registration status of the specified IMS service type for the SI
**Example** **Example**
```js ```js
let promise = radio.getImsRegInfo(0, 1); let promise = radio.getImsRegInfo(0, radio.ImsServiceType.TYPE_VIDEO);
promise.then(data => { promise.then(data => {
console.log(`getImsRegInfo success, promise: data->${JSON.stringify(data)}`); console.log(`getImsRegInfo success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -1728,7 +1728,7 @@ Enables listening for **imsRegStateChange** events for the SIM card in the speci ...@@ -1728,7 +1728,7 @@ Enables listening for **imsRegStateChange** events for the SIM card in the speci
**Example** **Example**
```js ```js
radio.on('imsRegStateChange', 0, 1, (err, data) => { radio.on('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1757,7 +1757,7 @@ Disables listening for **imsRegStateChange** events for the SIM card in the spec ...@@ -1757,7 +1757,7 @@ Disables listening for **imsRegStateChange** events for the SIM card in the spec
**Example** **Example**
```js ```js
radio.off('imsRegStateChange', 0, 1, (err, data) => { radio.off('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1840,10 +1840,10 @@ Defines the network status. ...@@ -1840,10 +1840,10 @@ Defines the network status.
| Name | Value | Description | | Name | Value | Description |
| ----------------------------- | ---- | -------------------------- | | ----------------------------- | ---- | -------------------------- |
| REG_STATE_NO_SERVICE | 0 | The device cannot use any service. | | REG_STATE_NO_SERVICE | 0 | The device cannot use any services, including data, SMS, and call services. |
| REG_STATE_IN_SERVICE | 1 | The device can use services normally. | | REG_STATE_IN_SERVICE | 1 | The device can use services properly, including data, SMS, and call services. |
| REG_STATE_EMERGENCY_CALL_ONLY | 2 | The device can use only the emergency call service.| | REG_STATE_EMERGENCY_CALL_ONLY | 2 | The device can use only the emergency call service. |
| REG_STATE_POWER_OFF | 3 | The cellular radio service is disabled. | | REG_STATE_POWER_OFF | 3 | The device cannot communicate with the network because the cellular radio service is disabled or the modem is powered off. |
## NsaState ## NsaState
......
...@@ -589,7 +589,7 @@ Obtains the account information list of the active SIM card. This API uses an as ...@@ -589,7 +589,7 @@ Obtains the account information list of the active SIM card. This API uses an as
**Example** **Example**
```js ```js
sim.getActiveSimAccountInfoList(0, (err, data) => { sim.getActiveSimAccountInfoList((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -689,7 +689,7 @@ promise.then(data => { ...@@ -689,7 +689,7 @@ promise.then(data => {
## sim.**setShowName**<sup>8+</sup> ## sim.**setShowName**<sup>8+</sup>
setShowName\(slotId: number, name: string,callback: AsyncCallback<void\>\): void setShowName\(slotId: number, name: string, callback: AsyncCallback<void\>\): void
Sets a display name for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Sets a display name for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
...@@ -710,7 +710,7 @@ Sets a display name for the SIM card in the specified slot. This API uses an asy ...@@ -710,7 +710,7 @@ Sets a display name for the SIM card in the specified slot. This API uses an asy
**Example** **Example**
```js ```js
const name='China Mobile'; let name = "ShowName";
sim.setShowName(0, name, (err, data) => { sim.setShowName(0, name, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -744,7 +744,7 @@ Sets a display name for the SIM card in the specified slot. This API uses a prom ...@@ -744,7 +744,7 @@ Sets a display name for the SIM card in the specified slot. This API uses a prom
**Example** **Example**
```js ```js
const name='China Mobile'; let name = "ShowName";
let promise = sim.setShowName(0, name); let promise = sim.setShowName(0, name);
promise.then(data => { promise.then(data => {
console.log(`setShowName success, promise: data->${JSON.stringify(data)}`); console.log(`setShowName success, promise: data->${JSON.stringify(data)}`);
...@@ -818,7 +818,7 @@ promise.then(data => { ...@@ -818,7 +818,7 @@ promise.then(data => {
## sim.**setShowNumber**<sup>8+</sup> ## sim.**setShowNumber**<sup>8+</sup>
setShowNumber\(slotId: number, number: string,callback: AsyncCallback<void\>\): void setShowNumber\(slotId: number, number: string, callback: AsyncCallback<void\>\): void
Sets a display number for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Sets a display number for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
...@@ -848,7 +848,7 @@ sim.setShowNumber(0, number, (err, data) => { ...@@ -848,7 +848,7 @@ sim.setShowNumber(0, number, (err, data) => {
## sim.**setShowNumber**<sup>8+</sup> ## sim.**setShowNumber**<sup>8+</sup>
setShowNumber\(slotId: number,number: string\): Promise\<void\> setShowNumber\(slotId: number, number: string\): Promise\<void\>
Sets a display number for the SIM card in the specified slot. This API uses a promise to return the result. Sets a display number for the SIM card in the specified slot. This API uses a promise to return the result.
...@@ -885,7 +885,7 @@ promise.then(data => { ...@@ -885,7 +885,7 @@ promise.then(data => {
## sim.**getShowNumber**<sup>8+</sup> ## sim.**getShowNumber**<sup>8+</sup>
getShowNumber(slotId: number,callback: AsyncCallback<string\>): void getShowNumber(slotId: number, callback: AsyncCallback<string\>): void
Obtains the display number of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Obtains the display number of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
...@@ -1096,9 +1096,9 @@ Sets the lock status of the SIM card in the specified slot. This API uses an asy ...@@ -1096,9 +1096,9 @@ Sets the lock status of the SIM card in the specified slot. This API uses an asy
```js ```js
let lockInfo = { let lockInfo = {
lockType = 1, lockType: sim.LockType.PIN_LOCK,
password = "1234", password: "1234",
state = 0 state: sim.LockState.LOCK_OFF
}; };
sim.setLockState(0, lockInfo, (err, data) => { sim.setLockState(0, lockInfo, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -1135,9 +1135,9 @@ Sets the lock status of the SIM card in the specified slot. This API uses a prom ...@@ -1135,9 +1135,9 @@ Sets the lock status of the SIM card in the specified slot. This API uses a prom
```js ```js
let lockInfo = { let lockInfo = {
lockType = 1, lockType: sim.LockType.PIN_LOCK,
password = "1234", password: "1234",
state = 0 state: sim.LockState.LOCK_OFF
}; };
let promise = sim.setLockState(0, lockInfo); let promise = sim.setLockState(0, lockInfo);
promise.then(data => { promise.then(data => {
...@@ -1344,7 +1344,7 @@ promise.then(data => { ...@@ -1344,7 +1344,7 @@ promise.then(data => {
## sim.**unlockPin**<sup>7+</sup> ## sim.**unlockPin**<sup>7+</sup>
unlockPin(slotId: number,pin: string ,callback: AsyncCallback<LockStatusResponse\>): void unlockPin(slotId: number, pin: string, callback: AsyncCallback<LockStatusResponse\>): void
Unlocks PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Unlocks PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
...@@ -1374,7 +1374,7 @@ sim.unlockPin(0, pin, (err, data) => { ...@@ -1374,7 +1374,7 @@ sim.unlockPin(0, pin, (err, data) => {
## sim.**unlockPin**<sup>7+</sup> ## sim.**unlockPin**<sup>7+</sup>
unlockPin(slotId: number,pin: string): Promise&lt;LockStatusResponse\> unlockPin(slotId: number, pin: string): Promise&lt;LockStatusResponse\>
Unlocks the PIN of the SIM card in the specified slot. This API uses a promise to return the result. Unlocks the PIN of the SIM card in the specified slot. This API uses a promise to return the result.
...@@ -1411,7 +1411,7 @@ promise.then(data => { ...@@ -1411,7 +1411,7 @@ promise.then(data => {
## sim.**unlockPuk**<sup>7+</sup> ## sim.**unlockPuk**<sup>7+</sup>
unlockPuk(slotId: number,newPin: string,puk: string ,callback: AsyncCallback<LockStatusResponse\>): void unlockPuk(slotId: number, newPin: string, puk: string ,callback: AsyncCallback<LockStatusResponse\>): void
Unlocks the PUK of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Unlocks the PUK of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
...@@ -1443,7 +1443,7 @@ sim.unlockPuk(0, newPin, puk, (err, data) => { ...@@ -1443,7 +1443,7 @@ sim.unlockPuk(0, newPin, puk, (err, data) => {
## sim.**unlockPuk**<sup>7+</sup> ## sim.**unlockPuk**<sup>7+</sup>
unlockPuk(slotId: number,newPin: string,puk: string): Promise&lt;LockStatusResponse\> unlockPuk(slotId: number, newPin: string, puk: string): Promise&lt;LockStatusResponse\>
Unlocks the PUK of the SIM card in the specified slot. This API uses a promise to return the result. Unlocks the PUK of the SIM card in the specified slot. This API uses a promise to return the result.
...@@ -1482,7 +1482,7 @@ promise.then(data => { ...@@ -1482,7 +1482,7 @@ promise.then(data => {
## sim.**unlockPin**2<sup>8+</sup> ## sim.**unlockPin**2<sup>8+</sup>
unlockPin2(slotId: number,pin2: string ,callback: AsyncCallback<LockStatusResponse\>): void unlockPin2(slotId: number, pin2: string, callback: AsyncCallback<LockStatusResponse\>): void
Unlocks PIN 2 of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Unlocks PIN 2 of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
...@@ -1512,7 +1512,7 @@ sim.unlockPin2(0, pin2, (err, data) => { ...@@ -1512,7 +1512,7 @@ sim.unlockPin2(0, pin2, (err, data) => {
## sim.**unlockPin**2<sup>8+</sup> ## sim.**unlockPin**2<sup>8+</sup>
unlockPin2(slotId: number,pin2: string): Promise&lt;LockStatusResponse\> unlockPin2(slotId: number, pin2: string): Promise&lt;LockStatusResponse\>
Unlocks PIN 2 of the SIM card in the specified slot. This API uses a promise to return the result. Unlocks PIN 2 of the SIM card in the specified slot. This API uses a promise to return the result.
...@@ -1539,7 +1539,7 @@ Unlocks PIN 2 of the SIM card in the specified slot. This API uses a promise to ...@@ -1539,7 +1539,7 @@ Unlocks PIN 2 of the SIM card in the specified slot. This API uses a promise to
```js ```js
let pin2='1234'; let pin2='1234';
let promise = sim.unlockPin2(0,pin2); let promise = sim.unlockPin2(0, pin2);
promise.then(data => { promise.then(data => {
console.log(`unlockPin2 success, promise: data->${JSON.stringify(data)}`); console.log(`unlockPin2 success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -1851,7 +1851,7 @@ Sets voice mailbox information for the SIM card in the specified slot. This API ...@@ -1851,7 +1851,7 @@ Sets voice mailbox information for the SIM card in the specified slot. This API
**Example** **Example**
```js ```js
sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com" , (err, data) => { sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -2236,12 +2236,12 @@ Adds contact numbers for the SIM card in the specified slot. This API uses an as ...@@ -2236,12 +2236,12 @@ Adds contact numbers for the SIM card in the specified slot. This API uses an as
```js ```js
let diallingNumbersInof = { let diallingNumbersInof = {
alphaTag = "alpha", alphaTag: "alpha",
number = "138xxxxxxxx", number: "138xxxxxxxx",
recordNumber = 123, recordNumber: 123,
pin2 = "1234" pin2: "1234"
}; };
sim.addIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -2277,12 +2277,12 @@ Adds contact numbers for the SIM card in the specified slot. This API uses a pro ...@@ -2277,12 +2277,12 @@ Adds contact numbers for the SIM card in the specified slot. This API uses a pro
```js ```js
let diallingNumbersInof = { let diallingNumbersInof = {
alphaTag = "alpha", alphaTag: "alpha",
number = "138xxxxxxxx", number: "138xxxxxxxx",
recordNumber = 123, recordNumber: 123,
pin2 = "1234" pin2: "1234"
}; };
let promise = sim.addIccDiallingNumbers(0, 1, diallingNumbersInof); let promise = sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
promise.then(data => { promise.then(data => {
console.log(`addIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); console.log(`addIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -2315,12 +2315,12 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a ...@@ -2315,12 +2315,12 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a
```js ```js
let diallingNumbersInof = { let diallingNumbersInof = {
alphaTag = "alpha", alphaTag: "alpha",
number = "138xxxxxxxx", number: "138xxxxxxxx",
recordNumber = 123, recordNumber: 123,
pin2 = "1234" pin2: "1234"
}; };
sim.delIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -2356,12 +2356,12 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a ...@@ -2356,12 +2356,12 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a
```js ```js
let diallingNumbersInof = { let diallingNumbersInof = {
alphaTag = "alpha", alphaTag: "alpha",
number = "138xxxxxxxx", number: "138xxxxxxxx",
recordNumber = 123, recordNumber: 123,
pin2 = "1234" pin2: "1234"
}; };
let promise = sim.delIccDiallingNumbers(0, 1, diallingNumbersInof); let promise = sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
promise.then(data => { promise.then(data => {
console.log(`delIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); console.log(`delIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -2394,12 +2394,12 @@ Updates contact numbers for the SIM card in the specified slot. This API uses an ...@@ -2394,12 +2394,12 @@ Updates contact numbers for the SIM card in the specified slot. This API uses an
```js ```js
let diallingNumbersInof = { let diallingNumbersInof = {
alphaTag = "alpha", alphaTag: "alpha",
number = "138xxxxxxxx", number: "138xxxxxxxx",
recordNumber = 123, recordNumber: 123,
pin2 = "1234" pin2: "1234"
}; };
sim.updateIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -2435,12 +2435,12 @@ Updates contact numbers for the SIM card in the specified slot. This API uses a ...@@ -2435,12 +2435,12 @@ Updates contact numbers for the SIM card in the specified slot. This API uses a
```js ```js
let diallingNumbersInof = { let diallingNumbersInof = {
alphaTag = "alpha", alphaTag: "alpha",
number = "138xxxxxxxx", number: "138xxxxxxxx",
recordNumber = 123, recordNumber: 123,
pin2 = "1234" pin2: "1234"
}; };
let promise = sim.updateIccDiallingNumbers(0, 1, diallingNumbersInof); let promise = sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
promise.then(data => { promise.then(data => {
console.log(`updateIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); console.log(`updateIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -2602,8 +2602,8 @@ Unlocks the SIM card in the specified slot. This API uses an asynchronous callba ...@@ -2602,8 +2602,8 @@ Unlocks the SIM card in the specified slot. This API uses an asynchronous callba
```js ```js
let persoLockInfo = { let persoLockInfo = {
lockType = 0, lockType: sim.PersoLockType.PN_PIN_LOCK,
password = "1234" password: "1234"
}; };
sim.unlockSimLock(0, persoLockInfo, (err, data) => { sim.unlockSimLock(0, persoLockInfo, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -2640,8 +2640,8 @@ Unlocks the SIM card in the specified slot. This API uses a promise to return th ...@@ -2640,8 +2640,8 @@ Unlocks the SIM card in the specified slot. This API uses a promise to return th
```js ```js
let persoLockInfo = { let persoLockInfo = {
lockType = 0, lockType: sim.PersoLockType.PN_PIN_LOCK,
password = "1234" password: "1234"
}; };
let promise = sim.unlockSimLock(0, persoLockInfo); let promise = sim.unlockSimLock(0, persoLockInfo);
promise.then(data => { promise.then(data => {
...@@ -2657,6 +2657,8 @@ getOpKey(slotId: number, callback: AsyncCallback<string\>): void ...@@ -2657,6 +2657,8 @@ getOpKey(slotId: number, callback: AsyncCallback<string\>): void
Obtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Obtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
**Parameters** **Parameters**
......
...@@ -160,7 +160,7 @@ promise.then(data => { ...@@ -160,7 +160,7 @@ promise.then(data => {
## sms.setDefaultSmsSlotId<sup>7+</sup> ## sms.setDefaultSmsSlotId<sup>7+</sup>
setDefaultSmsSlotId\(slotId: number,callback: AsyncCallback&lt;void&gt;\): void setDefaultSmsSlotId\(slotId: number, callback: AsyncCallback&lt;void&gt;\): void
Sets the default slot of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result. Sets the default slot of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
...@@ -180,7 +180,7 @@ Sets the default slot of the SIM card used to send SMS messages. This API uses a ...@@ -180,7 +180,7 @@ Sets the default slot of the SIM card used to send SMS messages. This API uses a
**Example** **Example**
```js ```js
sms.setDefaultSmsSlotId(0,(err, data) => { sms.setDefaultSmsSlotId(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -397,7 +397,7 @@ Splits an SMS message into multiple segments. This API uses an asynchronous call ...@@ -397,7 +397,7 @@ Splits an SMS message into multiple segments. This API uses an asynchronous call
**Example** **Example**
```js ```js
string content= "long message"; let content = "long message";
sms.splitMessage(content, (err, data) => { sms.splitMessage(content, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -431,7 +431,7 @@ Splits an SMS message into multiple segments. This API uses a promise to return ...@@ -431,7 +431,7 @@ Splits an SMS message into multiple segments. This API uses a promise to return
**Example** **Example**
```js ```js
string content = "long message"; let content = "long message";
let promise = sms.splitMessage(content); let promise = sms.splitMessage(content);
promise.then(data => { promise.then(data => {
console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`); console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`);
...@@ -463,10 +463,10 @@ Adds a SIM message. This API uses an asynchronous callback to return the result. ...@@ -463,10 +463,10 @@ Adds a SIM message. This API uses an asynchronous callback to return the result.
```js ```js
let simMessageOptions = { let simMessageOptions = {
slotId = 0, slotId: 0,
smsc = "test", smsc: "test",
pdu = "xxxxxx", pdu: "xxxxxx",
status = 0 status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
}; };
sms.addSimMessage(simMessageOptions, (err, data) => { sms.addSimMessage(simMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -502,10 +502,10 @@ Adds a SIM message. This API uses a promise to return the result. ...@@ -502,10 +502,10 @@ Adds a SIM message. This API uses a promise to return the result.
```js ```js
let simMessageOptions = { let simMessageOptions = {
slotId = 0, slotId: 0,
smsc = "test", smsc: "test",
pdu = "xxxxxx", pdu: "xxxxxx",
status = 0 status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
}; };
let promise = sms.addSimMessage(simMessageOptions); let promise = sms.addSimMessage(simMessageOptions);
promise.then(data => { promise.then(data => {
...@@ -607,11 +607,11 @@ Updates a SIM message. This API uses an asynchronous callback to return the resu ...@@ -607,11 +607,11 @@ Updates a SIM message. This API uses an asynchronous callback to return the resu
```js ```js
let updateSimMessageOptions = { let updateSimMessageOptions = {
slotId = 0, slotId: 0,
msgIndex = 1, msgIndex: 1,
newStatus = 0, newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
pdu = "xxxxxxx", pdu: "xxxxxxx",
smsc = "test" smsc: "test"
}; };
sms.updateSimMessage(updateSimMessageOptions, (err, data) => { sms.updateSimMessage(updateSimMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -647,11 +647,11 @@ Updates a SIM message. This API uses a promise to return the result. ...@@ -647,11 +647,11 @@ Updates a SIM message. This API uses a promise to return the result.
```js ```js
let updateSimMessageOptions = { let updateSimMessageOptions = {
slotId = 0, slotId: 0,
msgIndex = 1, msgIndex: 1,
newStatus = 0, newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
pdu = "xxxxxxx", pdu: "xxxxxxx",
smsc = "test" smsc: "test"
}; };
let promise = sms.updateSimMessage(updateSimMessageOptions); let promise = sms.updateSimMessage(updateSimMessageOptions);
promise.then(data => { promise.then(data => {
...@@ -749,10 +749,11 @@ Sets the cell broadcast configuration. This API uses an asynchronous callback to ...@@ -749,10 +749,11 @@ Sets the cell broadcast configuration. This API uses an asynchronous callback to
```js ```js
let cbConfigOptions = { let cbConfigOptions = {
slotId = 0, slotId: 0,
smsc = "test", enable: true,
pdu = "xxxxxxxx", startMessageId: 100,
status = 0 endMessageId: 200,
ranType: sms.RanType.TYPE_GSM
}; };
sms.setCBConfig(cbConfigOptions, (err, data) => { sms.setCBConfig(cbConfigOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -788,13 +789,14 @@ Sets the cell broadcast configuration. This API uses a promise to return the res ...@@ -788,13 +789,14 @@ Sets the cell broadcast configuration. This API uses a promise to return the res
```js ```js
let cbConfigOptions = { let cbConfigOptions = {
slotId = 0, slotId: 0,
smsc = "test", enable: true,
pdu = "xxxxxxxx", startMessageId: 100,
status = 0 endMessageId: 200,
ranType: sms.RanType.TYPE_GSM
}; };
let promise = sms.setCBConfig(cbConfigOptions); let promise = sms.setCBConfig(cbConfigOptions);
promise.then(data => promise.then(data => {
console.log(`setCBConfig success, promise: data->${JSON.stringify(data)}`); console.log(`setCBConfig success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`); console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`);
...@@ -859,7 +861,7 @@ Obtains SMS message segment information. This API uses a promise to return the r ...@@ -859,7 +861,7 @@ Obtains SMS message segment information. This API uses a promise to return the r
```js ```js
let slotId = 0; let slotId = 0;
let promise = sms.getSmsSegmentsInfo(slotId, "message", false); let promise = sms.getSmsSegmentsInfo(slotId, "message", false);
promise.then(data => promise.then(data => {
console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`); console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`); console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`);
...@@ -886,7 +888,7 @@ Checks whether SMS is supported on IMS. This API uses an asynchronous callback t ...@@ -886,7 +888,7 @@ Checks whether SMS is supported on IMS. This API uses an asynchronous callback t
```js ```js
sms.isImsSmsSupported((err, data) => { sms.isImsSmsSupported((err, data) => {
console.log(`callback: err->${JSON.(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1023,7 +1025,7 @@ Decodes MMS messages. This API uses a promise to return the result. ...@@ -1023,7 +1025,7 @@ Decodes MMS messages. This API uses a promise to return the result.
```js ```js
let mmsFilePathName = "filename"; let mmsFilePathName = "filename";
let promise = sms.getSmscAddr(mmsFilePathName); let promise = sms.decodeMms(mmsFilePathName);
promise.then(data => { promise.then(data => {
console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`); console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -1052,13 +1054,13 @@ Encodes MMS messages. This API uses an asynchronous callback to return the resul ...@@ -1052,13 +1054,13 @@ Encodes MMS messages. This API uses an asynchronous callback to return the resul
```js ```js
let mmsAcknowledgeInd = { let mmsAcknowledgeInd = {
transactionId = "100", transactionId: "100",
version = 0x10, version: sms.MmsVersionType.MMS_VERSION_1_0,
reportAllowed = 128 reportAllowed: sms.ReportType.MMS_YES
}; };
let mmsInformation = { let mmsInformation = {
messageType = 133, messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
mmsType = mmsAcknowledgeInd mmsType: mmsAcknowledgeInd
}; };
sms.encodeMms(mmsInformation, (err, data) => { sms.encodeMms(mmsInformation, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -1092,13 +1094,13 @@ Encodes MMS messages. This API uses a promise to return the result. ...@@ -1092,13 +1094,13 @@ Encodes MMS messages. This API uses a promise to return the result.
```js ```js
let mmsAcknowledgeInd = { let mmsAcknowledgeInd = {
transactionId = "100", transactionId: "100",
version = 0x10, version: sms.MmsVersionType.MMS_VERSION_1_0,
reportAllowed = 128 reportAllowed: sms.ReportType.MMS_YES
}; };
let mmsInformation = { let mmsInformation = {
messageType = 133, messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
mmsType = mmsAcknowledgeInd mmsType: mmsAcknowledgeInd
}; };
let promise = sms.encodeMms(mmsInformation); let promise = sms.encodeMms(mmsInformation);
promise.then(data => { promise.then(data => {
......
...@@ -63,56 +63,56 @@ promise.then((data) => { ...@@ -63,56 +63,56 @@ promise.then((data) => {
}); });
``` ```
## data.setDefaultCellularDataSlotId ## data.getDefaultCellularDataSlotIdSync
setDefaultCellularDataSlotId(slotId: number,callback: AsyncCallback\<void\>): void
Sets the default slot of the SIM card used for mobile data. This API uses an asynchronous callback to return the result. getDefaultCellularDataSlotIdSync(): number
This is a system API. Obtains the default SIM card used for mobile data synchronously.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE **Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
**Parameters** **Return value**
| Name | Type | Mandatory| Description | | Type | Description |
| -------- | --------------------- | ---- | ------------------------------------------------------------ | | ------ | -------------------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration| | number | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
data.setDefaultCellularDataSlotId(0,(err, data) => { console.log("Result: "+ data.getDefaultCellularDataSlotIdSync())
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
``` ```
## data.getDefaultCellularDataSlotIdSync
getDefaultCellularDataSlotIdSync(): number ## data.setDefaultCellularDataSlotId
Obtains the default SIM card used for mobile data. setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\<void\>): void
**Required permission**: ohos.permission.GET_NETWORK_INFO Sets the default slot of the SIM card used for mobile data. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CellularData **System capability**: SystemCapability.Telephony.CellularData
**Return value** **Parameters**
| Type | Description | | Name | Type | Mandatory| Description |
| ------ | -------------------------------------------------- | | -------- | --------------------- | ---- | ------------------------------------------------------------ |
| number | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2 | | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
console.log("Result: "+ data.getDefaultCellularDataSlotIdSync()) data.setDefaultCellularDataSlotId(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
``` ```
## data.setDefaultCellularDataSlotId ## data.setDefaultCellularDataSlotId
setDefaultCellularDataSlotId(slotId: number): Promise\<void\> setDefaultCellularDataSlotId(slotId: number): Promise\<void\>
...@@ -127,13 +127,13 @@ This is a system API. ...@@ -127,13 +127,13 @@ This is a system API.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration| | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------------- | | -------------- | ------------------------------- |
| Promise<\void\> | Promise used to return the result. | | Promise<\void\> | Promise used to return the result. |
...@@ -158,7 +158,7 @@ Obtains the cellular data flow type, which can be uplink or downlink. This API u ...@@ -158,7 +158,7 @@ Obtains the cellular data flow type, which can be uplink or downlink. This API u
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------- | ---- | ---------- | | -------- | ---------------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<[DataFlowType](#dataflowtype)\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[DataFlowType](#dataflowtype)\> | Yes | Callback used to return the result.|
...@@ -227,7 +227,7 @@ Obtains the connection status of the PS domain. This API uses a promise to retur ...@@ -227,7 +227,7 @@ Obtains the connection status of the PS domain. This API uses a promise to retur
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------------ | ------------------------------------- | | ------------------------------------------------ | ------------------------------------- |
| Promise\<[DataConnectState](#dataconnectstate)\> | Promise used to return the result.| | Promise\<[DataConnectState](#dataconnectstate)\> | Promise used to return the result.|
...@@ -313,7 +313,7 @@ Checks whether the cellular data roaming service is enabled. This API uses an as ...@@ -313,7 +313,7 @@ Checks whether the cellular data roaming service is enabled. This API uses an as
**Example** **Example**
```js ```js
data.isCellularDataRoamingEnabled(0,(err, data) => { data.isCellularDataRoamingEnabled(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
......
...@@ -184,12 +184,12 @@ The table below provides only the sites for downloading the latest OpenHarmony L ...@@ -184,12 +184,12 @@ The table below provides only the sites for downloading the latest OpenHarmony L
| Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | | Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) |
| RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | | RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - |
| **Source code of the Latest Release**| **Version Information**| **Site**| **SHA-256 Verification Code**| | **Source code of the Latest Release**| **Version Information**| **Site**| **SHA-256 Verification Code**|
| Full code base (for mini, small, and standard systems)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/code-v3.2-Beta2.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/code-v3.2-Beta2.tar.gz.sha256)| | Full code base (for mini, small, and standard systems)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/code-v3.2-Beta3.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/code-v3.2-Beta3.tar.gz.sha256)|
| RK3568 standard system solution (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)| | RK3568 standard system solution (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)|
| Hi3861 solution (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_pegasus.tar.gz.sha256) | | Hi3861 solution (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_pegasus.tar.gz.sha256) |
| Hi3516 solution-LiteOS (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_LiteOS.tar.gz.sha256)| | Hi3516 solution-LiteOS (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_taurus_LiteOS.tar.gz.sha256)|
| Hi3516 solution-Linux (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_Linux.tar.gz.sha256)| | Hi3516 solution-Linux (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_taurus_Linux.tar.gz.sha256)|
| RELEASE-NOTES | 3.2 Beta2 | [Download](../../release-notes/OpenHarmony-v3.2-beta2.md)| - | | RELEASE-NOTES | 3.2 Beta3 | [Download](../../release-notes/OpenHarmony-v3.2-beta3.md)| - |
| **Compiler Toolchain**| **Version Information**| **Site**| **SHA-256 Verification Code**| | **Compiler Toolchain**| **Version Information**| **Site**| **SHA-256 Verification Code**|
| Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | | Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - |
......
...@@ -116,27 +116,7 @@ The following table describes APIs available for obtaining device location infor ...@@ -116,27 +116,7 @@ The following table describes APIs available for obtaining device location infor
If your application needs to access the device location information when running on the background, it must be allowed to run on the background in the configuration file and also granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information even when your application moves to the background. If your application needs to access the device location information when running on the background, it must be allowed to run on the background in the configuration file and also granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information even when your application moves to the background.
To allow your application to access device location information, you can declare the required permissions in the **config.json** file of your application. The sample code is as follows: You can declare the required permission in your application's configuration file. For details, see [Application Package Structure Configuration File](../application-dev/quick-start/stage-structure.md).
```
{
"module": {
"reqPermissions": [{
"name": "ohos.permission.LOCATION",
"reason": "$string:reason_description",
"usedScene": {
"ability": ["com.myapplication.LocationAbility"],
"when": "inuse"
}, {
...
}
]
}
}
```
For details about the configuration fields, see [Application Package Structure Configuration File](../application-dev/quick-start/stage-structure.md).
2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities. 2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities.
...@@ -286,4 +266,4 @@ The following table describes APIs available for obtaining device location infor ...@@ -286,4 +266,4 @@ The following table describes APIs available for obtaining device location infor
Location subsystem Location subsystem
[base_location](https://gitee.com/openharmony/base_location) [base_location](https://gitee.com/openharmony/base_location/blob/master/README.en.md)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册