diff --git a/frameworks/js/napi/update/common/src/client_helper.cpp b/frameworks/js/napi/update/common/src/client_helper.cpp index be00e7e02f9b599dc82a0f883c3eab00371b2ad0..d623af7e5d8650add05702970648fa1b7ebbf064 100644 --- a/frameworks/js/napi/update/common/src/client_helper.cpp +++ b/frameworks/js/napi/update/common/src/client_helper.cpp @@ -332,6 +332,7 @@ int32_t ClientHelper::BuildUpgradePolicy(napi_env env, napi_value &obj, const Up // Add the result. NapiCommonUtils::SetBool(env, obj, "downloadStrategy", upgradePolicy.downloadStrategy); NapiCommonUtils::SetBool(env, obj, "autoUpgradeStrategy", upgradePolicy.autoUpgradeStrategy); + NapiCommonUtils::SetInt32(env, obj, "customPolicyType", CAST_INT(upgradePolicy.customPolicyType)); napi_value autoUpgradePeriods; size_t count = COUNT_OF(upgradePolicy.autoUpgradePeriods); diff --git a/interfaces/inner_api/feature/update/model/policy/enum_policy_type.h b/interfaces/inner_api/feature/update/model/policy/enum_policy_type.h new file mode 100644 index 0000000000000000000000000000000000000000..1aab961a5336f36f7a0e11c8d40343aab81d9dd7 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/policy/enum_policy_type.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ENUM_POLICY_TYPE_H +#define ENUM_POLICY_TYPE_H + +namespace OHOS::UpdateService { + enum class PolicyType { + DEFAULT = 0, + PROHIBIT, + UPGRADE_TO_SPECIFIC_VERSION, + WINDOWS, + POSTPONE + }; +} // namespace OHOS::UpdateService +#endif // ENUM_POLICY_TYPE_H \ No newline at end of file diff --git a/interfaces/inner_api/feature/update/model/policy/src/upgrade_policy.cpp b/interfaces/inner_api/feature/update/model/policy/src/upgrade_policy.cpp index 40efa3929e00eecd497ef2ac70168672e34ad499..66cd2a71e3ac9808fcf290bfc387a21259478518 100644 --- a/interfaces/inner_api/feature/update/model/policy/src/upgrade_policy.cpp +++ b/interfaces/inner_api/feature/update/model/policy/src/upgrade_policy.cpp @@ -23,6 +23,7 @@ bool UpgradePolicy::ReadFromParcel(Parcel &parcel) { downloadStrategy = static_cast(parcel.ReadBool()); autoUpgradeStrategy = static_cast(parcel.ReadBool()); + customPolicyType = static_cast(parcel.ReadInt32()); size_t size = static_cast(parcel.ReadInt32()); size_t arraySize = COUNT_OF(autoUpgradePeriods); if (size > MAX_VECTOR_SIZE) { @@ -48,6 +49,11 @@ bool UpgradePolicy::Marshalling(Parcel &parcel) const return false; } + if (!parcel.WriteInt32(CAST_INT(customPolicyType))) { + ENGINE_LOGE("Write customPolicyType failed"); + return false; + } + int32_t size = static_cast(COUNT_OF(autoUpgradePeriods)); if (!parcel.WriteInt32(size)) { ENGINE_LOGE("Write size failed"); diff --git a/interfaces/inner_api/feature/update/model/policy/upgrade_policy.h b/interfaces/inner_api/feature/update/model/policy/upgrade_policy.h index 801bb538a1b8c613b8075007f0f06e02891cba78..c88b83a3c3e3fd0b364bb4e54ed76abbc068a507 100644 --- a/interfaces/inner_api/feature/update/model/policy/upgrade_policy.h +++ b/interfaces/inner_api/feature/update/model/policy/upgrade_policy.h @@ -16,6 +16,7 @@ #ifndef UPDATE_SERVICE_UPGRADE_POLICY_H #define UPDATE_SERVICE_UPGRADE_POLICY_H +#include "enum_policy_type.h" #include "upgrade_period.h" #include "parcel.h" @@ -24,6 +25,7 @@ struct UpgradePolicy : public Parcelable { bool downloadStrategy = false; bool autoUpgradeStrategy = false; UpgradePeriod autoUpgradePeriods[2]; + PolicyType customPolicyType = PolicyType::DEFAULT; bool ReadFromParcel(Parcel &parcel); bool Marshalling(Parcel &parcel) const override;