• 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 NOTIFICATION_DISTRIBUTED_EXTENSION_DISTRIBUTED_DEVICE_DATA_SERVICE_H
17 #define NOTIFICATION_DISTRIBUTED_EXTENSION_DISTRIBUTED_DEVICE_DATA_SERVICE_H
18 
19 #include <set>
20 #include <mutex>
21 #include <vector>
22 #include <unordered_map>
23 
24 #include "ffrt.h"
25 
26 namespace OHOS {
27 namespace Notification {
28 
29 struct DeviceData {
30     std::string deviceId;
31     std::string deviceType;
32     bool notificationSyncEnable = true;
33     bool liveViewSyncEnable = true;
34     std::unordered_map<std::string, std::string> installedBundles;
35 };
36 
37 class DistributedDeviceDataService {
38 public:
39     static DistributedDeviceDataService& GetInstance();
40 
41     void ResetTargetDevice(const std::string& deviceType, const std::string& deviceId);
42     int32_t SetDeviceSyncSwitch(const std::string& deviceType, const std::string& deviceId,
43         bool notificationEnable, bool liveViewEnable);
44     int32_t SetTargetDeviceBundleList(const std::string& deviceType, const std::string& deviceId,
45         int operatorType, const std::vector<std::string>& bundleList, const std::vector<std::string>& labelList);
46     int32_t GetTargetDeviceBundleList(const std::string& deviceType, const std::string& deviceId,
47         std::vector<std::string>& bundleList, std::vector<std::string>& labelList);
48     bool CheckDeviceBundleExist(const std::string& deviceType, const std::string& deviceId,
49         const std::string& bundleName, const std::string& label);
50     bool GetDeviceNotificationEnable(const std::string& deviceType, const std::string& deviceId);
51     bool GetDeviceLiveViewEnable(const std::string& deviceType, const std::string& deviceId);
52 
53 private:
54     DistributedDeviceDataService() = default;
55     ~DistributedDeviceDataService() = default;
56 
57     ffrt::mutex lock_;
58     std::vector<DeviceData> devicesData_;
59 };
60 }
61 }
62 #endif // NOTIFICATION_DISTRIBUTED_EXTENSION_DISTRIBUTED_DEVICE_DATA_SERVICE_H
63