• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FILEMANAGEMENT_DFS_SERVICE_SYSTEM_NOTIFIER_H
17 #define FILEMANAGEMENT_DFS_SERVICE_SYSTEM_NOTIFIER_H
18 
19 #include "pixel_map.h"
20 #include <iostream>
21 #include <mutex>
22 #include <shared_mutex>
23 #include <string>
24 #include <unistd.h>
25 #include <utility>
26 #include <vector>
27 
28 namespace OHOS {
29 namespace Storage {
30 namespace DistributedFile {
31 
32 class SystemNotifier final {
33 public:
34     ~SystemNotifier() = default;
GetInstance()35     static SystemNotifier &GetInstance()
36     {
37         static SystemNotifier instance;
38         return instance;
39     }
40 
41     int32_t CreateLocalLiveView(const std::string &networkId);
42     int32_t CreateNotification(const std::string &networkId);
43     int32_t DestroyNotifyByNetworkId(const std::string &networkId);
44     int32_t DestroyNotifyByNotificationId(int32_t notifyId);
45 
46 private:
47     SystemNotifier();
48     bool GetPixelMap(const std::string &path, std::shared_ptr<Media::PixelMap> &pixelMap);
49     int32_t GenerateNextNotificationId();
50 
51     int32_t DisconnectByNetworkId(const std::string &networkId);
52     std::string GetRemoteDeviceName(const std::string &networkId);
53 
54     void UpdateResourceMap(const std::string &resourcePath);
55     void UpdateResourceMapByLanguage();
56 
57     template<typename... Args>
58     std::string GetKeyValue(const std::string &key, Args &&... args);
59 
60 private:
61     std::shared_ptr<Media::PixelMap> capsuleIconPixelMap_{};
62     std::shared_ptr<Media::PixelMap> notificationIconPixelMap_{};
63     std::shared_ptr<Media::PixelMap> buttonIconPixelMap_{};
64 
65     // networkId -> notificationId
66     std::shared_mutex mutex_;
67     std::map<std::string, int32_t> notificationMap_;
68 };
69 } // namespace DistributedFile
70 } // namespace Storage
71 } // namespace OHOS
72 #endif // FILEMANAGEMENT_DFS_SERVICE_SYSTEM_NOTIFIER_H