From d0ae0b8c5194254aa03663617d5bf6a9fd0746a7 Mon Sep 17 00:00:00 2001 From: zhaoyuan Date: Wed, 15 Sep 2021 20:01:28 +0000 Subject: [PATCH] update d.ts files about notification Signed-off-by: zhaoyuan --- api/@ohos.bundle.d.ts | 4 +- api/@ohos.commonEvent.d.ts | 67 +-- api/@ohos.notification.d.ts | 399 ++++++++++++++++++ api/@ohos.wantAgent.d.ts | 3 +- api/ability/startAbilityParameter.d.ts | 12 - api/app/context.d.ts | 4 - api/commonEvent/commonEventSubscriber.d.ts | 2 +- .../notificationActionButton.ts} | 31 +- api/notification/notificationContent.d.ts | 77 ++++ api/notification/notificationRequest.d.ts | 69 +++ api/notification/notificationSlot.d.ts | 104 +++++ api/notification/notificationSorting.d.ts | 31 ++ api/notification/notificationSortingMap.d.ts | 30 ++ api/notification/notificationSubscribeInfo.ts | 28 ++ api/notification/notificationSubscriber.d.ts | 58 +++ 15 files changed, 815 insertions(+), 104 deletions(-) create mode 100644 api/@ohos.notification.d.ts rename api/{app/missionSnapshot.d.ts => notification/notificationActionButton.ts} (49%) create mode 100644 api/notification/notificationContent.d.ts create mode 100644 api/notification/notificationRequest.d.ts create mode 100644 api/notification/notificationSlot.d.ts create mode 100644 api/notification/notificationSorting.d.ts create mode 100644 api/notification/notificationSortingMap.d.ts create mode 100644 api/notification/notificationSubscribeInfo.ts create mode 100644 api/notification/notificationSubscriber.d.ts diff --git a/api/@ohos.bundle.d.ts b/api/@ohos.bundle.d.ts index 3969625681..d63c553cd3 100644 --- a/api/@ohos.bundle.d.ts +++ b/api/@ohos.bundle.d.ts @@ -19,7 +19,6 @@ import { BundleInfo } from './bundle/bundleInfo'; import { AbilityInfo } from './bundle/abilityInfo'; import { Want } from './ability/want'; import { BundleInstaller } from './bundle/bundleInstaller'; -import { ElementName } from './bundle/elementName'; import { ShortcutInfo } from './bundle/shortcutInfo'; import { ModuleUsageRecord } from './bundle/moduleUsageRecord'; @@ -335,7 +334,8 @@ declare namespace bundle { */ function getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void; function getLaunchWantForBundle(bundleName: string): Promise; - + + /** * Obtains information about the shortcuts of the application. * * @devices phone, tablet, tv, wearable diff --git a/api/@ohos.commonEvent.d.ts b/api/@ohos.commonEvent.d.ts index cff53acc23..19d056ce6d 100644 --- a/api/@ohos.commonEvent.d.ts +++ b/api/@ohos.commonEvent.d.ts @@ -14,7 +14,7 @@ */ import { AsyncCallback } from './basic'; import { CommonEventData } from './commonEvent/commonEventData'; -import { CommonEventSubscriber } from './commonEvent/commonEventSubscriber' +import { CommonEventSubscriber } from './commonEvent/commonEventSubscriber'; import { CommonEventSubscribeInfo } from './commonEvent/commonEventSubscribeInfo'; import { CommonEventPublishData } from './commonEvent/commonEventPublishData'; @@ -45,7 +45,6 @@ declare namespace commonEvent { */ function publish(event: string, options: CommonEventPublishData, callback: AsyncCallback): void; - /** * create the CommonEventSubscriber for the SubscriberInfo. * @@ -402,7 +401,7 @@ declare namespace commonEvent { /** * Indicates Wi-Fi MpLink state notification acknowledged by binding or unbinding MpLink. */ - COMMON_EVENT_WIFI_MPLINK_STATE = "usual.event.wifi.mplink.STATE_CHANGE", + COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE = "usual.event.wifi.mplink.STATE_CHANGE", /** * Indicates Wi-Fi P2P connection state notification acknowledged by connecting or disconnecting P2P. @@ -796,19 +795,6 @@ declare namespace commonEvent { */ COMMON_EVENT_IVI_ACTIVE = "common.event.IVI_ACTIVE", - /** - * The usb state changed. - * This is a protected common event that can only be sent by system. - */ - COMMON_EVENT_USB_STATE = "usual.event.hardware.usb.action.USB_STATE", - - /** - * The usb port changed. - * This is a protected common event that can only be sent by system. - */ - COMMON_EVENT_USB_PORT_CHANGED = - "usual.event.hardware.usb.action.USB_PORT_CHANGED", - /** * The usb device attached. * This is a protected common event that can only be sent by system. @@ -837,30 +823,6 @@ declare namespace commonEvent { COMMON_EVENT_USB_ACCESSORY_DETACHED = "usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED", - /** - * The storage space is low. - * This is a protected common event that can only be sent by system. - */ - COMMON_EVENT_DEVICE_STORAGE_LOW = "usual.event.DEVICE_STORAGE_LOW", - - /** - * The storage space is normal. - * This is a protected common event that can only be sent by system. - */ - COMMON_EVENT_DEVICE_STORAGE_OK = "usual.event.DEVICE_STORAGE_OK", - - /** - * The storage space is full. - * This is a protected common event that can only be sent by system. - */ - COMMON_EVENT_DEVICE_STORAGE_FULL = "usual.event.DEVICE_STORAGE_FULL", - - /** - * The network connection was changed. - * This is a protected common event that can only be sent by system. - */ - COMMON_EVENT_CONNECTIVITY_CHANGE = "usual.event.CONNECTIVITY_CHANGE", - /** * The external storage was removed. * This is a protected common event that can only be sent by system. @@ -916,34 +878,11 @@ declare namespace commonEvent { */ COMMON_EVENT_FOUNDATION_READY = "common.event.FOUNDATION_READY", - /** - * Indicates the action of a common event that the phone SIM card state has changed. - * This is a protected common event that can only be sent by system. - */ - COMMON_EVENT_SIM_CARD_DEFAULT_VOICE_SUBSCRIPTION_CHANGED = - "usual.event.SIM.DEFAULT_VOICE_SUBSCRIPTION_CHANGED", - - /** - * Indicates the action of a common event that the phone SIM card state has changed. - * This is a protected common event that can only be sent by system. - */ - COMMON_EVENT_SIM_STATE_CHANGED = "usual.event.SIM.CARD_STATE_CHANGED", - /** * Indicates the common event Action indicating that the airplane mode status of the device changes. * Users can register this event to listen to the change of the airplane mode status of the device. */ - COMMON_EVENT_AIRPLANE_MODE_CHANGED = "usual.event.AIRPLANE_MODE", - - /** - * Only for test case. - */ - COMMON_EVENT_TEST_ACTION1 = "usual.event.test1", - - /** - * Only for test case. - */ - COMMON_EVENT_TEST_ACTION2 = "usual.event.test2" + COMMON_EVENT_AIRPLANE_MODE_CHANGED = "usual.event.AIRPLANE_MODE" } } diff --git a/api/@ohos.notification.d.ts b/api/@ohos.notification.d.ts new file mode 100644 index 0000000000..869beba60a --- /dev/null +++ b/api/@ohos.notification.d.ts @@ -0,0 +1,399 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AsyncCallback } from './basic'; +import { NotificationSlot } from './notification/notificationSlot'; +import { NotificationSubscriber } from './notification/notificationSubscriber'; +import { NotificationSubscribeInfo } from './notification/notificationSubscribeInfo'; +import { NotificationRequest } from './notification/notificationRequest'; + +/** + * Manages notifications. + * + *

Generally, only system applications have permissions on notification subscription and unsubscription. + * You can specify the content of a notification to be published and the content is carried by + * {@link NotificationRequest}. A notification ID is unique in an application and must be specified + * when using {@link NotificationRequest} to carry the notification content. If a notification + * with this ID has been published and you need to use this ID to publish another notification, + * the original notification will be updated. In addition, the notification ID can be used to cancel + * a notification by calling the {@link #cancel(int)} method. + * + * @name notification + * @since 7 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +declare namespace notification { + /** + * Publishes a 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 request Indicates the {@link NotificationRequest} object for setting the notification content. + * This parameter must be specified. + * + * @since 7 + */ + function publish(request: NotificationRequest, callback: AsyncCallback): void; + function publish(request: NotificationRequest): Promise; + + /** + * Cancels a published notification. + * + * @param id Indicates the unique notification ID in the application. The value must be the ID + * of a published notification. Otherwise, this method does not take effect. + * + * @since 7 + */ + function cancel(id: number, callback: AsyncCallback): void; + + /** + * Cancels a published notification matching the specified {@code label} and {@code notificationId}. + * + * @param label Indicates the label of the notification to cancel. + * @param id Indicates the ID of the notification to cancel. + * + * @since 7 + */ + function cancel(id: number, label: string, callback: AsyncCallback): void; + function cancel(id: number, label?: string): Promise; + + /** + * Cancels all the published notifications. + * + * @since 7 + */ + function cancelAll(callback: AsyncCallback): void; + function cancelAll(): Promise; + + /** + * Creates a notification slot. + * + * @param slot Indicates the notification slot to be created, which is set by {@link NotificationSlot}. + * This parameter must be specified. + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function addSlot(slot: NotificationSlot, callback: AsyncCallback): void; + function addSlot(slot: NotificationSlot): Promise; + + /** + * Creates a notification slot. + * + * @param slot Indicates the notification slot to be created, which is set by {@link SlotType}. + * This parameter must be specified. + * + * @since 7 + */ + function addSlot(type: SlotType, callback: AsyncCallback): void; + function addSlot(type: SlotType): Promise; + + /** + * Creates a notification slot. + * + * @param slots Indicates the notification slots to be created, which is set by {@link NotificationSlot}. + * This parameter must be specified. + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function addSlots(slots: Array, callback: AsyncCallback): void; + function addSlots(slots: Array): Promise; + + /** + * Queries a created notification slot. + * + * @param slotType Indicates the type of the slot, which is created by + * + * @return Returns the created {@link NotificationSlot}. + * + * @since 7 + */ + function getSlot(slotType: SlotType, callback: AsyncCallback): void; + function getSlot(slotType: SlotType): Promise; + + /** + * Obtains all notification slots of this application. + * + * @return Returns all notification slots of this application. + * + * @since 7 + */ + function getSlots(callback: AsyncCallback>): void; + function getSlots(): Promise>; + + /** + * Deletes a created notification slot based on the slot type. + * + * @param slotType Indicates the type of the slot. + * + * @since 7 + */ + function removeSlot(slotType: SlotType, callback: AsyncCallback): void; + function removeSlot(slotType: SlotType): Promise; + + /** + * Deletes all notification slots. + * + * @since 7 + */ + function removeAllSlots(callback: AsyncCallback): void; + function removeAllSlots(): Promise; + + /** + * Indicates the type of the slot + * + * @since 7 + */ + export enum SlotType { + UNKNOWN_TYPE = 0, + SOCIAL_COMMUNICATION = 1, + SERVICE_INFORMATION = 2, + CONTENT_INFORMATION = 3, + OTHER_TYPES = 0xFFFF, + } + + /** + * Indicates the type of the content + * + * @name ContentType + * @since 7 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ + export enum ContentType { + NOTIFICATION_CONTENT_BASIC_TEXT, + NOTIFICATION_CONTENT_LONG_TEXT, + NOTIFICATION_CONTENT_PICTURE, + NOTIFICATION_CONTENT_CONVERSATION, + NOTIFICATION_CONTENT_MULTILINE, + } + + /** + * Indicates the level of the slot + * + * @since 7 + */ + export enum SlotLevel { + LEVEL_NONE = 0, + LEVEL_MIN = 1, + LEVEL_LOW = 2, + LEVEL_DEFAULT = 3, + LEVEL_HIGH = 4, + } + + /** + * subscribe + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void; + function subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback): void; + function subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): Promise; + + /** + * unsubscribe + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void; + function unsubscribe(subscriber: NotificationSubscriber): Promise; + + /** + * enableNotification + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback): void; + function enableNotification(bundle: BundleOption, enable: boolean): Promise; + + /** + * isNotificationEnabled + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback): void; + function isNotificationEnabled(bundle: BundleOption): Promise; + + /** + * isNotificationEnabled + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function isNotificationEnabled(callback: AsyncCallback): void; + function isNotificationEnabled(): Promise; + + /** + * displayBadge + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback): void; + function displayBadge(bundle: BundleOption, enable: boolean): Promise; + + /** + * isBadgeDisplayed + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback): void; + function isBadgeDisplayed(bundle: BundleOption): Promise; + + /** + * setSlotByBundle + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback): void; + function setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + + /** + * getSlotsByBundle + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback>): void; + function getSlotsByBundle(bundle: BundleOption): Promise>; + + /** + * getSlotNumByBundle + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback): void; + function getSlotNumByBundle(bundle: BundleOption): Promise; + + /** + * remove + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback): void; + function remove(bundle: BundleOption, notificationKey: NotificationKey): Promise; + + /** + * remove + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function remove(hashCode: string, callback: AsyncCallback): void; + function remove(hashCode: string): Promise; + + /** + * removeAll + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function removeAll(bundle: BundleOption, callback: AsyncCallback): void; + function removeAll(callback: AsyncCallback): void; + function removeAll(bundle?: BundleOption): Promise; + + /** + * Obtains all active notifications in the current system. The caller must have system permissions to + * call this method. + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getAllActiveNotifications(callback: AsyncCallback>): void; + function getAllActiveNotifications(): Promise>; + + /** + * Obtains the number of active notifications of the current application in the system. + * + * @since 7 + */ + function getActiveNotificationCount(callback: AsyncCallback): void; + function getActiveNotificationCount(): Promise; + + /** + * Obtains active notifications of the current application in the system. + * + * @since 7 + */ + function getActiveNotifications(callback: AsyncCallback>): void; + function getActiveNotifications(): Promise>; + + /** + * BundleOption + * + * @since 7 + */ + export interface BundleOption { + bundle: string; + uid?: number; + } + + /** + * NotificationKey + * + * @since 7 + */ + export interface NotificationKey { + id: number; + label?: string; + } + + /** + * DisturbMode + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum DoNotDisturbMode { + ALLOW_UNKNOWN, + + /** + * Indicates that all notifications are allowed to interrupt the user in Do Not Disturb mode. + */ + ALLOW_ALL, + + /** + * Indicates that only notifications meeting the specified priority criteria are allowed to interrupt + * the user in Do Not Disturb mode. + */ + ALLOW_PRIORITY, + + /** + * Indicates that no notifications are allowed to interrupt the user in Do Not Disturb mode. + */ + ALLOW_NONE, + + /** + * Indicates that only notifications of the {@link NotificationRequest#CLASSIFICATION_ALARM} category + * are allowed to interrupt the user in Do Not Disturb mode. + */ + ALLOW_ALARMS + } +} + +export default notification; diff --git a/api/@ohos.wantAgent.d.ts b/api/@ohos.wantAgent.d.ts index 383a2ea493..2bdd0a1f0b 100644 --- a/api/@ohos.wantAgent.d.ts +++ b/api/@ohos.wantAgent.d.ts @@ -67,8 +67,7 @@ declare namespace wantAgent { START_ABILITY, START_ABILITIES, START_SERVICE, - SEND_COMMON_EVENT, - START_FOREGROUND_SERVICE + SEND_COMMON_EVENT } } diff --git a/api/ability/startAbilityParameter.d.ts b/api/ability/startAbilityParameter.d.ts index b70b1ce241..9d99dcb38d 100644 --- a/api/ability/startAbilityParameter.d.ts +++ b/api/ability/startAbilityParameter.d.ts @@ -13,7 +13,6 @@ * limitations under the License. */ import { Want } from './want'; -import { TaskSyncAnimationOptions } from './taskSyncAnimator' export interface StartAbilityParameter { /** @@ -36,15 +35,4 @@ export interface StartAbilityParameter { */ abilityStartSetting?: {[key: string]: any}; - /** - * Indicates the special start setting used in starting ability with TaskSyncAnimation. - *

Requires Permission: {@code ohos.permission.CONTROL_TASK_SYNC_ANIMATOR} - * - * @default - - * @devices phone, tablet - * @permission ohos.permission.CONTROL_TASK_SYNC_ANIMATOR - * @since 7 - * @SysCap aafwk - */ - taskSyncAnimationOptions?: TaskSyncAnimationOptions; } \ No newline at end of file diff --git a/api/app/context.d.ts b/api/app/context.d.ts index 61a6d65f7a..cb0b24f6e9 100644 --- a/api/app/context.d.ts +++ b/api/app/context.d.ts @@ -15,12 +15,8 @@ import { AsyncCallback } from '../basic'; import { ApplicationInfo } from '../bundle/applicationInfo'; -import { HapModuleInfo } from '../bundle/hapModuleInfo'; import { ProcessInfo } from './processInfo'; -import { AppVersionInfo } from './appVersionInfo'; -import { DisplayOrientation } from '../@ohos.bundle'; import { ElementName } from '../bundle/elementName'; -import { DisplayOrientation } from '../@ohos.bundle'; /** * The context of an ability or an application. It allows access to diff --git a/api/commonEvent/commonEventSubscriber.d.ts b/api/commonEvent/commonEventSubscriber.d.ts index 65e5aba353..1a8182bb1b 100644 --- a/api/commonEvent/commonEventSubscriber.d.ts +++ b/api/commonEvent/commonEventSubscriber.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ import { AsyncCallback } from './../basic'; -import { CommonEventSubscribeInfo } from './commonEventSubscribeInfo'; +import { CommonEventSubscribeInfo } from './commoneventsubscribeinfo'; /** * the subscriber of common event diff --git a/api/app/missionSnapshot.d.ts b/api/notification/notificationActionButton.ts similarity index 49% rename from api/app/missionSnapshot.d.ts rename to api/notification/notificationActionButton.ts index 01ae787ee8..140215050e 100644 --- a/api/app/missionSnapshot.d.ts +++ b/api/notification/notificationActionButton.ts @@ -1,10 +1,10 @@ /* * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"), * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http?://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,25 +13,18 @@ * limitations under the License. */ -import { ElementName } from '../bundle/elementName'; -import { image } from '../@ohos.multimedia.image'; +import { WantAgent } from '../@ohos.wantAgent'; /** - * @name This class represents a mission snapshot. + * The action button of notification + * @name NotificationActionButton * @since 7 - * @SysCap appexecfwk - * @import import MissionSnapshot from 'app/missionSnapshot' - * @devices phone, tablet - * @systemapi hide this for inner system use + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A */ -export interface MissionSnapshot { - /** - * @default The top ability in this mission snapshot - */ - topAbility: ElementName; - - /** - * @default The entity of snapshot - */ - snapshot: image.PixelMap; +export interface NotificationActionButton { + title: string; + wantAgent: WantAgent; + extras?: {[key: string]: any}; } diff --git a/api/notification/notificationContent.d.ts b/api/notification/notificationContent.d.ts new file mode 100644 index 0000000000..134218f5ef --- /dev/null +++ b/api/notification/notificationContent.d.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import notification from '../@ohos.notification'; + +/** + * Constructs basic notifications. + * + * @name NotificationBasicContent + * @since 7 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +export interface NotificationBasicContent { + title: string; + text: string; + additionalText?: string; +} + +/** + * Constructs notifications that include long text. The long text contains a maximum of 1024 characters. + * + * @name NotificationLongTextContent + * @since 7 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +export interface NotificationLongTextContent extends NotificationBasicContent { + longText: string; + briefText: string; + expandedTitle: string; +} + +/** + * Constructs a notification that includes multiple lines of text. + * + * @name NotificationMultiLineContent + * @since 7 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +export interface NotificationMultiLineContent extends NotificationBasicContent { + briefText: string; + longTitle: string; + lines: Array; +} + +/** + * Constructs a notification that includes multiple lines of text. + * + * @name NotificationMultiLineContent + * @since 7 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +export interface NotificationContent { + contentType: notification.ContentType; + normal?: NotificationBasicContent; + longText?: NotificationLongTextContent; + multiLine?: NotificationMultiLineContent; +} diff --git a/api/notification/notificationRequest.d.ts b/api/notification/notificationRequest.d.ts new file mode 100644 index 0000000000..0914b648d2 --- /dev/null +++ b/api/notification/notificationRequest.d.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http?://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import notification from '../@ohos.notification'; +import { WantAgent } from '../@ohos.wantAgent'; +import { NotificationContent } from './notificationContent'; +import { NotificationActionButton } from './notificationActionButton'; + +/** + * Carries notifications. + * + * @name NotificationRequest + * @since 7 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +export interface NotificationRequest { + content: NotificationContent; + id?: number; + slotType?: notification.SlotType; + isOngoing?: boolean; + isUnremovable?: boolean; + deliveryTime?: number; + tapDismissed?: boolean; + autoDeletedTime?: number; + wantAgent?: WantAgent; + extraInfo?: {[key: string]: any}; + color?: number; + colorEnabled?: boolean; + isAlertOnce?: boolean; + isStopwatch?: boolean; + isCountDown?: boolean; + isFloatingIcon?: boolean; + label?: string; + badgeIconStyle?: number; + showDeliveryTime?: boolean; + actionButtons?: Array; + readonly creatorBundleName?: string; + readonly creatorUid?: number; + readonly creatorPid?: number; + + /** + * Obtains the classification of this notification. + * + * @systemapi Hide this for inner system use. + * @since 7 + */ + classification?: string; + + /** + * Obtains the unique hash code of a notification in the current application. + * + * @since 7 + */ + readonly hashCode?: string; +} diff --git a/api/notification/notificationSlot.d.ts b/api/notification/notificationSlot.d.ts new file mode 100644 index 0000000000..56f987e69e --- /dev/null +++ b/api/notification/notificationSlot.d.ts @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import notification from '../@ohos.notification'; + +/** + * A constructor used to initialize the type, desc, and level of a {@code NotificationSlot} object. + * + * @name NotificationSlot + * @since 7 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +export interface NotificationSlot { + /** + * Obtains the type of a notification slot. + * + * @since 7 + */ + type: notification.SlotType; + + /** + * Obtains the level of a notification slot + * + * @since 7 + */ + level?: notification.SlotLevel; + + /** + * Obtains the description of a notification slot. + * + * @since 7 + */ + desc?: string; + + /** + * Obtains the application icon badge status of a notification slot. + * + * @since 7 + */ + badgeFlag?: boolean; + + /** + * Obtains whether DND mode is bypassed for a notification slot. + * + * @since 7 + */ + bypassDnd?: boolean; + + /** + * Whether and how to display notifications on the lock screen. + * + * @since 7 + */ + lockscreenVisibility?: number; + + /** + * Obtains the vibration status of the notification slot. + * + * @since 7 + */ + vibrationEnabled?: boolean; + + /** + * Obtains the prompt tone of the notification slot. + * + * @since 7 + */ + sound?: string; + + /** + * Obtains whether the notification light is enabled in a notification slot. + * + * @since 7 + */ + lightEnabled?: boolean; + + /** + * Obtains the color of the notification light in a notification slot. + * + * @since 7 + */ + lightColor?: number; + + /** + * Obtains the vibration style of notifications in this notification slot. + * + * @since 7 + */ + vibrationValues?: Array; +} diff --git a/api/notification/notificationSorting.d.ts b/api/notification/notificationSorting.d.ts new file mode 100644 index 0000000000..1a34e32fa2 --- /dev/null +++ b/api/notification/notificationSorting.d.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NotificationSlot } from './notificationSlot'; + +/** + * Provides sorting information about an active notification. + * + * @name NotificationSorting + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + * @since 7 + */ +export interface NotificationSorting { + readonly slot: NotificationSlot; + readonly hashCode: string; + readonly ranking: number; +} \ No newline at end of file diff --git a/api/notification/notificationSortingMap.d.ts b/api/notification/notificationSortingMap.d.ts new file mode 100644 index 0000000000..829ddaf15c --- /dev/null +++ b/api/notification/notificationSortingMap.d.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NotificationSorting } from './notificationSorting'; + +/** + * Provides sorting information about the active notifications among all the notifications that have been subscribed to + * + * @name NotificationSortingMap + * @since 7 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +interface NotificationSortingMap { + readonly sortings: {[key: string]: NotificationSorting}; + readonly sortedHashCode: Array; +} \ No newline at end of file diff --git a/api/notification/notificationSubscribeInfo.ts b/api/notification/notificationSubscribeInfo.ts new file mode 100644 index 0000000000..ea1f69fc2a --- /dev/null +++ b/api/notification/notificationSubscribeInfo.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Sets filter criteria of publishers for subscribing to desired notifications. + * + * @name NotificationSubscribeInfo + * @since 7 + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + */ +export interface NotificationSubscribeInfo { + bundleNames?: Array; + userId?: number; +} \ No newline at end of file diff --git a/api/notification/notificationSubscriber.d.ts b/api/notification/notificationSubscriber.d.ts new file mode 100644 index 0000000000..a659a9d0f1 --- /dev/null +++ b/api/notification/notificationSubscriber.d.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NotificationRequest } from './notificationRequest'; +import { NotificationSortingMap } from './notificationSortingMap'; +import notification from '../@ohos.notification'; + +/** + * Provides methods that will be called back when the subscriber receives a new notification or + * a notification is canceled. + * + * @name NotificationSubscriber + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + * @systemapi Hide this for inner system use. + * @since 7 + */ +export interface NotificationSubscriber { + onConsume?:(data: SubscribeCallbackData) => void; + onCancel?:(data: SubscribeCallbackData) => void; + onUpdate?:(data: NotificationSortingMap) => void; + onConnect?:() => void; + onDisconnect?:() => void; + onDestroy?:() => void; + onDisturbModeChange?:(mode: notification.DoNotDisturbMode) => void; +} + +/** + * Provides methods that will be called back when the subscriber receives a new notification or + * a notification is canceled. + * + * @name SubscribeCallbackData + * @sysCap SystemCapability.Notification.ANS + * @devices phone, tablet, tv, wearable, car + * @permission N/A + * @systemapi Hide this for inner system use. + * @since 7 + */ +export interface SubscribeCallbackData { + readonly request: NotificationRequest; + readonly sortingMap?: NotificationSortingMap; + readonly reason?: number; + readonly sound?: string; + readonly vibrationValues?: Array; +} \ No newline at end of file -- Gitee