• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 OHOS_DP_STATIC_PROFILE_MANAGER_H
17 #define OHOS_DP_STATIC_PROFILE_MANAGER_H
18 
19 #include "characteristic_profile.h"
20 #include "dm_device_info.h"
21 #include "kv_adapter.h"
22 #include "single_instance.h"
23 #include "trusted_device_info.h"
24 
25 namespace OHOS {
26 namespace DistributedDeviceProfile {
27 class StaticProfileManager {
28 DECLARE_SINGLE_INSTANCE(StaticProfileManager);
29 
30 public:
31     int32_t Init();
32     int32_t UnInit();
33     int32_t ReInit();
34     int32_t PutCharacteristicProfile(const CharacteristicProfile& charProfile);
35     int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName,
36         const std::string& characteristicKey, CharacteristicProfile& charProfile);
37     int32_t GetAllCharacteristicProfile(std::vector<CharacteristicProfile>& staticCapabilityProfiles);
38     void E2ESyncStaticProfile(const TrustedDeviceInfo& deviceInfo);
39 
40 private:
41     int32_t GenerateStaticInfoProfile(const CharacteristicProfile& staticCapabilityProfile,
42         std::unordered_map<std::string, CharacteristicProfile>& staticInfoProfiles);
43 
44 private:
45     std::mutex staticStoreMutex_;
46     std::shared_ptr<IKVAdapter> staticProfileStore_ = nullptr;
47 };
48 } // namespace DistributedDeviceProfile
49 } // namespace OHOS
50 #endif // OHOS_DP_STATIC_PROFILE_MANAGER_H
51