diff --git a/foundations/model/include/call_result.h b/foundations/model/include/call_result.h index 5832b888c91c772f2cbc85612776dc7f188eb89d..ac5acda8fe665167cf30157c0d27bb4d95a88789 100644 --- a/foundations/model/include/call_result.h +++ b/foundations/model/include/call_result.h @@ -37,8 +37,7 @@ enum class CallResult { TIME_OUT = 402, DB_ERROR = 501, IO_ERROR = 502, - NET_ERROR = 503, - CANCEL_ERROR = 504 + NET_ERROR = 503 }; constexpr int32_t INT_CALL_SUCCESS = CAST_INT(CallResult::SUCCESS); diff --git a/frameworks/js/napi/update/common/src/client_helper.cpp b/frameworks/js/napi/update/common/src/client_helper.cpp index 19dd60afa08aab4bcd0b9c46f462f916e511770f..fa060de7e0e301b7b5dce51a3a73d8a876cc6863 100644 --- a/frameworks/js/napi/update/common/src/client_helper.cpp +++ b/frameworks/js/napi/update/common/src/client_helper.cpp @@ -161,7 +161,6 @@ void BuildVersionComponents(napi_env env, napi_value &obj, const std::vector> otaTypeList = { - DECLARE_ENUM_PROPERTY(OtaMode::REGULAR), - DECLARE_ENUM_PROPERTY(OtaMode::STREAM), - DECLARE_ENUM_PROPERTY(OtaMode::AB), - DECLARE_ENUM_PROPERTY(OtaMode::AB_STREAM) - }; - NapiCommonUtils::CreateProperty(env, exports, "OtaMode", otaTypeList); -} - void DefineProperty::DefineNetType(napi_env env, napi_value exports) { std::vector> netTypeList = { diff --git a/interfaces/inner_api/feature/update/model/common/upgrade_status.h b/interfaces/inner_api/feature/update/model/common/upgrade_status.h index 9a67ce50ec24734693b597728a59263905af79ca..503fcc3e4562b0f84ac165d44cf70d57050ee1a0 100644 --- a/interfaces/inner_api/feature/update/model/common/upgrade_status.h +++ b/interfaces/inner_api/feature/update/model/common/upgrade_status.h @@ -42,7 +42,6 @@ enum class UpgradeStatus { INSTALLING = 80, INSTALL_FAIL, INSTALL_SUCCESS, - INSTALL_PAUSE, UPDATING = 90, UPDATE_FAIL, UPDATE_SUCCESS, diff --git a/interfaces/inner_api/feature/update/model/event/event_id.h b/interfaces/inner_api/feature/update/model/event/event_id.h index a50dd0c934bef33bec4387f81fef8950a81cc7bf..e7675d40858964b48c338765ae2bb2b6a645106d 100644 --- a/interfaces/inner_api/feature/update/model/event/event_id.h +++ b/interfaces/inner_api/feature/update/model/event/event_id.h @@ -38,7 +38,6 @@ enum class EventId { EVENT_APPLY_START, EVENT_UPGRADE_SUCCESS, EVENT_UPGRADE_FAIL, - EVENT_UPGRADE_PAUSE, EVENT_AUTH_START, EVENT_AUTH_SUCCESS, EVENT_DOWNLOAD_CANCEL, diff --git a/interfaces/inner_api/feature/update/model/message_parcel/src/message_parcel_helper.cpp b/interfaces/inner_api/feature/update/model/message_parcel/src/message_parcel_helper.cpp index 6e2f93c724b9696a81a2d6c9b8aea06b7c59cd8a..30fae43e3e412f666640e0e3e892bf6ad82b0856 100644 --- a/interfaces/inner_api/feature/update/model/message_parcel/src/message_parcel_helper.cpp +++ b/interfaces/inner_api/feature/update/model/message_parcel/src/message_parcel_helper.cpp @@ -151,7 +151,6 @@ void ReadVersionComponents(MessageParcel &reply, std::vector & versionComponent.innerVersion = Str16ToStr8(reply.ReadString16()); versionComponent.size = static_cast(reply.ReadUint64()); versionComponent.effectiveMode = static_cast(reply.ReadUint32()); - versionComponent.otaMode = static_cast(reply.ReadUint32()); versionComponent.descriptionInfo.descriptionType = static_cast(reply.ReadUint32()); versionComponent.descriptionInfo.content = Str16ToStr8(reply.ReadString16()); @@ -172,7 +171,6 @@ void WriteVersionComponents(MessageParcel &data, const std::vectorinnerVersion)); data.WriteUint64(static_cast(versionComponent->size)); data.WriteUint32(static_cast(versionComponent->effectiveMode)); - data.WriteUint32(static_cast(versionComponent->otaMode)); data.WriteUint32(static_cast(versionComponent->descriptionInfo.descriptionType)); data.WriteString16(Str8ToStr16(versionComponent->descriptionInfo.content)); 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 index 4163af3ae10e826922c16fab9e75ebad0ec7ce95..d7fad5bbbee0c4104bc070f745b22e748a6510f6 100644 --- 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 @@ -57,7 +57,6 @@ const std::map g_taskBodyTemplateMap = { { EventId::EVENT_APPLY_START, VERSION_DIGEST_INFO }, { EventId::EVENT_UPGRADE_SUCCESS, VERSION_DIGEST_INFO | VERSION_COMPONENT | SUB_STATUS }, { EventId::EVENT_UPGRADE_FAIL, VERSION_DIGEST_INFO | VERSION_COMPONENT | ERROR_MESSAGE }, - { EventId::EVENT_UPGRADE_PAUSE, VERSION_DIGEST_INFO | UPGRADE_STATUS | PROGRESS | 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 }, diff --git a/interfaces/inner_api/feature/update/model/version_info/ota_mode.h b/interfaces/inner_api/feature/update/model/version_info/ota_mode.h deleted file mode 100755 index 8946d4479d51a7d2fe0d6189fc31c58acf28553a..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/feature/update/model/version_info/ota_mode.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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_OTA_TYPE_H -#define UPDATE_SERVICE_OTA_TYPE_H - -namespace OHOS::UpdateEngine { -enum class OtaMode { - REGULAR = 0, - STREAM = 1, // 1 << 0 - AB = 2, // 1 << 1 - AB_STREAM = 3 // STREAM | AB -}; -} // namespace OHOS::UpdateEngine -#endif // UPDATE_SERVICE_OTA_TYPE_H diff --git a/interfaces/inner_api/feature/update/model/version_info/ota_type.h b/interfaces/inner_api/feature/update/model/version_info/ota_type.h deleted file mode 100755 index 8946d4479d51a7d2fe0d6189fc31c58acf28553a..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/feature/update/model/version_info/ota_type.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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_OTA_TYPE_H -#define UPDATE_SERVICE_OTA_TYPE_H - -namespace OHOS::UpdateEngine { -enum class OtaMode { - REGULAR = 0, - STREAM = 1, // 1 << 0 - AB = 2, // 1 << 1 - AB_STREAM = 3 // STREAM | AB -}; -} // namespace OHOS::UpdateEngine -#endif // UPDATE_SERVICE_OTA_TYPE_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 index f442a0a46515787db462b061fd19368316ce90e9..7a11eff8c3f55e05dfcd9d552edb4308f5e1b236 100644 --- 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 @@ -27,7 +27,6 @@ JsonBuilder VersionComponent::GetJsonBuilder() .Append("innerVersion", innerVersion) .Append("size", static_cast(size)) .Append("effectiveMode", static_cast(effectiveMode)) - .Append("otaMode", static_cast(otaMode)) .Append("descriptionInfo", descriptionInfo.GetJsonBuilder()) .Append("componentExtra", componentExtra, true) .Append("}"); 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 index 69335adec342ec9a30b7a1e6c882bc8fe0a6683f..12be40dad0755093fbe3370abce9252bc73a4473 100644 --- a/interfaces/inner_api/feature/update/model/version_info/version_component.h +++ b/interfaces/inner_api/feature/update/model/version_info/version_component.h @@ -25,7 +25,6 @@ #include "effective_mode.h" #include "update_define.h" #include "upgrade_action.h" -#include "ota_mode.h" namespace OHOS::UpdateEngine { struct VersionComponent : public BaseJsonStruct { @@ -36,7 +35,6 @@ struct VersionComponent : public BaseJsonStruct { std::string innerVersion; size_t size = 0; size_t effectiveMode = static_cast(EffectiveMode::COLD); - size_t otaMode = static_cast(OtaMode::REGULAR); DescriptionInfo descriptionInfo; std::string componentExtra; diff --git a/services/core/ability/adapter/include/config_info.h b/services/core/ability/adapter/include/config_info.h index 1d224976c3a789058a68512e96f3b1c95cc852f0..1ca9addaebf813207f4675bcad289d12f100f256 100644 --- a/services/core/ability/adapter/include/config_info.h +++ b/services/core/ability/adapter/include/config_info.h @@ -23,7 +23,6 @@ namespace OHOS::UpdateEngine { struct ConfigInfo { std::string businessDomain; uint32_t abInstallTimeout = 1800; // 1800s - uint32_t streamInstallTimeout = 3600; // 3600s std::string moduleLibPath; }; } // OHOS::UpdateEngine diff --git a/services/core/ability/adapter/include/config_parse.h b/services/core/ability/adapter/include/config_parse.h index 40ff0efa990ba272a6936a6afe9b20846ec7fb1d..2f6ec8501e450387c9a47cbdf99bce4013cb5071 100644 --- a/services/core/ability/adapter/include/config_parse.h +++ b/services/core/ability/adapter/include/config_parse.h @@ -27,7 +27,6 @@ class ConfigParse : public DelayedSingleton { public: uint32_t GetAbInstallerTimeout(); - uint32_t GetStreamInstallerTimeout(); std::string GetModuleLibPath(); void LoadConfigInfo(); diff --git a/services/core/ability/adapter/src/config_parse.cpp b/services/core/ability/adapter/src/config_parse.cpp index 337cef8648b6090b479435fa5818c286393b66a6..24d4b5ae3f40910732bd0aba583e776f63d9c801 100644 --- a/services/core/ability/adapter/src/config_parse.cpp +++ b/services/core/ability/adapter/src/config_parse.cpp @@ -40,11 +40,6 @@ uint32_t ConfigParse::GetAbInstallerTimeout() return configInfo_.abInstallTimeout; } -uint32_t ConfigParse::GetStreamInstallerTimeout() -{ - return configInfo_.streamInstallTimeout; -} - std::string ConfigParse::GetModuleLibPath() { return configInfo_.moduleLibPath; @@ -70,7 +65,6 @@ void ConfigParse::LoadConfigInfo() } JsonUtils::GetValueAndSetTo(root, "abInstallTimeout", configInfo_.abInstallTimeout); - JsonUtils::GetValueAndSetTo(root, "streamInstallTimeout", configInfo_.streamInstallTimeout); JsonUtils::GetValueAndSetTo(root, "moduleLibPath", configInfo_.moduleLibPath); } } // 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 1731c69c12f37008c46ae45f4f33588ef209a13a..fa9ef4e6a69e06e78efdf6add882fb3d7fecd295 100644 --- a/services/core/ability/callback/src/base_callback_utils.cpp +++ b/services/core/ability/callback/src/base_callback_utils.cpp @@ -51,7 +51,6 @@ void BaseCallbackUtils::ProgressCallback(const std::string &versionDigestInfo, c {UpgradeStatus::INSTALLING, EventId::EVENT_UPGRADE_UPDATE}, {UpgradeStatus::INSTALL_FAIL, EventId::EVENT_UPGRADE_FAIL}, {UpgradeStatus::INSTALL_SUCCESS, EventId::EVENT_APPLY_WAIT}, - {UpgradeStatus::INSTALL_PAUSE, EventId::EVENT_UPGRADE_PAUSE}, {UpgradeStatus::UPDATING, EventId::EVENT_UPGRADE_UPDATE}, {UpgradeStatus::UPDATE_FAIL, EventId::EVENT_UPGRADE_FAIL}, {UpgradeStatus::UPDATE_SUCCESS, EventId::EVENT_UPGRADE_SUCCESS}, diff --git a/services/core/ability/model/include/ota_mode.h b/services/core/ability/model/include/ota_mode.h deleted file mode 100755 index 739adb6f644d7ea969ea4f55f179f03f7fddd772..0000000000000000000000000000000000000000 --- a/services/core/ability/model/include/ota_mode.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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_OTA_MODE_H -#define UPDATE_SERVICE_OTA_MODE_H - -namespace OHOS::UpdateEngine { -enum class OtaType { - REGULAR = 0, - STREAM = 1, // 1 << 0 - AB = 2, // 1 << 1 - AB_STREAM = 3 // STREAM | AB -}; -} // namespace OHOS::UpdateEngine -#endif // UPDATE_SERVICE_OTA_MODE_H diff --git a/services/core/ability/model/include/ota_type.h b/services/core/ability/model/include/ota_type.h deleted file mode 100755 index 739adb6f644d7ea969ea4f55f179f03f7fddd772..0000000000000000000000000000000000000000 --- a/services/core/ability/model/include/ota_type.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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_OTA_MODE_H -#define UPDATE_SERVICE_OTA_MODE_H - -namespace OHOS::UpdateEngine { -enum class OtaType { - REGULAR = 0, - STREAM = 1, // 1 << 0 - AB = 2, // 1 << 1 - AB_STREAM = 3 // STREAM | AB -}; -} // namespace OHOS::UpdateEngine -#endif // UPDATE_SERVICE_OTA_MODE_H diff --git a/services/core/ability/status_cache/include/status_cache.h b/services/core/ability/status_cache/include/status_cache.h index ed1ba8908c536d595fb9a6c67086428057785883..bdeb489952438c0fbc6feeaad2edd799f9115a78 100644 --- a/services/core/ability/status_cache/include/status_cache.h +++ b/services/core/ability/status_cache/include/status_cache.h @@ -30,7 +30,6 @@ public: bool IsChecking(); void SetIsChecking(bool isChecking); bool IsDownloadTriggered(); - bool IsUpgradeTriggered(); private: int64_t GetCurrentTime(); @@ -39,7 +38,6 @@ private: bool isChecking_ = false; int64_t lastCheckTime_ = -1; int64_t lastDownloadTime_ = -1; - int64_t lastUpgradeTime_ = -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 f831e0ce01040c4bac7e32bb3f7be07d69d3ae55..bf73d4643bb9765365d6e4aa20d325bc6cced8a9 100644 --- a/services/core/ability/status_cache/src/status_cache.cpp +++ b/services/core/ability/status_cache/src/status_cache.cpp @@ -62,21 +62,5 @@ bool StatusCache::IsDownloadTriggered() lastDownloadTime_ = TimeUtils::GetTimestampByMilliseconds(); return false; } - -bool StatusCache::IsUpgradeTriggered() -{ - if (lastUpgradeTime_ == -1) { - lastUpgradeTime_ = TimeUtils::GetTimestampByMilliseconds(); - return false; - } - - if (abs(TimeUtils::GetTimestampByMilliseconds() - lastUpgradeTime_) < Constant::MILLESECONDS) { - // 当前时间与上次下载时间间隔小于1秒钟,不允许重复触发下载 - ENGINE_LOGI("interval time within one seconds"); - return true; - } - lastUpgradeTime_ = TimeUtils::GetTimestampByMilliseconds(); - return false; -} } // namespace UpdateEngine } // namespace OHOS diff --git a/services/engine/engine_sa.gni b/services/engine/engine_sa.gni index 602a0f14091ebdf2189d5d7491947b68a408e75c..d081c7a650a7559fe43673b6764a10eb62df4953 100644 --- a/services/engine/engine_sa.gni +++ b/services/engine/engine_sa.gni @@ -44,7 +44,6 @@ sa_sources = [ "$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/progress_thread.cpp", - "$updateengine_root_path/services/engine/src/stream_progress_thread.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", diff --git a/services/engine/etc/dupdate_config.json b/services/engine/etc/dupdate_config.json index 3033d79d5a3177b2c3e36db1cd2652b842b640fe..1ec9bc1103b6935490679d9dbad1b49efd375139 100644 --- a/services/engine/etc/dupdate_config.json +++ b/services/engine/etc/dupdate_config.json @@ -1,6 +1,5 @@ { "pullupInterval": 14400, "idleCheckInterval": 180, - "abInstallTimeout":1800, - "streamInstallTimeout":3600 + "abInstallTimeout":1800 } diff --git a/services/engine/include/progress_thread.h b/services/engine/include/progress_thread.h index e97fcb0acb19ea5b67ae1db365b6d8f3b6976495..d0ec1807356b5d124b630961bc78f4cce681b851 100644 --- a/services/engine/include/progress_thread.h +++ b/services/engine/include/progress_thread.h @@ -34,7 +34,6 @@ namespace UpdateEngine { constexpr uint32_t DOWNLOAD_FINISH_PERCENT = 100; constexpr uint32_t DOWNLOAD_PERIOD_PERCENT = 1; constexpr int32_t TIMEOUT_FOR_DOWNLOAD = 600; -constexpr int32_t TIMEOUT_FOR_STREAM_DOWNLOAD = 3600; #ifndef UPDATER_UT constexpr int32_t TIMEOUT_FOR_CONNECT = 10; #else @@ -105,47 +104,6 @@ private: std::string downloadFileName_; bool DealAbnormal(uint32_t percent); }; - -// 缓冲区大小50KB -constexpr size_t BUFFER_SIZE = 50 * 1024; - -class StreamProgressThread : public ProgressThread { -public: - using ProgressCallback = std::function; - explicit StreamProgressThread(ProgressCallback callback) : ProgressThread(), callback_(callback) {} - ~StreamProgressThread() override - { - ProgressThread::QuitDownloadThread(); - } - - int32_t StartDownload(const std::string &url, const int64_t size, const int64_t recordPoint); - void StopDownload(); - - static size_t WriteFunc(uint8_t *ptr, size_t size, size_t nmemb, void *localData); - static int32_t DownloadProgress(const void *localData, - double dlTotal, double dlNow, double ulTotal, double ulNow); - -protected: - bool ProcessThreadExecute() override; - void ProcessThreadExit() override; - int32_t DownloadCallback(uint32_t percent, UpgradeStatus status, const std::string &error); - -private: - bool DealExitOrCancel(); - bool CheckFileSize(); - bool DownloadFile(); - -private: - Progress downloadProgress_ {}; - ProgressCallback callback_; - CURL *downloadHandle_ { nullptr }; - uint8_t buffer_[BUFFER_SIZE] = {0}; - size_t bufferPos_ = 0; // 缓冲区中的当前位置 - std::string serverUrl_; - int64_t totalFileSize_ = 0; // 总文件大小 - int64_t downloadedSize_ = 0; // 已下载大小 - std::atomic exitDownload_ { false }; -}; } // namespace UpdateEngine } // namespace OHOS #endif // UPDATER_THREAD_H diff --git a/services/engine/src/stream_progress_thread.cpp b/services/engine/src/stream_progress_thread.cpp deleted file mode 100755 index 8d1c5b58f0673b32d00f67a177a9c09feba0d48d..0000000000000000000000000000000000000000 --- a/services/engine/src/stream_progress_thread.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "progress_thread.h" - -#include -#include -#include - -#include "curl/curl.h" -#include "curl/easy.h" - -#include "firmware_common.h" -#include "isys_installer.h" -#include "securec.h" -#include "sys_installer_kits_impl.h" -#include "update_define.h" -#include "update_log.h" - -namespace OHOS { -namespace UpdateEngine { - -int32_t StreamProgressThread::StartDownload(const std::string &url, const int64_t size, const int64_t recordPoint) -{ - ENGINE_LOGI("StartDownload url = %s", url.c_str()); - serverUrl_ = url; - downloadedSize_ = recordPoint; - totalFileSize_ = size; - bufferPos_ = 0; - isCancel_ = false; - exitDownload_ = false; - (void)memset_s(buffer_, BUFFER_SIZE, 0, BUFFER_SIZE); - curl_global_init(CURL_GLOBAL_ALL); - return StartProgress(); -} - -void StreamProgressThread::StopDownload() -{ - ENGINE_LOGI("StopDownload"); - exitDownload_ = true; - StopProgress(); - curl_global_cleanup(); -} - -bool StreamProgressThread::ProcessThreadExecute() -{ - ENGINE_LOGI("ProcessThreadExecute"); - downloadHandle_ = curl_easy_init(); - ENGINE_CHECK(downloadHandle_ != nullptr, ProcessThreadExit(); - DownloadCallback(0, UpgradeStatus::DOWNLOAD_FAIL, "Failed to init curl"); - return true, "Failed to init curl"); - if (!CheckFileSize()) { - ProcessThreadExit(); - DownloadCallback(0, UpgradeStatus::DOWNLOAD_FAIL, std::to_string(CAST_INT(DownloadEndReason::CURL_ERROR))); - return false; - } - - if (!DownloadFile()) { - ProcessThreadExit(); - DownloadCallback(0, UpgradeStatus::DOWNLOAD_CANCEL, - std::to_string(CAST_INT(DownloadEndReason::CANCEL))); - } else { - ProcessThreadExit(); - DownloadCallback(DOWNLOAD_FINISH_PERCENT, UpgradeStatus::DOWNLOAD_SUCCESS, ""); - } - - return false; -} - -bool StreamProgressThread::CheckFileSize() -{ - CURLcode res; - curl_easy_setopt(downloadHandle_, CURLOPT_TIMEOUT, TIMEOUT_FOR_DOWNLOAD); - curl_easy_setopt(downloadHandle_, CURLOPT_CONNECTTIMEOUT, TIMEOUT_FOR_CONNECT); - curl_easy_setopt(downloadHandle_, CURLOPT_URL, serverUrl_.c_str()); - curl_easy_setopt(downloadHandle_, CURLOPT_NOBODY, 1L); // 只获取文件头部 - curl_easy_setopt(downloadHandle_, CURLOPT_HEADER, 1L); // 包含响应头部 - res = curl_easy_perform(downloadHandle_); - if (res != CURLE_OK) { - ENGINE_LOGE("Failed to curl_easy_perform res %s", curl_easy_strerror(res)); - return false; - } - - // 获取文件大小 - double fileSize = 0; - res = curl_easy_getinfo(downloadHandle_, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &fileSize); - if (res != CURLE_OK || fileSize <= 0 || fileSize != totalFileSize_) { - ENGINE_LOGE("Failed to curl_easy_getinfo res:%{public}s fileSize:%{public}f totalFileSize_:%{public}" PRId64 "", - curl_easy_strerror(res), fileSize, totalFileSize_); - return false; - } - return true; -} - -bool StreamProgressThread::DownloadFile() -{ - CURLcode res; - curl_easy_setopt(downloadHandle_, CURLOPT_NOBODY, 0L); // 重置回去 - curl_easy_setopt(downloadHandle_, CURLOPT_HEADER, 0L); // 重置回去 - curl_easy_setopt(downloadHandle_, CURLOPT_WRITEDATA, this); - curl_easy_setopt(downloadHandle_, CURLOPT_WRITEFUNCTION, WriteFunc); - - ENGINE_LOGI("curl_easy_setopt downloadedSize_ %{public}" PRId64 "", downloadedSize_); - if (downloadedSize_ > 0) { - curl_easy_setopt(downloadHandle_, CURLOPT_RESUME_FROM_LARGE, static_cast(downloadedSize_)); - } - curl_easy_setopt(downloadHandle_, CURLOPT_NOPROGRESS, 0L); - curl_easy_setopt(downloadHandle_, CURLOPT_PROGRESSDATA, this); - curl_easy_setopt(downloadHandle_, CURLOPT_PROGRESSFUNCTION, DownloadProgress); - res = curl_easy_perform(downloadHandle_); - if (res != CURLE_OK) { - ENGINE_LOGE("Failed to download res:%{public}s", curl_easy_strerror(res)); - return false; - } else { - ENGINE_LOGI("Success to download"); - return true; - } -} - -void StreamProgressThread::ProcessThreadExit() -{ - ENGINE_LOGI("ProcessThreadExit"); - if (downloadHandle_ != nullptr) { - curl_easy_cleanup(downloadHandle_); - } - downloadHandle_ = nullptr; -} - -int32_t StreamProgressThread::DownloadCallback(uint32_t percent, UpgradeStatus status, const std::string &error) -{ - ENGINE_LOGI("DownloadCallback percent:%{public}d, status:%{public}d, error:%{public}s", - percent, CAST_INT(status), error.c_str()); - - downloadProgress_.endReason = error; - downloadProgress_.percent = percent; - downloadProgress_.status = status; - if (callback_ != nullptr) { - callback_(downloadProgress_); - } - return 0; -} - -int32_t StreamProgressThread::DownloadProgress(const void *localData, double dlTotal, double dlNow, double ulTotal, - double ulNow) -{ - auto engine = reinterpret_cast(const_cast(localData)); - ENGINE_CHECK(engine != nullptr, return -1, "Can not find engine"); - unsigned int percent = 0; - if (dlTotal > 0) { - percent = dlNow / dlTotal * DOWNLOAD_FINISH_PERCENT; - ENGINE_LOGI("StreamProgressThread DownloadProgress dlTotal:%{public}f,dlNow:%{public}f,ulTotal:%{public}f, " - "ulNow:%{public}f,percent:%{public}d", dlTotal, dlNow, ulTotal, ulNow, percent); - } else { - ENGINE_LOGI("StreamProgressThread DownloadProgress dlTotal:%{public}f is less than 0", dlTotal); - return 0; - } - return engine->DealExitOrCancel() ? -1 : 0; -} - -size_t StreamProgressThread::WriteFunc(uint8_t *ptr, size_t size, size_t nmemb, void *localData) -{ - ENGINE_LOGI("StreamProgressThread WriteFunc"); - auto engine = reinterpret_cast(const_cast(localData)); - ENGINE_CHECK(engine != nullptr, return -1, "Can not find engine"); - size_t totalSize = size * nmemb; // 本次收到的数据大小 - uint8_t *buffer = engine->buffer_; - size_t& bufferPos = engine->bufferPos_; - int64_t& totalFileSize = engine->totalFileSize_; - int64_t& downloadedSize = engine->downloadedSize_; - - size_t processed = 0; // 已处理的数据量 - - // 当还有未处理的数据时继续处理 - while (processed < totalSize) { - size_t spaceLeft = BUFFER_SIZE - bufferPos - 1; // 当前缓冲区剩余空间 - size_t bytesToCopy = std::min(spaceLeft, totalSize - processed); - - // 将数据复制到缓冲区 - errno_t err = memcpy_s(buffer + bufferPos, BUFFER_SIZE - bufferPos, ptr + processed, bytesToCopy); - if (err != 0) { - ENGINE_LOGE("WriteFunc memcpy_s failed with error code: %{public}d", err); - return -1; - } - bufferPos += bytesToCopy; - processed += bytesToCopy; - - // 如果缓冲区已满,处理并清空 - if (bufferPos == (BUFFER_SIZE - 1) || (downloadedSize + processed) == totalFileSize) { - ENGINE_LOGI("StreamProgressThread WriteFunc buffer full bufferPos:%{public}zu " - "(downloadedSize+processed):%{public}" PRId64 "", - bufferPos, downloadedSize + processed); - #ifndef UPDATER_UT - int32_t ret = SysInstaller::SysInstallerKitsImpl::GetInstance().ProcessStreamData(buffer, bufferPos); - if (ret != 0) { - ENGINE_LOGE("WriteFunc ProcessStreamData failed"); - return -1; - } - #endif - // 清空缓冲区 - (void)memset_s(buffer, BUFFER_SIZE, 0, BUFFER_SIZE); - bufferPos = 0; - } - } - downloadedSize += totalSize; - - return totalSize; -} - -bool StreamProgressThread::DealExitOrCancel() -{ - if (exitDownload_) { - ENGINE_LOGI("DealExitOrCancel exit Download"); - return true; - } - if (isCancel_) { - ENGINE_LOGI("DealExitOrCancel install task cancel"); - return true; - } - return false; -} -} // namespace UpdateEngine -} // namespace OHOS diff --git a/services/engine/src/update_service_impl_firmware.cpp b/services/engine/src/update_service_impl_firmware.cpp index f8e0f0423c64b8aee7fcc9a89cedc6daf3e077e0..f6d82bd3371778801f7e9a24ac436a5afdde2bcf 100644 --- a/services/engine/src/update_service_impl_firmware.cpp +++ b/services/engine/src/update_service_impl_firmware.cpp @@ -16,7 +16,6 @@ #include "update_service_impl_firmware.h" #include -#include "dupdate_errno.h" #include "firmware_check_data_processor.h" #include "firmware_constant.h" #include "firmware_component_operator.h" @@ -115,13 +114,6 @@ int32_t UpdateServiceImplFirmware::Upgrade(const UpgradeInfo &info, const Versio const UpgradeOptions &upgradeOptions, BusinessError &businessError) { FIRMWARE_LOGI("Upgrade order = %{public}d", CAST_INT(upgradeOptions.order)); - //控制1秒内重复点击下载 - if (DelayedSingleton::GetInstance()->IsUpgradeTriggered()) { - FIRMWARE_LOGI("on upgrading, not perrmit repeat submmit"); - businessError.Build(CallResult::FAIL, "repeat upgrade error"); - return INT_CALL_SUCCESS; - } - FirmwareTask task; FirmwareTaskOperator firmwareTaskOperator; firmwareTaskOperator.QueryTask(task); @@ -328,7 +320,6 @@ int32_t UpdateServiceImplFirmware::Cancel(const UpgradeInfo &info, int32_t servi DelayedSingleton::GetInstance()->DoCancel(businessError); } } - return INT_CALL_SUCCESS; } diff --git a/services/firmware/check/include/firmware_icheck.h b/services/firmware/check/include/firmware_icheck.h index 98b547b131f16fba9e7629dbd00f9ce4459a2c5f..de3c45d77c7ebd35dedffc15b18c4f06c9847c85 100644 --- a/services/firmware/check/include/firmware_icheck.h +++ b/services/firmware/check/include/firmware_icheck.h @@ -152,16 +152,7 @@ private: SSL_set_fd(ssl, engineSocket); int32_t ret = SSL_connect(ssl); if (ret != -1) { - std::string serverIp = OHOS::system::GetParameter(PARAM_NAME_FOR_SEARCH, DEFAULT_SERVER_IP); - std::string request = "GET /config.json HTTP/1.1\r\nHost: " + serverIp + ":" + - std::to_string(PORT_NUMBER) + "\r\nConnection: close\r\n\r\n"; - SSL_write(ssl, request.c_str(), request.size()); int32_t len = SSL_read(ssl, buffer.data(), JSON_MAX_SIZE); - std::string resultStr = buffer.data(); - int index = resultStr.find('{'); - if (index != -1) { - buffer.erase(buffer.begin(), buffer.begin() + index); - } if (len > 0 && ParseJsonFile(buffer, response) == 0) { result = SearchStatus::HAS_NEW_VERSION; errMsg = ""; diff --git a/services/firmware/common/include/firmware_common.h b/services/firmware/common/include/firmware_common.h index 4a143b4059170b36127c106eabcfbb8f5455fcca..e496da437ef60661de9ad7bf3a6f1352b4b440c1 100644 --- a/services/firmware/common/include/firmware_common.h +++ b/services/firmware/common/include/firmware_common.h @@ -63,7 +63,6 @@ enum class CheckResultStatus { enum class InstallType { QUICK_FIX = 1, SYS_INSTALLER, - STREAM_INSTALLLER, UPDATER }; diff --git a/services/firmware/common/include/firmware_update_helper.h b/services/firmware/common/include/firmware_update_helper.h index ad7c64dc1ea0544f4b725a1a37a5d24f4ee93e76..f96ddb9c2dbd61b8e9c78e33f4c33e854654bb3c 100644 --- a/services/firmware/common/include/firmware_update_helper.h +++ b/services/firmware/common/include/firmware_update_helper.h @@ -50,8 +50,6 @@ public: static bool IsUpgradeFailed(UpgradeStatus status); static std::string BuildTaskId(const std::vector &componentList); static InstallType GetInstallType(); - static bool IsStreamUpgrade(); - static bool IsStreamUpgrade(const std::vector &componentList); private: static VersionComponent BuildHotaVersionComponent(std::vector &hotaComponents); diff --git a/services/firmware/common/src/firmware_update_helper.cpp b/services/firmware/common/src/firmware_update_helper.cpp index 7c54fed79fdc874734ac1dd4489a822d0101eaad..6dc0d340ddb1b0fedf4beb9c6f0ed4f169160559 100644 --- a/services/firmware/common/src/firmware_update_helper.cpp +++ b/services/firmware/common/src/firmware_update_helper.cpp @@ -77,23 +77,11 @@ VersionComponent FirmwareUpdateHelper::BuildHotaVersionComponent(std::vector(EffectiveMode::LIVE_AND_COLD); } else { effectiveMode = static_cast(EffectiveMode::COLD); } - hotaVersionComponent.effectiveMode = effectiveMode; - size_t otaMode; - if (InstallType == InstallType::SYS_INSTALLER) { - otaMode = static_cast(OtaMode::AB); - } else if (InstallType == InstallType::STREAM_INSTALLLER) { - otaMode = static_cast(OtaMode::AB_STREAM); - } else { - otaMode = static_cast(OtaMode::REGULAR); - } - hotaVersionComponent.otaMode = otaMode; hotaVersionComponent.innerVersion = hotaComponents[0].targetBlVersionNumber; hotaVersionComponent.displayVersion = hotaComponents[0].targetBlDisplayVersionNumber; for (const auto &component : hotaComponents) { @@ -161,22 +149,5 @@ bool FirmwareUpdateHelper::IsUpgradePackagesReady(const std::vector components; - FirmwareComponentOperator().QueryAll(components); - return IsStreamUpgrade(components); -} - -bool FirmwareUpdateHelper::IsStreamUpgrade(const std::vector &componentList) -{ - if (componentList.empty()) { - FIRMWARE_LOGI("FirmwareUpdateHelper::IsStreamUpgrade componentList is empty"); - return false; - } - return (componentList[0].otaType == OtaType::AB_STREAM); -} - } // namespace UpdateEngine } // namespace OHOS \ No newline at end of file diff --git a/services/firmware/data/db/include/firmware_component.h b/services/firmware/data/db/include/firmware_component.h index bb8d11ab860dfa2437fe16839826e8303a3012d5..9da70d387c7ccb4693aec541409e98c61359057e 100644 --- a/services/firmware/data/db/include/firmware_component.h +++ b/services/firmware/data/db/include/firmware_component.h @@ -19,7 +19,6 @@ #include #include "package_type.h" -#include "ota_type.h" #include "update_define.h" #include "upgrade_status.h" @@ -31,7 +30,6 @@ struct FirmwareComponent { std::string versionId; // 标识包的唯一性 int32_t packageIndex = 0; // 包的安装顺序 PackageType versionPackageType = PackageType::DYNAMIC; - OtaType otaType = OtaType::REGULAR; std::string targetBlVersionNumber; std::string targetBlDisplayVersionNumber; @@ -57,8 +55,6 @@ struct FirmwareComponent { UpgradeStatus status = UpgradeStatus::INIT; int32_t progress = 0; - int64_t recordPoint = 0; - std::string ToString() { return std::string("FirmwareComponent: ") @@ -66,7 +62,6 @@ struct FirmwareComponent { .append("versionId=").append(versionId).append(",") .append("packageIndex=").append(std::to_string(packageIndex)).append(",") .append("versionPackageType=").append(std::to_string(CAST_INT(versionPackageType))).append(",") - .append("otaType=").append(std::to_string(CAST_INT(otaType))).append(",") .append("targetBlVersionNumber=").append(targetBlVersionNumber).append(",") .append("targetBlDisplayVersionNumber=").append(targetBlDisplayVersionNumber).append(",") .append("versionNumber=").append(versionNumber).append(",") @@ -85,8 +80,7 @@ struct FirmwareComponent { .append("verifyInfo=").append(verifyInfo).append(",") .append("spath=").append(spath).append(",") .append("status=").append(std::to_string(CAST_INT(status))).append(",") - .append("progress=").append(std::to_string(progress)).append(",") - .append("recordPoint=").append(std::to_string(recordPoint)); + .append("progress=").append(std::to_string(progress)).append(","); } }; } // 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 7bec4443857b1c5197d403461f8215d9c64c273f..bf3e2146239aaf4248da1256d112df0af9f2b993 100644 --- a/services/firmware/data/db/include/firmware_component_operator.h +++ b/services/firmware/data/db/include/firmware_component_operator.h @@ -45,9 +45,7 @@ public: #endif ~FirmwareComponentOperator() = default; bool UpdateProgressByUrl(const std::string &url, UpgradeStatus status, int32_t progress); - bool UpdateStatusByUrl(const std::string &url, UpgradeStatus status); bool UpdateUrlByVersionId(const std::string &versionId, const std::string &url); - bool UpdateRecordPointByUrl(const std::string &url, int64_t recordPoint); bool QueryByVersionId(const std::string &versionId, FirmwareComponent &component); bool QueryByUrl(const std::string &url, FirmwareComponent &component); }; diff --git a/services/firmware/data/db/include/firmware_component_table.h b/services/firmware/data/db/include/firmware_component_table.h index d92750f64aacc34c101d0cbd3dbce1fe200e24b6..48b8677e4639a35bc543559ee103942515c8fd4e 100644 --- a/services/firmware/data/db/include/firmware_component_table.h +++ b/services/firmware/data/db/include/firmware_component_table.h @@ -28,7 +28,6 @@ namespace UpdateEngine { const std::string FIRMWARE_TABLE_COMPONENT = "component"; const std::string COLUMN_COMPONENT_VERSION_ID = "versionId"; const std::string COLUMN_COMPONENT_VERSION_PACKAGE_TYPE = "versionPackageType"; -const std::string COLUMN_COMPONENT_OTA_MODE = "otaType"; const std::string COLUMN_COMPONENT_PACKAGE_INDEX = "packageIndex"; const std::string COLUMN_COMPONENT_TARGET_BL_DISPLAY_VERSION_NUMBER = "targetBlDisplayVersionNumber"; const std::string COLUMN_COMPONENT_TARGET_BL_VERSION_NUMBER = "targetBlVersionNumber"; @@ -49,7 +48,6 @@ const std::string COLUMN_COMPONENT_FILENAME = "fileName"; const std::string COLUMN_COMPONENT_SPATH = "spath"; const std::string COLUMN_COMPONENT_STATUS = "status"; const std::string COLUMN_COMPONENT_PROGRESS = "progress"; -const std::string COLUMN_COMPONENT_RECORD_POINT = "recordPoint"; // 预留6个字段 const std::string COLUMN_COMPONENT_EXTENDS1 = "extends1"; const std::string COLUMN_COMPONENT_EXTENDS2 = "extends2"; diff --git a/services/firmware/data/db/include/firmware_task.h b/services/firmware/data/db/include/firmware_task.h index 83aaea95b88ed4b8f8de572d70f4dd04ea803627..db7064da931d79cec835b82463f011810c280d17 100644 --- a/services/firmware/data/db/include/firmware_task.h +++ b/services/firmware/data/db/include/firmware_task.h @@ -48,7 +48,6 @@ struct FirmwareTask { std::string tokenHMac; std::string currentVersionList; int64_t authTime = 0; - bool isStreamUpgrade = false; std::string ToString() { @@ -69,8 +68,7 @@ struct FirmwareTask { .append("deviceToken=").append(deviceToken).append(",") .append("tokenHMac=").append(tokenHMac).append(",") .append("currentVersionList=").append(currentVersionList).append(",") - .append("authTime=").append(std::to_string(authTime)).append(",") - .append("isStreamUpgrade=").append(std::to_string(isStreamUpgrade)); + .append("authTime=").append(std::to_string(authTime)).append(","); } }; } // 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 37e3d52a5f388e409a21ab96c7d9b247af0231ef..c9163fe194e73de0e1d5a570abaa15ac0fb55901 100644 --- a/services/firmware/data/db/include/firmware_task_operator.h +++ b/services/firmware/data/db/include/firmware_task_operator.h @@ -47,7 +47,6 @@ public: ~FirmwareTaskOperator() = default; void QueryTask(FirmwareTask &task); bool UpdateProgressByTaskId(const std::string &taskId, UpgradeStatus status, int32_t progress); - bool UpdateStatusByTaskId(const std::string &taskId, UpgradeStatus status); bool UpdateErrMsgByTaskId(const std::string &taskId, int errorCode, const std::string &errorMsg); bool UpdateDownloadTaskIdByTaskId(const std::string &taskId, const std::string &downloadTaskId); bool UpdateCombinationTypeByTaskId(const std::string &taskId, diff --git a/services/firmware/data/db/include/firmware_task_table.h b/services/firmware/data/db/include/firmware_task_table.h index ca24a41cd333363b236fac4f129a867337cbfae0..289cbe260628c954838098b95e12d308d5e5a8ce 100644 --- a/services/firmware/data/db/include/firmware_task_table.h +++ b/services/firmware/data/db/include/firmware_task_table.h @@ -46,7 +46,6 @@ const std::string COLUMN_TASK_DEVICE_TOKEN = "deviceToken"; const std::string COLUMN_TASK_TOKEN_H_MAC = "tokenHMac"; const std::string COLUMN_TASK_CURR_VERSION_LIST = "currentVersionList"; const std::string COLUMN_TASK_AUTH_TIME = "authTime"; -const std::string COLUMN_TASK_IS_STREAM_UPGRADE = "isStreamUpgrade"; // 预留6个字段 const std::string COLUMN_TASK_EXTENDS1 = "extends1"; const std::string COLUMN_TASK_EXTENDS2 = "extends2"; diff --git a/services/firmware/data/db/src/firmware_component_operator.cpp b/services/firmware/data/db/src/firmware_component_operator.cpp index fcebe8e81d23b09fe04cc546871b45f821d693a3..551f795dc3237aa5beb82d418c9fce8b2467ac06 100644 --- a/services/firmware/data/db/src/firmware_component_operator.cpp +++ b/services/firmware/data/db/src/firmware_component_operator.cpp @@ -30,16 +30,6 @@ bool FirmwareComponentOperator::UpdateProgressByUrl(const std::string &url, Upgr return TableBaseOperator::Update(values, predicates); } -bool FirmwareComponentOperator::UpdateStatusByUrl(const std::string &url, UpgradeStatus status) -{ - NativeRdb::ValuesBucket values; - values.PutInt(COLUMN_COMPONENT_STATUS, CAST_INT(status)); - - OHOS::NativeRdb::RdbPredicates predicates(GetTableName()); - predicates.EqualTo(COLUMN_COMPONENT_DOWNLOAD_URL, url); - return TableBaseOperator::Update(values, predicates); -} - bool FirmwareComponentOperator::UpdateUrlByVersionId(const std::string &versionId, const std::string &url) { NativeRdb::ValuesBucket values; @@ -50,16 +40,6 @@ bool FirmwareComponentOperator::UpdateUrlByVersionId(const std::string &versionI return TableBaseOperator::Update(values, predicates); } -bool FirmwareComponentOperator::UpdateRecordPointByUrl(const std::string &url, int64_t recordPoint) -{ - NativeRdb::ValuesBucket values; - values.PutInt(COLUMN_COMPONENT_RECORD_POINT, recordPoint); - - OHOS::NativeRdb::RdbPredicates predicates(GetTableName()); - predicates.EqualTo(COLUMN_COMPONENT_DOWNLOAD_URL, url); - return TableBaseOperator::Update(values, predicates); -} - bool FirmwareComponentOperator::QueryByVersionId(const std::string &versionId, FirmwareComponent &component) { std::vector components; diff --git a/services/firmware/data/db/src/firmware_component_table.cpp b/services/firmware/data/db/src/firmware_component_table.cpp index 760a4c5474a7db68a9d9b53e297187ece19a8758..022da2d9cd3ddf32c3cd261dc065523cc3213ff0 100644 --- a/services/firmware/data/db/src/firmware_component_table.cpp +++ b/services/firmware/data/db/src/firmware_component_table.cpp @@ -29,7 +29,6 @@ std::string FirmwareComponentTable::GetTableCreateSql() .append(COLUMN_ID + " integer PRIMARY KEY autoincrement not null,") .append(COLUMN_COMPONENT_VERSION_ID + " varchar(256),") .append(COLUMN_COMPONENT_VERSION_PACKAGE_TYPE + " integer,") - .append(COLUMN_COMPONENT_OTA_MODE + " integer,") .append(COLUMN_COMPONENT_PACKAGE_INDEX + " integer,") .append(COLUMN_COMPONENT_TARGET_BL_DISPLAY_VERSION_NUMBER + " varchar(256),") .append(COLUMN_COMPONENT_TARGET_BL_VERSION_NUMBER + " varchar(256),") @@ -50,7 +49,6 @@ std::string FirmwareComponentTable::GetTableCreateSql() .append(COLUMN_COMPONENT_SPATH + " varchar(256),") .append(COLUMN_COMPONENT_STATUS + " integer,") .append(COLUMN_COMPONENT_PROGRESS + " integer,") - .append(COLUMN_COMPONENT_RECORD_POINT + " bigint,") .append(COLUMN_COMPONENT_EXTENDS1 + " varchar(256),") .append(COLUMN_COMPONENT_EXTENDS2 + " varchar(256),") .append(COLUMN_COMPONENT_EXTENDS3 + " varchar(256),") @@ -67,9 +65,6 @@ void FirmwareComponentTable::ParseDbValue(ResultSet *resultSet, FirmwareComponen int32_t versionPackageType = CAST_INT(PackageType::DYNAMIC); GetColumnValue(resultSet, COLUMN_COMPONENT_VERSION_PACKAGE_TYPE, versionPackageType); value.versionPackageType = static_cast(versionPackageType); - int32_t otaType = CAST_INT(OtaType::REGULAR); - GetColumnValue(resultSet, COLUMN_COMPONENT_OTA_MODE, otaType); - value.otaType = static_cast(otaType); GetColumnValue(resultSet, COLUMN_COMPONENT_PACKAGE_INDEX, value.packageIndex); GetColumnValue(resultSet, COLUMN_COMPONENT_TARGET_BL_DISPLAY_VERSION_NUMBER, value.targetBlDisplayVersionNumber); GetColumnValue(resultSet, COLUMN_COMPONENT_TARGET_BL_VERSION_NUMBER, value.targetBlVersionNumber); @@ -92,14 +87,12 @@ void FirmwareComponentTable::ParseDbValue(ResultSet *resultSet, FirmwareComponen GetColumnValue(resultSet, COLUMN_COMPONENT_STATUS, status); value.status = static_cast(status); GetColumnValue(resultSet, COLUMN_COMPONENT_PROGRESS, value.progress); - GetColumnValue(resultSet, COLUMN_COMPONENT_RECORD_POINT, value.recordPoint); } void FirmwareComponentTable::BuildDbValue(const FirmwareComponent &value, NativeRdb::ValuesBucket &dbValue) { PutColumnValue(dbValue, COLUMN_COMPONENT_VERSION_ID, value.versionId); PutColumnValue(dbValue, COLUMN_COMPONENT_VERSION_PACKAGE_TYPE, CAST_INT(value.versionPackageType)); - PutColumnValue(dbValue, COLUMN_COMPONENT_OTA_MODE, CAST_INT(value.otaType)); PutColumnValue(dbValue, COLUMN_COMPONENT_PACKAGE_INDEX, value.packageIndex); PutColumnValue(dbValue, COLUMN_COMPONENT_TARGET_BL_DISPLAY_VERSION_NUMBER, value.targetBlDisplayVersionNumber); PutColumnValue(dbValue, COLUMN_COMPONENT_TARGET_BL_VERSION_NUMBER, value.targetBlVersionNumber); @@ -120,7 +113,6 @@ void FirmwareComponentTable::BuildDbValue(const FirmwareComponent &value, Native PutColumnValue(dbValue, COLUMN_COMPONENT_SPATH, value.spath); PutColumnValue(dbValue, COLUMN_COMPONENT_STATUS, CAST_INT(value.status)); PutColumnValue(dbValue, COLUMN_COMPONENT_PROGRESS, value.progress); - PutColumnValue(dbValue, COLUMN_COMPONENT_RECORD_POINT, value.recordPoint); } } // namespace UpdateEngine } // namespace OHOS \ No newline at end of file diff --git a/services/firmware/data/db/src/firmware_database_callback.cpp b/services/firmware/data/db/src/firmware_database_callback.cpp index 14e0ef1ad7e6843096c03e5ada34b93471a043be..f0d318c2c72c301b2dac79dcded284c21dfa338e 100644 --- a/services/firmware/data/db/src/firmware_database_callback.cpp +++ b/services/firmware/data/db/src/firmware_database_callback.cpp @@ -25,12 +25,6 @@ namespace OHOS { namespace UpdateEngine { - -enum { - VERSION_INITIAL_VERSION = 1, - VERSION_ADD_STREAM_CAPACITY, -}; - int FirmwareDatabaseCallback::OnCreate(NativeRdb::RdbStore &rdbStore) { std::vector dbCreateSqlVector = GenerateDbCreateSqlVector(); @@ -49,12 +43,6 @@ int FirmwareDatabaseCallback::OnUpgrade(NativeRdb::RdbStore &rdbStore, int oldVe { ENGINE_LOGI("FirmwareDatabaseCallback OnUpgrade oldVersion=%{public}d newVersion=%{public}d", oldVersion, newVersion); - if (oldVersion < VERSION_ADD_STREAM_CAPACITY && newVersion >= VERSION_ADD_STREAM_CAPACITY) { - rdbStore.ExecuteSql("ALTER TABLE " + FIRMWARE_TABLE_COMPONENT + " ADD COLUMN " + - COLUMN_COMPONENT_RECORD_POINT + " bigint;"); - rdbStore.ExecuteSql("ALTER TABLE " + FIRMWARE_TABLE_TASK + " ADD COLUMN " + - COLUMN_TASK_IS_STREAM_UPGRADE + " integer;"); - } return NativeRdb::E_OK; } diff --git a/services/firmware/data/db/src/firmware_task_operator.cpp b/services/firmware/data/db/src/firmware_task_operator.cpp index fb0c35cfb4c67db5678ce420b2257f6bda869c2d..8cc133fbfbf95220026318471027682f002da33e 100644 --- a/services/firmware/data/db/src/firmware_task_operator.cpp +++ b/services/firmware/data/db/src/firmware_task_operator.cpp @@ -46,13 +46,6 @@ bool FirmwareTaskOperator::UpdateProgressByTaskId(const std::string &taskId, Upg return UpdateByTaskId(taskId, values); } -bool FirmwareTaskOperator::UpdateStatusByTaskId(const std::string &taskId, UpgradeStatus status) -{ - NativeRdb::ValuesBucket values; - values.PutInt(COLUMN_TASK_STATUS, CAST_INT(status)); - return UpdateByTaskId(taskId, values); -} - bool FirmwareTaskOperator::UpdateErrMsgByTaskId(const std::string &taskId, int errorCode, const std::string &errorMsg) { NativeRdb::ValuesBucket values; diff --git a/services/firmware/data/db/src/firmware_task_table.cpp b/services/firmware/data/db/src/firmware_task_table.cpp index 3373b8b98f5b0f3252861aaa68195dc53d41cf06..db83937efced2a3a196c8de965503048ba00985a 100644 --- a/services/firmware/data/db/src/firmware_task_table.cpp +++ b/services/firmware/data/db/src/firmware_task_table.cpp @@ -47,7 +47,6 @@ std::string FirmwareTaskTable::GetTableCreateSql() .append(COLUMN_TASK_TOKEN_H_MAC + " varchar(256),") .append(COLUMN_TASK_CURR_VERSION_LIST + " varchar(1024),") .append(COLUMN_TASK_AUTH_TIME + " bigint,") - .append(COLUMN_TASK_IS_STREAM_UPGRADE + " integer,") .append(COLUMN_TASK_EXTENDS1 + " varchar(256),") .append(COLUMN_TASK_EXTENDS2 + " varchar(256),") .append(COLUMN_TASK_EXTENDS3 + " varchar(256),") @@ -91,7 +90,6 @@ void FirmwareTaskTable::ParseDbValue(ResultSet *resultSet, FirmwareTask &value) GetColumnValue(resultSet, COLUMN_TASK_TOKEN_H_MAC, value.tokenHMac); GetColumnValue(resultSet, COLUMN_TASK_CURR_VERSION_LIST, value.currentVersionList); GetColumnValue(resultSet, COLUMN_TASK_AUTH_TIME, value.authTime); - GetColumnValue(resultSet, COLUMN_TASK_IS_STREAM_UPGRADE, value.isStreamUpgrade); } void FirmwareTaskTable::BuildDbValue(const FirmwareTask &value, NativeRdb::ValuesBucket &dbValue) @@ -114,7 +112,6 @@ void FirmwareTaskTable::BuildDbValue(const FirmwareTask &value, NativeRdb::Value PutColumnValue(dbValue, COLUMN_TASK_TOKEN_H_MAC, value.tokenHMac); PutColumnValue(dbValue, COLUMN_TASK_CURR_VERSION_LIST, value.currentVersionList); PutColumnValue(dbValue, COLUMN_TASK_AUTH_TIME, value.authTime); - PutColumnValue(dbValue, COLUMN_TASK_IS_STREAM_UPGRADE, value.isStreamUpgrade); } } // namespace UpdateEngine } // namespace OHOS \ No newline at end of file diff --git a/services/firmware/firmware.gni b/services/firmware/firmware.gni index 2fed1377baa0c4e31ea15762f62fd87415ff0751..e5b2b87aadd510b0e136f296855a36cf8a3444ff 100644 --- a/services/firmware/firmware.gni +++ b/services/firmware/firmware.gni @@ -48,7 +48,6 @@ ab_update_src = [ if (ability_ability_runtime_enable) { ab_update_src += [ "$firmware_root_path/upgrade/install/src/firmware_sys_installer_install.cpp" ] - ab_update_src += [ "$firmware_root_path/upgrade/install/src/firmware_stream_installer_install.cpp" ] } else { ab_update_src += [ "$firmware_root_path/upgrade/install/src/firmware_sys_installer_install_empty.cpp" ] } @@ -82,7 +81,6 @@ if (communication_netmanager_base_enable) { "$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", - "$firmware_root_path/upgrade/mode/src/firmware_stream_install_apply_mode.cpp", ] } else { firmware_src += [ diff --git a/services/firmware/upgrade/data_processor/include/firmware_install_data_processor.h b/services/firmware/upgrade/data_processor/include/firmware_install_data_processor.h index ab8028d695311f89d70b25bbe0caa72975d34ad7..a02c066c25f7b55b15c893dab1a5375a214c80e2 100644 --- a/services/firmware/upgrade/data_processor/include/firmware_install_data_processor.h +++ b/services/firmware/upgrade/data_processor/include/firmware_install_data_processor.h @@ -28,7 +28,6 @@ public: void SetInstallResult(const InstallCallbackInfo &installCallbackInfo); bool HasInstallSuccess(); - bool HasInstallFail(); bool HasUpdateSuccess(); bool IsSpaceEnough(int64_t &requireTotalSize); bool IsUpgradeFileCheckSuccess(); 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 d3fd4cd13b7883089b734b9b28818a6d54b840d0..3b4aaf2d7b8a0747c1cab43ca5d818661c002425 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 @@ -146,7 +146,6 @@ void FirmwareCheckDataProcessor::HandleNewVersion() FirmwareTask task; task.taskId = FirmwareUpdateHelper::BuildTaskId(componentList_); task.status = UpgradeStatus::CHECK_VERSION_SUCCESS; - task.isStreamUpgrade = FirmwareUpdateHelper::IsStreamUpgrade(componentList_); task.combinationType = GetCombinationType(); FirmwareTaskOperator().Insert(task); } diff --git a/services/firmware/upgrade/data_processor/src/firmware_install_data_processor.cpp b/services/firmware/upgrade/data_processor/src/firmware_install_data_processor.cpp index 79592b1f44e2b406f8047911d6f3393ce0e59951..9db57956117809468ce8f868b2625bc8b6cde383 100644 --- a/services/firmware/upgrade/data_processor/src/firmware_install_data_processor.cpp +++ b/services/firmware/upgrade/data_processor/src/firmware_install_data_processor.cpp @@ -46,34 +46,14 @@ bool FirmwareInstallDataProcessor::HasInstallSuccess() { // 实时取当前状态 FirmwareTaskOperator().QueryTask(tasks_); - if (!tasks_.isExistTask) { - FIRMWARE_LOGI("HasInstallSuccess no task"); - return false; - } FIRMWARE_LOGI("GetTaskStatus status: %{public}d", tasks_.status); return tasks_.status == UpgradeStatus::INSTALL_SUCCESS; } -bool FirmwareInstallDataProcessor::HasInstallFail() -{ - // 实时取当前状态 - FirmwareTaskOperator().QueryTask(tasks_); - if (!tasks_.isExistTask) { - FIRMWARE_LOGI("HasInstallFail no task"); - return false; - } - FIRMWARE_LOGI("GetTaskStatus status: %{public}d", tasks_.status); - return tasks_.status == UpgradeStatus::INSTALL_FAIL; -} - bool FirmwareInstallDataProcessor::HasUpdateSuccess() { // 实时取当前状态 FirmwareTaskOperator().QueryTask(tasks_); - if (!tasks_.isExistTask) { - FIRMWARE_LOGI("HasUpdateSuccess no task"); - return false; - } FIRMWARE_LOGI("GetTaskStatus status: %{public}d", tasks_.status); return tasks_.status == UpgradeStatus::UPDATE_SUCCESS; } @@ -98,10 +78,6 @@ void FirmwareInstallDataProcessor::SetInstallResult(const InstallCallbackInfo &i progress.status, installCallbackInfo.errorMessage); return; } - if (progress.status == UpgradeStatus::INSTALL_PAUSE) { - DelayedSingleton::GetInstance()->NotifyEvent(tasks_.taskId, EventId::EVENT_UPGRADE_PAUSE, - UpgradeStatus::INSTALL_PAUSE, installCallbackInfo.errorMessage); - } DelayedSingleton::GetInstance()->ProgressCallback(tasks_.taskId, progress); } diff --git a/services/firmware/upgrade/executor/include/firmware_install_executor.h b/services/firmware/upgrade/executor/include/firmware_install_executor.h index 61981c28ce62fad3768c87138d646118ba0f85fd..89dd895463fee7c4752783ea2e52abe87b3eb20d 100644 --- a/services/firmware/upgrade/executor/include/firmware_install_executor.h +++ b/services/firmware/upgrade/executor/include/firmware_install_executor.h @@ -37,7 +37,6 @@ private: void GetTask(); void HandleInstallProgress(const FirmwareComponent &component); void HandleInstallResult(const bool result, const ErrorMessage &errMsg, const UpgradeStatus &status); - void StartInstall(); private: InstallType installType_; diff --git a/services/firmware/upgrade/executor/src/firmware_install_executor.cpp b/services/firmware/upgrade/executor/src/firmware_install_executor.cpp index 6b4c2632af4593d689b1d0aab336f9f4812939fa..840058bdef447e25f5dab7daa893a52329865476 100644 --- a/services/firmware/upgrade/executor/src/firmware_install_executor.cpp +++ b/services/firmware/upgrade/executor/src/firmware_install_executor.cpp @@ -24,7 +24,6 @@ #include "firmware_install_factory.h" #include "firmware_log.h" #include "firmware_task_operator.h" -#include "firmware_update_helper.h" namespace OHOS { namespace UpdateEngine { @@ -72,8 +71,6 @@ void FirmwareInstallExecutor::DoInstall() for (FirmwareComponent &component : components_) { FirmwareComponentOperator().UpdateProgressByUrl(component.url, progress.status, progress.percent); } - - StartInstall(); } void FirmwareInstallExecutor::StartInstall() @@ -82,9 +79,6 @@ void FirmwareInstallExecutor::StartInstall() [=](const FirmwareComponent &component) { HandleInstallProgress(component); }, - [=](bool result, const ErrorMessage &errMsg, UpgradeStatus status) { - HandleInstallResult(result, errMsg, status); - }, [=](UpgradeStatus status) { FIRMWARE_LOGI("update start status :%{public}d", CAST_INT(status)); DelayedSingleton::GetInstance()->NotifyEvent(tasks_.taskId, @@ -120,13 +114,6 @@ void FirmwareInstallExecutor::HandleInstallProgress(const FirmwareComponent &com FIRMWARE_LOGE("FirmwareInstallExecutor HandleInstallProgress installCallback is null"); return; } - //流式升级只更新recordPoint还原点不实时更新task的status,避免异步安装过程覆盖结果 - if (installType_ == InstallType::STREAM_INSTALLLER) { - FirmwareComponentOperator().UpdateRecordPointByUrl(component.url, component.recordPoint); - } else { - FirmwareTaskOperator().UpdateProgressByTaskId(tasks_.taskId, taskProgress_.status, taskProgress_.percent); - } - installCallback_.installCallback(installCallbackInfo_); } @@ -141,14 +128,9 @@ void FirmwareInstallExecutor::HandleInstallResult(const bool result, const Error if (installType_ == InstallType::SYS_INSTALLER) { taskProgress_.status = UpgradeStatus::INSTALL_FAIL; } else if (installType_ == InstallType::STREAM_INSTALLLER) { - taskProgress_.status = status == UpgradeStatus::DOWNLOAD_CANCEL ? - UpgradeStatus::INSTALL_PAUSE : UpgradeStatus::INSTALL_FAIL; - } else { taskProgress_.status = UpgradeStatus::UPDATE_FAIL; } } - FIRMWARE_LOGI("HandleInstallResult status: %{public}d progress: %{public}d", - taskProgress_.status, taskProgress_.percent); // 整体进度插入到 task 表 FirmwareTaskOperator().UpdateProgressByTaskId(tasks_.taskId, taskProgress_.status, taskProgress_.percent); installCallbackInfo_.progress = taskProgress_; diff --git a/services/firmware/upgrade/flow/src/firmware_manager.cpp b/services/firmware/upgrade/flow/src/firmware_manager.cpp index 58f82da80bd14e7184115de402cb5a852ac11536..7b67c1fad9e7bd833096301fae4d1a560ed3ddb5 100644 --- a/services/firmware/upgrade/flow/src/firmware_manager.cpp +++ b/services/firmware/upgrade/flow/src/firmware_manager.cpp @@ -37,7 +37,6 @@ #include "firmware_manual_check_mode.h" #include "firmware_download_mode.h" #include "firmware_install_apply_mode.h" -#include "firmware_stream_install_apply_mode.h" #include "firmware_status_cache.h" #include "firmware_task_operator.h" #include "firmware_update_helper.h" @@ -220,8 +219,6 @@ bool FirmwareManager::CanInstall(void) InstallType InstallType = FirmwareUpdateHelper::GetInstallType(); if (InstallType == InstallType::SYS_INSTALLER) { return task.status == UpgradeStatus::DOWNLOAD_SUCCESS || task.status == UpgradeStatus::INSTALL_SUCCESS; - } else if (InstallType == InstallType::STREAM_INSTALLLER) { - return task.status != UpgradeStatus::INSTALLING; } else { return task.status == UpgradeStatus::DOWNLOAD_SUCCESS; } diff --git a/services/firmware/upgrade/install/include/firmware_install.h b/services/firmware/upgrade/install/include/firmware_install.h index e8d103921f30ebcc954c2372c5a23e5b90e8fd5e..f804ae2548046330d63c7a95e3c2fe5dd46de6e2 100644 --- a/services/firmware/upgrade/install/include/firmware_install.h +++ b/services/firmware/upgrade/install/include/firmware_install.h @@ -30,7 +30,6 @@ constexpr int32_t SLEEP_INSTALL = 1; struct InstallProgress { Progress progress; - uint32_t dealLen = 0; ErrorMessage errMsg; }; diff --git a/services/firmware/upgrade/install/include/firmware_stream_installer_install.h b/services/firmware/upgrade/install/include/firmware_stream_installer_install.h deleted file mode 100755 index 9e70443e95f92887128dce943fcc895d73c1785b..0000000000000000000000000000000000000000 --- a/services/firmware/upgrade/install/include/firmware_stream_installer_install.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FIRMWARE_STREAM_INSTALLER_INSTALL_H -#define FIRMWARE_STREAM_INSTALLER_INSTALL_H - -#include -#include -#include -#include - -#include "firmware_component.h" -#include "firmware_install.h" -#include "progress_thread.h" - -namespace OHOS { -namespace UpdateEngine { - -constexpr int16_t MAX_RETRY_COUNT = 3; // 重试次数 -constexpr int32_t RETRY_INTERVAL_TIME = 100 * 1000; // 重试间隔时间50ms - -class StreamInstallerInstall final : public FirmwareInstall { -private: - bool IsComponentLegal(const std::vector &componentList) final; - bool PerformInstall(const std::vector &componentList, UpgradeStatus &status) final; - int32_t StartInstallProcess(FirmwareComponent &component); - int32_t DoSysInstall(const FirmwareComponent &component); - bool InstallComponentWithRetry(const FirmwareComponent &component); - int32_t WaitInstallResult(); - int32_t InitSysInstaller(); - int32_t SetInstallerCallback(FirmwareComponent &component); - void NotifyCondition(); - -private: - Progress downloadProgress_; - Progress sysInstallProgress_; - std::shared_ptr downloadThread_ = nullptr; - std::mutex installMutex_; - std::condition_variable installCond_; -}; -} // namespace UpdateEngine -} // namespace OHOS -#endif // FIRMWARE_STREAM_INSTALLER_INSTALL_H \ No newline at end of file diff --git a/services/firmware/upgrade/install/include/firmware_sys_installer_callback.h b/services/firmware/upgrade/install/include/firmware_sys_installer_callback.h index a8acbae7a1e6fd9efa0c4bdf324b4d33b0a7d03e..fe06f2568d8b55cf1d1da2cc6d729814a211bc30 100644 --- a/services/firmware/upgrade/install/include/firmware_sys_installer_callback.h +++ b/services/firmware/upgrade/install/include/firmware_sys_installer_callback.h @@ -30,9 +30,6 @@ public: void OnUpgradeProgress(SysInstaller::UpdateStatus updateStatus, int percent, const std::string &resultMsg) final; - void OnUpgradeDealLen(SysInstaller::UpdateStatus updateStatus, int dealLen, - const std::string &resultMsg) final; - private: SysInstallerExecutorCallback sysInstallCallback_; }; diff --git a/services/firmware/upgrade/install/src/firmware_install.cpp b/services/firmware/upgrade/install/src/firmware_install.cpp index 1e0fb0c19a6173296e4bf37c71c9f4e1cad31233..bcae762f822a7dd5a4a1c53e440673681a6488ce 100644 --- a/services/firmware/upgrade/install/src/firmware_install.cpp +++ b/services/firmware/upgrade/install/src/firmware_install.cpp @@ -45,7 +45,6 @@ void FirmwareInstall::StartInstall(const std::vector &compone SetIsInstalling(true); onInstallCallback_ = cb; - UpgradeStatus status; bool result = PerformInstall(componentList, status); SetIsInstalling(false); CallbackResult(cb, result, status); diff --git a/services/firmware/upgrade/install/src/firmware_install_factory.cpp b/services/firmware/upgrade/install/src/firmware_install_factory.cpp index 3b80df1f3ef01878d217ead531759b3c76667760..696a72a90a0ce810ea113f2ea8b8de96936f7012 100644 --- a/services/firmware/upgrade/install/src/firmware_install_factory.cpp +++ b/services/firmware/upgrade/install/src/firmware_install_factory.cpp @@ -15,9 +15,7 @@ #include "firmware_install_factory.h" #include "firmware_sys_installer_install.h" -#include "firmware_stream_installer_install.h" #include "firmware_updater_install.h" -#include "firmware_update_helper.h" namespace OHOS { namespace UpdateEngine { @@ -26,8 +24,6 @@ std::shared_ptr InstallFactory::GetInstance(InstallType type) switch (type) { case InstallType::SYS_INSTALLER: return std::make_shared(); - case InstallType::STREAM_INSTALLLER: - return std::make_shared(); default: return std::make_shared(); } diff --git a/services/firmware/upgrade/install/src/firmware_sys_installer_callback.cpp b/services/firmware/upgrade/install/src/firmware_sys_installer_callback.cpp index 829a07f42b22a7208a60292bb5b67bf10480c307..d054ae245ffbe44fd1e48b4969e8017cece9ff1e 100644 --- a/services/firmware/upgrade/install/src/firmware_sys_installer_callback.cpp +++ b/services/firmware/upgrade/install/src/firmware_sys_installer_callback.cpp @@ -16,7 +16,6 @@ #include "firmware_sys_installer_callback.h" #include "firmware_log.h" -#include "firmware_constant.h" namespace OHOS { namespace UpdateEngine { @@ -53,35 +52,5 @@ void SysInstallerCallback::OnUpgradeProgress(SysInstaller::UpdateStatus updateSt } sysInstallCallback_.onSysInstallerCallback(installProgress); } - -void SysInstallerCallback::OnUpgradeDealLen(SysInstaller::UpdateStatus updateStatus, int dealLen, - const std::string &resultMsg) -{ - FIRMWARE_LOGI("sysInstallerCallback OnUpgradeDealLen status %{public}d " - "dealLen %{public}d", updateStatus, dealLen); - InstallProgress installProgress = {}; - switch (updateStatus) { - case SysInstaller::UpdateStatus::UPDATE_STATE_INIT: - case SysInstaller::UpdateStatus::UPDATE_STATE_ONGOING: - installProgress.progress.status = UpgradeStatus::INSTALLING; - break; - case SysInstaller::UpdateStatus::UPDATE_STATE_SUCCESSFUL: - installProgress.progress.status = UpgradeStatus::INSTALL_SUCCESS; - installProgress.progress.percent = Firmware::ONE_HUNDRED; - break; - default: - installProgress.progress.status = UpgradeStatus::INSTALL_FAIL; - installProgress.errMsg.errorMessage = resultMsg; - break; - } - - installProgress.errMsg.errorCode = CAST_INT(updateStatus); - installProgress.dealLen = dealLen; - if (sysInstallCallback_.onSysInstallerCallback == nullptr) { - FIRMWARE_LOGE("SysInstallerCallback OnUpgradeDealLen onSysInstallerCallback is null"); - return; - } - sysInstallCallback_.onSysInstallerCallback(installProgress); -} } // namespace UpdateEngine } // namespace OHOS diff --git a/services/firmware/upgrade/mode/include/firmware_stream_install_apply_mode.h b/services/firmware/upgrade/mode/include/firmware_stream_install_apply_mode.h deleted file mode 100644 index 2b55283075a5e85cfbb0f475af1862e2b66cfe7f..0000000000000000000000000000000000000000 --- a/services/firmware/upgrade/mode/include/firmware_stream_install_apply_mode.h +++ /dev/null @@ -1,69 +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 FIRMWARE_STREAM_INSTALL_APPLY_MODE_H -#define FIRMWARE_STREAM_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 "upgrade_options.h" - -namespace OHOS { -namespace UpdateEngine { -class FirmwareStreamInstallApplyMode final : public FirmwareIExecuteMode { -public: - FirmwareStreamInstallApplyMode(const UpgradeOptions &upgradeOptions, BusinessError &businessError, - InstallType installType, OnExecuteFinishCallback onExecuteFinishCallback) - : upgradeOptions_(upgradeOptions), - businessError_(businessError), - installType_(installType), - onExecuteFinishCallback_(onExecuteFinishCallback) {} - - ~FirmwareStreamInstallApplyMode() = default; - FirmwareStep GetNextStep(FirmwareStep step) final; - void SetInstallResult(const InstallCallbackInfo &installCallbackInfo) final; - UpgradeOptions GetUpgradeOptions() final; - InstallType GetInstallType(); - void HandleComplete() final; - -private: - FirmwareStep GetStepAfterInit(); - FirmwareStep GetStepAfterInstall(); - FirmwareStep GetStepAfterApply(); - FirmwareStep GetStepForInstallAndApplyOrder(); - bool IsAllowInstall(); - - void GetTask(); - void SetApplyResult(bool isSuccess); - -private: - FirmwareInstallDataProcessor installStepDataProcessor_; - UpgradeOptions upgradeOptions_; - BusinessError &businessError_; - InstallType installType_; - OnExecuteFinishCallback onExecuteFinishCallback_; - FirmwareTask tasks_; - std::shared_ptr preferencesUtil_ = - DelayedSingleton::GetInstance(); -}; -} // namespace UpdateEngine -} // namespace OHOS -#endif // FIRMWARE_STREAM_INSTALL_APPLY_MODE_H \ No newline at end of file diff --git a/services/firmware/upgrade/mode/src/firmware_stream_install_apply_mode.cpp b/services/firmware/upgrade/mode/src/firmware_stream_install_apply_mode.cpp deleted file mode 100644 index 469df35b05d4dad3a07c58c2fc21a6da167cd4c1..0000000000000000000000000000000000000000 --- a/services/firmware/upgrade/mode/src/firmware_stream_install_apply_mode.cpp +++ /dev/null @@ -1,162 +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. - */ - -#include "firmware_stream_install_apply_mode.h" - -#include - -#include "dupdate_errno.h" -#include "dupdate_net_manager.h" -#include "dupdate_upgrade_helper.h" -#include "firmware_callback_utils.h" -#include "firmware_changelog_utils.h" -#include "firmware_common.h" -#include "firmware_component_operator.h" -#include "firmware_constant.h" -#include "firmware_log.h" -#include "firmware_preferences_utils.h" -#include "firmware_status_cache.h" -#include "firmware_task_operator.h" -#include "firmware_update_helper.h" - -namespace OHOS { -namespace UpdateEngine { -FirmwareStep FirmwareStreamInstallApplyMode::GetNextStep(FirmwareStep step) -{ - FIRMWARE_LOGI("GetNextStep %{public}d", static_cast(step)); - FirmwareStep nextStep = FirmwareStep::COMPLETE; - switch (step) { - case FirmwareStep::INIT: - nextStep = GetStepAfterInit(); - break; - case FirmwareStep::INSTALL_STEP: - nextStep = GetStepAfterInstall(); - break; - case FirmwareStep::APPLY_STEP: - nextStep = GetStepAfterApply(); - break; - default: - break; - } - return nextStep; -} - -FirmwareStep FirmwareStreamInstallApplyMode::GetStepAfterInit() -{ - GetTask(); - if (!tasks_.isExistTask) { - FIRMWARE_LOGI("GetStepAfterInit no task"); - businessError_.Build(CallResult::FAIL, "no task!"); - return FirmwareStep::COMPLETE; - } - - FIRMWARE_LOGI("GetStepAfterInit status %{public}d taskId = %{public}s, order = %{public}d", - static_cast(tasks_.status), tasks_.taskId.c_str(), CAST_INT(upgradeOptions_.order)); - - if (upgradeOptions_.order == Order::INSTALL || upgradeOptions_.order == Order::INSTALL_AND_APPLY) { - return GetStepForInstallAndApplyOrder(); - } - - if (upgradeOptions_.order == Order::APPLY) { - return FirmwareStep::APPLY_STEP; - } - - businessError_.Build(CallResult::FAIL, "upgradeOptions error"); - return FirmwareStep::COMPLETE; -} - -FirmwareStep FirmwareStreamInstallApplyMode::GetStepForInstallAndApplyOrder() -{ - if (!IsAllowInstall()) { - return FirmwareStep::COMPLETE; - } - - return FirmwareStep::INSTALL_STEP; -} - -bool FirmwareStreamInstallApplyMode::IsAllowInstall() -{ - FIRMWARE_LOGI("IsAllowInstall is StreamUpgrade"); - if (installType_ != InstallType::STREAM_INSTALLLER) { - FIRMWARE_LOGE("IsAllowInstall stream is not support"); - businessError_.Build(CallResult::FAIL, "install condition fail!"); - businessError_.AddErrorMessage(CAST_INT(DUPDATE_ERR_LOW_BATTERY_LEVEL), "battery is low"); - return false; - } - if (!DelayedSingleton::GetInstance()->IsNetAvailable()) { - FIRMWARE_LOGI("IsAllowInstall IsNeedBlockCheck no network, nettype is %{public}d", - DelayedSingleton::GetInstance()->GetNetType()); - businessError_.Build(CallResult::FAIL, "download no network!"); - businessError_.AddErrorMessage(CAST_INT(DUPDATE_ERR_DLOAD_REQUEST_FAIL), "download no network!"); - return false; - } - if (!FirmwareUpdateHelper::IsBatteryEnough(MANUAL_UPGRADE_BATTERY_LEVEL)) { - FIRMWARE_LOGE("IsAllowInstall isBatteryEnough is false"); - businessError_.Build(CallResult::FAIL, "install condition fail!"); - businessError_.AddErrorMessage(CAST_INT(DUPDATE_ERR_LOW_BATTERY_LEVEL), "battery is low"); - return false; - } - return true; -} - -FirmwareStep FirmwareStreamInstallApplyMode::GetStepAfterInstall() -{ - FIRMWARE_LOGI("FirmwareStreamInstallApplyMode installOptions %{public}d", CAST_INT(upgradeOptions_.order)); - if (installStepDataProcessor_.HasInstallFail()) { - FirmwareUpdateHelper::ClearFirmwareInfo(); - } - - return FirmwareStep::COMPLETE; -} - -FirmwareStep FirmwareStreamInstallApplyMode::GetStepAfterApply() -{ - return FirmwareStep::COMPLETE; -} - -void FirmwareStreamInstallApplyMode::GetTask() -{ - if (!tasks_.isExistTask) { - FirmwareTaskOperator().QueryTask(tasks_); - FIRMWARE_LOGI("FirmwareStreamInstallApplyMode::GetTask status: %{public}d ", CAST_INT(tasks_.status)); - } -} - -void FirmwareStreamInstallApplyMode::HandleComplete() -{ - onExecuteFinishCallback_(); -} - -UpgradeOptions FirmwareStreamInstallApplyMode::GetUpgradeOptions() -{ - return upgradeOptions_; -} - -InstallType FirmwareStreamInstallApplyMode::GetInstallType() -{ - return installType_; -} - -void FirmwareStreamInstallApplyMode::SetInstallResult(const InstallCallbackInfo &installCallbackInfo) -{ - installStepDataProcessor_.SetInstallResult(installCallbackInfo); -} - -void FirmwareStreamInstallApplyMode::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/status/include/firmware_status_cache.h b/services/firmware/upgrade/status/include/firmware_status_cache.h index 68f428f48304c6fa21b9ef7637fea0a98a41f11c..4c60a414efbd5f761ac8600d434e0e209cc452da 100644 --- a/services/firmware/upgrade/status/include/firmware_status_cache.h +++ b/services/firmware/upgrade/status/include/firmware_status_cache.h @@ -29,7 +29,6 @@ public: bool IsChecking(); void SetIsChecking(bool isChecking); bool IsDownloadTriggered(); - bool IsUpgradeTriggered(); private: std::shared_ptr statusCache_ = nullptr; }; diff --git a/services/firmware/upgrade/status/src/firmware_status_cache.cpp b/services/firmware/upgrade/status/src/firmware_status_cache.cpp index b97043e41acdb5f7e30358bac41da2c14bf1276e..b5abc046312ac20717ec1c8a0c9b2f1258cd9f99 100644 --- a/services/firmware/upgrade/status/src/firmware_status_cache.cpp +++ b/services/firmware/upgrade/status/src/firmware_status_cache.cpp @@ -54,13 +54,5 @@ bool FirmwareStatusCache::IsDownloadTriggered() } return statusCache_->IsDownloadTriggered(); } - -bool FirmwareStatusCache::IsUpgradeTriggered() -{ - if (statusCache_ == nullptr) { - return false; - } - return statusCache_->IsUpgradeTriggered(); -} } // 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 778bfa40ce083208113a0f0fc206c7a349e714bc..bb676d410c9ad59801fb7823ade20f6e40ccb570 100644 --- a/services/firmware/utils/include/firmware_check_analyze_utils.h +++ b/services/firmware/utils/include/firmware_check_analyze_utils.h @@ -36,8 +36,6 @@ public: private: bool IsLegalStatus(int32_t status); int32_t AnalyzeComponents(nlohmann::json &root); - int32_t ProcessCheckResults(const nlohmann::json &checkResults); - int32_t ProcessDescriptInfo(const nlohmann::json &descriptInfo); int32_t AnalyzeBlVersionCheckResults(nlohmann::json &root, BlCheckResponse &response); private: diff --git a/services/firmware/utils/src/firmware_check_analyze_utils.cpp b/services/firmware/utils/src/firmware_check_analyze_utils.cpp index d9f53797dda11c29557a81471c6f0df5da1303de..488032534444c19adf40530ed6ea48acda312d5a 100644 --- a/services/firmware/utils/src/firmware_check_analyze_utils.cpp +++ b/services/firmware/utils/src/firmware_check_analyze_utils.cpp @@ -104,41 +104,15 @@ int32_t FirmwareCheckAnalyzeUtils::AnalyzeBlVersionCheckResults(nlohmann::json & int32_t FirmwareCheckAnalyzeUtils::AnalyzeComponents(nlohmann::json &root) { - // 检查 "checkResults" 是否存在 if (root.find("checkResults") == root.end()) { FIRMWARE_LOGE("FirmwareCheckAnalyzeUtils::AnalyzeComponents no key checkResults"); return CAST_INT(JsonParseError::MISSING_PROP); } FIRMWARE_LOGI("checkResults size is %{public}" PRIu64 "", static_cast(root["checkResults"].size())); - - // 初始化返回值 int32_t ret = CAST_INT(JsonParseError::ERR_OK); - - // 处理 "checkResults" 部分 - ret += ProcessCheckResults(root["checkResults"]); - - // 检查 "descriptInfo" 是否存在 - if (root.find("descriptInfo") == root.end()) { - FIRMWARE_LOGE("FirmwareCheckAnalyzeUtils::AnalyzeComponents no key descriptInfo"); - return CAST_INT(JsonParseError::MISSING_PROP); - } - - // 处理 "descriptInfo" 部分 - ret += ProcessDescriptInfo(root["descriptInfo"]); - - return ret; -} - -int32_t FirmwareCheckAnalyzeUtils::ProcessCheckResults(const nlohmann::json &checkResults) -{ - int32_t ret = CAST_INT(JsonParseError::ERR_OK); - std::string componentId; - for (auto &result : checkResults) { FirmwareComponent component; int32_t componetSize = 0; - - // 获取组件相关属性 ret += JsonUtils::GetValueAndSetTo(result, "descriptPackageId", component.descriptPackageId); ret += JsonUtils::GetValueAndSetTo(result, "url", component.url); ret += JsonUtils::GetValueAndSetTo(result, "size", componetSize); @@ -147,15 +121,6 @@ int32_t FirmwareCheckAnalyzeUtils::ProcessCheckResults(const nlohmann::json &che ret += JsonUtils::GetValueAndSetTo(result, "verifyInfo", component.verifyInfo); ret += JsonUtils::GetValueAndSetTo(result, "versionCode", component.versionNumber); ret += JsonUtils::GetValueAndSetTo(result, "versionName", component.targetBlVersionNumber); - - int32_t versionPackageType = CAST_INT(PackageType::DYNAMIC); - ret += JsonUtils::GetValueAndSetTo(result, "packageType", versionPackageType); - component.versionPackageType = static_cast(versionPackageType); - - int32_t otaType = CAST_INT(OtaType::REGULAR); - ret += JsonUtils::GetValueAndSetTo(result, "otaType", otaType); - component.otaType = static_cast(otaType); - component.targetBlDisplayVersionNumber = component.targetBlVersionNumber; component.blVersionType = 1; component.componentId = component.descriptPackageId; diff --git a/services/service/include/dupdate_errno.h b/services/service/include/dupdate_errno.h index 7545bdf12d0e02a598d73c3e00fb08e51cf355ef..9712945751abd9e812e7425ced2ae93893f60011 100644 --- a/services/service/include/dupdate_errno.h +++ b/services/service/include/dupdate_errno.h @@ -64,7 +64,6 @@ typedef enum { DUPDATE_ERR_IPC_ERROR = -410, DUPDATE_ERR_UPDATE_NO_EXECUTED = -411, DUPDATE_ERR_UPDATE_FILE_ERROR = -412, - DUPDATE_ERR_CANCEL_TASK_ERROR = -413, /* -499 ~ -420 reserved for private update error numbers */ DUPDATE_ERR_UPDATE_PRECHECK_FAIL = -420, diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 0624938e8d3dfaa74375a7eeff8bc1c6d7f8b42b..8621f097a23a07b586546a370773ffc764c75828 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -18,6 +18,5 @@ group("unittest") { testonly = true deps = [ "$updateengine_root_path/foundations/ability/log/src/test/unittest:UpdateLogTest", - "$updateengine_root_path/test/unittest/stream_install:stream_install_unittest", ] } diff --git a/test/unittest/stream_install/BUILD.gn b/test/unittest/stream_install/BUILD.gn deleted file mode 100644 index f057a5b86e8c68935e05d19129bfaeebc7330542..0000000000000000000000000000000000000000 --- a/test/unittest/stream_install/BUILD.gn +++ /dev/null @@ -1,66 +0,0 @@ -# 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/services/engine/engine_sa.gni") -import("//base/update/updateservice/updateengine.gni") -import("//build/test.gni") - -module_output_path = "$updateengine_part_name/$updateengine_unittest_name" - -ohos_unittest("firmware_stream_installer_install_test") { - module_out_path = module_output_path - include_dirs = sa_include_dirs - deps = sa_deps - external_deps = sa_external_deps - defines = [ - "UPDATER_UT", - "RELATIONAL_STORE_NATIVE_RDB_ENABLE", - ] - sources = [ - "$firmware_root_path/data/db/src/firmware_component_operator.cpp", - "$firmware_root_path/data/db/src/firmware_component_table.cpp", - "$firmware_root_path/data/db/src/firmware_database.cpp", - "$firmware_root_path/data/db/src/firmware_database_callback.cpp", - "$firmware_root_path/data/db/src/firmware_task_operator.cpp", - "$firmware_root_path/data/db/src/firmware_task_table.cpp", - "$firmware_root_path/upgrade/install/src/firmware_install.cpp", - "$firmware_root_path/upgrade/install/src/firmware_stream_installer_install.cpp", - "$sqlite_root_path/core/src/sqlite_db.cpp", - "$updateengine_root_path/test/unittest/stream_install/firmware_stream_installer_install_test.cpp", - ] - external_deps += [ "googletest:gtest_main" ] - part_name = updateengine_part_name -} - -ohos_unittest("stream_progress_thread_test") { - module_out_path = module_output_path - include_dirs = sa_include_dirs - deps = sa_deps - external_deps = sa_external_deps - defines = [ "UPDATER_UT" ] - sources = [ - "$updateengine_root_path/services/engine/src/progress_thread.cpp", - "$updateengine_root_path/services/engine/src/stream_progress_thread.cpp", - "$updateengine_root_path/test/unittest/stream_install/stream_progress_thread_test.cpp", - ] - external_deps += [ "googletest:gtest_main" ] - part_name = updateengine_part_name -} - -group("stream_install_unittest") { - testonly = true - deps = [ - ":firmware_stream_installer_install_test", - ":stream_progress_thread_test", - ] -} diff --git a/test/unittest/stream_install/firmware_stream_installer_install_test.cpp b/test/unittest/stream_install/firmware_stream_installer_install_test.cpp deleted file mode 100644 index 49a3601fff31b5e642b765e4368f014d1e0bea7b..0000000000000000000000000000000000000000 --- a/test/unittest/stream_install/firmware_stream_installer_install_test.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 -#include "firmware_stream_installer_install.h" - -using namespace testing::ext; -using namespace testing; - -namespace OHOS::UpdateEngine { - -UpgradeStatus g_status; -bool g_result; -void OnFirmwareProgressImpl(const FirmwareComponent &component) -{ -} - -void OnFirmwareEventImpl(bool result, const ErrorMessage &errMsg, UpgradeStatus status) -{ - g_result = result; - g_status = status; -} - -void OnFirmwareStatusImpl(UpgradeStatus status) -{ - g_status = status; -} - -class StreamInstallerInstallTest : public ::testing::Test { -protected: - void SetUp() override - { - installer = std::make_unique(); - } - - std::unique_ptr installer; -}; - -// 测试 StartInstall 函数 -HWTEST_F(StreamInstallerInstallTest, StartInstallSuccess, TestSize.Level1) -{ - FirmwareComponent component; - component.url = "http://file-examples.com/wp-content/uploads/2017/02/file-example_txt-download.txt"; - component.size = 2250; - component.status = UpgradeStatus::INIT; - component.progress = 0; - component.recordPoint = 0; - - FirmwareInstallCallback callback; - callback.onFirmwareProgress = OnFirmwareProgressImpl; - callback.onFirmwareEvent = OnFirmwareEventImpl; - callback.onFirmwareStatus = OnFirmwareStatusImpl; - - // 创建组件列表 - std::vector componentList = {component}; - - // 调用 StartInstall - installer->StartInstall(componentList, callback); - ASSERT_EQ(g_result, true); -} - -HWTEST_F(StreamInstallerInstallTest, StartInstallFailure, TestSize.Level1) -{ - // 创建空组件列表 - std::vector emptyList; - - FirmwareInstallCallback callback; - callback.onFirmwareProgress = OnFirmwareProgressImpl; - callback.onFirmwareEvent = OnFirmwareEventImpl; - callback.onFirmwareStatus = OnFirmwareStatusImpl; - - // 调用 StartInstall - installer->StartInstall(emptyList, callback); - - ASSERT_EQ(g_result, false); -} - -} // namespace OHOS::UpdateEngine \ No newline at end of file diff --git a/test/unittest/stream_install/stream_progress_thread_test.cpp b/test/unittest/stream_install/stream_progress_thread_test.cpp deleted file mode 100644 index ce3c4102666f8382e5df0aac2bc1cfd241987e13..0000000000000000000000000000000000000000 --- a/test/unittest/stream_install/stream_progress_thread_test.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 - -#include "progress_thread.h" - -using namespace testing::ext; -using namespace testing; - -namespace OHOS::UpdateEngine { - -Progress downloadProgress; -void TestProgressCallback(const Progress &progress) -{ - downloadProgress = progress; -} - -class StreamProgressThreadTest : public testing::Test { -public: - static void SetupTestCase(void) {}; - static void TearDownTestCase(void) {}; - void SetUp() final {}; - void TearDown() final {}; -}; - -HWTEST_F(StreamProgressThreadTest, StartDownloadTest, TestSize.Level1) -{ - StreamProgressThread thread(TestProgressCallback); - - std::string url = "http://file-examples.com/wp-content/uploads/2017/02/file-example_txt-download.txt"; - int64_t fileSize = 2250; - int64_t recordPoint = 0; - - // 调用 StartDownload - int32_t result = thread.StartDownload(url, fileSize, recordPoint); - ASSERT_EQ(result, 0); // 假设 StartDownload 返回 0 表示成功 - thread.StopDownload(); -} - -HWTEST_F(StreamProgressThreadTest, WriteFuncTest, TestSize.Level1) -{ - StreamProgressThread thread(TestProgressCallback); - - // 模拟写入数据 - uint8_t data[] = {0x01, 0x02, 0x03, 0x04}; - size_t size = sizeof(data); - size_t nmemb = 1; - - // 调用 WriteFunc - size_t result = StreamProgressThread::WriteFunc(data, size, nmemb, &thread); - ASSERT_EQ(result, size); -} - -HWTEST_F(StreamProgressThreadTest, DownloadProgressTest, TestSize.Level1) -{ - StreamProgressThread thread(TestProgressCallback); - - // 模拟进度更新参数 - double dlTotal = 1024; - double dlNow = 512; - double ulTotal = 0; - double ulNow = 0; - - // 调用 DownloadProgress - int32_t result = StreamProgressThread::DownloadProgress(&thread, dlTotal, dlNow, ulTotal, ulNow); - ASSERT_EQ(result, 0); -} -} // namespace OHOS::UpdateEngine \ No newline at end of file