196279301Sopenharmony_ci/*
296279301Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
396279301Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
496279301Sopenharmony_ci * you may not use this file except in compliance with the License.
596279301Sopenharmony_ci * You may obtain a copy of the License at
696279301Sopenharmony_ci *
796279301Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
896279301Sopenharmony_ci *
996279301Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1096279301Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1196279301Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1296279301Sopenharmony_ci * See the License for the specific language governing permissions and
1396279301Sopenharmony_ci * limitations under the License.
1496279301Sopenharmony_ci */
1596279301Sopenharmony_ci
1696279301Sopenharmony_ci#ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_H
1796279301Sopenharmony_ci#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_H
1896279301Sopenharmony_ci
1996279301Sopenharmony_ci#include "notification_request.h"
2096279301Sopenharmony_ci#include "parcel.h"
2196279301Sopenharmony_ci#include "uri.h"
2296279301Sopenharmony_ci
2396279301Sopenharmony_cinamespace OHOS {
2496279301Sopenharmony_cinamespace Notification {
2596279301Sopenharmony_ciclass Notification final : public Parcelable {
2696279301Sopenharmony_cipublic:
2796279301Sopenharmony_ci    /**
2896279301Sopenharmony_ci     * @brief A constructor used to create a Notification instance by existing NotificationRequest object.
2996279301Sopenharmony_ci     *
3096279301Sopenharmony_ci     * @param request Indicates the existing NotificationRequest object.
3196279301Sopenharmony_ci     */
3296279301Sopenharmony_ci    Notification(const sptr<NotificationRequest> &request);
3396279301Sopenharmony_ci
3496279301Sopenharmony_ci    /**
3596279301Sopenharmony_ci     * @brief A constructor used to create a Notification instance by existing NotificationRequest object.
3696279301Sopenharmony_ci     *
3796279301Sopenharmony_ci     * @param deviceId Indicates the device id.
3896279301Sopenharmony_ci     * @param request Indicates the existing NotificationRequest object.
3996279301Sopenharmony_ci     */
4096279301Sopenharmony_ci    Notification(const std::string &deviceId, const sptr<NotificationRequest> &request);
4196279301Sopenharmony_ci
4296279301Sopenharmony_ci    /**
4396279301Sopenharmony_ci     * @brief A constructor used to create a Notification instance by copying parameters from an existing one.
4496279301Sopenharmony_ci     *
4596279301Sopenharmony_ci     * @param other Indicates the Notification object.
4696279301Sopenharmony_ci     */
4796279301Sopenharmony_ci    Notification(const Notification &other);
4896279301Sopenharmony_ci
4996279301Sopenharmony_ci    ~Notification();
5096279301Sopenharmony_ci
5196279301Sopenharmony_ci    /**
5296279301Sopenharmony_ci     * @brief Obtains whether to enable the notification light when a notification is received on the device, provided
5396279301Sopenharmony_ci     * that this device has a notification light.
5496279301Sopenharmony_ci     *
5596279301Sopenharmony_ci     * @return Returns true if led light color is set.
5696279301Sopenharmony_ci     */
5796279301Sopenharmony_ci    bool EnableLight() const;
5896279301Sopenharmony_ci
5996279301Sopenharmony_ci    /**
6096279301Sopenharmony_ci     * @brief Obtains the sound enabled or not, set by ANS.
6196279301Sopenharmony_ci     *
6296279301Sopenharmony_ci     * @return Returns true if sound is set.
6396279301Sopenharmony_ci     */
6496279301Sopenharmony_ci    bool EnableSound() const;
6596279301Sopenharmony_ci
6696279301Sopenharmony_ci    /**
6796279301Sopenharmony_ci     * @brief Obtains the vibrate enabled or not, set by ANS.
6896279301Sopenharmony_ci     *
6996279301Sopenharmony_ci     * @return Returns true if vibrate style is set.
7096279301Sopenharmony_ci     */
7196279301Sopenharmony_ci    bool EnableVibrate() const;
7296279301Sopenharmony_ci
7396279301Sopenharmony_ci    /**
7496279301Sopenharmony_ci     * @brief Obtains the bundle's name which publish this notification.
7596279301Sopenharmony_ci     *
7696279301Sopenharmony_ci     * @return Returns the bundle's name.
7796279301Sopenharmony_ci     */
7896279301Sopenharmony_ci    std::string GetBundleName() const;
7996279301Sopenharmony_ci
8096279301Sopenharmony_ci    /**
8196279301Sopenharmony_ci     * @brief Obtains the bundle's name which create this notification.
8296279301Sopenharmony_ci     *
8396279301Sopenharmony_ci     * @return Returns the creator bundle name.
8496279301Sopenharmony_ci     */
8596279301Sopenharmony_ci    std::string GetCreateBundle() const;
8696279301Sopenharmony_ci
8796279301Sopenharmony_ci    /**
8896279301Sopenharmony_ci     * @brief Obtains the label of this notification.
8996279301Sopenharmony_ci     *
9096279301Sopenharmony_ci     * @return Returns the label.
9196279301Sopenharmony_ci     */
9296279301Sopenharmony_ci    std::string GetLabel() const;
9396279301Sopenharmony_ci
9496279301Sopenharmony_ci    /**
9596279301Sopenharmony_ci     * @brief Obtains the color of the notification light in a NotificationSlot object
9696279301Sopenharmony_ci     *
9796279301Sopenharmony_ci     * @return Returns the color of the notification light.
9896279301Sopenharmony_ci     */
9996279301Sopenharmony_ci    int32_t GetLedLightColor() const;
10096279301Sopenharmony_ci
10196279301Sopenharmony_ci    /**
10296279301Sopenharmony_ci     * @brief Sets the notification display effect, including whether to display this notification on the lock screen,
10396279301Sopenharmony_ci     * and how it will be presented if displayed.
10496279301Sopenharmony_ci     *
10596279301Sopenharmony_ci     * @return Returns the display effect of this notification on the lock screen.
10696279301Sopenharmony_ci     */
10796279301Sopenharmony_ci    NotificationConstant::VisiblenessType GetLockscreenVisibleness() const;
10896279301Sopenharmony_ci
10996279301Sopenharmony_ci    /**
11096279301Sopenharmony_ci     * @brief The ID passed to setGroup(), or the override, or null.
11196279301Sopenharmony_ci     *
11296279301Sopenharmony_ci     * @return Returns the string of group.
11396279301Sopenharmony_ci     */
11496279301Sopenharmony_ci    std::string GetGroup() const;
11596279301Sopenharmony_ci
11696279301Sopenharmony_ci    /**
11796279301Sopenharmony_ci     * @brief Obtains the id of the notification.
11896279301Sopenharmony_ci     *
11996279301Sopenharmony_ci     * @return Returns the id supplied to NotificationManager::Notify(int, NotificationRequest).
12096279301Sopenharmony_ci     */
12196279301Sopenharmony_ci    int32_t GetId() const;
12296279301Sopenharmony_ci
12396279301Sopenharmony_ci    /**
12496279301Sopenharmony_ci     * @brief A key for this notification record.
12596279301Sopenharmony_ci     *
12696279301Sopenharmony_ci     * @return Returns a unique instance key.
12796279301Sopenharmony_ci     */
12896279301Sopenharmony_ci    std::string GetKey() const;
12996279301Sopenharmony_ci
13096279301Sopenharmony_ci    /**
13196279301Sopenharmony_ci     * @brief Obtains the notification request set by ANS.
13296279301Sopenharmony_ci     *
13396279301Sopenharmony_ci     * @return Returns NotificationRequest object.
13496279301Sopenharmony_ci     */
13596279301Sopenharmony_ci    NotificationRequest GetNotificationRequest() const;
13696279301Sopenharmony_ci
13796279301Sopenharmony_ci    /**
13896279301Sopenharmony_ci     * @brief Obtains the notification request point set by ANS.
13996279301Sopenharmony_ci     *
14096279301Sopenharmony_ci     * @return Returns NotificationRequest sptr.
14196279301Sopenharmony_ci     */
14296279301Sopenharmony_ci    sptr<NotificationRequest> GetNotificationRequestPoint() const;
14396279301Sopenharmony_ci
14496279301Sopenharmony_ci    /**
14596279301Sopenharmony_ci     * @brief Obtains the time notification was posted.
14696279301Sopenharmony_ci     *
14796279301Sopenharmony_ci     * @return Returns the time notificationRequest was posted.
14896279301Sopenharmony_ci     */
14996279301Sopenharmony_ci    int64_t GetPostTime() const;
15096279301Sopenharmony_ci
15196279301Sopenharmony_ci    /**
15296279301Sopenharmony_ci     * @brief Obtains the sound uri.
15396279301Sopenharmony_ci     *
15496279301Sopenharmony_ci     * @return Returns the sound set by ANS.
15596279301Sopenharmony_ci     */
15696279301Sopenharmony_ci    Uri GetSound() const;
15796279301Sopenharmony_ci
15896279301Sopenharmony_ci    /**
15996279301Sopenharmony_ci     * @brief Obtains the UID of the notification creator.
16096279301Sopenharmony_ci     *
16196279301Sopenharmony_ci     * @return Returns the UID of the notification creator.
16296279301Sopenharmony_ci     */
16396279301Sopenharmony_ci    int32_t GetUid() const;
16496279301Sopenharmony_ci
16596279301Sopenharmony_ci    /**
16696279301Sopenharmony_ci     * @brief Obtains the PID of the notification creator.
16796279301Sopenharmony_ci     *
16896279301Sopenharmony_ci     * @return Returns the PID of the notification creator.
16996279301Sopenharmony_ci     */
17096279301Sopenharmony_ci    pid_t GetPid() const;
17196279301Sopenharmony_ci
17296279301Sopenharmony_ci    /**
17396279301Sopenharmony_ci     * @brief Checks whether this notification is unremovable.
17496279301Sopenharmony_ci     * @return Returns true if this notification is unremovable; returns false otherwise.
17596279301Sopenharmony_ci     */
17696279301Sopenharmony_ci    bool IsUnremovable() const;
17796279301Sopenharmony_ci
17896279301Sopenharmony_ci    /**
17996279301Sopenharmony_ci     * @brief Obtains the vibration style for this notifications.
18096279301Sopenharmony_ci     *
18196279301Sopenharmony_ci     * @return Returns the vibration style.
18296279301Sopenharmony_ci     */
18396279301Sopenharmony_ci    std::vector<int64_t> GetVibrationStyle() const;
18496279301Sopenharmony_ci
18596279301Sopenharmony_ci    /**
18696279301Sopenharmony_ci     * @brief This notification is part of a group or not.
18796279301Sopenharmony_ci     *
18896279301Sopenharmony_ci     * @return Returns true if this notification is part of a group.
18996279301Sopenharmony_ci     */
19096279301Sopenharmony_ci    bool IsGroup() const;
19196279301Sopenharmony_ci
19296279301Sopenharmony_ci    /**
19396279301Sopenharmony_ci     * @brief Checks whether this notification is displayed as a floating icon on top of the screen.
19496279301Sopenharmony_ci     *
19596279301Sopenharmony_ci     * @return Returns true if this notification is displayed as a floating icon; returns false otherwise.
19696279301Sopenharmony_ci     */
19796279301Sopenharmony_ci    bool IsFloatingIcon() const;
19896279301Sopenharmony_ci
19996279301Sopenharmony_ci    /**
20096279301Sopenharmony_ci     * @brief Obtains the remind type of a notification.
20196279301Sopenharmony_ci     * @return Returns the remind type of a notification.
20296279301Sopenharmony_ci     */
20396279301Sopenharmony_ci    NotificationConstant::RemindType GetRemindType() const;
20496279301Sopenharmony_ci
20596279301Sopenharmony_ci    /**
20696279301Sopenharmony_ci     * @brief Whether to support remove allowed.
20796279301Sopenharmony_ci     * @return Returns the current remove allowed status.
20896279301Sopenharmony_ci     */
20996279301Sopenharmony_ci    bool IsRemoveAllowed() const;
21096279301Sopenharmony_ci
21196279301Sopenharmony_ci    /**
21296279301Sopenharmony_ci     * @brief Gets the notification source.
21396279301Sopenharmony_ci     * @return Returns the notification slot type.
21496279301Sopenharmony_ci     */
21596279301Sopenharmony_ci    NotificationConstant::SourceType GetSourceType() const;
21696279301Sopenharmony_ci
21796279301Sopenharmony_ci    /**
21896279301Sopenharmony_ci     * @brief Gets the device id of the notification source.
21996279301Sopenharmony_ci     *
22096279301Sopenharmony_ci     * @return Returns the device id.
22196279301Sopenharmony_ci     */
22296279301Sopenharmony_ci    std::string GetDeviceId() const;
22396279301Sopenharmony_ci
22496279301Sopenharmony_ci    /**
22596279301Sopenharmony_ci     * @brief Obtains the UserId of the notification creator.
22696279301Sopenharmony_ci     *
22796279301Sopenharmony_ci     * @return Returns the UserId of the notification creator.
22896279301Sopenharmony_ci     */
22996279301Sopenharmony_ci    int32_t GetUserId() const;
23096279301Sopenharmony_ci
23196279301Sopenharmony_ci    /**
23296279301Sopenharmony_ci     * @brief Obtains the instance key of the notification creator.
23396279301Sopenharmony_ci     *
23496279301Sopenharmony_ci     * @return Returns the instance key of the notification creator.
23596279301Sopenharmony_ci     */
23696279301Sopenharmony_ci    int32_t GetInstanceKey() const;
23796279301Sopenharmony_ci
23896279301Sopenharmony_ci    /**
23996279301Sopenharmony_ci     * @brief Obtains the UserId of the notification receiver.
24096279301Sopenharmony_ci     *
24196279301Sopenharmony_ci     * @return Returns the UserId of the notification receiver.
24296279301Sopenharmony_ci     */
24396279301Sopenharmony_ci    int32_t GetRecvUserId() const;
24496279301Sopenharmony_ci
24596279301Sopenharmony_ci    /**
24696279301Sopenharmony_ci     * @brief Dumps a string representation of the object.
24796279301Sopenharmony_ci     *
24896279301Sopenharmony_ci     * @return Returns a string representation of the object.
24996279301Sopenharmony_ci     */
25096279301Sopenharmony_ci    std::string Dump() const;
25196279301Sopenharmony_ci
25296279301Sopenharmony_ci    /**
25396279301Sopenharmony_ci     * @brief Marshals a Notification object into a Parcel.
25496279301Sopenharmony_ci     *
25596279301Sopenharmony_ci     * @param parcel Indicates the Parcel object for marshalling.
25696279301Sopenharmony_ci     * @return Returns true if the marshalling is successful; returns false otherwise.
25796279301Sopenharmony_ci     */
25896279301Sopenharmony_ci    bool Marshalling(Parcel &parcel) const;
25996279301Sopenharmony_ci
26096279301Sopenharmony_ci    /**
26196279301Sopenharmony_ci     * @brief Unmarshals a Notification object from a Parcel.
26296279301Sopenharmony_ci     *
26396279301Sopenharmony_ci     * @param Indicates the Parcel object for unmarshalling.
26496279301Sopenharmony_ci     * @return Returns true if the unmarshalling is successful; returns false otherwise.
26596279301Sopenharmony_ci     */
26696279301Sopenharmony_ci    static Notification *Unmarshalling(Parcel &parcel);
26796279301Sopenharmony_ci
26896279301Sopenharmony_ci    /**
26996279301Sopenharmony_ci     * @brief Obtains the update timer id.
27096279301Sopenharmony_ci     *
27196279301Sopenharmony_ci     * @return Returns the id of the notification update timer.
27296279301Sopenharmony_ci     */
27396279301Sopenharmony_ci    uint64_t GetUpdateTimer() const;
27496279301Sopenharmony_ci
27596279301Sopenharmony_ci    /**
27696279301Sopenharmony_ci     * @brief Obtains the update timer id.
27796279301Sopenharmony_ci     *
27896279301Sopenharmony_ci     * @param updateTimerId the id of the notification update timer.
27996279301Sopenharmony_ci     */
28096279301Sopenharmony_ci    void SetUpdateTimer(uint64_t updateTimerId);
28196279301Sopenharmony_ci
28296279301Sopenharmony_ci    /**
28396279301Sopenharmony_ci     * @brief Obtains the finish timer id of notification.
28496279301Sopenharmony_ci     *
28596279301Sopenharmony_ci     * @return Returns the id of the notification finish timer.
28696279301Sopenharmony_ci     */
28796279301Sopenharmony_ci    uint64_t GetFinishTimer() const;
28896279301Sopenharmony_ci
28996279301Sopenharmony_ci    /**
29096279301Sopenharmony_ci     * @brief Obtains the finish timer id.
29196279301Sopenharmony_ci     *
29296279301Sopenharmony_ci     * @param finishTimerId the id of the notification finish timer.
29396279301Sopenharmony_ci     */
29496279301Sopenharmony_ci    void SetFinishTimer(uint64_t finishTimerId);
29596279301Sopenharmony_ci
29696279301Sopenharmony_ci    /**
29796279301Sopenharmony_ci     * @brief Obtains the archive timer id of notification.
29896279301Sopenharmony_ci     *
29996279301Sopenharmony_ci     * @return Returns the id of the notification archive timer.
30096279301Sopenharmony_ci     */
30196279301Sopenharmony_ci    uint64_t GetArchiveTimer() const;
30296279301Sopenharmony_ci
30396279301Sopenharmony_ci    /**
30496279301Sopenharmony_ci     * @brief Obtains the archive timer id.
30596279301Sopenharmony_ci     *
30696279301Sopenharmony_ci     * @param archiveTimerId the id of the notification archive timer.
30796279301Sopenharmony_ci     */
30896279301Sopenharmony_ci    void SetArchiveTimer(uint64_t archiveTimerId);
30996279301Sopenharmony_ci
31096279301Sopenharmony_ci    /**
31196279301Sopenharmony_ci     * @brief Obtains the autoDeleted timer id of notification.
31296279301Sopenharmony_ci     *
31396279301Sopenharmony_ci     * @return Returns the id of the notification autoDeleted timer.
31496279301Sopenharmony_ci     */
31596279301Sopenharmony_ci    uint64_t GetAutoDeletedTimer() const;
31696279301Sopenharmony_ci
31796279301Sopenharmony_ci    /**
31896279301Sopenharmony_ci     * @brief Obtains the autoDeleted timer id.
31996279301Sopenharmony_ci     *
32096279301Sopenharmony_ci     * @param autoDeletedTimerId the id of the notification archive autoDeleted.
32196279301Sopenharmony_ci     */
32296279301Sopenharmony_ci    void SetAutoDeletedTimer(uint64_t autoDeletedTimerId);
32396279301Sopenharmony_ci
32496279301Sopenharmony_ciprivate:
32596279301Sopenharmony_ci    Notification();
32696279301Sopenharmony_ci    void SetEnableSound(const bool &enable);
32796279301Sopenharmony_ci    void SetEnableLight(const bool &enable);
32896279301Sopenharmony_ci    void SetEnableVibration(const bool &enable);
32996279301Sopenharmony_ci    void SetLedLightColor(const int32_t &color);
33096279301Sopenharmony_ci    void SetLockScreenVisbleness(const NotificationConstant::VisiblenessType &visbleness);
33196279301Sopenharmony_ci    void SetPostTime(const int64_t &time);
33296279301Sopenharmony_ci    void SetSound(const Uri &sound);
33396279301Sopenharmony_ci    void SetVibrationStyle(const std::vector<int64_t> &style);
33496279301Sopenharmony_ci    void SetRemindType(const NotificationConstant::RemindType &reminType);
33596279301Sopenharmony_ci    void SetRemoveAllowed(bool removeAllowed);
33696279301Sopenharmony_ci    void SetSourceType(NotificationConstant::SourceType sourceType);
33796279301Sopenharmony_ci    bool ReadFromParcel(Parcel &parcel);
33896279301Sopenharmony_ci    void ReadFromParcelBool(Parcel &parcel);
33996279301Sopenharmony_ci    void ReadFromParcelString(Parcel &parcel);
34096279301Sopenharmony_ci    void ReadFromParcelInt32(Parcel &parcel);
34196279301Sopenharmony_ci    void ReadFromParcelInt64(Parcel &parcel);
34296279301Sopenharmony_ci    void ReadFromParcelUint64(Parcel &parcel);
34396279301Sopenharmony_ci    bool ReadFromParcelParcelable(Parcel &parcel);
34496279301Sopenharmony_ci    bool MarshallingBool(Parcel &parcel) const;
34596279301Sopenharmony_ci    bool MarshallingString(Parcel &parcel) const;
34696279301Sopenharmony_ci    bool MarshallingInt32(Parcel &parcel) const;
34796279301Sopenharmony_ci    bool MarshallingInt64(Parcel &parcel) const;
34896279301Sopenharmony_ci    bool MarshallingUint64(Parcel &parcel) const;
34996279301Sopenharmony_ci    bool MarshallingParcelable(Parcel &parcel) const;
35096279301Sopenharmony_ci
35196279301Sopenharmony_ciprivate:
35296279301Sopenharmony_ci    bool enableSound_ {false};
35396279301Sopenharmony_ci    bool enableLight_ {false};
35496279301Sopenharmony_ci    bool enableVibration_ {false};
35596279301Sopenharmony_ci    bool isRemoveAllowed_ {true};
35696279301Sopenharmony_ci    std::string key_ {""};
35796279301Sopenharmony_ci    std::string deviceId_ {""};
35896279301Sopenharmony_ci    int32_t ledLightColor_ {0};
35996279301Sopenharmony_ci    NotificationConstant::VisiblenessType lockscreenVisibleness_ {NotificationConstant::VisiblenessType::NO_OVERRIDE};
36096279301Sopenharmony_ci    NotificationConstant::RemindType remindType_ {NotificationConstant::RemindType::NONE};
36196279301Sopenharmony_ci    NotificationConstant::SourceType sourceType_ {NotificationConstant::SourceType::TYPE_NORMAL};
36296279301Sopenharmony_ci    sptr<NotificationRequest> request_ {nullptr};
36396279301Sopenharmony_ci    int64_t postTime_ {0};
36496279301Sopenharmony_ci    uint64_t updateTimerId_ {0};
36596279301Sopenharmony_ci    uint64_t finishTimerId_ {0};
36696279301Sopenharmony_ci    uint64_t archiveTimerId_ {0};
36796279301Sopenharmony_ci    std::shared_ptr<Uri> sound_ {nullptr};
36896279301Sopenharmony_ci    std::vector<int64_t> vibrationStyle_ {};
36996279301Sopenharmony_ci    uint64_t autoDeletedTimerId_ {0};
37096279301Sopenharmony_ci
37196279301Sopenharmony_ci    friend class AdvancedNotificationService;
37296279301Sopenharmony_ci    friend class NotificationSlotFilter;
37396279301Sopenharmony_ci    friend class DisturbFilter;
37496279301Sopenharmony_ci};
37596279301Sopenharmony_ci}  // namespace Notification
37696279301Sopenharmony_ci}  // namespace OHOS
37796279301Sopenharmony_ci#endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_H
378