已合并
update docs #157063
LexieLi创建于 7月23日
update docs #157063
已合并
共 13 个文件变更+795-666
| @@ -41,6 +41,7 @@ | |||
| 41 | <!--DelEnd--> | 41 | <!--DelEnd--> |
| 42 | - Data File Processing<!--data-file-processing-arkts--> | 42 | - Data File Processing<!--data-file-processing-arkts--> |
| 43 | - [@ohos.app.ability.PrintExtensionAbility (Print Extension Ability)](js-apis-app-ability-PrintExtensionAbility.md) | 43 | - [@ohos.app.ability.PrintExtensionAbility (Print Extension Ability)](js-apis-app-ability-PrintExtensionAbility.md) |
| 44 | + - [PrintExtensionContext](js-apis-PrintExtensionContext.md) | ||
| 44 | - [@ohos.pasteboard (Pasteboard)](js-apis-pasteboard.md) | 45 | - [@ohos.pasteboard (Pasteboard)](js-apis-pasteboard.md) |
| 45 | - [@ohos.print (Print)](js-apis-print.md) | 46 | - [@ohos.print (Print)](js-apis-print.md) |
| 46 | - [@ohos.scan (Scan)](js-apis-scan.md) | 47 | - [@ohos.scan (Scan)](js-apis-scan.md) |
| @@ -82,6 +83,7 @@ | |||
| 82 | - [@ohos.annotation (Annotation)](js-apis-annotation.md) | 83 | - [@ohos.annotation (Annotation)](js-apis-annotation.md) |
| 83 | - [@ohos.customization.customConfig (Custom Configurations)](js-apis-customization-customConfig.md) | 84 | - [@ohos.customization.customConfig (Custom Configurations)](js-apis-customization-customConfig.md) |
| 84 | - [@ohos.settings (Data Item Settings)](js-apis-settings.md) | 85 | - [@ohos.settings (Data Item Settings)](js-apis-settings.md) |
| 86 | + - [@ohos.settingsLite (Setting Information)](js-apis-settings-lite.md) | ||
| 85 | - [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md) | 87 | - [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md) |
| 86 | - [@ohos.resourceschedule.systemload (System Load Level Management)](js-apis-resourceschedule-systemload.md) | 88 | - [@ohos.resourceschedule.systemload (System Load Level Management)](js-apis-resourceschedule-systemload.md) |
| 87 | - [@ohos.systemDateTime (System Time and Time Zone)](js-apis-date-time.md) | 89 | - [@ohos.systemDateTime (System Time and Time Zone)](js-apis-date-time.md) |
| @@ -172,7 +174,7 @@ | |||
| 172 | - [Thermal Manager Error Codes](errorcode-thermal.md) | 174 | - [Thermal Manager Error Codes](errorcode-thermal.md) |
| 173 | - [Upload and Download Error Codes](errorcode-request.md) | 175 | - [Upload and Download Error Codes](errorcode-request.md) |
| 174 | - [Time and Time Zone Service Error Codes](errorcode-time.md) | 176 | - [Time and Time Zone Service Error Codes](errorcode-time.md) |
| 175 | - - [Event Error Codes](errorcode-CommonEventService.md) | 177 | + - [Common Event Error Codes](errorcode-CommonEventService.md) |
| 176 | <!--Del--> | 178 | <!--Del--> |
| 177 | - [System Parameter Error Codes](errorcode-system-parameterV9.md) | 179 | - [System Parameter Error Codes](errorcode-system-parameterV9.md) |
| 178 | <!--DelEnd--> | 180 | <!--DelEnd--> |
| @@ -16,14 +16,14 @@ This module provides APIs for three processes: subscription, publishing, and ord | |||
| 16 | 16 | ||
| 17 | **Combination 1: subscribing to and processing common events** | 17 | **Combination 1: subscribing to and processing common events** |
| 18 | 18 | ||
| 19 | -1. Call **OH_CommonEvent_CreateSubscribeInfo** to create subscriber information, declare the name of the event to be subscribed to, and set the publisher permissions and package name as required to filter the event source. | 19 | +1. Call **OH_CommonEvent_CreateSubscribeInfo** to create subscriber information, declare the name of the event to be subscribed to, and set the publisher permissions and bundle name as required to filter the event source. |
| 20 | 2. Call **OH_CommonEvent_CreateSubscriber** to create a subscriber and register the callback function for receiving events. Then, call **OH_CommonEvent_Subscribe** to subscribe to a common event. After the subscription takes effect, wait for event delivery in the callback. | 20 | 2. Call **OH_CommonEvent_CreateSubscriber** to create a subscriber and register the callback function for receiving events. Then, call **OH_CommonEvent_Subscribe** to subscribe to a common event. After the subscription takes effect, wait for event delivery in the callback. |
| 21 | -3. When the event is triggered, obtain the event name, code, data, and publisher's package name from the callback parameter **CommonEvent_RcvData**, and then process the service logic. | 21 | +3. When the event is triggered, obtain the event name, code, data, and publisher's bundle name from the callback parameter **CommonEvent_RcvData**, and then process the service logic. |
| 22 | 4. When the subscription is no longer needed, call **OH_CommonEvent_UnSubscribe** to unsubscribe from the event and release related resources. | 22 | 4. When the subscription is no longer needed, call **OH_CommonEvent_UnSubscribe** to unsubscribe from the event and release related resources. |
| 23 | 23 | ||
| 24 | **Combination 2: publishing a common event that carries additional information** | 24 | **Combination 2: publishing a common event that carries additional information** |
| 25 | 25 | ||
| 26 | -1. Call **OH_CommonEvent_CreatePublishInfo** to create a common event property object, and set the code, data, subscriber package name, subscriber permission, and additional information as required. | 26 | +1. Call **OH_CommonEvent_CreatePublishInfo** to create a common event property object, and set the code, data, subscriber bundle name, subscriber permission, and additional information as required. |
| 27 | 2. Call **OH_CommonEvent_PublishWithInfo** to publish an event that carries the property. | 27 | 2. Call **OH_CommonEvent_PublishWithInfo** to publish an event that carries the property. |
| 28 | 28 | ||
| 29 | > If no additional property is required, you can call **OH_CommonEvent_Publish(event)** to publish the event. | 29 | > If no additional property is required, you can call **OH_CommonEvent_Publish(event)** to publish the event. |
| @@ -152,15 +152,14 @@ Enumerates the error codes. | |||
| 152 | | Value| Description| | 152 | | Value| Description| |
| 153 | | -- | -- | | 153 | | -- | -- | |
| 154 | | COMMONEVENT_ERR_OK = 0 | Operation successful.| | 154 | | COMMONEVENT_ERR_OK = 0 | Operation successful.| |
| 155 | -| COMMONEVENT_ERR_PERMISSION_ERROR = 201 | Permission denied.| | 155 | +| COMMONEVENT_ERR_INVALID_PARAMETER = 401 | Invalid parameter. The parameter is invalid. Check the parameter type, value range, and whether the parameter is empty.| |
| 156 | -| COMMONEVENT_ERR_INVALID_PARAMETER = 401 | Invalid parameter.| | 156 | +| COMMONEVENT_ERR_SENDING_LIMIT_EXCEEDED = 1500003| Event sending frequency is too high. Check whether the application sends common events too frequently. If more than 20 common events are sent every 5 milliseconds, reduce the common event sending frequency or increase the sending interval and try again.<br>**Since**: 20| |
| 157 | -| COMMONEVENT_ERR_SENDING_LIMIT_EXCEEDED = 1500003| Event sending frequency is too high.<br>**Since**: 20| | 157 | +| COMMONEVENT_ERR_NOT_SYSTEM_SERVICE = 1500004 | The third-party application fails to send system common events. Check whether the current application is a system application or whether the current service is a system service.| |
| 158 | -| COMMONEVENT_ERR_NOT_SYSTEM_SERVICE = 1500004 | The third-party application fails to send system common events.| | 158 | +| COMMONEVENT_ERR_SENDING_REQUEST_FAILED = 1500007 | Failed to send IPC requests. Do not set up connections frequently. Try again later.| |
| 159 | -| COMMONEVENT_ERR_SENDING_REQUEST_FAILED = 1500007 | Failed to send IPC requests.| | 159 | +| COMMONEVENT_ERR_INIT_UNDONE = 1500008 | Services not initialized. Try again later.| |
| 160 | -| COMMONEVENT_ERR_INIT_UNDONE = 1500008 | Services not initialized.| | 160 | +| COMMONEVENT_ERR_OBTAIN_SYSTEM_PARAMS = 1500009 | System error. Try again later.| |
| 161 | -| COMMONEVENT_ERR_OBTAIN_SYSTEM_PARAMS = 1500009 | System error.| | 161 | +| COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED = 1500010 | The number of subscribers in the process exceeds the system limit (200). Unregister the subscriber that is no longer used in the application. If the subscriber has been unregistered, try again later.| |
| 162 | -| COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED = 1500010 | The number of subscribers in the process exceeds the system limit (200).| | 162 | +| COMMONEVENT_ERR_ALLOC_MEMORY_FAILED = 1500011 | Failed to allocate memory. Try again later.| |
| 163 | -| COMMONEVENT_ERR_ALLOC_MEMORY_FAILED = 1500011 | Failed to allocate memory.| | ||
| 164 | 163 | ||
| 165 | 164 | ||
| 166 | ## Function Description | 165 | ## Function Description |
| @@ -201,14 +200,14 @@ Creates the subscriber information. | |||
| 201 | 200 | ||
| 202 | | Name| Description| | 201 | | Name| Description| |
| 203 | | -- | -- | | 202 | | -- | -- | |
| 204 | -| const char* events[] | Pointer to the common events. The valid number of subscribed common events is the smaller value between **eventsNum** and **events[]**.| | 203 | +| const char* events[] | Pointer to the common events. The actual number of subscribed common events is the smaller value between **eventsNum** and **events**.| |
| 205 | -| int32_t eventsNum | Number of common events to subscribe. The value is the length of the **events** array.| | 204 | +| int32_t eventsNum | Number of common events to subscribe to. The value is a non-negative integer and is the length of the **events** array.| |
| 206 | 205 | ||
| 207 | **Returns** | 206 | **Returns** |
| 208 | 207 | ||
| 209 | | Type | Description| | 208 | | Type | Description| |
| 210 | |--------------------------------| -- | | 209 | |--------------------------------| -- | |
| 211 | -| [CommonEvent_SubscribeInfo](capi-oh-commonevent-commonevent-subscribeinfo.md)* | Returns the subscriber information created if the operation is successful; returns **NULL** otherwise.| | 210 | +| [CommonEvent_SubscribeInfo](capi-oh-commonevent-commonevent-subscribeinfo.md)* | Returns the subscriber information created if the operation is successful; returns **NULL** otherwise. This pointer is internally managed and is released when [OH_CommonEvent_DestroySubscribeInfo()](#oh_commonevent_destroysubscribeinfo) is called.| |
| 212 | 211 | ||
| 213 | ### OH_CommonEvent_SetPublisherPermission() | 212 | ### OH_CommonEvent_SetPublisherPermission() |
| 214 | 213 | ||
| @@ -227,8 +226,8 @@ Sets the publisher permission. | |||
| 227 | 226 | ||
| 228 | | Name| Description| | 227 | | Name| Description| |
| 229 | | -- | -- | | 228 | | -- | -- | |
| 230 | -| [CommonEvent_SubscribeInfo](capi-oh-commonevent-commonevent-subscribeinfo.md)* info | Pointer to the subscriber information.| | 229 | +| [CommonEvent_SubscribeInfo](capi-oh-commonevent-commonevent-subscribeinfo.md)* info | Pointer to the subscriber information object for which the publisher permission is to be set.| |
| 231 | -| const char* permission | Pointer to the permission name.| | 230 | +| const char* permission | Pointer to the permission name. The value is an array of permission names defined by the system. The subscriber can receive only the events from the publisher with this permission. If this parameter is not set, the subscriber can receive events from all publishers.| |
| 232 | 231 | ||
| 233 | **Returns** | 232 | **Returns** |
| 234 | 233 | ||
| @@ -253,8 +252,8 @@ Sets the publisher bundle name. | |||
| 253 | 252 | ||
| 254 | | Name| Description| | 253 | | Name| Description| |
| 255 | | -- | -- | | 254 | | -- | -- | |
| 256 | -| [CommonEvent_SubscribeInfo](capi-oh-commonevent-commonevent-subscribeinfo.md)* info | Pointer to the subscriber information.| | 255 | +| [CommonEvent_SubscribeInfo](capi-oh-commonevent-commonevent-subscribeinfo.md)* info | Pointer to the subscriber information object for which the publisher permission is to be set.| |
| 257 | -| const char* bundleName | Pointer to the bundle name.| | 256 | +| const char* bundleName | Pointer to the bundle name. This parameter is used to specify that the subscriber receives only public events published by the publisher with the specified bundle name. If this parameter is not set, the subscriber can receive all public events published by the app.| |
| 258 | 257 | ||
| 259 | **Returns** | 258 | **Returns** |
| 260 | 259 | ||
| @@ -299,13 +298,13 @@ Creates a subscriber. | |||
| 299 | | Name | Description| | 298 | | Name | Description| |
| 300 | |----------------------------------------------------------------------| -- | | 299 | |----------------------------------------------------------------------| -- | |
| 301 | | const [CommonEvent_SubscribeInfo](capi-oh-commonevent-commonevent-subscribeinfo.md)* info | Pointer to the subscriber information.| | 300 | | const [CommonEvent_SubscribeInfo](capi-oh-commonevent-commonevent-subscribeinfo.md)* info | Pointer to the subscriber information.| |
| 302 | -| [CommonEvent_ReceiveCallback](#commonevent_receivecallback) callback | Callback to be invoked when a common event is triggered.| | 301 | +| [CommonEvent_ReceiveCallback](#commonevent_receivecallback) callback | Callback to be invoked when a common event is triggered. When a common event is successfully subscribed to, the common event data is returned by **data** when the event is triggered.| |
| 303 | 302 | ||
| 304 | **Returns** | 303 | **Returns** |
| 305 | 304 | ||
| 306 | | Type| Description| | 305 | | Type| Description| |
| 307 | | -- | -- | | 306 | | -- | -- | |
| 308 | -| [CommonEvent_Subscriber](#variables)*| Returns the subscriber created if the operation is successful; returns **NULL** otherwise.| | 307 | +| [CommonEvent_Subscriber](#variables)*| Returns the subscriber created if the operation is successful; returns **NULL** otherwise. This pointer is internally managed and is released when [OH_CommonEvent_DestroySubscriber()](#oh_commonevent_destroysubscriber) is called.| |
| 309 | 308 | ||
| 310 | ### OH_CommonEvent_DestroySubscriber() | 309 | ### OH_CommonEvent_DestroySubscriber() |
| 311 | 310 | ||
| @@ -399,7 +398,7 @@ Obtains the name of a common event. | |||
| 399 | 398 | ||
| 400 | | Type| Description| | 399 | | Type| Description| |
| 401 | | -- | -- | | 400 | | -- | -- | |
| 402 | -| const char* | Name of a common event.| | 401 | +| const char* | Name of a common event. This pointer is generated by the system and is released immediately after the callback function [CommonEvent_ReceiveCallback](#commonevent_receivecallback) ends. This parameter cannot be used outside the callback function.| |
| 403 | 402 | ||
| 404 | ### OH_CommonEvent_GetCodeFromRcvData() | 403 | ### OH_CommonEvent_GetCodeFromRcvData() |
| 405 | 404 | ||
| @@ -449,7 +448,7 @@ Obtains the result data (string type) of a common event. | |||
| 449 | 448 | ||
| 450 | | Type| Description| | 449 | | Type| Description| |
| 451 | | -- | -- | | 450 | | -- | -- | |
| 452 | -| const char* | Result data (string type) of a common event.| | 451 | +| const char* | Result data (string type) of a common event. This pointer is generated by the system and is released immediately after the callback function [CommonEvent_ReceiveCallback](#commonevent_receivecallback) ends. This parameter cannot be used outside the callback function.| |
| 453 | 452 | ||
| 454 | ### OH_CommonEvent_GetBundleNameFromRcvData() | 453 | ### OH_CommonEvent_GetBundleNameFromRcvData() |
| 455 | 454 | ||
| @@ -474,7 +473,7 @@ Obtains the bundle name of a common event. | |||
| 474 | 473 | ||
| 475 | | Type| Description| | 474 | | Type| Description| |
| 476 | | -- | -- | | 475 | | -- | -- | |
| 477 | -| const char* | Bundle name obtained.| | 476 | +| const char* | Bundle name obtained. This pointer is generated by the system and is released immediately after the callback function [CommonEvent_ReceiveCallback](#commonevent_receivecallback) ends. This parameter cannot be used outside the callback function.| |
| 478 | 477 | ||
| 479 | ### OH_CommonEvent_GetParametersFromRcvData() | 478 | ### OH_CommonEvent_GetParametersFromRcvData() |
| 480 | 479 | ||
| @@ -524,7 +523,7 @@ Creates a property object of a common event. | |||
| 524 | 523 | ||
| 525 | | Type | Description| | 524 | | Type | Description| |
| 526 | |------------------------------| -- | | 525 | |------------------------------| -- | |
| 527 | -| [CommonEvent_PublishInfo](capi-oh-commonevent-commonevent-publishinfo.md)* | Returns the property object if the operation is successful; returns **NULL** otherwise.| | 526 | +| [CommonEvent_PublishInfo](capi-oh-commonevent-commonevent-publishinfo.md)* | Returns the property object if the operation is successful; returns **NULL** otherwise. This pointer is internally managed and is released when [OH_CommonEvent_DestroyPublishInfo()](#oh_commonevent_destroypublishinfo) is called.| |
| 528 | 527 | ||
| 529 | ### OH_CommonEvent_DestroyPublishInfo() | 528 | ### OH_CommonEvent_DestroyPublishInfo() |
| 530 | 529 | ||
| @@ -589,7 +588,7 @@ Sets permissions for a common event. | |||
| 589 | | Name| Description| | 588 | | Name| Description| |
| 590 | | -- | -- | | 589 | | -- | -- | |
| 591 | | [CommonEvent_PublishInfo](capi-oh-commonevent-commonevent-publishinfo.md)* info | Pointer to the property object of a common event.| | 590 | | [CommonEvent_PublishInfo](capi-oh-commonevent-commonevent-publishinfo.md)* info | Pointer to the property object of a common event.| |
| 592 | -| const char* permissions[] | Pointer to the array of permission names. The valid number of permissions is the smaller value between **num** and **permissions[]**.| | 591 | +| const char* permissions[] | Subscriber permissions. Only subscribers with the specified permissions can receive the common event. The valid number of permissions is the smaller value between **num** and **permissions**.| |
| 593 | | int32_t num | Number of permission names. The value is the length of the **permissions** array.| | 592 | | int32_t num | Number of permission names. The value is the length of the **permissions** array.| |
| 594 | 593 | ||
| 595 | **Returns** | 594 | **Returns** |
| @@ -693,7 +692,7 @@ Creates an additional information object of a common event. | |||
| 693 | 692 | ||
| 694 | | Type| Description| | 693 | | Type| Description| |
| 695 | | -- | -- | | 694 | | -- | -- | |
| 696 | -| [CommonEvent_Parameters](#variables)*| Returns additional information of the common event if operation is successful; returns **NULL** otherwise.| | 695 | +| [CommonEvent_Parameters](#variables)*| Returns additional information of the common event if operation is successful; returns **NULL** otherwise. This pointer is internally managed and is released when [OH_CommonEvent_DestroyParameters()](#oh_commonevent_destroyparameters) is called.| |
| 697 | 696 | ||
| 698 | ### OH_CommonEvent_DestroyParameters() | 697 | ### OH_CommonEvent_DestroyParameters() |
| 699 | 698 | ||
| @@ -840,7 +839,7 @@ Sets the int array with a specific key for the additional information of a commo | |||
| 840 | | -- | -- | | 839 | | -- | -- | |
| 841 | | [CommonEvent_Parameters](#variables)* param| Pointer to the additional information of a common event.| | 840 | | [CommonEvent_Parameters](#variables)* param| Pointer to the additional information of a common event.| |
| 842 | | const char* key | Pointer to the key.| | 841 | | const char* key | Pointer to the key.| |
| 843 | -| const int* value | The int array to set.| | 842 | +| const int* value | The int array to set. The actual number of elements is **num**. The length of the **value** array must be greater than **num**. Otherwise, out-of-bounds access may occur.| |
| 844 | | size_t num | Number of elements in the int array.| | 843 | | size_t num | Number of elements in the int array.| |
| 845 | 844 | ||
| 846 | **Returns** | 845 | **Returns** |
| @@ -949,7 +948,7 @@ Sets the long array for the additional information of a common event. | |||
| 949 | | -- | -- | | 948 | | -- | -- | |
| 950 | | [CommonEvent_Parameters](#variables)* param| Pointer to the additional information of a common event.| | 949 | | [CommonEvent_Parameters](#variables)* param| Pointer to the additional information of a common event.| |
| 951 | | const char* key | Pointer to the key.| | 950 | | const char* key | Pointer to the key.| |
| 952 | -| const long* value | Pointer to the long array to set.| | 951 | +| const long* value | Pointer to the long array to set. The actual number of elements is **num**. The length of the **value** array must be greater than **num**. Otherwise, out-of-bounds access may occur.| |
| 953 | | size_t num | Number of elements in the long array.| | 952 | | size_t num | Number of elements in the long array.| |
| 954 | 953 | ||
| 955 | **Returns** | 954 | **Returns** |
| @@ -1058,7 +1057,7 @@ Sets the Boolean array with a specific key for the additional information of a c | |||
| 1058 | | -- | -- | | 1057 | | -- | -- | |
| 1059 | | [CommonEvent_Parameters](#variables)* param| Pointer to the additional information of a common event.| | 1058 | | [CommonEvent_Parameters](#variables)* param| Pointer to the additional information of a common event.| |
| 1060 | | const char* key | Pointer to the key.| | 1059 | | const char* key | Pointer to the key.| |
| 1061 | -| const bool* value | Pointer to the Boolean array to set.| | 1060 | +| const bool* value | Pointer to the Boolean array to set. The actual number of elements is **num**. The length of the **value** array must be greater than **num**. Otherwise, out-of-bounds access may occur.| |
| 1062 | | size_t num | Number of elements in the Boolean array.| | 1061 | | size_t num | Number of elements in the Boolean array.| |
| 1063 | 1062 | ||
| 1064 | **Returns** | 1063 | **Returns** |
| @@ -1167,7 +1166,7 @@ Sets the character array with a specific key for the additional information of a | |||
| 1167 | | -- | -- | | 1166 | | -- | -- | |
| 1168 | | [CommonEvent_Parameters](#variables)* param| Pointer to the additional information of a common event.| | 1167 | | [CommonEvent_Parameters](#variables)* param| Pointer to the additional information of a common event.| |
| 1169 | | const char* key | Pointer to the key.| | 1168 | | const char* key | Pointer to the key.| |
| 1170 | -| const char* value | Pointer to the character array to set.| | 1169 | +| const char* value | Pointer to the character array to set. The actual number of elements is the smaller value between **num** and the length of the **value** array.| |
| 1171 | | size_t num | Number of elements in the character array.| | 1170 | | size_t num | Number of elements in the character array.| |
| 1172 | 1171 | ||
| 1173 | **Returns** | 1172 | **Returns** |
| @@ -1276,7 +1275,7 @@ Sets the double array with a specific key for the additional information of a co | |||
| 1276 | | -- | -- | | 1275 | | -- | -- | |
| 1277 | | [CommonEvent_Parameters](#variables)* param| Pointer to the additional information of a common event.| | 1276 | | [CommonEvent_Parameters](#variables)* param| Pointer to the additional information of a common event.| |
| 1278 | | const char* key | Pointer to the key.| | 1277 | | const char* key | Pointer to the key.| |
| 1279 | -| const double* value | Pointer to the double array to set.| | 1278 | +| const double* value | Pointer to the double array to set. The actual number of elements is **num**. The length of the **value** array must be greater than **num**. Otherwise, out-of-bounds access may occur.| |
| 1280 | | size_t num | Number of elements in the double array.| | 1279 | | size_t num | Number of elements in the double array.| |
| 1281 | 1280 | ||
| 1282 | **Returns** | 1281 | **Returns** |
| @@ -1308,7 +1307,7 @@ Publishes a common event. | |||
| 1308 | 1307 | ||
| 1309 | | Type| Description| | 1308 | | Type| Description| |
| 1310 | | -- | -- | | 1309 | | -- | -- | |
| 1311 | -| [CommonEvent_ErrCode](#commonevent_errcode) | Returns an execution result.<br> [COMMONEVENT_ERR_OK](capi-oh-commonevent-h.md#commonevent_errcode): Operation is successful.<br> [COMMONEVENT_ERR_INVALID_PARAMETER](capi-oh-commonevent-h.md#commonevent_errcode): The parameter is invalid.<br> [COMMONEVENT_ERR_SENDING_LIMIT_EXCEEDED](capi-oh-commonevent-h.md#commonevent_errcode): Event sending frequency is too high.<br> [COMMONEVENT_ERR_SENDING_REQUEST_FAILED](capi-oh-commonevent-h.md#commonevent_errcode): Failed to send IPC requests.<br> [COMMONEVENT_ERR_INIT_UNDONE](capi-oh-commonevent-h.md#commonevent_errcode): The common event service is not initialized.| | 1310 | +| [CommonEvent_ErrCode](#commonevent_errcode) | Returns an execution result.<br> [COMMONEVENT_ERR_OK](capi-oh-commonevent-h.md#commonevent_errcode): Operation is successful.<br> [COMMONEVENT_ERR_INVALID_PARAMETER](capi-oh-commonevent-h.md#commonevent_errcode): The parameter is invalid.<br> [COMMONEVENT_ERR_SENDING_LIMIT_EXCEEDED](capi-oh-commonevent-h.md#commonevent_errcode): Event sending frequency is too high.<br> [COMMONEVENT_ERR_SENDING_REQUEST_FAILED](capi-oh-commonevent-h.md#commonevent_errcode): Failed to send IPC requests.<br> [COMMONEVENT_ERR_INIT_UNDONE](capi-oh-commonevent-h.md#commonevent_errcode): The common event service is not initialized. [COMMONEVENT_ERR_NOT_SYSTEM_SERVICE](capi-oh-commonevent-h.md#commonevent_errcode): The third-party app cannot send system common events.| |
| 1312 | 1311 | ||
| 1313 | ### OH_CommonEvent_PublishWithInfo() | 1312 | ### OH_CommonEvent_PublishWithInfo() |
| 1314 | 1313 | ||
| @@ -26,7 +26,7 @@ Provides common event constants defined by the system. | |||
| 26 | 26 | ||
| 27 | | Name| Description| | 27 | | Name| Description| |
| 28 | | -- | -- | | 28 | | -- | -- | |
| 29 | -| static const char * const COMMON_EVENT_SHUTDOWN = "usual.event.SHUTDOWN" | Indicates the common event that the device is being shut down and the final shutdown will proceed.<br>**Since**: 12<br>**System capability**: SystemCapability.Notification.CommonEvent| | 29 | +| static const char * const COMMON_EVENT_SHUTDOWN = "usual.event.SHUTDOWN" | Indicates the common event that the device is being shut down and the final shutdown will proceed.<br>**Since**: 12| |
| 30 | | static const char * const COMMON_EVENT_BATTERY_CHANGED = "usual.event.BATTERY_CHANGED" | Indicates the common event that the charging state, level, and other information about the battery have changed.<br>**Since**: 12| | 30 | | static const char * const COMMON_EVENT_BATTERY_CHANGED = "usual.event.BATTERY_CHANGED" | Indicates the common event that the charging state, level, and other information about the battery have changed.<br>**Since**: 12| |
| 31 | | static const char * const COMMON_EVENT_BATTERY_LOW = "usual.event.BATTERY_LOW" | Indicates the common event that the battery level is low.<br>**Since**: 12| | 31 | | static const char * const COMMON_EVENT_BATTERY_LOW = "usual.event.BATTERY_LOW" | Indicates the common event that the battery level is low.<br>**Since**: 12| |
| 32 | | static const char * const COMMON_EVENT_BATTERY_OKAY = "usual.event.BATTERY_OKAY" | Indicates the common event that the battery exits the low state.<br>**Since**: 12| | 32 | | static const char * const COMMON_EVENT_BATTERY_OKAY = "usual.event.BATTERY_OKAY" | Indicates the common event that the battery exits the low state.<br>**Since**: 12| |
Men/application-dev/reference/apis-basic-services-kit/common_event/commonEventManager-definitions.md+8-6
| @@ -126,7 +126,7 @@ When a specified application package is removed by a specified user on the devic | |||
| 126 | 126 | ||
| 127 | ### COMMON_EVENT_BUNDLE_REMOVED | 127 | ### COMMON_EVENT_BUNDLE_REMOVED |
| 128 | 128 | ||
| 129 | -Indicates that an installed bundle has been uninstalled from the device. | 129 | +(Reserved, not supported yet) Indicates that an installed bundle has been uninstalled from the device. |
| 130 | 130 | ||
| 131 | **System capability**: SystemCapability.Notification.CommonEvent | 131 | **System capability**: SystemCapability.Notification.CommonEvent |
| 132 | 132 | ||
| @@ -186,7 +186,7 @@ When the cache of an application package installed on the device is cleared, the | |||
| 186 | 186 | ||
| 187 | ### COMMON_EVENT_PACKAGES_SUSPENDED | 187 | ### COMMON_EVENT_PACKAGES_SUSPENDED |
| 188 | 188 | ||
| 189 | -Indicates that application packages have been suspended. | 189 | +(Reserved, not supported yet) Indicates that the package has been suspended. |
| 190 | 190 | ||
| 191 | **System capability**: SystemCapability.Notification.CommonEvent | 191 | **System capability**: SystemCapability.Notification.CommonEvent |
| 192 | 192 | ||
| @@ -197,7 +197,7 @@ Indicates that application packages have been suspended. | |||
| 197 | 197 | ||
| 198 | ### COMMON_EVENT_MY_PACKAGE_SUSPENDED | 198 | ### COMMON_EVENT_MY_PACKAGE_SUSPENDED |
| 199 | 199 | ||
| 200 | -Indicates that application packages have been suspended by the system. | 200 | +(Reserved, not supported yet) Indicates that application packages have been suspended by the system. |
| 201 | 201 | ||
| 202 | **System capability**: SystemCapability.Notification.CommonEvent | 202 | **System capability**: SystemCapability.Notification.CommonEvent |
| 203 | 203 | ||
| @@ -208,7 +208,7 @@ Indicates that application packages have been suspended by the system. | |||
| 208 | 208 | ||
| 209 | ### COMMON_EVENT_MY_PACKAGE_UNSUSPENDED | 209 | ### COMMON_EVENT_MY_PACKAGE_UNSUSPENDED |
| 210 | 210 | ||
| 211 | -Indicates that application packages have been unsuspended by the system. | 211 | +(Reserved, not supported yet) Indicates that application packages have been unsuspended by the system. |
| 212 | 212 | ||
| 213 | **System capability**: SystemCapability.Notification.CommonEvent | 213 | **System capability**: SystemCapability.Notification.CommonEvent |
| 214 | 214 | ||
| @@ -611,7 +611,7 @@ When the battery level drops to lower than the low battery level set for the dev | |||
| 611 | 611 | ||
| 612 | Indicates that the battery level is normal. | 612 | Indicates that the battery level is normal. |
| 613 | 613 | ||
| 614 | -When the battery level changes from the low level to normal level, the event notification service is triggered to publish this event. | 614 | +When the battery level increases from a low level to a level higher than the low level, the event notification service is triggered to publish this event. |
| 615 | 615 | ||
| 616 | 616 | ||
| 617 | **System capability**: SystemCapability.Notification.CommonEvent | 617 | **System capability**: SystemCapability.Notification.CommonEvent |
| @@ -1336,8 +1336,10 @@ When the signal information of the device is updated, the event notification ser | |||
| 1336 | This topic lists the common system events provided by the AppGallery Kit to applications. | 1336 | This topic lists the common system events provided by the AppGallery Kit to applications. |
| 1337 | 1337 | ||
| 1338 | ### COMMON_EVENT_PRIVACY_STATE_CHANGED<sup>11+</sup> | 1338 | ### COMMON_EVENT_PRIVACY_STATE_CHANGED<sup>11+</sup> |
| 1339 | + | ||
| 1339 | Indicates the privacy state has been changed. | 1340 | Indicates the privacy state has been changed. |
| 1340 | -When a user clicks **Agree** in a privacy dialog box, the event notification service is triggered to publish this event. | 1341 | + |
| 1342 | +When a user taps the agree button in the privacy statement dialog box, the event notification service is triggered to publish this event. | ||
| 1341 | 1343 | ||
| 1342 | **System capability**: SystemCapability.Notification.CommonEvent | 1344 | **System capability**: SystemCapability.Notification.CommonEvent |
| 1343 | 1345 | ||
| @@ -1,4 +1,4 @@ | |||
| 1 | -# Event Error Codes | 1 | +# Common Event Error Codes |
| 2 | <!--Kit: Basic Services Kit--> | 2 | <!--Kit: Basic Services Kit--> |
| 3 | <!--Subsystem: Notification--> | 3 | <!--Subsystem: Notification--> |
| 4 | <!--Owner: @HuYueRong--> | 4 | <!--Owner: @HuYueRong--> |
| @@ -58,11 +58,11 @@ The frequency at which the application sends common events exceeds the system li | |||
| 58 | 58 | ||
| 59 | **Possible Causes** | 59 | **Possible Causes** |
| 60 | 60 | ||
| 61 | -The number of events sent by the application within a short period of time exceeds the system limit, triggering frequency control. | 61 | +More than 20 common events are sent per 5 milliseconds, triggering the system frequency limit. |
| 62 | 62 | ||
| 63 | **Solution** | 63 | **Solution** |
| 64 | 64 | ||
| 65 | -Check whether the application sends common events too frequently. If so, reduce the event sending frequency or increase the sending interval and try again. | 65 | +Check whether the application sends common events too frequently. If more than 20 common events are sent every 5 milliseconds, reduce the common event sending frequency or increase the sending interval and try again. |
| 66 | 66 | ||
| 67 | ## 1500004 Failed to Send System Common Events | 67 | ## 1500004 Failed to Send System Common Events |
| 68 | 68 | ||
| @@ -0,0 +1,37 @@ | |||
| 1 | +# PrintExtensionContext | ||
| 2 | + | ||
| 3 | +<!--Kit: Basic Services Kit--> | ||
| 4 | +<!--Subsystem: Print--> | ||
| 5 | +<!--Owner: @guoshengbang--> | ||
| 6 | +<!--Designer: @baozewei--> | ||
| 7 | +<!--Tester: @baozewei--> | ||
| 8 | +<!--Adviser: @fang-jinxu--> | ||
| 9 | + | ||
| 10 | +**PrintExtensionContext** represents the context of **PrintExtensionAbility** and is inherited from [ExtensionContext](../apis-ability-kit/js-apis-inner-application-extensionContext.md). | ||
| 11 | + | ||
| 12 | +It can be directly used as the context of **PrintExtensionAbility** to obtain and manage printing resources for printing extension development, so as to complete printing tasks. For details about the design logic and accessible resources of **PrintExtensionContext**, see [PrintExtensionAbility](js-apis-app-ability-PrintExtensionAbility.md) and [ExtensionContext](../apis-ability-kit/js-apis-inner-application-extensionContext.md). | ||
| 13 | + | ||
| 14 | +> **NOTE** | ||
| 15 | +> | ||
| 16 | +> - The APIs of this module can be used only in the stage model. | ||
| 17 | +> - **Since:** 26.0.0 | ||
| 18 | + | ||
| 19 | +## Modules to Import | ||
| 20 | +```ts | ||
| 21 | +import { PrintExtensionAbility } from '@kit.BasicServicesKit'; | ||
| 22 | +``` | ||
| 23 | +## How to Use | ||
| 24 | + | ||
| 25 | +Obtain **PrintExtensionContext** through a **PrintExtensionAbility** child class instance. | ||
| 26 | + | ||
| 27 | +```ts | ||
| 28 | +import { PrintExtensionAbility } from '@kit.BasicServicesKit'; | ||
| 29 | +import { Want } from '@kit.AbilityKit'; | ||
| 30 | + | ||
| 31 | +export default class PrintExtension extends PrintExtensionAbility { | ||
| 32 | + | ||
| 33 | + onCreate(want: Want) { | ||
| 34 | + let context = this.context; // Obtain PrintExtensionContext, which can be used to access printing resources. | ||
| 35 | + } | ||
| 36 | +} | ||
| 37 | +``` | ||
| @@ -1,14 +1,12 @@ | |||
| 1 | # @ohos.commonEventManager (Common Event) (System API) | 1 | # @ohos.commonEventManager (Common Event) (System API) |
| 2 | - | ||
| 3 | <!--Kit: Basic Services Kit--> | 2 | <!--Kit: Basic Services Kit--> |
| 4 | <!--Subsystem: Notification--> | 3 | <!--Subsystem: Notification--> |
| 5 | <!--Owner: @HuYueRong--> | 4 | <!--Owner: @HuYueRong--> |
| 6 | <!--Designer: @dongqingran--> | 5 | <!--Designer: @dongqingran--> |
| 7 | <!--Tester: @wanghong1997--> | 6 | <!--Tester: @wanghong1997--> |
| 8 | <!--Adviser: @fang-jinxu--> | 7 | <!--Adviser: @fang-jinxu--> |
| 9 | -<!-- md-trans-meta sourceCommit=5b716a0e1c062ed98c8e1f363a9507fe09b52f56 translatedAt=2026-07-21T02:32:52.027Z pushedAt=2026-07-21T07:45:40.309Z --> | ||
| 10 | 8 | ||
| 11 | -This module provides system APIs related to common events, including publishing common events to specified users, removing sticky common events, and enabling or disabling static subscription events. | 9 | +This module provides system APIs to publish common events to specified users, remove sticky common events, enable or disable static subscription events. |
| 12 | 10 | ||
| 13 | > **NOTE** | 11 | > **NOTE** |
| 14 | > | 12 | > |
| @@ -48,7 +46,7 @@ Publishes a common event to a specified user. This API uses an asynchronous call | |||
| 48 | 46 | ||
| 49 | **Error codes** | 47 | **Error codes** |
| 50 | 48 | ||
| 51 | -For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Event Error Codes](./errorcode-CommonEventService.md). | 49 | +For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 52 | 50 | ||
| 53 | | ID| Error Message | | 51 | | ID| Error Message | |
| 54 | | -------- | ----------------------------------- | | 52 | | -------- | ----------------------------------- | |
| @@ -103,7 +101,7 @@ Publishes a common event to a specified user and specifies the information to be | |||
| 103 | 101 | ||
| 104 | **Error codes** | 102 | **Error codes** |
| 105 | 103 | ||
| 106 | -For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Event Error Codes](./errorcode-CommonEventService.md). | 104 | +For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 107 | 105 | ||
| 108 | | ID| Error Message | | 106 | | ID| Error Message | |
| 109 | | -------- | ----------------------------------- | | 107 | | -------- | ----------------------------------- | |
| @@ -163,7 +161,7 @@ Removes a sticky common event. This API uses an asynchronous callback to return | |||
| 163 | 161 | ||
| 164 | **Error codes** | 162 | **Error codes** |
| 165 | 163 | ||
| 166 | -For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Event Error Codes](./errorcode-CommonEventService.md). | 164 | +For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 167 | 165 | ||
| 168 | | ID| Error Message | | 166 | | ID| Error Message | |
| 169 | | -------- | ----------------------------------- | | 167 | | -------- | ----------------------------------- | |
| @@ -214,7 +212,7 @@ Removes a sticky common event that has been published. This API uses a promise t | |||
| 214 | 212 | ||
| 215 | **Error codes** | 213 | **Error codes** |
| 216 | 214 | ||
| 217 | -For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Event Error Codes](./errorcode-CommonEventService.md). | 215 | +For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 218 | 216 | ||
| 219 | | ID| Error Message | | 217 | | ID| Error Message | |
| 220 | | -------- | ----------------------------------- | | 218 | | -------- | ----------------------------------- | |
| @@ -258,7 +256,7 @@ Enables or disables static subscription for an app. This API uses an asynchronou | |||
| 258 | 256 | ||
| 259 | **Error codes** | 257 | **Error codes** |
| 260 | 258 | ||
| 261 | -For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Event Error Codes](./errorcode-CommonEventService.md). | 259 | +For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 262 | 260 | ||
| 263 | | ID| Error Message | | 261 | | ID| Error Message | |
| 264 | | -------- | ----------------------------------- | | 262 | | -------- | ----------------------------------- | |
| @@ -307,7 +305,7 @@ Enables or disables static subscription for an app. This API uses a promise to r | |||
| 307 | 305 | ||
| 308 | **Error codes** | 306 | **Error codes** |
| 309 | 307 | ||
| 310 | -For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Event Error Codes](./errorcode-CommonEventService.md). | 308 | +For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 311 | 309 | ||
| 312 | | ID| Error Message | | 310 | | ID| Error Message | |
| 313 | | -------- | ----------------------------------- | | 311 | | -------- | ----------------------------------- | |
| @@ -318,6 +316,7 @@ For details about the error codes, see [Universal Error Codes](../errorcode-univ | |||
| 318 | 316 | ||
| 319 | **Example** | 317 | **Example** |
| 320 | 318 | ||
| 319 | + | ||
| 321 | ```ts | 320 | ```ts |
| 322 | import { BusinessError } from '@kit.BasicServicesKit'; | 321 | import { BusinessError } from '@kit.BasicServicesKit'; |
| 323 | 322 | ||
| @@ -355,7 +354,7 @@ Enables or disables static subscription to a common event for the current app. T | |||
| 355 | 354 | ||
| 356 | **Error codes** | 355 | **Error codes** |
| 357 | 356 | ||
| 358 | -For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Event Error Codes](./errorcode-CommonEventService.md). | 357 | +For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 359 | 358 | ||
| 360 | | ID| Error Message | | 359 | | ID| Error Message | |
| 361 | | -------- | ------------------------------------------------------ | | 360 | | -------- | ------------------------------------------------------ | |
| @@ -1,22 +1,17 @@ | |||
| 1 | # @ohos.commonEventManager (Common Event) | 1 | # @ohos.commonEventManager (Common Event) |
| 2 | - | ||
| 3 | <!--Kit: Basic Services Kit--> | 2 | <!--Kit: Basic Services Kit--> |
| 4 | <!--Subsystem: Notification--> | 3 | <!--Subsystem: Notification--> |
| 5 | <!--Owner: @HuYueRong--> | 4 | <!--Owner: @HuYueRong--> |
| 6 | <!--Designer: @dongqingran--> | 5 | <!--Designer: @dongqingran--> |
| 7 | <!--Tester: @wanghong1997--> | 6 | <!--Tester: @wanghong1997--> |
| 8 | <!--Adviser: @fang-jinxu--> | 7 | <!--Adviser: @fang-jinxu--> |
| 9 | -<!-- md-trans-meta sourceCommit=5b716a0e1c062ed98c8e1f363a9507fe09b52f56 translatedAt=2026-07-21T02:33:50.547Z pushedAt=2026-07-21T07:45:40.311Z --> | ||
| 10 | 8 | ||
| 11 | This module provides APIs to publish, subscribe to, and unsubscribe from common events. This module provides a system-level event notification mechanism that allows an app to send notifications to other apps that have subscribed to the event when the system status changes (such as power-on completion, battery level change, and screen on/off) or a custom service event occurs. This mechanism enables transferring information across components and apps. | 9 | This module provides APIs to publish, subscribe to, and unsubscribe from common events. This module provides a system-level event notification mechanism that allows an app to send notifications to other apps that have subscribed to the event when the system status changes (such as power-on completion, battery level change, and screen on/off) or a custom service event occurs. This mechanism enables transferring information across components and apps. |
| 12 | 10 | ||
| 13 | The key concepts involved in this module are as follows: | 11 | The key concepts involved in this module are as follows: |
| 14 | - | ||
| 15 | - Unordered common events: common events that CES forwards regardless of whether subscribers receive the events and when they subscribe to the events. | 12 | - Unordered common events: common events that CES forwards regardless of whether subscribers receive the events and when they subscribe to the events. |
| 16 | - | 13 | +- Ordered common events: common events that CES forwards based on the subscriber priority. CES preferentially forwards an ordered common event to the subscriber with higher priority, waits until the subscriber receives the event, and then forwards the events to the subscriber with lower priority. Subscribers with the same priority receive common events in a random order. |
| 17 | -- Ordered common events: common events that CES forwards based on the subscriber priority. CES preferentially forwards an ordered common event to the subscriber with a higher priority, waits until the subscriber receives the event, and then forwards the event to the subscriber with a lower priority. Subscribers with the same priority receive common events in a random order. | 14 | +- Sticky common events: common events that can be sent to a subscriber before or after they initiate a subscription. Only system apps or services can send sticky common events. |
| 18 | - | ||
| 19 | -- Sticky common events: common events that can be sent to a subscriber before or after the subscriber initiates a subscription. Only system applications and system services can send sticky common events. | ||
| 20 | 15 | ||
| 21 | **APIs used in combination** | 16 | **APIs used in combination** |
| 22 | 17 | ||
| @@ -25,25 +20,19 @@ The event communication of this module involves three processes: subscription, p | |||
| 25 | **Subscription process: Create a subscriber, subscribe to an event, receive the event, and cancel the subscription.** | 20 | **Subscription process: Create a subscriber, subscribe to an event, receive the event, and cancel the subscription.** |
| 26 | 21 | ||
| 27 | 1. Configure the subscriber information, declare the name of the event to be subscribed to, and set the subscription priority, publisher permission, and package name as required. | 22 | 1. Configure the subscriber information, declare the name of the event to be subscribed to, and set the subscription priority, publisher permission, and package name as required. |
| 28 | - | ||
| 29 | 2. Create a subscriber object using **commonEventManager.createSubscriberSync**. | 23 | 2. Create a subscriber object using **commonEventManager.createSubscriberSync**. |
| 30 | - | ||
| 31 | 3. Subscribe to an event using **commonEventManager.subscribe**. When an event is published, use a callback to receive **CommonEventData**, and process the event data in the callback. | 24 | 3. Subscribe to an event using **commonEventManager.subscribe**. When an event is published, use a callback to receive **CommonEventData**, and process the event data in the callback. |
| 32 | - | ||
| 33 | 4. Unsubscribe from the event using **commonEventManager.unsubscribe** when it is no longer needed. | 25 | 4. Unsubscribe from the event using **commonEventManager.unsubscribe** when it is no longer needed. |
| 34 | 26 | ||
| 35 | **Publishing process: Publish an event (carrying data and attributes as required).** | 27 | **Publishing process: Publish an event (carrying data and attributes as required).** |
| 36 | 28 | ||
| 37 | 1. Simple publishing: Publish an event by specifying only the event name using **commonEventManager.publish**. | 29 | 1. Simple publishing: Publish an event by specifying only the event name using **commonEventManager.publish**. |
| 38 | - | ||
| 39 | 2. Publishing with data and attributes: Configure attributes such as code, data, parameters, and **isOrdered** using **CommonEventPublishData**, and then call **publish** to publish the event. | 30 | 2. Publishing with data and attributes: Configure attributes such as code, data, parameters, and **isOrdered** using **CommonEventPublishData**, and then call **publish** to publish the event. |
| 40 | 31 | ||
| 41 | **Ordered event process: Deliver the event by priority by collaborating with the subscriber.** | 32 | **Ordered event process: Deliver the event by priority by collaborating with the subscriber.** |
| 42 | 33 | ||
| 43 | 1. Set **isOrdered** to **true** using **CommonEventPublishData** and call **publish** to publish ordered events. Events are delivered in sequence based on the subscriber priority. | 34 | 1. Set **isOrdered** to **true** using **CommonEventPublishData** and call **publish** to publish ordered events. Events are delivered in sequence based on the subscriber priority. |
| 44 | - | ||
| 45 | 2. The subscriber with a higher priority receives the event first, who can modify the code and data in the callback using methods such as **setCodeAndData** for subsequent subscribers to receive. | 35 | 2. The subscriber with a higher priority receives the event first, who can modify the code and data in the callback using methods such as **setCodeAndData** for subsequent subscribers to receive. |
| 46 | - | ||
| 47 | 3. After the processing is complete, call **finishCommonEvent** to deliver the event to the subscriber with the next highest priority. To stop delivering the event, call **abortCommonEvent** to mark the event as aborted. | 36 | 3. After the processing is complete, call **finishCommonEvent** to deliver the event to the subscriber with the next highest priority. To stop delivering the event, call **abortCommonEvent** to mark the event as aborted. |
| 48 | 37 | ||
| 49 | > **NOTE** | 38 | > **NOTE** |
| @@ -75,11 +64,11 @@ Publishes a common event. This API uses an asynchronous callback to return the r | |||
| 75 | | Name | Type | Mandatory| Description | | 64 | | Name | Type | Mandatory| Description | |
| 76 | | -------- | -------------------- | ---- | ---------------------- | | 65 | | -------- | -------------------- | ---- | ---------------------- | |
| 77 | | event | string | Yes | Name of the common event to publish. For details, see [System Common Events](./common_event/commonEventManager-definitions.md).| | 66 | | event | string | Yes | Name of the common event to publish. For details, see [System Common Events](./common_event/commonEventManager-definitions.md).| |
| 78 | -| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the common event is successfully published, **err** is **undefined**; otherwise, **err** is an error object. | | 67 | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the common event is successfully published, **err** is **undefined**; if the event fails to be published, **err** is an error object.| |
| 79 | 68 | ||
| 80 | **Error codes** | 69 | **Error codes** |
| 81 | 70 | ||
| 82 | -For details about the error codes, see [Event Error Codes](./errorcode-CommonEventService.md). | 71 | +For details about the error codes, see [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 83 | 72 | ||
| 84 | | ID| Error Message | | 73 | | ID| Error Message | |
| 85 | | -------- | ----------------------------------- | | 74 | | -------- | ----------------------------------- | |
| @@ -123,12 +112,12 @@ Publishes a common event. This API uses an asynchronous callback to return the r | |||
| 123 | | Name | Type | Mandatory| Description | | 112 | | Name | Type | Mandatory| Description | |
| 124 | | -------- | ---------------------- | ---- | ---------------------- | | 113 | | -------- | ---------------------- | ---- | ---------------------- | |
| 125 | | event | string | Yes | Name of the common event to publish. For details, see [System Common Events](./common_event/commonEventManager-definitions.md). | | 114 | | event | string | Yes | Name of the common event to publish. For details, see [System Common Events](./common_event/commonEventManager-definitions.md). | |
| 126 | -| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | Yes | Attributes of the common event to publish.| | 115 | +| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | Yes | Properties of the common event to publish.| |
| 127 | -| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the common event is published successfully, **err** is **undefined**; otherwise, **err** is an error object. | | 116 | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the common event is successfully published, **err** is **undefined**; if the event fails to be published, **err** is an error object. | |
| 128 | 117 | ||
| 129 | **Error codes** | 118 | **Error codes** |
| 130 | 119 | ||
| 131 | -For details about the error codes, see [Event Error Codes](./errorcode-CommonEventService.md). | 120 | +For details about the error codes, see [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 132 | 121 | ||
| 133 | | ID| Error Message | | 122 | | ID| Error Message | |
| 134 | | -------- | ----------------------------------- | | 123 | | -------- | ----------------------------------- | |
| @@ -179,7 +168,7 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul | |||
| 179 | | Name | Type | Mandatory| Description | | 168 | | Name | Type | Mandatory| Description | |
| 180 | | ------------- | ------------------------------------------------------------ | ---- | -------------------------- | | 169 | | ------------- | ------------------------------------------------------------ | ---- | -------------------------- | |
| 181 | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. | | 170 | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. | |
| 182 | -| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md#commoneventsubscriber-1)> | Yes | Callback used to return the result. If the common event subscriber is created successfully, **err** is **undefined** and **data** is the created **CommonEventSubscriber** object; if the creation fails, **err** is an error object. | | 171 | +| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md#commoneventsubscriber-1)> | Yes | Callback used to receive the created subscriber object. When a common event subscriber is successfully created, **err** is **undefined** and **data** is the **CommonEventSubscriber** object created. If the subscriber fails to be created, **err** is an error object.| |
| 183 | 172 | ||
| 184 | **Error codes** | 173 | **Error codes** |
| 185 | 174 | ||
| @@ -235,7 +224,6 @@ Creates a subscriber. This API uses a promise to return the result. | |||
| 235 | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information.| | 224 | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information.| |
| 236 | 225 | ||
| 237 | **Return value** | 226 | **Return value** |
| 238 | - | ||
| 239 | | Type | Description | | 227 | | Type | Description | |
| 240 | | --------------------------------------------------------- | ---------------- | | 228 | | --------------------------------------------------------- | ---------------- | |
| 241 | | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md#commoneventsubscriber-1)> | Promise used to return the created subscriber object.| | 229 | | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md#commoneventsubscriber-1)> | Promise used to return the created subscriber object.| |
| @@ -285,7 +273,6 @@ Creates a subscriber synchronously. | |||
| 285 | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information.| | 273 | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information.| |
| 286 | 274 | ||
| 287 | **Return value** | 275 | **Return value** |
| 288 | - | ||
| 289 | | Type | Description | | 276 | | Type | Description | |
| 290 | | --------------------------------------------------------- | ---------------- | | 277 | | --------------------------------------------------------- | ---------------- | |
| 291 | | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md#commoneventsubscriber-1) | Promise used to return the subscriber object.| | 278 | | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md#commoneventsubscriber-1) | Promise used to return the subscriber object.| |
| @@ -337,7 +324,7 @@ Subscribes to a common event. This API uses an asynchronous callback to return t | |||
| 337 | 324 | ||
| 338 | **Error codes** | 325 | **Error codes** |
| 339 | 326 | ||
| 340 | -For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Event Error Codes](./errorcode-CommonEventService.md). | 327 | +For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 341 | 328 | ||
| 342 | | ID| Error Message | | 329 | | ID| Error Message | |
| 343 | | -------- | ----------------------------------- | | 330 | | -------- | ----------------------------------- | |
| @@ -403,11 +390,11 @@ Unsubscribes from a common event. This API uses an asynchronous callback to retu | |||
| 403 | | Name | Type | Mandatory| Description | | 390 | | Name | Type | Mandatory| Description | |
| 404 | | ---------- | ----------------------------------------------- | ---- | ------------------------ | | 391 | | ---------- | ----------------------------------------------- | ---- | ------------------------ | |
| 405 | | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md#commoneventsubscriber-1) | Yes | Subscriber object. | | 392 | | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md#commoneventsubscriber-1) | Yes | Subscriber object. | |
| 406 | -| callback | AsyncCallback\<void> | No | Callback used to return the result. If the unsubscription is successful, **err** is undefined; otherwise, **err** is an error object. If this parameter is not passed, the subscription is unsubscribed by default without returning a result. | | 393 | +| callback | AsyncCallback\<void> | No | Callback used to return the result. If the common event is successfully unsubscribed from, **err** is **undefined**; if the unsubscription fails, **err** is an error object. If this parameter is not passed, the subscription is canceled by default and no result is returned.| |
| 407 | 394 | ||
| 408 | **Error codes** | 395 | **Error codes** |
| 409 | 396 | ||
| 410 | -For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Event Error Codes](./errorcode-CommonEventService.md). | 397 | +For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 411 | 398 | ||
| 412 | | ID| Error Message | | 399 | | ID| Error Message | |
| 413 | | -------- | ----------------------------------- | | 400 | | -------- | ----------------------------------- | |
| @@ -495,16 +482,15 @@ Subscribes to a common event. This API uses a promise to return the result. | |||
| 495 | | callback | Callback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | Yes | Callback to be invoked when a common event is subscribed to.| | 482 | | callback | Callback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | Yes | Callback to be invoked when a common event is subscribed to.| |
| 496 | 483 | ||
| 497 | **Return value** | 484 | **Return value** |
| 498 | - | ||
| 499 | | Type | Description | | 485 | | Type | Description | |
| 500 | | --------------------------------------------------------- | ---------------- | | 486 | | --------------------------------------------------------- | ---------------- | |
| 501 | | Promise\<void> | Promise that returns no value.| | 487 | | Promise\<void> | Promise that returns no value.| |
| 502 | 488 | ||
| 503 | **Error codes** | 489 | **Error codes** |
| 504 | 490 | ||
| 505 | -For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Event Error Codes](./errorcode-CommonEventService.md). | 491 | +For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Common Event Error Codes](./errorcode-CommonEventService.md). |
| 506 | 492 | ||
| 507 | -| ID| Error Message | | 493 | +| ID| Error Message | |
| 508 | | -------- | ----------------------------------- | | 494 | | -------- | ----------------------------------- | |
| 509 | | 801 | Capability not supported. | | 495 | | 801 | Capability not supported. | |
| 510 | | 1500007 | Failed to send the message to the common event service. | | 496 | | 1500007 | Failed to send the message to the common event service. | |
| @@ -0,0 +1,126 @@ | |||
| 1 | +# @ohos.settingsLite (Setting Information) | ||
| 2 | + | ||
| 3 | +<!--Kit: Basic Services Kit--> | ||
| 4 | +<!--Subsystem: Applications--> | ||
| 5 | +<!--Owner: @guo_san_quan--> | ||
| 6 | +<!--Designer: @tuonixiaositing--> | ||
| 7 | +<!--Tester: @c30034487--> | ||
| 8 | +<!--Adviser: @fang-jinxu--> | ||
| 9 | + | ||
| 10 | +This module provides lightweight setting capabilities and allows you to redirect to the settings page. | ||
| 11 | + | ||
| 12 | +> **NOTE** | ||
| 13 | +> | ||
| 14 | +> - The initial APIs of this module are supported since API version 24. Newly added APIs will be marked with a superscript to indicate their earliest API version. | ||
| 15 | + | ||
| 16 | +## Modules to Import | ||
| 17 | + | ||
| 18 | +```js | ||
| 19 | +import settingsLite from '@ohos.settingsLite'; | ||
| 20 | +``` | ||
| 21 | + | ||
| 22 | +## settingsLite.openPinSettingPage | ||
| 23 | + | ||
| 24 | +openPinSettingPage(): void | ||
| 25 | + | ||
| 26 | +Opens the password settings page. | ||
| 27 | + | ||
| 28 | +**System capability:** SystemCapability.Applications.Settings.Core.Lite | ||
| 29 | + | ||
| 30 | +**Model restriction:** This API can be used only in the FA model. | ||
| 31 | + | ||
| 32 | +**Example** | ||
| 33 | + | ||
| 34 | +```js | ||
| 35 | +import settingsLite from '@ohos.settingsLite'; | ||
| 36 | + | ||
| 37 | +settingsLite.openPinSettingPage(); | ||
| 38 | +``` | ||
| 39 | + | ||
| 40 | +## settingsLite.openNfcSettingsPage | ||
| 41 | + | ||
| 42 | +openNfcSettingsPage(): void | ||
| 43 | + | ||
| 44 | +Opens the NFC settings page. | ||
| 45 | + | ||
| 46 | +**System capability:** SystemCapability.Applications.Settings.Core.Lite | ||
| 47 | + | ||
| 48 | +**Model restriction:** This API can be used only in the FA model. | ||
| 49 | + | ||
| 50 | +**Example** | ||
| 51 | + | ||
| 52 | +```js | ||
| 53 | +import settingsLite from '@ohos.settingsLite'; | ||
| 54 | + | ||
| 55 | +settingsLite.openNfcSettingsPage(); | ||
| 56 | +``` | ||
| 57 | + | ||
| 58 | +## settingsLite.openDoubleClickSettingsPage | ||
| 59 | + | ||
| 60 | +openDoubleClickSettingsPage(): void | ||
| 61 | + | ||
| 62 | +Opens the double-click settings page. | ||
| 63 | + | ||
| 64 | +**System capability:** SystemCapability.Applications.Settings.Core.Lite | ||
| 65 | + | ||
| 66 | +**Model restriction:** This API can be used only in the FA model. | ||
| 67 | + | ||
| 68 | +**Example** | ||
| 69 | + | ||
| 70 | +```js | ||
| 71 | +import settingsLite from '@ohos.settingsLite'; | ||
| 72 | + | ||
| 73 | +settingsLite.openDoubleClickSettingsPage(); | ||
| 74 | +``` | ||
| 75 | + | ||
| 76 | +## settingsLite.isDoubleClickAppForSelf | ||
| 77 | + | ||
| 78 | +isDoubleClickAppForSelf(callback: ClickCallback): void | ||
| 79 | + | ||
| 80 | +Checks whether the default application started by double-pressing the down button is the current application. | ||
| 81 | + | ||
| 82 | +**System capability:** SystemCapability.Applications.Settings.Core.Lite | ||
| 83 | + | ||
| 84 | +**Model restriction:** This API can be used only in the FA model. | ||
| 85 | + | ||
| 86 | +**Parameters** | ||
| 87 | + | ||
| 88 | +| Name | Type | Mandatory | Description | | ||
| 89 | +| -------- | ------------------------------- | --- | ------- | | ||
| 90 | +| callback | [ClickCallback](#clickcallback) | Yes | Callback used to return the check result.| | ||
| 91 | + | ||
| 92 | +**Example** | ||
| 93 | + | ||
| 94 | +```js | ||
| 95 | +import settingsLite from '@ohos.settingsLite'; | ||
| 96 | + | ||
| 97 | +settingsLite.isDoubleClickAppForSelf({ | ||
| 98 | + onResult(result) { | ||
| 99 | + console.info('isDoubleClickAppForSelf result: ' + result); | ||
| 100 | + } | ||
| 101 | +}); | ||
| 102 | +``` | ||
| 103 | + | ||
| 104 | +## ClickCallback | ||
| 105 | + | ||
| 106 | +Checks the callback on the double-click settings page. | ||
| 107 | + | ||
| 108 | +**System capability:** SystemCapability.Applications.Settings.Core.Lite | ||
| 109 | + | ||
| 110 | +**Model restriction:** This API can be used only in the FA model. | ||
| 111 | + | ||
| 112 | +### onResult | ||
| 113 | + | ||
| 114 | +onResult(result: boolean):void | ||
| 115 | + | ||
| 116 | +Defines a callback used to return the double-click result. | ||
| 117 | + | ||
| 118 | +**System capability:** SystemCapability.Applications.Settings.Core.Lite | ||
| 119 | + | ||
| 120 | +**Model restriction:** This API can be used only in the FA model. | ||
| 121 | + | ||
| 122 | +**Parameters** | ||
| 123 | + | ||
| 124 | +| Name | Type | Mandatory | Description | | ||
| 125 | +| ------ | ------- | --- | ------ | | ||
| 126 | +| result | boolean | Yes | Check result.| | ||
| @@ -5,6 +5,7 @@ | |||
| 5 | <!--Designer: @QRF--> | 5 | <!--Designer: @QRF--> |
| 6 | <!--Tester: @nacyli--> | 6 | <!--Tester: @nacyli--> |
| 7 | <!--Adviser: @zengyawen--> | 7 | <!--Adviser: @zengyawen--> |
| 8 | +<!-- md-trans-meta sourceCommit=603965e6f67783378238262d049a93a8d321dd6f translatedAt=2026-07-23T07:32:39.360Z pushedAt=2026-07-23T09:14:30.222Z --> | ||
| 8 | 9 | ||
| 9 | > **NOTE** | 10 | > **NOTE** |
| 10 | > | 11 | > |
| @@ -22,7 +23,7 @@ Invalid parameters are specified. | |||
| 22 | 23 | ||
| 23 | **Possible Causes** | 24 | **Possible Causes** |
| 24 | 25 | ||
| 25 | -1. The account is empty or exceeds 1024 characters. | 26 | +1. The account is empty or the account length exceeds 1024 characters. |
| 26 | 27 | ||
| 27 | 2. The account type is incorrect. | 28 | 2. The account type is incorrect. |
| 28 | 29 | ||
| @@ -559,4 +560,4 @@ The user with the specified ID is a personal space user and cannot set controlle | |||
| 559 | 560 | ||
| 560 | **Solution** | 561 | **Solution** |
| 561 | 562 | ||
| 562 | -Ensure that the passed user ID does not belong to a personal space user. | 563 | +Ensure that the passed user ID does not belong to a personal space user. |
| @@ -141,7 +141,7 @@ For details about the error codes, see [Universal Error Codes](../errorcode-univ | |||
| 141 | import { dlpPermission } from '@kit.DataProtectionKit'; | 141 | import { dlpPermission } from '@kit.DataProtectionKit'; |
| 142 | 142 | ||
| 143 | dlpPermission.getDLPGatheringPolicy((err, gatheringPolicy) => { | 143 | dlpPermission.getDLPGatheringPolicy((err, gatheringPolicy) => { |
| 144 | - if (err !== undefined) { | 144 | + if (err) { |
| 145 | console.error('getDLPGatheringPolicy error,', err.code, err.message); | 145 | console.error('getDLPGatheringPolicy error,', err.code, err.message); |
| 146 | } else { | 146 | } else { |
| 147 | console.info('gatheringPolicy: ', JSON.stringify(gatheringPolicy)); | 147 | console.info('gatheringPolicy: ', JSON.stringify(gatheringPolicy)); |
| @@ -169,10 +169,10 @@ Before a DLP file management application opens a protected file, the system need | |||
| 169 | 169 | ||
| 170 | | Name| Type| Mandatory| Description| | 170 | | Name| Type| Mandatory| Description| |
| 171 | | -------- | -------- | -------- | -------- | | 171 | | -------- | -------- | -------- | -------- | |
| 172 | -| bundleName | string | Yes| Bundle name of the application. The value contains 7 to 128 bytes. If the value is out of range, error code 19100001 is thrown.| | 172 | +| bundleName | string | Yes| Bundle name of the application. The value contains 7 to 128 bytes. If the value is out of range, error code 401 is thrown.| |
| 173 | | access | [DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess) | Yes| Permission on the DLP file. The permissions on a DLP file determine the access scope of the file.| | 173 | | access | [DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess) | Yes| Permission on the DLP file. The permissions on a DLP file determine the access scope of the file.| |
| 174 | | userId | number | Yes| Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**.<br>The value range is [0, 2<sup>31</sup>-1]. If the value is out of range, the excess part will be truncated. If the value of the passed parameter is less than 0, an error log is generated.| | 174 | | userId | number | Yes| Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**.<br>The value range is [0, 2<sup>31</sup>-1]. If the value is out of range, the excess part will be truncated. If the value of the passed parameter is less than 0, an error log is generated.| |
| 175 | -| uri | string | Yes| URI of the DLP file. The value contains up to 4095 bytes. If the value is out of range, error code 19100001 is thrown.| | 175 | +| uri | string | Yes| URI of the DLP file. The value contains up to 4095 bytes. If the value is out of range, error code 401 is thrown.| |
| 176 | 176 | ||
| 177 | **Return value** | 177 | **Return value** |
| 178 | 178 | ||
| @@ -226,10 +226,10 @@ Before a DLP file management application opens a protected file, the system need | |||
| 226 | 226 | ||
| 227 | | Name| Type| Mandatory| Description| | 227 | | Name| Type| Mandatory| Description| |
| 228 | | -------- | -------- | -------- | -------- | | 228 | | -------- | -------- | -------- | -------- | |
| 229 | -| bundleName | string | Yes| Bundle name of the application. The value contains 7 to 128 bytes. If the value is out of range, error code 19100001 is thrown.| | 229 | +| bundleName | string | Yes| Bundle name of the application. The value contains 7 to 128 bytes. If the value is out of range, error code 401 is thrown.| |
| 230 | | access | [DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess) | Yes| Permission on the DLP file. The permissions on a DLP file determine the access scope of the file.| | 230 | | access | [DLPFileAccess](js-apis-dlppermission.md#dlpfileaccess) | Yes| Permission on the DLP file. The permissions on a DLP file determine the access scope of the file.| |
| 231 | | userId | number | Yes| Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**.<br>The value range is [0, 2<sup>31</sup>-1]. If the value is out of range, the excess part will be truncated. If the value of the passed parameter is less than 0, an error log is generated.| | 231 | | userId | number | Yes| Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**.<br>The value range is [0, 2<sup>31</sup>-1]. If the value is out of range, the excess part will be truncated. If the value of the passed parameter is less than 0, an error log is generated.| |
| 232 | -| uri | string | Yes| URI of the DLP file. The value contains up to 4095 bytes. If the value is out of range, error code 19100001 is thrown.| | 232 | +| uri | string | Yes| URI of the DLP file. The value contains up to 4095 bytes. If the value is out of range, error code 401 is thrown.| |
| 233 | | callback | AsyncCallback<[DLPSandboxInfo](#dlpsandboxinfo)> | Yes| Callback used to return the result. If the DLP sandbox is installed successfully, **err** is **undefined** and **data** is the sandbox information obtained; otherwise, **err** is an error object.| | 233 | | callback | AsyncCallback<[DLPSandboxInfo](#dlpsandboxinfo)> | Yes| Callback used to return the result. If the DLP sandbox is installed successfully, **err** is **undefined** and **data** is the sandbox information obtained; otherwise, **err** is an error object.| |
| 234 | 234 | ||
| 235 | **Error codes** | 235 | **Error codes** |
| @@ -251,7 +251,7 @@ import { dlpPermission } from '@kit.DataProtectionKit'; | |||
| 251 | 251 | ||
| 252 | let uri = 'file://docs/storage/Users/currentUser/Desktop/test.txt.dlp'; | 252 | let uri = 'file://docs/storage/Users/currentUser/Desktop/test.txt.dlp'; |
| 253 | dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.READ_ONLY, 100, uri, (err, res) => { | 253 | dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.READ_ONLY, 100, uri, (err, res) => { |
| 254 | - if (err !== undefined) { | 254 | + if (err) { |
| 255 | console.error('installDLPSandbox error,', err.code, err.message); | 255 | console.error('installDLPSandbox error,', err.code, err.message); |
| 256 | } else { | 256 | } else { |
| 257 | console.info('res', JSON.stringify(res)); | 257 | console.info('res', JSON.stringify(res)); |
| @@ -279,7 +279,7 @@ This API can be called only after a DLP sandbox is installed by calling [install | |||
| 279 | 279 | ||
| 280 | | Name| Type| Mandatory| Description| | 280 | | Name| Type| Mandatory| Description| |
| 281 | | -------- | -------- | -------- | -------- | | 281 | | -------- | -------- | -------- | -------- | |
| 282 | -| bundleName | string | Yes| Bundle name of the application. The value contains 7 to 128 bytes. If the value is out of range, error code 19100001 is thrown.| | 282 | +| bundleName | string | Yes| Bundle name of the application. The value contains 7 to 128 bytes. If the value is out of range, error code 401 is thrown.| |
| 283 | | userId | number | Yes| Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**.<br>The value range is [0, 2<sup>31</sup>-1]. If the value is out of range, the excess part will be truncated. If the value of the passed parameter is less than 0, an error log is generated.| | 283 | | userId | number | Yes| Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**.<br>The value range is [0, 2<sup>31</sup>-1]. If the value is out of range, the excess part will be truncated. If the value of the passed parameter is less than 0, an error log is generated.| |
| 284 | | appIndex | number | Yes| DLP sandbox index, which is the value returned after **installDLPSandbox** is successfully called. It is used to identify the installed DLP sandbox. The value range is [1000, 1100]. If the value is out of range, an error log is generated.| | 284 | | appIndex | number | Yes| DLP sandbox index, which is the value returned after **installDLPSandbox** is successfully called. It is used to identify the installed DLP sandbox. The value range is [1000, 1100]. If the value is out of range, an error log is generated.| |
| 285 | 285 | ||
| @@ -336,7 +336,7 @@ This API can be called only after a DLP sandbox is installed by calling [install | |||
| 336 | 336 | ||
| 337 | | Name| Type| Mandatory| Description| | 337 | | Name| Type| Mandatory| Description| |
| 338 | | -------- | -------- | -------- | -------- | | 338 | | -------- | -------- | -------- | -------- | |
| 339 | -| bundleName | string | Yes| Bundle name of the application. The value contains 7 to 128 bytes. If the value is out of range, error code 19100001 is thrown.| | 339 | +| bundleName | string | Yes| Bundle name of the application. The value contains 7 to 128 bytes. If the value is out of range, error code 401 is thrown.| |
| 340 | | userId | number | Yes| Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**. The value range is [0, 2<sup>31</sup>-1]. If the value is out of range, the excess part will be truncated. | | 340 | | userId | number | Yes| Current user ID, which is the system account ID obtained by the account subsystem. The default super user ID is **100**. The value range is [0, 2<sup>31</sup>-1]. If the value is out of range, the excess part will be truncated. | |
| 341 | | appIndex | number | Yes| DLP sandbox index, which is the value returned after **installDLPSandbox** is successfully called. It is used to identify the installed DLP sandbox. The value range is [1000, 1100]. If the value is out of range, an error log is generated.| | 341 | | appIndex | number | Yes| DLP sandbox index, which is the value returned after **installDLPSandbox** is successfully called. It is used to identify the installed DLP sandbox. The value range is [1000, 1100]. If the value is out of range, an error log is generated.| |
| 342 | | callback | AsyncCallback<void> | Yes| Callback used to return the result. If the DLP sandbox is uninstalled successfully, **err** is **undefined**; otherwise, **err** is an error object.| | 342 | | callback | AsyncCallback<void> | Yes| Callback used to return the result. If the DLP sandbox is uninstalled successfully, **err** is **undefined**; otherwise, **err** is an error object.| |
| @@ -363,7 +363,7 @@ dlpPermission.installDLPSandbox('com.ohos.note', dlpPermission.DLPFileAccess.REA | |||
| 363 | uri).then((dlpSandboxInfo: dlpPermission.DLPSandboxInfo) => { | 363 | uri).then((dlpSandboxInfo: dlpPermission.DLPSandboxInfo) => { |
| 364 | console.info('dlpSandboxInfo: ', JSON.stringify(dlpSandboxInfo)); | 364 | console.info('dlpSandboxInfo: ', JSON.stringify(dlpSandboxInfo)); |
| 365 | dlpPermission.uninstallDLPSandbox('com.ohos.note', 100, dlpSandboxInfo.appIndex, (err, res) => { | 365 | dlpPermission.uninstallDLPSandbox('com.ohos.note', 100, dlpSandboxInfo.appIndex, (err, res) => { |
| 366 | - if (err !== undefined) { | 366 | + if (err) { |
| 367 | console.error('uninstallDLPSandbox error,', err.code, err.message); | 367 | console.error('uninstallDLPSandbox error,', err.code, err.message); |
| 368 | } else { | 368 | } else { |
| 369 | console.info('res', JSON.stringify(res)); | 369 | console.info('res', JSON.stringify(res)); |
| @@ -496,7 +496,7 @@ When a DLP application needs to access a DLP file using a standard file API, it | |||
| 496 | 496 | ||
| 497 | | Name| Type| Mandatory| Description| | 497 | | Name| Type| Mandatory| Description| |
| 498 | | -------- | -------- | -------- | -------- | | 498 | | -------- | -------- | -------- | -------- | |
| 499 | -| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 19100001 is thrown.| | 499 | +| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 401 is thrown.| |
| 500 | 500 | ||
| 501 | **Return value** | 501 | **Return value** |
| 502 | 502 | ||
| @@ -540,7 +540,7 @@ async function ExampleFunction() { | |||
| 540 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. | 540 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. |
| 541 | await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. | 541 | await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. |
| 542 | 542 | ||
| 543 | - dlpFile?.closeDLPFile(); // Close the DLP object. | 543 | + await dlpFile?.closeDLPFile(); // Close the DLP object. |
| 544 | if (file) { | 544 | if (file) { |
| 545 | fileIo.closeSync(file); | 545 | fileIo.closeSync(file); |
| 546 | } | 546 | } |
| @@ -569,7 +569,7 @@ This API is called when a DLP application needs to access a DLP file using a sta | |||
| 569 | 569 | ||
| 570 | | Name| Type| Mandatory| Description| | 570 | | Name| Type| Mandatory| Description| |
| 571 | | -------- | -------- | -------- | -------- | | 571 | | -------- | -------- | -------- | -------- | |
| 572 | -| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 19100001 is thrown.| | 572 | +| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 401 is thrown.| |
| 573 | | callback | AsyncCallback<void> | Yes| Callback used to receive the result of adding a link file.| | 573 | | callback | AsyncCallback<void> | Yes| Callback used to receive the result of adding a link file.| |
| 574 | 574 | ||
| 575 | **Error codes** | 575 | **Error codes** |
| @@ -607,7 +607,7 @@ async function ExampleFunction() { | |||
| 607 | file = fileIo.openSync(uri).fd; | 607 | file = fileIo.openSync(uri).fd; |
| 608 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. | 608 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. |
| 609 | dlpFile.addDLPLinkFile('test.txt.dlp.link', async (err, res) => { | 609 | dlpFile.addDLPLinkFile('test.txt.dlp.link', async (err, res) => { |
| 610 | - if (err !== undefined) { | 610 | + if (err) { |
| 611 | console.error('addDLPLinkFile error,', err.code, err.message); | 611 | console.error('addDLPLinkFile error,', err.code, err.message); |
| 612 | } else { | 612 | } else { |
| 613 | console.info('res', JSON.stringify(res)); | 613 | console.info('res', JSON.stringify(res)); |
| @@ -674,10 +674,10 @@ async function ExampleFunction() { | |||
| 674 | appId = data.signatureInfo.appId; | 674 | appId = data.signatureInfo.appId; |
| 675 | 675 | ||
| 676 | file = fileIo.openSync(uri).fd; | 676 | file = fileIo.openSync(uri).fd; |
| 677 | - dlpFile = await dlpPermission.openDLPFile(file, appId) // Open a DLP file. | 677 | + dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. |
| 678 | - dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. | 678 | + await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. |
| 679 | - dlpFile.stopFuseLink(); // Stop read/write on the link file. | 679 | + await dlpFile.stopFuseLink(); // Stop the read and write on the link file. |
| 680 | - dlpFile?.closeDLPFile(); // Close the DLP object. | 680 | + await dlpFile?.closeDLPFile(); // Close the DLP object. |
| 681 | if (file) { | 681 | if (file) { |
| 682 | fileIo.closeSync(file); | 682 | fileIo.closeSync(file); |
| 683 | } | 683 | } |
| @@ -744,7 +744,7 @@ async function ExampleFunction() { | |||
| 744 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. | 744 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. |
| 745 | await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. | 745 | await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. |
| 746 | dlpFile.stopFuseLink(async (err, res) => { | 746 | dlpFile.stopFuseLink(async (err, res) => { |
| 747 | - if (err !== undefined) { | 747 | + if (err) { |
| 748 | console.error('stopFuseLink error,', err.code, err.message); | 748 | console.error('stopFuseLink error,', err.code, err.message); |
| 749 | } else { | 749 | } else { |
| 750 | console.info('res', JSON.stringify(res)); | 750 | console.info('res', JSON.stringify(res)); |
| @@ -816,7 +816,7 @@ async function ExampleFunction() { | |||
| 816 | await dlpFile.stopFuseLink(); // Stop the read and write on the link file. | 816 | await dlpFile.stopFuseLink(); // Stop the read and write on the link file. |
| 817 | await dlpFile.resumeFuseLink(); // Resume read/write on the link file. | 817 | await dlpFile.resumeFuseLink(); // Resume read/write on the link file. |
| 818 | 818 | ||
| 819 | - dlpFile?.closeDLPFile(); // Close the DLP object. | 819 | + await dlpFile?.closeDLPFile(); // Close the DLP object. |
| 820 | if (file) { | 820 | if (file) { |
| 821 | fileIo.closeSync(file); | 821 | fileIo.closeSync(file); |
| 822 | } | 822 | } |
| @@ -884,7 +884,7 @@ async function ExampleFunction() { | |||
| 884 | await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. | 884 | await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. |
| 885 | await dlpFile.stopFuseLink(); // Stop the read and write on the link file. | 885 | await dlpFile.stopFuseLink(); // Stop the read and write on the link file. |
| 886 | dlpFile.resumeFuseLink(async (err, res) => { | 886 | dlpFile.resumeFuseLink(async (err, res) => { |
| 887 | - if (err !== undefined) { | 887 | + if (err) { |
| 888 | console.error('resumeFuseLink error,', err.code, err.message); | 888 | console.error('resumeFuseLink error,', err.code, err.message); |
| 889 | } else { | 889 | } else { |
| 890 | console.info('res', JSON.stringify(res)); | 890 | console.info('res', JSON.stringify(res)); |
| @@ -901,7 +901,7 @@ ExampleFunction(); | |||
| 901 | 901 | ||
| 902 | replaceDLPLinkFile(linkFileName: string): Promise<void> | 902 | replaceDLPLinkFile(linkFileName: string): Promise<void> |
| 903 | 903 | ||
| 904 | -Replaces a link file. This API uses a promise to return the result. After the API is successfully called, the current link file is replaced with the new link file. | 904 | +Replaces a link file. This API uses a promise to return the result. After the API is successfully called, the current link file is replaced with the new link file. Before performing this operation, you need to create a link file and stop the read and write operation on the FUSE. |
| 905 | 905 | ||
| 906 | When you need to access a different DLP file, you can replace the link file to change the file mapping. | 906 | When you need to access a different DLP file, you can replace the link file to change the file mapping. |
| 907 | 907 | ||
| @@ -915,7 +915,7 @@ When you need to access a different DLP file, you can replace the link file to c | |||
| 915 | 915 | ||
| 916 | | Name| Type| Mandatory| Description| | 916 | | Name| Type| Mandatory| Description| |
| 917 | | -------- | -------- | -------- | -------- | | 917 | | -------- | -------- | -------- | -------- | |
| 918 | -| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 19100001 is thrown.| | 918 | +| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 401 is thrown.| |
| 919 | 919 | ||
| 920 | **Return value** | 920 | **Return value** |
| 921 | 921 | ||
| @@ -977,7 +977,7 @@ replaceDLPLinkFile(linkFileName: string, callback: AsyncCallback<void>): v | |||
| 977 | 977 | ||
| 978 | Replaces a link file. This API uses an asynchronous callback to return the result. After the API is successfully called, the current link file is replaced with the new link file. | 978 | Replaces a link file. This API uses an asynchronous callback to return the result. After the API is successfully called, the current link file is replaced with the new link file. |
| 979 | 979 | ||
| 980 | -When you need to access a different DLP file, you can replace the link file. | 980 | +When you need to access a different DLP file, you can replace the link file. Before performing this operation, you need to create a link file and stop the read and write operation on the FUSE. |
| 981 | 981 | ||
| 982 | **System API**: This is a system API. | 982 | **System API**: This is a system API. |
| 983 | 983 | ||
| @@ -989,7 +989,7 @@ When you need to access a different DLP file, you can replace the link file. | |||
| 989 | 989 | ||
| 990 | | Name| Type| Mandatory| Description| | 990 | | Name| Type| Mandatory| Description| |
| 991 | | -------- | -------- | -------- | -------- | | 991 | | -------- | -------- | -------- | -------- | |
| 992 | -| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 19100001 is thrown.| | 992 | +| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 401 is thrown.| |
| 993 | | callback | AsyncCallback<void> | Yes| Callback used to receive the result of replacing a link file. The callback parameter is **err**. **err** is **undefined** when the operation is successful; otherwise, **err** is an error object.| | 993 | | callback | AsyncCallback<void> | Yes| Callback used to receive the result of replacing a link file. The callback parameter is **err**. **err** is **undefined** when the operation is successful; otherwise, **err** is an error object.| |
| 994 | 994 | ||
| 995 | **Error codes** | 995 | **Error codes** |
| @@ -1029,7 +1029,7 @@ async function ExampleFunction() { | |||
| 1029 | await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. | 1029 | await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. |
| 1030 | await dlpFile.stopFuseLink(); // Stop the read and write on the link file. | 1030 | await dlpFile.stopFuseLink(); // Stop the read and write on the link file. |
| 1031 | dlpFile.replaceDLPLinkFile('test_new.txt.dlp.link', async (err, res) => { // Replace a link file. | 1031 | dlpFile.replaceDLPLinkFile('test_new.txt.dlp.link', async (err, res) => { // Replace a link file. |
| 1032 | - if (err !== undefined) { | 1032 | + if (err) { |
| 1033 | console.error('replaceDLPLinkFile error,', err.code, err.message); | 1033 | console.error('replaceDLPLinkFile error,', err.code, err.message); |
| 1034 | } else { | 1034 | } else { |
| 1035 | console.info('res', JSON.stringify(res)); | 1035 | console.info('res', JSON.stringify(res)); |
| @@ -1063,7 +1063,7 @@ This API is used to clear the link file mapping after DLP file access is complet | |||
| 1063 | 1063 | ||
| 1064 | | Name| Type| Mandatory| Description| | 1064 | | Name| Type| Mandatory| Description| |
| 1065 | | -------- | -------- | -------- | -------- | | 1065 | | -------- | -------- | -------- | -------- | |
| 1066 | -| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 19100001 is thrown.| | 1066 | +| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 401 is thrown.| |
| 1067 | 1067 | ||
| 1068 | **Return value** | 1068 | **Return value** |
| 1069 | 1069 | ||
| @@ -1137,7 +1137,7 @@ This API is used to clear the link file mapping after DLP file access is complet | |||
| 1137 | 1137 | ||
| 1138 | | Name| Type| Mandatory| Description| | 1138 | | Name| Type| Mandatory| Description| |
| 1139 | | -------- | -------- | -------- | -------- | | 1139 | | -------- | -------- | -------- | -------- | |
| 1140 | -| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 19100001 is thrown.| | 1140 | +| linkFileName | string | Yes| Name of the link file in the FUSE. The value contains up to 255 bytes. If the value is out of range, error code 401 is thrown.| |
| 1141 | | callback | AsyncCallback<void> | Yes| Callback used to receive the result of deleting a link file.| | 1141 | | callback | AsyncCallback<void> | Yes| Callback used to receive the result of deleting a link file.| |
| 1142 | 1142 | ||
| 1143 | **Error codes** | 1143 | **Error codes** |
| @@ -1176,7 +1176,7 @@ async function ExampleFunction() { | |||
| 1176 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. | 1176 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. |
| 1177 | await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. | 1177 | await dlpFile.addDLPLinkFile('test.txt.dlp.link'); // Add a link file. |
| 1178 | dlpFile.deleteDLPLinkFile('test.txt.dlp.link', async (err, res) => { // Delete a link file. | 1178 | dlpFile.deleteDLPLinkFile('test.txt.dlp.link', async (err, res) => { // Delete a link file. |
| 1179 | - if (err !== undefined) { | 1179 | + if (err) { |
| 1180 | console.error('deleteDLPLinkFile error,', err.code, err.message); | 1180 | console.error('deleteDLPLinkFile error,', err.code, err.message); |
| 1181 | } else { | 1181 | } else { |
| 1182 | console.info('res', JSON.stringify(res)); | 1182 | console.info('res', JSON.stringify(res)); |
| @@ -1255,10 +1255,10 @@ async function ExampleFunction() { | |||
| 1255 | appId = data.signatureInfo.appId; | 1255 | appId = data.signatureInfo.appId; |
| 1256 | 1256 | ||
| 1257 | file = fileIo.openSync(uri).fd; | 1257 | file = fileIo.openSync(uri).fd; |
| 1258 | - destFile = fileIo.openSync('destUri').fd; | 1258 | + destFile = fileIo.openSync('file://docs/storage/Users/currentUser/Desktop/dest.txt').fd; |
| 1259 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. | 1259 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. |
| 1260 | await dlpFile.recoverDLPFile(destFile); // Recover the plaintext of a DLP file. | 1260 | await dlpFile.recoverDLPFile(destFile); // Recover the plaintext of a DLP file. |
| 1261 | - dlpFile?.closeDLPFile(); // Close the DLP object. | 1261 | + await dlpFile?.closeDLPFile(); // Close the DLP object. |
| 1262 | if (file) { | 1262 | if (file) { |
| 1263 | fileIo.closeSync(file); | 1263 | fileIo.closeSync(file); |
| 1264 | } | 1264 | } |
| @@ -1334,7 +1334,7 @@ async function ExampleFunction() { | |||
| 1334 | destFile = fileIo.openSync('destUri').fd; | 1334 | destFile = fileIo.openSync('destUri').fd; |
| 1335 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. | 1335 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. |
| 1336 | dlpFile.recoverDLPFile(destFile, async (err, res) => { // Recover the plaintext of a DLP file. | 1336 | dlpFile.recoverDLPFile(destFile, async (err, res) => { // Recover the plaintext of a DLP file. |
| 1337 | - if (err !== undefined) { | 1337 | + if (err) { |
| 1338 | console.error('recoverDLPFile error,', err.code, err.message); | 1338 | console.error('recoverDLPFile error,', err.code, err.message); |
| 1339 | } else { | 1339 | } else { |
| 1340 | console.info('res', JSON.stringify(res)); | 1340 | console.info('res', JSON.stringify(res)); |
| @@ -1408,7 +1408,7 @@ async function ExampleFunction() { | |||
| 1408 | file = fileIo.openSync(uri).fd; | 1408 | file = fileIo.openSync(uri).fd; |
| 1409 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. | 1409 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. |
| 1410 | 1410 | ||
| 1411 | - dlpFile?.closeDLPFile(); // Close the DLP object. | 1411 | + await dlpFile?.closeDLPFile(); // Close the DLP object. |
| 1412 | if (file) { | 1412 | if (file) { |
| 1413 | fileIo.closeSync(file); | 1413 | fileIo.closeSync(file); |
| 1414 | } | 1414 | } |
| @@ -1478,7 +1478,7 @@ async function ExampleFunction() { | |||
| 1478 | file = fileIo.openSync(uri).fd; | 1478 | file = fileIo.openSync(uri).fd; |
| 1479 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. | 1479 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. |
| 1480 | dlpFile.closeDLPFile((err, res) => {// Close the DLP file. | 1480 | dlpFile.closeDLPFile((err, res) => {// Close the DLP file. |
| 1481 | - if (err !== undefined) { | 1481 | + if (err) { |
| 1482 | console.error('closeDLPFile error,', err.code, err.message); | 1482 | console.error('closeDLPFile error,', err.code, err.message); |
| 1483 | } else { | 1483 | } else { |
| 1484 | console.info('res', JSON.stringify(res)); | 1484 | console.info('res', JSON.stringify(res)); |
| @@ -1561,7 +1561,7 @@ async function ExampleFunction() { | |||
| 1561 | }; | 1561 | }; |
| 1562 | dlpFile = await dlpPermission.generateDLPFile(file, dlp, dlpProperty); // Generate a DLP file. | 1562 | dlpFile = await dlpPermission.generateDLPFile(file, dlp, dlpProperty); // Generate a DLP file. |
| 1563 | 1563 | ||
| 1564 | - dlpFile?.closeDLPFile(); // Close the DLP object. | 1564 | + await dlpFile?.closeDLPFile(); // Close the DLP object. |
| 1565 | if (file) { | 1565 | if (file) { |
| 1566 | fileIo.closeSync(file); | 1566 | fileIo.closeSync(file); |
| 1567 | } | 1567 | } |
| @@ -1636,7 +1636,7 @@ let dlpProperty: dlpPermission.DLPProperty = { | |||
| 1636 | everyoneAccessList: [] | 1636 | everyoneAccessList: [] |
| 1637 | }; | 1637 | }; |
| 1638 | dlpPermission.generateDLPFile(file, dlp, dlpProperty, (err, res) => { // Generate a DLP file. | 1638 | dlpPermission.generateDLPFile(file, dlp, dlpProperty, (err, res) => { // Generate a DLP file. |
| 1639 | - if (err !== undefined) { | 1639 | + if (err) { |
| 1640 | console.error('generateDLPFile error,', err.code, err.message); | 1640 | console.error('generateDLPFile error,', err.code, err.message); |
| 1641 | } else { | 1641 | } else { |
| 1642 | console.info('res', JSON.stringify(res)); | 1642 | console.info('res', JSON.stringify(res)); |
| @@ -1667,7 +1667,7 @@ When a DLP management application or an authorized application needs to access a | |||
| 1667 | | Name| Type| Mandatory| Description| | 1667 | | Name| Type| Mandatory| Description| |
| 1668 | | -------- | -------- | -------- | -------- | | 1668 | | -------- | -------- | -------- | -------- | |
| 1669 | | ciphertextFd | number | Yes| FD of the encrypted file. The value range is [0, 2<sup>31</sup>-1]. If the value of **fd** is less than 0, an error log is generated, and the function stops running. If the value of **fd** is greater than 2<sup>31</sup>-1, the excess part will be truncated.| | 1669 | | ciphertextFd | number | Yes| FD of the encrypted file. The value range is [0, 2<sup>31</sup>-1]. If the value of **fd** is less than 0, an error log is generated, and the function stops running. If the value of **fd** is greater than 2<sup>31</sup>-1, the excess part will be truncated.| |
| 1670 | -| appId | string | Yes| ID of the caller. The value contains 8 to 1024 bytes. If the value is out of range, error code 19100001 is returned.| | 1670 | +| appId | string | Yes| ID of the caller. The value contains 8 to 1024 bytes. If the value is out of range, error code 401 is thrown.| |
| 1671 | 1671 | ||
| 1672 | **Return value** | 1672 | **Return value** |
| 1673 | 1673 | ||
| @@ -1717,6 +1717,7 @@ async function ExampleFunction() { | |||
| 1717 | 1717 | ||
| 1718 | file = fileIo.openSync(uri).fd; // The FD is obtained by opening a file. | 1718 | file = fileIo.openSync(uri).fd; // The FD is obtained by opening a file. |
| 1719 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. | 1719 | dlpFile = await dlpPermission.openDLPFile(file, appId); // Open a DLP file. |
| 1720 | + await dlpFile?.closeDLPFile(); // Close the DLP object. | ||
| 1720 | 1721 | ||
| 1721 | if (file) { | 1722 | if (file) { |
| 1722 | fileIo.closeSync(file); | 1723 | fileIo.closeSync(file); |
| @@ -1743,7 +1744,7 @@ Opens a DLP file. This API uses an asynchronous callback to return the result. A | |||
| 1743 | | Name| Type| Mandatory| Description| | 1744 | | Name| Type| Mandatory| Description| |
| 1744 | | -------- | -------- | -------- | -------- | | 1745 | | -------- | -------- | -------- | -------- | |
| 1745 | | ciphertextFd | number | Yes| FD of the encrypted file. The value range is [0, 2<sup>31</sup>-1]. If the value of **fd** is less than 0, an error log is generated, and the function stops running. If the value of **fd** is greater than 2<sup>31</sup>-1, the excess part will be truncated.| | 1746 | | ciphertextFd | number | Yes| FD of the encrypted file. The value range is [0, 2<sup>31</sup>-1]. If the value of **fd** is less than 0, an error log is generated, and the function stops running. If the value of **fd** is greater than 2<sup>31</sup>-1, the excess part will be truncated.| |
| 1746 | -| appId | string | Yes| ID of the caller. The value contains 8 to 1024 bytes. If the value is out of range, error code 19100001 is returned.| | 1747 | +| appId | string | Yes| ID of the caller. The value contains 8 to 1024 bytes. If the value is out of range, error code 401 is thrown.| |
| 1747 | | callback | AsyncCallback<[DLPFile](#dlpfile)> | Yes| Callback used to receive the result of opening a DLP file. The callback parameters include **err** and **res**. **err** is **undefined** when the operation is successful; otherwise, **err** is an error object. **res** is a **DLPFile** object that represents the DLP file opened.| | 1748 | | callback | AsyncCallback<[DLPFile](#dlpfile)> | Yes| Callback used to receive the result of opening a DLP file. The callback parameters include **err** and **res**. **err** is **undefined** when the operation is successful; otherwise, **err** is an error object. **res** is a **DLPFile** object that represents the DLP file opened.| |
| 1748 | 1749 | ||
| 1749 | **Error codes** | 1750 | **Error codes** |
| @@ -1785,12 +1786,13 @@ let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId); | |||
| 1785 | appId = data.signatureInfo.appId; // The app ID is obtained from the application package. | 1786 | appId = data.signatureInfo.appId; // The app ID is obtained from the application package. |
| 1786 | 1787 | ||
| 1787 | file = fileIo.openSync(uri).fd; // The FD is obtained by opening a file. | 1788 | file = fileIo.openSync(uri).fd; // The FD is obtained by opening a file. |
| 1788 | -dlpPermission.openDLPFile(file, appId, (err, res) => { // Open a DLP file. | 1789 | +dlpPermission.openDLPFile(file, appId, async (err, res) => { // Open a DLP file. |
| 1789 | - if (err !== undefined) { | 1790 | + if (err) { |
| 1790 | console.error('openDLPFile error,', err.code, err.message); | 1791 | console.error('openDLPFile error,', err.code, err.message); |
| 1791 | } else { | 1792 | } else { |
| 1792 | console.info('res', JSON.stringify(res)); | 1793 | console.info('res', JSON.stringify(res)); |
| 1793 | } | 1794 | } |
| 1795 | + await res?.closeDLPFile(); // Close the DLP object. | ||
| 1794 | if (file) { | 1796 | if (file) { |
| 1795 | fileIo.closeSync(file); | 1797 | fileIo.closeSync(file); |
| 1796 | } | 1798 | } |
| @@ -1821,7 +1823,7 @@ Represents the DLP sandbox state information. | |||
| 1821 | 1823 | ||
| 1822 | | Name| Type| Read Only| Optional| Description| | 1824 | | Name| Type| Read Only| Optional| Description| |
| 1823 | | -------- | -------- | -------- | -------- | -------- | | 1825 | | -------- | -------- | -------- | -------- | -------- | |
| 1824 | -| bundleName | string | No| No| Bundle name of the application. The value contains 7 to 128 bytes. If the value is out of range, error code 19100001 is thrown.| | 1826 | +| bundleName | string | No| No| Bundle name of the application.| |
| 1825 | | appIndex | number | No| No| Index of the DLP sandbox application. The value range is [1000, 1100]. If the value is out of range, an error log is generated.| | 1827 | | appIndex | number | No| No| Index of the DLP sandbox application. The value range is [1000, 1100]. If the value is out of range, an error log is generated.| |
| 1826 | 1828 | ||
| 1827 | ## GatheringPolicyType | 1829 | ## GatheringPolicyType |
| @@ -1836,5 +1838,5 @@ Enumerates the DLP sandbox gathering policy types. **GATHERING** allows the DLP | |||
| 1836 | 1838 | ||
| 1837 | | Name| Value| Description| | 1839 | | Name| Value| Description| |
| 1838 | | -------- | -------- | -------- | | 1840 | | -------- | -------- | -------- | |
| 1839 | -| GATHERING | 1 | Allows the DLP files of the same permission type to be opened in a sandbox. For example, the files of the same permission type can be opened in tab pages of a window.| | 1841 | +| GATHERING | 1 | Allows the DLP files of the same permission type to be opened in a sandbox.| |
| 1840 | | NON_GATHERING | 2 | Allows the DLP files of different permission types to be opened in different sandboxes.| | 1842 | | NON_GATHERING | 2 | Allows the DLP files of different permission types to be opened in different sandboxes.| |
| @@ -6,15 +6,14 @@ | |||
| 6 | <!--Tester: @nacyli--> | 6 | <!--Tester: @nacyli--> |
| 7 | <!--Adviser: @zengyawen--> | 7 | <!--Adviser: @zengyawen--> |
| 8 | 8 | ||
| 9 | -This module controls the Data Loss Prevention (DLP) feature, including enabling or disabling DLP and returning the DLP status. | 9 | +This module provides APIs for controlling the Data Loss Prevention (DLP) feature, including enabling or disabling the DLP feature and returning the DLP status. It helps enterprises meet data security compliance requirements and implement access control and encryption protection for confidential files. |
| 10 | 10 | ||
| 11 | **Use scenarios** | 11 | **Use scenarios** |
| 12 | - Data security compliance requirements must be met. | 12 | - Data security compliance requirements must be met. |
| 13 | - Access control and encryption protection are provided for confidential files. | 13 | - Access control and encryption protection are provided for confidential files. |
| 14 | - | ||
| 15 | > **NOTE** | 14 | > **NOTE** |
| 16 | > | 15 | > |
| 17 | -> - The initial APIs of this module are supported since API version 26. Newly added APIs will be marked with a superscript to indicate their earliest API version. | 16 | +> - The initial APIs of this module are supported since API version 26.0.0. Newly added APIs will be marked with a superscript to indicate their earliest API version. |
| 18 | > - The APIs provided by this module are system APIs. | 17 | > - The APIs provided by this module are system APIs. |
| 19 | 18 | ||
| 20 | ## Key Classes and APIs | 19 | ## Key Classes and APIs |
| @@ -39,9 +38,9 @@ setDlpFeature(status: DlpFeatureStatus): Promise<StatusInfoResult> | |||
| 39 | 38 | ||
| 40 | Sets the DLP status. This API uses a promise to return the result. The system enables or disables the DLP protection function based on the DLP status specified using this API. | 39 | Sets the DLP status. This API uses a promise to return the result. The system enables or disables the DLP protection function based on the DLP status specified using this API. |
| 41 | 40 | ||
| 42 | -When this feature is enabled, right-click the file to be encrypted, and the encryption option is displayed in the shortcut menu. Files in .txt, .pdf, .xls, .xlsx, .ppt, .pptx, .doc, and .docx formats can be encrypted. | 41 | +When this feature is enabled, right-click a file that can be encrypted, and the encryption option is displayed in the shortcut menu. Files in .txt, .pdf, .xls, .xlsx, .ppt, .pptx, .doc, and .docx formats can be encrypted. |
| 43 | 42 | ||
| 44 | -This API is used to enable or disable the DLP function in enterprise policies. | 43 | +This API is used to enable or disable the DLP feature for enterprise policies. |
| 45 | 44 | ||
| 46 | **Since:** 26.0.0 | 45 | **Since:** 26.0.0 |
| 47 | 46 | ||
| @@ -55,7 +54,7 @@ This API is used to enable or disable the DLP function in enterprise policies. | |||
| 55 | 54 | ||
| 56 | | Name| Type| Mandatory| Description| | 55 | | Name| Type| Mandatory| Description| |
| 57 | | -------- | -------- | -------- | -------- | | 56 | | -------- | -------- | -------- | -------- | |
| 58 | -| status | [DlpFeatureStatus](#dlpfeaturestatus) | Yes| DLP status. The value **ENABLED_FEATURE** indicates the DLP feature is enabled, and the encryption option is displayed in the menu. The value **NOT_ENABLED_FEATURE** indicates the DLP feature is disabled, and the encryption option is not displayed in the menu. If the value is out of range, error code 19100001 is thrown.| | 57 | +| status | [DlpFeatureStatus](#dlpfeaturestatus) | Yes| DLP status. The value **ENABLED_FEATURE** indicates the DLP feature is enabled, and the encryption option is displayed in the menu. The value **NOT_ENABLED_FEATURE** indicates the DLP feature is disabled, and the encryption option is not displayed in the menu. If the value is out of range, error code 401 is thrown.| |
| 59 | 58 | ||
| 60 | **Return value** | 59 | **Return value** |
| 61 | 60 | ||
| @@ -80,8 +79,8 @@ import { dlpSetDlpFeature } from '@kit.DataProtectionKit'; | |||
| 80 | 79 | ||
| 81 | async function exampleFunction() { | 80 | async function exampleFunction() { |
| 82 | let statusInfoResult: dlpSetDlpFeature.StatusInfoResult = | 81 | let statusInfoResult: dlpSetDlpFeature.StatusInfoResult = |
| 83 | - await dlpSetDlpFeature.setDlpFeature(dlpSetDlpFeature.DlpFeatureStatus.ENABLED_FEATURE); // Record the execution result. | 82 | + await dlpSetDlpFeature.setDlpFeature(dlpSetDlpFeature.DlpFeatureStatus.ENABLED_FEATURE); |
| 84 | - console.info('setDlpFeature result: ', JSON.stringify(statusInfoResult)); | 83 | + console.info('setDlpFeature result: ', JSON.stringify(statusInfoResult)); |
| 85 | } // Set the DLP status. | 84 | } // Set the DLP status. |
| 86 | 85 | ||
| 87 | exampleFunction(); | 86 | exampleFunction(); |
| @@ -103,7 +102,7 @@ Describes the DLP settings. | |||
| 103 | | -------- | -------- | -------- | -------- | -------- | | 102 | | -------- | -------- | -------- | -------- | -------- | |
| 104 | | isSuccess | boolean | No| No| Whether the DLP setting is successful. The value **true** indicates that the setting is successful, and the value **false** indicates that the setting fails.| | 103 | | isSuccess | boolean | No| No| Whether the DLP setting is successful. The value **true** indicates that the setting is successful, and the value **false** indicates that the setting fails.| |
| 105 | 104 | ||
| 106 | -## DLPFeatureInfo | 105 | +## DlpFeatureInfo |
| 107 | 106 | ||
| 108 | Sets the DLP status. | 107 | Sets the DLP status. |
| 109 | 108 | ||