公共事件组件增加atomicservice标签

Signed-off-by: lvzhuoyao <lvzhuoyao@huawei.com>
Change-Id: I2e020dca1d25da6a8afe0a4f5cf4a4650d61bfd9
This commit is contained in:
lvzhuoyao 2023-11-08 19:03:46 +08:00
parent 397e146a6f
commit 7f5dac5035
4 changed files with 325 additions and 0 deletions

View File

@ -26,6 +26,14 @@ import { CommonEventPublishData as _CommonEventPublishData } from './commonEvent
* @syscap SystemCapability.Notification.CommonEvent
* @since 9
*/
/**
* Common event definition
*
* @namespace commonEventManager
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
declare namespace commonEventManager {
/**
* Publishes an ordered, sticky, or standard common event.
@ -40,6 +48,20 @@ declare namespace commonEventManager {
* @syscap SystemCapability.Notification.CommonEvent
* @since 9
*/
/**
* Publishes an ordered, sticky, or standard common event.
*
* @param { string } event - name of the common event.
* @param { AsyncCallback<void> } callback - The callback of publish.
* @throws { BusinessError } 401 - parameter error
* @throws { BusinessError } 1500004 - not System services
* @throws { BusinessError } 1500007 - error sending message to Common Event Service
* @throws { BusinessError } 1500008 - Common Event Service does not complete initialization
* @throws { BusinessError } 1500009 - error obtaining system parameters
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
function publish(event: string, callback: AsyncCallback<void>): void;
/**
@ -57,6 +79,22 @@ declare namespace commonEventManager {
* @syscap SystemCapability.Notification.CommonEvent
* @since 9
*/
/**
* Publishes an ordered, sticky, or standard common event.
*
* @param { string } event - name of the common event.
* @param { CommonEventPublishData } options - Indicate the CommonEventPublishData containing the common event
* content and attributes.
* @param { AsyncCallback<void> } callback - The callback of publish.
* @throws { BusinessError } 401 - parameter error
* @throws { BusinessError } 1500004 - not System services
* @throws { BusinessError } 1500007 - error sending message to Common Event Service
* @throws { BusinessError } 1500008 - Common Event Service does not complete initialization
* @throws { BusinessError } 1500009 - error obtaining system parameters
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
function publish(event: string, options: CommonEventPublishData, callback: AsyncCallback<void>): void;
/**
@ -121,6 +159,7 @@ declare namespace commonEventManager {
* @throws { BusinessError } 401 - parameter error
* @syscap SystemCapability.Notification.CommonEvent
* @crossplatform
* @atomicservice
* @since 11
*/
function createSubscriber(
@ -145,6 +184,7 @@ declare namespace commonEventManager {
* @throws { BusinessError } 401 - parameter error
* @syscap SystemCapability.Notification.CommonEvent
* @crossplatform
* @atomicservice
* @since 11
*/
function createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise<CommonEventSubscriber>;
@ -158,6 +198,16 @@ declare namespace commonEventManager {
* @syscap SystemCapability.Notification.CommonEvent
* @since 10
*/
/**
* Creates a CommonEventSubscriber for the SubscriberInfo.
*
* @param { CommonEventSubscribeInfo } subscribeInfo - Indicates the information of the subscriber.
* @returns { CommonEventSubscriber } Returns the CommonEventSubscriber object.
* @throws { BusinessError } 401 - parameter error
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
function createSubscriberSync(subscribeInfo: CommonEventSubscribeInfo): CommonEventSubscriber;
/**
@ -183,6 +233,7 @@ declare namespace commonEventManager {
* @throws { BusinessError } 1500008 - Common Event Service does not complete initialization
* @syscap SystemCapability.Notification.CommonEvent
* @crossplatform
* @atomicservice
* @since 11
*/
function subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback<CommonEventData>): void;
@ -210,6 +261,7 @@ declare namespace commonEventManager {
* @throws { BusinessError } 1500008 - Common Event Service does not complete initialization
* @syscap SystemCapability.Notification.CommonEvent
* @crossplatform
* @atomicservice
* @since 11
*/
function unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback<void>): void;
@ -289,6 +341,14 @@ declare namespace commonEventManager {
* @syscap SystemCapability.Notification.CommonEvent
* @since 9
*/
/**
* The event type that the commonEvent supported.
*
* @enum { string }
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
export enum Support {
/**
* This commonEvent means when the device is booted or system upgrade completed, and only be sent by system.
@ -1568,6 +1628,13 @@ declare namespace commonEventManager {
* @syscap SystemCapability.Notification.CommonEvent
* @since 9
*/
/**
* sent by the window manager service when the window mode is split.
*
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
COMMON_EVENT_SPLIT_SCREEN = 'common.event.SPLIT_SCREEN',
/**
@ -1849,6 +1916,13 @@ declare namespace commonEventManager {
* @syscap SystemCapability.Notification.CommonEvent
* @since 10
*/
/**
* This commonEvent means when the screen is unlocked.
*
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
COMMON_EVENT_SCREEN_UNLOCKED = 'usual.event.SCREEN_UNLOCKED',
/**
@ -1857,6 +1931,13 @@ declare namespace commonEventManager {
* @syscap SystemCapability.Notification.CommonEvent
* @since 10
*/
/**
* This commonEvent means when the screen is locked.
*
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
COMMON_EVENT_SCREEN_LOCKED = 'usual.event.SCREEN_LOCKED',
/**
@ -1866,6 +1947,14 @@ declare namespace commonEventManager {
* @syscap SystemCapability.Notification.CommonEvent
* @since 10
*/
/**
* Indicates the action of a common event that the network connectivity changed.
* This is a protected common event that can only be sent by system.
*
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
COMMON_EVENT_CONNECTIVITY_CHANGE = 'usual.event.CONNECTIVITY_CHANGE',
/**

View File

@ -20,6 +20,14 @@
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* containing the common event content and attributes
*
* @typedef CommonEventPublishData
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
export interface CommonEventPublishData {
/**
* bundle name
@ -28,6 +36,14 @@ export interface CommonEventPublishData {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* bundle name
*
* @type { ?string }
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
bundleName?: string;
/**
@ -38,6 +54,15 @@ export interface CommonEventPublishData {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* The custom result code of the common event.
*
* @type { ?number }
* @default 0
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
code?: number;
/**
@ -47,6 +72,14 @@ export interface CommonEventPublishData {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* The custom result data of the common event.
*
* @type { ?string }
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
data?: string;
/**
@ -56,6 +89,14 @@ export interface CommonEventPublishData {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* The permissions for subscribers. Only subscribers with required permissions can receive published common events.
*
* @type { ?Array<string> }
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
subscriberPermissions?: Array<string>;
/**
@ -85,5 +126,13 @@ export interface CommonEventPublishData {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* The description of the parameters in a common event.
*
* @type { ?object }
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
parameters?: { [key: string]: any };
}

View File

@ -26,6 +26,7 @@
* @typedef CommonEventSubscribeInfo
* @syscap SystemCapability.Notification.CommonEvent
* @crossplatform
* @atomicservice
* @since 11
*/
export interface CommonEventSubscribeInfo {
@ -42,6 +43,7 @@ export interface CommonEventSubscribeInfo {
* @type { Array<string> }
* @syscap SystemCapability.Notification.CommonEvent
* @crossplatform
* @atomicservice
* @since 11
*/
events: Array<string>;
@ -54,6 +56,15 @@ export interface CommonEventSubscribeInfo {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* The permission that the publisher must have in order to send a common event to this subscriber.
* This subscriber receives only common events sent by publishers granted with this permission.
*
* @type { ?string }
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
publisherPermission?: string;
/**
@ -63,6 +74,14 @@ export interface CommonEventSubscribeInfo {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* deviceId Indicates the device ID. The value must be an existing device ID on the same ohos network.
*
* @type { ?string }
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
publisherDeviceId?: string;
/**
@ -73,6 +92,15 @@ export interface CommonEventSubscribeInfo {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Indicates the user ID. This parameter is optional, and the default value is the ID of the
* current user. If this parameter is specified, the value must be an existing user ID in the system.
*
* @type { ?number }
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
userId?: number;
/**
@ -82,6 +110,14 @@ export interface CommonEventSubscribeInfo {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Indicates the subscriber priority. The value ranges from -100 to 1000.
*
* @type { ?number }
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
priority?: number;
/**
@ -89,6 +125,7 @@ export interface CommonEventSubscribeInfo {
*
* @type { ?string }
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
publisherBundleName?: string;

View File

@ -23,6 +23,14 @@ import { CommonEventSubscribeInfo } from './commonEventSubscribeInfo';
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* the subscriber of common event
*
* @interface CommonEventSubscriber
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
export interface CommonEventSubscriber {
/**
* Obtains the result code of the current ordered common event.
@ -31,6 +39,14 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Obtains the result code of the current ordered common event.
*
* @param { AsyncCallback<number> } callback - Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
getCode(callback: AsyncCallback<number>): void;
/**
@ -40,6 +56,14 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Obtains the result code of the current ordered common event.
*
* @returns { Promise<number> } Returns code of this common event
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
getCode(): Promise<number>;
/**
@ -49,6 +73,14 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 10
*/
/**
* Obtains the result code of the current ordered common event.
*
* @returns { number } Returns code of this common event
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
getCodeSync(): number;
/**
@ -59,6 +91,15 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Sets the result code of the current ordered common event.
*
* @param { number } code - Indicates the custom result code to set. You can set it to any value.
* @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
setCode(code: number, callback: AsyncCallback<void>): void;
/**
@ -69,6 +110,15 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Sets the result code of the current ordered common event.
*
* @param { number } code - Indicates the custom result code to set. You can set it to any value.
* @returns { Promise<void> } The promise returned by the function.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
setCode(code: number): Promise<void>;
/**
@ -79,6 +129,15 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 10
*/
/**
* Sets the result code of the current ordered common event.
*
* @param { number } code - Indicates the custom result code to set. You can set it to any value.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
setCodeSync(code: number): void;
/**
@ -88,6 +147,14 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Obtains the result data of the current ordered common event.
*
* @param { AsyncCallback<string> } callback - Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
getData(callback: AsyncCallback<string>): void;
/**
@ -97,6 +164,14 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Obtains the result data of the current ordered common event.
*
* @returns { Promise<string> } Returns data of this common event
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
getData(): Promise<string>;
/**
@ -106,6 +181,14 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 10
*/
/**
* Obtains the result data of the current ordered common event.
*
* @returns { string } Returns data of this common event
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
getDataSync(): string;
/**
@ -116,6 +199,15 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Sets the result data of the current ordered common event.
*
* @param { string } data - Indicates the custom result data to set. You can set it to any character string.
* @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
setData(data: string, callback: AsyncCallback<void>): void;
/**
@ -126,6 +218,15 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Sets the result data of the current ordered common event.
*
* @param { string } data - Indicates the custom result data to set. You can set it to any character string.
* @returns { Promise<void> } the promise returned by the function.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
setData(data: string): Promise<void>;
/**
@ -136,6 +237,15 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 10
*/
/**
* Sets the result data of the current ordered common event.
*
* @param { string } data - Indicates the custom result data to set. You can set it to any character string.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
setDataSync(data: string): void;
/**
@ -147,6 +257,16 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Sets the result of the current ordered common event.
*
* @param { number } code - Indicates the custom result code to set. You can set it to any value.
* @param { string } data - Indicates the custom result data to set. You can set it to any character string.
* @param { AsyncCallback<void> } callback - Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
setCodeAndData(code: number, data: string, callback: AsyncCallback<void>): void;
/**
@ -158,6 +278,16 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
/**
* Sets the result of the current ordered common event.
*
* @param { number } code - Indicates the custom result code to set. You can set it to any value.
* @param { string } data - Indicates the custom result data to set. You can set it to any character string.
* @returns { Promise<void> } The promise returned by the function.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
setCodeAndData(code: number, data: string): Promise<void>;
/**
@ -169,6 +299,16 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 10
*/
/**
* Sets the result of the current ordered common event.
*
* @param { number } code - Indicates the custom result code to set. You can set it to any value.
* @param { string } data - Indicates the custom result data to set. You can set it to any character string.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
setCodeAndDataSync(code: number, data: string): void;
/**
@ -317,6 +457,7 @@ export interface CommonEventSubscriber {
* @param { AsyncCallback<CommonEventSubscribeInfo> } callback - Indicate callback function to receive common event.
* @syscap SystemCapability.Notification.CommonEvent
* @crossplatform
* @atomicservice
* @since 11
*/
getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void;
@ -334,6 +475,7 @@ export interface CommonEventSubscriber {
* @returns { Promise<CommonEventSubscribeInfo> } Returns the commonEvent subscribe information
* @syscap SystemCapability.Notification.CommonEvent
* @crossplatform
* @atomicservice
* @since 11
*/
getSubscribeInfo(): Promise<CommonEventSubscribeInfo>;
@ -345,6 +487,14 @@ export interface CommonEventSubscriber {
* @syscap SystemCapability.Notification.CommonEvent
* @since 10
*/
/**
* Get the CommonEventSubscribeInfo of this CommonEventSubscriber.
*
* @returns { CommonEventSubscribeInfo } Returns the commonEvent subscribe information
* @syscap SystemCapability.Notification.CommonEvent
* @atomicservice
* @since 11
*/
getSubscribeInfoSync(): CommonEventSubscribeInfo;
/**