From bd284a4fc1b5bc98e9733d89d8b64d6f65b99aa7 Mon Sep 17 00:00:00 2001 From: xieluyao Date: Mon, 28 Apr 2025 17:43:10 +0800 Subject: [PATCH] update Signed-off-by: xieluyao --- frameworks/installer_manager/BUILD.gn | 5 - .../include/stream_installer_manager.h | 47 ------ .../include/stream_installer_manager_helper.h | 40 ----- .../include/sys_installer_manager.h | 91 ----------- .../include/sys_installer_manager_helper.h | 44 ------ .../src/stream_installer_manager.cpp | 94 ------------ .../src/stream_installer_manager_helper.cpp | 97 ------------ .../src/sys_installer_manager.cpp | 116 -------------- .../src/sys_installer_manager_helper.cpp | 100 ------------- .../include/sys_installer_callback_proxy.h | 2 - .../ipc_server/include/sys_installer_server.h | 6 - .../ipc_server/include/sys_installer_stub.h | 6 - .../src/sys_installer_callback_proxy.cpp | 29 ---- .../ipc_server/src/sys_installer_server.cpp | 32 ---- .../ipc_server/src/sys_installer_stub.cpp | 45 ------ frameworks/status_manager/BUILD.gn | 1 - .../include/stream_status_manager.h | 43 ------ .../src/stream_status_manager.cpp | 67 --------- interfaces/inner_api/include/isys_installer.h | 3 - .../include/isys_installer_callback.h | 2 - .../include/isys_installer_callback_func.h | 2 - .../sys_installer_sa_ipc_interface_code.h | 4 - .../include/sys_installer_callback.h | 1 - .../ipc_client/include/sys_installer_kits.h | 3 - .../include/sys_installer_kits_impl.h | 3 - .../ipc_client/include/sys_installer_proxy.h | 3 - .../ipc_client/src/sys_installer_callback.cpp | 15 -- .../ipc_client/src/sys_installer_client.cpp | 5 - .../src/sys_installer_kits_impl.cpp | 39 ----- .../ipc_client/src/sys_installer_proxy.cpp | 84 ----------- .../module_update/util/include/module_utils.h | 1 - .../module_update/util/src/module_utils.cpp | 17 --- services/stream_update/BUILD.gn | 45 ------ .../stream_update/include/stream_update.h | 59 -------- services/stream_update/src/stream_update.cpp | 141 ------------------ .../imodule_update_fuzzer.cpp | 5 - test/unittest/ipc_test/BUILD.gn | 97 ------------ .../ipc_test/sys_installer_ipc_test.cpp | 5 - test/unittest/stream_update/BUILD.gn | 79 ---------- .../stream_update/stream_update_test.cpp | 63 -------- .../stream_update/stream_update_test.h | 51 ------- tools/module_update_tool/main.cpp | 4 - 42 files changed, 1596 deletions(-) delete mode 100644 frameworks/installer_manager/include/stream_installer_manager.h delete mode 100644 frameworks/installer_manager/include/stream_installer_manager_helper.h delete mode 100644 frameworks/installer_manager/include/sys_installer_manager.h delete mode 100644 frameworks/installer_manager/include/sys_installer_manager_helper.h delete mode 100644 frameworks/installer_manager/src/stream_installer_manager.cpp delete mode 100644 frameworks/installer_manager/src/stream_installer_manager_helper.cpp delete mode 100644 frameworks/installer_manager/src/sys_installer_manager.cpp delete mode 100644 frameworks/installer_manager/src/sys_installer_manager_helper.cpp delete mode 100644 frameworks/status_manager/include/stream_status_manager.h delete mode 100644 frameworks/status_manager/src/stream_status_manager.cpp delete mode 100755 services/stream_update/BUILD.gn delete mode 100755 services/stream_update/include/stream_update.h delete mode 100755 services/stream_update/src/stream_update.cpp delete mode 100755 test/unittest/ipc_test/BUILD.gn delete mode 100755 test/unittest/stream_update/BUILD.gn delete mode 100755 test/unittest/stream_update/stream_update_test.cpp delete mode 100755 test/unittest/stream_update/stream_update_test.h diff --git a/frameworks/installer_manager/BUILD.gn b/frameworks/installer_manager/BUILD.gn index 7afb01f..2c90910 100644 --- a/frameworks/installer_manager/BUILD.gn +++ b/frameworks/installer_manager/BUILD.gn @@ -25,7 +25,6 @@ config("libinstallermanager_exported_headers") { "${sys_installer_path}/frameworks/installer_manager/include", "${sys_installer_path}/frameworks/status_manager/include", "${sys_installer_path}/services/ab_update/include", - "${sys_installer_path}/services/stream_update/include", ] } ohos_static_library("libinstallermanager") { @@ -46,22 +45,18 @@ ohos_static_library("libinstallermanager") { "${sys_installer_path}/frameworks/installer_manager/include", "${sys_installer_path}/frameworks/status_manager/include", "${sys_installer_path}/services/ab_update/include", - "${sys_installer_path}/services/stream_update/include", ] deps = [ "${sys_installer_path}/frameworks/action_processer:libactionprocesser", "${sys_installer_path}/frameworks/actions/verify_action:libverifyaction", "${sys_installer_path}/services/ab_update:libabupdate", - "${sys_installer_path}/services/stream_update:libstreamupdate", ] public_configs = [ ":libinstallermanager_exported_headers" ] external_deps = [ - "bounds_checking_function:libsec_static", "hilog:libhilog", "openssl:libcrypto_shared", "openssl:libssl_static", - "updater:libbinchunkupdate", "updater:libpackageExt", "updater:libringbuffer", "updater:libupdater", diff --git a/frameworks/installer_manager/include/stream_installer_manager.h b/frameworks/installer_manager/include/stream_installer_manager.h deleted file mode 100644 index 8abf35f..0000000 --- a/frameworks/installer_manager/include/stream_installer_manager.h +++ /dev/null @@ -1,47 +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 STREAM_INSTALLER_MANAGER_H -#define STREAM_INSTALLER_MANAGER_H - -#include "stream_installer_manager_helper.h" -#include "macros_updater.h" -#include "stream_status_manager.h" - -namespace OHOS { -namespace SysInstaller { -class StreamInstallerManager { - DISALLOW_COPY_MOVE(StreamInstallerManager); -public: - void RegisterDump(std::unique_ptr ptr); - static StreamInstallerManager &GetInstance(); - - virtual int32_t SysInstallerInit(); - virtual int32_t StartStreamUpdate(); - virtual int32_t StopStreamUpdate(); - virtual int32_t ProcessStreamData(const uint8_t *buffer, size_t size); - virtual int32_t SetUpdateCallback(const sptr &updateCallback); - virtual int32_t GetUpdateStatus(); - -protected: - std::unique_ptr helper_ {}; - -private: - StreamInstallerManager() = default; - ~StreamInstallerManager() = default; -}; -} // SysInstaller -} // namespace OHOS -#endif // SYS_INSTALLER_MANAGER_HELPER_H diff --git a/frameworks/installer_manager/include/stream_installer_manager_helper.h b/frameworks/installer_manager/include/stream_installer_manager_helper.h deleted file mode 100644 index 25150e6..0000000 --- a/frameworks/installer_manager/include/stream_installer_manager_helper.h +++ /dev/null @@ -1,40 +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 STREAM_INSTALLER_MANAGER_HELPER_H -#define STREAM_INSTALLER_MANAGER_HELPER_H - -#include "stream_status_manager.h" - -namespace OHOS { -namespace SysInstaller { -class StreamInstallerManagerHelper { -public: - StreamInstallerManagerHelper() = default; - virtual ~StreamInstallerManagerHelper() = default; - - virtual int32_t SysInstallerInit(); - virtual int32_t SetUpdateCallback(const sptr &updateCallback); - virtual int32_t GetUpdateStatus(); - virtual int32_t StartStreamUpdate(); - virtual int32_t StopStreamUpdate(); - virtual int32_t ProcessStreamData(const uint8_t *buffer, size_t size); - -protected: - std::shared_ptr statusManager_ {}; -}; -} // SysInstaller -} // namespace OHOS -#endif // SYS_INSTALLER_MANAGER_HELPER_H diff --git a/frameworks/installer_manager/include/sys_installer_manager.h b/frameworks/installer_manager/include/sys_installer_manager.h deleted file mode 100644 index 2324684..0000000 --- a/frameworks/installer_manager/include/sys_installer_manager.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2022 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 SYS_INSTALLER_MANAGER_H -#define SYS_INSTALLER_MANAGER_H - -#include "sys_installer_manager_helper.h" -#include "macros_updater.h" -#include "status_manager.h" - -namespace OHOS { -namespace SysInstaller { -class SysInstallerManager { - DISALLOW_COPY_MOVE(SysInstallerManager); -public: - void RegisterDump(std::unique_ptr ptr); - static SysInstallerManager &GetInstance(); - - virtual int32_t SysInstallerInit(); - virtual int32_t StartUpdatePackageZip(const std::string &pkgPath); - virtual int32_t SetUpdateCallback(const sptr &updateCallback); - virtual int32_t GetUpdateStatus(); - virtual int32_t StartUpdateParaZip(const std::string &pkgPath, - const std::string &location, const std::string &cfgDir); - virtual int32_t StartDeleteParaZip(const std::string &location, const std::string &cfgDir); - virtual int32_t AccDecompressAndVerifyPkg(const std::string &srcPath, - const std::string &dstPath, const uint32_t type); - virtual int32_t AccDeleteDir(const std::string &dstPath); - -protected: - std::unique_ptr helper_ {}; - -private: - SysInstallerManager() = default; - ~SysInstallerManager() = default; -}; - -enum SysInstallerInitEvent { - SYS_PRE_INIT_EVENT = 0, - SYS_POST_INIT_EVENT, - SYS_POST_EVENT, - SYS_APP_QUICKFIX_EVENT, - SYS_INIT_EVENT_BUTT -}; -using InitHandler = void (*)(void); - -class SysInstallerManagerInit { - DISALLOW_COPY_MOVE(SysInstallerManagerInit); -public: - static SysInstallerManagerInit &GetInstance() - { - static SysInstallerManagerInit instance; - return instance; - } - void InvokeEvent(enum SysInstallerInitEvent eventId) const - { - if (eventId >= SYS_INIT_EVENT_BUTT) { - return; - } - for (const auto &handler : initEvent_[eventId]) { - if (handler != nullptr) { - handler(); - } - } - } - void SubscribeEvent(enum SysInstallerInitEvent eventId, InitHandler handler) - { - if (eventId < SYS_INIT_EVENT_BUTT) { - initEvent_[eventId].push_back(handler); - } - } -private: - SysInstallerManagerInit() = default; - ~SysInstallerManagerInit() = default; - std::vector initEvent_[SYS_INIT_EVENT_BUTT]; -}; -} // SysInstaller -} // namespace OHOS -#endif // SYS_INSTALLER_MANAGER_HELPER_H diff --git a/frameworks/installer_manager/include/sys_installer_manager_helper.h b/frameworks/installer_manager/include/sys_installer_manager_helper.h deleted file mode 100644 index ec0557d..0000000 --- a/frameworks/installer_manager/include/sys_installer_manager_helper.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022 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 SYS_INSTALLER_MANAGER_HELPER_H -#define SYS_INSTALLER_MANAGER_HELPER_H - -#include "status_manager.h" - -namespace OHOS { -namespace SysInstaller { -class SysInstallerManagerHelper { -public: - SysInstallerManagerHelper() = default; - virtual ~SysInstallerManagerHelper() = default; - - virtual int32_t SysInstallerInit(); - virtual int32_t StartUpdatePackageZip(const std::string &pkgPath); - virtual int32_t SetUpdateCallback(const sptr &updateCallback); - virtual int32_t GetUpdateStatus(); - virtual int32_t StartUpdateParaZip(const std::string &pkgPath, - const std::string &location, const std::string &cfgDir); - virtual int32_t StartDeleteParaZip(const std::string &location, const std::string &cfgDir); - virtual int32_t AccDecompressAndVerifyPkg(const std::string &srcPath, - const std::string &dstPath, const uint32_t type); - virtual int32_t AccDeleteDir(const std::string &dstPath); - -protected: - std::shared_ptr statusManager_ {}; -}; -} // SysInstaller -} // namespace OHOS -#endif // SYS_INSTALLER_MANAGER_HELPER_H diff --git a/frameworks/installer_manager/src/stream_installer_manager.cpp b/frameworks/installer_manager/src/stream_installer_manager.cpp deleted file mode 100644 index 15c77b9..0000000 --- a/frameworks/installer_manager/src/stream_installer_manager.cpp +++ /dev/null @@ -1,94 +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 "stream_installer_manager.h" - -#include "log/log.h" -#include "package/pkg_manager.h" -#include "utils.h" -#include "updater_main.h" - -namespace OHOS { -namespace SysInstaller { -using namespace Updater; - -void StreamInstallerManager::RegisterDump(std::unique_ptr ptr) -{ - helper_ = std::move(ptr); -} - -StreamInstallerManager &StreamInstallerManager::GetInstance() -{ - static StreamInstallerManager instance; - return instance; -} - -int32_t StreamInstallerManager::SysInstallerInit() -{ - if (helper_ == nullptr) { - if (helper_ == nullptr) { - RegisterDump(std::make_unique()); - } - } - return helper_->SysInstallerInit(); -} - -int32_t StreamInstallerManager::StartStreamUpdate() -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->StartStreamUpdate(); -} - -int32_t StreamInstallerManager::StopStreamUpdate() -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->StopStreamUpdate(); -} - -int32_t StreamInstallerManager::ProcessStreamData(const uint8_t *buffer, size_t size) -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->ProcessStreamData(buffer, size); -} - -int32_t StreamInstallerManager::SetUpdateCallback(const sptr &updateCallback) -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->SetUpdateCallback(updateCallback); -} - -int32_t StreamInstallerManager::GetUpdateStatus() -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->GetUpdateStatus(); -} - -} // namespace SysInstaller -} // namespace OHOS diff --git a/frameworks/installer_manager/src/stream_installer_manager_helper.cpp b/frameworks/installer_manager/src/stream_installer_manager_helper.cpp deleted file mode 100644 index 905ed3c..0000000 --- a/frameworks/installer_manager/src/stream_installer_manager_helper.cpp +++ /dev/null @@ -1,97 +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 "stream_installer_manager_helper.h" - -#include "log/log.h" -#include "stream_update.h" -#include "utils.h" - -namespace OHOS { -namespace SysInstaller { -using namespace Hpackage; -using namespace Updater; - -int32_t StreamInstallerManagerHelper::SysInstallerInit() -{ - LOG(INFO) << "SysInstallerInit"; - - if (statusManager_ == nullptr) { - statusManager_ = std::make_shared(); - } - statusManager_->Init(); - StreamInstallProcesser::GetInstance().SetStatusManager(statusManager_); - - return 0; -} - -int32_t StreamInstallerManagerHelper::StartStreamUpdate() -{ - LOG(INFO) << "StartStreamUpdate start"; - if (statusManager_ == nullptr) { - LOG(ERROR) << "statusManager_ nullptr"; - return -1; - } - if (StreamInstallProcesser::GetInstance().IsRunning()) { - LOG(ERROR) << "StreamInstallProcesser IsRunning"; - return -1; - } - if (StreamInstallProcesser::GetInstance().Start() == -1) { - LOG(ERROR) << "StreamInstallProcesser start fail"; - return -1; - } - return 0; -} - -int32_t StreamInstallerManagerHelper::StopStreamUpdate() -{ - LOG(INFO) << "StopStreamUpdate enter"; - if (statusManager_ == nullptr) { - LOG(ERROR) << "statusManager_ nullptr"; - return -1; - } - if (!StreamInstallProcesser::GetInstance().IsRunning()) { - LOG(ERROR) << "StreamInstallProcesser is not Running"; - return -1; - } - StreamInstallProcesser::GetInstance().Stop(); - return 0; -} - -int32_t StreamInstallerManagerHelper::ProcessStreamData(const uint8_t *buffer, size_t size) -{ - return StreamInstallProcesser::GetInstance().ProcessStreamData(buffer, size); -} - -int32_t StreamInstallerManagerHelper::SetUpdateCallback(const sptr &updateCallback) -{ - if (statusManager_ == nullptr) { - LOG(ERROR) << "statusManager_ nullptr"; - return -1; - } - return statusManager_->SetUpdateCallback(updateCallback); -} - -int32_t StreamInstallerManagerHelper::GetUpdateStatus() -{ - if (statusManager_ == nullptr) { - LOG(ERROR) << "statusManager_ nullptr"; - return -1; - } - return statusManager_->GetUpdateStatus(); -} - -} // namespace SysInstaller -} // namespace OHOS diff --git a/frameworks/installer_manager/src/sys_installer_manager.cpp b/frameworks/installer_manager/src/sys_installer_manager.cpp deleted file mode 100644 index 4451722..0000000 --- a/frameworks/installer_manager/src/sys_installer_manager.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2022 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 "sys_installer_manager.h" - -#include "log/log.h" -#include "package/pkg_manager.h" -#include "utils.h" -#include "updater_main.h" - -namespace OHOS { -namespace SysInstaller { -using namespace Updater; - -void SysInstallerManager::RegisterDump(std::unique_ptr ptr) -{ - helper_ = std::move(ptr); -} - -SysInstallerManager &SysInstallerManager::GetInstance() -{ - static SysInstallerManager instance; - return instance; -} - -int32_t SysInstallerManager::SysInstallerInit() -{ - if (helper_ == nullptr) { - SysInstallerManagerInit::GetInstance().InvokeEvent(SYS_PRE_INIT_EVENT); - UpdaterInit::GetInstance().InvokeEvent(UPDATER_PRE_INIT_EVENT); - UpdaterInit::GetInstance().InvokeEvent(UPDATER_INIT_EVENT); - if (helper_ == nullptr) { - RegisterDump(std::make_unique()); - } - } - return helper_->SysInstallerInit(); -} - -int32_t SysInstallerManager::StartUpdatePackageZip(const std::string &pkgPath) -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->StartUpdatePackageZip(pkgPath); -} - -int32_t SysInstallerManager::SetUpdateCallback(const sptr &updateCallback) -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->SetUpdateCallback(updateCallback); -} - -int32_t SysInstallerManager::GetUpdateStatus() -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->GetUpdateStatus(); -} - -int32_t SysInstallerManager::StartUpdateParaZip(const std::string &pkgPath, - const std::string &location, const std::string &cfgDir) -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->StartUpdateParaZip(pkgPath, location, cfgDir); -} - -int32_t SysInstallerManager::StartDeleteParaZip(const std::string &location, const std::string &cfgDir) -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->StartDeleteParaZip(location, cfgDir); -} - -int32_t SysInstallerManager::AccDecompressAndVerifyPkg(const std::string &srcPath, - const std::string &dstPath, const uint32_t type) -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->AccDecompressAndVerifyPkg(srcPath, dstPath, type); -} - -int32_t SysInstallerManager::AccDeleteDir(const std::string &dstPath) -{ - if (helper_ == nullptr) { - LOG(ERROR) << "helper_ null"; - return -1; - } - return helper_->AccDeleteDir(dstPath); -} -} // namespace SysInstaller -} // namespace OHOS diff --git a/frameworks/installer_manager/src/sys_installer_manager_helper.cpp b/frameworks/installer_manager/src/sys_installer_manager_helper.cpp deleted file mode 100644 index dc2e8cc..0000000 --- a/frameworks/installer_manager/src/sys_installer_manager_helper.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2022 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 "sys_installer_manager_helper.h" - -#include "action_processer.h" -#include "log/log.h" -#include "package/cert_verify.h" -#include "package/pkg_manager.h" -#include "utils.h" -#include "pkg_verify.h" -#include "ab_update.h" - -namespace OHOS { -namespace SysInstaller { -using namespace Hpackage; -using namespace Updater; - -int32_t SysInstallerManagerHelper::SysInstallerInit() -{ - LOG(INFO) << "SysInstallerInit"; - - if (statusManager_ == nullptr) { - statusManager_ = std::make_shared(); - } - statusManager_->Init(); - ActionProcesser::GetInstance().SetStatusManager(statusManager_); - return 0; -} - -int32_t SysInstallerManagerHelper::StartUpdatePackageZip(const std::string &pkgPath) -{ - LOG(INFO) << "StartUpdatePackageZip start"; - if (statusManager_ == nullptr) { - LOG(ERROR) << "statusManager_ nullptr"; - return -1; - } - if (ActionProcesser::GetInstance().IsRunning()) { - LOG(ERROR) << "ActionProcesser IsRunning"; - return -1; - } - ActionProcesser::GetInstance().AddAction(std::make_unique(statusManager_, pkgPath)); - ActionProcesser::GetInstance().AddAction(std::make_unique(statusManager_, pkgPath)); - ActionProcesser::GetInstance().Start(); - return 0; -} - -int32_t SysInstallerManagerHelper::SetUpdateCallback(const sptr &updateCallback) -{ - if (statusManager_ == nullptr) { - LOG(ERROR) << "statusManager_ nullptr"; - return -1; - } - return statusManager_->SetUpdateCallback(updateCallback); -} - -int32_t SysInstallerManagerHelper::GetUpdateStatus() -{ - if (statusManager_ == nullptr) { - LOG(ERROR) << "statusManager_ nullptr"; - return -1; - } - return statusManager_->GetUpdateStatus(); -} - -int32_t SysInstallerManagerHelper::StartUpdateParaZip(const std::string &pkgPath, - const std::string &location, const std::string &cfgDir) -{ - return -1; -} - -int32_t SysInstallerManagerHelper::StartDeleteParaZip(const std::string &location, const std::string &cfgDir) -{ - return -1; -} - -int32_t SysInstallerManagerHelper::AccDecompressAndVerifyPkg(const std::string &srcPath, - const std::string &dstPath, const uint32_t type) -{ - return -1; -} - -int32_t SysInstallerManagerHelper::AccDeleteDir(const std::string &dstPath) -{ - return -1; -} -} // namespace SysInstaller -} // namespace OHOS diff --git a/frameworks/ipc_server/include/sys_installer_callback_proxy.h b/frameworks/ipc_server/include/sys_installer_callback_proxy.h index a8daf5f..ca0d3c9 100644 --- a/frameworks/ipc_server/include/sys_installer_callback_proxy.h +++ b/frameworks/ipc_server/include/sys_installer_callback_proxy.h @@ -29,8 +29,6 @@ public: void OnUpgradeProgress(UpdateStatus updateStatus, int percent, const std::string &resultMsg) override; - void OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen, const std::string &resultMsg) override; - private: static inline BrokerDelegator delegator_; }; diff --git a/frameworks/ipc_server/include/sys_installer_server.h b/frameworks/ipc_server/include/sys_installer_server.h index 8c1c177..11b2fa8 100644 --- a/frameworks/ipc_server/include/sys_installer_server.h +++ b/frameworks/ipc_server/include/sys_installer_server.h @@ -19,12 +19,10 @@ #include #include "if_system_ability_manager.h" #include "sys_installer_manager.h" -#include "stream_installer_manager.h" #include "ipc_skeleton.h" #include "iremote_stub.h" #include "isys_installer.h" #include "status_manager.h" -#include "stream_status_manager.h" #include "system_ability.h" #include "sys_installer_common.h" #include "sys_installer_stub.h" @@ -40,9 +38,6 @@ public: int32_t SysInstallerInit(bool bStreamUpgrade = false) override; int32_t StartUpdatePackageZip(const std::string &pkgPath) override; - int32_t StartStreamUpdate() override; - int32_t StopStreamUpdate() override; - int32_t ProcessStreamData(const uint8_t *buffer, size_t size) override; int32_t SetUpdateCallback(const sptr &updateCallback) override; int32_t GetUpdateStatus() override; int32_t StartUpdateParaZip(const std::string &pkgPath, @@ -62,7 +57,6 @@ public: private: bool logInit_ = false; - bool bStreamUpgrade_ = false; std::mutex sysInstallerServerLock_; }; } // namespace SysInstaller diff --git a/frameworks/ipc_server/include/sys_installer_stub.h b/frameworks/ipc_server/include/sys_installer_stub.h index 64cea85..0f0808b 100644 --- a/frameworks/ipc_server/include/sys_installer_stub.h +++ b/frameworks/ipc_server/include/sys_installer_stub.h @@ -41,12 +41,6 @@ private: MessageParcel &data, MessageParcel &reply, MessageOption &option); int32_t StartUpdatePackageZipStub(SysInstallerStub *service, MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t StartStreamUpdateStub(SysInstallerStub *service, - MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t StopStreamUpdateStub(SysInstallerStub *service, - MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t ProcessStreamDataStub(SysInstallerStub *service, - MessageParcel &data, MessageParcel &reply, MessageOption &option); int32_t SetUpdateCallbackStub(SysInstallerStub *service, MessageParcel &data, MessageParcel &reply, MessageOption &option); int32_t GetUpdateStatusStub(SysInstallerStub *service, diff --git a/frameworks/ipc_server/src/sys_installer_callback_proxy.cpp b/frameworks/ipc_server/src/sys_installer_callback_proxy.cpp index cb69c1a..56bfb24 100644 --- a/frameworks/ipc_server/src/sys_installer_callback_proxy.cpp +++ b/frameworks/ipc_server/src/sys_installer_callback_proxy.cpp @@ -51,34 +51,5 @@ void SysInstallerCallbackProxy::OnUpgradeProgress(UpdateStatus updateStatus, int LOG(ERROR) << "Can not SendRequest " << result; } } - -void SysInstallerCallbackProxy::OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen, - const std::string &resultMsg) -{ - LOG(INFO) << "OnUpgradeDealLen"; - MessageParcel data; - MessageParcel reply; - MessageOption option { MessageOption::TF_SYNC }; - - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG(INFO) << "UpdateCallbackProxy WriteInterfaceToken fail"; - return; - } - - auto remote = Remote(); - if (remote == nullptr) { - LOG(ERROR) << "Can not get remote"; - return; - } - - data.WriteInt32(updateStatus); - data.WriteInt32(dealLen); - data.WriteString(resultMsg); - int32_t result = remote->SendRequest( - static_cast(SysInstallerCallbackInterfaceCode::STREAM_UPDATE_RESULT), data, reply, option); - if (result != ERR_OK) { - LOG(ERROR) << "Can not SendRequest " << result; - } -} } } // namespace OHOS diff --git a/frameworks/ipc_server/src/sys_installer_server.cpp b/frameworks/ipc_server/src/sys_installer_server.cpp index 1421628..a3496ce 100644 --- a/frameworks/ipc_server/src/sys_installer_server.cpp +++ b/frameworks/ipc_server/src/sys_installer_server.cpp @@ -45,13 +45,7 @@ int32_t SysInstallerServer::SysInstallerInit(bool bStreamUpgrade) InitUpdaterLogger("SysInstaller", SYS_LOG_FILE, SYS_STAGE_FILE, SYS_ERROR_FILE); logInit_ = true; } - bStreamUpgrade_ = bStreamUpgrade; - if (bStreamUpgrade_) { - StreamInstallerManager::GetInstance().SysInstallerInit(); - } else { SysInstallerManager::GetInstance().SysInstallerInit(); - } - return 0; } @@ -61,42 +55,16 @@ int32_t SysInstallerServer::StartUpdatePackageZip(const std::string &pkgPath) return SysInstallerManager::GetInstance().StartUpdatePackageZip(pkgPath); } -int32_t SysInstallerServer::StartStreamUpdate() -{ - LOG(INFO) << "StartStreamUpdate"; - return StreamInstallerManager::GetInstance().StartStreamUpdate(); -} - -int32_t SysInstallerServer::StopStreamUpdate() -{ - LOG(INFO) << "StopStreamUpdate"; - return StreamInstallerManager::GetInstance().StopStreamUpdate(); -} - -int32_t SysInstallerServer::ProcessStreamData(const uint8_t *buffer, size_t size) -{ - LOG(INFO) << "ProcessStreamData"; - return StreamInstallerManager::GetInstance().ProcessStreamData(buffer, size); -} - int32_t SysInstallerServer::SetUpdateCallback(const sptr &updateCallback) { LOG(INFO) << "SetUpdateCallback"; - if (bStreamUpgrade_) { - return StreamInstallerManager::GetInstance().SetUpdateCallback(updateCallback); - } else { return SysInstallerManager::GetInstance().SetUpdateCallback(updateCallback); - } } int32_t SysInstallerServer::GetUpdateStatus() { LOG(INFO) << "GetUpdateStatus"; - if (bStreamUpgrade_) { - return StreamInstallerManager::GetInstance().GetUpdateStatus(); - } else { return SysInstallerManager::GetInstance().GetUpdateStatus(); - } } int32_t SysInstallerServer::StartUpdateParaZip(const std::string &pkgPath, diff --git a/frameworks/ipc_server/src/sys_installer_stub.cpp b/frameworks/ipc_server/src/sys_installer_stub.cpp index 86eee41..391530e 100644 --- a/frameworks/ipc_server/src/sys_installer_stub.cpp +++ b/frameworks/ipc_server/src/sys_installer_stub.cpp @@ -37,12 +37,6 @@ SysInstallerStub::SysInstallerStub() bind(&SysInstallerStub::SysInstallerInitStub, this, _1, _2, _3, _4)); requestFuncMap_.emplace(SysInstallerInterfaceCode::UPDATE_PACKAGE, bind(&SysInstallerStub::StartUpdatePackageZipStub, this, _1, _2, _3, _4)); - requestFuncMap_.emplace(SysInstallerInterfaceCode::START_STREAM_UPDATE, - bind(&SysInstallerStub::StartStreamUpdateStub, this, _1, _2, _3, _4)); - requestFuncMap_.emplace(SysInstallerInterfaceCode::STOP_STREAM_UPDATE, - bind(&SysInstallerStub::StopStreamUpdateStub, this, _1, _2, _3, _4)); - requestFuncMap_.emplace(SysInstallerInterfaceCode::PROCESS_STREAM_DATA, - bind(&SysInstallerStub::ProcessStreamDataStub, this, _1, _2, _3, _4)); requestFuncMap_.emplace(SysInstallerInterfaceCode::SET_UPDATE_CALLBACK, bind(&SysInstallerStub::SetUpdateCallbackStub, this, _1, _2, _3, _4)); requestFuncMap_.emplace(SysInstallerInterfaceCode::GET_UPDATE_STATUS, @@ -69,7 +63,6 @@ int32_t SysInstallerStub::SysInstallerInitStub(SysInstallerStub *service, LOG(ERROR) << "Invalid param"; return -1; } - bool bStreamUpgrade = data.ReadBool(); int ret = service->SysInstallerInit(bStreamUpgrade); reply.WriteInt32(ret); return 0; @@ -88,44 +81,6 @@ int32_t SysInstallerStub::StartUpdatePackageZipStub(SysInstallerStub *service, return 0; } -int32_t SysInstallerStub::StartStreamUpdateStub(SysInstallerStub *service, - MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - if (service == nullptr) { - LOG(ERROR) << "Invalid param"; - return -1; - } - int ret = service->StartStreamUpdate(); - reply.WriteInt32(ret); - return 0; -} - -int32_t SysInstallerStub::StopStreamUpdateStub(SysInstallerStub *service, - MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - if (service == nullptr) { - LOG(ERROR) << "Invalid param"; - return -1; - } - int ret = service->StopStreamUpdate(); - reply.WriteInt32(ret); - return 0; -} - -int32_t SysInstallerStub::ProcessStreamDataStub(SysInstallerStub *service, - MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - if (service == nullptr) { - LOG(ERROR) << "Invalid param"; - return -1; - } - uint32_t size = data.ReadUint32(); - const uint8_t *buffer = data.ReadBuffer(size); - int ret = service->ProcessStreamData(buffer, size); - reply.WriteInt32(ret); - return 0; -} - int32_t SysInstallerStub::SetUpdateCallbackStub(SysInstallerStub *service, MessageParcel &data, MessageParcel &reply, MessageOption &option) { diff --git a/frameworks/status_manager/BUILD.gn b/frameworks/status_manager/BUILD.gn index aaf40e0..323fc7c 100644 --- a/frameworks/status_manager/BUILD.gn +++ b/frameworks/status_manager/BUILD.gn @@ -18,7 +18,6 @@ sys_installer_path = rebase_path("${sys_installer_absolutely_path}", ".") ohos_static_library("libstatusmanager") { sources = [ "${sys_installer_path}/frameworks/status_manager/src/status_manager.cpp", - "${sys_installer_path}/frameworks/status_manager/src/stream_status_manager.cpp", ] include_dirs = [ diff --git a/frameworks/status_manager/include/stream_status_manager.h b/frameworks/status_manager/include/stream_status_manager.h deleted file mode 100644 index 0546ce9..0000000 --- a/frameworks/status_manager/include/stream_status_manager.h +++ /dev/null @@ -1,43 +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 STREAM_INSTALLER_STATUS_MANAGER_H -#define STREAM_INSTALLER_STATUS_MANAGER_H - -#include "isys_installer.h" -#include "isys_installer_callback.h" -#include "refbase.h" -#include "sys_installer_common.h" - -namespace OHOS { -namespace SysInstaller { -class StreamStatusManager { -public: - StreamStatusManager() = default; - virtual ~StreamStatusManager() = default; - - virtual void Init(); - virtual int GetUpdateStatus(); - virtual int SetUpdateCallback(const sptr &updateCallback); - virtual void UpdateCallback(UpdateStatus updateStatus, int dealLen, const std::string &resultMsg); - -protected: - UpdateStatus updateStatus_ = UPDATE_STATE_INIT; - std::mutex updateCbMutex_ {}; - sptr updateCallback_ {}; -}; -} // SysInstaller -} // namespace OHOS -#endif // SYS_INSTALLER_STATUS_MANAGER_H diff --git a/frameworks/status_manager/src/stream_status_manager.cpp b/frameworks/status_manager/src/stream_status_manager.cpp deleted file mode 100644 index a353702..0000000 --- a/frameworks/status_manager/src/stream_status_manager.cpp +++ /dev/null @@ -1,67 +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 "stream_status_manager.h" - -#include "sys_installer_common.h" -#include "log/log.h" -#include "utils.h" - -namespace OHOS { -namespace SysInstaller { -using namespace Updater; - -void StreamStatusManager::Init() -{ - updateStatus_ = UPDATE_STATE_INIT; -} - -int StreamStatusManager::SetUpdateCallback(const sptr &updateCallback) -{ - std::lock_guard lock(updateCbMutex_); - if (updateCallback == nullptr) { - LOG(ERROR) << "para error"; - return -1; - } - - updateCallback_ = updateCallback; - return 0; -} - -int StreamStatusManager::GetUpdateStatus() -{ - return updateStatus_; -} - -void StreamStatusManager::UpdateCallback(UpdateStatus updateStatus, int dealLen, const std::string &resultMsg) -{ - std::lock_guard lock(updateCbMutex_); - if (updateCallback_ == nullptr) { - LOG(ERROR) << "updateCallback_ null"; - return; - } - - if (updateStatus > UPDATE_STATE_MAX) { - LOG(INFO) << "status error:" << updateStatus; - return; - } - - updateStatus_ = updateStatus; - LOG(INFO) << "status:" << updateStatus_ << " dealLen:" << dealLen << " msg:" << resultMsg; - updateCallback_->OnUpgradeDealLen(updateStatus_, dealLen, resultMsg); -} - -} // namespace SysInstaller -} // namespace OHOS diff --git a/interfaces/inner_api/include/isys_installer.h b/interfaces/inner_api/include/isys_installer.h index 5ebfdd9..9f5d6d6 100644 --- a/interfaces/inner_api/include/isys_installer.h +++ b/interfaces/inner_api/include/isys_installer.h @@ -29,9 +29,6 @@ public: virtual int32_t SysInstallerInit(bool bStreamUpgrade = false) = 0; virtual int32_t StartUpdatePackageZip(const std::string &pkgPath) = 0; - virtual int32_t StartStreamUpdate() = 0; - virtual int32_t StopStreamUpdate() = 0; - virtual int32_t ProcessStreamData(const uint8_t *buffer, size_t size) = 0; virtual int32_t SetUpdateCallback(const sptr &updateCallback) = 0; virtual int32_t GetUpdateStatus() = 0; virtual int32_t StartUpdateParaZip(const std::string &pkgPath, diff --git a/interfaces/inner_api/include/isys_installer_callback.h b/interfaces/inner_api/include/isys_installer_callback.h index 69781c2..69cb249 100644 --- a/interfaces/inner_api/include/isys_installer_callback.h +++ b/interfaces/inner_api/include/isys_installer_callback.h @@ -39,8 +39,6 @@ public: virtual void OnUpgradeProgress(UpdateStatus updateStatus, int percent, const std::string &resultMsg) = 0; - virtual void OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen, - const std::string &resultMsg) = 0; }; } // namespace SysInstaller } // namespace OHOS diff --git a/interfaces/inner_api/include/isys_installer_callback_func.h b/interfaces/inner_api/include/isys_installer_callback_func.h index 8a6741b..7944c09 100755 --- a/interfaces/inner_api/include/isys_installer_callback_func.h +++ b/interfaces/inner_api/include/isys_installer_callback_func.h @@ -25,8 +25,6 @@ public: virtual void OnUpgradeProgress(UpdateStatus updateStatus, int percent, const std::string &resultMsg) = 0; - virtual void OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen, - const std::string &resultMsg) = 0; }; } // namespace SysInstaller } // namespace OHOS diff --git a/interfaces/inner_api/include/sys_installer_sa_ipc_interface_code.h b/interfaces/inner_api/include/sys_installer_sa_ipc_interface_code.h index 7ef7bd9..4fa031a 100644 --- a/interfaces/inner_api/include/sys_installer_sa_ipc_interface_code.h +++ b/interfaces/inner_api/include/sys_installer_sa_ipc_interface_code.h @@ -32,15 +32,11 @@ enum ModuleUpdateInterfaceCode { enum SysInstallerCallbackInterfaceCode { UPDATE_RESULT = 1, - STREAM_UPDATE_RESULT = 2, }; enum SysInstallerInterfaceCode { SYS_INSTALLER_INIT = 1, UPDATE_PACKAGE, - START_STREAM_UPDATE, - STOP_STREAM_UPDATE, - PROCESS_STREAM_DATA, SET_UPDATE_CALLBACK, GET_UPDATE_STATUS, UPDATE_PARA_PACKAGE, diff --git a/interfaces/innerkits/ipc_client/include/sys_installer_callback.h b/interfaces/innerkits/ipc_client/include/sys_installer_callback.h index 1f5f885..5910163 100644 --- a/interfaces/innerkits/ipc_client/include/sys_installer_callback.h +++ b/interfaces/innerkits/ipc_client/include/sys_installer_callback.h @@ -34,7 +34,6 @@ public: ~SysInstallerCallback() = default; void OnUpgradeProgress(UpdateStatus updateStatus, int percent, const std::string &resultMsg) override; - void OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen, const std::string &resultMsg) override; void RegisterCallback(sptr callback); private: diff --git a/interfaces/innerkits/ipc_client/include/sys_installer_kits.h b/interfaces/innerkits/ipc_client/include/sys_installer_kits.h index 6e350d9..b92761c 100644 --- a/interfaces/innerkits/ipc_client/include/sys_installer_kits.h +++ b/interfaces/innerkits/ipc_client/include/sys_installer_kits.h @@ -38,9 +38,6 @@ public: virtual int32_t Init() = 0; virtual int32_t SysInstallerInit(bool bStreamUpgrade = false) = 0; virtual int32_t StartUpdatePackageZip(const std::string &pkgPath) = 0; - virtual int32_t StartStreamUpdate() = 0; - virtual int32_t StopStreamUpdate() = 0; - virtual int32_t ProcessStreamData(const uint8_t *buffer, size_t size) = 0; virtual int32_t SetUpdateCallback(const sptr &cb) = 0; virtual int32_t GetUpdateStatus() = 0; virtual int32_t StartUpdateParaZip(const std::string &pkgPath, diff --git a/interfaces/innerkits/ipc_client/include/sys_installer_kits_impl.h b/interfaces/innerkits/ipc_client/include/sys_installer_kits_impl.h index 7a24aab..e5d2a85 100644 --- a/interfaces/innerkits/ipc_client/include/sys_installer_kits_impl.h +++ b/interfaces/innerkits/ipc_client/include/sys_installer_kits_impl.h @@ -29,9 +29,6 @@ public: static SysInstallerKitsImpl &GetInstance(); virtual int32_t SysInstallerInit(bool bStreamUpgrade = false); virtual int32_t StartUpdatePackageZip(const std::string &pkgPath); - virtual int32_t StartStreamUpdate(); - virtual int32_t StopStreamUpdate(); - virtual int32_t ProcessStreamData(const uint8_t *buffer, size_t size); virtual int32_t SetUpdateCallback(sptr callback); virtual int32_t GetUpdateStatus(); virtual int32_t StartUpdateParaZip(const std::string &pkgPath, diff --git a/interfaces/innerkits/ipc_client/include/sys_installer_proxy.h b/interfaces/innerkits/ipc_client/include/sys_installer_proxy.h index dd788e3..db78e71 100644 --- a/interfaces/innerkits/ipc_client/include/sys_installer_proxy.h +++ b/interfaces/innerkits/ipc_client/include/sys_installer_proxy.h @@ -27,9 +27,6 @@ public: virtual int32_t SysInstallerInit(bool bStreamUpgrade = false); virtual int32_t StartUpdatePackageZip(const std::string &pkgPath); - virtual int32_t StartStreamUpdate(); - virtual int32_t StopStreamUpdate(); - virtual int32_t ProcessStreamData(const uint8_t *buffer, size_t size); virtual int32_t SetUpdateCallback(const sptr &updateCallback); virtual int32_t GetUpdateStatus(); virtual int32_t StartUpdateParaZip(const std::string &pkgPath, diff --git a/interfaces/innerkits/ipc_client/src/sys_installer_callback.cpp b/interfaces/innerkits/ipc_client/src/sys_installer_callback.cpp index 6838ac3..126d414 100755 --- a/interfaces/innerkits/ipc_client/src/sys_installer_callback.cpp +++ b/interfaces/innerkits/ipc_client/src/sys_installer_callback.cpp @@ -43,12 +43,6 @@ int32_t SysInstallerCallbackStub::OnRemoteRequest(uint32_t code, OnUpgradeProgress(static_cast(updateStatus), percent, data.ReadString()); break; } - case static_cast(SysInstallerCallbackInterfaceCode::STREAM_UPDATE_RESULT): { - int updateStatus = data.ReadInt32(); - int dealLen = data.ReadInt32(); - OnUpgradeDealLen(static_cast(updateStatus), dealLen, data.ReadString()); - break; - } default: { return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } @@ -65,15 +59,6 @@ void SysInstallerCallback::OnUpgradeProgress(UpdateStatus updateStatus, int perc } } -void SysInstallerCallback::OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen, - const std::string &resultMsg) -{ - LOG(INFO) << "updateStatus: " << updateStatus << " dealLen:" << dealLen << " msg:" << resultMsg; - if (callback_ != nullptr) { - callback_->OnUpgradeDealLen(updateStatus, dealLen, resultMsg); - } -} - void SysInstallerCallback::RegisterCallback(sptr callback) { callback_ = callback; diff --git a/interfaces/innerkits/ipc_client/src/sys_installer_client.cpp b/interfaces/innerkits/ipc_client/src/sys_installer_client.cpp index e79d2ca..3e55cd5 100644 --- a/interfaces/innerkits/ipc_client/src/sys_installer_client.cpp +++ b/interfaces/innerkits/ipc_client/src/sys_installer_client.cpp @@ -31,11 +31,6 @@ public: printf("ProgressCallback progress %d percent %d msg %s\n", updateStatus, percent, resultMsg.c_str()); } - void OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen, const std::string &resultMsg) override - { - printf("ProgressCallback progress %d dealLen %d msg %s\n", - updateStatus, dealLen, resultMsg.c_str()); - } }; int main(int argc, char **argv) diff --git a/interfaces/innerkits/ipc_client/src/sys_installer_kits_impl.cpp b/interfaces/innerkits/ipc_client/src/sys_installer_kits_impl.cpp index f3047ab..727e598 100644 --- a/interfaces/innerkits/ipc_client/src/sys_installer_kits_impl.cpp +++ b/interfaces/innerkits/ipc_client/src/sys_installer_kits_impl.cpp @@ -160,45 +160,6 @@ int32_t SysInstallerKitsImpl::StartUpdatePackageZip(const std::string &pkgPath) return ret; } -int32_t SysInstallerKitsImpl::StartStreamUpdate() -{ - LOG(INFO) << "StartStreamUpdate"; - auto updateService = GetService(); - if (updateService == nullptr) { - LOG(ERROR) << "Get updateService failed"; - return -1; - } - int32_t ret = updateService->StartStreamUpdate(); - LOG(INFO) << "StartStreamUpdate ret:" << ret; - return ret; -} - -int32_t SysInstallerKitsImpl::StopStreamUpdate() -{ - LOG(INFO) << "StopStreamUpdate"; - auto updateService = GetService(); - if (updateService == nullptr) { - LOG(ERROR) << "Get updateService failed"; - return -1; - } - int32_t ret = updateService->StopStreamUpdate(); - LOG(INFO) << "StopStreamUpdate ret:" << ret; - return ret; -} - -int32_t SysInstallerKitsImpl::ProcessStreamData(const uint8_t *buffer, size_t size) -{ - LOG(INFO) << "ProcessStreamData"; - auto updateService = GetService(); - if (updateService == nullptr) { - LOG(ERROR) << "Get updateService failed"; - return -1; - } - int32_t ret = updateService->ProcessStreamData(buffer, size); - LOG(INFO) << "ProcessStreamData ret:" << ret; - return ret; -} - int32_t SysInstallerKitsImpl::SetUpdateCallback(sptr callback) { LOG(INFO) << "SetUpdateCallback"; diff --git a/interfaces/innerkits/ipc_client/src/sys_installer_proxy.cpp b/interfaces/innerkits/ipc_client/src/sys_installer_proxy.cpp index 99fc8a0..35bd4f9 100644 --- a/interfaces/innerkits/ipc_client/src/sys_installer_proxy.cpp +++ b/interfaces/innerkits/ipc_client/src/sys_installer_proxy.cpp @@ -38,7 +38,6 @@ int32_t SysInstallerProxy::SysInstallerInit(bool bStreamUpgrade) if (!data.WriteInterfaceToken(GetDescriptor())) { return ERR_FLATTEN_OBJECT; } - data.WriteBool(bStreamUpgrade); MessageParcel reply; MessageOption option; int32_t ret = remote->SendRequest( @@ -79,89 +78,6 @@ int32_t SysInstallerProxy::StartUpdatePackageZip(const std::string &pkgPath) return reply.ReadInt32(); } -int32_t SysInstallerProxy::StartStreamUpdate() -{ - LOG(INFO) << "StartStreamUpdate"; - auto remote = Remote(); - if (remote == nullptr) { - LOG(ERROR) << "Can not get remote"; - return ERR_FLATTEN_OBJECT; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG(ERROR) << "WriteInterfaceToken error"; - return ERR_FLATTEN_OBJECT; - } - - MessageParcel reply; - MessageOption option { MessageOption::TF_SYNC}; - int32_t ret = remote->SendRequest( - static_cast(SysInstallerInterfaceCode::START_STREAM_UPDATE), data, reply, option); - if (ret != ERR_OK) { - LOG(ERROR) << "SendRequest error"; - return ERR_FLATTEN_OBJECT; - } - - return reply.ReadInt32(); -} - -int32_t SysInstallerProxy::StopStreamUpdate() -{ - LOG(INFO) << "StopStreamUpdate"; - auto remote = Remote(); - if (remote == nullptr) { - LOG(ERROR) << "Can not get remote"; - return ERR_FLATTEN_OBJECT; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG(ERROR) << "WriteInterfaceToken error"; - return ERR_FLATTEN_OBJECT; - } - - MessageParcel reply; - MessageOption option { MessageOption::TF_SYNC}; - int32_t ret = remote->SendRequest( - static_cast(SysInstallerInterfaceCode::STOP_STREAM_UPDATE), data, reply, option); - if (ret != ERR_OK) { - LOG(ERROR) << "SendRequest error"; - return ERR_FLATTEN_OBJECT; - } - - return reply.ReadInt32(); -} - -int32_t SysInstallerProxy::ProcessStreamData(const uint8_t *buffer, size_t size) -{ - LOG(INFO) << "ProcessStreamData"; - auto remote = Remote(); - if (remote == nullptr) { - LOG(ERROR) << "Can not get remote"; - return ERR_FLATTEN_OBJECT; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG(ERROR) << "WriteInterfaceToken error"; - return ERR_FLATTEN_OBJECT; - } - data.WriteInt32(size); - data.WriteBuffer(buffer, size); - - MessageParcel reply; - MessageOption option { MessageOption::TF_SYNC}; - int32_t ret = remote->SendRequest( - static_cast(SysInstallerInterfaceCode::PROCESS_STREAM_DATA), data, reply, option); - if (ret != ERR_OK) { - LOG(ERROR) << "SendRequest error"; - return ERR_FLATTEN_OBJECT; - } - - return reply.ReadInt32(); -} - int32_t SysInstallerProxy::SetUpdateCallback(const sptr &cb) { if (cb == nullptr) { diff --git a/services/module_update/util/include/module_utils.h b/services/module_update/util/include/module_utils.h index 20984be..265a8c3 100644 --- a/services/module_update/util/include/module_utils.h +++ b/services/module_update/util/include/module_utils.h @@ -48,7 +48,6 @@ std::string GetContentFromZip(const std::string &zipPath, const std::string &fil bool CheckAndUpdateRevertResult(const std::string &hmpPath, const std::string &resultInfo, const std::string &keyWord); std::string GetCurrentHmpName(void); int32_t NotifyBmsRevert(const std::string &hmpName, bool record); -int32_t WriteStringToFile(const std::string &filePath, const std::string &content); #ifdef __cplusplus extern "C" { diff --git a/services/module_update/util/src/module_utils.cpp b/services/module_update/util/src/module_utils.cpp index 83d8699..8453fe0 100644 --- a/services/module_update/util/src/module_utils.cpp +++ b/services/module_update/util/src/module_utils.cpp @@ -499,22 +499,5 @@ int32_t NotifyBmsRevert(const std::string &hmpName, bool record) } return result; } - -int32_t WriteStringToFile(const std::string &filePath, const std::string &content) -{ - // if file not exist, create file or appead - std::ofstream file (filePath, std::ios::app); - if (!file.is_open()) { - LOG(ERROR) << "open file fail: " << filePath << "; err is " << strerror(errno); - return -1; - } - file << content; - if (file.bad()) { - LOG(ERROR) << "write to file fail, " << filePath; - } - file.close(); - sync(); - return 0; -} } // namespace SysInstaller } // namespace OHOS \ No newline at end of file diff --git a/services/stream_update/BUILD.gn b/services/stream_update/BUILD.gn deleted file mode 100755 index a14fb0e..0000000 --- a/services/stream_update/BUILD.gn +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2022 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/sys_installer/sys_installer_default_cfg.gni") -import("//build/ohos.gni") - -sys_installer_path = rebase_path("${sys_installer_absolutely_path}", ".") -ohos_static_library("libstreamupdate") { - sources = - [ "${sys_installer_path}/services/stream_update/src/stream_update.cpp" ] - - include_dirs = [ - "${sys_installer_path}/common/include", - "${sys_installer_path}/interfaces/innerkits", - "${sys_installer_path}/interfaces/inner_api/include", - "${sys_installer_path}/frameworks/actions/include", - "${sys_installer_path}/frameworks/installer_manager/include", - "${sys_installer_path}/frameworks/status_manager/include", - "${sys_installer_path}/include", - "${sys_installer_path}/services/stream_update/include", - ] - - external_deps = [ - "bounds_checking_function:libsec_static", - "hilog:libhilog", - "ipc:ipc_core", - "openssl:libcrypto_static", - "updater:libbinchunkupdate", - "updater:libringbuffer", - "updater:libupdater", - "updater:libutils", - ] - part_name = "sys_installer" - subsystem_name = "updater" -} diff --git a/services/stream_update/include/stream_update.h b/services/stream_update/include/stream_update.h deleted file mode 100755 index b0bd32c..0000000 --- a/services/stream_update/include/stream_update.h +++ /dev/null @@ -1,59 +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 SYS_INSTALLER_STREAM_UPDATE_H -#define SYS_INSTALLER_STREAM_UPDATE_H - -#include "stream_status_manager.h" -#include "updater/updater.h" -#include "bin_chunk_update.h" -#include "ring_buffer.h" -#include - -namespace OHOS { -namespace SysInstaller { - -class StreamInstallProcesser { - DISALLOW_COPY_MOVE(StreamInstallProcesser); -public: - static StreamInstallProcesser &GetInstance(); - void SetStatusManager(std::shared_ptr statusManager) - { - statusManager_ = statusManager; - } - - bool IsRunning(); - int32_t Start(); - void Stop(); - int32_t ProcessStreamData(const uint8_t *buffer, size_t size); - void UpdateResult(UpdateStatus updateStatus, int dealLen, const std::string &resultMsg); - -private: - StreamInstallProcesser() = default; - ~StreamInstallProcesser() = default; - void ThreadExecuteFunc(); - void ThreadExitProc(); - -private: - Updater::RingBuffer ringBuffer_; - std::shared_ptr statusManager_ {}; - std::shared_ptr binChunkUpdate_ {}; - std::atomic isExitThread_ = false; - std::thread *pComsumeThread_ { nullptr }; - bool isRunning_ = false; -}; -} // SysInstaller -} // namespace OHOS -#endif // SYS_INSTALLER_STREAM_UPDATE_H diff --git a/services/stream_update/src/stream_update.cpp b/services/stream_update/src/stream_update.cpp deleted file mode 100755 index 1efc372..0000000 --- a/services/stream_update/src/stream_update.cpp +++ /dev/null @@ -1,141 +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 "stream_update.h" - -#include "log/log.h" -#include "package/package.h" -#include "package/pkg_manager.h" -#include "scope_guard.h" -#include "securec.h" -#include "updater/updater_const.h" -#include "utils.h" -#include - -namespace OHOS { -namespace SysInstaller { -using namespace Updater; - -constexpr uint32_t BUFFER_SIZE = 50 * 1024; -constexpr uint16_t MAX_RING_BUFFER_NUM = 2; -constexpr uint32_t MAX_UPDATER_BUFFER_SIZE = 2 * BUFFER_SIZE; - -StreamInstallProcesser &StreamInstallProcesser::GetInstance() -{ - static StreamInstallProcesser instance; - return instance; -} - -int32_t StreamInstallProcesser::Start() -{ - LOG(INFO) << "StreamInstallProcesser Start"; - - if (!ringBuffer_.Init(BUFFER_SIZE, MAX_RING_BUFFER_NUM)) { - LOG(ERROR) << "StreamInstallProcesser Start Init ringBuffer_ failed"; - return -1; - } - - binChunkUpdate_ = std::make_unique(MAX_UPDATER_BUFFER_SIZE); - isExitThread_ = false; - isRunning_ = true; - pComsumeThread_ = new (std::nothrow) std::thread([this] { this->ThreadExecuteFunc(); }); - if (pComsumeThread_ == nullptr) { - LOG(ERROR) << "StreamInstallProcesser Start new pComsumeThread_ failed"; - return -1; - } - UpdateResult(UPDATE_STATE_INIT, 0, ""); - return 0; -} - -void StreamInstallProcesser::Stop() -{ - LOG(INFO) << "StreamInstallProcesser Stop enter"; - if (!isRunning_) { - LOG(WARNING) << "Action not running"; - return; - } - - isRunning_ = false; - isExitThread_ = true; - ringBuffer_.Stop(); - if (pComsumeThread_ != nullptr) { - pComsumeThread_->join(); - delete pComsumeThread_; - pComsumeThread_ = nullptr; - } - ThreadExitProc(); - LOG(INFO) << "StreamInstallProcesser Stop leave"; - return; -} - -bool StreamInstallProcesser::IsRunning() -{ - return isRunning_; -} - -void StreamInstallProcesser::ThreadExecuteFunc() -{ - LOG(INFO) << "StreamInstallProcesser ThreadExecuteFunc enter"; - while (!isExitThread_) { - uint8_t buffer[BUFFER_SIZE]{0}; - uint32_t len = 0; - uint32_t dealLen = 0; - if (!ringBuffer_.Pop(buffer, sizeof(buffer), len)) break; - UpdateResultCode ret = binChunkUpdate_->StartBinChunkUpdate(buffer, len, dealLen); - if (STREAM_UPDATE_SUCCESS == ret) { - LOG(INFO) << "StreamInstallProcesser ThreadExecuteFunc STREM_UPDATE_SUCCESS"; - UpdateResult(UPDATE_STATE_ONGOING, dealLen, ""); - } else if (STREAM_UPDATE_FAILURE == ret) { - LOG(ERROR) << "StreamInstallProcesser ThreadExecuteFunc STREM_UPDATE_FAILURE"; - UpdateResult(UPDATE_STATE_FAILED, dealLen, ""); - break; - } else if (STREAM_UPDATE_COMPLETE == ret) { - LOG(INFO) << "StreamInstallProcesser ThreadExecuteFunc STREM_UPDATE_COMPLETE"; - UpdateResult(UPDATE_STATE_SUCCESSFUL, dealLen, ""); - break; - } - } -} - -void StreamInstallProcesser::ThreadExitProc() -{ - LOG(INFO) << "StreamInstallProcesser ThreadExitProc enter"; - isRunning_ = false; - isExitThread_ = true; - ringBuffer_.Stop(); - ringBuffer_.Reset(); -} - -int32_t StreamInstallProcesser::ProcessStreamData(const uint8_t *buffer, size_t size) -{ - uint8_t tmpBuff[BUFFER_SIZE]{0}; - errno_t ret = memcpy_s(tmpBuff, BUFFER_SIZE, buffer, size); - if (ret != 0) { - LOG(ERROR) << "ProcessStreamData memcpy_s failed: " << ret; - return -1; - } - return ringBuffer_.Push(tmpBuff, size) ? 0 : -1; -} - -void StreamInstallProcesser::UpdateResult(UpdateStatus updateStatus, int dealLen, const std::string &resultMsg) -{ - if (statusManager_ == nullptr) { - LOG(ERROR) << "statusManager_ nullptr"; - return; - } - statusManager_->UpdateCallback(updateStatus, dealLen, resultMsg); -} -} // namespace SysInstaller -} // namespace OHOS diff --git a/test/fuzztest/imoduleupdate_fuzzer/imodule_update_fuzzer.cpp b/test/fuzztest/imoduleupdate_fuzzer/imodule_update_fuzzer.cpp index 2204d91..8e17fa5 100644 --- a/test/fuzztest/imoduleupdate_fuzzer/imodule_update_fuzzer.cpp +++ b/test/fuzztest/imoduleupdate_fuzzer/imodule_update_fuzzer.cpp @@ -46,11 +46,6 @@ public: printf("ProgressCallback progress %d percent %d msg %s\n", updateStatus, percent, resultMsg.c_str()); } - void OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen, const std::string &resultMsg) override - { - printf("ProgressCallback progress %d dealLen %d msg %s\n", updateStatus, dealLen, - resultMsg.c_str()); - } }; void FuzzModuleUpdateOther(const uint8_t* data, size_t size) diff --git a/test/unittest/ipc_test/BUILD.gn b/test/unittest/ipc_test/BUILD.gn deleted file mode 100755 index 1f8e817..0000000 --- a/test/unittest/ipc_test/BUILD.gn +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (c) 2021 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/sys_installer/sys_installer_default_cfg.gni") -import("//build/test.gni") - -sys_installer_path = rebase_path("${sys_installer_absolutely_path}", ".") -module_output_path = "sys_installer/sys_installer" - -config("utest_config") { - visibility = [ ":*" ] - - cflags = [ - "-fprofile-arcs", - "-Wno-implicit-fallthrough", - "-Wno-unused-function", - ] - cflags_cc = [ "-Wno-implicit-fallthrough" ] - - ldflags = [ "--coverage" ] -} - -ohos_unittest("sys_installer_unittest") { - testonly = true - module_out_path = module_output_path - sources = [ - "${sys_installer_path}/interfaces/innerkits/ipc_client/src/sys_installer_kits_impl.cpp", - "sys_installer_ipc_test.cpp", - ] - - include_dirs = [ - "${sys_installer_path}/interfaces/inner_api/include", - "${sys_installer_path}/interfaces/innerkits/ipc_client/include", - "${sys_installer_path}/test/unitest", - ] - deps = [ - "${sys_installer_path}/interfaces/innerkits/ipc_client:libsysinstallerkits", - ] - - deps += [ - "${sys_installer_path}/test/unittest/ipc_test:sys_installer_client_test", - ] - external_deps = [ - "bounds_checking_function:libsec_static", - "googletest:gmock_main", - "googletest:gtest_main", - "updater:libupdaterlog", - ] - - cflags_cc = [ "-fexceptions" ] - - defines = [ - "UPDATER_UT", - "BUILD_OHOS", - "HDC_DEBUG", - "HARMONY_PROJECT", - ] - - public_configs = [ ":utest_config" ] - install_enable = true - part_name = "sys_installer" -} - -ohos_executable("sys_installer_client_test") { - sources = [ "${sys_installer_path}/interfaces/innerkits/ipc_client/src/sys_installer_client.cpp" ] - - include_dirs = [ - "${sys_installer_path}/interfaces/innerkits/ipc_client/include", - "${sys_installer_path}/interfaces/inner_api/include", - ] - - deps = [ - "${sys_installer_path}/interfaces/innerkits/ipc_client:libsysinstallerkits", - ] - - external_deps = [ - "bounds_checking_function:libsec_static", - "c_utils:utils", - "init:libbegetutil", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] - install_enable = true - part_name = "sys_installer" - subsystem_name = "updater" -} diff --git a/test/unittest/ipc_test/sys_installer_ipc_test.cpp b/test/unittest/ipc_test/sys_installer_ipc_test.cpp index b9ea015..2265303 100644 --- a/test/unittest/ipc_test/sys_installer_ipc_test.cpp +++ b/test/unittest/ipc_test/sys_installer_ipc_test.cpp @@ -69,11 +69,6 @@ public: printf("ProgressCallback progress %d percent %d msg %s\n", updateStatus, percent, resultMsg.c_str()); } - void OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen, const std::string &resultMsg) override - { - printf("ProgressCallback progress %d dealLen %d msg %s\n", - updateStatus, dealLen, resultMsg.c_str()); - } }; // callback diff --git a/test/unittest/stream_update/BUILD.gn b/test/unittest/stream_update/BUILD.gn deleted file mode 100755 index 448b0b0..0000000 --- a/test/unittest/stream_update/BUILD.gn +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (c) 2021 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/sys_installer/sys_installer_default_cfg.gni") -import("//build/test.gni") - -sys_installer_path = rebase_path("${sys_installer_absolutely_path}", ".") -module_output_path = "sys_installer/sys_installer" - -config("utest_config") { - visibility = [ ":*" ] - - cflags = [ - "-fprofile-arcs", - "-Wno-implicit-fallthrough", - "-Wno-unused-function", - ] - cflags_cc = [ "-Wno-implicit-fallthrough" ] - - ldflags = [ "--coverage" ] -} - -ohos_unittest("stream_update_unittest") { - testonly = true - module_out_path = module_output_path - sources = [ - "${sys_installer_path}/services/stream_update/src/stream_update.cpp", - "stream_update_test.cpp", - ] - - include_dirs = [ - "${sys_installer_path}/common/include", - "${sys_installer_path}/interfaces/innerkits", - "${sys_installer_path}/interfaces/inner_api/include", - "${sys_installer_path}/frameworks/actions/include", - "${sys_installer_path}/frameworks/installer_manager/include", - "${sys_installer_path}/frameworks/status_manager/include", - "${sys_installer_path}/include", - "${sys_installer_path}/services/stream_update/include", - ] - - deps = [ "${sys_installer_path}/frameworks/status_manager:libstatusmanager" ] - - external_deps = [ - "bounds_checking_function:libsec_static", - "googletest:gmock_main", - "googletest:gtest_main", - "hilog:libhilog", - "ipc:ipc_core", - "openssl:libcrypto_static", - "updater:libbinchunkupdate", - "updater:libringbuffer", - "updater:libupdater", - "updater:libutils", - ] - - cflags_cc = [ "-fexceptions" ] - - defines = [ - "UPDATER_UT", - "BUILD_OHOS", - "HDC_DEBUG", - "HARMONY_PROJECT", - ] - - public_configs = [ ":utest_config" ] - install_enable = true - part_name = "sys_installer" -} diff --git a/test/unittest/stream_update/stream_update_test.cpp b/test/unittest/stream_update/stream_update_test.cpp deleted file mode 100755 index 942a933..0000000 --- a/test/unittest/stream_update/stream_update_test.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022 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 "stream_update_test.h" -#include "updater/updater.h" -#include "bin_chunk_update.h" -#include "log/log.h" -#include "scope_guard.h" -#include "securec.h" -#include "updater/updater_const.h" -#include "utils.h" -#include -#include -#include - -#include "gtest/gtest.h" - -using namespace testing::ext; -using namespace std; - -namespace OHOS { -namespace SysInstaller { - -HWTEST_F(StreamInstallProcesserTest, StartStopTest, TestSize.Level1) -{ - StreamInstallProcesser::GetInstance().Start(); - EXPECT_TRUE(StreamInstallProcesser::GetInstance().IsRunning()); - StreamInstallProcesser::GetInstance().Stop(); - EXPECT_FALSE(StreamInstallProcesser::GetInstance().IsRunning()); -} - -HWTEST_F(StreamInstallProcesserTest, ProcessStreamDataSuccess, TestSize.Level1) -{ - EXPECT_EQ(StreamInstallProcesser::GetInstance().Start(), 0); - - uint8_t data[1024] = {0}; - std::fill_n(data, sizeof(data), 0x55); - - EXPECT_EQ(StreamInstallProcesser::GetInstance().ProcessStreamData(data, sizeof(data)), 0); - StreamInstallProcesser::GetInstance().Stop(); -} - -HWTEST_F(StreamInstallProcesserTest, UpdateResultTest, TestSize.Level1) -{ - // 预期 UpdateCallback 方法被调用 - EXPECT_CALL(*statusManager, UpdateCallback(UPDATE_STATE_INIT, 0, "Initializing")).Times(1); - StreamInstallProcesser::GetInstance().UpdateResult(UPDATE_STATE_INIT, 0, "Initializing"); -} - -} // namespace SysInstaller -} // namespace OHOS diff --git a/test/unittest/stream_update/stream_update_test.h b/test/unittest/stream_update/stream_update_test.h deleted file mode 100755 index d2023f8..0000000 --- a/test/unittest/stream_update/stream_update_test.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -* Copyright (c) 2021 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 STREAM_UPDATE_UNITTEST_H -#define STREAM_UPDATE_UNITTEST_H - -#include -#include -#include "stream_status_manager.h" -#include "stream_update.h" - -namespace OHOS { -namespace SysInstaller { - -class MockStatusManager : public StreamStatusManager { -public: - MOCK_METHOD(void, UpdateCallback, (UpdateStatus updateStatus, int dealLen, - const std::string &resultMsg), (override)); -}; - -class StreamInstallProcesserTest : public ::testing::Test { -protected: - std::shared_ptr statusManager {}; - - void SetUp() override - { - statusManager = std::make_shared(); - statusManager->Init(); - StreamInstallProcesser::GetInstance().SetStatusManager(statusManager); - } - - void TearDown() override - { - } -}; - -} // SysInstaller -} // OHOS -#endif // STREAM_UPDATE_UNITTEST_H diff --git a/tools/module_update_tool/main.cpp b/tools/module_update_tool/main.cpp index d098821..43842bc 100644 --- a/tools/module_update_tool/main.cpp +++ b/tools/module_update_tool/main.cpp @@ -117,10 +117,6 @@ public: { printf("ProgressCallback progress %d percent %d msg %s\n", updateStatus, percent, resultMsg.c_str()); } - void OnUpgradeDealLen(UpdateStatus updateStatus, int dealLen, const std::string &resultMsg) override - { - printf("ProgressCallback progress %d dealLen %d msg %s\n", updateStatus, dealLen, resultMsg.c_str()); - } }; static int UpdateModulePackage(const std::string &path) -- Gitee