提交 b7ee0a08 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 24bb8ec5
# DFX
- Application Event Logging
- [Development of Application Event Logging](hiappevent-guidelines.md)
- Distributed Call Chain Tracing
- [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md)
- HiLog
- [HiLog Development](hilog-guidelines.md)
- Performance Tracing
- [Development of Performance Tracing](hitracemeter-guidelines.md)
- [Development of Application Event Logging](hiappevent-guidelines.md)
- [Development of Performance Tracing](hitracemeter-guidelines.md)
- [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md)
- [HiLog Development (Native)](hilog-guidelines.md)
- Error Management
- [Development of Error Manager](errormanager-guidelines.md)
- [Development of Application Recovery](apprecovery-guidelines.md)
- [Development of Application Recovery](apprecovery-guidelines.md)
\ No newline at end of file
......@@ -12,11 +12,11 @@ Application error management APIs are provided by the **errorManager** module. F
| API | Description |
| ------------------------------------------------------------ | ---------------------------------------------------- |
| registerErrorObserver(observer: ErrorObserver): number | Registers an observer for application errors. A callback will be invoked when an application error is detected. This API works in a synchronous manner. The return value is the SN of the registered observer.|
| unregisterErrorObserver(observerId: number, callback: AsyncCallback\<void\>): void | Unregisters an observer in callback mode. The number passed to this API is the SN of the registered observer. |
| unregisterErrorObserver(observerId: number): Promise\<void\> | Unregisters an observer in promise mode. The number passed to this API is the SN of the registered observer. |
| on(type: "error", observer: ErrorObserver): number | Registers an observer for application errors. A callback will be invoked when an application error is detected. This API works in a synchronous manner. The return value is the SN of the registered observer.|
| off(type: "error", observerId: number, callback: AsyncCallback\<void\>): void | Unregisters an observer in callback mode. The number passed to this API is the SN of the registered observer. |
| off(type: "error", observerId: number): Promise\<void\> | Unregisters an observer in promise mode. The number passed to this API is the SN of the registered observer. |
When an asynchronous callback is used, the return value can be processed directly in the callback. If a promise is used, the return value can also be processed in the promise in a similar way. For details about the result codes, see [Result Codes for Unregistering an Observer](#result-codes-for-unregistering-an-observer).
When an asynchronous callback is used, the return value can be processed directly in the callback. If a promise is used, the return value can also be processed in the promise in a similar way. For details about the result codes, see [Result Codes for Unregistering an Observer](#result codes-for-unregistering-an-observer).
**Table 2** Description of the ErrorObserver API
......@@ -45,7 +45,8 @@ let callback = {
console.log(errMsg);
}
}
export default class EntryAbility extends Ability {
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
console.log("[Demo] EntryAbility onCreate")
registerId = errorManager.on("error", callback);
......
......@@ -782,12 +782,12 @@ For details about the following error codes, see [Location Error Codes](../error
{
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
action: "action1",
action: "action1"
}
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG],
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
......
......@@ -411,7 +411,7 @@ Registers a listener for status change events of the specified geofence.
{
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
action: "action1",
action: "action1"
}
],
operationType: wantAgent.OperationType.START_ABILITY,
......
......@@ -13,14 +13,15 @@ The Resource Manager module provides APIs to obtain information about applicatio
import resourceManager from '@ohos.resourceManager';
```
## Instruction
## How to Use
Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model.
For details about how to reference **context** in the stage model, see [Context in the Stage Model](../../application-models/application-context-stage.md).
Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model. For the FA model, you need to import the required bundle and then call the [getResourceManager](#resourcemanagergetresourcemanager) API to obtain a **ResourceManager** object.
For details about how to reference context in the stage model, see [Context in the Stage Model](../../application-models/application-context-stage.md).
```ts
import Ability from '@ohos.application.Ability';
class MainAbility extends Ability {
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
let context = this.context;
let resourceManager = context.resourceManager;
......@@ -60,6 +61,7 @@ Obtains the **ResourceManager** object of this application. This API uses an asy
});
});
```
> **NOTE**<br>In the sample code, **0x1000000** indicates the resource ID, which can be found in the compiled **ResourceTable.txt** file.
## resourceManager.getResourceManager
......@@ -76,7 +78,7 @@ Obtains the **ResourceManager** object of an application based on the specified
| Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ----------------------------- |
| bundleName | string | Yes | Bundle name of the application. |
| bundleName | string | Yes | Bundle name of the target application. |
| callback | AsyncCallback&lt;[ResourceManager](#resourcemanager)&gt; | Yes | Callback used to return the result.|
**Example**
......@@ -116,6 +118,7 @@ Obtains the **ResourceManager** object of this application. This API uses a prom
console.log("error is " + error);
});
```
> **NOTE**<br>> In the sample code, **0x1000000** indicates the resource ID, which can be found in the compiled **ResourceTable.txt** file.
## resourceManager.getResourceManager
......@@ -132,7 +135,7 @@ Obtains the **ResourceManager** object of an application based on the specified
| Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ------------- |
| bundleName | string | Yes | Bundle name of the application.|
| bundleName | string | Yes | Bundle name of the target application.|
**Return value**
......@@ -168,12 +171,12 @@ Enumerates the device types.
| Name | Value | Description |
| -------------------- | ---- | ---- |
| DEVICE_TYPE_PHONE | 0x00 | Phone |
| DEVICE_TYPE_TABLET | 0x01 | Tablet |
| DEVICE_TYPE_CAR | 0x02 | Head unit |
| DEVICE_TYPE_PC | 0x03 | PC |
| DEVICE_TYPE_TV | 0x04 | TV |
| DEVICE_TYPE_WEARABLE | 0x06 | Wearable |
| DEVICE_TYPE_PHONE | 0x00 | Phone. |
| DEVICE_TYPE_TABLET | 0x01 | Tablet. |
| DEVICE_TYPE_CAR | 0x02 | Head unit. |
| DEVICE_TYPE_PC | 0x03 | PC. |
| DEVICE_TYPE_TV | 0x04 | TV. |
| DEVICE_TYPE_WEARABLE | 0x06 | Wearable. |
## ScreenDensity
......@@ -275,7 +278,7 @@ Defines the capability of accessing application resources.
> **NOTE**
>
> - The APIs involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm.
> - The methods involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm.
>
> - Resource files are defined in the **resources** directory of the project. You can obtain the resource ID using **$r(resource address).id**, for example, **$r('app.string.test').id**.
......@@ -642,7 +645,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco
getMediaContent(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result.
Obtains the content of the media file corresponding to the specified resource name. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Global.ResourceManager
......@@ -1655,7 +1658,7 @@ Obtains the string corresponding to the specified resource name. This API uses a
| Type | Description |
| --------------------- | ---------- |
| Promise&lt;string&gt; | String corresponding to the resource name.|
| Promise&lt;string&gt; | Promise used to return the result.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
......@@ -2033,7 +2036,7 @@ Obtains the string corresponding to the specified resource ID. This API returns
| Type | Description |
| ------ | ----------- |
| string | Promise used to return the result.|
| string | String corresponding to the specified resource ID.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
......@@ -2072,7 +2075,7 @@ Obtains the string corresponding to the specified resource object. This API retu
| Type | Description |
| ------ | ---------------- |
| string | Promise used to return the result.|
| string | String corresponding to the resource object.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
......@@ -2116,7 +2119,7 @@ Obtains the string corresponding to the specified resource name. This API return
| Type | Description |
| ------ | ---------- |
| string | String corresponding to the specified resource name.|
| string | String corresponding to the resource name.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
......@@ -2527,7 +2530,7 @@ This API is deprecated since API version 9. You are advised to use [getStringArr
getMedia(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result.
Obtains the content of the media file corresponding to the specified resource name. This API uses an asynchronous callback to return the result.
This API is deprecated since API version 9. You are advised to use [getMediaContent](#getmediacontent9) instead.
......
......@@ -70,10 +70,10 @@ export default {
console.log('success get location data. latitude:' + data.latitude);
},
fail: function(data, code) {
console.log('fail to get location. code:' + code + ', data:' + data);
},
console.log('fail to get location. code:' + code + ', data:' + data);
}
});
},
}
}
```
......@@ -192,8 +192,8 @@ Cancels listening to the geographic location.
```
export default {
unsubscribe() {
geolocation.unsubscribe();
},
geolocation.unsubscribe();
}
}
```
......
......@@ -49,6 +49,10 @@
- [Upload and Download Error Codes](errorcode-request.md)
- [HTTP Error Codes](errorcode-net-http.md)
- [Socket Error Codes](errorcode-net-socket.md)
- [Network Connection Management Error Codes](errorcode-net-connection.md)
- [Ethernet Connection Error Codes](errorcode-net-ethernet.md)
- [Network Sharing Error Codes](errorcode-net-sharing.md)
- [Policy Management Error Codes](errorcode-net-policy.md)
- Connectivity
- [NFC Error Codes](errorcode-nfc.md)
- [RPC Error Codes](errorcode-rpc.md)
......
# Network Connection Management Error Codes
## 2100001 Invalid Parameter Value
**Error Message**
Invalid parameter value.
**Description**
This error code is reported if the parameter value is invalid.
**Cause**
The input parameter value is not within the valid value range.
**Procedure**
Check whether the input parameter value is within the valid value range.
## 2100002 Service Connection Failure
**Error Message**
Operation failed. Cannot connect to service.
**Description**
This error code is reported if a service connection failure occurs.
**Cause**
The service is abnormal.
**Procedure**
Check whether system services are running properly.
## 2100003 System Internal Error
**Error Message**
System internal error.
**Description**
This error code is reported if a system internal error occurs.
**Cause**
1. The memory is abnormal.
2. A null pointer is present.
**Procedure**
1. Check whether the memory space is sufficient. If not, clear the memory and try again.
2. Check whether the system is normal. If not, try again later or restart the device.
## 2101007 Callback Already Exists
**Error Message**
The same callback exists.
**Description**
This error code is reported if the same callback already exists.
**Cause**
The **callback** object has been registered for activating a network or listening to network status changes.
**Procedure**
1. Check whether the **callback** object has been registered.
2. If the **callback** object has been registered, use the registered **callback** object.
## 2101008 Callback Not Exist
**Error Message**
The callback is not exists.
**Description**
This error code is reported if a **callback** object to be unregistered does not exist.
**Cause**
The **callback** object has not been registered for activating a network or listening to network status changes.
**Procedure**
Before unregistering a **callback** object, make sure that it has been registered for activating a network or listening to network status changes.
## 2101022 Number of Requests Exceeding the Maximum
**Error Message**
The number of requests exceeded the maximum.
**Description**
This error code is reported if the number of network requests exceeds the maximum.
**Cause**
The number of requests for activating a network or listening to network status changes has reached the maximum value.
**Procedure**
Locate the fault based on the "Over the max request number" log record.
# Ethernet Connection Error Codes
## 2200001 Invalid Parameter Value
**Error Message**
Invalid parameter value.
**Description**
This error code is reported if the parameter value is invalid.
**Cause**
The input parameter value is not within the valid value range.
**Procedure**
Check whether the input parameter value is within the valid value range.
## 2200002 Service Connection Failure
**Error Message**
Operation failed. Cannot connect to service.
**Description**
This error code is reported if a service connection failure occurs.
**Cause**
The service is abnormal.
**Procedure**
Check whether system services are running properly.
## 2200003 System Internal Error
**Error Message**
System internal error.
**Description**
This error code is reported if a system internal error occurs.
**Cause**
1. The memory is abnormal.
2. A null pointer is present.
**Procedure**
1. Check whether the memory space is sufficient. If not, clear the memory and try again.
2. Check whether the system is normal. If not, try again later or restart the device.
## 2201005 Device Information Not Exist
**Error Message**
The device information does not exist.
**Description**
This error code is reported if the device information does not exist.
**Cause**
The device to set or obtain does not exist.
**Procedure**
```bash
> hdc shell ifconfig
```
Check whether the device, for example, **eth0** or **eth1**, exists.
## 2201006 Device Not Connected
**Error Message**
Device disconnected.
**Description**
This error code is reported if the device is not connected.
**Cause**
The network interface card (NIC) is faulty.
**Procedure**
View the Ethernet service and netsys logs to check for the connection status information reported by the kernel.
## 2201007 Failed to Write the User Configuration
**Error Message**
Failed to write the user configuration.
**Description**
This error code is reported if an error occurs while writing data to the user configuration file.
**Cause**
The system reports an error.
**Procedure**
A system internal error occurs. You are advised to locate the fault based on logs.
# Policy Management Error Codes
## 2100001 Invalid Parameter Value
**Error Message**
Invalid parameter value.
**Description**
Invalid parameter value
**Cause**
The input parameter value is not within the valid value range.
**Procedure**
Check whether the input parameter value is within the valid value range.
## 2100002 Service Connection Failure
**Error Message**
Operation failed. Cannot connect to service.
**Description**
This error code is reported if a service connection failure occurs.
**Cause**
The service is abnormal.
**Procedure**
Check whether system services are running properly.
## 2100003 System Internal Error
**Error Message**
System internal error.
**Description**
This error code is reported if a system internal error occurs.
**Cause**
1. The memory is abnormal.
2. A null pointer is present.
**Procedure**
1. Check whether the memory space is sufficient. If not, clear the memory and try again.
2. Check whether the system is normal. If not, try again later or restart the device.
# Network Sharing Error Codes
## 2200001 Invalid Parameter Value
**Error Message**
Invalid parameter value.
**Description**
This error code is reported if the parameter value is invalid.
**Cause**
The input parameter value is not within the valid value range.
**Procedure**
Check whether the input parameter value is within the valid value range.
## 2200002 Service Connection Failure
**Error Message**
Operation failed. Cannot connect to service.
**Description**
This error code is reported if a service connection failure occurs.
**Cause**
The service is abnormal.
**Procedure**
Check whether system services are running properly.
## 2200003 System Internal Error
**Error Message**
System internal error.
**Description**
This error code is reported if a system internal error occurs.
**Cause**
1. The memory is abnormal.
2. A null pointer is present.
**Procedure**
1. Check whether the memory space is sufficient. If not, clear the memory and try again.
2. Check whether the system is normal. If not, try again later or restart the device.
## 2202004 Shared Iface Unavailable
**Error Message**
Try to share an unavailable iface.
**Description**
This error code is reported if an Iface is used.
**Cause**
The specified Iface does not exist or the Iface name is incorrect.
**Procedure**
1. Check whether the shared Iface is available.
```bash
> ifconfig -a
```
2. Check whether the Iface name is correct.
## 2202005 Wi-Fi Sharing Failure
**Error Message**
WiFi sharing failed.
**Description**
This error code is reported if Wi-Fi sharing fails.
**Cause**
No connected network is available and therefore the attempt to obtain the default network fails.
**Procedure**
Check whether the network connection is normal.
## 2202006 Bluetooth Sharing Failure
**Error Message**
Bluetooth sharing failed.
**Description**
This error code is reported if Bluetooth sharing fails.
**Cause**
1. Bluetooth is disabled.
2. No connected network is available and therefore the attempt to obtain the default network fails.
**Procedure**
1. Touch the Bluetooth icon to turn on Bluetooth mode.
2. Check whether the network connection is normal.
## 2202009 Failed to Enable Forwarding for Network Sharing
**Error Message**
Network share enable forwarding error.
**Description**
This error code is reported if an error occurs while enabling forwarding for network sharing.
**Cause**
The Iptables rule setting fails and therefore an error occurs while combining Iptables commands fails.
**Procedure**
Enable the debug log function, and check whether Iptables commands are correctly combined.
## 2202011 Failed to Obtain the Network Sharing Configuration
**Error Message**
Cannot get network sharing configuration.
**Description**
This error code is reported if an error occurs while obtaining the network sharing configuration.
**Cause**
The configuration file directory is incorrect.
**Procedure**
Specify a correct configuration file directory.
# Telephony Subsystem Changelog
## cl.telephony.1 Call Module reject API Change
Changed the `reject` API to the `rejectCall` API in the call module of the telephony subsystem since API version 9.
You need to adapt your application.
**Change Impact**
The `reject` API is deprecated and cannot be used any more. Use the `rejectCall` API instead. Otherwise, relevant functions will be affected.
- Involved APIs:
```js
function reject(callId: number, callback: AsyncCallback<void>): void;
function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void>): void;
function reject(callId?: number, options?: RejectMessageOptions): Promise<void>;
function reject(callback: AsyncCallback<void>): void;
function reject(options: RejectMessageOptions, callback: AsyncCallback<void>): void;
```
- Before change:
```js
function reject(callId: number, callback: AsyncCallback<void>): void;
function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void>): void;
function reject(callId?: number, options?: RejectMessageOptions): Promise<void>;
function reject(callback: AsyncCallback<void>): void;
function reject(options: RejectMessageOptions, callback: AsyncCallback<void>): void;
```
- After change:
```js
function rejectCall(callId: number, callback: AsyncCallback<void>): void;
function rejectCall(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void>): void;
function rejectCall(callId?: number, options?: RejectMessageOptions): Promise<void>;
function rejectCall(callback: AsyncCallback<void>): void;
function rejectCall(options: RejectMessageOptions, callback: AsyncCallback<void>): void;
```
**Adaptation Guide**
The `reject` API is deprecated and cannot be used any more. Use the `rejectCall` API instead.
Use the new API. The sample code is as follows:
```js
call.rejectCall("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
let promise = call.rejectCall(1, rejectMessageOptions);
promise.then(data => {
console.log(`rejectCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`rejectCall fail, promise: err->${JSON.stringify(err)}`);
});
```
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
let promise = call.rejectCall(1, rejectMessageOptions);
promise.then(data => {
console.log(`rejectCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`rejectCall fail, promise: err->${JSON.stringify(err)}`);
});
```
```js
call.rejectCall((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
call.rejectCall(rejectMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## cl.telephony.2 Call Module answer API Change
Changed the `answer` API to the `answerCall` API in the call module of the telephony subsystem since API version 9.
You need to adapt your application.
**Change Impact**
The `answer` API is deprecated and cannot be used any more. Use the `answerCall` API instead. Otherwise, relevant functions will be affected.
- Involved APIs:
```js
function answer(callId: number, callback: AsyncCallback<void>): void;
function answer(callId?: number): Promise<void>;
function answer(callback: AsyncCallback<void>): void;
```
- Before change:
```js
function answer(callId: number, callback: AsyncCallback<void>): void;
function answer(callId?: number): Promise<void>;
function answer(callback: AsyncCallback<void>): void;
```
- After change:
```js
function answerCall(callId: number, callback: AsyncCallback<void>): void;
function answerCall(callId?: number): Promise<void>;
function answerCall(callback: AsyncCallback<void>): void;
```
**Adaptation Guide**
The `answer` API is deprecated and cannot be used any more. Use the `answerCall` API instead.
Use the new API. The sample code is as follows:
```js
call.answerCall(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
```js
let promise = call.answerCall(1);
promise.then(data => {
console.log(`answerCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`answerCall fail, promise: err->${JSON.stringify(err)}`);
});
```
```js
call.answerCall((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## cl.telephony.1 Call Module hangup API Change
Changed the `hangup` API to the `hangUpCall` API in the call module of the telephony subsystem since API version 9.
You need to adapt your application.
**Change Impact**
The `hangup` API is deprecated and cannot be used any more. Use the `hangUpCall` API instead. Otherwise, relevant functions will be affected.
- Involved APIs:
```js
function hangup(callId: number, callback: AsyncCallback<void>): void;
function hangup(callId?: number): Promise<void>;
function hangup(callback: AsyncCallback<void>): void;
```
- Before change:
```js
function hangup(callId: number, callback: AsyncCallback<void>): void;
function hangup(callId?: number): Promise<void>;
function hangup(callback: AsyncCallback<void>): void;
```
- After change:
```js
function hangUpCall(callId: number, callback: AsyncCallback<void>): void;
function hangUpCall(callId?: number): Promise<void>;
function hangUpCall(callback: AsyncCallback<void>): void;
```
**Adaptation Guide**
The `hangup` API is deprecated and cannot be used any more. Use the `hangUpCall` API instead.
Use the new API. The sample code is as follows:
```js
call.hangUpCall(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
```js
let promise = call.hangUpCall(1);
promise.then(data => {
console.log(`hangUpCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`hangUpCall fail, promise: err->${JSON.stringify(err)}`);
});
```
```js
call.hangUpCall((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册