diff --git a/adapter/default_config/feature_config/standard/config.gni b/adapter/default_config/feature_config/standard/config.gni index 2598c14f0d541e4e1c78205da9921e5f0a5b45f6..e333d5a8138b114e5f59be8887ce3c48ff3c195e 100644 --- a/adapter/default_config/feature_config/standard/config.gni +++ b/adapter/default_config/feature_config/standard/config.gni @@ -22,4 +22,8 @@ declare_args() { if (!defined(global_parts_info.ability_ability_runtime)) { ability_ability_runtime_enable = false } + communication_netmanager_base_enable = true + if (!defined(global_parts_info.communication_netmanager_base)) { + communication_netmanager_base_enable = false + } } diff --git a/bundle.json b/bundle.json index 761522ff5f9830c2f078ddaf6d35ddc6424ea923..843296aa3fd233e1bd881347007e106e12f0b86d 100644 --- a/bundle.json +++ b/bundle.json @@ -36,6 +36,7 @@ "access_token", "hisysevent", "init", + "json", "updater", "ability_base", "ability_runtime", @@ -47,7 +48,6 @@ "third_party": [ "curl", "libxml2", - "json", "cJSON", "bounds_checking_function", "glib", @@ -67,6 +67,13 @@ "//base/update/updateservice/services/engine/sa_profile:updater_sa_profile" ], "inner_api": [ + { + "header": { + "header_base": "//base/update/updateservice/foundations", + "header_files": [] + }, + "name": "//base/update/updateservice/foundations:update_foundations" + }, { "header": { "header_base": "//base/update/updateservice/interfaces/inner_api/include", diff --git a/foundations/BUILD.gn b/foundations/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6cdc3b98c8b9c06c31560267e2770c72f721ce55 --- /dev/null +++ b/foundations/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2024 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. + +import("//base/update/updateservice/foundations/foundations.gni") +import("//base/update/updateservice/updateengine.gni") +import("//build/ohos.gni") + +config("update_service_foundations_config") { + include_dirs = foundations_include +} + +ohos_shared_library("update_foundations") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" + + defines = [] + if (!ability_ability_runtime_enable) { + defines += [ "ABILITY_RUNTIME_INNER_ENABLE" ] + } + + include_dirs = foundations_include + sources = foundations_sources + deps = foundations_deps + external_deps = foundations_external_deps + + public_configs = [ ":update_service_foundations_config" ] + + part_name = "$updateengine_part_name" + subsystem_name = "updater" +} diff --git a/services/core/ability/define/define.gni b/foundations/ability/define/define.gni similarity index 69% rename from services/core/ability/define/define.gni rename to foundations/ability/define/define.gni index 0d202f8bf1b56c20403d15cbd708cfbabd06a364..0e9bb9cdb0ed38efcc26130c077c3849fcf9d712 100644 --- a/services/core/ability/define/define.gni +++ b/foundations/ability/define/define.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2024 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 @@ -11,8 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../../../updateengine.gni") +import("//base/update/updateservice/updateengine.gni") -define_root_path = "$updateengine_root_path/services/core/ability/define" - -define_include = [ "$define_root_path/include" ] +define_external_deps = [] +define_deps = [] +define_include = + [ "$updateengine_root_path/foundations/ability/define/include" ] +define_src = [] diff --git a/services/core/ability/define/include/update_define.h b/foundations/ability/define/include/update_define.h similarity index 100% rename from services/core/ability/define/include/update_define.h rename to foundations/ability/define/include/update_define.h diff --git a/services/core/ability/log/include/update_log.h b/foundations/ability/log/include/update_log.h similarity index 99% rename from services/core/ability/log/include/update_log.h rename to foundations/ability/log/include/update_log.h index 9b20ef5c9b51274eb1016014f5280b2dfaf67d36..ebbc6ce0ecde831544a8461416cd8881e7c884f4 100644 --- a/services/core/ability/log/include/update_log.h +++ b/foundations/ability/log/include/update_log.h @@ -16,6 +16,7 @@ #ifndef UPDATE_LOG_H #define UPDATE_LOG_H +#include #include #include "hilog/log.h" diff --git a/services/core/ability/log/log.gni b/foundations/ability/log/log.gni similarity index 67% rename from services/core/ability/log/log.gni rename to foundations/ability/log/log.gni index be71f6e1ff5a13e323f7f29d4f60abc124dbcad2..51216d82437ad1b0dbfc5a6433b121451a0d1520 100644 --- a/services/core/ability/log/log.gni +++ b/foundations/ability/log/log.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2024 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 @@ -13,9 +13,11 @@ import("//base/update/updateservice/updateengine.gni") -update_log_root_path = "$updateengine_root_path/services/core/ability/log" - -update_log_external_deps = [ "hilog:libhilog" ] +update_log_external_deps = [ + "hilog:libhilog", + "updater:libupdaterlog_shared", +] update_log_deps = [] -update_log_include = [ "$update_log_root_path/include" ] -update_log_src = [ "$update_log_root_path/src/update_log.cpp" ] +update_log_include = + [ "$updateengine_root_path/foundations/ability/log/include" ] +update_log_src = [ "$updateengine_root_path/foundations/ability/log/src/update_log.cpp" ] diff --git a/services/core/ability/log/src/update_log.cpp b/foundations/ability/log/src/update_log.cpp similarity index 100% rename from services/core/ability/log/src/update_log.cpp rename to foundations/ability/log/src/update_log.cpp diff --git a/interfaces/inner_api/common/include/base_service_kits_impl.h b/foundations/ability/sa_loader/include/base_service_kits_impl.h similarity index 100% rename from interfaces/inner_api/common/include/base_service_kits_impl.h rename to foundations/ability/sa_loader/include/base_service_kits_impl.h diff --git a/interfaces/inner_api/common/include/common_death_recipient.h b/foundations/ability/sa_loader/include/common_death_recipient.h similarity index 100% rename from interfaces/inner_api/common/include/common_death_recipient.h rename to foundations/ability/sa_loader/include/common_death_recipient.h diff --git a/interfaces/inner_api/common/include/load_sa_service.h b/foundations/ability/sa_loader/include/load_sa_service.h similarity index 100% rename from interfaces/inner_api/common/include/load_sa_service.h rename to foundations/ability/sa_loader/include/load_sa_service.h diff --git a/foundations/ability/sa_loader/sa_loader.gni b/foundations/ability/sa_loader/sa_loader.gni new file mode 100644 index 0000000000000000000000000000000000000000..02290adf6364eaf777cad25291d6bd8159d999d6 --- /dev/null +++ b/foundations/ability/sa_loader/sa_loader.gni @@ -0,0 +1,29 @@ +# Copyright (c) 2024 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. + +import("//base/update/updateservice/updateengine.gni") + +sa_loader_external_deps = [ + "c_utils:utils", # sptr + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", +] +if (ability_ability_runtime_enable) { + sa_loader_external_deps += [ "ability_runtime:ability_manager" ] +} + +sa_loader_deps = [] +sa_loader_include = + [ "$updateengine_root_path/foundations/ability/sa_loader/include" ] +sa_loader_src = [ "$updateengine_root_path/foundations/ability/sa_loader/src/load_sa_service.cpp" ] diff --git a/interfaces/inner_api/common/src/load_sa_service.cpp b/foundations/ability/sa_loader/src/load_sa_service.cpp similarity index 100% rename from interfaces/inner_api/common/src/load_sa_service.cpp rename to foundations/ability/sa_loader/src/load_sa_service.cpp diff --git a/interfaces/inner_api/include/update_system_event.h b/foundations/ability/sys_event/include/update_system_event.h similarity index 100% rename from interfaces/inner_api/include/update_system_event.h rename to foundations/ability/sys_event/include/update_system_event.h diff --git a/foundations/ability/sys_event/sys_event.gni b/foundations/ability/sys_event/sys_event.gni new file mode 100644 index 0000000000000000000000000000000000000000..456580172b17c606cd0004e7866221c1318b807a --- /dev/null +++ b/foundations/ability/sys_event/sys_event.gni @@ -0,0 +1,20 @@ +# Copyright (c) 2024 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. + +import("//base/update/updateservice/updateengine.gni") + +sys_event_external_deps = [] +sys_event_deps = [] +sys_event_include = + [ "$updateengine_root_path/foundations/ability/sys_event/include" ] +sys_event_src = [] diff --git a/services/core/ability/utils/include/encrypt_utils.h b/foundations/ability/utils/include/anonymous_utils.h similarity index 82% rename from services/core/ability/utils/include/encrypt_utils.h rename to foundations/ability/utils/include/anonymous_utils.h index 0f8b53e44b52cd44b3c62eb7557a2d7093279c73..61d77029d8209e6bed5718682a531bf0e98bf6c0 100644 --- a/services/core/ability/utils/include/encrypt_utils.h +++ b/foundations/ability/utils/include/anonymous_utils.h @@ -13,34 +13,23 @@ * limitations under the License. */ -#ifndef ENCRYPT_UTILS_H -#define ENCRYPT_UTILS_H +#ifndef ANONYMOUS_UTILS_H +#define ANONYMOUS_UTILS_H #include #include #include #include -#include "update_log.h" namespace OHOS { namespace UpdateEngine { static const int32_t ENCRYPT_LENGTH = 4; // 需要替换*的长度 static const int32_t ENCRYPT_TOTAL_LENGTH = 8; // 敏感数据匿名化后最长长度 static const std::string ENCRYPT_STR = "****"; -class EncryptUtils { +class AnonymousUtils { public: - static int64_t GetRand(int32_t min, int32_t max) - { - // 随机 min ~ max值 - if (max < min) { - return min; - } - srand(time(nullptr)); - return min + rand() % (max - min); - } - - static std::string EncryptUrl(const std::string &url) + static std::string AnonymousUrl(const std::string &url) { std::string encryptUrl = url; std::string httpsPrefix = "https://"; @@ -58,7 +47,7 @@ public: return encryptUrl; } - static std::string EncryptString(std::string inputStr) + static std::string AnonymousString(std::string inputStr) { if (inputStr.empty()) { return inputStr; @@ -79,4 +68,4 @@ public: }; } // namespace UpdateEngine } // namespace OHOS -#endif // ENCRYPT_UTILS_H \ No newline at end of file +#endif // ANONYMOUS_UTILS_H \ No newline at end of file diff --git a/services/core/ability/utils/include/json_utils.h b/foundations/ability/utils/include/dupdate_json_utils.h similarity index 100% rename from services/core/ability/utils/include/json_utils.h rename to foundations/ability/utils/include/dupdate_json_utils.h diff --git a/interfaces/inner_api/include/json_builder.h b/foundations/ability/utils/include/json_builder.h similarity index 100% rename from interfaces/inner_api/include/json_builder.h rename to foundations/ability/utils/include/json_builder.h diff --git a/services/core/ability/utils/include/string_utils.h b/foundations/ability/utils/include/string_utils.h similarity index 100% rename from services/core/ability/utils/include/string_utils.h rename to foundations/ability/utils/include/string_utils.h diff --git a/foundations/ability/utils/utils.gni b/foundations/ability/utils/utils.gni new file mode 100644 index 0000000000000000000000000000000000000000..b4a33b7d191088b872f6b38bf1e8eb520e036dc4 --- /dev/null +++ b/foundations/ability/utils/utils.gni @@ -0,0 +1,19 @@ +# Copyright (c) 2024 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. + +import("//base/update/updateservice/updateengine.gni") + +utils_external_deps = [ "json:nlohmann_json_static" ] +utils_deps = [] +utils_include = [ "$updateengine_root_path/foundations/ability/utils/include" ] +utils_src = [] diff --git a/foundations/foundations.gni b/foundations/foundations.gni new file mode 100644 index 0000000000000000000000000000000000000000..615367352f174d640097d7a49141af04d3c80437 --- /dev/null +++ b/foundations/foundations.gni @@ -0,0 +1,53 @@ +# Copyright (c) 2024 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. + +import("//base/update/updateservice/foundations/ability/define/define.gni") +import("//base/update/updateservice/foundations/ability/log/log.gni") +import( + "//base/update/updateservice/foundations/ability/sa_loader/sa_loader.gni") +import( + "//base/update/updateservice/foundations/ability/sys_event/sys_event.gni") +import("//base/update/updateservice/foundations/ability/utils/utils.gni") +import("//base/update/updateservice/foundations/model/base_model.gni") + +foundations_external_deps = [] +foundations_external_deps += define_external_deps +foundations_external_deps += update_log_external_deps +foundations_external_deps += sa_loader_external_deps +foundations_external_deps += sys_event_external_deps +foundations_external_deps += utils_external_deps +foundations_external_deps += base_model_external_deps + +foundations_deps = [] +foundations_deps += define_deps +foundations_deps += update_log_deps +foundations_deps += sa_loader_deps +foundations_deps += sys_event_deps +foundations_deps += utils_deps +foundations_deps += base_model_deps + +foundations_include = [] +foundations_include += define_include +foundations_include += update_log_include +foundations_include += sa_loader_include +foundations_include += sys_event_include +foundations_include += utils_include +foundations_include += base_model_include + +foundations_sources = [] +foundations_sources += define_src +foundations_sources += update_log_src +foundations_sources += sa_loader_src +foundations_sources += sys_event_src +foundations_sources += utils_src +foundations_sources += base_model_src diff --git a/foundations/model/base_model.gni b/foundations/model/base_model.gni new file mode 100644 index 0000000000000000000000000000000000000000..c96c71072b475e007fa93d918dd92b5c17b6b91e --- /dev/null +++ b/foundations/model/base_model.gni @@ -0,0 +1,19 @@ +# Copyright (c) 2024 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. + +import("//base/update/updateservice/updateengine.gni") + +base_model_external_deps = [] +base_model_deps = [] +base_model_include = [ "$updateengine_root_path/foundations/model/include" ] +base_model_src = [] diff --git a/interfaces/inner_api/common/include/common_error_define.h b/foundations/model/include/business_error.h similarity index 44% rename from interfaces/inner_api/common/include/common_error_define.h rename to foundations/model/include/business_error.h index 7b1a89ec3fa6bd76efbe0b65a1d279bbda375546..24a7f5723139cedf58c3d18968d062d9a2f6b5af 100644 --- a/interfaces/inner_api/common/include/common_error_define.h +++ b/foundations/model/include/business_error.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 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 @@ -13,79 +13,20 @@ * limitations under the License. */ -#ifndef COMMON_ERROR_DEFINE_H -#define COMMON_ERROR_DEFINE_H +#ifndef UPDATE_SERVICE_BUSINESS_ERROR_H +#define UPDATE_SERVICE_BUSINESS_ERROR_H #include #include +#include "nlohmann/json.hpp" + +#include "call_result.h" +#include "dupdate_json_utils.h" +#include "error_message.h" #include "json_builder.h" -#include "json_utils.h" namespace OHOS::UpdateEngine { -#define CAST_INT(enumClass) (static_cast(enumClass)) -#define CALL_RESULT_TO_IPC_RESULT(callResult) ((callResult) + CALL_RESULT_OFFSET) -constexpr int32_t COMPONENT_ERR = 11500000; -constexpr int CALL_RESULT_OFFSET = 2000; -enum class CallResult { - // 通用错误码 - APP_NOT_GRANTED = 201, - NOT_SYSTEM_APP = 202, - PARAM_ERR = 401, - UN_SUPPORT = 801, - - // 模块内错误码 - SUCCESS = 0, - FAIL = 100, - DEV_UPG_INFO_ERR = 102, - FORBIDDEN = 103, - IPC_ERR = 104, - TIME_OUT = 402, - DB_ERROR = 501, - IO_ERROR = 502, - NET_ERROR = 503 -}; - -constexpr int32_t INT_CALL_SUCCESS = CAST_INT(CallResult::SUCCESS); -constexpr int32_t INT_CALL_FAIL = CAST_INT(CallResult::FAIL); -constexpr int32_t INT_UN_SUPPORT = CAST_INT(CallResult::UN_SUPPORT); -constexpr int32_t INT_FORBIDDEN = CAST_INT(CallResult::FORBIDDEN); -constexpr int32_t INT_CALL_IPC_ERR = CAST_INT(CallResult::IPC_ERR); -constexpr int32_t INT_APP_NOT_GRANTED = CAST_INT(CallResult::APP_NOT_GRANTED); -constexpr int32_t INT_NOT_SYSTEM_APP = CAST_INT(CallResult::NOT_SYSTEM_APP); -constexpr int32_t INT_PARAM_ERR = CAST_INT(CallResult::PARAM_ERR); -constexpr int32_t INT_DEV_UPG_INFO_ERR = CAST_INT(CallResult::DEV_UPG_INFO_ERR); -constexpr int32_t INT_TIME_OUT = CAST_INT(CallResult::TIME_OUT); -constexpr int32_t INT_DB_ERROR = CAST_INT(CallResult::DB_ERROR); -constexpr int32_t INT_IO_ERROR = CAST_INT(CallResult::IO_ERROR); -constexpr int32_t INT_NET_ERROR = CAST_INT(CallResult::NET_ERROR); - -struct ErrorMessage { - int32_t errorCode = 0; - std::string errorMessage; - - friend void to_json(nlohmann::json &jsonObj, const ErrorMessage &message) - { - jsonObj["errorCode"] = message.errorCode; - jsonObj["errorMessage"] = message.errorMessage; - } - - friend void from_json(const nlohmann::json &jsonObj, ErrorMessage &message) - { - JsonUtils::GetValueAndSetTo(jsonObj, "errorCode", message.errorCode); - JsonUtils::GetValueAndSetTo(jsonObj, "errorMessage", message.errorMessage); - } - - JsonBuilder GetJsonBuilder() - { - return JsonBuilder() - .Append("{") - .Append("errorCode", errorCode) - .Append("errorMessage", errorMessage) - .Append("}"); - } -}; - struct BusinessError { std::string message; CallResult errorNum = CallResult::SUCCESS; @@ -124,4 +65,4 @@ struct BusinessError { } }; } // namespace OHOS::UpdateEngine -#endif // COMMON_ERROR_DEFINE_H \ No newline at end of file +#endif // UPDATE_SERVICE_BUSINESS_ERROR_H diff --git a/foundations/model/include/call_result.h b/foundations/model/include/call_result.h new file mode 100644 index 0000000000000000000000000000000000000000..e32cff45a51a62ea85de29e22a838d642e88e908 --- /dev/null +++ b/foundations/model/include/call_result.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_CALL_RESULT_H +#define UPDATE_SERVICE_CALL_RESULT_H + +#include "update_define.h" + +namespace OHOS::UpdateEngine { +constexpr int CALL_RESULT_OFFSET = 2000; + +enum class CallResult { + // 通用错误码 + APP_NOT_GRANTED = 201, + NOT_SYSTEM_APP = 202, + PARAM_ERR = 401, + UN_SUPPORT = 801, + + // 模块内错误码 + SUCCESS = 0, + FAIL = 100, + DEV_UPG_INFO_ERR = 102, + FORBIDDEN = 103, + IPC_ERR = 104, + TIME_OUT = 402, + DB_ERROR = 501, + IO_ERROR = 502, + NET_ERROR = 503 +}; + +constexpr int32_t INT_CALL_SUCCESS = CAST_INT(CallResult::SUCCESS); +constexpr int32_t INT_CALL_FAIL = CAST_INT(CallResult::FAIL); +constexpr int32_t INT_UN_SUPPORT = CAST_INT(CallResult::UN_SUPPORT); +constexpr int32_t INT_FORBIDDEN = CAST_INT(CallResult::FORBIDDEN); +constexpr int32_t INT_CALL_IPC_ERR = CAST_INT(CallResult::IPC_ERR); +constexpr int32_t INT_APP_NOT_GRANTED = CAST_INT(CallResult::APP_NOT_GRANTED); +constexpr int32_t INT_NOT_SYSTEM_APP = CAST_INT(CallResult::NOT_SYSTEM_APP); +constexpr int32_t INT_PARAM_ERR = CAST_INT(CallResult::PARAM_ERR); +constexpr int32_t INT_DEV_UPG_INFO_ERR = CAST_INT(CallResult::DEV_UPG_INFO_ERR); +constexpr int32_t INT_TIME_OUT = CAST_INT(CallResult::TIME_OUT); +constexpr int32_t INT_DB_ERROR = CAST_INT(CallResult::DB_ERROR); +constexpr int32_t INT_IO_ERROR = CAST_INT(CallResult::IO_ERROR); +constexpr int32_t INT_NET_ERROR = CAST_INT(CallResult::NET_ERROR); +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_CALL_RESULT_H diff --git a/foundations/model/include/error_message.h b/foundations/model/include/error_message.h new file mode 100644 index 0000000000000000000000000000000000000000..7d565bf8d5f365c9e802681b43d6116ef3d7f8f6 --- /dev/null +++ b/foundations/model/include/error_message.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_ERROR_MESSAGE_H +#define UPDATE_SERVICE_ERROR_MESSAGE_H + +#include +#include + +#include "nlohmann/json.hpp" + +#include "dupdate_json_utils.h" +#include "json_builder.h" + +namespace OHOS::UpdateEngine { +struct ErrorMessage { + int32_t errorCode = 0; + std::string errorMessage; + + friend void to_json(nlohmann::json &jsonObj, const ErrorMessage &message) + { + jsonObj["errorCode"] = message.errorCode; + jsonObj["errorMessage"] = message.errorMessage; + } + + friend void from_json(const nlohmann::json &jsonObj, ErrorMessage &message) + { + JsonUtils::GetValueAndSetTo(jsonObj, "errorCode", message.errorCode); + JsonUtils::GetValueAndSetTo(jsonObj, "errorMessage", message.errorMessage); + } + + JsonBuilder GetJsonBuilder() + { + return JsonBuilder() + .Append("{") + .Append("errorCode", errorCode) + .Append("errorMessage", errorMessage) + .Append("}"); + } +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_ERROR_MESSAGE_H diff --git a/interfaces/inner_api/include/net_manager_model.h b/foundations/model/include/network_type.h similarity index 88% rename from interfaces/inner_api/include/net_manager_model.h rename to foundations/model/include/network_type.h index 7efa829d2bf222f5eb72aa5a5aa473780a7e65a5..fc85b43585d28de0181b9197d89dd99a3b7a285c 100644 --- a/interfaces/inner_api/include/net_manager_model.h +++ b/foundations/model/include/network_type.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef MIGRATE_SERVER_NET_MANAGER_MODEL_H -#define MIGRATE_SERVER_NET_MANAGER_MODEL_H +#ifndef UPDATE_SERVICE_NETWORK_TYPE_H +#define UPDATE_SERVICE_NETWORK_TYPE_H namespace OHOS::UpdateEngine { enum class NetType { @@ -28,4 +28,4 @@ enum class NetType { CELLULAR_AND_WIFI = CELLULAR | WIFI }; } // namespace OHOS::UpdateEngine -#endif // MIGRATE_SERVER_NET_MANAGER_MODEL_H +#endif // UPDATE_SERVICE_NETWORK_TYPE_H diff --git a/foundations/model/include/update_device_type.h b/foundations/model/include/update_device_type.h new file mode 100644 index 0000000000000000000000000000000000000000..9783e1997a645bbd0b0e4636b672d9e27c1ee813 --- /dev/null +++ b/foundations/model/include/update_device_type.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_DEVICE_TYPE_H +#define UPDATE_SERVICE_DEVICE_TYPE_H + +namespace OHOS::UpdateEngine { +enum class DeviceType { + UNKNOWN = 0, + SMART_PHONE = 1, // 手机 + SMART_PAD = 2, // 平板 + SMART_TV = 4, // 智能电视 + TWS = 6, // 真无线耳机 + KEYBOARD = 7, // 键盘 + PEN = 8 // 手写笔 +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_DEVICE_TYPE_H diff --git a/frameworks/js/napi/session/include/napi_common_define.h b/frameworks/js/napi/session/include/napi_common_define.h index cf04ef387e3fb544f7fec058fe8024e23e2e2933..0db714dc6733d5aca72e2f8c28bc726c3e961c82 100644 --- a/frameworks/js/napi/session/include/napi_common_define.h +++ b/frameworks/js/napi/session/include/napi_common_define.h @@ -24,6 +24,7 @@ #include "update_log.h" namespace OHOS::UpdateEngine { +constexpr int32_t COMPONENT_ERR = 11500000; #define PARAM_CHECK(validCheck, exper, ...) \ if (!(validCheck)) { \ ENGINE_LOGE(__VA_ARGS__); \ diff --git a/frameworks/js/napi/session/include/napi_common_utils.h b/frameworks/js/napi/session/include/napi_common_utils.h index e1f180c4a72f0c030f3247ab72da4c98cffcd766..41ddd10ddc7d8e38e767b95a40cd01b78c167fb1 100644 --- a/frameworks/js/napi/session/include/napi_common_utils.h +++ b/frameworks/js/napi/session/include/napi_common_utils.h @@ -22,7 +22,9 @@ #include "js_native_api.h" #include "js_native_api_types.h" -#include "common_error_define.h" +#include "business_error.h" +#include "call_result.h" +#include "error_message.h" #include "napi_common_define.h" namespace OHOS::UpdateEngine { diff --git a/frameworks/js/napi/session/include/napi_session.h b/frameworks/js/napi/session/include/napi_session.h index 7efec3d40d488a705f9760f8aebd59b393db1f3c..9ba9e09300566dc0913dba1767657e14fac64db2 100644 --- a/frameworks/js/napi/session/include/napi_session.h +++ b/frameworks/js/napi/session/include/napi_session.h @@ -25,6 +25,8 @@ #include "base_client.h" #include "base_session.h" +#include "business_error.h" +#include "call_result.h" #include "napi_common_define.h" #include "napi_common_utils.h" #include "napi_structs_base.h" diff --git a/frameworks/js/napi/session/include/napi_structs_base.h b/frameworks/js/napi/session/include/napi_structs_base.h index 145ec5c8cdecb8f79bea1ee056c27927b0b83227..726a7218bd7437a53ab64b920bb18869fde34c76 100644 --- a/frameworks/js/napi/session/include/napi_structs_base.h +++ b/frameworks/js/napi/session/include/napi_structs_base.h @@ -18,7 +18,7 @@ #include -#include "common_error_define.h" +#include "business_error.h" #include "napi_common_define.h" namespace OHOS::UpdateEngine { diff --git a/frameworks/js/napi/update/BUILD.gn b/frameworks/js/napi/update/BUILD.gn index c4e7b8b239d09f27a015d90ddfff5babda4f65f0..c356937e89b91aa5abe3bbb63fad6845178976b0 100644 --- a/frameworks/js/napi/update/BUILD.gn +++ b/frameworks/js/napi/update/BUILD.gn @@ -29,7 +29,6 @@ ohos_shared_library("$updateengine_client_library_name") { sources += [ "$updateengine_root_path/frameworks/js/napi/update/common/src/client_helper.cpp", "$updateengine_root_path/frameworks/js/napi/update/common/src/iupdater.cpp", - "$updateengine_root_path/frameworks/js/napi/update/src/define_property.cpp", "$updateengine_root_path/frameworks/js/napi/update/src/local_updater.cpp", "$updateengine_root_path/frameworks/js/napi/update/src/restorer.cpp", @@ -45,24 +44,19 @@ ohos_shared_library("$updateengine_client_library_name") { "$updateengine_root_path/frameworks/js/napi/update/common/include", "$updateengine_root_path/frameworks/js/napi/update/include", - "$updateengine_root_path/services/core/ability/utils/include", - "//third_party/json/include", "//third_party/node/src", # napi ] include_dirs += session_include_dirs deps = [ + "$updateengine_root_path/foundations:update_foundations", "$updateengine_root_path/interfaces/inner_api/engine:$updateengine_inner_library_name", - "//third_party/json:nlohmann_json_static", ] external_deps = [ "c_utils:utils", # sptr "hilog:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", ] if (ability_ability_runtime_enable) { diff --git a/frameworks/js/napi/update/common/include/client_helper.h b/frameworks/js/napi/update/common/include/client_helper.h index bbbb380c0655834db89185905ece859d45e8d959..066f23a24441ed583ac9b8863959a18c4a85d916 100644 --- a/frameworks/js/napi/update/common/include/client_helper.h +++ b/frameworks/js/napi/update/common/include/client_helper.h @@ -20,9 +20,22 @@ #include "node_api.h" +#include "clear_options.h" +#include "description_format.h" +#include "description_options.h" +#include "download_options.h" +#include "event_classify_info.h" +#include "event_info.h" #include "napi_common_utils.h" -#include "update_helper.h" +#include "network_type.h" +#include "order.h" +#include "pause_download_options.h" +#include "resume_download_options.h" #include "update_result.h" +#include "upgrade_file.h" +#include "upgrade_info.h" +#include "upgrade_options.h" +#include "upgrade_policy.h" namespace OHOS::UpdateEngine { class ClientHelper { diff --git a/frameworks/js/napi/update/common/include/upgrade_file.h b/frameworks/js/napi/update/common/include/upgrade_file.h new file mode 100644 index 0000000000000000000000000000000000000000..dd111442c299bdf2f5aa4422e4cfdc137e86f5da --- /dev/null +++ b/frameworks/js/napi/update/common/include/upgrade_file.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 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 UPDATE_SERVICE_UPGRADE_FILE_H +#define UPDATE_SERVICE_UPGRADE_FILE_H + +#include + +#include "component_type.h" + +namespace OHOS::UpdateEngine { +struct UpgradeFile { + ComponentType fileType = ComponentType::INVALID; + std::string filePath; +}; +} // OHOS::UpdateEngine +#endif // UPDATE_SERVICE_UPGRADE_FILE_H diff --git a/frameworks/js/napi/update/common/src/client_helper.cpp b/frameworks/js/napi/update/common/src/client_helper.cpp index 44a3e0fb429bdb5379e5a1e8a459d866ea846fda..758a181b48d1afa2b18ccd4f96fbb3c747e22cb3 100644 --- a/frameworks/js/napi/update/common/src/client_helper.cpp +++ b/frameworks/js/napi/update/common/src/client_helper.cpp @@ -21,9 +21,13 @@ #include "node_api.h" #include "unistd.h" +#include "check_result.h" +#include "component_description.h" +#include "current_version_info.h" #include "napi_common_define.h" +#include "task_body_member_mask.h" #include "update_define.h" -#include "update_helper.h" +#include "version_description_info.h" namespace OHOS::UpdateEngine { void ClientHelper::TrimString(std::string &str) diff --git a/frameworks/js/napi/update/common/src/iupdater.cpp b/frameworks/js/napi/update/common/src/iupdater.cpp index 100ca3e104c72d7c458255767b01c0c3329cdc5e..ac44fb0122c52db780b508fa832f89869a5d179e 100644 --- a/frameworks/js/napi/update/common/src/iupdater.cpp +++ b/frameworks/js/napi/update/common/src/iupdater.cpp @@ -16,7 +16,6 @@ #include "iupdater.h" #include "napi_common_define.h" -#include "update_helper.h" #include "update_session.h" namespace OHOS::UpdateEngine { diff --git a/frameworks/js/napi/update/include/local_updater.h b/frameworks/js/napi/update/include/local_updater.h index 6336693fcb2c87672d797e4ce747f55e7704d89b..3dce891b7b9c2324f37b0e0216db5ec0ce5e558f 100644 --- a/frameworks/js/napi/update/include/local_updater.h +++ b/frameworks/js/napi/update/include/local_updater.h @@ -18,7 +18,6 @@ #include "iupdater.h" #include "node_api.h" -#include "update_helper.h" namespace OHOS::UpdateEngine { class LocalUpdater : public IUpdater { diff --git a/frameworks/js/napi/update/include/session_manager.h b/frameworks/js/napi/update/include/session_manager.h index 4d36cc84e097a08019b956998f128681034d0064..38bf5dc06a3daf8a99df6a8a2c60c8a6bc05b6ec 100644 --- a/frameworks/js/napi/update/include/session_manager.h +++ b/frameworks/js/napi/update/include/session_manager.h @@ -24,7 +24,8 @@ #include "js_native_api_types.h" #include "base_session.h" -#include "update_helper.h" +#include "event_classify_info.h" +#include "event_info.h" namespace OHOS::UpdateEngine { class SessionManager { diff --git a/frameworks/js/napi/update/include/session_type.h b/frameworks/js/napi/update/include/session_type.h index c7d76e991ac96c0e9a3ce757e5575775df826ecb..560a2aa1e7db91b701b0ea1c8079374a1c0fee29 100644 --- a/frameworks/js/napi/update/include/session_type.h +++ b/frameworks/js/napi/update/include/session_type.h @@ -19,28 +19,28 @@ #include namespace OHOS::UpdateEngine::SessionType { - constexpr uint32_t SESSION_CHECK_VERSION = 0; - constexpr uint32_t SESSION_DOWNLOAD = 1; - constexpr uint32_t SESSION_PAUSE_DOWNLOAD = 2; - constexpr uint32_t SESSION_RESUME_DOWNLOAD = 3; - constexpr uint32_t SESSION_UPGRADE = 4; - constexpr uint32_t SESSION_SET_POLICY = 5; - constexpr uint32_t SESSION_GET_POLICY = 6; - constexpr uint32_t SESSION_CLEAR_ERROR = 7; - constexpr uint32_t SESSION_TERMINATE_UPGRADE = 8; - constexpr uint32_t SESSION_GET_NEW_VERSION = 9; - constexpr uint32_t SESSION_GET_NEW_VERSION_DESCRIPTION = 10; - constexpr uint32_t SESSION_SUBSCRIBE = 11; - constexpr uint32_t SESSION_UNSUBSCRIBE = 12; - constexpr uint32_t SESSION_GET_UPDATER = 13; - constexpr uint32_t SESSION_APPLY_NEW_VERSION = 14; - constexpr uint32_t SESSION_FACTORY_RESET = 15; - constexpr uint32_t SESSION_VERIFY_PACKAGE = 16; - constexpr uint32_t SESSION_CANCEL_UPGRADE = 17; - constexpr uint32_t SESSION_GET_CUR_VERSION = 18; - constexpr uint32_t SESSION_GET_CUR_VERSION_DESCRIPTION = 19; - constexpr uint32_t SESSION_GET_TASK_INFO = 20; - constexpr uint32_t SESSION_REPLY_PARAM_ERROR = 21; - constexpr uint32_t SESSION_MAX = UINT32_MAX; +constexpr uint32_t SESSION_CHECK_VERSION = 0; +constexpr uint32_t SESSION_DOWNLOAD = 1; +constexpr uint32_t SESSION_PAUSE_DOWNLOAD = 2; +constexpr uint32_t SESSION_RESUME_DOWNLOAD = 3; +constexpr uint32_t SESSION_UPGRADE = 4; +constexpr uint32_t SESSION_SET_POLICY = 5; +constexpr uint32_t SESSION_GET_POLICY = 6; +constexpr uint32_t SESSION_CLEAR_ERROR = 7; +constexpr uint32_t SESSION_TERMINATE_UPGRADE = 8; +constexpr uint32_t SESSION_GET_NEW_VERSION = 9; +constexpr uint32_t SESSION_GET_NEW_VERSION_DESCRIPTION = 10; +constexpr uint32_t SESSION_SUBSCRIBE = 11; +constexpr uint32_t SESSION_UNSUBSCRIBE = 12; +constexpr uint32_t SESSION_GET_UPDATER = 13; +constexpr uint32_t SESSION_APPLY_NEW_VERSION = 14; +constexpr uint32_t SESSION_FACTORY_RESET = 15; +constexpr uint32_t SESSION_VERIFY_PACKAGE = 16; +constexpr uint32_t SESSION_CANCEL_UPGRADE = 17; +constexpr uint32_t SESSION_GET_CUR_VERSION = 18; +constexpr uint32_t SESSION_GET_CUR_VERSION_DESCRIPTION = 19; +constexpr uint32_t SESSION_GET_TASK_INFO = 20; +constexpr uint32_t SESSION_REPLY_PARAM_ERROR = 21; +constexpr uint32_t SESSION_MAX = UINT32_MAX; } // namespace OHOS::UpdateEngine::SessionType #endif // UPDATE_SESSION_TYPE_H diff --git a/frameworks/js/napi/update/include/update_client.h b/frameworks/js/napi/update/include/update_client.h index 392d43f55ae32526f46eab5c8356304467528444..dfb93d9d358ecb228b24756a6f61441195eaca1a 100644 --- a/frameworks/js/napi/update/include/update_client.h +++ b/frameworks/js/napi/update/include/update_client.h @@ -16,7 +16,13 @@ #ifndef UPDATE_CLIENT_H #define UPDATE_CLIENT_H +#include "check_result.h" +#include "current_version_info.h" #include "iupdater.h" +#include "new_version_info.h" +#include "progress.h" +#include "task_info.h" +#include "version_description_info.h" namespace OHOS::UpdateEngine { class UpdateClient : public IUpdater { diff --git a/frameworks/js/napi/update/include/update_result.h b/frameworks/js/napi/update/include/update_result.h index 3fe6ac60c31b78b51678c42fec8ec7d25ee287ed..435f978a3f9b0080455c7cc725015bc00a4fa68f 100644 --- a/frameworks/js/napi/update/include/update_result.h +++ b/frameworks/js/napi/update/include/update_result.h @@ -16,8 +16,15 @@ #ifndef UPDATE_RESULT_H #define UPDATE_RESULT_H +#include "check_result.h" +#include "current_version_info.h" #include "napi_structs_base.h" +#include "new_version_info.h" +#include "progress.h" #include "session_type.h" +#include "task_info.h" +#include "upgrade_policy.h" +#include "version_description_info.h" namespace OHOS::UpdateEngine { struct UpdateResult : NapiResult { diff --git a/frameworks/js/napi/update/include/update_session.h b/frameworks/js/napi/update/include/update_session.h index b67df88976e5de10fb2c6aa9af2470785c4b9e12..dfe615f1055cdf4acea790e73c593ef8871bfccb 100644 --- a/frameworks/js/napi/update/include/update_session.h +++ b/frameworks/js/napi/update/include/update_session.h @@ -25,9 +25,7 @@ #include "base_async_session.h" #include "base_promise_session.h" #include "iupdater.h" -#include "iupdate_service.h" #include "napi_session.h" -#include "update_client.h" namespace OHOS::UpdateEngine { class BaseUpdateSession : public BaseAsyncSession { diff --git a/frameworks/js/napi/update/src/define_property.cpp b/frameworks/js/napi/update/src/define_property.cpp index bd97a3e9b870aca5b4de6ab399ddcbd4b17d7354..b4bddcafcd95828f4abfdbd72ef6b5d06f2a320c 100644 --- a/frameworks/js/napi/update/src/define_property.cpp +++ b/frameworks/js/napi/update/src/define_property.cpp @@ -15,10 +15,22 @@ #include "define_property.h" +#include "business_sub_type.h" +#include "business_vendor.h" +#include "call_result.h" +#include "component_type.h" +#include "description_format.h" +#include "description_type.h" +#include "effective_mode.h" +#include "event_classify.h" +#include "event_id.h" #include "napi_common_utils.h" +#include "network_type.h" +#include "order.h" #include "string_utils.h" #include "update_define.h" -#include "update_helper.h" +#include "upgrade_action.h" +#include "upgrade_status.h" #define DECLARE_ENUM_PROPERTY(item) \ {StringUtils::GetEnumValueString(#item), NapiCommonUtils::CreateUint32(env, CAST_UINT((item)))} diff --git a/frameworks/js/napi/update/src/local_updater.cpp b/frameworks/js/napi/update/src/local_updater.cpp index 5b3967bff24c772a71a15c9e490af69b4010f989..1621450197aa29fbe655fcdfea7fd85d0962ae7c 100644 --- a/frameworks/js/napi/update/src/local_updater.cpp +++ b/frameworks/js/napi/update/src/local_updater.cpp @@ -17,6 +17,7 @@ #include "napi_common_utils.h" #include "update_define.h" +#include "update_callback_info.h" #include "update_service_kits.h" namespace OHOS::UpdateEngine { diff --git a/frameworks/js/napi/update/src/session_manager.cpp b/frameworks/js/napi/update/src/session_manager.cpp index 66aacd0e214153215a6c2d60a847475966d55d7f..eb17ba7df65ddf6ddb10c1ae41733d650c473150 100644 --- a/frameworks/js/napi/update/src/session_manager.cpp +++ b/frameworks/js/napi/update/src/session_manager.cpp @@ -21,7 +21,6 @@ #include "client_helper.h" #include "update_define.h" -#include "update_helper.h" #include "update_session.h" using namespace std; diff --git a/frameworks/js/napi/update/src/update_client.cpp b/frameworks/js/napi/update/src/update_client.cpp index 39f2252feabf9888174bd1720a6708c69fdb47ed..2bc0d39d388e274270fd26869abc563e762c1dd6 100644 --- a/frameworks/js/napi/update/src/update_client.cpp +++ b/frameworks/js/napi/update/src/update_client.cpp @@ -19,9 +19,9 @@ #include "client_helper.h" #include "napi_common_utils.h" -#include "update_helper.h" #include "update_service_kits.h" #include "update_session.h" +#include "update_callback_info.h" #include "updater_sa_ipc_interface_code.h" using namespace std; @@ -119,26 +119,14 @@ napi_value UpdateClient::CheckNewVersion(napi_env env, napi_callback_info info) napi_value UpdateClient::CancelUpgrade(napi_env env, napi_callback_info info) { - size_t argc = MAX_ARGC; - napi_value args[MAX_ARGC] = { 0 }; - napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); - PARAM_CHECK_NAPI_CALL(env, status == napi_ok && argc == 0, return nullptr, "Error get cb info"); ENGINE_LOGI("CancelUpgrade"); SessionParams sessionParams(SessionType::SESSION_CANCEL_UPGRADE, CALLBACK_POSITION_ONE, true); - std::shared_ptr sess = nullptr; - sess = std::make_shared(this, sessionParams, argc); - PARAM_CHECK_NAPI_CALL(env, sess != nullptr, return nullptr, "Failed to create update session"); - sessionsMgr_->AddSession(sess); - napi_value retValue = sess->StartWork( - env, args, - [=](void *context) -> int { - BusinessError *businessError = reinterpret_cast(context); + napi_value retValue = StartSession(env, info, sessionParams, [=](void *context) -> int { + BusinessError *businessError = reinterpret_cast(context); return UpdateServiceKits::GetInstance().Cancel(upgradeInfo_, CAST_INT(UpdaterSaInterfaceCode::DOWNLOAD), *businessError); - }, - nullptr); - PARAM_CHECK(retValue != nullptr, sessionsMgr_->RemoveSession(sess->GetSessionId()); - return nullptr, "Failed to start worker."); + }); + PARAM_CHECK(retValue != nullptr, return nullptr, "Failed to start worker."); return retValue; } diff --git a/frameworks/js/napi/update/src/update_session.cpp b/frameworks/js/napi/update/src/update_session.cpp index 9c13a8e7c55bc09f8066d4cbff456df4548805cc..59da7c8c8546a55d2bb86e3db300387614698185 100644 --- a/frameworks/js/napi/update/src/update_session.cpp +++ b/frameworks/js/napi/update/src/update_session.cpp @@ -20,7 +20,6 @@ #include "client_helper.h" #include "napi_common_utils.h" #include "update_define.h" -#include "update_helper.h" using namespace std; diff --git a/interfaces/inner_api/engine/BUILD.gn b/interfaces/inner_api/engine/BUILD.gn index 8dcbb7d13f33d13c725a4fdf2b1e5f6130f1cd90..008142910d3ac83ff3dbb2544747feafef4b1446 100644 --- a/interfaces/inner_api/engine/BUILD.gn +++ b/interfaces/inner_api/engine/BUILD.gn @@ -11,9 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//base/update/updateservice/foundations/foundations.gni") import("//base/update/updateservice/updateengine.gni") import("//build/ohos.gni") -import("$updateengine_root_path/services/core/ability/log/log.gni") +import("../feature/feature.gni") ohos_prebuilt_etc("updater_sa.rc") { source = "etc/updater_sa.rc" @@ -25,13 +26,10 @@ ohos_prebuilt_etc("updater_sa.rc") { config("updateengine_inner_library_native_config") { include_dirs = [ "$updateengine_root_path/interfaces/inner_api/include", - "$updateengine_root_path/interfaces/inner_api/common/include", - "$updateengine_root_path/services/core/ability/define/include", - "$updateengine_root_path/services/core/ability/log/include", - "$updateengine_root_path/services/core/ability/utils/include", - "//third_party/json/include", ] + include_dirs += feature_include + include_dirs += foundations_include } ohos_shared_library("$updateengine_inner_library_name") { @@ -47,24 +45,15 @@ ohos_shared_library("$updateengine_inner_library_name") { defines += [ "ABILITY_RUNTIME_INNER_ENABLE" ] } sources = [ - "$updateengine_root_path/interfaces/inner_api/common/src/load_sa_service.cpp", - "$updateengine_root_path/interfaces/inner_api/engine/update_service_kits_impl.cpp", - "$updateengine_root_path/interfaces/inner_api/engine/update_service_proxy.cpp", - "$updateengine_root_path/services/callback/src/update_callback.cpp", - "$updateengine_root_path/services/callback/src/update_callback_stub.cpp", - "$updateengine_root_path/services/core/ability/log/src/update_log.cpp", - "$updateengine_root_path/services/engine/src/message_parcel_helper.cpp", - "$updateengine_root_path/services/engine/src/update_helper.cpp", + "$updateengine_root_path/interfaces/inner_api/engine/src/update_callback.cpp", + "$updateengine_root_path/interfaces/inner_api/engine/src/update_callback_stub.cpp", + "$updateengine_root_path/interfaces/inner_api/engine/src/update_service_kits_impl.cpp", + "$updateengine_root_path/interfaces/inner_api/engine/src/update_service_proxy.cpp", ] include_dirs = [ - "$updateengine_root_path/interfaces/inner_api/common/include", + "$updateengine_root_path/interfaces/inner_api/engine/include", "$updateengine_root_path/interfaces/inner_api/include", - "$updateengine_root_path/services/callback/include", - "$updateengine_root_path/services/engine/include", - - "$updateengine_root_path/services/core/ability/define/include", - "$updateengine_root_path/services/core/ability/utils/include", "//third_party/json/include", "//third_party/bounds_checking_function/include", # secure method @@ -73,19 +62,25 @@ ohos_shared_library("$updateengine_inner_library_name") { public_configs = [ ":updateengine_inner_library_native_config" ] deps = [ + "$updateengine_root_path/foundations:update_foundations", "$updateengine_root_path/interfaces/inner_api/modulemgr:update_module_mgr", "//third_party/bounds_checking_function:libsec_static", - "//third_party/json:nlohmann_json_static", ] external_deps = [ "c_utils:utils", # sptr "hilog:libhilog", "ipc:ipc_core", + "json:nlohmann_json_static", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] + include_dirs += feature_include + sources += feature_sources + deps += feature_deps + external_deps += feature_external_deps + if (ability_ability_runtime_enable) { external_deps += [ "ability_runtime:ability_manager" ] } diff --git a/services/callback/include/update_callback.h b/interfaces/inner_api/engine/include/update_callback.h similarity index 97% rename from services/callback/include/update_callback.h rename to interfaces/inner_api/engine/include/update_callback.h index 202a9500e6d5647df9a7d136ee9045c476a2f267..8d83ff6f915f04b5677419b07181723387e02c56 100644 --- a/services/callback/include/update_callback.h +++ b/interfaces/inner_api/engine/include/update_callback.h @@ -16,8 +16,8 @@ #ifndef UPDATE_CALLBACK_H #define UPDATE_CALLBACK_H +#include "update_callback_info.h" #include "update_callback_stub.h" -#include "update_helper.h" namespace OHOS::UpdateEngine { class UpdateCallback : public UpdateCallbackStub { diff --git a/services/callback/include/update_callback_stub.h b/interfaces/inner_api/engine/include/update_callback_stub.h similarity index 100% rename from services/callback/include/update_callback_stub.h rename to interfaces/inner_api/engine/include/update_callback_stub.h diff --git a/interfaces/inner_api/include/update_service_kits_impl.h b/interfaces/inner_api/engine/include/update_service_kits_impl.h similarity index 99% rename from interfaces/inner_api/include/update_service_kits_impl.h rename to interfaces/inner_api/engine/include/update_service_kits_impl.h index a759e86c0316898043ee2f112a6a638d26f74abc..9640797732a16696fc5a95b79b8c1cadfa3ae499 100644 --- a/interfaces/inner_api/include/update_service_kits_impl.h +++ b/interfaces/inner_api/engine/include/update_service_kits_impl.h @@ -21,7 +21,6 @@ #include "base_service_kits_impl.h" #include "iupdate_callback.h" #include "update_define.h" -#include "update_helper.h" #include "update_service_kits.h" #include "update_callback.h" #include "update_service_proxy.h" diff --git a/services/engine/include/update_service_proxy.h b/interfaces/inner_api/engine/include/update_service_proxy.h similarity index 100% rename from services/engine/include/update_service_proxy.h rename to interfaces/inner_api/engine/include/update_service_proxy.h diff --git a/services/callback/src/update_callback.cpp b/interfaces/inner_api/engine/src/update_callback.cpp similarity index 100% rename from services/callback/src/update_callback.cpp rename to interfaces/inner_api/engine/src/update_callback.cpp diff --git a/services/callback/src/update_callback_stub.cpp b/interfaces/inner_api/engine/src/update_callback_stub.cpp similarity index 98% rename from services/callback/src/update_callback_stub.cpp rename to interfaces/inner_api/engine/src/update_callback_stub.cpp index 55f9b0328d400bc2a976e0b8610391e1bcd605a5..a8be6b92c7655cd771e01dfc17b248f71047506e 100644 --- a/services/callback/src/update_callback_stub.cpp +++ b/interfaces/inner_api/engine/src/update_callback_stub.cpp @@ -16,7 +16,6 @@ #include "update_callback_stub.h" #include "message_parcel_helper.h" -#include "update_helper.h" #include "update_log.h" using namespace std; diff --git a/interfaces/inner_api/engine/update_service_kits_impl.cpp b/interfaces/inner_api/engine/src/update_service_kits_impl.cpp similarity index 100% rename from interfaces/inner_api/engine/update_service_kits_impl.cpp rename to interfaces/inner_api/engine/src/update_service_kits_impl.cpp diff --git a/interfaces/inner_api/engine/update_service_proxy.cpp b/interfaces/inner_api/engine/src/update_service_proxy.cpp similarity index 97% rename from interfaces/inner_api/engine/update_service_proxy.cpp rename to interfaces/inner_api/engine/src/update_service_proxy.cpp index 05d69311aa781f1b1302a6775e276ecf73591e7e..4a0442388e7b3b35f7cdcab1e0ca0ad948ca7c0e 100644 --- a/interfaces/inner_api/engine/update_service_proxy.cpp +++ b/interfaces/inner_api/engine/src/update_service_proxy.cpp @@ -13,18 +13,30 @@ * limitations under the License. */ +#include #include "update_service_proxy.h" #include "securec.h" -#include "common_check.h" #include "message_parcel_helper.h" #include "update_define.h" -#include "update_helper.h" +#include "update_define.h" #include "update_log.h" #include "updater_sa_ipc_interface_code.h" namespace OHOS::UpdateEngine { +#define RETURN_WHEN_REMOTE_NULL(remote) \ + ENGINE_CHECK((remote) != nullptr, return INT_CALL_IPC_ERR, "Can not get remote") + +#define IPC_RESULT_TO_CALL_RESULT(result) \ + if ((result) == ERR_NONE) { \ + result = INT_CALL_SUCCESS; \ + } else if ((result) >= CALL_RESULT_OFFSET) { \ + result = (result) - CALL_RESULT_OFFSET; \ + } else { \ + result = INT_CALL_IPC_ERR; \ + } + #define RETURN_WHEN_TOKEN_WRITE_FAIL(data) \ if (!(data).WriteInterfaceToken(GetDescriptor())) { \ ENGINE_LOGE("UpdateServiceProxy WriteInterfaceToken fail"); \ diff --git a/interfaces/inner_api/feature/feature.gni b/interfaces/inner_api/feature/feature.gni new file mode 100644 index 0000000000000000000000000000000000000000..045c15c8cb73a081dea9c2dca3380d8b4ff8fa65 --- /dev/null +++ b/interfaces/inner_api/feature/feature.gni @@ -0,0 +1,31 @@ +# Copyright (c) 2024 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. + +import("../feature/update/api/api.gni") +import("../feature/update/model/model.gni") + +feature_external_deps = [] +feature_external_deps += api_external_deps +feature_external_deps += model_external_deps + +feature_deps = [] +feature_deps += api_deps +feature_deps += model_deps + +feature_include = [] +feature_include += api_include +feature_include += model_include + +feature_sources = [] +feature_sources += api_src +feature_sources += model_src diff --git a/interfaces/inner_api/feature/update/api/api.gni b/interfaces/inner_api/feature/update/api/api.gni new file mode 100644 index 0000000000000000000000000000000000000000..a5d40ef519f9f3e599df225752153d302ff5c63e --- /dev/null +++ b/interfaces/inner_api/feature/update/api/api.gni @@ -0,0 +1,23 @@ +# Copyright (c) 2024 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. + +api_external_deps = [] +api_deps = [] +api_include = [ + "../feature/update/api/callback", + "../feature/update/api/local_updater", + "../feature/update/api/online_updater", + "../feature/update/api/restorer", + "../feature/update/api/update_service", +] +api_src = [] diff --git a/interfaces/inner_api/include/iupdate_callback.h b/interfaces/inner_api/feature/update/api/callback/iupdate_callback.h similarity index 93% rename from interfaces/inner_api/include/iupdate_callback.h rename to interfaces/inner_api/feature/update/api/callback/iupdate_callback.h index 68f83ed998a1a58693131533ee98d8f5af437f45..7d21263459e008f18cd8e00d293c30a8e3f2ff24 100644 --- a/interfaces/inner_api/include/iupdate_callback.h +++ b/interfaces/inner_api/feature/update/api/callback/iupdate_callback.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 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 @@ -17,7 +17,7 @@ #define IUPDATE_CALLBACK_H #include -#include "update_helper.h" +#include "event_info.h" #include "iremote_broker.h" #include "iremote_proxy.h" diff --git a/interfaces/inner_api/include/iservice_local_updater.h b/interfaces/inner_api/feature/update/api/local_updater/iservice_local_updater.h similarity index 92% rename from interfaces/inner_api/include/iservice_local_updater.h rename to interfaces/inner_api/feature/update/api/local_updater/iservice_local_updater.h index 6d44ff90324b2019b2556fa64c2f2bd186f4e49f..1d98f6861c13f3bf1c7e8f9697a987995d1c13c1 100644 --- a/interfaces/inner_api/include/iservice_local_updater.h +++ b/interfaces/inner_api/feature/update/api/local_updater/iservice_local_updater.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 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 @@ -18,7 +18,8 @@ #include "refbase.h" -#include "update_helper.h" +#include "business_error.h" +#include "upgrade_info.h" namespace OHOS::UpdateEngine { class IServiceLocalUpdater : public virtual RefBase { diff --git a/interfaces/inner_api/include/iservice_online_updater.h b/interfaces/inner_api/feature/update/api/online_updater/iservice_online_updater.h similarity index 86% rename from interfaces/inner_api/include/iservice_online_updater.h rename to interfaces/inner_api/feature/update/api/online_updater/iservice_online_updater.h index a38db25abbe626f8349e936d01e6ba5251a73ce2..ef26ce6837685e61aa0eb0bce7300ac08470c7b1 100644 --- a/interfaces/inner_api/include/iservice_online_updater.h +++ b/interfaces/inner_api/feature/update/api/online_updater/iservice_online_updater.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 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 @@ -18,8 +18,22 @@ #include "refbase.h" +#include "business_error.h" +#include "check_result.h" +#include "clear_options.h" +#include "current_version_info.h" +#include "description_options.h" +#include "download_options.h" #include "iupdate_callback.h" -#include "update_helper.h" +#include "pause_download_options.h" +#include "resume_download_options.h" +#include "new_version_info.h" +#include "upgrade_info.h" +#include "upgrade_options.h" +#include "upgrade_policy.h" +#include "task_info.h" +#include "version_description_info.h" +#include "version_digest_info.h" namespace OHOS::UpdateEngine { class IServiceOnlineUpdater : public virtual RefBase { diff --git a/interfaces/inner_api/include/iservice_restorer.h b/interfaces/inner_api/feature/update/api/restorer/iservice_restorer.h similarity index 92% rename from interfaces/inner_api/include/iservice_restorer.h rename to interfaces/inner_api/feature/update/api/restorer/iservice_restorer.h index b1bd7a60193308d4d77f839b8af3a5863598d9d2..857554b17e38e4bda3aa62322304710dfab09169 100644 --- a/interfaces/inner_api/include/iservice_restorer.h +++ b/interfaces/inner_api/feature/update/api/restorer/iservice_restorer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 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 @@ -18,7 +18,7 @@ #include "refbase.h" -#include "update_helper.h" +#include "business_error.h" namespace OHOS::UpdateEngine { class IServiceRestorer : public virtual RefBase { diff --git a/interfaces/inner_api/include/iupdate_service.h b/interfaces/inner_api/feature/update/api/update_service/iupdate_service.h similarity index 94% rename from interfaces/inner_api/include/iupdate_service.h rename to interfaces/inner_api/feature/update/api/update_service/iupdate_service.h index 6a28bf728035e2332cd31c99d46ffa86256e8248..dda1db37a5dc87d981e0a9e4414b9ae683790f81 100644 --- a/interfaces/inner_api/include/iupdate_service.h +++ b/interfaces/inner_api/feature/update/api/update_service/iupdate_service.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 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 @@ -23,7 +23,6 @@ #include "iservice_online_updater.h" #include "iservice_restorer.h" #include "iupdate_callback.h" -#include "update_helper.h" namespace OHOS::UpdateEngine { class IUpdateService : public OHOS::IRemoteBroker, public IServiceOnlineUpdater, public IServiceRestorer, diff --git a/interfaces/inner_api/common/include/common_check.h b/interfaces/inner_api/feature/update/model/check/check_result.h similarity index 50% rename from interfaces/inner_api/common/include/common_check.h rename to interfaces/inner_api/feature/update/model/check/check_result.h index 5200df945f4d94df51014b4930d270f079f0da58..828fe406827b733c70f30b022e1b5f5a55b17b65 100644 --- a/interfaces/inner_api/common/include/common_check.h +++ b/interfaces/inner_api/feature/update/model/check/check_result.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 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 @@ -13,19 +13,15 @@ * limitations under the License. */ -#ifndef COMMON_CHECK_H -#define COMMON_CHECK_H +#ifndef UPDATE_SERVICE_CHECK_RESULT_H +#define UPDATE_SERVICE_CHECK_RESULT_H -namespace OHOS::UpdateEngine { -#define RETURN_WHEN_REMOTE_NULL(remote) ENGINE_CHECK((remote) != nullptr, return INT_CALL_IPC_ERR, "Can not get remote") +#include "new_version_info.h" -#define IPC_RESULT_TO_CALL_RESULT(result) \ - if ((result) == ERR_NONE) { \ - result = INT_CALL_SUCCESS; \ - } else if ((result) >= CALL_RESULT_OFFSET) { \ - result = (result) - CALL_RESULT_OFFSET; \ - } else { \ - result = INT_CALL_IPC_ERR; \ - } +namespace OHOS::UpdateEngine { +struct CheckResult { + bool isExistNewVersion = false; + NewVersionInfo newVersionInfo; +}; } // namespace OHOS::UpdateEngine -#endif // COMMON_CHECK_H \ No newline at end of file +#endif // UPDATE_SERVICE_CHECK_RESULT_H diff --git a/interfaces/inner_api/feature/update/model/check/search_status.h b/interfaces/inner_api/feature/update/model/check/search_status.h new file mode 100644 index 0000000000000000000000000000000000000000..1a30af16e9cf26722f00529f3fd7a6a0b4d3e286 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/check/search_status.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_SEARCH_STATUS_H +#define UPDATE_SERVICE_SEARCH_STATUS_H + +namespace OHOS::UpdateEngine { +// 搜索状态 +enum class SearchStatus { + NET_ERROR = -2, + SYSTEM_ERROR, + HAS_NEW_VERSION, + NO_NEW_VERSION, + SERVER_BUSY, + CHECK_EXECUTE_ERR +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_SEARCH_STATUS_H diff --git a/interfaces/inner_api/feature/update/model/clear/clear_options.h b/interfaces/inner_api/feature/update/model/clear/clear_options.h new file mode 100644 index 0000000000000000000000000000000000000000..5b8abe891fe747f93c5ea6b01eb5874950ef8d71 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/clear/clear_options.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_CLEAR_OPTIONS_H +#define UPDATE_SERVICE_CLEAR_OPTIONS_H + +#include "upgrade_status.h" + +namespace OHOS::UpdateEngine { +struct ClearOptions { + UpgradeStatus status = UpgradeStatus::INIT; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_CLEAR_OPTIONS_H diff --git a/interfaces/inner_api/feature/update/model/common/base_json_struct.h b/interfaces/inner_api/feature/update/model/common/base_json_struct.h new file mode 100644 index 0000000000000000000000000000000000000000..fb81696668f88564ef895102777b2b274df6673f --- /dev/null +++ b/interfaces/inner_api/feature/update/model/common/base_json_struct.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_BASE_JSON_STRUCT_H +#define UPDATE_SERVICE_BASE_JSON_STRUCT_H + +#include + +#include "json_builder.h" + +namespace OHOS::UpdateEngine { +struct BaseJsonStruct { + virtual ~BaseJsonStruct() = default; + + virtual JsonBuilder GetJsonBuilder() = 0; + + virtual std::string ToJson() + { + return GetJsonBuilder().ToJson(); + }; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_BASE_JSON_STRUCT_H diff --git a/interfaces/inner_api/feature/update/model/common/order.h b/interfaces/inner_api/feature/update/model/common/order.h new file mode 100644 index 0000000000000000000000000000000000000000..812559e24f4c6c84892bbcbd1801f204a35e7752 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/common/order.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_ORDER_H +#define UPDATE_SERVICE_ORDER_H + +namespace OHOS::UpdateEngine { +enum class Order { + DOWNLOAD = 1, + INSTALL = 2, + DOWNLOAD_AND_INSTALL = DOWNLOAD | INSTALL, + APPLY = 4, + INSTALL_AND_APPLY = INSTALL | APPLY +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_ORDER_H diff --git a/interfaces/inner_api/feature/update/model/common/progress.h b/interfaces/inner_api/feature/update/model/common/progress.h new file mode 100644 index 0000000000000000000000000000000000000000..aaed216c589bf0398a1f3c626bff8642595ad723 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/common/progress.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_PROGRESS_H +#define UPDATE_SERVICE_PROGRESS_H + +#include +#include + +#include "upgrade_status.h" + +namespace OHOS::UpdateEngine { +struct Progress { + uint32_t percent = 0; + UpgradeStatus status = UpgradeStatus::INIT; + std::string endReason; +}; +} // OHOS::UpdateEngine +#endif // UPDATE_SERVICE_PROGRESS_H diff --git a/interfaces/inner_api/feature/update/model/common/upgrade_status.h b/interfaces/inner_api/feature/update/model/common/upgrade_status.h new file mode 100644 index 0000000000000000000000000000000000000000..21f97c439d0e4ac9b5128003283923064ca1319f --- /dev/null +++ b/interfaces/inner_api/feature/update/model/common/upgrade_status.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_UPGRADE_STATUS_H +#define UPDATE_SERVICE_UPGRADE_STATUS_H + +namespace OHOS::UpdateEngine { +enum class UpgradeStatus { + INIT = 0, + CHECKING_VERSION = 10, + CHECK_VERSION_FAIL, + CHECK_VERSION_SUCCESS, + DOWNLOADING = 20, + DOWNLOAD_PAUSE, + DOWNLOAD_CANCEL, + DOWNLOAD_FAIL, + DOWNLOAD_SUCCESS, + VERIFYING = 30, + VERIFY_FAIL, + VERIFY_SUCCESS, + AUTHING, + AUTH_FAIL, + AUTH_SUCCESS, + PACKAGE_TRANSING = 70, + PACKAGE_TRANS_FAIL, + PACKAGE_TRANS_SUCCESS, + INSTALLING = 80, + INSTALL_FAIL, + INSTALL_SUCCESS, + UPDATING = 90, + UPDATE_FAIL, + UPDATE_SUCCESS +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_UPGRADE_STATUS_H diff --git a/interfaces/inner_api/feature/update/model/download/download_options.h b/interfaces/inner_api/feature/update/model/download/download_options.h new file mode 100644 index 0000000000000000000000000000000000000000..d8e380971847043eecb482395ec40dc8995f5ed4 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/download/download_options.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_DOWNLOAD_OPTIONS_H +#define UPDATE_SERVICE_DOWNLOAD_OPTIONS_H + +#include "network_type.h" +#include "order.h" + +namespace OHOS::UpdateEngine { +struct DownloadOptions { + NetType allowNetwork = NetType::WIFI; + Order order = Order::DOWNLOAD; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_DOWNLOAD_OPTIONS_H diff --git a/interfaces/inner_api/feature/update/model/download/pause_download_options.h b/interfaces/inner_api/feature/update/model/download/pause_download_options.h new file mode 100644 index 0000000000000000000000000000000000000000..bd26b4de2ae44f42eec5c06c482bbd3cb28dcc83 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/download/pause_download_options.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_PAUSE_DOWNLOAD_OPTIONS_H +#define UPDATE_SERVICE_PAUSE_DOWNLOAD_OPTIONS_H + +namespace OHOS::UpdateEngine { +struct PauseDownloadOptions { + bool isAllowAutoResume = false; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_PAUSE_DOWNLOAD_OPTIONS_H diff --git a/interfaces/inner_api/feature/update/model/download/resume_download_options.h b/interfaces/inner_api/feature/update/model/download/resume_download_options.h new file mode 100644 index 0000000000000000000000000000000000000000..22a35d16c1df4b2f2d6a079467f002f0047d4533 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/download/resume_download_options.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_RESUME_DOWNLOAD_OPTIONS_H +#define UPDATE_SERVICE_RESUME_DOWNLOAD_OPTIONS_H + +#include "network_type.h" + +namespace OHOS::UpdateEngine { +struct ResumeDownloadOptions { + NetType allowNetwork = NetType::WIFI; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_RESUME_DOWNLOAD_OPTIONS_H diff --git a/interfaces/inner_api/feature/update/model/event/event_classify.h b/interfaces/inner_api/feature/update/model/event/event_classify.h new file mode 100644 index 0000000000000000000000000000000000000000..4b70e86c8093bf9839d1da7142393658fcbb7ba4 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/event/event_classify.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_EVENT_CLASSIFY_H +#define UPDATE_SERVICE_EVENT_CLASSIFY_H + +#include + +namespace OHOS::UpdateEngine { +enum class EventClassify { + TASK = 0x01000000, + SYSTEM = 0x02000000, +}; + +const std::list g_eventClassifyList = { EventClassify::TASK, EventClassify::SYSTEM }; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_EVENT_CLASSIFY_H diff --git a/interfaces/inner_api/feature/update/model/event/event_id.h b/interfaces/inner_api/feature/update/model/event/event_id.h new file mode 100644 index 0000000000000000000000000000000000000000..11e13724748de4295b4d9b5eb105a2873e2335c3 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/event/event_id.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_EVENT_ID_H +#define UPDATE_SERVICE_EVENT_ID_H + +#include "event_classify.h" +#include "update_define.h" + +namespace OHOS::UpdateEngine { +enum class EventId { + EVENT_TASK_BASE = CAST_UINT(EventClassify::TASK), + EVENT_TASK_RECEIVE, + EVENT_TASK_CANCEL, + EVENT_DOWNLOAD_WAIT, + EVENT_DOWNLOAD_START, + EVENT_DOWNLOAD_UPDATE, + EVENT_DOWNLOAD_PAUSE, + EVENT_DOWNLOAD_RESUME, + EVENT_DOWNLOAD_SUCCESS, + EVENT_DOWNLOAD_FAIL, + EVENT_UPGRADE_WAIT, + EVENT_UPGRADE_START, + EVENT_UPGRADE_UPDATE, + EVENT_APPLY_WAIT, + EVENT_APPLY_START, + EVENT_UPGRADE_SUCCESS, + EVENT_UPGRADE_FAIL, + EVENT_AUTH_START, + EVENT_AUTH_SUCCESS, + EVENT_DOWNLOAD_CANCEL, + EVENT_INITIALIZE, + EVENT_TASK_CHANGE, + EVENT_VERSION_INFO_CHANGE, + SYSTEM_BASE = CAST_UINT(EventClassify::SYSTEM), + SYSTEM_BOOT_COMPLETE, +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_EVENT_ID_H diff --git a/interfaces/inner_api/feature/update/model/event/event_info.h b/interfaces/inner_api/feature/update/model/event/event_info.h new file mode 100644 index 0000000000000000000000000000000000000000..461d58f61d174330fdbb1d7bb88cbd57721f9cea --- /dev/null +++ b/interfaces/inner_api/feature/update/model/event/event_info.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_EVENT_INFO_H +#define UPDATE_SERVICE_EVENT_INFO_H + +#include "base_json_struct.h" +#include "event_id.h" +#include "task_body.h" + +namespace OHOS::UpdateEngine { +struct EventInfo : public BaseJsonStruct { + EventId eventId = EventId::EVENT_TASK_BASE; + TaskBody taskBody; + + EventInfo() = default; + EventInfo(EventId id, TaskBody body) : eventId(id), taskBody(std::move(body)) {} + + JsonBuilder GetJsonBuilder() final; +}; +} // OHOS::UpdateEngine +#endif // UPDATE_SERVICE_EVENT_INFO_H diff --git a/interfaces/inner_api/feature/update/model/event/on_off/event_classify_info.h b/interfaces/inner_api/feature/update/model/event/on_off/event_classify_info.h new file mode 100644 index 0000000000000000000000000000000000000000..5c88b5687bf358deb597379bc179fab6b136e495 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/event/on_off/event_classify_info.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_EVENT_CLASSIFY_INFO_H +#define UPDATE_SERVICE_EVENT_CLASSIFY_INFO_H + +#include + +#include "event_classify.h" + +namespace OHOS::UpdateEngine { +struct EventClassifyInfo { + EventClassify eventClassify = EventClassify::TASK; + std::string extraInfo; + + EventClassifyInfo() : eventClassify(EventClassify::TASK) {} + explicit EventClassifyInfo(EventClassify classify) : eventClassify(classify) {} + EventClassifyInfo(EventClassify classify, const std::string &info) : eventClassify(classify), extraInfo(info) {} +}; +} // OHOS::UpdateEngine +#endif // UPDATE_SERVICE_EVENT_CLASSIFY_INFO_H diff --git a/interfaces/inner_api/feature/update/model/event/src/event_info.cpp b/interfaces/inner_api/feature/update/model/event/src/event_info.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ffea4a75379d7961b55929f25abb49faa8e9c3e2 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/event/src/event_info.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 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. + */ + +#include "event_info.h" +#include "update_define.h" + +namespace OHOS::UpdateEngine { +JsonBuilder EventInfo::GetJsonBuilder() +{ + return JsonBuilder() + .Append("{") + .Append("eventId", CAST_INT(eventId)) + .Append("taskBody", taskBody.GetJsonBuilder(eventId)) + .Append("}"); +} +} // namespace OHOS::UpdateEngine \ No newline at end of file diff --git a/interfaces/inner_api/feature/update/model/event/update_callback_info.h b/interfaces/inner_api/feature/update/model/event/update_callback_info.h new file mode 100644 index 0000000000000000000000000000000000000000..32777c564b010327171c86bac7653e0ea0f0e682 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/event/update_callback_info.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_UPDATE_CALLBACK_INFO_H +#define UPDATE_SERVICE_UPDATE_CALLBACK_INFO_H + +#include "event_info.h" + +namespace OHOS::UpdateEngine { +using OnEvent = std::function; + +// 回调函数 +struct UpdateCallbackInfo { + OnEvent onEvent; +}; +} // OHOS::UpdateEngine +#endif // UPDATE_SERVICE_UPDATE_CALLBACK_INFO_H diff --git a/interfaces/inner_api/feature/update/model/install/install_mode.h b/interfaces/inner_api/feature/update/model/install/install_mode.h new file mode 100644 index 0000000000000000000000000000000000000000..ba0a4c1fa4b20a4aad7689be805a0174ad9a7633 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/install/install_mode.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_INSTALL_MODE_H +#define UPDATE_SERVICE_INSTALL_MODE_H + +namespace OHOS::UpdateEngine { +enum class InstallMode { + NORMAL = 0, + NIGHT, + AUTO +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_INSTALL_MODE_H diff --git a/interfaces/inner_api/include/message_parcel_helper.h b/interfaces/inner_api/feature/update/model/message_parcel/include/message_parcel_helper.h similarity index 89% rename from interfaces/inner_api/include/message_parcel_helper.h rename to interfaces/inner_api/feature/update/model/message_parcel/include/message_parcel_helper.h index 1d1d0da79af737fd0a4e225ca275130af9eff947..0990c551d44780f20444de66f74b4efd2e5430b9 100644 --- a/interfaces/inner_api/include/message_parcel_helper.h +++ b/interfaces/inner_api/feature/update/model/message_parcel/include/message_parcel_helper.h @@ -18,9 +18,24 @@ #include +#include "business_error.h" +#include "check_result.h" +#include "clear_options.h" +#include "current_version_info.h" +#include "description_options.h" +#include "download_options.h" +#include "event_info.h" #include "message_parcel.h" +#include "new_version_info.h" #include "parcel.h" -#include "update_helper.h" +#include "pause_download_options.h" +#include "resume_download_options.h" +#include "task_info.h" +#include "upgrade_info.h" +#include "upgrade_options.h" +#include "upgrade_policy.h" +#include "version_description_info.h" +#include "version_digest_info.h" namespace OHOS::UpdateEngine { class MessageParcelHelper { diff --git a/services/engine/src/message_parcel_helper.cpp b/interfaces/inner_api/feature/update/model/message_parcel/src/message_parcel_helper.cpp similarity index 99% rename from services/engine/src/message_parcel_helper.cpp rename to interfaces/inner_api/feature/update/model/message_parcel/src/message_parcel_helper.cpp index ca27a2a87ba4c9e03861f2e4bd2a83b4f9e935ea..621460596ddb2726ca9904b7e67cbabbbbdb5d50 100644 --- a/services/engine/src/message_parcel_helper.cpp +++ b/interfaces/inner_api/feature/update/model/message_parcel/src/message_parcel_helper.cpp @@ -17,9 +17,9 @@ #include #include +#include #include -#include "update_helper.h" #include "update_log.h" namespace OHOS { diff --git a/interfaces/inner_api/feature/update/model/model.gni b/interfaces/inner_api/feature/update/model/model.gni new file mode 100644 index 0000000000000000000000000000000000000000..2dba0c796537466749e04f3d277397f4644158dd --- /dev/null +++ b/interfaces/inner_api/feature/update/model/model.gni @@ -0,0 +1,45 @@ +# Copyright (c) 2024 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. + +model_external_deps = [] +model_deps = [] +model_include = [ + "../feature/update/model/check", + "../feature/update/model/clear", + "../feature/update/model/common", + "../feature/update/model/download", + "../feature/update/model/event", + "../feature/update/model/event/on_off", + "../feature/update/model/install", + "../feature/update/model/message_parcel/include", + "../feature/update/model/policy", + "../feature/update/model/subscribe", + "../feature/update/model/task", + "../feature/update/model/upgrade", + "../feature/update/model/upgrade_info", + "../feature/update/model/version_info", + "../feature/update/model/version_info/current_version", + "../feature/update/model/version_info/description", + "../feature/update/model/version_info/new_version", +] +model_src = [ + "../feature/update/model/event/src/event_info.cpp", + "../feature/update/model/message_parcel/src/message_parcel_helper.cpp", + "../feature/update/model/subscribe/src/subscribe_info.cpp", + "../feature/update/model/task/src/task_body.cpp", + "../feature/update/model/upgrade_info/src/business_type.cpp", + "../feature/update/model/upgrade_info/src/upgrade_info.cpp", + "../feature/update/model/version_info/description/src/description_info.cpp", + "../feature/update/model/version_info/src/version_component.cpp", + "../feature/update/model/version_info/src/version_digest_info.cpp", +] diff --git a/interfaces/inner_api/feature/update/model/policy/upgrade_period.h b/interfaces/inner_api/feature/update/model/policy/upgrade_period.h new file mode 100644 index 0000000000000000000000000000000000000000..e5dabf256a5a930980a2a00ad443786522cfe170 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/policy/upgrade_period.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_UPGRADE_PERIOD_H +#define UPDATE_SERVICE_UPGRADE_PERIOD_H + +#include + +namespace OHOS::UpdateEngine { +struct UpgradePeriod { + uint32_t start = 0; + uint32_t end = 0; +}; +} // OHOS::UpdateEngine +#endif // UPDATE_SERVICE_UPGRADE_PERIOD_H diff --git a/interfaces/inner_api/feature/update/model/policy/upgrade_policy.h b/interfaces/inner_api/feature/update/model/policy/upgrade_policy.h new file mode 100644 index 0000000000000000000000000000000000000000..97fcf583883ee4dd5e4e5c3c21656c32aa7104b6 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/policy/upgrade_policy.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_UPGRADE_POLICY_H +#define UPDATE_SERVICE_UPGRADE_POLICY_H + +#include "upgrade_period.h" + +namespace OHOS::UpdateEngine { +struct UpgradePolicy { + bool downloadStrategy = false; + bool autoUpgradeStrategy = false; + UpgradePeriod autoUpgradePeriods[2]; +}; +} // OHOS::UpdateEngine +#endif // UPDATE_SERVICE_UPGRADE_POLICY_H diff --git a/interfaces/inner_api/feature/update/model/subscribe/src/subscribe_info.cpp b/interfaces/inner_api/feature/update/model/subscribe/src/subscribe_info.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dc619e5262bf98adbf25633580de43e1db2e3894 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/subscribe/src/subscribe_info.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 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. + */ + +#include "subscribe_info.h" + +namespace OHOS::UpdateEngine { +JsonBuilder SubscribeInfo::GetJsonBuilder() +{ + return JsonBuilder() + .Append("{") + .Append("upgradeApp", upgradeApp) + .Append("businessType", businessType.GetJsonBuilder()) + .Append("abilityName", abilityName) + .Append("subscriberDevId", subscriberDevId) + .Append("upgradeDevId", upgradeDevId) + .Append("deviceType", CAST_INT(deviceType)) + .Append("deviceName", deviceName) + .Append("}"); +} +} // namespace OHOS::UpdateEngine \ No newline at end of file diff --git a/interfaces/inner_api/feature/update/model/subscribe/subscribe_info.h b/interfaces/inner_api/feature/update/model/subscribe/subscribe_info.h new file mode 100644 index 0000000000000000000000000000000000000000..24b1dd035fdbb9a57f47d7ab1211dc089eb4616a --- /dev/null +++ b/interfaces/inner_api/feature/update/model/subscribe/subscribe_info.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_SUBSCRIBE_INFO_H +#define UPDATE_SERVICE_SUBSCRIBE_INFO_H + +#include + +#include "base_json_struct.h" +#include "business_type.h" +#include "update_device_type.h" + +namespace OHOS::UpdateEngine { +const std::string OUC_PACKAGE_NAME = "com.ohos.updateapp"; +const std::string OUC_SERVICE_EXT_ABILITY_NAME = "ServiceExtAbility"; + +struct SubscribeInfo : public BaseJsonStruct { + std::string upgradeApp = OUC_PACKAGE_NAME; + BusinessType businessType = {}; + std::string abilityName; + std::string subscriberDevId; + std::string upgradeDevId; + DeviceType deviceType = DeviceType::UNKNOWN; + std::string deviceName; + + explicit SubscribeInfo(BusinessSubType subType) + { + businessType.subType = subType; + } + + SubscribeInfo() = default; + + JsonBuilder GetJsonBuilder() final; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_SUBSCRIBE_INFO_H diff --git a/services/engine/src/update_helper.cpp b/interfaces/inner_api/feature/update/model/task/src/task_body.cpp similarity index 43% rename from services/engine/src/update_helper.cpp rename to interfaces/inner_api/feature/update/model/task/src/task_body.cpp index 87009b2091b1ad1bc2708e1ddd9de89c74ab8cff..2275c17cccffcab300dea482a5052039b15616ec 100644 --- a/services/engine/src/update_helper.cpp +++ b/interfaces/inner_api/feature/update/model/task/src/task_body.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2024 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 @@ -13,88 +13,11 @@ * limitations under the License. */ -#include "update_helper.h" - -#include -#include - -#include "encrypt_utils.h" +#include "task_body.h" +#include "task_body_member_mask.h" #include "update_log.h" -namespace OHOS { -namespace UpdateEngine { -std::string UpgradeInfo::ToString() const -{ - std::string output = "upgradeApp:" + upgradeApp; - output += ",businessType(vender:" + businessType.vendor; - output += ",subType:" + std::to_string(CAST_INT(businessType.subType)); - output += "),upgradeDevId:" + EncryptUtils::EncryptString(upgradeDevId); - output += ",controlDevId:" + EncryptUtils::EncryptString(controlDevId); - return output; -} - -JsonBuilder BusinessType::GetJsonBuilder() -{ - return JsonBuilder() - .Append("{") - .Append("vendor", vendor) - .Append("subType", CAST_INT(subType)) - .Append("}"); -} - -JsonBuilder VersionDigestInfo::GetJsonBuilder() -{ - return JsonBuilder().Append("{").Append("versionDigest", versionDigest).Append("}"); -} - -JsonBuilder SubscribeInfo::GetJsonBuilder() -{ - return JsonBuilder() - .Append("{") - .Append("upgradeApp", upgradeApp) - .Append("businessType", businessType.GetJsonBuilder()) - .Append("abilityName", abilityName) - .Append("subscriberDevId", subscriberDevId) - .Append("upgradeDevId", upgradeDevId) - .Append("deviceType", CAST_INT(deviceType)) - .Append("deviceName", deviceName) - .Append("}"); -} - -JsonBuilder EventInfo::GetJsonBuilder() -{ - return JsonBuilder() - .Append("{") - .Append("eventId", CAST_INT(eventId)) - .Append("taskBody", taskBody.GetJsonBuilder(eventId)) - .Append("}"); -} - -JsonBuilder DescriptionInfo::GetJsonBuilder() -{ - return JsonBuilder() - .Append("{") - .Append("descriptionType", CAST_INT(descriptionType)) - .Append("content", content) - .Append("}"); -} - -JsonBuilder VersionComponent::GetJsonBuilder() -{ - return JsonBuilder() - .Append("{") - .Append("componentId", componentId) - .Append("componentType", componentType) - .Append("upgradeAction", upgradeAction) - .Append("displayVersion", displayVersion) - .Append("innerVersion", innerVersion) - .Append("size", static_cast(size)) - .Append("effectiveMode", static_cast(effectiveMode)) - .Append("descriptionInfo", descriptionInfo.GetJsonBuilder()) - .Append("componentExtra", componentExtra, true) - .Append("}"); -} - +namespace OHOS::UpdateEngine { JsonBuilder GetJsonBuilder(VersionComponent &versionComponent) { return versionComponent.GetJsonBuilder(); @@ -106,7 +29,7 @@ JsonBuilder GetJsonBuilder(ErrorMessage &errorMessage) } template -std::vector GetArrayJsonBuidlerList(const std::vector &valueList) +std::vector GetArrayJsonBuilderList(const std::vector &valueList) { std::vector jsonBuilderList; for (T value : valueList) { @@ -141,12 +64,11 @@ JsonBuilder TaskBody::GetJsonBuilder(EventId eventId) jsonBuilder.Append("installMode", installMode); } if (taskBodyTemplate & ERROR_MESSAGE) { - jsonBuilder.Append("errorMessages", GetArrayJsonBuidlerList(errorMessages)); + jsonBuilder.Append("errorMessages", GetArrayJsonBuilderList(errorMessages)); } if (taskBodyTemplate & VERSION_COMPONENT) { - jsonBuilder.Append("versionComponents", GetArrayJsonBuidlerList(versionComponents)); + jsonBuilder.Append("versionComponents", GetArrayJsonBuilderList(versionComponents)); } return jsonBuilder.Append("}"); } -} // namespace UpdateEngine -} // namespace OHOS +} // namespace OHOS::UpdateEngine \ No newline at end of file diff --git a/interfaces/inner_api/feature/update/model/task/task_body.h b/interfaces/inner_api/feature/update/model/task/task_body.h new file mode 100644 index 0000000000000000000000000000000000000000..b803013e0111ac85f51db3ed98b060538e94b569 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/task/task_body.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_TASK_BODY_H +#define UPDATE_SERVICE_TASK_BODY_H + +#include "event_id.h" +#include "error_message.h" +#include "install_mode.h" +#include "update_define.h" +#include "upgrade_status.h" +#include "version_digest_info.h" +#include "version_component.h" + +namespace OHOS::UpdateEngine { +struct TaskBody { + VersionDigestInfo versionDigestInfo; + UpgradeStatus status = UpgradeStatus::INIT; + int32_t subStatus = CAST_INT(UpgradeStatus::INIT); + int32_t progress = 0; + int32_t installMode = CAST_INT(InstallMode::NORMAL); + std::vector errorMessages; + std::vector versionComponents; + + JsonBuilder GetJsonBuilder(EventId eventId); +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_TASK_BODY_H diff --git a/interfaces/inner_api/feature/update/model/task/task_body_member_mask.h b/interfaces/inner_api/feature/update/model/task/task_body_member_mask.h new file mode 100644 index 0000000000000000000000000000000000000000..508a02859efdb8530e0eb0d710ee7e8ed4bf582f --- /dev/null +++ b/interfaces/inner_api/feature/update/model/task/task_body_member_mask.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_TASK_BODY_MEMBER_MASK_H +#define UPDATE_SERVICE_TASK_BODY_MEMBER_MASK_H + +#include + +#include "event_id.h" + +namespace OHOS::UpdateEngine { +enum TaskBodyMemberMask { + VERSION_DIGEST_INFO = 0x00000001, + UPGRADE_STATUS = 0x00000010, + SUB_STATUS = 0x00000100, + PROGRESS = 0x00001000, + INSTALL_MODE = 0x00010000, + ERROR_MESSAGE = 0x00100000, + VERSION_COMPONENT = 0x01000000 +}; + +const std::map g_taskBodyTemplateMap = { + { EventId::EVENT_TASK_RECEIVE, VERSION_DIGEST_INFO }, + { EventId::EVENT_TASK_CANCEL, VERSION_DIGEST_INFO }, + { EventId::EVENT_DOWNLOAD_WAIT, VERSION_DIGEST_INFO | UPGRADE_STATUS | INSTALL_MODE }, + { EventId::EVENT_DOWNLOAD_START, VERSION_DIGEST_INFO | INSTALL_MODE }, + { EventId::EVENT_DOWNLOAD_UPDATE, VERSION_DIGEST_INFO | UPGRADE_STATUS | PROGRESS | INSTALL_MODE }, + { EventId::EVENT_DOWNLOAD_PAUSE, VERSION_DIGEST_INFO | UPGRADE_STATUS | PROGRESS | INSTALL_MODE | ERROR_MESSAGE }, + { EventId::EVENT_DOWNLOAD_RESUME, VERSION_DIGEST_INFO | UPGRADE_STATUS | PROGRESS | INSTALL_MODE }, + { EventId::EVENT_DOWNLOAD_SUCCESS, VERSION_DIGEST_INFO | INSTALL_MODE }, + { EventId::EVENT_DOWNLOAD_CANCEL, VERSION_DIGEST_INFO | UPGRADE_STATUS }, + { EventId::EVENT_DOWNLOAD_FAIL, VERSION_DIGEST_INFO | INSTALL_MODE | ERROR_MESSAGE }, + { EventId::EVENT_UPGRADE_WAIT, VERSION_DIGEST_INFO | UPGRADE_STATUS | INSTALL_MODE | ERROR_MESSAGE }, + { EventId::EVENT_UPGRADE_START, VERSION_DIGEST_INFO | UPGRADE_STATUS | INSTALL_MODE }, + { EventId::EVENT_UPGRADE_UPDATE, VERSION_DIGEST_INFO | UPGRADE_STATUS | PROGRESS | INSTALL_MODE }, + { EventId::EVENT_APPLY_WAIT, VERSION_DIGEST_INFO | UPGRADE_STATUS | ERROR_MESSAGE }, + { EventId::EVENT_APPLY_START, VERSION_DIGEST_INFO }, + { EventId::EVENT_UPGRADE_SUCCESS, VERSION_DIGEST_INFO | VERSION_COMPONENT }, + { EventId::EVENT_UPGRADE_FAIL, VERSION_DIGEST_INFO | VERSION_COMPONENT | ERROR_MESSAGE }, + { EventId::EVENT_AUTH_START, VERSION_DIGEST_INFO | VERSION_COMPONENT | UPGRADE_STATUS }, + { EventId::EVENT_AUTH_SUCCESS, VERSION_DIGEST_INFO | VERSION_COMPONENT | UPGRADE_STATUS }, + { EventId::EVENT_INITIALIZE, UPGRADE_STATUS }, +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_TASK_BODY_MEMBER_MASK_H diff --git a/interfaces/inner_api/feature/update/model/task/task_info.h b/interfaces/inner_api/feature/update/model/task/task_info.h new file mode 100644 index 0000000000000000000000000000000000000000..d9651f5d7a0083451c8dfef0e2b0a227dccc1b6b --- /dev/null +++ b/interfaces/inner_api/feature/update/model/task/task_info.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_TASK_INFO_H +#define UPDATE_SERVICE_TASK_INFO_H + +#include "task_body.h" + +namespace OHOS::UpdateEngine { +struct TaskInfo { + bool existTask = false; + TaskBody taskBody; +}; +} // OHOS::UpdateEngine +#endif // UPDATE_SERVICE_TASK_INFO_H diff --git a/interfaces/inner_api/feature/update/model/upgrade/upgrade_interval.h b/interfaces/inner_api/feature/update/model/upgrade/upgrade_interval.h new file mode 100644 index 0000000000000000000000000000000000000000..af12b11d8cfc86f4a2822c9702dc94d81c6bbec7 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/upgrade/upgrade_interval.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_UPGRADE_INTERVAL_H +#define UPDATE_SERVICE_UPGRADE_INTERVAL_H + +#include + +namespace OHOS::UpdateEngine { +struct UpgradeInterval { + uint64_t timeStart = 0; + uint64_t timeEnd = 0; +}; +} // OHOS::UpdateEngine +#endif // UPDATE_SERVICE_UPGRADE_INTERVAL_H diff --git a/interfaces/inner_api/feature/update/model/upgrade/upgrade_options.h b/interfaces/inner_api/feature/update/model/upgrade/upgrade_options.h new file mode 100644 index 0000000000000000000000000000000000000000..c8b9d9a68ea8100b78014d1778d68760959cea74 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/upgrade/upgrade_options.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_UPGRADE_OPTIONS_H +#define UPDATE_SERVICE_UPGRADE_OPTIONS_H + +#include "order.h" + +namespace OHOS::UpdateEngine { +struct UpgradeOptions { + Order order = Order::INSTALL; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_UPGRADE_OPTIONS_H diff --git a/interfaces/inner_api/feature/update/model/upgrade_info/business_sub_type.h b/interfaces/inner_api/feature/update/model/upgrade_info/business_sub_type.h new file mode 100644 index 0000000000000000000000000000000000000000..d37e39296d6b0d54801b8503658b6bd23e125e01 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/upgrade_info/business_sub_type.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_BUSINESS_SUB_TYPE_H +#define UPDATE_SERVICE_BUSINESS_SUB_TYPE_H + +namespace OHOS::UpdateEngine { +enum class BusinessSubType { + START_UP = 0, + FIRMWARE = 1, + PARAM = 2, + ROLLBACK = 3, + ACCESSORY = 4 +}; +} // namespace OHOS::UpdateEngine: +#endif // UPDATE_SERVICE_BUSINESS_SUB_TYPE_H diff --git a/interfaces/inner_api/feature/update/model/upgrade_info/business_type.h b/interfaces/inner_api/feature/update/model/upgrade_info/business_type.h new file mode 100644 index 0000000000000000000000000000000000000000..72ccfc030bf08bd6f17987c5f66b0048056e95f5 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/upgrade_info/business_type.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_BUSINESS_TYPE_H +#define UPDATE_SERVICE_BUSINESS_TYPE_H + +#include + +#include "base_json_struct.h" +#include "business_sub_type.h" +#include "business_vendor.h" +#include "update_define.h" + +namespace OHOS::UpdateEngine { +struct BusinessType : public BaseJsonStruct { + std::string vendor; // BusinessVendor + BusinessSubType subType = BusinessSubType::FIRMWARE; + + bool operator<(const BusinessType &businessType) const + { + if (vendor != businessType.vendor) { + return vendor < businessType.vendor; + } + + if (subType != businessType.subType) { + return CAST_INT(subType) < CAST_INT(businessType.subType); + } + + return false; + } + + bool operator!=(const BusinessType &businessType) const + { + return vendor != businessType.vendor || CAST_INT(subType) != CAST_INT(businessType.subType); + } + + JsonBuilder GetJsonBuilder() final; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_BUSINESS_TYPE_H diff --git a/interfaces/inner_api/feature/update/model/upgrade_info/business_vendor.h b/interfaces/inner_api/feature/update/model/upgrade_info/business_vendor.h new file mode 100644 index 0000000000000000000000000000000000000000..a6732da0c03b7f751fb7a029a66a3eb3e8daa0bc --- /dev/null +++ b/interfaces/inner_api/feature/update/model/upgrade_info/business_vendor.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_BUSINESS_VENDOR_H +#define UPDATE_SERVICE_BUSINESS_VENDOR_H + +namespace OHOS::UpdateEngine { +class BusinessVendor { +public: + static constexpr const char *PUBLIC = "public"; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_BUSINESS_VENDOR_H diff --git a/interfaces/inner_api/feature/update/model/upgrade_info/src/business_type.cpp b/interfaces/inner_api/feature/update/model/upgrade_info/src/business_type.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1cb14a37314d13efacd6f5150962322ded382e12 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/upgrade_info/src/business_type.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 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. + */ + +#include "business_type.h" + +namespace OHOS::UpdateEngine { +JsonBuilder BusinessType::GetJsonBuilder() +{ + return JsonBuilder() + .Append("{") + .Append("vendor", vendor) + .Append("subType", CAST_INT(subType)) + .Append("}"); +} +} // namespace OHOS::UpdateEngine \ No newline at end of file diff --git a/interfaces/inner_api/feature/update/model/upgrade_info/src/upgrade_info.cpp b/interfaces/inner_api/feature/update/model/upgrade_info/src/upgrade_info.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d088c888587f8e718522b27f65b6da5422c3969f --- /dev/null +++ b/interfaces/inner_api/feature/update/model/upgrade_info/src/upgrade_info.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 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. + */ + +#include "anonymous_utils.h" +#include "upgrade_info.h" +#include "update_define.h" + +namespace OHOS::UpdateEngine { +std::string UpgradeInfo::ToString() const +{ + std::string output = "upgradeApp:" + upgradeApp; + output += ",businessType(vender:" + businessType.vendor; + output += ",subType:" + std::to_string(CAST_INT(businessType.subType)); + output += "),upgradeDevId:" + AnonymousUtils::AnonymousString(upgradeDevId); + output += ",controlDevId:" + AnonymousUtils::AnonymousString(controlDevId); + return output; +} +} // namespace OHOS::UpdateEngine \ No newline at end of file diff --git a/interfaces/inner_api/feature/update/model/upgrade_info/upgrade_info.h b/interfaces/inner_api/feature/update/model/upgrade_info/upgrade_info.h new file mode 100644 index 0000000000000000000000000000000000000000..c604c500e588d35fd216033495dabc95dae87db1 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/upgrade_info/upgrade_info.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_UPGRADE_INFO_H +#define UPDATE_SERVICE_UPGRADE_INFO_H + +#include + +#include "business_type.h" +#include "update_device_type.h" + +namespace OHOS::UpdateEngine { +const std::string LOCAL_UPGRADE_INFO = "LocalUpgradeInfo"; +struct UpgradeInfo { + std::string upgradeApp; + BusinessType businessType = {}; + std::string upgradeDevId; + std::string controlDevId; + int32_t processId; + DeviceType deviceType = DeviceType::UNKNOWN; + + bool operator<(const UpgradeInfo &other) const + { + if (upgradeApp != other.upgradeApp) { + return upgradeApp < other.upgradeApp; + } + + if (businessType != other.businessType) { + return businessType < other.businessType; + } + + if (upgradeDevId != other.upgradeDevId) { + return upgradeDevId < other.upgradeDevId; + } + + if (controlDevId != other.controlDevId) { + return controlDevId < other.controlDevId; + } + + if (processId != other.processId) { + return processId < other.processId; + } + + if (deviceType != other.deviceType) { + return deviceType < other.deviceType; + } + + return false; + } + + std::string ToString() const; + + bool IsLocal() const + { + return upgradeApp == LOCAL_UPGRADE_INFO; + } +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_UPGRADE_INFO_H diff --git a/interfaces/inner_api/feature/update/model/version_info/component_type.h b/interfaces/inner_api/feature/update/model/version_info/component_type.h new file mode 100644 index 0000000000000000000000000000000000000000..55538de9533cd20233a00c790b0de07a7221330b --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/component_type.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_COMPONENT_TYPE_H +#define UPDATE_SERVICE_COMPONENT_TYPE_H + +namespace OHOS::UpdateEngine { +enum class ComponentType { + INVALID = 0, + OTA = 1, + PATCH = 2, + COTA = 4, + PARAM = 8, + SA = 16 +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_COMPONENT_TYPE_H diff --git a/interfaces/inner_api/feature/update/model/version_info/current_version/current_version_info.h b/interfaces/inner_api/feature/update/model/version_info/current_version/current_version_info.h new file mode 100644 index 0000000000000000000000000000000000000000..d6645118e68c3c535a2b96ee0ef3437fc8c4f05d --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/current_version/current_version_info.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_CURRENT_VERSION_INFO_H +#define UPDATE_SERVICE_CURRENT_VERSION_INFO_H + +#include +#include + +#include "version_component.h" + +namespace OHOS::UpdateEngine { +struct CurrentVersionInfo { + std::string osVersion; + std::string deviceName; + std::vector versionComponents; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_CURRENT_VERSION_INFO_H diff --git a/interfaces/inner_api/feature/update/model/version_info/description/component_description.h b/interfaces/inner_api/feature/update/model/version_info/description/component_description.h new file mode 100644 index 0000000000000000000000000000000000000000..8ed99c97f04f543ec1699a665dfa6cb36b5e4f1c --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/description/component_description.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_COMPONENT_DESCRIPTION_H +#define UPDATE_SERVICE_COMPONENT_DESCRIPTION_H + +#include + +#include "description_info.h" + +namespace OHOS::UpdateEngine { +struct ComponentDescription { + std::string componentId; + DescriptionInfo descriptionInfo; + DescriptionInfo notifyDescriptionInfo; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_COMPONENT_DESCRIPTION_H diff --git a/interfaces/inner_api/feature/update/model/version_info/description/description_format.h b/interfaces/inner_api/feature/update/model/version_info/description/description_format.h new file mode 100644 index 0000000000000000000000000000000000000000..0d266d756309925a92b334df5ad3232a795435cf --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/description/description_format.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_DESCRIPTION_FORMAT_H +#define UPDATE_SERVICE_DESCRIPTION_FORMAT_H + +namespace OHOS::UpdateEngine { +enum class DescriptionFormat { + STANDARD = 0, + SIMPLIFIED = 1 +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_DESCRIPTION_FORMAT_H diff --git a/interfaces/inner_api/feature/update/model/version_info/description/description_info.h b/interfaces/inner_api/feature/update/model/version_info/description/description_info.h new file mode 100644 index 0000000000000000000000000000000000000000..a3cf3267f68de8d86ee3be58bcf04a4b24a56db6 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/description/description_info.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_DESCRIPTION_INFO_H +#define UPDATE_SERVICE_DESCRIPTION_INFO_H + +#include "base_json_struct.h" +#include "description_type.h" + +namespace OHOS::UpdateEngine { +struct DescriptionInfo : public BaseJsonStruct { + DescriptionType descriptionType = DescriptionType::CONTENT; + std::string content; + + JsonBuilder GetJsonBuilder() final; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_DESCRIPTION_INFO_H diff --git a/interfaces/inner_api/feature/update/model/version_info/description/description_options.h b/interfaces/inner_api/feature/update/model/version_info/description/description_options.h new file mode 100644 index 0000000000000000000000000000000000000000..192bf1d0da18bfadbd757909c1579157b4e78de9 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/description/description_options.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_DESCRIPTION_OPTIONS_H +#define UPDATE_SERVICE_DESCRIPTION_OPTIONS_H + +#include + +#include "description_format.h" + +namespace OHOS::UpdateEngine { +struct DescriptionOptions { + DescriptionFormat format = DescriptionFormat::STANDARD; + std::string language; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_DESCRIPTION_OPTIONS_H diff --git a/interfaces/inner_api/feature/update/model/version_info/description/description_type.h b/interfaces/inner_api/feature/update/model/version_info/description/description_type.h new file mode 100644 index 0000000000000000000000000000000000000000..e717f1bff44b9c9ddf6f5c4534d7f2b144cfa9da --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/description/description_type.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_DESCRIPTION_TYPE_H +#define UPDATE_SERVICE_DESCRIPTION_TYPE_H + +namespace OHOS::UpdateEngine { +enum class DescriptionType { + CONTENT = 0, + URI = 1, + ID = 2 +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_DESCRIPTION_TYPE_H diff --git a/interfaces/inner_api/feature/update/model/version_info/description/src/description_info.cpp b/interfaces/inner_api/feature/update/model/version_info/description/src/description_info.cpp new file mode 100644 index 0000000000000000000000000000000000000000..27e74c93dee5e4d124769bf036f16dff6124cb5f --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/description/src/description_info.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 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. + */ + +#include "description_info.h" +#include "update_define.h" + +namespace OHOS::UpdateEngine { +JsonBuilder DescriptionInfo::GetJsonBuilder() +{ + return JsonBuilder() + .Append("{") + .Append("descriptionType", CAST_INT(descriptionType)) + .Append("content", content) + .Append("}"); +} +} // namespace OHOS::UpdateEngine \ No newline at end of file diff --git a/interfaces/inner_api/feature/update/model/version_info/description/version_description_info.h b/interfaces/inner_api/feature/update/model/version_info/description/version_description_info.h new file mode 100644 index 0000000000000000000000000000000000000000..83fa61b583cc0ee5deed0b1df0df6b0e3cb7eef7 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/description/version_description_info.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_VERSION_DESCRIPTION_INFO_H +#define UPDATE_SERVICE_VERSION_DESCRIPTION_INFO_H + +#include + +#include "component_description.h" + +namespace OHOS::UpdateEngine { +struct VersionDescriptionInfo { + std::vector componentDescriptions; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_VERSION_DESCRIPTION_INFO_H diff --git a/interfaces/inner_api/feature/update/model/version_info/effective_mode.h b/interfaces/inner_api/feature/update/model/version_info/effective_mode.h new file mode 100644 index 0000000000000000000000000000000000000000..ecf221ea41fe2b714f118801e4c7b25e70ccc359 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/effective_mode.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_EFFECTIVE_MODE_H +#define UPDATE_SERVICE_EFFECTIVE_MODE_H + +namespace OHOS::UpdateEngine { +enum class EffectiveMode { + COLD = 1, + LIVE = 2, + LIVE_AND_COLD = 3 +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_EFFECTIVE_MODE_H diff --git a/interfaces/inner_api/feature/update/model/version_info/new_version/new_version_info.h b/interfaces/inner_api/feature/update/model/version_info/new_version/new_version_info.h new file mode 100644 index 0000000000000000000000000000000000000000..6578830fca47621e4e6a4873c17d06151d5a418a --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/new_version/new_version_info.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_NEW_VERSION_INFO_H +#define UPDATE_SERVICE_NEW_VERSION_INFO_H + +#include + +#include "version_component.h" +#include "version_digest_info.h" + +namespace OHOS::UpdateEngine { +struct NewVersionInfo { + VersionDigestInfo versionDigestInfo; + std::vector versionComponents; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_NEW_VERSION_INFO_H diff --git a/interfaces/inner_api/feature/update/model/version_info/src/version_component.cpp b/interfaces/inner_api/feature/update/model/version_info/src/version_component.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7a11eff8c3f55e05dfcd9d552edb4308f5e1b236 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/src/version_component.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 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. + */ + +#include "version_component.h" + +namespace OHOS::UpdateEngine { +JsonBuilder VersionComponent::GetJsonBuilder() +{ + return JsonBuilder() + .Append("{") + .Append("componentId", componentId) + .Append("componentType", componentType) + .Append("upgradeAction", upgradeAction) + .Append("displayVersion", displayVersion) + .Append("innerVersion", innerVersion) + .Append("size", static_cast(size)) + .Append("effectiveMode", static_cast(effectiveMode)) + .Append("descriptionInfo", descriptionInfo.GetJsonBuilder()) + .Append("componentExtra", componentExtra, true) + .Append("}"); +} +} // namespace OHOS::UpdateEngine \ No newline at end of file diff --git a/interfaces/inner_api/feature/update/model/version_info/src/version_digest_info.cpp b/interfaces/inner_api/feature/update/model/version_info/src/version_digest_info.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e3c1217e6deec2d4a0387f9928b4b5388c5f5cd1 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/src/version_digest_info.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 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. + */ + +#include "version_digest_info.h" + +namespace OHOS::UpdateEngine { +JsonBuilder VersionDigestInfo::GetJsonBuilder() +{ + return JsonBuilder() + .Append("{") + .Append("versionDigest", versionDigest) + .Append("}"); +} +} // namespace OHOS::UpdateEngine \ No newline at end of file diff --git a/interfaces/inner_api/feature/update/model/version_info/upgrade_action.h b/interfaces/inner_api/feature/update/model/version_info/upgrade_action.h new file mode 100644 index 0000000000000000000000000000000000000000..2b7b8b15943308e5d8ce6bbe2fdee6fc84c74952 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/upgrade_action.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_UPGRADE_ACTION_H +#define UPDATE_SERVICE_UPGRADE_ACTION_H + +namespace OHOS::UpdateEngine { +class UpgradeAction { +public: + static constexpr const char *UPGRADE = "upgrade"; + static constexpr const char *RECOVERY = "recovery"; + static constexpr const char *ROLLBACK = "rollback"; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_UPGRADE_ACTION_H diff --git a/interfaces/inner_api/feature/update/model/version_info/version_component.h b/interfaces/inner_api/feature/update/model/version_info/version_component.h new file mode 100644 index 0000000000000000000000000000000000000000..12be40dad0755093fbe3370abce9252bc73a4473 --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/version_component.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_VERSION_COMPONENT_H +#define UPDATE_SERVICE_VERSION_COMPONENT_H + +#include +#include + +#include "base_json_struct.h" +#include "component_type.h" +#include "description_info.h" +#include "effective_mode.h" +#include "update_define.h" +#include "upgrade_action.h" + +namespace OHOS::UpdateEngine { +struct VersionComponent : public BaseJsonStruct { + std::string componentId; + int32_t componentType = CAST_INT(ComponentType::INVALID); + std::string upgradeAction; + std::string displayVersion; + std::string innerVersion; + size_t size = 0; + size_t effectiveMode = static_cast(EffectiveMode::COLD); + DescriptionInfo descriptionInfo; + std::string componentExtra; + + JsonBuilder GetJsonBuilder() final; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_VERSION_COMPONENT_H diff --git a/interfaces/inner_api/feature/update/model/version_info/version_digest_info.h b/interfaces/inner_api/feature/update/model/version_info/version_digest_info.h new file mode 100644 index 0000000000000000000000000000000000000000..188c9ca7e2c3d39cdfd3c755403b3d90f565511f --- /dev/null +++ b/interfaces/inner_api/feature/update/model/version_info/version_digest_info.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_VERSION_DIGEST_INFO_H +#define UPDATE_SERVICE_VERSION_DIGEST_INFO_H + +#include + +#include "base_json_struct.h" + +namespace OHOS::UpdateEngine { +struct VersionDigestInfo : public BaseJsonStruct { + std::string versionDigest; + + JsonBuilder GetJsonBuilder() final; +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_VERSION_DIGEST_INFO_H diff --git a/interfaces/inner_api/include/update_helper.h b/interfaces/inner_api/include/update_helper.h deleted file mode 100644 index ef5949b6909ed082d47377bf3fa838d840710b7d..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/include/update_helper.h +++ /dev/null @@ -1,522 +0,0 @@ -/* - * Copyright (c) 2023 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 UPDATE_HELPER_H -#define UPDATE_HELPER_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nlohmann/json.hpp" - -#include "common_error_define.h" -#include "json_builder.h" -#include "net_manager_model.h" -#include "update_define.h" - -namespace OHOS::UpdateEngine { -const std::string OUC_PACKAGE_NAME = "com.ohos.updateapp"; -const std::string OUC_SERVICE_EXT_ABILITY_NAME = "ServiceExtAbility"; - -// 搜索状态 -enum class SearchStatus { - NET_ERROR = -2, - SYSTEM_ERROR, - HAS_NEW_VERSION, - NO_NEW_VERSION, - SERVER_BUSY, - CHECK_EXECUTE_ERR -}; - -enum class UpgradeStatus { - INIT = 0, - CHECKING_VERSION = 10, - CHECK_VERSION_FAIL, - CHECK_VERSION_SUCCESS, - DOWNLOADING = 20, - DOWNLOAD_PAUSE, - DOWNLOAD_CANCEL, - DOWNLOAD_FAIL, - DOWNLOAD_SUCCESS, - VERIFYING = 30, - VERIFY_FAIL, - VERIFY_SUCCESS, - AUTHING, - AUTH_FAIL, - AUTH_SUCCESS, - PACKAGE_TRANSING = 70, - PACKAGE_TRANS_FAIL, - PACKAGE_TRANS_SUCCESS, - INSTALLING = 80, - INSTALL_FAIL, - INSTALL_SUCCESS, - UPDATING = 90, - UPDATE_FAIL, - UPDATE_SUCCESS -}; - -enum class PackageType { - DYNAMIC = 0, - NORMAL = 1, - BASE = 2, - CUST = 3, - PRELOAD = 4, - COTA = 5, - VERSION = 6, - PATCH = 8, - SA = 9 -}; - -enum class ComponentType { - INVALID = 0, - OTA = 1, - PATCH = 2, - COTA = 4, - PARAM = 8, - SA = 16 -}; - -enum class EffectiveMode { - COLD = 1, - LIVE = 2, - LIVE_AND_COLD = 3 -}; - -enum class Order { - DOWNLOAD = 1, - INSTALL = 2, - DOWNLOAD_AND_INSTALL = DOWNLOAD | INSTALL, - APPLY = 4, - INSTALL_AND_APPLY = INSTALL | APPLY -}; - -enum class OptionsAfterUpgrade { - NORMAL = 0, - REBOOT = 1, - SHUTDOWN = 2 -}; - -enum class BusinessSubType { - START_UP = 0, - FIRMWARE = 1, - PARAM = 2, - ROLLBACK = 3, - ACCESSORY = 4 -}; - -enum class DescriptionType { - CONTENT = 0, - URI = 1, - ID = 2 -}; - -enum class DescriptionFormat { - STANDARD = 0, - SIMPLIFIED = 1 -}; - -enum ForceUpgradeSwitch { - OPEN = 0x01000000, - CLOSE = 0x00000000, -}; - -enum ForceUpgradeDataNetworkOption { - CELLULAR_NOT_SUPPORT = 0x00000000, - CELLULAR = 0x00000001, - ROAMING = 0x00000002, - CELLULAR_AND_ROAMING = CELLULAR | ROAMING, -}; - -enum class ForceUpgradeType { - NOT_SUPPORT = ForceUpgradeSwitch::CLOSE, - CELLULAR_NOT_SUPPORT = ForceUpgradeSwitch::OPEN | ForceUpgradeDataNetworkOption::CELLULAR_NOT_SUPPORT, - CELLULAR = ForceUpgradeSwitch::OPEN | ForceUpgradeDataNetworkOption::CELLULAR, - CELLULAR_AND_ROAMING = ForceUpgradeSwitch::OPEN | ForceUpgradeDataNetworkOption::CELLULAR_AND_ROAMING, -}; - -enum class EventClassify { - TASK = 0x01000000, - SYSTEM = 0x02000000, -}; - -const std::list g_eventClassifyList = { EventClassify::TASK, EventClassify::SYSTEM }; - -enum class EventId { - EVENT_TASK_BASE = CAST_UINT(EventClassify::TASK), - EVENT_TASK_RECEIVE, - EVENT_TASK_CANCEL, - EVENT_DOWNLOAD_WAIT, - EVENT_DOWNLOAD_START, - EVENT_DOWNLOAD_UPDATE, - EVENT_DOWNLOAD_PAUSE, - EVENT_DOWNLOAD_RESUME, - EVENT_DOWNLOAD_SUCCESS, - EVENT_DOWNLOAD_FAIL, - EVENT_UPGRADE_WAIT, - EVENT_UPGRADE_START, - EVENT_UPGRADE_UPDATE, - EVENT_APPLY_WAIT, - EVENT_APPLY_START, - EVENT_UPGRADE_SUCCESS, - EVENT_UPGRADE_FAIL, - EVENT_AUTH_START, - EVENT_AUTH_SUCCESS, - EVENT_DOWNLOAD_CANCEL, - EVENT_INITIALIZE, - EVENT_TASK_CHANGE, - EVENT_VERSION_INFO_CHANGE, - SYSTEM_BASE = CAST_UINT(EventClassify::SYSTEM), - SYSTEM_BOOT_COMPLETE, -}; - -enum TaskBodyMemeberMask { - VERSION_DIGEST_INFO = 0x00000001, - UPGRADE_STATUS = 0x00000010, - SUB_STATUS = 0x00000100, - PROGRESS = 0x00001000, - INSTALL_MODE = 0x00010000, - ERROR_MESSAGE = 0x00100000, - VERSION_COMPONENT = 0x01000000 -}; - -const std::map g_taskBodyTemplateMap = { - { EventId::EVENT_TASK_RECEIVE, VERSION_DIGEST_INFO }, - { EventId::EVENT_TASK_CHANGE, VERSION_DIGEST_INFO | UPGRADE_STATUS | PROGRESS }, - { EventId::EVENT_TASK_CANCEL, VERSION_DIGEST_INFO }, - { EventId::EVENT_VERSION_INFO_CHANGE, VERSION_DIGEST_INFO | UPGRADE_STATUS }, - { EventId::EVENT_DOWNLOAD_WAIT, VERSION_DIGEST_INFO | UPGRADE_STATUS | INSTALL_MODE }, - { EventId::EVENT_DOWNLOAD_START, VERSION_DIGEST_INFO | INSTALL_MODE }, - { EventId::EVENT_DOWNLOAD_UPDATE, VERSION_DIGEST_INFO | UPGRADE_STATUS | PROGRESS | INSTALL_MODE }, - { EventId::EVENT_DOWNLOAD_PAUSE, VERSION_DIGEST_INFO | UPGRADE_STATUS | PROGRESS | INSTALL_MODE | ERROR_MESSAGE }, - { EventId::EVENT_DOWNLOAD_RESUME, VERSION_DIGEST_INFO | UPGRADE_STATUS | PROGRESS | INSTALL_MODE }, - { EventId::EVENT_DOWNLOAD_SUCCESS, VERSION_DIGEST_INFO | INSTALL_MODE }, - { EventId::EVENT_DOWNLOAD_CANCEL, VERSION_DIGEST_INFO | UPGRADE_STATUS }, - { EventId::EVENT_DOWNLOAD_FAIL, VERSION_DIGEST_INFO | INSTALL_MODE | ERROR_MESSAGE }, - { EventId::EVENT_UPGRADE_WAIT, VERSION_DIGEST_INFO | UPGRADE_STATUS | INSTALL_MODE | ERROR_MESSAGE }, - { EventId::EVENT_UPGRADE_START, VERSION_DIGEST_INFO | UPGRADE_STATUS | INSTALL_MODE }, - { EventId::EVENT_UPGRADE_UPDATE, VERSION_DIGEST_INFO | UPGRADE_STATUS | PROGRESS | INSTALL_MODE }, - { EventId::EVENT_APPLY_WAIT, VERSION_DIGEST_INFO | UPGRADE_STATUS | ERROR_MESSAGE }, - { EventId::EVENT_APPLY_START, VERSION_DIGEST_INFO }, - { EventId::EVENT_UPGRADE_SUCCESS, VERSION_DIGEST_INFO | VERSION_COMPONENT }, - { EventId::EVENT_UPGRADE_FAIL, VERSION_DIGEST_INFO | VERSION_COMPONENT | ERROR_MESSAGE }, - { EventId::EVENT_AUTH_START, VERSION_DIGEST_INFO | VERSION_COMPONENT | UPGRADE_STATUS }, - { EventId::EVENT_AUTH_SUCCESS, VERSION_DIGEST_INFO | VERSION_COMPONENT | UPGRADE_STATUS }, - { EventId::EVENT_INITIALIZE, UPGRADE_STATUS }, - { EventId::SYSTEM_BOOT_COMPLETE, UPGRADE_STATUS } -}; - -class UpgradeAction { -public: - static constexpr const char *UPGRADE = "upgrade"; - static constexpr const char *RECOVERY = "recovery"; - static constexpr const char *ROLLBACK = "rollback"; -}; - -class BusinessVendor { -public: - static constexpr const char *PUBLIC = "public"; -}; - -struct BaseJsonStruct { - virtual ~BaseJsonStruct() {} - virtual JsonBuilder GetJsonBuilder() = 0; - - virtual std::string ToJson() - { - return GetJsonBuilder().ToJson(); - }; -}; - -enum class DeviceType { - UNKNOWN = 0, - SMART_PHONE = 1, // 手机 - SMART_PAD = 2, // 平板 - SMART_TV = 4, // 智能电视 - TWS = 6, // 真无线耳机 - KEYBOARD = 7, // 键盘 - PEN = 8 // 手写笔 -}; - -struct BusinessType : public BaseJsonStruct { - std::string vendor; // BusinessVendor - BusinessSubType subType = BusinessSubType::FIRMWARE; - - bool operator<(const BusinessType &businessType) const - { - if (vendor < businessType.vendor) return true; - if (vendor > businessType.vendor) return false; - - if (CAST_INT(subType) < CAST_INT(businessType.subType)) return true; - if (CAST_INT(subType) > CAST_INT(businessType.subType)) return false; - - return false; - } - - JsonBuilder GetJsonBuilder() final; -}; - -const std::string LOCAL_UPGRADE_INFO = "LocalUpgradeInfo"; -struct UpgradeInfo { - std::string upgradeApp; - BusinessType businessType; - std::string upgradeDevId; - std::string controlDevId; - int32_t processId; - DeviceType deviceType; - - bool operator<(const UpgradeInfo &r) const - { - if (upgradeApp < r.upgradeApp) return true; - if (upgradeApp > r.upgradeApp) return false; - - if (businessType < r.businessType) return true; - if (r.businessType < businessType) return false; - - if (upgradeDevId < r.upgradeDevId) return true; - if (upgradeDevId > r.upgradeDevId) return false; - - if (controlDevId < r.controlDevId) return true; - if (controlDevId > r.controlDevId) return false; - - if (processId < r.processId) return true; - if (processId > r.processId) return false; - - if (deviceType < r.deviceType) return true; - if (deviceType > r.deviceType) return false; - - return false; - } - - std::string ToString() const; - - bool IsLocal() const - { - return upgradeApp == LOCAL_UPGRADE_INFO; - } -}; - -struct SubscribeInfo : public BaseJsonStruct { - std::string upgradeApp = OUC_PACKAGE_NAME; - BusinessType businessType; - std::string abilityName; - std::string subscriberDevId; - std::string upgradeDevId; - DeviceType deviceType = DeviceType::UNKNOWN; - std::string deviceName; - - explicit SubscribeInfo(BusinessSubType subType) - { - businessType.subType = subType; - } - SubscribeInfo() = default; - - JsonBuilder GetJsonBuilder() final; -}; - -struct VersionDigestInfo : public BaseJsonStruct { - std::string versionDigest; - - JsonBuilder GetJsonBuilder() final; -}; - -struct DescriptionOptions { - DescriptionFormat format = DescriptionFormat::STANDARD; - std::string language; -}; - -struct DownloadOptions { - NetType allowNetwork = NetType::WIFI; - Order order = Order::DOWNLOAD; -}; - -struct ResumeDownloadOptions { - NetType allowNetwork = NetType::WIFI; -}; - -struct PauseDownloadOptions { - bool isAllowAutoResume = false; -}; - -struct UpgradeOptions { - Order order = Order::INSTALL; - OptionsAfterUpgrade optionsAfterUpgrade = OptionsAfterUpgrade::NORMAL; -}; - -struct ClearOptions { - UpgradeStatus status = UpgradeStatus::INIT; -}; - -enum class InstallMode { - NORMAL = 0, - NIGHT, - AUTO -}; - -enum class AutoUpgradeCondition { - IDLE = 0, -}; - -struct DescriptionInfo : public BaseJsonStruct { - DescriptionType descriptionType = DescriptionType::CONTENT; - std::string content; - - JsonBuilder GetJsonBuilder() final; -}; - -struct ComponentDescription { - std::string componentId; - DescriptionInfo descriptionInfo; - DescriptionInfo notifyDescriptionInfo; -}; - -struct VersionComponent : public BaseJsonStruct { - std::string componentId; - int32_t componentType = CAST_INT(ComponentType::INVALID); - std::string upgradeAction; - std::string displayVersion; - std::string innerVersion; - size_t size = 0; - size_t effectiveMode = static_cast(EffectiveMode::COLD); - DescriptionInfo descriptionInfo; - std::string componentExtra; - - JsonBuilder GetJsonBuilder() final; -}; - -struct CurrentVersionInfo { - std::string osVersion; - std::string deviceName; - std::vector versionComponents; -}; - -struct NewVersionInfo { - VersionDigestInfo versionDigestInfo; - std::vector versionComponents; -}; - -struct VersionDescriptionInfo { - std::vector componentDescriptions; -}; - -struct CheckResult { - bool isExistNewVersion = false; - NewVersionInfo newVersionInfo; -}; - -struct TaskBody { - VersionDigestInfo versionDigestInfo; - UpgradeStatus status = UpgradeStatus::INIT; - int32_t subStatus = CAST_INT(UpgradeStatus::INIT); - int32_t progress = 0; - int32_t installMode = CAST_INT(InstallMode::NORMAL); - std::vector errorMessages; - std::vector versionComponents; - - JsonBuilder GetJsonBuilder(EventId eventId); -}; - -struct TaskInfo { - bool existTask; - TaskBody taskBody; -}; - -struct Progress { - uint32_t percent = 0; - UpgradeStatus status = UpgradeStatus::INIT; - std::string endReason; -}; - -struct UpgradeInterval { - uint64_t timeStart = 0; - uint64_t timeEnd = 0; -}; - -struct UpgradePeriod { - uint32_t start = 0; - uint32_t end = 0; -}; - -struct UpdateTime { - int64_t lastUpdateTime = 0; - int64_t installWindowStart = 0; - int64_t installWindowEnd = 0; - - friend void to_json(nlohmann::json &jsonObj, const UpdateTime &updateTime) - { - jsonObj["lastUpdateTime"] = updateTime.lastUpdateTime; - jsonObj["installWindowStart"] = updateTime.installWindowStart; - jsonObj["installWindowEnd"] = updateTime.installWindowEnd; - } - - friend void from_json(const nlohmann::json &jsonObj, UpdateTime &updateTime) - { - JsonUtils::GetValueAndSetTo(jsonObj, "lastUpdateTime", updateTime.lastUpdateTime); - JsonUtils::GetValueAndSetTo(jsonObj, "installWindowStart", updateTime.installWindowStart); - JsonUtils::GetValueAndSetTo(jsonObj, "installWindowEnd", updateTime.installWindowEnd); - } -}; - -struct UpgradePolicy { - bool downloadStrategy = false; - bool autoUpgradeStrategy = false; - UpgradePeriod autoUpgradePeriods[2]; -}; - -struct UpgradeFile { - ComponentType fileType = ComponentType::INVALID; - std::string filePath; -}; - -struct EventClassifyInfo { - EventClassify eventClassify = EventClassify::TASK; - std::string extraInfo; - - EventClassifyInfo() : eventClassify(EventClassify::TASK) {} - explicit EventClassifyInfo(EventClassify classify) : eventClassify(classify) {} - EventClassifyInfo(EventClassify classify, const std::string &info) : eventClassify(classify), extraInfo(info) {} -}; - -struct EventInfo : public BaseJsonStruct { - EventId eventId = EventId::EVENT_TASK_BASE; - TaskBody taskBody; - - EventInfo() = default; - EventInfo(EventId id, TaskBody body) : eventId(id), taskBody(std::move(body)) {} - - JsonBuilder GetJsonBuilder() final; -}; - -struct ConfigInfo { - std::string businessDomain; - uint32_t abInstallTimeout = 1800; // 1800s - std::string moduleLibPath; -}; - -using OnEvent = std::function; - -// 回调函数 -struct UpdateCallbackInfo { - OnEvent onEvent; -}; -} // namespace OHOS::UpdateEngine -#endif // UPDATE_HELPER_H diff --git a/interfaces/inner_api/include/update_service_kits.h b/interfaces/inner_api/include/update_service_kits.h index ed547e3777d248148d488788484fd161adc9da0b..f3c8122ae019fe050be4938687e0f8fb77e5f148 100644 --- a/interfaces/inner_api/include/update_service_kits.h +++ b/interfaces/inner_api/include/update_service_kits.h @@ -17,8 +17,24 @@ #define UPDATE_SERVICE_KITS_H #include -#include "iupdate_service.h" -#include "update_helper.h" + +#include "business_error.h" +#include "check_result.h" +#include "clear_options.h" +#include "current_version_info.h" +#include "description_options.h" +#include "download_options.h" +#include "iupdate_callback.h" +#include "pause_download_options.h" +#include "resume_download_options.h" +#include "new_version_info.h" +#include "update_callback_info.h" +#include "upgrade_info.h" +#include "upgrade_options.h" +#include "upgrade_policy.h" +#include "task_info.h" +#include "version_description_info.h" +#include "version_digest_info.h" namespace OHOS::UpdateEngine { class UpdateServiceKits { diff --git a/interfaces/inner_api/modulemgr/BUILD.gn b/interfaces/inner_api/modulemgr/BUILD.gn index 4f3cfcc072235ea036e8c9d7c083128dd2c6dbd6..4bacef5ee003745bd5e5dbf48dd880ab0a647a62 100644 --- a/interfaces/inner_api/modulemgr/BUILD.gn +++ b/interfaces/inner_api/modulemgr/BUILD.gn @@ -34,6 +34,6 @@ ohos_shared_library("update_module_mgr") { part_name = "$updateengine_part_name" subsystem_name = "updater" cflags = modulemgr_cflags - + innerapi_tags = [ "sasdk" ] public_configs = [ ":module_mgr_library_native_config" ] } diff --git a/interfaces/inner_api/modulemgr/src/module_manager.cpp b/interfaces/inner_api/modulemgr/src/module_manager.cpp index 5edaf939a75753c325809dd7e5eaa5232cd798e8..8436004a3da6790b63f0d61d342d88f499111ebe 100644 --- a/interfaces/inner_api/modulemgr/src/module_manager.cpp +++ b/interfaces/inner_api/modulemgr/src/module_manager.cpp @@ -31,11 +31,13 @@ bool ModuleManager::isLoaded = false; void ModuleManager::LoadModule(std::string libPath) { std::string prefix = "/system/lib64/updateext"; + std::string modulePrefix = "/module_update/3006/lib64/updateext"; std::string suffix = ".so"; - if ((libPath.substr(0, prefix.length()) != prefix) || - (libPath.substr(libPath.length() - suffix.length(), suffix.length()) != suffix)) { - UTILS_LOGE("LoadModule lib path invalid"); - return; + if ((libPath.substr(0, prefix.length()) != prefix && + libPath.substr(0, modulePrefix.length()) != modulePrefix) || + (libPath.substr(libPath.length() - suffix.length(), suffix.length()) != suffix)) { + UTILS_LOGE("LoadModule lib path invalid"); + return; } UTILS_LOGD("LoadModule so path: %{public}s", libPath.c_str()); if (dueModuleHandler == nullptr) { diff --git a/services/callback/include/update_callback_proxy.h b/services/callback/include/update_callback_proxy.h index 42ec59166216c04760d38906d6a18c1aa0801bd5..a0d99c0ebf18445e1b1115c088eef7142e981b04 100644 --- a/services/callback/include/update_callback_proxy.h +++ b/services/callback/include/update_callback_proxy.h @@ -18,8 +18,9 @@ #include "iremote_broker.h" #include "iremote_proxy.h" + +#include "event_info.h" #include "iupdate_callback.h" -#include "update_helper.h" namespace OHOS::UpdateEngine { class UpdateCallbackProxy : public IRemoteProxy { diff --git a/services/callback/src/update_callback_proxy.cpp b/services/callback/src/update_callback_proxy.cpp index a79a0515d02f5d2cef0fa0fc1937566e9fc6eac5..3ab9fa966a998521022336d72ee917136b3261de 100644 --- a/services/callback/src/update_callback_proxy.cpp +++ b/services/callback/src/update_callback_proxy.cpp @@ -15,8 +15,8 @@ #include "update_callback_proxy.h" +#include "event_info.h" #include "message_parcel_helper.h" -#include "update_helper.h" #include "update_log.h" namespace OHOS::UpdateEngine { diff --git a/services/core/ability/adapter/include/config_info.h b/services/core/ability/adapter/include/config_info.h new file mode 100644 index 0000000000000000000000000000000000000000..1ca9addaebf813207f4675bcad289d12f100f256 --- /dev/null +++ b/services/core/ability/adapter/include/config_info.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_CONFIG_INFO_H +#define UPDATE_SERVICE_CONFIG_INFO_H + +#include +#include + +namespace OHOS::UpdateEngine { +struct ConfigInfo { + std::string businessDomain; + uint32_t abInstallTimeout = 1800; // 1800s + std::string moduleLibPath; +}; +} // OHOS::UpdateEngine +#endif //UPDATE_SERVICE_CONFIG_INFO_H diff --git a/services/core/ability/adapter/include/config_parse.h b/services/core/ability/adapter/include/config_parse.h index 84a0c859cb77a4c928d2d3a68c2717c85d9137b5..2f6ec8501e450387c9a47cbdf99bce4013cb5071 100644 --- a/services/core/ability/adapter/include/config_parse.h +++ b/services/core/ability/adapter/include/config_parse.h @@ -18,7 +18,7 @@ #include "singleton.h" -#include "update_helper.h" +#include "config_info.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/core/ability/adapter/src/config_parse.cpp b/services/core/ability/adapter/src/config_parse.cpp index 621f694dbc5ab10f039cba0e9cd66d9c40787e5e..9ea2d3e0c09b3e716ba7989417bc2e47a7927c44 100644 --- a/services/core/ability/adapter/src/config_parse.cpp +++ b/services/core/ability/adapter/src/config_parse.cpp @@ -19,9 +19,10 @@ #include #include #include + #include "constant.h" +#include "dupdate_json_utils.h" #include "firmware_constant.h" -#include "json_utils.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/core/ability/adapter/src/device_adapter.cpp b/services/core/ability/adapter/src/device_adapter.cpp index 81709a690d8eadb2d73b6a5100856b117b2aae89..26e032725f34c484abf1892295c87fa98c82025e 100644 --- a/services/core/ability/adapter/src/device_adapter.cpp +++ b/services/core/ability/adapter/src/device_adapter.cpp @@ -27,11 +27,10 @@ #include "parameter.h" #include "securec.h" +#include "anonymous_utils.h" #include "constant.h" #include "config_parse.h" -#include "encrypt_utils.h" #include "update_log.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/core/ability/callback/include/base_callback_utils.h b/services/core/ability/callback/include/base_callback_utils.h index 1aa4a794bc649060323e5185b15d38454233ca64..9486be052fc6fd3848a9b9cc3192ebe3c01cd241 100644 --- a/services/core/ability/callback/include/base_callback_utils.h +++ b/services/core/ability/callback/include/base_callback_utils.h @@ -18,8 +18,15 @@ #include +#include "business_sub_type.h" +#include "error_message.h" +#include "event_id.h" +#include "event_info.h" #include "iupdate_callback.h" -#include "update_helper.h" +#include "progress.h" +#include "upgrade_status.h" +#include "upgrade_info.h" +#include "version_component.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/core/ability/callback/src/base_callback_utils.cpp b/services/core/ability/callback/src/base_callback_utils.cpp index ec1db30e1e5bbf4a0746d1f114137f2304bda475..5741a3b267e66e17105212bdf7b5e1dcd96bced8 100644 --- a/services/core/ability/callback/src/base_callback_utils.cpp +++ b/services/core/ability/callback/src/base_callback_utils.cpp @@ -16,7 +16,7 @@ #include "base_callback_utils.h" #include "iupdate_callback.h" -#include "update_helper.h" +#include "subscribe_info.h" #include "update_log.h" #include "update_notify.h" #include "update_service.h" diff --git a/services/core/ability/callback/src/base_callback_utils_empty.cpp b/services/core/ability/callback/src/base_callback_utils_empty.cpp index 059dfe987d70b74732cd072707d7f838c5ac7f94..00ca9b65945e6f36262107cd7fb4eb941932c7f2 100644 --- a/services/core/ability/callback/src/base_callback_utils_empty.cpp +++ b/services/core/ability/callback/src/base_callback_utils_empty.cpp @@ -16,12 +16,8 @@ #include "base_callback_utils.h" #include "iupdate_callback.h" -#include "update_define.h" -#include "update_helper.h" #include "update_log.h" -#include "update_service.h" #include "update_service_cache.h" -#include "update_service_util.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/core/ability/common/include/constant.h b/services/core/ability/common/include/constant.h index 20383f9c63aca6f1f6e744781ec91c635e096e8a..6319187806f20c82336d8381610f116286515a08 100644 --- a/services/core/ability/common/include/constant.h +++ b/services/core/ability/common/include/constant.h @@ -29,6 +29,7 @@ constexpr int32_t ONE_DAY_HOUR = 24; constexpr int32_t ONE_HOUR_MINUTES = 60; constexpr int32_t ONE_MINUTE_SECONDS = 60; constexpr int32_t FIVE_MINUTES_SECONDS = 5 * Constant::ONE_MINUTE_SECONDS; +constexpr int32_t MILLESECONDS = 1000; static const std::string DUPDATE_ENGINE_CONFIG_PATH = "/system/etc/update/dupdate_config.json"; diff --git a/services/core/ability/download/data/include/download_info.h b/services/core/ability/download/data/include/download_info.h index ac944eec8e99904cf8e7904537a80ee96e0e7cca..82fa4070404889c1e1065d29287572417e7ebdd2 100644 --- a/services/core/ability/download/data/include/download_info.h +++ b/services/core/ability/download/data/include/download_info.h @@ -16,11 +16,11 @@ #ifndef DOWNLOAD_INFO_H #define DOWNLOAD_INFO_H +#include +#include #include -#include "encrypt_utils.h" -#include "update_define.h" -#include "update_helper.h" +#include "anonymous_utils.h" namespace OHOS { namespace UpdateEngine { @@ -58,7 +58,7 @@ public: return std::string("DownloadInfo: ") .append("id=").append(std::to_string(id)).append(",") .append("taskId=").append(taskId).append(",") - .append("url=").append(EncryptUtils::EncryptUrl(url)).append(",") + .append("url=").append(AnonymousUtils::AnonymousUrl(url)).append(",") .append("path=").append(path).append(",") .append("veriftInfo=").append(veriftInfo).append(",") .append("retryTimes=").append(std::to_string(retryTimes)).append(",") diff --git a/services/core/ability/model/include/device_info.h b/services/core/ability/model/include/device_info.h index 10e7593a87bb8c3eaf01ae1d3ff8474e8fe0bc74..ed112c759bd14a5a3ee194cd788e7a4e257de5f0 100644 --- a/services/core/ability/model/include/device_info.h +++ b/services/core/ability/model/include/device_info.h @@ -20,7 +20,7 @@ #include "nlohmann/json.hpp" -#include "encrypt_utils.h" +#include "anonymous_utils.h" namespace OHOS { namespace UpdateEngine { @@ -32,8 +32,8 @@ public: nlohmann::ordered_json ToJson(bool isPrint) { nlohmann::ordered_json json = nlohmann::ordered_json::object(); - json["udid"] = isPrint ? EncryptUtils::EncryptString(udid) : udid; - json["deviceId"] = isPrint ? EncryptUtils::EncryptString(deviceId) : deviceId; + json["udid"] = isPrint ? AnonymousUtils::AnonymousString(udid) : udid; + json["deviceId"] = isPrint ? AnonymousUtils::AnonymousString(deviceId) : deviceId; return json; } }; diff --git a/services/core/ability/model/include/package_type.h b/services/core/ability/model/include/package_type.h new file mode 100644 index 0000000000000000000000000000000000000000..d01cc4f65aa054104b21605f096c76f311b497dc --- /dev/null +++ b/services/core/ability/model/include/package_type.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 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 UPDATE_SERVICE_PACKAGE_TYPE_H +#define UPDATE_SERVICE_PACKAGE_TYPE_H + +namespace OHOS::UpdateEngine { +enum class PackageType { + DYNAMIC = 0, + NORMAL = 1, + BASE = 2, + CUST = 3, + PRELOAD = 4, + COTA = 5, + VERSION = 6, + PATCH = 8, + SA = 9 +}; +} // namespace OHOS::UpdateEngine +#endif // UPDATE_SERVICE_PACKAGE_TYPE_H diff --git a/services/core/ability/sqlite/sqlite.gni b/services/core/ability/sqlite/sqlite.gni index 5cddb3f5e04d15da9267ceecfb3713b536e1a5de..07dece57cdb5afed0f246e5c8cc7c49db3e6c60e 100644 --- a/services/core/ability/sqlite/sqlite.gni +++ b/services/core/ability/sqlite/sqlite.gni @@ -27,10 +27,7 @@ sqlite_src = [] if (relational_store_native_rdb_enable) { sqlite_root_path = "$updateengine_root_path/services/core/ability/sqlite" sqlite_external_deps += [ "relational_store:native_rdb" ] - sqlite_include += [ - "$sqlite_root_path/core/include", - "//foundation/distributeddatamgr/relational_store/interfaces/inner_api/rdb/include", - ] + sqlite_include += [ "$sqlite_root_path/core/include" ] sqlite_src += [ "$sqlite_root_path/core/src/sqlite_db.cpp" ] sqlite_defines += [ "RELATIONAL_STORE_NATIVE_RDB_ENABLE" ] } diff --git a/services/core/ability/status_cache/include/status_cache.h b/services/core/ability/status_cache/include/status_cache.h index 1ab7136b8fcc050976b33febff457fcc9fa04177..b90586fb8226eb0af118694a6fab1ba15f42737a 100644 --- a/services/core/ability/status_cache/include/status_cache.h +++ b/services/core/ability/status_cache/include/status_cache.h @@ -29,6 +29,7 @@ public: bool IsChecking(); void SetIsChecking(bool isChecking); + bool IsDownloadTriggered(); private: int64_t GetCurrentTime(); @@ -37,6 +38,7 @@ private: std::shared_ptr timeUtilsProxy_ = nullptr; bool isChecking_ = false; int64_t lastCheckTime_ = -1; + int64_t lastDownloadTime_ = -1; }; } // namespace UpdateEngine } // namespace OHOS diff --git a/services/core/ability/status_cache/src/status_cache.cpp b/services/core/ability/status_cache/src/status_cache.cpp index 9fdca16aa283d14b030123e61b91b59b4dc77345..bf73d4643bb9765365d6e4aa20d325bc6cced8a9 100644 --- a/services/core/ability/status_cache/src/status_cache.cpp +++ b/services/core/ability/status_cache/src/status_cache.cpp @@ -16,6 +16,7 @@ #include "status_cache.h" #include "constant.h" +#include "time_utils.h" #include "update_log.h" namespace OHOS { @@ -45,5 +46,21 @@ int64_t StatusCache::GetCurrentTime() } return timeUtilsProxy_->GetTimestamp(); } + +bool StatusCache::IsDownloadTriggered() +{ + if (lastDownloadTime_ == -1) { + lastDownloadTime_ = TimeUtils::GetTimestampByMilliseconds(); + return false; + } + + if (abs(TimeUtils::GetTimestampByMilliseconds() - lastDownloadTime_) < Constant::MILLESECONDS) { + // 当前时间与上次下载时间间隔小于1秒钟,不允许重复触发下载 + ENGINE_LOGI("interval time within one seconds"); + return true; + } + lastDownloadTime_ = TimeUtils::GetTimestampByMilliseconds(); + return false; +} } // namespace UpdateEngine } // namespace OHOS diff --git a/services/core/ability/utils/include/file_utils.h b/services/core/ability/utils/include/file_utils.h index 25ee0479edcee56530e8637ef49062e3a605a151..bc5b16d5f6f6c0cc0b130ed4026fec64176a1375 100644 --- a/services/core/ability/utils/include/file_utils.h +++ b/services/core/ability/utils/include/file_utils.h @@ -21,6 +21,7 @@ #include #include #include +#include namespace OHOS { namespace UpdateEngine { diff --git a/services/core/ability/utils/include/time_utils.h b/services/core/ability/utils/include/time_utils.h index c39fb132181c78887f16298b2804d05c78276c5a..b00c42abc4bcdd560edd6eae51a088d368b75c99 100644 --- a/services/core/ability/utils/include/time_utils.h +++ b/services/core/ability/utils/include/time_utils.h @@ -35,6 +35,12 @@ public: return static_cast(currentTime); } + static int64_t GetTimestampByMilliseconds() + { + return std::chrono::duration_cast + (std::chrono::system_clock::now().time_since_epoch()).count(); + } + static std::string GetPrintTimeStr(int64_t time) { time_t printTime = static_cast(time); diff --git a/services/core/ability/utils/src/file_utils.cpp b/services/core/ability/utils/src/file_utils.cpp index 7c60701750257deeaaafc5b7f41152f126ab412e..7baef164bd41720bd3edf17be72a2efcda8ebcad 100644 --- a/services/core/ability/utils/src/file_utils.cpp +++ b/services/core/ability/utils/src/file_utils.cpp @@ -26,7 +26,6 @@ #include #include "constant.h" -#include "update_helper.h" #include "update_log.h" namespace OHOS { diff --git a/services/engine/engine_sa.gni b/services/engine/engine_sa.gni index 72dc2f5ade0bf5ba3308a3c14c5ae19d709d090b..d9a52e5b5a44033654dc26209f16dcfa1435afa2 100644 --- a/services/engine/engine_sa.gni +++ b/services/engine/engine_sa.gni @@ -13,7 +13,6 @@ import("//base/update/updateservice/updateengine.gni") import("//build/ohos.gni") -import("$updateengine_root_path/services/core/ability/log/log.gni") import("$updateengine_root_path/services/core/ability/sqlite/sqlite.gni") import("$updateengine_root_path/services/firmware/firmware.gni") import("$updateengine_root_path/services/startup/startup.gni") @@ -24,10 +23,6 @@ declare_args() { ability_ability_base_enable = false } - communication_netmanager_base_enable = true - if (!defined(global_parts_info.communication_netmanager_base)) { - communication_netmanager_base_enable = false - } preference_native_preferences_enable = true if (!defined(global_parts_info.distributeddatamgr_preferences)) { preference_native_preferences_enable = false @@ -35,9 +30,7 @@ declare_args() { } sa_sources = [ - "$updateengine_root_path/services/callback/src/update_callback.cpp", "$updateengine_root_path/services/callback/src/update_callback_proxy.cpp", - "$updateengine_root_path/services/callback/src/update_callback_stub.cpp", "$updateengine_root_path/services/core/ability/adapter/src/config_parse.cpp", "$updateengine_root_path/services/core/ability/adapter/src/device_adapter.cpp", "$updateengine_root_path/services/core/ability/alarm/src/alarm_manager.cpp", @@ -46,9 +39,7 @@ sa_sources = [ "$updateengine_root_path/services/core/ability/utils/src/file_utils.cpp", "$updateengine_root_path/services/core/ability/utils/src/sha256_utils.cpp", "$updateengine_root_path/services/core/ability/utils/src/time_utils_proxy.cpp", - "$updateengine_root_path/services/engine/src/message_parcel_helper.cpp", "$updateengine_root_path/services/engine/src/progress_thread.cpp", - "$updateengine_root_path/services/engine/src/update_helper.cpp", "$updateengine_root_path/services/engine/src/update_service.cpp", "$updateengine_root_path/services/engine/src/update_service_cache.cpp", "$updateengine_root_path/services/engine/src/update_service_impl_firmware.cpp", @@ -87,7 +78,6 @@ if (preference_native_preferences_enable) { sa_sources += firmware_src sa_sources += sqlite_src -sa_sources += update_log_src sa_sources += startup_src sa_include_dirs = [ @@ -98,7 +88,6 @@ sa_include_dirs = [ "$updateengine_root_path/services/core/ability/alarm/include", "$updateengine_root_path/services/core/ability/callback/include", "$updateengine_root_path/services/core/ability/common/include", - "$updateengine_root_path/services/core/ability/define/include", "$updateengine_root_path/services/core/ability/model/include", "$updateengine_root_path/services/core/ability/net/include", "$updateengine_root_path/services/core/ability/preference/include", @@ -121,56 +110,27 @@ sa_include_dirs = [ "//third_party/glib", "//third_party/openssl/include", "//third_party/cJSON/", + "//third_party/json/include", ] -if (!ability_ability_base_enable || !ability_ability_runtime_enable) { - sa_include_dirs += [ - "//foundation/ability/ability_base/interfaces/inner_api/base/include", - "//foundation/ability/ability_base/interfaces/kits/native/uri/include", - "//foundation/ability/ability_base/interfaces/kits/native/want/include", - "//foundation/ability/ability_runtime/frameworks/simulator/common/include", - "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager/include", - "//foundation/ability/ability_runtime/interfaces/inner_api/app_manager/include/appmgr", - "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native", - "//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_base/include", - ] -} - -if (!preference_native_preferences_enable) { - sa_include_dirs += [ - "//foundation/distributeddatamgr/preferences/interfaces/inner_api/include", - ] -} - -if (!communication_netmanager_base_enable) { - sa_include_dirs += [ - "//foundation/communication/netmanager_base/interfaces/innerkits/include", - "//foundation/communication/netmanager_base/interfaces/innerkits/netconnclient/include", - "//foundation/communication/netmanager_base/interfaces/innerkits/netconnclient/include/proxy", - ] -} - if (!relational_store_native_rdb_enable) { sa_include_dirs += [ "//base/update/updateservice/services/core/ability/sqlite/core/include", - "//foundation/distributeddatamgr/relational_store/interfaces/inner_api/rdb/include", ] } sa_include_dirs += firmware_include sa_include_dirs += sqlite_include -sa_include_dirs += update_log_include sa_include_dirs += startup_include sa_include_dirs += [ "//base/update/updateservice/interfaces/innner_api/modulemgr/include" ] sa_deps = [ + "$updateengine_root_path/foundations:update_foundations", + "$updateengine_root_path/interfaces/inner_api/engine:$updateengine_inner_library_name", "$updateengine_root_path/interfaces/inner_api/modulemgr:update_module_mgr", - "//base/update/updater/services/fs_manager:libfsmanager", # factory_reset_GetBlockDeviceByMountPoint_"fs_manager/mount.h" "//third_party/cJSON:cjson", "//third_party/curl:curl", - "//third_party/glib:glib_packages", - "//third_party/jsoncpp:jsoncpp", "//third_party/libxml2:libxml2", "//third_party/mbedtls:mbedtls_shared", "//third_party/openssl:libcrypto_shared", @@ -178,7 +138,6 @@ sa_deps = [ ] sa_deps += firmware_deps -sa_deps += update_log_deps sa_deps += startup_deps sa_external_deps = [ @@ -191,8 +150,8 @@ sa_external_deps = [ "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "updater:libpackageExt", # "package/package.h" - "updater:libupdaterkits", # "updaterkits/updaterkits.h" + "updater:libpackage_shared", # "package/package.h" + "updater:libupdater_shared", # "updaterkits/updaterkits.h" ] if (ability_ability_base_enable) { @@ -204,9 +163,11 @@ if (ability_ability_base_enable) { if (ability_ability_runtime_enable) { sa_external_deps += [ "ability_runtime:ability_manager" ] } + if (communication_netmanager_base_enable) { sa_external_deps += [ "netmanager_base:net_conn_manager_if" ] } + if (preference_native_preferences_enable) { sa_external_deps += [ "preferences:native_preferences" ] } @@ -216,7 +177,6 @@ if (ability_ability_runtime_enable) { } sa_external_deps += sqlite_external_deps -sa_external_deps += update_log_external_deps sa_external_deps += startup_external_deps sa_public_deps = [] diff --git a/services/engine/etc/updater_sa.cfg b/services/engine/etc/updater_sa.cfg index 28a8eee7398988c93bed16862cf04b976d06c0c7..de4271cca246afcde596159f665907bd0a348928 100644 --- a/services/engine/etc/updater_sa.cfg +++ b/services/engine/etc/updater_sa.cfg @@ -24,7 +24,8 @@ "uid" : "update", "gid" : ["update", "netsys_socket"], "permission" : [ - "ohos.permission.UPDATE_SYSTEM" + "ohos.permission.UPDATE_SYSTEM", + "ohos.permission.GET_NETWORK_INFO" ], "secon" : "u:r:updater_sa:s0" } diff --git a/services/engine/include/progress_thread.h b/services/engine/include/progress_thread.h index d36a114af8a1b1282afb12207767e0b9ac0c3876..8e352e28b0b59623ac84e714c8387401dd656134 100644 --- a/services/engine/include/progress_thread.h +++ b/services/engine/include/progress_thread.h @@ -21,7 +21,8 @@ #include #include #include "curl/curl.h" -#include "update_helper.h" + +#include "progress.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/engine/include/update_service.h b/services/engine/include/update_service.h index fb69dd8002455163c02cddb5d730a8c2efaf28f0..0090f95b56b524c48b75501e719af2c9c4d9df6e 100644 --- a/services/engine/include/update_service.h +++ b/services/engine/include/update_service.h @@ -24,7 +24,6 @@ #include "iremote_stub.h" #include "system_ability.h" -#include "update_helper.h" #include "update_service_impl_manager.h" #include "update_service_stub.h" diff --git a/services/engine/include/update_service_cache.h b/services/engine/include/update_service_cache.h index 75e616ef371d037f2dbc4325c4394cf04f50904f..a42a986e60aff81e994c9b343228d97536b908a7 100644 --- a/services/engine/include/update_service_cache.h +++ b/services/engine/include/update_service_cache.h @@ -16,7 +16,11 @@ #ifndef UPDATE_SERVICE_CACHE_H #define UPDATE_SERVICE_CACHE_H -#include "update_helper.h" +#include + +#include "business_sub_type.h" +#include "upgrade_info.h" +#include "upgrade_interval.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/engine/include/update_service_impl_firmware.h b/services/engine/include/update_service_impl_firmware.h index dc4e145b0c33c2301ba5d3748d191bb44905b0ba..d8c1ec3e4be3c083abfce247dcc058ee9841fd4c 100644 --- a/services/engine/include/update_service_impl_firmware.h +++ b/services/engine/include/update_service_impl_firmware.h @@ -22,7 +22,6 @@ #include "firmware_preferences_utils.h" #include "firmware_task.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/engine/include/update_service_impl_manager.h b/services/engine/include/update_service_impl_manager.h index 66186d67da1a96d21126789dce195727cb3a7272..49dbe81c369834fa186ae4afc3802b7e38b5ac93 100644 --- a/services/engine/include/update_service_impl_manager.h +++ b/services/engine/include/update_service_impl_manager.h @@ -20,7 +20,7 @@ #include -#include "update_helper.h" +#include "upgrade_info.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/engine/include/update_service_util.h b/services/engine/include/update_service_util.h index 6260ac015cfb173744e818d134af64533a0e21b8..d242949878e6e5fd2569297adf739bece6d4b590 100644 --- a/services/engine/include/update_service_util.h +++ b/services/engine/include/update_service_util.h @@ -17,7 +17,9 @@ #define UPDATE_SERVICE_UTIL_H #include "iupdate_callback.h" -#include "update_helper.h" +#include "progress.h" +#include "task_body.h" +#include "upgrade_info.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/engine/src/update_notify.cpp b/services/engine/src/update_notify.cpp index 98a6604088be581375a841fcbe0a550660d4e3f0..01000ac15916bf3d209314d6e8fc8762b06d6721 100644 --- a/services/engine/src/update_notify.cpp +++ b/services/engine/src/update_notify.cpp @@ -17,7 +17,7 @@ #include "iservice_registry.h" -#include "update_helper.h" +#include "subscribe_info.h" #include "update_log.h" namespace OHOS { diff --git a/services/engine/src/update_service.cpp b/services/engine/src/update_service.cpp index 6b14d0ce5a02efcc94ee8cb21cefc6b3802add0b..f888c6ecb304c1218647b222b32105f5956aa67c 100644 --- a/services/engine/src/update_service.cpp +++ b/services/engine/src/update_service.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include "iservice_registry.h" #include "ohos_types.h" diff --git a/services/engine/src/update_service_cache.cpp b/services/engine/src/update_service_cache.cpp index 61394bdc66813591c8b1ac1fd5638772889a4a73..081ef7bf45e12abb318b15aa71eeffd7fe80af51 100644 --- a/services/engine/src/update_service_cache.cpp +++ b/services/engine/src/update_service_cache.cpp @@ -15,9 +15,12 @@ #include "update_service_cache.h" +#include + #include "update_define.h" -#include "update_helper.h" #include "update_log.h" +#include "upgrade_info.h" +#include "upgrade_interval.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/engine/src/update_service_impl_firmware.cpp b/services/engine/src/update_service_impl_firmware.cpp index 524eb5b645e645803cef064ca344e1a9d7797ac7..040f9cacd85b475c91482f12d4197e1e02938d51 100644 --- a/services/engine/src/update_service_impl_firmware.cpp +++ b/services/engine/src/update_service_impl_firmware.cpp @@ -22,6 +22,7 @@ #include "firmware_component_operator.h" #include "firmware_log.h" #include "firmware_manager.h" +#include "firmware_status_cache.h" #include "firmware_task_operator.h" #include "device_adapter.h" #include "firmware_update_helper.h" @@ -59,6 +60,7 @@ int32_t UpdateServiceImplFirmware::CheckNewVersion(const UpgradeInfo &info, Busi businessError.errorNum = CallResult::TIME_OUT; businessError.message = "CheckNewVersion TimeOut"; } + weakPtr->checkComplete_ = false; return INT_CALL_SUCCESS; } @@ -67,6 +69,13 @@ int32_t UpdateServiceImplFirmware::Download(const UpgradeInfo &info, const Versi { FIRMWARE_LOGI("Download allowNetwork:%{public}d order:%{public}d", CAST_INT(downloadOptions.allowNetwork), CAST_INT(downloadOptions.order)); + //控制1秒内重复点击下载 + if (DelayedSingleton::GetInstance()->IsDownloadTriggered()) { + FIRMWARE_LOGI("on downloading, not perrmit repeat submmit"); + businessError.Build(CallResult::FAIL, "repeat download error"); + return INT_CALL_SUCCESS; + } + FirmwareTask task; FirmwareTaskOperator firmwareTaskOperator; firmwareTaskOperator.QueryTask(task); diff --git a/services/engine/src/update_service_restorer.cpp b/services/engine/src/update_service_restorer.cpp index 37a8fad728f3fe225b963bee1d837fe9b0f9d2c4..47c37ffa1fdaf49a7bd9ae074d7c11739d219fd7 100644 --- a/services/engine/src/update_service_restorer.cpp +++ b/services/engine/src/update_service_restorer.cpp @@ -15,7 +15,9 @@ #include "update_service_restorer.h" +#ifndef UPDATER_FUZZ #include "fs_manager/mount.h" +#endif #include "updaterkits/updaterkits.h" #include "update_define.h" diff --git a/services/engine/src/update_service_stub.cpp b/services/engine/src/update_service_stub.cpp index 66174265288726d367a0987097c34a98781c3d19..c862be67e6b3ccec0b2ddbe9573531e7324d3780 100644 --- a/services/engine/src/update_service_stub.cpp +++ b/services/engine/src/update_service_stub.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include + #include "accesstoken_kit.h" #include "access_token.h" #include "ipc_skeleton.h" @@ -20,7 +22,6 @@ #include "securec.h" #include "tokenid_kit.h" #include "update_define.h" -#include "update_helper.h" #include "update_log.h" #include "update_service_stub.h" #include "update_system_event.h" @@ -39,6 +40,8 @@ constexpr const pid_t EDM_UID = 3057; #define RETURN_FAIL_WHEN_SERVICE_NULL(service) \ ENGINE_CHECK((service) != nullptr, return INT_CALL_IPC_ERR, "service null") +#define CALL_RESULT_TO_IPC_RESULT(callResult) ((callResult) + CALL_RESULT_OFFSET) + UpdateServiceStub::UpdateServiceStub() { requestFuncMap_ = { diff --git a/services/firmware/check/include/firmware_icheck.h b/services/firmware/check/include/firmware_icheck.h index fb303e2caec88f2085e2d1f953b7a5ec99add237..ae188fe79469fdaa9e9b912a721bff5b439fc845 100644 --- a/services/firmware/check/include/firmware_icheck.h +++ b/services/firmware/check/include/firmware_icheck.h @@ -29,7 +29,7 @@ #include "parameter.h" #include "parameters.h" -#include "encrypt_utils.h" +#include "anonymous_utils.h" #include "firmware_check_analyze_utils.h" #include "firmware_common.h" #include "firmware_component.h" @@ -37,7 +37,7 @@ #include "device_adapter.h" #include "firmware_update_helper.h" #include "network_response.h" -#include "update_helper.h" +#include "search_status.h" #include "update_service_util.h" constexpr int32_t PORT_NUMBER = 5022; diff --git a/services/firmware/common/include/firmware_common.h b/services/firmware/common/include/firmware_common.h index 3865d51b9a14969d1f5aa2b4edc9e17f9ef61cd5..e496da437ef60661de9ad7bf3a6f1352b4b440c1 100644 --- a/services/firmware/common/include/firmware_common.h +++ b/services/firmware/common/include/firmware_common.h @@ -20,11 +20,11 @@ #include "nlohmann/json.hpp" +#include "anonymous_utils.h" #include "constant.h" -#include "encrypt_utils.h" #include "firmware_component.h" #include "firmware_log.h" -#include "update_helper.h" +#include "update_define.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/common/include/firmware_constant.h b/services/firmware/common/include/firmware_constant.h index adf5c4bd1bb96aa99ce81a7383c1b48f2c331d59..b232b098005fb386d9714cf59354a5abdc520986 100644 --- a/services/firmware/common/include/firmware_constant.h +++ b/services/firmware/common/include/firmware_constant.h @@ -19,7 +19,6 @@ #include #include "constant.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/common/include/firmware_update_helper.h b/services/firmware/common/include/firmware_update_helper.h index a0e2336cb20b7366e1a13328cffe0cc6b0bba3b3..f96ddb9c2dbd61b8e9c78e33f4c33e854654bb3c 100644 --- a/services/firmware/common/include/firmware_update_helper.h +++ b/services/firmware/common/include/firmware_update_helper.h @@ -20,6 +20,7 @@ #include "nlohmann/json.hpp" +#include "current_version_info.h" #include "firmware_changelog_utils.h" #include "firmware_constant.h" #include "firmware_combine_version_utils.h" @@ -33,7 +34,7 @@ #include "device_adapter.h" #include "sha256_utils.h" #include "time_utils.h" -#include "update_helper.h" +#include "version_component.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/common/src/firmware_update_adapter.cpp b/services/firmware/common/src/firmware_update_adapter.cpp index febe4b78f8235488d485224c83b706c01676e2e0..d02a69b28af0468f25e9db1c3b083f2e6684c039 100644 --- a/services/firmware/common/src/firmware_update_adapter.cpp +++ b/services/firmware/common/src/firmware_update_adapter.cpp @@ -34,7 +34,6 @@ #include "firmware_preferences_utils.h" #include "firmware_task.h" #include "time_utils.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/data/db/include/firmware_component.h b/services/firmware/data/db/include/firmware_component.h index fd83ae9c1a3bef6f34591da1b0002f70afd0c442..babc871296e3196f2adf61a00852ab832167b66d 100644 --- a/services/firmware/data/db/include/firmware_component.h +++ b/services/firmware/data/db/include/firmware_component.h @@ -18,7 +18,9 @@ #include -#include "update_helper.h" +#include "package_type.h" +#include "update_define.h" +#include "upgrade_status.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/data/db/include/firmware_component_operator.h b/services/firmware/data/db/include/firmware_component_operator.h index 9d14f08cfd7356b055b8fc94935b8195185c3933..bf3e2146239aaf4248da1256d112df0af9f2b993 100644 --- a/services/firmware/data/db/include/firmware_component_operator.h +++ b/services/firmware/data/db/include/firmware_component_operator.h @@ -21,10 +21,11 @@ #include "firmware_component.h" #include "firmware_component_table.h" #include "firmware_database.h" +#include "upgrade_status.h" + #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE #include "table_base_operator.h" #endif -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/data/db/include/firmware_task.h b/services/firmware/data/db/include/firmware_task.h index 55646f5f6afaeb894f3edf6c9d664e654867fa70..db7064da931d79cec835b82463f011810c280d17 100644 --- a/services/firmware/data/db/include/firmware_task.h +++ b/services/firmware/data/db/include/firmware_task.h @@ -19,7 +19,9 @@ #include #include "firmware_common.h" -#include "update_helper.h" +#include "network_type.h" +#include "order.h" +#include "update_define.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/data/db/include/firmware_task_operator.h b/services/firmware/data/db/include/firmware_task_operator.h index 2438203b6d36cb2f30d0635313e29cf6c663e655..c9163fe194e73de0e1d5a570abaa15ac0fb55901 100644 --- a/services/firmware/data/db/include/firmware_task_operator.h +++ b/services/firmware/data/db/include/firmware_task_operator.h @@ -22,6 +22,9 @@ #include "firmware_database.h" #include "firmware_task_table.h" #include "firmware_task.h" +#include "network_type.h" +#include "order.h" + #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE #include "table_base_operator.h" #endif diff --git a/services/firmware/data/db/src/firmware_task_operator.cpp b/services/firmware/data/db/src/firmware_task_operator.cpp index a4811a809f2b512c9c5e4999ae9dbba046d832fb..8cc133fbfbf95220026318471027682f002da33e 100644 --- a/services/firmware/data/db/src/firmware_task_operator.cpp +++ b/services/firmware/data/db/src/firmware_task_operator.cpp @@ -17,8 +17,11 @@ #include +#include "network_type.h" +#include "order.h" #include "time_utils.h" -#include "update_helper.h" +#include "update_define.h" +#include "upgrade_status.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/data/db/src/firmware_task_operator_empty.cpp b/services/firmware/data/db/src/firmware_task_operator_empty.cpp index f7ce5f37de464f3f201e7ebad4349c1a64ad2352..b2454fcafd6a6c425f69f397f82adfa5385ad1f6 100644 --- a/services/firmware/data/db/src/firmware_task_operator_empty.cpp +++ b/services/firmware/data/db/src/firmware_task_operator_empty.cpp @@ -18,7 +18,8 @@ #include #include "time_utils.h" -#include "update_helper.h" +#include "network_type.h" +#include "order.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/data/db/src/firmware_task_table_empty.cpp b/services/firmware/data/db/src/firmware_task_table_empty.cpp index d14701f64aceb1ba2a0ff1e2b899a95189a2aab7..56167839d0fce299ea5719e21c4482dcb88b0d64 100644 --- a/services/firmware/data/db/src/firmware_task_table_empty.cpp +++ b/services/firmware/data/db/src/firmware_task_table_empty.cpp @@ -15,9 +15,6 @@ #include "firmware_task_table.h" -#include "itable.h" -#include "update_define.h" - namespace OHOS { namespace UpdateEngine { std::string FirmwareTaskTable::GetTableName() diff --git a/services/firmware/event/include/firmware_event_listener.h b/services/firmware/event/include/firmware_event_listener.h index 1fbd87c223451e4046b2538e907ba47a938fdc7a..d49927f491f96ef7c8df6aaceca0dee51e5a71a5 100644 --- a/services/firmware/event/include/firmware_event_listener.h +++ b/services/firmware/event/include/firmware_event_listener.h @@ -19,7 +19,6 @@ #include "singleton.h" #include "dupdate_inet_observer.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/event/src/firmware_event_listener_empty.cpp b/services/firmware/event/src/firmware_event_listener_empty.cpp new file mode 100644 index 0000000000000000000000000000000000000000..21dc8281696aa9fd0c02416eb5a869ed052e82ac --- /dev/null +++ b/services/firmware/event/src/firmware_event_listener_empty.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "firmware_event_listener.h" + +#include "firmware_log.h" + +namespace OHOS { +namespace UpdateEngine { +FirmwareEventListener::FirmwareEventListener() +{ + FIRMWARE_LOGD("FirmwareEventListener::FirmwareEventListener"); +} + +FirmwareEventListener::~FirmwareEventListener() +{ + FIRMWARE_LOGD("FirmwareEventListener::~FirmwareEventListener"); +} + +void FirmwareEventListener::RegisterNetChangedListener() +{ + FIRMWARE_LOGI("FirmwareEventListener RegisterNetChangedListener"); +} + +void FirmwareEventListener::UnregisterNetChangedListener() +{ + FIRMWARE_LOGI("FirmwareEventListener UnregisterNetChangedListener"); +} +} // namespace UpdateEngine +} // namespace OHOS \ No newline at end of file diff --git a/services/firmware/firmware.gni b/services/firmware/firmware.gni index ad84eaafe95f645a582bf6a98a2effc48a044af2..b2049eced80c6b0141fe3a89de1e39f8099f3816 100644 --- a/services/firmware/firmware.gni +++ b/services/firmware/firmware.gni @@ -16,12 +16,8 @@ import("$updateengine_root_path/services/core/ability/sqlite/sqlite.gni") firmware_root_path = "$updateengine_root_path/services/firmware" -ab_update_include = [ - "//base/update/sys_installer/include", - "//base/update/sys_installer/interfaces/innerkits", - "//base/update/sys_installer/interfaces/inner_api/include", - "//base/update/sys_installer/interfaces/innerkits/ipc_client/include", -] +ab_update_include = + [ "//base/update/sys_installer/interfaces/inner_api/include" ] download_include = [ "//base/update/updateservice/services/core/ability/download/data/include", @@ -60,8 +56,6 @@ firmware_src = [ "$firmware_root_path/callback/src/firmware_callback_utils.cpp", "$firmware_root_path/common/src/firmware_update_helper.cpp", "$firmware_root_path/data/manager/src/firmware_preferences_utils.cpp", - "$firmware_root_path/event/src/firmware_event_listener.cpp", - "$firmware_root_path/upgrade/data_processor/src/firmware_check_data_processor.cpp", "$firmware_root_path/upgrade/data_processor/src/firmware_download_data_processor.cpp", "$firmware_root_path/upgrade/data_processor/src/firmware_install_data_processor.cpp", "$firmware_root_path/upgrade/executor/src/firmware_apply_executor.cpp", @@ -73,9 +67,6 @@ firmware_src = [ "$firmware_root_path/upgrade/install/src/firmware_install.cpp", "$firmware_root_path/upgrade/install/src/firmware_updater_install.cpp", "$firmware_root_path/upgrade/install/src/firmware_install_factory.cpp", - "$firmware_root_path/upgrade/mode/src/firmware_manual_check_mode.cpp", - "$firmware_root_path/upgrade/mode/src/firmware_download_mode.cpp", - "$firmware_root_path/upgrade/mode/src/firmware_install_apply_mode.cpp", "$firmware_root_path/upgrade/status/src/firmware_status_cache.cpp", "$firmware_root_path/upgrade/status/src/firmware_result_process.cpp", "$firmware_root_path/utils/src/firmware_check_analyze_utils.cpp", @@ -83,6 +74,24 @@ firmware_src = [ "$firmware_root_path/utils/src/firmware_combine_version_utils.cpp", ] +if (communication_netmanager_base_enable) { + firmware_src += [ + "$firmware_root_path/event/src/firmware_event_listener.cpp", + "$firmware_root_path/upgrade/data_processor/src/firmware_check_data_processor.cpp", + "$firmware_root_path/upgrade/mode/src/firmware_download_mode.cpp", + "$firmware_root_path/upgrade/mode/src/firmware_manual_check_mode.cpp", + "$firmware_root_path/upgrade/mode/src/firmware_install_apply_mode.cpp", + ] +} else { + firmware_src += [ + "$firmware_root_path/event/src/firmware_event_listener_empty.cpp", + "$firmware_root_path/upgrade/data_processor/src/firmware_check_data_processor_empty.cpp", + "$firmware_root_path/upgrade/mode/src/firmware_download_mode_empty.cpp", + "$firmware_root_path/upgrade/mode/src/firmware_manual_check_mode_empty.cpp", + "$firmware_root_path/upgrade/mode/src/firmware_install_apply_mode_empty.cpp", + ] +} + if (relational_store_native_rdb_enable) { firmware_src += [ "$firmware_root_path/data/db/src/firmware_component_operator.cpp", @@ -103,7 +112,7 @@ if (relational_store_native_rdb_enable) { } firmware_src += ab_update_src -firmware_external_deps = [ "sys_installer:libsysinstallerkits" ] +firmware_external_deps = [ "sys_installer:libsysinstaller_shared" ] ab_update_deps = [] diff --git a/services/firmware/upgrade/data_processor/include/firmware_check_data_processor.h b/services/firmware/upgrade/data_processor/include/firmware_check_data_processor.h index bdc43c4b7cd89211b2786f8991cc49e1131ccfba..b1bbe6d7247c7cdaccd08c6f41b7daef11bc0edb 100644 --- a/services/firmware/upgrade/data_processor/include/firmware_check_data_processor.h +++ b/services/firmware/upgrade/data_processor/include/firmware_check_data_processor.h @@ -16,9 +16,11 @@ #ifndef FIRMWARE_CHECK_DATA_PROCESSOR_H #define FIRMWARE_CHECK_DATA_PROCESSOR_H +#include "check_result.h" #include "firmware_common.h" #include "firmware_component.h" #include "firmware_preferences_utils.h" +#include "new_version_info.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/data_processor/include/firmware_download_data_processor.h b/services/firmware/upgrade/data_processor/include/firmware_download_data_processor.h index 189bfafe386abeb91b1505cfeb3a314b0b010204..186c864b7466b96f087ee34b59c44a9cbfd05dc9 100644 --- a/services/firmware/upgrade/data_processor/include/firmware_download_data_processor.h +++ b/services/firmware/upgrade/data_processor/include/firmware_download_data_processor.h @@ -18,7 +18,7 @@ #include "firmware_common.h" #include "firmware_task.h" -#include "update_helper.h" +#include "progress.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/data_processor/src/firmware_check_data_processor.cpp b/services/firmware/upgrade/data_processor/src/firmware_check_data_processor.cpp index 62de4e82e46bc4544b2e13a9b16680403ecbef8a..5e4c2d6cd2ec2befba879021fcb57f94668eb112 100644 --- a/services/firmware/upgrade/data_processor/src/firmware_check_data_processor.cpp +++ b/services/firmware/upgrade/data_processor/src/firmware_check_data_processor.cpp @@ -31,7 +31,6 @@ #include "firmware_update_helper.h" #include "string_utils.h" #include "time_utils.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/data_processor/src/firmware_check_data_processor_empty.cpp b/services/firmware/upgrade/data_processor/src/firmware_check_data_processor_empty.cpp new file mode 100644 index 0000000000000000000000000000000000000000..41e27984f45cb61231337c7a2deddffbd94bcfb4 --- /dev/null +++ b/services/firmware/upgrade/data_processor/src/firmware_check_data_processor_empty.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "firmware_check_data_processor.h" + +#include "firmware_log.h" + +namespace OHOS { +namespace UpdateEngine { +FirmwareCheckDataProcessor::FirmwareCheckDataProcessor() +{ + FIRMWARE_LOGD("FirmwareCheckDataProcessor::FirmwareCheckDataProcessor"); +} + +FirmwareCheckDataProcessor::~FirmwareCheckDataProcessor() +{ + FIRMWARE_LOGD("FirmwareCheckDataProcessor::~FirmwareCheckDataProcessor"); +} + +void FirmwareCheckDataProcessor::SetCheckResult( + CheckStatus status, const Duration &duration, const std::vector &componentList) +{ + FIRMWARE_LOGI("FirmwareCheckDataProcessor::SetCheckResult status %{public}d duration %{public}d", + static_cast(status), duration.duration); + status_ = status; + duration_ = duration; + componentList_ = componentList; +} + +bool FirmwareCheckDataProcessor::IsCheckFailed() +{ + return true; +} + +bool FirmwareCheckDataProcessor::HasNewVersion() +{ + return !componentList_.empty(); +} + +bool FirmwareCheckDataProcessor::IsSameWithDb() +{ + return true; +} + +void FirmwareCheckDataProcessor::HandleCheckResult() +{ + FIRMWARE_LOGI("FirmwareCheckDataProcessor HandleCheckResult"); +} + +bool FirmwareCheckDataProcessor::HasUndoneTask() +{ + FIRMWARE_LOGI("HasUndoneTask"); + return true; +} + +bool FirmwareCheckDataProcessor::IsUpdateOnStatus() +{ + return true; +} + +void FirmwareCheckDataProcessor::HandleNewVersion() +{ + FIRMWARE_LOGI("FirmwareCheckDataProcessor::HandleNewVersion"); +} + +void FirmwareCheckDataProcessor::BuildComponentSPath() +{ + FIRMWARE_LOGI("FirmwareCheckDataProcessor::BuildComponentSPath"); +} + +bool FirmwareCheckDataProcessor::IsVersionSameWithDb() +{ + return true; +} + +void FirmwareCheckDataProcessor::UpdateFirmwareComponent() +{ + FIRMWARE_LOGI("FirmwareCheckDataProcessor::UpdateFirmwareComponent"); +} + +void FirmwareCheckDataProcessor::HandleNoNewVersion() +{ + FIRMWARE_LOGI("FirmwareCheckDataProcessor::HandleNoNewVersion"); + isSameWithDb_ = IsVersionSameWithDb(); +} + +CombinationType FirmwareCheckDataProcessor::GetCombinationType() +{ + uint32_t combinationType = CAST_UINT(CombinationType::INVALLID_TYPE); + FIRMWARE_LOGI("CombinationType::%{public}u", combinationType); + return static_cast(combinationType); +} + +void FirmwareCheckDataProcessor::RefreshPollingCycle() +{ + FIRMWARE_LOGI("FirmwareCheckDataProcessor::RefreshPollingCycle"); +} + +void FirmwareCheckDataProcessor::BuildCheckResult(CheckResult &checkResult) +{ + FIRMWARE_LOGI("FirmwareCheckDataProcessor::BuildCheckResult"); +} + +void FirmwareCheckDataProcessor::BuildVersionDigest( + NewVersionInfo &newVersionInfo, const std::vector &componentList) +{ + FIRMWARE_LOGI("FirmwareCheckDataProcessor::BuildVersionDigest"); +} +} // namespace UpdateEngine +} // namespace OHOS \ No newline at end of file diff --git a/services/firmware/upgrade/executor/include/firmware_download_executor.h b/services/firmware/upgrade/executor/include/firmware_download_executor.h index b1aaed5483f79d6d941a2c097f2e66a4b27374de..fb8f301d2e0010ab89161b37f194d594d9c17598 100644 --- a/services/firmware/upgrade/executor/include/firmware_download_executor.h +++ b/services/firmware/upgrade/executor/include/firmware_download_executor.h @@ -16,11 +16,11 @@ #ifndef FIRMWARE_DOWNLOAD_EXECUTOR_H #define FIRMWARE_DOWNLOAD_EXECUTOR_H +#include "download_options.h" #include "firmware_component.h" #include "firmware_iexecutor.h" #include "firmware_task.h" #include "progress_thread.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/executor/include/firmware_iexecutor.h b/services/firmware/upgrade/executor/include/firmware_iexecutor.h index f13c76ca5fc71d354cb8016ead9a8f4568e04305..47c9b81ef58ffef8825c61e4b73a9386c65f2db4 100644 --- a/services/firmware/upgrade/executor/include/firmware_iexecutor.h +++ b/services/firmware/upgrade/executor/include/firmware_iexecutor.h @@ -16,9 +16,11 @@ #ifndef FIRMWARE_IEXECUTOR_H #define FIRMWARE_IEXECUTOR_H +#include "error_message.h" #include "firmware_common.h" #include "firmware_component.h" #include "firmware_log.h" +#include "progress.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/executor/src/firmware_apply_executor.cpp b/services/firmware/upgrade/executor/src/firmware_apply_executor.cpp index 6113454f177b63985adfa46ad3d599ba71bd653f..9a27865e33d494063ffe572a9df34d35e0759e7a 100644 --- a/services/firmware/upgrade/executor/src/firmware_apply_executor.cpp +++ b/services/firmware/upgrade/executor/src/firmware_apply_executor.cpp @@ -26,7 +26,6 @@ #include "firmware_log.h" #include "firmware_task_operator.h" #include "firmware_update_helper.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/executor/src/firmware_check_executor.cpp b/services/firmware/upgrade/executor/src/firmware_check_executor.cpp index d4e9b079a240e3b23e0d378a89ab9b0ecc0b9924..7a9c0f8e285d4ee2805d626e38b6bd573c19248f 100644 --- a/services/firmware/upgrade/executor/src/firmware_check_executor.cpp +++ b/services/firmware/upgrade/executor/src/firmware_check_executor.cpp @@ -25,7 +25,6 @@ #include "firmware_log.h" #include "firmware_status_cache.h" #include "firmware_update_helper.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/executor/src/firmware_download_executor.cpp b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp index 0f316c7e4a909915cd1ee57f18aa98adc76a7437..9519a1e5b70a1fd2eb4e064c557be30dc0ab6464 100644 --- a/services/firmware/upgrade/executor/src/firmware_download_executor.cpp +++ b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp @@ -29,7 +29,6 @@ #include "firmware_update_helper.h" #include "progress_thread.h" #include "string_utils.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/executor/src/firmware_install_executor.cpp b/services/firmware/upgrade/executor/src/firmware_install_executor.cpp index 815c2d63dff948d4825d108039bec6bfcca80f56..96219b0b69014fc3095aed32534eff5e332a7100 100644 --- a/services/firmware/upgrade/executor/src/firmware_install_executor.cpp +++ b/services/firmware/upgrade/executor/src/firmware_install_executor.cpp @@ -17,14 +17,13 @@ #include +#include "event_id.h" #include "firmware_callback_utils.h" #include "firmware_component_operator.h" #include "firmware_constant.h" #include "firmware_install_factory.h" #include "firmware_log.h" #include "firmware_task_operator.h" -#include "firmware_update_helper.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/flow/include/firmware_flow_manager.h b/services/firmware/upgrade/flow/include/firmware_flow_manager.h index f297c964a6e1914a0e6d502842b49e2ba78f0d26..1940a9c0a7600b931fe8334d933046f161979c2d 100644 --- a/services/firmware/upgrade/flow/include/firmware_flow_manager.h +++ b/services/firmware/upgrade/flow/include/firmware_flow_manager.h @@ -16,11 +16,11 @@ #ifndef FIRMWARE_FLOW_MANAGER_H #define FIRMWARE_FLOW_MANAGER_H -#include "update_helper.h" #include "firmware_common.h" #include "firmware_component.h" #include "firmware_iexecute_mode.h" #include "firmware_iexecutor.h" +#include "progress.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/flow/include/firmware_manager.h b/services/firmware/upgrade/flow/include/firmware_manager.h index 4b6729409d809b10998fc10cbd76e83a8677d5e6..5adfaab2e7588e7d7d1f55aa18da13fc64261ff6 100644 --- a/services/firmware/upgrade/flow/include/firmware_manager.h +++ b/services/firmware/upgrade/flow/include/firmware_manager.h @@ -18,7 +18,9 @@ #include "singleton.h" +#include "business_error.h" #include "constant.h" +#include "download_options.h" #include "firmware_common.h" #include "firmware_flow_manager.h" #include "firmware_result_process.h" @@ -26,7 +28,7 @@ #include "device_adapter.h" #include "firmware_preferences_utils.h" #include "schedule_task.h" -#include "update_helper.h" +#include "upgrade_options.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/flow/src/firmware_manager.cpp b/services/firmware/upgrade/flow/src/firmware_manager.cpp index f53c19e116ab6d710af2bfbc3ab6752992df4e51..8eed522177d7e707e0886cfffc232a8705edb6d1 100644 --- a/services/firmware/upgrade/flow/src/firmware_manager.cpp +++ b/services/firmware/upgrade/flow/src/firmware_manager.cpp @@ -22,7 +22,9 @@ #include "config_parse.h" #include "dupdate_errno.h" #include "dupdate_upgrade_helper.h" +#ifdef NETMANAGER_BASE_ENABLE #include "dupdate_net_manager.h" +#endif #include "file_utils.h" #include "firmware_callback_utils.h" #include "firmware_changelog_utils.h" @@ -44,7 +46,6 @@ #include "startup_schedule.h" #include "string_utils.h" #include "time_utils.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { @@ -314,6 +315,7 @@ void FirmwareManager::HandleBootComplete() void FirmwareManager::HandleNetChanged() { FIRMWARE_LOGI("HandleNetChanged"); + #ifdef NETMANAGER_BASE_ENABLE if (!DelayedSingleton::GetInstance()->IsNetAvailable()) { FIRMWARE_LOGE("HandleNetChanged network not available."); ProgressThread::isNoNet_ = true; @@ -342,6 +344,7 @@ void FirmwareManager::HandleNetChanged() DoAutoDownload(task); } } + #endif } // updater调用后正常启动 diff --git a/services/firmware/upgrade/install/include/firmware_install.h b/services/firmware/upgrade/install/include/firmware_install.h index 09db3585f2a72a3a2b523dd275806522d1c9359c..cf6bdbcda268f8282b6a0174b5b5b453493aca15 100644 --- a/services/firmware/upgrade/install/include/firmware_install.h +++ b/services/firmware/upgrade/install/include/firmware_install.h @@ -20,9 +20,10 @@ #include #include +#include "error_message.h" #include "firmware_common.h" #include "firmware_component.h" -#include "update_helper.h" +#include "progress.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/install/include/firmware_sys_installer_install.h b/services/firmware/upgrade/install/include/firmware_sys_installer_install.h index 65954ee77d48360ece157a668e1b5eb09161d4a4..ac59770182030ff94bbfc7e5bc9b56ccc7149552 100644 --- a/services/firmware/upgrade/install/include/firmware_sys_installer_install.h +++ b/services/firmware/upgrade/install/include/firmware_sys_installer_install.h @@ -20,7 +20,6 @@ #include "firmware_component.h" #include "firmware_install.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/install/src/firmware_sys_installer_install.cpp b/services/firmware/upgrade/install/src/firmware_sys_installer_install.cpp index a6a50e695ef0e3d74f39ab019d34aa10261b9498..826e131332c323b08b0de742a39d7f25e4cad57e 100644 --- a/services/firmware/upgrade/install/src/firmware_sys_installer_install.cpp +++ b/services/firmware/upgrade/install/src/firmware_sys_installer_install.cpp @@ -43,14 +43,14 @@ bool SysInstallerInstall::PerformInstall(const std::vector &c if (componentList.empty()) { return false; } - int32_t successCount = 0; + uint32_t successCount = 0; for (const auto &component : componentList) { onInstallCallback_.onFirmwareStatus(UpgradeStatus::INSTALLING); if (DoSysInstall(component) == OHOS_SUCCESS) { successCount ++; } } - return successCount == componentList.size(); + return successCount == static_cast(componentList.size()); } int32_t SysInstallerInstall::DoSysInstall(const FirmwareComponent &firmwareComponent) diff --git a/services/firmware/upgrade/install/src/firmware_updater_install.cpp b/services/firmware/upgrade/install/src/firmware_updater_install.cpp index 87b7f1db3e5abfc02cb8e76ee6800ca26b9abb47..0941dfa4fb4d58c8a3376b0b312ff92cc6bd1743 100644 --- a/services/firmware/upgrade/install/src/firmware_updater_install.cpp +++ b/services/firmware/upgrade/install/src/firmware_updater_install.cpp @@ -28,7 +28,6 @@ #include "firmware_constant.h" #include "firmware_log.h" #include "firmware_update_helper.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/mode/include/firmware_download_mode.h b/services/firmware/upgrade/mode/include/firmware_download_mode.h index ca2499cba74dfed94b4715d7b7aa747117bc8da6..018f5debe8ab7bb47ac7e375abbc9cc4766a0ae1 100644 --- a/services/firmware/upgrade/mode/include/firmware_download_mode.h +++ b/services/firmware/upgrade/mode/include/firmware_download_mode.h @@ -16,13 +16,16 @@ #ifndef FIRMWARE_DOWNLOAD_MODE_H #define FIRMWARE_DOWNLOAD_MODE_H +#include "business_error.h" +#include "device_adapter.h" +#include "download_options.h" +#include "error_message.h" #include "firmware_common.h" #include "firmware_download_data_processor.h" #include "firmware_iexecute_mode.h" #include "firmware_install_data_processor.h" #include "firmware_task.h" -#include "device_adapter.h" -#include "update_helper.h" +#include "progress.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/mode/include/firmware_iexecute_mode.h b/services/firmware/upgrade/mode/include/firmware_iexecute_mode.h index a0a2356b561707c5b1f76adf053b8c41323033ff..7572b2df4b1c3f514de0984241adc16eb715f46b 100644 --- a/services/firmware/upgrade/mode/include/firmware_iexecute_mode.h +++ b/services/firmware/upgrade/mode/include/firmware_iexecute_mode.h @@ -16,10 +16,14 @@ #ifndef FIRMWARE_IEXECUTE_MODE_H #define FIRMWARE_IEXECUTE_MODE_H +#include "business_error.h" +#include "check_result.h" +#include "download_options.h" #include "firmware_common.h" #include "firmware_component.h" #include "firmware_iexecutor.h" -#include "update_helper.h" +#include "progress.h" +#include "upgrade_options.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/mode/include/firmware_install_apply_mode.h b/services/firmware/upgrade/mode/include/firmware_install_apply_mode.h index e102de466207f274a99ceb468eeeae07eb55be01..b0512dfcbea8d6ebd08223056843f213d5323e9e 100644 --- a/services/firmware/upgrade/mode/include/firmware_install_apply_mode.h +++ b/services/firmware/upgrade/mode/include/firmware_install_apply_mode.h @@ -16,14 +16,15 @@ #ifndef FIRMWARE_INSTALL_APPLY_MODE_H #define FIRMWARE_INSTALL_APPLY_MODE_H +#include "business_error.h" +#include "device_adapter.h" #include "firmware_common.h" #include "firmware_download_data_processor.h" #include "firmware_iexecute_mode.h" #include "firmware_install_data_processor.h" #include "firmware_preferences_utils.h" #include "firmware_task.h" -#include "device_adapter.h" -#include "update_helper.h" +#include "upgrade_options.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/mode/include/firmware_manual_check_mode.h b/services/firmware/upgrade/mode/include/firmware_manual_check_mode.h index 89d278937195179e8d1256e2e2465c4aa2bc8ad8..3ec40aa17300eb78a8713bc678abb189005349a4 100644 --- a/services/firmware/upgrade/mode/include/firmware_manual_check_mode.h +++ b/services/firmware/upgrade/mode/include/firmware_manual_check_mode.h @@ -16,8 +16,8 @@ #ifndef FIRMWARE_MANUAL_CHECK_MODE_H #define FIRMWARE_MANUAL_CHECK_MODE_H +#include "business_error.h" #include "firmware_check_data_processor.h" - #include "firmware_common.h" #include "firmware_component.h" #include "firmware_iexecute_mode.h" diff --git a/services/firmware/upgrade/mode/src/firmware_download_mode.cpp b/services/firmware/upgrade/mode/src/firmware_download_mode.cpp index 638e99c1e64a8361d0f685a998f69538b6e4cf13..316904711cc348816b50f9a40e32507d076609d5 100644 --- a/services/firmware/upgrade/mode/src/firmware_download_mode.cpp +++ b/services/firmware/upgrade/mode/src/firmware_download_mode.cpp @@ -26,7 +26,6 @@ #include "firmware_status_cache.h" #include "firmware_task_operator.h" #include "firmware_update_helper.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/mode/src/firmware_download_mode_empty.cpp b/services/firmware/upgrade/mode/src/firmware_download_mode_empty.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dad111bcd745658593a016fe8049a1376ec70206 --- /dev/null +++ b/services/firmware/upgrade/mode/src/firmware_download_mode_empty.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "firmware_download_mode.h" + +#include "firmware_constant.h" +#include "firmware_log.h" + +namespace OHOS { +namespace UpdateEngine { +FirmwareStep FirmwareDownloadMode::GetNextStep(FirmwareStep step) +{ + FIRMWARE_LOGI("GetNextStep %{public}d", static_cast(step)); + return step; +} + +FirmwareStep FirmwareDownloadMode::GetStepAfterInit() +{ + return FirmwareStep::DOWNLOAD_STEP; +} + +FirmwareStep FirmwareDownloadMode::GetStepAfterDownload() +{ + FIRMWARE_LOGI("GetStepAfterDownload downloadOptions %{public}d", CAST_INT(downloadOptions_.order)); + return FirmwareStep::COMPLETE; +} + +void FirmwareDownloadMode::DownloadPauseProcess(const FirmwareTask &task, const ErrorMessage &errorMessage) +{ + FIRMWARE_LOGI("GetStepAfterDownload download pause"); +} + +void FirmwareDownloadMode::DownloadFailProcess(const FirmwareTask &task, const ErrorMessage &errorMessage) +{ + FIRMWARE_LOGI("GetStepAfterDownload download fail"); +} + +void FirmwareDownloadMode::DownloadCancelProcess(const FirmwareTask &task, const ErrorMessage &errorMessage) +{ + FIRMWARE_LOGI("GetStepAfterDownload download cancel"); +} + +void FirmwareDownloadMode::DownloadSucessProcess(const FirmwareTask &task, const ErrorMessage &errorMessage) +{ + FIRMWARE_LOGI("GetStepAfterDownload download success"); +} + +void FirmwareDownloadMode::GetTask() +{ + FIRMWARE_LOGI("FirmwareDownloadMode::GetTask"); + businessError_.Build(CallResult::FAIL, "no task!"); +} + +void FirmwareDownloadMode::HandleComplete() +{ + FIRMWARE_LOGI("FirmwareDownloadMode::HandleComplete"); + onExecuteFinishCallback_(); +} + +DownloadOptions FirmwareDownloadMode::GetDownloadOptions() +{ + return downloadOptions_; +} + +void FirmwareDownloadMode::SetDownloadProgress(const Progress &progress) +{ + downloadDataProcessor_.SetDownloadProgress(progress); +} +} // namespace UpdateEngine +} // namespace OHOS \ No newline at end of file diff --git a/services/firmware/upgrade/mode/src/firmware_install_apply_mode.cpp b/services/firmware/upgrade/mode/src/firmware_install_apply_mode.cpp index 513aa5abc2e9859aeab17c08d87e92db27067e64..ae0827d093fd5ab5778b20fab305068fd42e9232 100644 --- a/services/firmware/upgrade/mode/src/firmware_install_apply_mode.cpp +++ b/services/firmware/upgrade/mode/src/firmware_install_apply_mode.cpp @@ -30,7 +30,6 @@ #include "firmware_status_cache.h" #include "firmware_task_operator.h" #include "firmware_update_helper.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/mode/src/firmware_install_apply_mode_empty.cpp b/services/firmware/upgrade/mode/src/firmware_install_apply_mode_empty.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ded4df2eb6ca716c6707231cbbfdd9c33f769411 --- /dev/null +++ b/services/firmware/upgrade/mode/src/firmware_install_apply_mode_empty.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "firmware_install_apply_mode.h" + +#include "firmware_constant.h" +#include "firmware_log.h" + +namespace OHOS { +namespace UpdateEngine { +FirmwareStep FirmwareInstallApplyMode::GetNextStep(FirmwareStep step) +{ + FIRMWARE_LOGI("GetNextStep %{public}d", static_cast(step)); + return step; +} + +FirmwareStep FirmwareInstallApplyMode::GetStepAfterInit() +{ + return FirmwareStep::COMPLETE; +} + +FirmwareStep FirmwareInstallApplyMode::GetStepForInstallAndApplyOrder() +{ + return FirmwareStep::INSTALL_STEP; +} + +bool FirmwareInstallApplyMode::IsAllowInstall() +{ + return true; +} + +bool FirmwareInstallApplyMode::IsUpgradeFilesReady() +{ + return true; +} + +FirmwareStep FirmwareInstallApplyMode::GetStepAfterInstall() +{ + return FirmwareStep::COMPLETE; +} + +FirmwareStep FirmwareInstallApplyMode::GetStepAfterApply() +{ + return FirmwareStep::COMPLETE; +} + +void FirmwareInstallApplyMode::GetTask() +{ + FIRMWARE_LOGI("FirmwareInstallApplyMode::GetTask"); + businessError_.Build(CallResult::FAIL, "no task!"); +} + +void FirmwareInstallApplyMode::HandleComplete() +{ + onExecuteFinishCallback_(); +} + +UpgradeOptions FirmwareInstallApplyMode::GetUpgradeOptions() +{ + return upgradeOptions_; +} + +InstallType FirmwareInstallApplyMode::GetInstallType() +{ + return installType_; +} + +void FirmwareInstallApplyMode::SetInstallResult(const InstallCallbackInfo &installCallbackInfo) +{ + installStepDataProcessor_.SetInstallResult(installCallbackInfo); +} + +void FirmwareInstallApplyMode::SetApplyResult(bool isSuccess) +{ + FIRMWARE_LOGI("SetApplyResult isSuccess: %{public}s", isSuccess ? "success" : "fail"); +} +} // namespace UpdateEngine +} // namespace OHOS \ No newline at end of file diff --git a/services/firmware/upgrade/mode/src/firmware_manual_check_mode.cpp b/services/firmware/upgrade/mode/src/firmware_manual_check_mode.cpp index 2d72310c7269f306d40cde95a50ac597ea966753..7d37a03fb4df3125e1e0aa6a97521d2e1170dd3c 100644 --- a/services/firmware/upgrade/mode/src/firmware_manual_check_mode.cpp +++ b/services/firmware/upgrade/mode/src/firmware_manual_check_mode.cpp @@ -15,6 +15,7 @@ #include "firmware_manual_check_mode.h" +#include "check_result.h" #include "dupdate_errno.h" #include "dupdate_net_manager.h" #include "firmware_callback_utils.h" @@ -26,7 +27,7 @@ #include "firmware_status_cache.h" #include "firmware_task.h" #include "firmware_task_operator.h" -#include "update_helper.h" +#include "search_status.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/upgrade/mode/src/firmware_manual_check_mode_empty.cpp b/services/firmware/upgrade/mode/src/firmware_manual_check_mode_empty.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5ed475658a830a6f2804cdbe7211fbcb883cc0af --- /dev/null +++ b/services/firmware/upgrade/mode/src/firmware_manual_check_mode_empty.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "firmware_manual_check_mode.h" + +#include "firmware_constant.h" +#include "firmware_log.h" + +namespace OHOS { +namespace UpdateEngine { +FirmwareStep FirmwareManualCheckMode::GetNextStep(FirmwareStep step) +{ + FIRMWARE_LOGI("GetNextStep %{public}d", static_cast(step)); + return step; +} + +FirmwareStep FirmwareManualCheckMode::GetStepAfterInit() +{ + return FirmwareStep::CHECK_STEP; +} + +FirmwareStep FirmwareManualCheckMode::GetStepAfterCheck() +{ + return FirmwareStep::COMPLETE; +} + +void FirmwareManualCheckMode::SetCheckResult( + CheckStatus status, const Duration &duration, const std::vector &componentList, + const CheckAndAuthInfo &checkAndAuthInfo) +{ + FIRMWARE_LOGI("FirmwareManualCheckMode::SetCheckResult %{public}d", static_cast(status)); +} + +void FirmwareManualCheckMode::HandleComplete() +{ + FIRMWARE_LOGI("FirmwareManualCheckMode::HandleComplete"); +} +} // namespace UpdateEngine +} // namespace OHOS \ No newline at end of file diff --git a/services/firmware/upgrade/status/include/firmware_result_process.h b/services/firmware/upgrade/status/include/firmware_result_process.h index a5b240af5de861d0e812090bd6a67edf59aa6cdc..fa9942715b23cd6a65c351499d963d8325a4051c 100644 --- a/services/firmware/upgrade/status/include/firmware_result_process.h +++ b/services/firmware/upgrade/status/include/firmware_result_process.h @@ -71,6 +71,7 @@ private: const std::vector &components); UpdateResultCode HandleFileResults(std::map &resultMap, const std::vector &components); + void ParseResult(const std::vector &results, std::string &value, size_t index); }; } // namespace UpdateEngine } // namespace OHOS diff --git a/services/firmware/upgrade/status/include/firmware_status_cache.h b/services/firmware/upgrade/status/include/firmware_status_cache.h index 8b19781c8eb91c0b1c504faad003d471eb3a7d55..4c60a414efbd5f761ac8600d434e0e209cc452da 100644 --- a/services/firmware/upgrade/status/include/firmware_status_cache.h +++ b/services/firmware/upgrade/status/include/firmware_status_cache.h @@ -28,7 +28,7 @@ class FirmwareStatusCache : public DelayedSingleton { public: bool IsChecking(); void SetIsChecking(bool isChecking); - + bool IsDownloadTriggered(); private: std::shared_ptr statusCache_ = nullptr; }; diff --git a/services/firmware/upgrade/status/src/firmware_result_process.cpp b/services/firmware/upgrade/status/src/firmware_result_process.cpp index 837079d7cebc1b89023fd771eb3978707db657df..7bcc39234964f9850b6d4fcd09eeaf73cc6cf275 100644 --- a/services/firmware/upgrade/status/src/firmware_result_process.cpp +++ b/services/firmware/upgrade/status/src/firmware_result_process.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -37,6 +38,18 @@ static const std::string UPDATER_RESULT_FILE = "/data/updater/updater_result"; constexpr int32_t SYMBOL_LENGTH = 1; constexpr uint32_t UPDATE_SUCCESSED = 1; constexpr uint32_t UPDATE_FAILED = 2; +constexpr size_t PKG_PATH_INDEX = 0; +constexpr size_t RESULT_INDEX = 1; +constexpr size_t REASON_INDEX = 2; + +void FirmwareResultProcess::ParseResult(const std::vector &results, std::string &value, size_t index) +{ + if (index >= results.size()) { + return; + } + value = results[index]; + StringUtils::Trim(value); +} UpdateResultCode FirmwareResultProcess::GetUpdaterResult(const std::vector &components, std::map &resultMap) @@ -93,31 +106,32 @@ UpdateResult FirmwareResultProcess::CompareVersion(const FirmwareComponent &comp void FirmwareResultProcess::ParseUpdaterResultRecord(const std::string &resultLine, std::map &resultMap) { + FIRMWARE_LOGE("ParseUpdaterResultRecord"); if (resultLine.empty()) { FIRMWARE_LOGE("resultLine is null"); return; } - UpdateResult updaterReason; - std::string::size_type verticalPlace = resultLine.find_first_of("|"); - std::string resultAndReason; - if (verticalPlace == std::string::npos) { - updaterReason.spath = resultLine; - } else { - updaterReason.spath = resultLine.substr(0, verticalPlace); - resultAndReason = resultLine.substr(verticalPlace + SYMBOL_LENGTH); + UpdateResult updateResult; + std::vector results; + std::stringstream stringStream(resultLine); + std::string token; + while (std::getline(stringStream, token, '|')) { + results.push_back(token); } - std::string::size_type colonPlace = resultAndReason.find_first_of(":"); - if (colonPlace == std::string::npos) { - updaterReason.result = resultAndReason; - } else { - updaterReason.result = resultAndReason.substr(0, colonPlace); - updaterReason.reason = resultAndReason.substr(colonPlace + SYMBOL_LENGTH); + ParseResult(results, updateResult.spath, PKG_PATH_INDEX); + ParseResult(results, updateResult.result, RESULT_INDEX); + ParseResult(results, updateResult.reason, REASON_INDEX); + + auto colonPlace = updateResult.result.find_first_of(":"); + if (colonPlace != std::string::npos) { + updateResult.result = updateResult.result.substr(0, colonPlace); + updateResult.reason = results[RESULT_INDEX].substr(colonPlace + SYMBOL_LENGTH); } - StringUtils::Trim(updaterReason.spath); - StringUtils::Trim(updaterReason.result); - StringUtils::Trim(updaterReason.reason); - resultMap.emplace(std::make_pair(updaterReason.spath, updaterReason)); + StringUtils::Trim(updateResult.spath); + StringUtils::Trim(updateResult.result); + StringUtils::Trim(updateResult.reason); + resultMap.emplace(std::make_pair(updateResult.spath, updateResult)); } void FirmwareResultProcess::HandleFileError(std::map &resultMap, diff --git a/services/firmware/upgrade/status/src/firmware_status_cache.cpp b/services/firmware/upgrade/status/src/firmware_status_cache.cpp index 8b436a2c1fa4e485d204611d9dfad7113bec5a76..b5abc046312ac20717ec1c8a0c9b2f1258cd9f99 100644 --- a/services/firmware/upgrade/status/src/firmware_status_cache.cpp +++ b/services/firmware/upgrade/status/src/firmware_status_cache.cpp @@ -46,5 +46,13 @@ void FirmwareStatusCache::SetIsChecking(bool isChecking) } statusCache_->SetIsChecking(isChecking); } + +bool FirmwareStatusCache::IsDownloadTriggered() +{ + if (statusCache_ == nullptr) { + return false; + } + return statusCache_->IsDownloadTriggered(); +} } // namespace UpdateEngine } // namespace OHOS diff --git a/services/firmware/utils/include/firmware_check_analyze_utils.h b/services/firmware/utils/include/firmware_check_analyze_utils.h index e56d9c1d34802562671690f91dd27bb379053781..bb676d410c9ad59801fb7823ade20f6e40ccb570 100644 --- a/services/firmware/utils/include/firmware_check_analyze_utils.h +++ b/services/firmware/utils/include/firmware_check_analyze_utils.h @@ -21,8 +21,8 @@ #include "singleton.h" +#include "dupdate_json_utils.h" #include "firmware_common.h" -#include "json_utils.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/firmware/utils/src/firmware_check_analyze_utils.cpp b/services/firmware/utils/src/firmware_check_analyze_utils.cpp index 7fdb7d1616d37c692f8bc10b851d10a917aab450..a5de85c0a04ea0a52fc95c19bdf6e30691505a95 100644 --- a/services/firmware/utils/src/firmware_check_analyze_utils.cpp +++ b/services/firmware/utils/src/firmware_check_analyze_utils.cpp @@ -22,14 +22,13 @@ #include #include "constant.h" +#include "dupdate_json_utils.h" #include "file_utils.h" #include "firmware_combine_version_utils.h" #include "firmware_constant.h" #include "firmware_log.h" #include "firmware_preferences_utils.h" -#include "json_utils.h" #include "string_utils.h" -#include "update_helper.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/startup/manage/include/schedule_config.h b/services/startup/manage/include/schedule_config.h index 48d98116084f96d1f19ee2848cb7eb357d3bcfd2..66ed1100bf58e6f8484b8c0b2b0e4c7c178077f1 100644 --- a/services/startup/manage/include/schedule_config.h +++ b/services/startup/manage/include/schedule_config.h @@ -16,7 +16,7 @@ #ifndef SCHEDULE_CONFIG_H #define SCHEDULE_CONFIG_H -#include "json_utils.h" +#include "dupdate_json_utils.h" #include "startup_constant.h" namespace OHOS { diff --git a/services/utils/include/dupdate_inet_observer.h b/services/utils/include/dupdate_inet_observer.h index c5d33ec45819b328d5ddfbda527ab885ca33522a..ad6ca08a599f6a0262a373d3326fbf1be013ac2e 100644 --- a/services/utils/include/dupdate_inet_observer.h +++ b/services/utils/include/dupdate_inet_observer.h @@ -18,7 +18,7 @@ #include -#include "update_helper.h" +#include "network_type.h" namespace OHOS { namespace UpdateEngine { diff --git a/services/utils/include/dupdate_net_manager.h b/services/utils/include/dupdate_net_manager.h index 43a462a9ad0faf20a8b269769c74862ba7aef59e..2c6c5b4e3d2b3d07be0e7842244179669c877217 100644 --- a/services/utils/include/dupdate_net_manager.h +++ b/services/utils/include/dupdate_net_manager.h @@ -18,10 +18,13 @@ #include "singleton.h" +#include #include #include "dupdate_inet_observer.h" +#ifdef NETMANAGER_BASE_ENABLE #include "dupdate_net_observer.h" +#endif namespace OHOS { namespace UpdateEngine { @@ -49,7 +52,9 @@ public: private: bool IsBaseNetType(NetType netType); +#ifdef NETMANAGER_BASE_ENABLE sptr observer_ = nullptr; +#endif std::mutex netChangeMutex_; NetType netType_ = NetType::NO_NET; std::map netChangeCallbackMap_; diff --git a/test/fuzztest/updateservicecancel_fuzzer/updateservicecancel_fuzzer.cpp b/test/fuzztest/updateservicecancel_fuzzer/updateservicecancel_fuzzer.cpp index db62e4476b89422d4c9cfc99613d1b6c66d68f65..55a9d3bd02d8ff4b16982361666dc7ace9d74801 100644 --- a/test/fuzztest/updateservicecancel_fuzzer/updateservicecancel_fuzzer.cpp +++ b/test/fuzztest/updateservicecancel_fuzzer/updateservicecancel_fuzzer.cpp @@ -15,8 +15,6 @@ #include "updateservicecancel_fuzzer.h" -#include "update_helper.h" - using namespace OHOS::UpdateEngine; namespace OHOS {