提交 fb3ae500 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 a7b5fd9c
......@@ -10,7 +10,7 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat
| Class/Interface | Function | Description |
| --------------- | -------- | ----------- |
| IRemoteBroker | sptr<IRemoteObject> AsObject() | Obtains the holder of a remote proxy object. This method must be implemented by the derived classes of **IRemoteBroker**. If you call this method on the stub, the **RemoteObject** is returned; if you call this method on the proxy, the proxy object is returned. |
| [IRemoteBroker](../reference/apis/js-apis-rpc.md#iremotebroker) | sptr<IRemoteObject> AsObject() | Obtains the holder of a remote proxy object. This method must be implemented by the derived classes of **IRemoteBroker**. If you call this method on the stub, the **RemoteObject** is returned; if you call this method on the proxy, the proxy object is returned. |
| IRemoteStub | virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) | Called to process a request from the proxy and return the result. Derived classes need to override this method. |
| IRemoteProxy | | Service proxy classes are derived from the **IRemoteProxy** class. |
......@@ -25,10 +25,10 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat
```
class ITestAbility : public IRemoteBroker {
public:
// DECLARE_INTERFACE_DESCRIPTOR is mandatory, and the input parameter is std::u16string.
DECLARE_INTERFACE_DESCRIPTOR(u"test.ITestAbility");
int TRANS_ID_PING_ABILITY = 1; // Define the message code.
virtual int TestPingAbility(const std::u16string &dummy) = 0; // Define functions.
// DECLARE_INTERFACE_DESCRIPTOR is mandatory, and the input parameter is std::u16string.
DECLARE_INTERFACE_DESCRIPTOR(u"test.ITestAbility");
int TRANS_ID_PING_ABILITY = 1; // Define the message code.
virtual int TestPingAbility(const std::u16string &dummy) = 0; // Define functions.
};
```
......
......@@ -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.
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:
```
{
"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).
You can declare the required permission in your application's configuration file. For details, 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.
......
......@@ -403,7 +403,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
**Example**
```js
call.formatPhoneNumber("138xxxxxxxx",{
call.formatPhoneNumber("138xxxxxxxx", {
countryCode: "CN"
}, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......
......@@ -16,7 +16,7 @@ import connection from '@ohos.net.connection'
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
......@@ -41,7 +41,7 @@ connection.getDefaultNet(function (error, 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
......@@ -65,7 +65,7 @@ connection.getDefaultNet().then(function (netHandle) {
getDefaultNetSync(): NetHandle;
Obtains the default active data network in synchronous mode.
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
......@@ -88,8 +88,7 @@ let netHandle = connection.getDefaultNetSync();
hasDefaultNet(callback: AsyncCallback\<boolean>): void
Checks whether the default data network is activated. This API uses an asynchronous callback to return the result.
The default network priority is as follows: Ethernet > Wi-Fi > cellular. When only one network is connected, it is treated as the default data network.
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
......@@ -114,8 +113,7 @@ connection.hasDefaultNet(function (error, has) {
hasDefaultNet(): Promise\<boolean>
Checks whether the default data network is activated. This API uses a promise to return the result.
The default network priority is as follows: Ethernet > Wi-Fi > cellular. When only one network is connected, it is treated as the default data network.
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
......
......@@ -1840,10 +1840,10 @@ Defines the network status.
| Name | Value | Description |
| ----------------------------- | ---- | -------------------------- |
| REG_STATE_NO_SERVICE | 0 | The device cannot use any service. |
| REG_STATE_IN_SERVICE | 1 | The device can use services normally. |
| 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_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 properly, including data, SMS, and call services. |
| REG_STATE_EMERGENCY_CALL_ONLY | 2 | The device can use only the emergency call service. |
| 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
......
......@@ -689,7 +689,7 @@ promise.then(data => {
## 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.
......@@ -710,7 +710,7 @@ Sets a display name for the SIM card in the specified slot. This API uses an asy
**Example**
```js
let name = 'China Mobile';
let name = "China Mobile";
sim.setShowName(0, name, (err, 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
**Example**
```js
let name = 'China Mobile';
let name = "China Mobile";
let promise = sim.setShowName(0, name);
promise.then(data => {
console.log(`setShowName success, promise: data->${JSON.stringify(data)}`);
......@@ -818,7 +818,7 @@ promise.then(data => {
## 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.
......@@ -848,7 +848,7 @@ sim.setShowNumber(0, number, (err, data) => {
## 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.
......@@ -885,7 +885,7 @@ promise.then(data => {
## 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.
......@@ -1097,7 +1097,7 @@ Sets the lock status of the SIM card in the specified slot. This API uses an asy
```js
let lockInfo = {
lockType: sim.LockType.PIN_LOCK,
password = "1234",
password: "1234",
state: sim.LockState.LOCK_OFF
};
sim.setLockState(0, lockInfo, (err, data) => {
......@@ -1136,7 +1136,7 @@ Sets the lock status of the SIM card in the specified slot. This API uses a prom
```js
let lockInfo = {
lockType: sim.LockType.PIN_LOCK,
password = "1234",
password: "1234",
state: sim.LockState.LOCK_OFF
};
let promise = sim.setLockState(0, lockInfo);
......@@ -1344,7 +1344,7 @@ promise.then(data => {
## 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.
......@@ -1374,7 +1374,7 @@ sim.unlockPin(0, pin, (err, data) => {
## 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.
......@@ -1411,7 +1411,7 @@ promise.then(data => {
## 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.
......@@ -1443,7 +1443,7 @@ sim.unlockPuk(0, newPin, puk, (err, data) => {
## 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.
......@@ -1482,7 +1482,7 @@ promise.then(data => {
## 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.
......@@ -1512,7 +1512,7 @@ sim.unlockPin2(0, pin2, (err, data) => {
## 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.
......@@ -1539,7 +1539,7 @@ Unlocks PIN 2 of the SIM card in the specified slot. This API uses a promise to
```js
let pin2='1234';
let promise = sim.unlockPin2(0,pin2);
let promise = sim.unlockPin2(0, pin2);
promise.then(data => {
console.log(`unlockPin2 success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
......@@ -1851,7 +1851,7 @@ Sets voice mailbox information for the SIM card in the specified slot. This API
**Example**
```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)}`);
});
```
......@@ -2602,8 +2602,8 @@ Unlocks the SIM card in the specified slot. This API uses an asynchronous callba
```js
let persoLockInfo = {
lockType = sim.PersoLockType.PN_PIN_LOCK,
password = "1234"
lockType: sim.PersoLockType.PN_PIN_LOCK,
password: "1234"
};
sim.unlockSimLock(0, persoLockInfo, (err, 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
```js
let persoLockInfo = {
lockType = sim.PersoLockType.PN_PIN_LOCK,
password = "1234"
lockType: sim.PersoLockType.PN_PIN_LOCK,
password: "1234"
};
let promise = sim.unlockSimLock(0, persoLockInfo);
promise.then(data => {
......
......@@ -160,7 +160,7 @@ promise.then(data => {
## 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.
......@@ -180,7 +180,7 @@ Sets the default slot of the SIM card used to send SMS messages. This API uses a
**Example**
```js
sms.setDefaultSmsSlotId(0,(err, data) => {
sms.setDefaultSmsSlotId(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
......@@ -610,8 +610,8 @@ let updateSimMessageOptions = {
slotId: 0,
msgIndex: 1,
newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
pdu = "xxxxxxx",
smsc = "test"
pdu: "xxxxxxx",
smsc: "test"
};
sms.updateSimMessage(updateSimMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -650,8 +650,8 @@ let updateSimMessageOptions = {
slotId: 0,
msgIndex: 1,
newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE,
pdu = "xxxxxxx",
smsc = "test"
pdu: "xxxxxxx",
smsc: "test"
};
let promise = sms.updateSimMessage(updateSimMessageOptions);
promise.then(data => {
......@@ -1054,13 +1054,13 @@ Encodes MMS messages. This API uses an asynchronous callback to return the resul
```js
let mmsAcknowledgeInd = {
transactionId = "100",
version = 0x10,
reportAllowed = 128
transactionId: "100",
version: sms.MmsVersionType.MMS_VERSION_1_0,
reportAllowed: sms.ReportType.MMS_YES
};
let mmsInformation = {
messageType = 133,
mmsType = mmsAcknowledgeInd
messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
mmsType: mmsAcknowledgeInd
};
sms.encodeMms(mmsInformation, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -1096,10 +1096,10 @@ Encodes MMS messages. This API uses a promise to return the result.
let mmsAcknowledgeInd = {
transactionId: "100",
version: sms.MmsVersionType.MMS_VERSION_1_0,
reportAllowed = sms.ReportType.MMS_YES
reportAllowed: sms.ReportType.MMS_YES
};
let mmsInformation = {
messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND,
mmsType: mmsAcknowledgeInd
};
let promise = sms.encodeMms(mmsInformation);
......
......@@ -88,7 +88,7 @@ console.log("Result: "+ data.getDefaultCellularDataSlotIdSync())
## data.setDefaultCellularDataSlotId
setDefaultCellularDataSlotId(slotId: number,callback: AsyncCallback\<void\>): void
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.
......@@ -108,7 +108,7 @@ This is a system API.
**Example**
```js
data.setDefaultCellularDataSlotId(0,(err, data) => {
data.setDefaultCellularDataSlotId(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
......@@ -313,7 +313,7 @@ Checks whether the cellular data roaming service is enabled. This API uses an as
**Example**
```js
data.isCellularDataRoamingEnabled(0,(err, data) => {
data.isCellularDataRoamingEnabled(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
......
......@@ -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.
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:
```
{
"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).
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).
2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册