• 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 DISTRIBUTED_INCLUDE_SOFTBUS_DISTRIBUTED_BUNDLE_SERVICE_H
17 #define DISTRIBUTED_INCLUDE_SOFTBUS_DISTRIBUTED_BUNDLE_SERVICE_H
18 
19 #include <set>
20 #include <map>
21 
22 #include "tlv_box.h"
23 #include "distributed_device_data.h"
24 
25 namespace OHOS {
26 namespace Notification {
27 class DistributedBundleService {
28 public:
29     static DistributedBundleService& GetInstance();
30 
31     void HandleBundleIconSync(const std::shared_ptr<TlvBox>& boxMessage);
32 #ifdef DISTRIBUTED_FEATURE_MASTER
33     void RequestBundlesIcon(const DistributedDeviceInfo peerDevice, bool isForce);
34     void GenerateBundleIconSync(const DistributedDeviceInfo& device);
35     void HandleBundleRemoved(const std::string& bundleName);
36     void HandleBundleChanged(const std::string& bundleName, bool updatedExit);
37     void SetDeviceBundleList(const std::shared_ptr<TlvBox>& boxMessage);
38 private:
39     int32_t UpdateBundlesIcon(const std::unordered_map<std::string, std::string>& icons,
40         const DistributedDeviceInfo peerDevice);
41     bool GetBundleResourceInfo(const std::string bundleName, std::string& icon);
42     void GetNeedUpdateDevice(bool updatedExit, const std::string& bundleName,
43         std::vector<DistributedDeviceInfo>& updateDeviceList);
44 #else
45     void ReportBundleIconList(const DistributedDeviceInfo peerDevice);
46     void SyncInstalledBundles(const DistributedDeviceInfo& peerDevice, bool isForce);
47     void SendInstalledBundles(const DistributedDeviceInfo& peerDevice, const std::string& localDeviceId,
48         const std::vector<std::pair<std::string, std::string>>& bundles, int32_t type);
49 #endif
50 
51 private:
52     std::map<std::string, std::set<std::string>> bundleIconCache_;
53 };
54 }
55 }
56 #endif // DISTRIBUTED_INCLUDE_SOFTBUS_DISTRIBUTED_BUNDLE_SERVICE_H
57