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 UPDATE_SERVICE_UPGRADE_INFO_H 17 #define UPDATE_SERVICE_UPGRADE_INFO_H 18 19 #include <string> 20 21 #include "business_type.h" 22 #include "update_device_type.h" 23 24 namespace OHOS::UpdateEngine { 25 const std::string LOCAL_UPGRADE_INFO = "LocalUpgradeInfo"; 26 struct UpgradeInfo { 27 std::string upgradeApp; 28 BusinessType businessType = {}; 29 std::string upgradeDevId; 30 std::string controlDevId; 31 int32_t processId; 32 DeviceType deviceType = DeviceType::UNKNOWN; 33 34 bool operator<(const UpgradeInfo &other) const 35 { 36 if (upgradeApp != other.upgradeApp) { 37 return upgradeApp < other.upgradeApp; 38 } 39 40 if (businessType != other.businessType) { 41 return businessType < other.businessType; 42 } 43 44 if (upgradeDevId != other.upgradeDevId) { 45 return upgradeDevId < other.upgradeDevId; 46 } 47 48 if (controlDevId != other.controlDevId) { 49 return controlDevId < other.controlDevId; 50 } 51 52 if (processId != other.processId) { 53 return processId < other.processId; 54 } 55 56 if (deviceType != other.deviceType) { 57 return deviceType < other.deviceType; 58 } 59 60 return false; 61 } 62 63 std::string ToString() const; 64 IsLocalUpgradeInfo65 bool IsLocal() const 66 { 67 return upgradeApp == LOCAL_UPGRADE_INFO; 68 } 69 }; 70 } // namespace OHOS::UpdateEngine 71 #endif // UPDATE_SERVICE_UPGRADE_INFO_H 72