未验证 提交 f00d58bd 编写于 作者: O openharmony_ci 提交者: Gitee

!12687 翻译完成 12410+10680+11610+10625+10605+11345+11642+12228+12223+11627+11064+11632+12129

Merge pull request !12687 from ester.zhou/TR-12410
# CommonEvent
# @ohos.commonEvent
The **CommonEvent** module provides common event capabilities, including the capabilities to publish, subscribe to, and unsubscribe from common events, as well obtaining and setting the common event result code and result data.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are no longer maintained since API version 9. You are advised to use [@ohos.commonEventManager](js-apis-commonEventManager.md).
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......@@ -14,7 +14,7 @@ import CommonEvent from '@ohos.commonEvent';
## Support
Provides the event types supported by the **CommonEvent** module. The name and value indicate the macro and name of a common event, respectively.
The table below lists the event types supported by the **CommonEvent** module. The name and value indicate the macro and name of a common event, respectively.
**System capability**: SystemCapability.Notification.CommonEvent
......@@ -167,8 +167,8 @@ Provides the event types supported by the **CommonEvent** module. The name and v
| COMMON_EVENT_ACCOUNT_DELETED | usual.event.data.ACCOUNT_DELETED | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the account was deleted. |
| COMMON_EVENT_FOUNDATION_READY | usual.event.data.FOUNDATION_READY | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the foundation is ready. |
| COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | - | Indicates the common event that the airplane mode of the device has changed. |
| COMMON_EVENT_SPLIT_SCREEN<sup>8+<sup> | usual.event.SPLIT_SCREEN | - | Indicates the common event of screen splitting. |
| COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | Indicates the common event that the notification slot has changed. |
| COMMON_EVENT_SPLIT_SCREEN<sup>8+<sup> | usual.event.SPLIT_SCREEN | - | Indicates the common event of screen splitting. |
| COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | Indicates the common event that the notification slot has been updated. |
| COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | - | Indicates the common event that the SPN displayed has been updated. |
| COMMON_EVENT_QUICK_FIX_APPLY_RESULT <sup>9+<sup> | usual.event.QUICK_FIX_APPLY_RESULT | - | Indicates the common event that a quick fix is applied to the application. |
......@@ -192,7 +192,7 @@ Publishes a common event. This API uses an asynchronous callback to return the r
```js
// Callback for common event publication
function PublishCallBack(err) {
function publishCallBack(err) {
if (err.code) {
console.error("publish failed " + JSON.stringify(err));
} else {
......@@ -201,7 +201,7 @@ function PublishCallBack(err) {
}
// Publish a common event.
CommonEvent.publish("event", PublishCallBack);
CommonEvent.publish("event", publishCallBack);
```
......@@ -234,7 +234,7 @@ let options = {
}
// Callback for common event publication
function PublishCallBack(err) {
function publishCallBack(err) {
if (err.code) {
console.error("publish failed " + JSON.stringify(err));
} else {
......@@ -243,7 +243,7 @@ function PublishCallBack(err) {
}
// Publish a common event.
CommonEvent.publish("event", options, PublishCallBack);
CommonEvent.publish("event", options, publishCallBack);
```
......@@ -270,7 +270,7 @@ Publishes a common event to a specific user. This API uses an asynchronous callb
```js
// Callback for common event publication
function PublishAsUserCallBack(err) {
function publishAsUserCallBack(err) {
if (err.code) {
console.error("publishAsUser failed " + JSON.stringify(err));
} else {
......@@ -282,7 +282,7 @@ function PublishAsUserCallBack(err) {
let userId = 100;
// Publish a common event.
CommonEvent.publishAsUser("event", userId, PublishAsUserCallBack);
CommonEvent.publishAsUser("event", userId, publishAsUserCallBack);
```
......@@ -317,7 +317,7 @@ let options = {
}
// Callback for common event publication
function PublishAsUserCallBack(err) {
function publishAsUserCallBack(err) {
if (err.code) {
console.error("publishAsUser failed " + JSON.stringify(err));
} else {
......@@ -329,7 +329,7 @@ function PublishAsUserCallBack(err) {
let userId = 100;
// Publish a common event.
CommonEvent.publishAsUser("event", userId, options, PublishAsUserCallBack);
CommonEvent.publishAsUser("event", userId, options, publishAsUserCallBack);
```
......@@ -361,7 +361,7 @@ let subscribeInfo = {
};
// Callback for subscriber creation.
function CreateSubscriberCallBack(err, commonEventSubscriber) {
function createSubscriberCallBack(err, commonEventSubscriber) {
if (err.code) {
console.error("createSubscriber failed " + JSON.stringify(err));
} else {
......@@ -371,7 +371,7 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) {
}
// Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
```
......@@ -442,7 +442,7 @@ let subscribeInfo = {
};
// Callback for common event subscription.
function SubscribeCallBack(err, data) {
function subscribeCallBack(err, data) {
if (err.code) {
console.error("subscribe failed " + JSON.stringify(err));
} else {
......@@ -451,19 +451,19 @@ function SubscribeCallBack(err, data) {
}
// Callback for subscriber creation.
function CreateSubscriberCallBack(err, commonEventSubscriber) {
function createSubscriberCallBack(err, commonEventSubscriber) {
if (err.code) {
console.error("createSubscriber failed " + JSON.stringify(err));
} else {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
// Subscribe to a common event.
CommonEvent.subscribe(subscriber, SubscribeCallBack);
CommonEvent.subscribe(subscriber, subscribeCallBack);
}
}
// Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
```
......@@ -494,7 +494,7 @@ let subscribeInfo = {
};
// Callback for common event subscription.
function SubscribeCallBack(err, data) {
function subscribeCallBack(err, data) {
if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
......@@ -503,19 +503,19 @@ function SubscribeCallBack(err, data) {
}
// Callback for subscriber creation.
function CreateSubscriberCallBack(err, commonEventSubscriber) {
function createSubscriberCallBack(err, commonEventSubscriber) {
if (err.code) {
console.info("createSubscriber failed " + JSON.stringify(err));
} else {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
// Subscribe to a common event.
CommonEvent.subscribe(subscriber, SubscribeCallBack);
CommonEvent.subscribe(subscriber, subscribeCallBack);
}
}
// Callback for common event unsubscription.
function UnsubscribeCallBack(err) {
function unsubscribeCallBack(err) {
if (err.code) {
console.info("unsubscribe failed " + JSON.stringify(err));
} else {
......@@ -524,10 +524,10 @@ function UnsubscribeCallBack(err) {
}
// Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
// Unsubscribe from the common event.
CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack);
CommonEvent.unsubscribe(subscriber, unsubscribeCallBack);
```
## CommonEventSubscriber
......@@ -1233,39 +1233,45 @@ subscriber.finishCommonEvent().then(() => {
## CommonEventData
Describes the common event data body.
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable| Writable| Type | Description |
| ---------- | ---- | ---- | -------------------- | ------------------------------------------------------- |
| event | Yes | No | string | Name of the common event that is being received. |
| bundleName | Yes | No | string | Bundle name. |
| code | Yes | No | number | Result code of the common event, which is used to transfer data of the int type. |
| data | Yes | No | string | Custom result data of the common event, which is used to transfer data of the string type.|
| parameters | Yes | No | {[key: string]: any} | Additional information about the common event. |
| Name | Type | Readable| Writable| Description |
| ---------- |-------------------- | ---- | ---- | ------------------------------------------------------- |
| event | string | Yes | No | Name of the common event that is being received. |
| bundleName | string | Yes | No | Bundle name. |
| code | number | Yes | No | Result code of the common event, which is used to transfer data of the int type. |
| data | string | Yes | No | Custom result data of the common event, which is used to transfer data of the string type.|
| parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
## CommonEventPublishData
Describes the data body published by a common event, including the common event content and attributes.
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable| Writable| Type | Description |
| --------------------- | ---- | ---- | -------------------- | ---------------------------- |
| bundleName | Yes | No | string | Bundle name. |
| code | Yes | No | number | Result code of the common event. |
| data | Yes | No | string | Custom result data of the common event.|
| subscriberPermissions | Yes | No | Array\<string> | Permissions required for subscribers to receive the common event. |
| isOrdered | Yes | No | boolean | Whether the common event is an ordered one. |
| isSticky | Yes | No | boolean | Whether the common event is a sticky one. |
| parameters | Yes | No | {[key: string]: any} | Additional information about the common event. |
| Name | Type | Readable| Writable| Description |
| --------------------- | -------------------- | ---- | ---- | ---------------------------- |
| bundleName | string | Yes | No | Bundle name. |
| code | number | Yes | No | Result code of the common event. |
| data | string | Yes | No | Custom result data of the common event.|
| subscriberPermissions | Array\<string> | Yes | No | Permissions required for subscribers to receive the common event. |
| isOrdered | boolean | Yes | No | Whether the common event is an ordered one. |
| isSticky | boolean | Yes | No | Whether the common event is a sticky one. Only system applications and system services are allowed to send sticky events.|
| parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
## CommonEventSubscribeInfo
Provides the subscriber information.
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable| Writable| Type | Description |
| ------------------- | ---- | ---- | -------------- | ------------------------------------------------------------ |
| events | Yes | No | Array\<string> | Name of the common event to publish. |
| publisherPermission | Yes | No | string | Permissions required for publishers to publish the common event. |
| publisherDeviceId | Yes | No | string | Device ID. The value must be the ID of an existing device on the same network. |
| userId | Yes | No | number | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | Yes | No | number | Subscriber priority. The value ranges from -100 to 1000. |
| Name | Type | Readable| Writable| Description |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| events | Array\<string> | Yes | No | Name of the common event to publish. |
| publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. |
| publisherDeviceId | string | Yes | No | Device ID. The value must be the ID of an existing device on the same network. |
| userId | number | Yes | No | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | number | Yes | No | Subscriber priority. The value ranges from -100 to +1000. |
# Emitter
# @ohos.events.emitter
The **Emitter** module provides APIs for sending and processing in-process events, including the APIs for processing events that are subscribed to in persistent or one-shot manner, unsubscribing from events, and emitting events to the event queue.
......
# SystemParameter
# @ohos.systemParameter
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs of this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see
[Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
> **NOTE**
>
> - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterV9](js-apis-system-parameterV9.md) instead.
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs.
......@@ -54,7 +53,7 @@ try {
get(key: string, callback: AsyncCallback&lt;string&gt;): void
Obtains the value of the system parameter with the specified key. This API uses an asynchronous callback to return the result.
Obtains the value of the system parameter with the specified key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Startup.SystemInfo
......@@ -164,9 +163,9 @@ Sets a value for the system parameter with the specified key.
| value | string | Yes| Value of the system parameter to set.|
> **NOTE**
>
> - This API can be used only for setting parameters of system applications.
> - SELinux and DAC rules must be configured for authorized system applications. For details, see [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
> - SELinux and Discretionary Access Control (DAC) rules must be configured for authorized system applications. For details about how to configure SELinux and DAC rules, see [Parameter Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
**Example**
......@@ -195,9 +194,8 @@ Sets a value for the system parameter with the specified key. This API uses an a
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
> **NOTE**
>
> - This API can be used only for setting parameters of system applications.
> - SELinux and discretionary access control (DAC) rules must be configured for authorized system applications. For details, see [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
> - SELinux and Discretionary Access Control (DAC) rules must be configured for authorized system applications. For details about how to configure SELinux and DAC rules, see [Parameter Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
**Example**
......@@ -236,9 +234,8 @@ Sets a value for the system parameter with the specified key. This API uses a pr
| Promise&lt;void&gt; | Promise used to return the execution result.|
> **NOTE**
>
> - This API can be used only for setting parameters of system applications.
> - SELinux and discretionary access control (DAC) rules must be configured for authorized system applications. For details, see [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
> - SELinux and Discretionary Access Control (DAC) rules must be configured for authorized system applications. For details about how to configure SELinux and DAC rules, see [Parameter Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
**Example**
......
# Event Error Codes
## 1500001 Want Action Is Null
**Error Message**
Want action is null
**Description**
This error code is reported when the **Action** attribute in the **want** is null for the event to send.
**Possible Causes**
The **Action** attribute in the **want** is null for the event to send.
**Solution**
Make sure the **Action** attribute in the **want** is not null.
## 1500002 Failed to Send Common Events from a Sandbox Application
**Error Message**
sandbox application can not send common event
**Description**
This error code is reported when an attempt is made to send a common event from a sandbox application.
**Possible Causes**
Common events from a sandbox application are blocked.
**Solution**
Check whether the application used to send a common event is a sandbox application. If so, switch to another application.
## 1500003 Event Sending Frequency Is Too High
**Error Message**
common event send frequency too high
**Description**
This error code is reported when the application sends common events too frequently.
**Possible Causes**
The number of common events sent by the application in a given time frame has reached the maximum.
**Solution**
Do not send common events too frequently.
## 1500004 Failed to Send System Common Events
**Error Message**
not System services or System app
**Description**
This error code is reported when the application cannot send system common events.
**Possible Causes**
The application is not a system application or system service.
**Solution**
Make sure the application to send system common events is a system application or system service.
## 1500005 Subscriber Not Found
**Error Message**
subscriber can not found
**Description**
This error code is reported when the subscriber cannot be found.
**Possible Causes**
The subscriber is deleted.
**Solution**
Check whether the subscription has already been canceled. If the subscription has been canceled, the subscriber is deleted.
## 1500006 Invalid User ID
**Error Message**
usreId is invalid
**Description**
This error code is reported when the user ID is invalid.
**Possible Causes**
The user ID is different from the system user ID, or the application is not a system application or subsystem process.
**Solution**
Check whether the current user ID is the same as the system user ID. If they are different, check whether the application is a system application or subsystem process
## 1500007 Failed to Send a Request Through IPC
**Error Message**
message send error
**Description**
This error code is reported when the attempt to send a request through IPC fails.
**Possible Causes**
The connection object fails to be created.
**Solution**
Do not set up connections frequently. Try again later.
## 1500008 Failed to Read Data
**Error Message**
CEMS error
**Description**
This error code is reported when an error occurs on the server.
**Possible Causes**
A service exception occurs when the server processes data.
**Solution**
Try again later.
## 1500009 System Error
**Error Message**
system error
**Description**
This error code is reported when an exception occurs in the system during service processing, for example, when the current system time fails to be obtained.
**Possible Causes**
A system fault occurs.
**Solution**
Try again later.
# DistributedNotificationService Error Codes
## 1600001 Internal Error
**Error Message**
Internal Error.
**Description**
This error code is reported when an internal processing error occurs, such as a memory allocation or multi-thread processing error.
**Possible Causes**
1. Common kernel errors such as memory allocation and multi-thread processing errors occur.
**Solution**
1. Ensure sufficient system memory.
2. Restart the system.
## 1600002 Data Processing or Interaction Error Between the Application and Notification Subsystem
**Error Message**
IPC Error.
**Description**
This error code is reported when a serialization or deserialization error occurs and the interaction with the notification subsystem fails.
**Possible Causes**
1. A serialization and deserialization error occurs.
2. The interaction with the notification subsystem fails.
**Solution**
1. Make sure the input parameter value is within the valid range.
2. Make sure the notification subsystem is not being started.
## 1600003 Failed to Connect to the Service
**Error Message**
Failed to connect to service.
**Description**
This error code is reported when the notification subsystem is abnormal due to a service connection failure.
**Possible Causes**
The service is busy or the notification subsystem is not working correctly.
**Solution**
1. Try again later.
2. Make sure the notification subsystem is started.
## 1600004 Notification Is Disabled
**Error Message**
Notification is not enabled.
**Description**
This error code is reported when the notification function is disabled.
**Possible Causes**
The notification function is set to its default state (default) or manually disabled.
**Solution**
Enable the notification function.
## 1600005 Notification Slot Is Disabled
**Error Message**
Notification slot is not enabled.
**Description**
This error code is reported when the notification slot is disabled.
**Possible Causes**
The notification slot is disabled.
**Solution**
Make sure the application notification slot is enabled.
## 1600006 Unable to Remove the Notification
**Error Message**
Notification is not allowed to remove.
**Description**
This error code is reported when **isUnremoveable** is set to **true** and an attempt is made to remove all notifications or when **isRemoveAllowed** is set to **false** and an attempt is made to remove a specific notification.
**Possible Causes**
1. When **isUnremoveable** is set to **true**, notifications can only be removed on a one-by-one basis.
2. When **isRemoveAllowed** is set to **false**, no notification can be deleted.
**Solution**
1. Check whether **unremovable** is set to **true**.
2. Check whether **isRemoveAllowed** is set to **false**.
## 1600007 Notification Not Found
**Error Message**
The notification is not exist.
**Description**
This error code is reported when the target notification is not found.
**Possible Causes**
1. The notification has been deleted.
2. The notification has been canceled.
**Solution**
Make sure the notification exists.
## 1600008 User Not Found
**Error Message**
The user is not exist.
**Description**
This error code is reported when the target user is not found.
**Possible Causes**
1. The user ID is incorrect.
2. No user account has not been activated.
**Solution**
Make sure the user account with the specified ID has been activated.
## 1600009 Maximum Number of Notifications per Second Reached
**Error Message**
Over max number notifications per second.
**Description**
This error code is reported when the number of notifications sent per second has reached the maximum.
**Possible Causes**
More than 10 notifications are sent per second.
**Solution**
Reduce the number of notifications sent per second to 10 or less.
## 1600010 Distributed Processing Error
**Error Message**
Distributed operation failed.
**Description**
This error code is reported when a database processing error occurs or the database operations are too frequent.
**Possible Causes**
1. A database processing error occurs.
2. The database operations are too frequent.
**Solution**
1. Make sure the distributed data is running properly.
2. Reduce the database operation frequency.
## 1600011 Failed to read the Template Configuration File
**Error Message**
Read template config failed.
**Description**
This error code is reported when the template configuration file fails to be read.
**Possible Causes**
1. The template configuration file is lost.
2. The current template version is not supported.
**Solution**
1. Check for the **/system/etc/notification_template/external.json** file.
2. Update the version to 3.2 or later.
## 17700001 Bundle Name Not Found
**Error Message**
The specified bundle name was not found.
**Description**
This error code is reported when the specified bund name is not found.
**Possible Causes**
1. The bundle name is incorrect.
2. The application is not installed.
**Solution**
1. Verify the bundle name.
2. Make sure the application has been installed.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册