Merge remote-tracking branch 'upstream/master'

This commit is contained in:
kirby
2025-10-14 15:16:55 +08:00
6 changed files with 208 additions and 20 deletions
+10 -2
View File
@@ -23,6 +23,7 @@ import ohos.value_type.{ValueType, CArrParameters, Parameters}
/**
* Common event data.
*
*/
@!APILevel[
since: "22",
@@ -31,6 +32,7 @@ import ohos.value_type.{ValueType, CArrParameters, Parameters}
public class CommonEventData {
/**
* Name of the common event that is being received.
*
*/
@!APILevel[
since: "22",
@@ -39,6 +41,7 @@ public class CommonEventData {
public var event: String
/**
* Bundle name. This parameter is left empty by default.
*
*/
@!APILevel[
since: "22",
@@ -47,7 +50,9 @@ public class CommonEventData {
public var bundleName: String
/**
* Common event data received by the subscriber. The value of this field is the same as that of the code field in
* CommonEventPublishData when the publisher uses commonEventManager.publish to publish a common event. The default value is 0.
* CommonEventPublishData when the publisher uses commonEventManager.publish to publish a common event. The default
* value is 0.
*
*/
@!APILevel[
since: "22",
@@ -57,6 +62,7 @@ public class CommonEventData {
/**
* Common event data received by the subscriber. The value of this field is the same as that of the data field in
* CommonEventPublishData when the publisher uses commonEventManager.publish to publish a common event.
*
*/
@!APILevel[
since: "22",
@@ -65,7 +71,9 @@ public class CommonEventData {
public var data: String
/**
* Additional information about the common event received by the subscriber. The value of this field is the same as
* that of the parameters field in CommonEventPublishData when the publisher uses commonEventManager.publish to publish a common event.
* that of the parameters field in CommonEventPublishData when the publisher uses commonEventManager.publish to
* publish a common event.
*
*/
@!APILevel[
since: "22",
@@ -29,7 +29,8 @@ public import ohos.common_event_subscriber.CommonEventSubscriber
public import ohos.value_type.ValueType
/**
* The CommonEventManager module provides common event capabilities, including the capabilities to publish, subscribe to, and unsubscribe from common events.
* The CommonEventManager module provides common event capabilities, including the capabilities to publish, subscribe
* to, and unsubscribe from common events.
*/
@!APILevel[
since: "22",
@@ -42,9 +43,9 @@ public class CommonEventManager {
* @param { String } event - Name of the common event to publish.
* @param { CommonEventPublishData } options - Attributes of the common event to publish.
* @throws { BusinessException } 1500003 - The common event sending frequency too high.
* @throws { BusinessException } 1500007 - If error sending message to Common Event Service.
* @throws { BusinessException } 1500008 - If Common Event Service does not complete initialization.
* @throws { BusinessException } 1500009 - If error obtaining system parameters.
* @throws { BusinessException } 1500007 - Failed to send the message to the common event service.
* @throws { BusinessException } 1500008 - Failed to initialize the common event service.
* @throws { BusinessException } 1500009 - Failed to obtain system parameters.
*/
@!APILevel[
since: "22",
@@ -63,10 +64,11 @@ public class CommonEventManager {
}
/**
* create the CommonEventSubscriber for the SubscriberInfo.
* Create the CommonEventSubscriber for the SubscriberInfo.
*
* @param { CommonEventSubscribeInfo } subscribeInfo - Indicates the information of the subscriber.
* @returns { CommonEventSubscriber } CommonEventSubscriber instance.
* @throws { BusinessException } 1500008 - Common Event Service does not complete initialization.
*/
@!APILevel[
since: "22",
@@ -82,12 +84,13 @@ public class CommonEventManager {
}
/**
* subscribe an ordered, sticky, or standard common event.
* Subscribe an ordered, sticky, or standard common event.
*
* @param { CommonEventSubscriber } subscriber - Indicate the subscriber of the common event.
* @throws { BusinessException } 801 - capability not supported
* @throws { BusinessException } 1500007 - If error sending message to Common Event Service.
* @throws { BusinessException } 1500008 - If Common Event Service does not complete initialization.
* @param { AsyncCallback<CommonEventData> } callback - Callback used to return the result.
* @throws { BusinessException } 801 - Capability not supported.
* @throws { BusinessException } 1500007 - Failed to send the message to the common event service.
* @throws { BusinessException } 1500008 - Failed to initialize the common event service.
* @throws { BusinessException } 1500010 - The count of subscriber exceed system specification.
*/
@!APILevel[
@@ -106,12 +109,12 @@ public class CommonEventManager {
}
/**
* unsubscribe from an ordered, sticky, or standard common event.
* Unsubscribe from an ordered, sticky, or standard common event.
*
* @param { CommonEventSubscriber } subscriber - Indicate the subscriber of the common event.
* @throws { BusinessException } 801 - capability not supported
* @throws { BusinessException } 1500007 - If error sending message to Common Event Service.
* @throws { BusinessException } 1500008 - If Common Event Service does not complete initialization.
* @throws { BusinessException } 801 - Capability not supported.
* @throws { BusinessException } 1500007 - Failed to send the message to the common event service.
* @throws { BusinessException } 1500008 - Failed to initialize the common event service.
*/
@!APILevel[
since: "22",
File diff suppressed because it is too large Load Diff
@@ -24,6 +24,7 @@ import ohos.ffi.{CArrString, CTypeResource}
/**
* The CommonEventPublishData module provides APIs for defining common event content and attributes.
*
*/
@!APILevel[
since: "22",
@@ -32,6 +33,7 @@ import ohos.ffi.{CArrString, CTypeResource}
public class CommonEventPublishData {
/**
* Bundle name of the subscriber that can receive the common event.
*
*/
@!APILevel[
since: "22",
@@ -40,6 +42,7 @@ public class CommonEventPublishData {
public var bundleName: String
/**
* Common event data transferred by the publisher. The data size cannot exceed 64 KB.
*
*/
@!APILevel[
since: "22",
@@ -48,6 +51,7 @@ public class CommonEventPublishData {
public var data: String
/**
* Common event data transferred by the publisher. The default value is 0.
*
*/
@!APILevel[
since: "22",
@@ -56,6 +60,7 @@ public class CommonEventPublishData {
public var code: Int32
/**
* Permissions required for subscribers to receive the common event.
*
*/
@!APILevel[
since: "22",
@@ -64,6 +69,7 @@ public class CommonEventPublishData {
public var subscriberPermissions: Array<String>
/**
* Whether the common event is an ordered one.
*
*/
@!APILevel[
since: "22",
@@ -71,7 +77,9 @@ public class CommonEventPublishData {
]
public var isOrdered: Bool
/**
* Whether the common event is a sticky one. Only system applications and system services are allowed to send sticky events.
* Whether the common event is a sticky one. Only system applications and system services are allowed to
* send sticky events.
*
*/
@!APILevel[
since: "22",
@@ -81,6 +89,7 @@ public class CommonEventPublishData {
public var isSticky: Bool
/**
* Additional information about the common event transferred by the publisher.
*
*/
@!APILevel[
since: "22",
@@ -78,7 +78,8 @@ public class CommonEventSubscribeInfo {
]
public var events: Array<String>
/**
* Subscriber priority. The value ranges from 100 to +1000. If the value exceeds the upper or lower limit, the upper or lower limit is used.
* Subscriber priority. The value ranges from 100 to +1000. If the value exceeds the upper or lower limit, the
* upper or lower limit is used.
*/
@!APILevel[
since: "22",
@@ -86,8 +87,9 @@ public class CommonEventSubscribeInfo {
]
public var priority: Int32
/**
* User ID. If this parameter is not specified, the default value, which is the ID of the current user, will be used.
* The value must be an existing user ID in the system. Use getOsAccountLocalId to obtain the system account ID and use it as the user ID of the subscriber.
* User ID. If this parameter is not specified, the default value, which is the ID of the current user, will be
* used.The value must be an existing user ID in the system. Use getOsAccountLocalId to obtain the system account
* ID and use it as the user ID of the subscriber.
*/
@!APILevel[
since: "22",
+1 -1
View File
@@ -219,7 +219,7 @@ func getValue(value: ValueType): (Int8, CPointer<Unit>, Int64) {
case ArrayFd(v) =>
throwIfEmpty(v)
return (ARRAYFD_TYPE, createArrPtr<Int32>(v), v.size)
case _ => throw IllegalArgumentException("The type is not supported.")
case _ => throw BusinessException(1500009, "Error obtaining system parameters.")
}
}
}