From e4522d2353a83bd486e1d5344d8b5ac03f46cb50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Fri, 23 May 2025 09:18:28 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- .../napi/update/common/src/client_helper.cpp | 1 + .../update/model/policy/enum_policy_type.h | 28 +++++++++++++++++++ .../model/policy/src/upgrade_policy.cpp | 6 ++++ .../update/model/policy/upgrade_policy.h | 2 ++ 4 files changed, 37 insertions(+) create mode 100644 interfaces/inner_api/feature/update/model/policy/enum_policy_type.h diff --git a/frameworks/js/napi/update/common/src/client_helper.cpp b/frameworks/js/napi/update/common/src/client_helper.cpp index be00e7e0..f6d54e42 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::SetBool(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 00000000..1aab961a --- /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 40efa392..66cd2a71 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 801bb538..c88b83a3 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; -- Gitee From 9ca25ef46bf5c3d7692056017135ce80fc29ea47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Fri, 23 May 2025 09:39:37 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=AC=E5=8F=B7?= =?UTF-8?q?=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- frameworks/js/napi/update/common/src/client_helper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/js/napi/update/common/src/client_helper.cpp b/frameworks/js/napi/update/common/src/client_helper.cpp index f6d54e42..d623af7e 100644 --- a/frameworks/js/napi/update/common/src/client_helper.cpp +++ b/frameworks/js/napi/update/common/src/client_helper.cpp @@ -332,7 +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::SetBool(env, obj, "customPolicyType", CAST_INT(upgradePolicy.customPolicyType); + NapiCommonUtils::SetInt32(env, obj, "customPolicyType", CAST_INT(upgradePolicy.customPolicyType)); napi_value autoUpgradePeriods; size_t count = COUNT_OF(upgradePolicy.autoUpgradePeriods); -- Gitee