1 /*
2  * Copyright (c) 2022-2023 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 #ifndef OHOS_DMS_VERSION_MANAGER_H
16 #define OHOS_DMS_VERSION_MANAGER_H
17 
18 #include <string>
19 #include "ipc_skeleton.h"
20 
21 namespace OHOS {
22 namespace DistributedSchedule {
23 struct DmsVersion {
24     uint32_t majorVersionNum = 0;
25     uint32_t minorVersionNum = 0;
26     uint32_t featureVersionNum = 0;
27 };
28 
29 class DmsVersionManager {
30 public:
31     static bool IsRemoteDmsVersionLower(const std::string& remoteDeviceId, const DmsVersion& thresholdDmsVersion);
32 private:
33     static int32_t GetRemoteDmsVersion(const std::string& deviceId, DmsVersion& dmsVersion);
34     static int32_t GetAppInfoFromDP(const std::string& deviceId, std::string& appInfoJsonData);
35     static int32_t ParseAppInfo(const std::string& appInfoJsonData, std::string& packageNamesData,
36         std::string& versionsData);
37     static int32_t GetDmsVersionDataFromAppInfo(const std::string& packageNamesData, const std::string& versionsData,
38         std::string& dmsVersionData);
39     static bool ParseDmsVersion(const std::string& dmsVersionData, DmsVersion& dmsVersion);
40     static bool CompareDmsVersion(const DmsVersion& dmsVersion, const DmsVersion& thresholdDmsVersion);
41 };
42 } // namespace DistributedSchedule
43 } // namespace OHOS
44 #endif // OHOS_DMS_VERSION_MANAGER_H