From 7f6ecb143fd5c22b2ba863a8e2aec61e6b396c62 Mon Sep 17 00:00:00 2001 From: njupthan Date: Thu, 27 Jan 2022 14:02:57 +0000 Subject: [PATCH 1/4] Add dts for Distributed Signed-off-by: njupthan --- interfaces/kits/js/@ohos.notification.d.ts | 80 +++++++++++++++++++ .../js/notification/notificationRequest.d.ts | 51 ++++++++++++ 2 files changed, 131 insertions(+) diff --git a/interfaces/kits/js/@ohos.notification.d.ts b/interfaces/kits/js/@ohos.notification.d.ts index edbbd33d7..a96782068 100644 --- a/interfaces/kits/js/@ohos.notification.d.ts +++ b/interfaces/kits/js/@ohos.notification.d.ts @@ -552,6 +552,58 @@ declare namespace notification { function isSupportTemplate(templateName: string, callback: AsyncCallback): void; function isSupportTemplate(templateName: string): Promise; + /** + * Sets whether the device supports distributed notification. + * + * @since 8 + * @systemapi Hide this for inner system use. + */ + function enableDistributed(enable: boolean, callback: AsyncCallback): void; + function enableDistributed(enable: boolean): Promise; + + /** + * Obtains whether the device supports distributed notification. + * + * @since 8 + */ + function isDistributedEnabled(callback: AsyncCallback): void; + function isDistributedEnabled(): Promise; + + /** + * Sets whether an application supports distributed notification. + * + * @since 8 + * @systemapi Hide this for inner system use. + */ + function enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback): void; + function enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise; + + /** + * Sets whether the application supports distributed notification. + * + * @since 8 + */ + function enableDistributedSelf(enable: boolean, callback: AsyncCallback): void; + function enableDistributedSelf(enable: boolean): Promise; + + /** + * Obtains whether an application supports distributed notification. + * + * @since 8 + * @systemapi Hide this for inner system use. + */ + function isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback): void; + function isDistributedEnabledByBundle(bundle: BundleOption): Promise; + + /** + * Obtains the remind modes of the notification. + * + * @since 8 + * @systemapi Hide this for inner system use. + */ + function getDeviceRemindType(callback: AsyncCallback): void; + function getDeviceRemindType(): Promise; + /** * Describes a BundleOption. */ @@ -725,6 +777,34 @@ declare namespace notification { */ TYPE_TIMER = 0x00000002, } + + /** + * The remind type of the nofication. + * + * @since 8 + * @systemapi Hide this for inner system use. + */ + export enum DeviceRemindType { + /** + * The device is not in use, no reminder + */ + IDLE_DONOT_REMIND = 0, + + /** + * The device is not in use, remind + */ + IDLE_REMIND = 1, + + /** + * The device is in use, no reminder + */ + ACTIVE_DONOT_REMIND = 2, + + /** + * The device is in use, reminder + */ + ACTIVE_REMIND = 3, + } } export default notification; diff --git a/interfaces/kits/js/notification/notificationRequest.d.ts b/interfaces/kits/js/notification/notificationRequest.d.ts index 971ecb0c7..e4dabaca9 100644 --- a/interfaces/kits/js/notification/notificationRequest.d.ts +++ b/interfaces/kits/js/notification/notificationRequest.d.ts @@ -199,6 +199,21 @@ export interface NotificationRequest { */ template?: NotificationTemplate; + /** + * The options to distributed notification. + * + * @since 8 + */ + distributedOption?: DistributedOptions; + + /** + * The device ID of the notification source. + * + * @since 8 + * @systemapi Hide this for inner system use. + */ + readonly deviceId?: string; + /** * Obtains the set of identifiers for the notification. * @@ -206,3 +221,39 @@ export interface NotificationRequest { */ readonly notificationFlags?: NotificationFlags; } + + +/** + * Describes distributed options. + * + * @name DistributedOptions + * @since 8 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +export interface DistributedOptions { + /** + * Obtains whether is the distributed notification. + * + * @default true + */ + isDistributed?: boolean; + + /** + * Obtains the types of devices to which the notification can be synchronized. + */ + supportDisplayDevices?: Array; + + /** + * Obtains the devices on which notifications can be open. + */ + supportOperateDevices?: Array; + + /** + * Obtains the remind mode of the notification. enum DeviceRemindType. + + * @systemapi Hide this for inner system use. + */ + readonly remindType?: number; +} \ No newline at end of file -- Gitee From e3a4214a5d24b33d25f13ab7b2ad80a787860f11 Mon Sep 17 00:00:00 2001 From: njupthan Date: Wed, 23 Feb 2022 17:58:21 +0800 Subject: [PATCH 2/4] updsate d.ts file Signed-off-by: njupthan --- interfaces/kits/js/@ohos.notification.d.ts | 131 +++++++++++++++--- .../notificationActionButton.d.ts | 3 +- .../js/notification/notificationRequest.d.ts | 14 +- .../notification/notificationSubscriber.d.ts | 26 +++- 4 files changed, 141 insertions(+), 33 deletions(-) diff --git a/interfaces/kits/js/@ohos.notification.d.ts b/interfaces/kits/js/@ohos.notification.d.ts index a96782068..4fd30fa4b 100644 --- a/interfaces/kits/js/@ohos.notification.d.ts +++ b/interfaces/kits/js/@ohos.notification.d.ts @@ -32,8 +32,7 @@ import { NotificationRequest } from './notification/notificationRequest'; * * @name notification * @since 7 - * @sysCap SystemCapability.Notification.ANS - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Notification.Notification * @import import notification from '@ohos.notification'; * @permission N/A */ @@ -44,23 +43,37 @@ declare namespace notification { *

If a notification with the same ID has been published by the current application and has not been deleted, * this method will update the notification. * - * @param Publishes a notification. + * @param request notification request + * @param callback callback function */ function publish(request: NotificationRequest, callback: AsyncCallback): void; function publish(request: NotificationRequest): Promise; + /** + * Publishes a notification to the specified user. + * + * @since 8 + * @param Publishes a notification. + * @param userId of subscriber receiving the notification + * + */ + function publish(request: NotificationRequest, userId: number, callback: AsyncCallback): void; + function publish(request: NotificationRequest, userId: number): Promise; + /** * Cancels a notification with the specified ID. * - * @param ID of the notification to cancel, which must be unique in the application. + * @param id of the notification to cancel, which must be unique in the application. + * @param callback callback function */ function cancel(id: number, callback: AsyncCallback): void; /** * Cancels a notification with the specified label and ID. * - * @param ID of the notification to cancel, which must be unique in the application. - * @param Label of the notification to cancel. + * @param id ID of the notification to cancel, which must be unique in the application. + * @param label Label of the notification to cancel. + * @param callback callback function */ function cancel(id: number, label: string, callback: AsyncCallback): void; function cancel(id: number, label?: string): Promise; @@ -76,8 +89,9 @@ declare namespace notification { * * @param slot Indicates the notification slot to be created, which is set by {@link NotificationSlot}. * This parameter must be specified. - * + * @param callback callback function * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function addSlot(slot: NotificationSlot, callback: AsyncCallback): void; @@ -88,13 +102,15 @@ declare namespace notification { * This parameter must be specified. * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function addSlot(slot: NotificationSlot): Promise; /** * Adds a slot type. * - * @param Slot type to add. + * @param type Slot type to add. + * @param callback callback function */ function addSlot(type: SlotType, callback: AsyncCallback): void; function addSlot(type: SlotType): Promise; @@ -104,8 +120,9 @@ declare namespace notification { * * @param slots Indicates the notification slots to be created, which is set by {@link NotificationSlot}. * This parameter must be specified. - * + * @param callback callback function * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function addSlots(slots: Array, callback: AsyncCallback): void; @@ -116,14 +133,15 @@ declare namespace notification { * This parameter must be specified. * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function addSlots(slots: Array): Promise; /** * Obtains a notification slot of the specified slot type. * - * @param Type of the notification slot to obtain. - * + * @param slotType Type of the notification slot to obtain. + * @param callback callback function * @return Returns the created {@link NotificationSlot}. */ function getSlot(slotType: SlotType, callback: AsyncCallback): void; @@ -140,7 +158,8 @@ declare namespace notification { /** * Removes a NotificationSlot of the specified SlotType created by the current application. * - * @param Type of the NotificationSlot to remove. + * @param slotType Type of the NotificationSlot to remove. + * @param callback callback function */ function removeSlot(slotType: SlotType, callback: AsyncCallback): void; function removeSlot(slotType: SlotType): Promise; @@ -186,8 +205,7 @@ declare namespace notification { * * @name ContentType * @since 7 - * @sysCap SystemCapability.Notification.ANS - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Notification.Notification * @permission N/A */ export enum ContentType { @@ -311,6 +329,7 @@ declare namespace notification { * isNotificationEnabled * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback): void; @@ -318,6 +337,7 @@ declare namespace notification { * isNotificationEnabled * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function isNotificationEnabled(bundle: BundleOption): Promise; @@ -325,6 +345,7 @@ declare namespace notification { * isNotificationEnabled * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function isNotificationEnabled(callback: AsyncCallback): void; @@ -332,13 +353,25 @@ declare namespace notification { * isNotificationEnabled * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function isNotificationEnabled(): Promise; + /** + * Checks whether this application has permission to publish notifications under the user. + * + * since 8 + * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER + */ + function isNotificationEnabled(userId: number, callback: AsyncCallback): void; + function isNotificationEnabled(userId: number): Promise; + /** * displayBadge * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback): void; @@ -346,6 +379,7 @@ declare namespace notification { * displayBadge * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function displayBadge(bundle: BundleOption, enable: boolean): Promise; @@ -353,6 +387,7 @@ declare namespace notification { * isBadgeDisplayed * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback): void; @@ -360,6 +395,7 @@ declare namespace notification { * isBadgeDisplayed * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function isBadgeDisplayed(bundle: BundleOption): Promise; @@ -399,6 +435,7 @@ declare namespace notification { * getSlotNumByBundle * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback): void; @@ -406,6 +443,7 @@ declare namespace notification { * getSlotNumByBundle * * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function getSlotNumByBundle(bundle: BundleOption): Promise; @@ -457,6 +495,16 @@ declare namespace notification { */ function removeAll(callback: AsyncCallback): void; + /** + * Remove all notifications under the specified user. + * + * @since 8 + * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER + */ + function removeAll(userId: number, callback: AsyncCallback): void; + function removeAll(userId: number): Promise; + /** * removeAll * @@ -523,6 +571,16 @@ declare namespace notification { function setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback): void; function setDoNotDisturbDate(date: DoNotDisturbDate): Promise; + /** + * Set the Do Not Disturb date under the specified user. + * + * @since 8 + * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER + */ + function setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback): void; + function setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise; + /** * Obtains the Do Not Disturb date. * @@ -533,6 +591,16 @@ declare namespace notification { function getDoNotDisturbDate(callback: AsyncCallback): void; function getDoNotDisturbDate(): Promise; + /** + * Obtains the Do Not Disturb date. + * + * @since 8 + * @systemapi Hide this for inner system use under the specified user. + * @permission ohos.permission.NOTIFICATION_CONTROLLER + */ + function getDoNotDisturbDate(userId: number, callback: AsyncCallback): void; + function getDoNotDisturbDate(userId: number): Promise; + /** * Obtains whether to support the Do Not Disturb mode. * @@ -548,15 +616,33 @@ declare namespace notification { * * @since 8 * @param templateName Name of template to be Obtained + * @param callback callback function */ function isSupportTemplate(templateName: string, callback: AsyncCallback): void; function isSupportTemplate(templateName: string): Promise; + /** + * Query notification sending permission. + * + * @since 8 + */ + function isNotificationEnabledSelf(callback: AsyncCallback): void; + function isNotificationEnabledSelf(): Promise; + + /** + * Request permission to send notification. + * + * @since 8 + */ + function requestEnableNotification(callback: AsyncCallback): void; + function requestEnableNotification(): Promise; + /** * Sets whether the device supports distributed notification. * * @since 8 * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function enableDistributed(enable: boolean, callback: AsyncCallback): void; function enableDistributed(enable: boolean): Promise; @@ -574,32 +660,35 @@ declare namespace notification { * * @since 8 * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback): void; function enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise; /** - * Sets whether the application supports distributed notification. + * Obtains whether an application supports distributed notification. * * @since 8 + * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ - function enableDistributedSelf(enable: boolean, callback: AsyncCallback): void; - function enableDistributedSelf(enable: boolean): Promise; + function isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback): void; + function isDistributedEnabledByBundle(bundle: BundleOption): Promise; /** - * Obtains whether an application supports distributed notification. + * Sets whether the application supports distributed notification. * * @since 8 - * @systemapi Hide this for inner system use. */ - function isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback): void; - function isDistributedEnabledByBundle(bundle: BundleOption): Promise; + function enableDistributedSelf(enable: boolean, callback: AsyncCallback): void; + function enableDistributedSelf(enable: boolean): Promise; /** * Obtains the remind modes of the notification. * * @since 8 * @systemapi Hide this for inner system use. + * @permission ohos.permission.NOTIFICATION_CONTROLLER */ function getDeviceRemindType(callback: AsyncCallback): void; function getDeviceRemindType(): Promise; diff --git a/interfaces/kits/js/notification/notificationActionButton.d.ts b/interfaces/kits/js/notification/notificationActionButton.d.ts index 9428cc4f0..cd67a4452 100644 --- a/interfaces/kits/js/notification/notificationActionButton.d.ts +++ b/interfaces/kits/js/notification/notificationActionButton.d.ts @@ -20,9 +20,8 @@ import { WantAgent } from '../@ohos.wantAgent'; * Describes an action button displayed in a notification. * @name NotificationActionButton * @since 7 - * @devices phone, tablet, tv, wearable, car * @permission N/A - * @sysCap SystemCapability.Notification.ANS + * @syscap SystemCapability.Notification.Notification */ export interface NotificationActionButton { /** diff --git a/interfaces/kits/js/notification/notificationRequest.d.ts b/interfaces/kits/js/notification/notificationRequest.d.ts index e4dabaca9..e68532b8c 100644 --- a/interfaces/kits/js/notification/notificationRequest.d.ts +++ b/interfaces/kits/js/notification/notificationRequest.d.ts @@ -26,8 +26,7 @@ import { NotificationFlags } from './notificationFlags'; * * @name NotificationRequest * @since 7 - * @sysCap SystemCapability.Notification.ANS - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Notification.Notification * @permission N/A */ export interface NotificationRequest { @@ -163,6 +162,11 @@ export interface NotificationRequest { */ readonly creatorPid?: number; + /** + * Read-only UserId of the notification creator. + */ + readonly creatorUserId?: number; + /** * Obtains the classification of this notification. * @@ -222,14 +226,12 @@ export interface NotificationRequest { readonly notificationFlags?: NotificationFlags; } - /** * Describes distributed options. * * @name DistributedOptions * @since 8 - * @sysCap SystemCapability.Notification.ANS - * @devices phone, tablet, tv, wearable, car + * @sysCap SystemCapability.Notification.Notification * @permission N/A */ export interface DistributedOptions { @@ -256,4 +258,4 @@ export interface DistributedOptions { * @systemapi Hide this for inner system use. */ readonly remindType?: number; -} \ No newline at end of file +} diff --git a/interfaces/kits/js/notification/notificationSubscriber.d.ts b/interfaces/kits/js/notification/notificationSubscriber.d.ts index 3ae878775..d14e59c08 100644 --- a/interfaces/kits/js/notification/notificationSubscriber.d.ts +++ b/interfaces/kits/js/notification/notificationSubscriber.d.ts @@ -22,8 +22,7 @@ import notification from '../@ohos.notification'; * a notification is canceled. * * @name NotificationSubscriber - * @sysCap SystemCapability.Notification.ANS - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Notification.Notification * @permission N/A * @systemapi Hide this for inner system use. * @since 7 @@ -42,6 +41,13 @@ export interface NotificationSubscriber { * @since 8 */ onDoNotDisturbDateChange?:(mode: notification.DoNotDisturbDate) => void; + + /** + * Callback when the notificaition permission is changed. + * + * @since 8 + */ + onEnabledNotificationChanged?:(callbackData: EnabledNotificationCallbackData) => void; } /** @@ -49,8 +55,7 @@ export interface NotificationSubscriber { * a notification is canceled. * * @name SubscribeCallbackData - * @sysCap SystemCapability.Notification.ANS - * @devices phone, tablet, tv, wearable, car + * @syscap SystemCapability.Notification.Notification * @permission N/A * @systemapi Hide this for inner system use. * @since 7 @@ -61,4 +66,17 @@ export interface SubscribeCallbackData { readonly reason?: number; readonly sound?: string; readonly vibrationValues?: Array; +} + +/** + * Describes the properties of the application that the permission to send notifications has changed. + * + * @name EnabledNotificationCallbackData + * @systemapi Hide this for inner system use. + * @since 8 + */ +export interface EnabledNotificationCallbackData { + readonly bundle: string; + readonly uid: number; + readonly enable: boolean; } \ No newline at end of file -- Gitee From ba3c634292a44431f105e9c9a1cd563a161fb204 Mon Sep 17 00:00:00 2001 From: njupthan Date: Wed, 23 Feb 2022 18:15:14 +0800 Subject: [PATCH 3/4] update d.ts file Signed-off-by: njupthan --- interfaces/kits/js/@ohos.notification.d.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/interfaces/kits/js/@ohos.notification.d.ts b/interfaces/kits/js/@ohos.notification.d.ts index 9c6ba7ef5..4fd30fa4b 100644 --- a/interfaces/kits/js/@ohos.notification.d.ts +++ b/interfaces/kits/js/@ohos.notification.d.ts @@ -349,15 +349,6 @@ declare namespace notification { */ function isNotificationEnabled(callback: AsyncCallback): void; - /** - * Checks whether this application has permission to publish notifications under the user. - * - * since 8 - * @systemapi Hide this for inner system use. - */ - function isNotificationEnabled(userId: number, callback: AsyncCallback): void; - function isNotificationEnabled(userId: number): Promise; - /** * isNotificationEnabled * -- Gitee From e875effd816ae38e388f2a52f864c366b84f8606 Mon Sep 17 00:00:00 2001 From: njupthan Date: Thu, 24 Feb 2022 17:02:16 +0800 Subject: [PATCH 4/4] update d.ts file Signed-off-by: njupthan --- interfaces/kits/js/@ohos.notification.d.ts | 54 ---------------------- 1 file changed, 54 deletions(-) diff --git a/interfaces/kits/js/@ohos.notification.d.ts b/interfaces/kits/js/@ohos.notification.d.ts index 7ef22dec3..ecfb62086 100644 --- a/interfaces/kits/js/@ohos.notification.d.ts +++ b/interfaces/kits/js/@ohos.notification.d.ts @@ -677,14 +677,6 @@ declare namespace notification { function isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback): void; function isDistributedEnabledByBundle(bundle: BundleOption): Promise; - /** - * Sets whether the application supports distributed notification. - * - * @since 8 - */ - function enableDistributedSelf(enable: boolean, callback: AsyncCallback): void; - function enableDistributedSelf(enable: boolean): Promise; - /** * Obtains the remind modes of the notification. * @@ -767,29 +759,6 @@ declare namespace notification { end: Date; } - /** - * Notification source type - * - * @since 8 - * @systemapi Hide this for inner system use. - */ - export enum SourceType { - /** - * General notification - */ - TYPE_NORMAL = 0x00000000, - - /** - * Continuous notification - */ - TYPE_CONTINUOUS = 0x00000001, - - /** - * Scheduled notification - */ - TYPE_TIMER = 0x00000002, - } - /** * The type of the Do Not Disturb. * @@ -846,29 +815,6 @@ declare namespace notification { end: Date; } - /** - * Notification source type - * - * @since 8 - * @systemapi Hide this for inner system use. - */ - export enum SourceType { - /** - * General notification - */ - TYPE_NORMAL = 0x00000000, - - /** - * Continuous notification - */ - TYPE_CONTINUOUS = 0x00000001, - - /** - * Scheduled notification - */ - TYPE_TIMER = 0x00000002, - } - /** * The remind type of the nofication. * -- Gitee