1 /* 2 * Copyright (c) 2022-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 #include "app_info_collector.h" 17 18 #include "device_profile_log.h" 19 #include "dms_constant.h" 20 #include "nlohmann/json.hpp" 21 22 namespace OHOS { 23 namespace DeviceProfile { 24 namespace { 25 const std::string TAG = "AppInfoCollector"; 26 27 const std::string SERVICE_ID = "appInfo"; 28 const std::string SERVICE_TYPE = "appInfo"; 29 const std::string PACKAGE_NAMES = "packageNames"; 30 const std::string VERSIONS = "versions"; 31 } 32 ConvertToProfileData(ServiceCharacteristicProfile & profile)33bool AppInfoCollector::ConvertToProfileData(ServiceCharacteristicProfile& profile) 34 { 35 profile.SetServiceId(SERVICE_ID); 36 profile.SetServiceType(SERVICE_TYPE); 37 nlohmann::json jsonData; 38 std::string packageNames; 39 std::string versions; 40 GetDmsVersionInfo(packageNames, versions); 41 jsonData[PACKAGE_NAMES] = packageNames; 42 jsonData[VERSIONS] = versions; 43 profile.SetCharacteristicProfileJson(jsonData.dump()); 44 return true; 45 } 46 GetDmsVersionInfo(std::string & dmsName,std::string & dmsVersionData)47bool AppInfoCollector::GetDmsVersionInfo(std::string& dmsName, std::string& dmsVersionData) 48 { 49 dmsName = DistributedSchedule::Constants::DMS_NAME; 50 dmsVersionData = DistributedSchedule::Constants::DMS_VERSION; 51 return true; 52 } 53 } // namespace DeviceProfile 54 } // OHOS 55