1bc2ed2b3Sopenharmony_ci/*
2bc2ed2b3Sopenharmony_ci * Copyright (C) 2024 Huawei Device Co., Ltd.
3bc2ed2b3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4bc2ed2b3Sopenharmony_ci * you may not use this file except in compliance with the License.
5bc2ed2b3Sopenharmony_ci * You may obtain a copy of the License at
6bc2ed2b3Sopenharmony_ci *
7bc2ed2b3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8bc2ed2b3Sopenharmony_ci *
9bc2ed2b3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10bc2ed2b3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11bc2ed2b3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12bc2ed2b3Sopenharmony_ci * See the License for the specific language governing permissions and
13bc2ed2b3Sopenharmony_ci * limitations under the License.
14bc2ed2b3Sopenharmony_ci */
15bc2ed2b3Sopenharmony_ci
16bc2ed2b3Sopenharmony_ci#ifndef NFC_NOTIFICATION_H
17bc2ed2b3Sopenharmony_ci#define NFC_NOTIFICATION_H
18bc2ed2b3Sopenharmony_ci
19bc2ed2b3Sopenharmony_ci#include <mutex>
20bc2ed2b3Sopenharmony_ci#include <string>
21bc2ed2b3Sopenharmony_ci
22bc2ed2b3Sopenharmony_ci#include "image_source.h"
23bc2ed2b3Sopenharmony_ci#include "pixel_map.h"
24bc2ed2b3Sopenharmony_ci
25bc2ed2b3Sopenharmony_ci#ifdef __cplusplus
26bc2ed2b3Sopenharmony_ci#if __cplusplus
27bc2ed2b3Sopenharmony_ciextern "C" {
28bc2ed2b3Sopenharmony_ci#endif /* __cplusplus */
29bc2ed2b3Sopenharmony_ci#endif /* __cplusplus */
30bc2ed2b3Sopenharmony_ci
31bc2ed2b3Sopenharmony_citypedef void (*NfcNtfCallback)(int notificationId);
32bc2ed2b3Sopenharmony_civoid RegNotificationCallback(NfcNtfCallback callback);
33bc2ed2b3Sopenharmony_civoid PublishNfcNotification(int notificationId, const std::string &name, int balance);
34bc2ed2b3Sopenharmony_ci
35bc2ed2b3Sopenharmony_ci#ifdef __cplusplus
36bc2ed2b3Sopenharmony_ci#if __cplusplus
37bc2ed2b3Sopenharmony_ci}
38bc2ed2b3Sopenharmony_ci#endif /* __cplusplus */
39bc2ed2b3Sopenharmony_ci#endif /* __cplusplus */
40bc2ed2b3Sopenharmony_ci
41bc2ed2b3Sopenharmony_cinamespace OHOS {
42bc2ed2b3Sopenharmony_cinamespace NFC {
43bc2ed2b3Sopenharmony_cinamespace TAG {
44bc2ed2b3Sopenharmony_cienum NfcNotificationId : int {
45bc2ed2b3Sopenharmony_ci    NFC_TAG_DEFAULT_NTF_ID = 114000,
46bc2ed2b3Sopenharmony_ci    NFC_BT_NOTIFICATION_ID = 114001,
47bc2ed2b3Sopenharmony_ci    NFC_WIFI_NOTIFICATION_ID = 114002,
48bc2ed2b3Sopenharmony_ci    NFC_TRANSPORT_CARD_NOTIFICATION_ID = 114003,
49bc2ed2b3Sopenharmony_ci    NFC_BROWSER_NOTIFICATION_ID = 114004,
50bc2ed2b3Sopenharmony_ci    NFC_HCE_AID_CONFLICTED_ID = 114005,
51bc2ed2b3Sopenharmony_ci    NFC_NO_HAP_SUPPORTED_NOTIFICATION_ID = 114006,
52bc2ed2b3Sopenharmony_ci
53bc2ed2b3Sopenharmony_ci    // add NTF ID type before NFC_NTF_END
54bc2ed2b3Sopenharmony_ci    NFC_NTF_END,
55bc2ed2b3Sopenharmony_ci};
56bc2ed2b3Sopenharmony_ci
57bc2ed2b3Sopenharmony_ciconst int MAX_BUFF_LEN = 100;
58bc2ed2b3Sopenharmony_ciconst int NFC_UNIT_CHANGE_CONSTANT = 100;
59bc2ed2b3Sopenharmony_ciconst int NTF_AUTO_DELETE_TIME = 10000;
60bc2ed2b3Sopenharmony_ciconst int MAX_RES_VEC_LEN = 100;
61bc2ed2b3Sopenharmony_ciconst int NFC_NTF_CONTROL_FLAG = 0;
62bc2ed2b3Sopenharmony_ciconst int NFC_SLOT_CONTROL_FLAG = 0b101111; // no vibration
63bc2ed2b3Sopenharmony_ciconst int NTF_COUNT_CONSTANT = 1000000; // final notification id = 1000000 * count + NfcNotificationId
64bc2ed2b3Sopenharmony_ciconst int NFC_MAX_NTF_COUNT = 100;
65bc2ed2b3Sopenharmony_ci
66bc2ed2b3Sopenharmony_ciconstexpr const char* NFC_ICON_PATH = "system/etc/nfc/nfc_icon.png";
67bc2ed2b3Sopenharmony_ciconstexpr const char* NFC_RES_DEFAULT_JSON_FILEPATH = "system/etc/nfc/string_zh.json";
68bc2ed2b3Sopenharmony_ciconstexpr const char* NFC_RES_EN_JSON_FILEPATH = "system/etc/nfc/string_en.json";
69bc2ed2b3Sopenharmony_ci
70bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_STRING = "string";
71bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_NAME = "name";
72bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_VALUE = "value";
73bc2ed2b3Sopenharmony_ci
74bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_TAG_DEFAULT_NTF_TITLE     = "DefaultTitle";
75bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_TAG_DEFAULT_NTF_TEXT      = "DefaultText";
76bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_TRANSPORT_CARD_NTF_TITLE  = "TransportCardTitle";
77bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_TRANSPORT_CARD_NTF_TEXT   = "TransportCardText";
78bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_NFC_WIFI_NTF_TITLE        = "NfcWifiNtfTitle";
79bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_NFC_WIFI_NTF_TEXT         = "NfcWifiNtfText";
80bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_ACTION_BUTTON_NAME        = "ActionButtonName";
81bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_NFC_WIFI_BUTTON_NAME      = "NfcWifiButtonName";
82bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_NFC_BT_NTF_TITLE          = "NfcBtNtfTitle";
83bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_NFC_BT_NTF_TEXT           = "NfcBtNtfText";
84bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_NFC_BT_BUTTON_NAME        = "NfcBtButtonName";
85bc2ed2b3Sopenharmony_ciconstexpr const char* NFC_OPEN_LINK_BUTTON_NAME     = "NfcOpenLinkButtonName";
86bc2ed2b3Sopenharmony_ciconstexpr const char* NFC_OPEN_LINK_TEXT_HEAD       = "NfcOpenLinkTextHead";
87bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_HCE_AID_CONFLICTED_TITLE  = "NfcHceAidConflictedTitle";
88bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_HCE_AID_CONFLICTED_TEXT   = "NfcHceAidConflictedText";
89bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_NO_HAP_TITLE              = "NoHapSupportedNtfTitle";
90bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_NO_HAP_TEXT               = "NoHapSupportedNtfText";
91bc2ed2b3Sopenharmony_ciconstexpr const char* KEY_NO_HAP_BUTTON_NAME        = "NoHapSupportedNtfButtonName";
92bc2ed2b3Sopenharmony_ci
93bc2ed2b3Sopenharmony_ciclass NfcNotification {
94bc2ed2b3Sopenharmony_cipublic:
95bc2ed2b3Sopenharmony_ci    static NfcNotification& GetInstance(void);
96bc2ed2b3Sopenharmony_ci
97bc2ed2b3Sopenharmony_ci    void PublishNfcNotification(int notificationId, const std::string &name, int balance);
98bc2ed2b3Sopenharmony_ci    void RegNotificationCallback(NfcNtfCallback callback);
99bc2ed2b3Sopenharmony_ci
100bc2ed2b3Sopenharmony_ciprivate:
101bc2ed2b3Sopenharmony_ci    NfcNotification();
102bc2ed2b3Sopenharmony_ci    ~NfcNotification();
103bc2ed2b3Sopenharmony_ci    NfcNotification(const NfcNotification&) = delete;
104bc2ed2b3Sopenharmony_ci    NfcNotification& operator=(const NfcNotification&) = delete;
105bc2ed2b3Sopenharmony_ci
106bc2ed2b3Sopenharmony_ci    void GetPixelMap(const std::string &path);
107bc2ed2b3Sopenharmony_ci
108bc2ed2b3Sopenharmony_ci    std::mutex mutex_ {};
109bc2ed2b3Sopenharmony_ci    std::shared_ptr<Media::PixelMap> nfcIconPixelMap_ {};
110bc2ed2b3Sopenharmony_ci    std::vector<int> tagNtfCountVec_ {};
111bc2ed2b3Sopenharmony_ci};
112bc2ed2b3Sopenharmony_ci}  // namespace TAG
113bc2ed2b3Sopenharmony_ci}  // namespace NFC
114bc2ed2b3Sopenharmony_ci}  // namespace OHOS
115bc2ed2b3Sopenharmony_ci#endif  // NFC_NOTIFICATION_H
116