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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_PATCH_INFO_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_PATCH_INFO_H 18 19 #include <string> 20 21 #include "json_util.h" 22 #include "nlohmann/json.hpp" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 27 enum class AppPatchType : uint8_t { 28 DEFAULT = 0, 29 INTERNAL = 1, 30 SERVICE_FWK = 2, 31 SHARED_BUNDLES = 3, 32 }; 33 34 struct PatchInfo { 35 uint32_t versionCode = 0; 36 AppPatchType appPatchType = AppPatchType::DEFAULT; 37 }; 38 39 class InnerPatchInfo { 40 public: InnerPatchInfo()41 InnerPatchInfo() {}; ~InnerPatchInfo()42 ~InnerPatchInfo() {}; 43 44 bool FromJson(const std::string &jsonObject); 45 std::string ToString() const; SetPatchInfo(const PatchInfo & patchInfo)46 void SetPatchInfo(const PatchInfo &patchInfo) 47 { 48 patchInfo_ = patchInfo; 49 } 50 GetVersionCode()51 uint32_t GetVersionCode() const 52 { 53 return patchInfo_.versionCode; 54 } 55 GetAppPatchType()56 AppPatchType GetAppPatchType() const 57 { 58 return patchInfo_.appPatchType; 59 } 60 61 private: 62 void ToJson(nlohmann::json &jsonObject) const; 63 PatchInfo patchInfo_; 64 }; 65 66 } // namespace AppExecFwk 67 } // namespace OHOS 68 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_PATCH_INFO_H 69