From 7819e29c3b4d6183a881f1d658736a4a4d38f1ab Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 26 Jul 2024 19:49:29 +0800 Subject: [PATCH 01/21] add ut Signed-off-by: unknown --- .../updater_ui_env_unittest.cpp | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/unittest/updater_ui_test/updater_ui_env_unittest.cpp diff --git a/test/unittest/updater_ui_test/updater_ui_env_unittest.cpp b/test/unittest/updater_ui_test/updater_ui_env_unittest.cpp new file mode 100644 index 00000000..ee8cce9e --- /dev/null +++ b/test/unittest/updater_ui_test/updater_ui_env_unittest.cpp @@ -0,0 +1,55 @@ +/* + * 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 "gtest/gtest.h" +#include "updater_ui_env.h" +#include +#include +#include +#include +#include +#include "callback_manager.h" +#include "common/graphic_startup.h" +#include "common/screen.h" +#include "components/root_view.h" +#include "graphic_engine.h" +#include "input_event.h" +#include "language/language_ui.h" +#include "log/log.h" +#include "page/page_manager.h" +#include "updater_ui_config.h" + +using namespace testing::ext; +using namespace Updater; + +namespace UpdaterUt { +class UpdaterUiEnvUnitTest : public testing::Test { +public: + static void SetUpTestCase(void) {} + static void TearDownTestCase(void) {} + void SetUp() override {} + void TearDown() override {} +}; + +constexpr std::pair MY_BRIGHTNESS_FILE = + std::pair { "/data/updater/ui/brightness", "/data/updater/ui/max_brightness" }; + +HWTEST_F(UpdaterUiEnvUnitTest, test_updater_ui_env_bright_init, TestSize.Level0) +{ + EXPECT_FALSE(UpdaterUiEnv::InitBrightness("/fakebrightness", "/fakemaxbrightness")); + EXPECT_FALSE(UpdaterUiEnv::InitBrightness(MY_BRIGHTNESS_FILE.first, "/fakemaxbrightness")); + EXPECT_TRUE(UpdaterUiEnv::InitBrightness(MY_BRIGHTNESS_FILE.first, MY_BRIGHTNESS_FILE.second)); +} +} \ No newline at end of file -- Gitee From a337a4641c5b550a5963bab2b7f521fe879b5324 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 26 Jul 2024 19:49:29 +0800 Subject: [PATCH 02/21] add ut Signed-off-by: unknown --- .../updater_ui_env_unittest.cpp | 55 +++++++++++++ .../updater_ui_facade_unittest.cpp | 78 +++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 test/unittest/updater_ui_test/updater_ui_env_unittest.cpp create mode 100644 test/unittest/updater_ui_test/updater_ui_facade_unittest.cpp diff --git a/test/unittest/updater_ui_test/updater_ui_env_unittest.cpp b/test/unittest/updater_ui_test/updater_ui_env_unittest.cpp new file mode 100644 index 00000000..ee8cce9e --- /dev/null +++ b/test/unittest/updater_ui_test/updater_ui_env_unittest.cpp @@ -0,0 +1,55 @@ +/* + * 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 "gtest/gtest.h" +#include "updater_ui_env.h" +#include +#include +#include +#include +#include +#include "callback_manager.h" +#include "common/graphic_startup.h" +#include "common/screen.h" +#include "components/root_view.h" +#include "graphic_engine.h" +#include "input_event.h" +#include "language/language_ui.h" +#include "log/log.h" +#include "page/page_manager.h" +#include "updater_ui_config.h" + +using namespace testing::ext; +using namespace Updater; + +namespace UpdaterUt { +class UpdaterUiEnvUnitTest : public testing::Test { +public: + static void SetUpTestCase(void) {} + static void TearDownTestCase(void) {} + void SetUp() override {} + void TearDown() override {} +}; + +constexpr std::pair MY_BRIGHTNESS_FILE = + std::pair { "/data/updater/ui/brightness", "/data/updater/ui/max_brightness" }; + +HWTEST_F(UpdaterUiEnvUnitTest, test_updater_ui_env_bright_init, TestSize.Level0) +{ + EXPECT_FALSE(UpdaterUiEnv::InitBrightness("/fakebrightness", "/fakemaxbrightness")); + EXPECT_FALSE(UpdaterUiEnv::InitBrightness(MY_BRIGHTNESS_FILE.first, "/fakemaxbrightness")); + EXPECT_TRUE(UpdaterUiEnv::InitBrightness(MY_BRIGHTNESS_FILE.first, MY_BRIGHTNESS_FILE.second)); +} +} \ No newline at end of file diff --git a/test/unittest/updater_ui_test/updater_ui_facade_unittest.cpp b/test/unittest/updater_ui_test/updater_ui_facade_unittest.cpp new file mode 100644 index 00000000..69dc7a48 --- /dev/null +++ b/test/unittest/updater_ui_test/updater_ui_facade_unittest.cpp @@ -0,0 +1,78 @@ +/* + * 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 "gtest/gtest.h" +#include +#include "component/text_label_adapter.h" +#include "updater_event.h" +#include "updater_ui_config.h" +#include "updater_ui_env.h" +#include "updater_ui_tools.h" + +using namespace testing::ext; +using namespace Updater; + +#define UPDATER_UI_INSTANCE UpdaterUiFacade::GetInstance() + +namespace UpdaterUt { +class UpdaterUiFacadeUnitTest : public testing::Test { +public: + static void SetUpTestCase(void) {} + static void TearDownTestCase(void) {} + void SetUp() override {} + void TearDown() override {} +}; + +HWTEST_F(UpdaterUiFacadeUnitTest, test_updater_ui_facade_set_mode, Test.Level0) +{ + std::string mode = "abc"; + EXPECT_TRUE(UPDATER_UI_INSTANCE.SetMode("")); + EXPECT_TRUE(UPDATER_UI_INSTANCE.SetMode(mode)); + EXPECT_EQ(UPDATER_UI_INSTANCE.GetMode(), mode); +} + +HWTEST_F(UpdaterUiFacadeUnitTest, test_updater_ui_facade_show_funcs, Test.Level0) +{ + std::string log = "log"; + UPDATER_UI_INSTANCE.ShowLog(log); + UPDATER_UI_INSTANCE.ShowLogRes(log); + UPDATER_UI_INSTANCE.ShowUpdInfo(log); + UPDATER_UI_INSTANCE.ClearText(); + UPDATER_UI_INSTANCE.ClearLog(); + UPDATER_UI_INSTANCE.ShowProgress(0.0); + UPDATER_UI_INSTANCE.ShowProgressPage(); + UPDATER_UI_INSTANCE.ShowSuccessPage(); + UPDATER_UI_INSTANCE.ShowFailedPage(); + UPDATER_UI_INSTANCE.ShowFactoryConfirmPage(); + UPDATER_UI_INSTANCE.ShowMainpage(); + UPDATER_UI_INSTANCE.ShowProgressWarning(false); + EXPECT_FALSE(UPDATER_UI_INSTANCE.IsInProgress()); + EXPECT_TRUE(UPDATER_UI_INSTANCE.SetMode("ota")); + UPDATER_UI_INSTANCE.ShowLog(log); + UPDATER_UI_INSTANCE.ShowLog(log, true); + UPDATER_UI_INSTANCE.ShowLogRes(log); + UPDATER_UI_INSTANCE.ShowUpdInfo(log); + UPDATER_UI_INSTANCE.ClearText(); + UPDATER_UI_INSTANCE.ClearLog(); + UPDATER_UI_INSTANCE.ShowProgress(0.0); + UPDATER_UI_INSTANCE.ShowProgressPage(); + UPDATER_UI_INSTANCE.ShowSuccessPage(); + UPDATER_UI_INSTANCE.ShowFailedPage(); + UPDATER_UI_INSTANCE.ShowFactoryConfirmPage(); + UPDATER_UI_INSTANCE.ShowMainpage(); + UPDATER_UI_INSTANCE.ShowProgressWarning(false); + EXPECT_TRUE(UPDATER_UI_INSTANCE.IsInProgress()); +} +} \ No newline at end of file -- Gitee From d8bbe8344b5b270d502e27e96f87f9d25ff93367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=87=AF?= Date: Thu, 1 Aug 2024 03:14:35 +0000 Subject: [PATCH 03/21] update services/factory_reset/factory_reset.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈凯 --- services/factory_reset/factory_reset.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/services/factory_reset/factory_reset.cpp b/services/factory_reset/factory_reset.cpp index 570690c9..9451018a 100644 --- a/services/factory_reset/factory_reset.cpp +++ b/services/factory_reset/factory_reset.cpp @@ -46,27 +46,27 @@ int FactoryResetProcess::FactoryResetFunc(FactoryResetMode mode, const std::stri LOG(ERROR) << "Invalid factory reset tag: " << mode; return 1; } - if (CommonResetPreFunc_ == nullptr || - CommonResetPreFunc_(mode == MENU_WIPE_DATA || mode == FACTORY_WIPE_DATA) != 0) { - LOG(ERROR) << "Failed to erase the security status"; - return -1; - } if (iter->second(path) != 0) { LOG(ERROR) << "Do factory reset failed! tag: " << mode; return 1; } + if (CommonResetPostFunc_ == nullptr || + CommonResetPostFunc_(mode == MENU_WIPE_DATA || mode == FACTORY_WIPE_DATA) != 0) { + LOG(ERROR) << "Failed to erase the security status"; + return -1; + } return 0; } -static int CommonResetPre(bool flag) +static int CommonResetPost(bool flag) { - LOG(INFO) << "CommonResetPre"; + LOG(INFO) << "CommonResetPost"; return 0; } -void FactoryResetProcess::RegisterCommonResetPreFunc(CommonResetPreFunc ptr) +void FactoryResetProcess::RegisterCommonResetPostFunc(CommonResetPostFunc ptr) { - CommonResetPreFunc_ = std::move(ptr); + CommonResetPostFunc_ = std::move(ptr); } static int FactoryResetPre() @@ -128,9 +128,9 @@ int FactoryResetProcess::DoFactoryReset(const std::string &path) return resetStatus; } -extern "C" __attribute__((constructor)) void RegisterCommonResetPreFunc(void) +extern "C" __attribute__((constructor)) void RegisterCommonResetPostFunc(void) { - FactoryResetProcess::GetInstance().RegisterCommonResetPreFunc(CommonResetPre); + FactoryResetProcess::GetInstance().RegisterCommonResetPostFunc(CommonResetPost); } extern "C" __attribute__((constructor)) void RegisterFactoryResetPreFunc(void) -- Gitee From 771b6c411a4de1738e3b5f0d64678b9a8c9030c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=87=AF?= Date: Thu, 1 Aug 2024 03:15:45 +0000 Subject: [PATCH 04/21] update services/factory_reset/factory_reset.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈凯 --- services/factory_reset/factory_reset.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/factory_reset/factory_reset.h b/services/factory_reset/factory_reset.h index 192df9cc..053631f8 100644 --- a/services/factory_reset/factory_reset.h +++ b/services/factory_reset/factory_reset.h @@ -22,7 +22,7 @@ #include "updater_main.h" namespace Updater { -using CommonResetPreFunc = std::function; +using CommonResetPostFunc = std::function; using FactoryResetPreFunc = std::function; using FactoryResetPostFunc = std::function; class FactoryResetProcess { @@ -33,13 +33,13 @@ public: static FactoryResetProcess &GetInstance(); using ResetFunc = std::function; - void RegisterCommonResetPreFunc(CommonResetPreFunc ptr); + void RegisterCommonResetPostFunc(CommonResetPostFunc ptr); void RegisterFactoryResetPreFunc(FactoryResetPreFunc ptr); void RegisterFactoryResetPostFunc(FactoryResetPostFunc ptr); int FactoryResetFunc(FactoryResetMode mode, const std::string &path); private: - CommonResetPreFunc CommonResetPreFunc_ = nullptr; + CommonResetPostFunc CommonResetPostFunc_ = nullptr; FactoryResetPreFunc FactoryResetPreFunc_ = nullptr; FactoryResetPostFunc FactoryResetPostFunc_ = nullptr; std::unordered_map resetTab_; -- Gitee From 1e36903e39953eedc8a1241607bab12f043a1e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=87=AF?= Date: Fri, 2 Aug 2024 03:19:44 +0000 Subject: [PATCH 05/21] update services/factory_reset/factory_reset.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈凯 --- services/factory_reset/factory_reset.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/services/factory_reset/factory_reset.cpp b/services/factory_reset/factory_reset.cpp index 9451018a..88c6ebc7 100644 --- a/services/factory_reset/factory_reset.cpp +++ b/services/factory_reset/factory_reset.cpp @@ -17,6 +17,7 @@ #include "log/dump.h" #include "log/log.h" #include "fs_manager/mount.h" +#include "scope_guard.h" namespace Updater { FactoryResetProcess &FactoryResetProcess::GetInstance() @@ -46,13 +47,21 @@ int FactoryResetProcess::FactoryResetFunc(FactoryResetMode mode, const std::stri LOG(ERROR) << "Invalid factory reset tag: " << mode; return 1; } - if (iter->second(path) != 0) { + int resetStatus = iter->second(path); + ON_SCOPE_EXIT(factoryResetPost) { + if (mode == FACTORY_WIPE_DATA && + (FactoryResetPostFunc_ == nullptr || FactoryResetPostFunc_(resetStatus) != 0)) { + LOG(ERROR) << "FactoryResetPostFunc_ fail"; + } + }; + if (resetStatus != 0) { LOG(ERROR) << "Do factory reset failed! tag: " << mode; return 1; } if (CommonResetPostFunc_ == nullptr || CommonResetPostFunc_(mode == MENU_WIPE_DATA || mode == FACTORY_WIPE_DATA) != 0) { - LOG(ERROR) << "Failed to erase the security status"; + resetStatus = 1; + LOG(ERROR) << "CommonResetPostFunc_ fail"; return -1; } return 0; @@ -122,9 +131,6 @@ int FactoryResetProcess::DoFactoryReset(const std::string &path) } LOG(INFO) << "Factory level FactoryReset status:" << resetStatus; - if (FactoryResetPostFunc_ == nullptr || FactoryResetPostFunc_(resetStatus) != 0) { - LOG(ERROR) << "FactoryResetPostFunc_ fail"; - } return resetStatus; } -- Gitee From b042089fc7bb6c4b71c17a83363c91fdc60c0dd5 Mon Sep 17 00:00:00 2001 From: LeonShu Date: Mon, 5 Aug 2024 10:07:15 +0800 Subject: [PATCH 06/21] Signed-off-by: LeonShu --- test/unittest/updater_ui_test/BUILD.gn | 2 + .../control/ui_control_unittest.cpp | 71 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 test/unittest/updater_ui_test/control/ui_control_unittest.cpp diff --git a/test/unittest/updater_ui_test/BUILD.gn b/test/unittest/updater_ui_test/BUILD.gn index 1471027f..559ed68f 100644 --- a/test/unittest/updater_ui_test/BUILD.gn +++ b/test/unittest/updater_ui_test/BUILD.gn @@ -32,6 +32,7 @@ ohos_unittest("ui_unittest") { "ENABLE_VECTOR_FONT = 1", ] sources = [ + "control/ui_control_unittest.cpp", "driver/fbdev_driver_unittest.cpp", "driver/keys_input_device_unittest.cpp", "driver/pointers_input_device_unittest.cpp", @@ -46,6 +47,7 @@ ohos_unittest("ui_unittest") { "view/ui_view_proxy_unittest.cpp", ] sources += [ + "${updater_path}/services/ui/control/event_listener.cpp", "${updater_path}/services/ui/driver/drm_driver.cpp", "${updater_path}/services/ui/driver/fbdev_driver.cpp", "${updater_path}/services/ui/driver/graphic_engine.cpp", diff --git a/test/unittest/updater_ui_test/control/ui_control_unittest.cpp b/test/unittest/updater_ui_test/control/ui_control_unittest.cpp new file mode 100644 index 00000000..e3a08fd8 --- /dev/null +++ b/test/unittest/updater_ui_test/control/ui_control_unittest.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gtest/gtest.h" +#include "event_listener.h" +#include +#include "dock/input_device.h" + +using namespace testing::ext; +using namespace Updater; + +namespace { +class UpdaterUiControlUnittest : public testing::Test { +public: + KeyListener *keyListener; + OHOS::UIView *view; + + static void SetUpTestCase(void) {} + static void TearDownTestCase(void) {} + void SetUp() override + { + keyListener = new KeyListener(); + view = new OHOS::UIView(); + } + void TearDown() override + { + delete keyListener; + delete view; + } +}; + +HWTEST_F(UpdaterUiControlUnittest, OnKeyAct01, TestSize.Level0) +{ + OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_POWER, OHOS::InputDevice::STATE_PRESS); + bool ret = keyListenet->OnKeyAct(*view, *event); + EXPECT_EQ(ret true); +} + +HWTEST_F(UpdaterUiControlUnittest, OnKeyAct02, TestSize.Level0) +{ + OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_VOLUMEUP, OHOS::InputDevice::STATE_PRESS); + bool ret = keyListenet->OnKeyAct(*view, *event); + EXPECT_EQ(ret true); +} + +HWTEST_F(UpdaterUiControlUnittest, OnKeyAct03, TestSize.Level0) +{ + OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_VOLUMEDOWN, OHOS::InputDevice::STATE_PRESS); + bool ret = keyListenet->OnKeyAct(*view, *event); + EXPECT_EQ(ret true); +} + +HWTEST_F(UpdaterUiControlUnittest, OnKeyAct04, TestSize.Level0) +{ + OHOS::KeyEvent *event = new OHOS::KeyEvent(100, OHOS::InputDevice::STATE_PRESS); + bool ret = keyListenet->OnKeyAct(*view, *event); + EXPECT_EQ(ret true); +} +} \ No newline at end of file -- Gitee From 60236aa8dd8bda54f373e1b17556aa18e6120130 Mon Sep 17 00:00:00 2001 From: LeonShu Date: Mon, 5 Aug 2024 10:29:55 +0800 Subject: [PATCH 07/21] Signed-off-by: LeonShu --- .../updater_ui_test/control/ui_control_unittest.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/unittest/updater_ui_test/control/ui_control_unittest.cpp b/test/unittest/updater_ui_test/control/ui_control_unittest.cpp index e3a08fd8..c2506d8e 100644 --- a/test/unittest/updater_ui_test/control/ui_control_unittest.cpp +++ b/test/unittest/updater_ui_test/control/ui_control_unittest.cpp @@ -37,35 +37,37 @@ public: void TearDown() override { delete keyListener; + keyListener = nullptr; delete view; + view = nullptr; } }; HWTEST_F(UpdaterUiControlUnittest, OnKeyAct01, TestSize.Level0) { OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_POWER, OHOS::InputDevice::STATE_PRESS); - bool ret = keyListenet->OnKeyAct(*view, *event); + bool ret = keyListener->OnKeyAct(*view, *event); EXPECT_EQ(ret true); } HWTEST_F(UpdaterUiControlUnittest, OnKeyAct02, TestSize.Level0) { OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_VOLUMEUP, OHOS::InputDevice::STATE_PRESS); - bool ret = keyListenet->OnKeyAct(*view, *event); + bool ret = keyListener->OnKeyAct(*view, *event); EXPECT_EQ(ret true); } HWTEST_F(UpdaterUiControlUnittest, OnKeyAct03, TestSize.Level0) { OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_VOLUMEDOWN, OHOS::InputDevice::STATE_PRESS); - bool ret = keyListenet->OnKeyAct(*view, *event); + bool ret = keyListener->OnKeyAct(*view, *event); EXPECT_EQ(ret true); } HWTEST_F(UpdaterUiControlUnittest, OnKeyAct04, TestSize.Level0) { OHOS::KeyEvent *event = new OHOS::KeyEvent(100, OHOS::InputDevice::STATE_PRESS); - bool ret = keyListenet->OnKeyAct(*view, *event); + bool ret = keyListener->OnKeyAct(*view, *event); EXPECT_EQ(ret true); } } \ No newline at end of file -- Gitee From ec89fa428439228984939024f8476b02fe3c301e Mon Sep 17 00:00:00 2001 From: LeonShu Date: Mon, 5 Aug 2024 10:42:58 +0800 Subject: [PATCH 08/21] Signed-off-by: LeonShu --- .../updater_ui_test/control/ui_control_unittest.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unittest/updater_ui_test/control/ui_control_unittest.cpp b/test/unittest/updater_ui_test/control/ui_control_unittest.cpp index c2506d8e..becf17c8 100644 --- a/test/unittest/updater_ui_test/control/ui_control_unittest.cpp +++ b/test/unittest/updater_ui_test/control/ui_control_unittest.cpp @@ -47,27 +47,27 @@ HWTEST_F(UpdaterUiControlUnittest, OnKeyAct01, TestSize.Level0) { OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_POWER, OHOS::InputDevice::STATE_PRESS); bool ret = keyListener->OnKeyAct(*view, *event); - EXPECT_EQ(ret true); + EXPECT_EQ(ret, true); } HWTEST_F(UpdaterUiControlUnittest, OnKeyAct02, TestSize.Level0) { OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_VOLUMEUP, OHOS::InputDevice::STATE_PRESS); bool ret = keyListener->OnKeyAct(*view, *event); - EXPECT_EQ(ret true); + EXPECT_EQ(ret, true); } HWTEST_F(UpdaterUiControlUnittest, OnKeyAct03, TestSize.Level0) { OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_VOLUMEDOWN, OHOS::InputDevice::STATE_PRESS); bool ret = keyListener->OnKeyAct(*view, *event); - EXPECT_EQ(ret true); + EXPECT_EQ(ret, true); } HWTEST_F(UpdaterUiControlUnittest, OnKeyAct04, TestSize.Level0) { OHOS::KeyEvent *event = new OHOS::KeyEvent(100, OHOS::InputDevice::STATE_PRESS); bool ret = keyListener->OnKeyAct(*view, *event); - EXPECT_EQ(ret true); + EXPECT_EQ(ret, true); } } \ No newline at end of file -- Gitee From f92ba76ecab5d90a944db72617e39a24f281acf2 Mon Sep 17 00:00:00 2001 From: LeonShu Date: Mon, 5 Aug 2024 11:26:42 +0800 Subject: [PATCH 09/21] Signed-off-by: LeonShu --- .../control/ui_control_unittest.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/unittest/updater_ui_test/control/ui_control_unittest.cpp b/test/unittest/updater_ui_test/control/ui_control_unittest.cpp index becf17c8..91ee8883 100644 --- a/test/unittest/updater_ui_test/control/ui_control_unittest.cpp +++ b/test/unittest/updater_ui_test/control/ui_control_unittest.cpp @@ -48,6 +48,10 @@ HWTEST_F(UpdaterUiControlUnittest, OnKeyAct01, TestSize.Level0) OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_POWER, OHOS::InputDevice::STATE_PRESS); bool ret = keyListener->OnKeyAct(*view, *event); EXPECT_EQ(ret, true); + if (event != nullptr) { + delete event; + event = nullptr; + } } HWTEST_F(UpdaterUiControlUnittest, OnKeyAct02, TestSize.Level0) @@ -55,6 +59,10 @@ HWTEST_F(UpdaterUiControlUnittest, OnKeyAct02, TestSize.Level0) OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_VOLUMEUP, OHOS::InputDevice::STATE_PRESS); bool ret = keyListener->OnKeyAct(*view, *event); EXPECT_EQ(ret, true); + if (event != nullptr) { + delete event; + event = nullptr; + } } HWTEST_F(UpdaterUiControlUnittest, OnKeyAct03, TestSize.Level0) @@ -62,6 +70,10 @@ HWTEST_F(UpdaterUiControlUnittest, OnKeyAct03, TestSize.Level0) OHOS::KeyEvent *event = new OHOS::KeyEvent(KEY_VOLUMEDOWN, OHOS::InputDevice::STATE_PRESS); bool ret = keyListener->OnKeyAct(*view, *event); EXPECT_EQ(ret, true); + if (event != nullptr) { + delete event; + event = nullptr; + } } HWTEST_F(UpdaterUiControlUnittest, OnKeyAct04, TestSize.Level0) @@ -69,5 +81,9 @@ HWTEST_F(UpdaterUiControlUnittest, OnKeyAct04, TestSize.Level0) OHOS::KeyEvent *event = new OHOS::KeyEvent(100, OHOS::InputDevice::STATE_PRESS); bool ret = keyListener->OnKeyAct(*view, *event); EXPECT_EQ(ret, true); + if (event != nullptr) { + delete event; + event = nullptr; + } } } \ No newline at end of file -- Gitee From 9a70573a4f96d6dabca24bd621837e7c870d1b95 Mon Sep 17 00:00:00 2001 From: LeonShu Date: Tue, 6 Aug 2024 09:43:05 +0800 Subject: [PATCH 10/21] Signed-off-by: LeonShu --- BUILD.gn | 1 + services/factory_reset/factory_reset.h | 2 + services/updater_main.h | 1 + test/unittest/factory_reset_test/BUILD.gn | 50 +++++++++ .../factory_reset_unittest.cpp | 100 ++++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 test/unittest/factory_reset_test/BUILD.gn create mode 100644 test/unittest/factory_reset_test/factory_reset_unittest.cpp diff --git a/BUILD.gn b/BUILD.gn index ac948c97..4c82fe12 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -43,6 +43,7 @@ group("unittest") { "test/unittest:updater_unittest", "test/unittest/applypatch_test:applypatch_unittest", "test/unittest/common/ring_buffer:ring_buffer_test", + "test/unittest/factory_reset_test:factory_reset_unittest", "test/unittest/flashd_test:flashd_unittest", "test/unittest/flashd_test:flashd_utils_unittest", "test/unittest/flow_update/update_bin:bin_flow_update_test", diff --git a/services/factory_reset/factory_reset.h b/services/factory_reset/factory_reset.h index 053631f8..9892d0ac 100644 --- a/services/factory_reset/factory_reset.h +++ b/services/factory_reset/factory_reset.h @@ -38,7 +38,9 @@ public: void RegisterFactoryResetPostFunc(FactoryResetPostFunc ptr); int FactoryResetFunc(FactoryResetMode mode, const std::string &path); +#ifndef UPDATER_UT private: +#endif CommonResetPostFunc CommonResetPostFunc_ = nullptr; FactoryResetPreFunc FactoryResetPreFunc_ = nullptr; FactoryResetPostFunc FactoryResetPostFunc_ = nullptr; diff --git a/services/updater_main.h b/services/updater_main.h index f0019166..6ff76fe1 100644 --- a/services/updater_main.h +++ b/services/updater_main.h @@ -26,6 +26,7 @@ enum FactoryResetMode { USER_WIPE_DATA = 0, FACTORY_WIPE_DATA, MENU_WIPE_DATA, + INVALID, }; int UpdaterMain(int argc, char **argv); diff --git a/test/unittest/factory_reset_test/BUILD.gn b/test/unittest/factory_reset_test/BUILD.gn new file mode 100644 index 00000000..ea3120e9 --- /dev/null +++ b/test/unittest/factory_reset_test/BUILD.gn @@ -0,0 +1,50 @@ +# 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/updater/updater_default_cfg.gni") +import("//build/test.gni") + +updater_path = rebase_path("${updater_absolutely_path}", ".") + +MODULE_OUTPUT_PATH = "updater/updater_test" + +ohos_unittest("factory_reset_unittest") { + defines = [ "UPDATER_UT" ] + testonly = true + module_out_path = MODULE_OUTPUT_PATH + sources = [ + "${updater_path}/services/factory_reset/factory_reset.cpp", + "factory_reset_unittest.cpp", + ] + + include_dirs = [ + "${updater_path}/utils/include", + "${updater_path}/services", + "${updater_path}/services/include", + "${updater_path}/services/include/package", + "${updater_path}/services/factory_reset/", + "${updater_path}/interfaces/kits/include/", + "${updater_path}/services/common", + ] + + deps = [ + "${updater_path}/services/fs_manager:libfsmanager", + "${updater_path}/services/log:libupdaterlog", + "${updater_path}/utils:libutils", + ] + + external_deps = [ "init:libbegetutil_static" ] + configs = [ "${updater_path}/test/unittest:utest_config" ] + install_enable = true + part_name = "updater" +} diff --git a/test/unittest/factory_reset_test/factory_reset_unittest.cpp b/test/unittest/factory_reset_test/factory_reset_unittest.cpp new file mode 100644 index 00000000..8f0c5adc --- /dev/null +++ b/test/unittest/factory_reset_test/factory_reset_unittest.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2024-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 "factory_reset.h" + +using namespace Updater; +using namespace testing::ext; + +namespace { +class FactoryResetUnitTest : public testing::Test { +public: + FactoryResetUnitTest() + { + std::cout<<"FactoryResetUnitTest()"; + } + ~FactoryResetUnitTest() {} + FactoryResetProcess* factoryResetProcess; + std::unordered_map resetTab_; + std::function CommonResetPostFunc_; + + static void SetUpTestCase(void) {} + static void TearDownTestCase(void) {} + void SetUp() + { + factoryResetProcess = new FactoryResetProcess(); + factoryResetProcess->resetTab_ = resetTab_; + factoryResetProcess->CommonResetPostFunc_ = CommonResetPostFunc_; + } + void TearDown() + { + delete factoryResetProcess; + factoryResetProcess = nullptr; + } + void TestBody() {} +}; + +HWTEST_F(FactoryResetUnitTest, FactoryResetFunc01, TestSize.Level0) +{ + int ret = factoryResetProcess->GetInstance().FactoryResetFunc(FactoryResetMode::INVALID, "/data"); + EXPECT_EQ(ret, 1); +} + +HWTEST_F(FactoryResetUnitTest, FactoryResetFunc02, TestSize.Level0) +{ + resetTab_[FactoryResetMode::USER_WIPE_DATA] = [](const std::string &) { return 0; }; + int ret = factoryResetProcess->GetInstance().FactoryResetFunc(FactoryResetMode::USER_WIPE_DATA, "/data"); + EXPECT_EQ(ret, 1); +} + +HWTEST_F(FactoryResetUnitTest, FactoryResetFunc03, TestSize.Level0) +{ + CommonResetPostFunc_ = [](bool) { return 0; }; + resetTab_[FactoryResetMode::USER_WIPE_DATA] = [](const std::string &) { return 0; }; + int ret = factoryResetProcess->GetInstance().FactoryResetFunc(FactoryResetMode::USER_WIPE_DATA, "/data"); + EXPECT_EQ(ret, 1); +} + +HWTEST_F(FactoryResetUnitTest, FactoryResetFunc04, TestSize.Level0) +{ + resetTab_[FactoryResetMode::FACTORY_WIPE_DATA] = [](const std::string &) { return 0; }; + int ret = factoryResetProcess->GetInstance().FactoryResetFunc(FactoryResetMode::FACTORY_WIPE_DATA, "/data"); + EXPECT_EQ(ret, 1); +} + +HWTEST_F(FactoryResetUnitTest, FactoryResetFunc05, TestSize.Level0) +{ + CommonResetPostFunc_ = [](bool) { return 0; }; + resetTab_[FactoryResetMode::FACTORY_WIPE_DATA] = [](const std::string &) { return 0; }; + int ret = factoryResetProcess->GetInstance().FactoryResetFunc(FactoryResetMode::FACTORY_WIPE_DATA, "/data"); + EXPECT_EQ(ret, 1); +} + +HWTEST_F(FactoryResetUnitTest, FactoryResetFunc06, TestSize.Level0) +{ + resetTab_[FactoryResetMode::MENU_WIPE_DATA] = [](const std::string &) { return 0; }; + int ret = factoryResetProcess->GetInstance().FactoryResetFunc(FactoryResetMode::MENU_WIPE_DATA, "/data"); + EXPECT_EQ(ret, 1); +} + +HWTEST_F(FactoryResetUnitTest, FactoryResetFunc07, TestSize.Level0) +{ + CommonResetPostFunc_ = [](bool) { return 0; }; + resetTab_[FactoryResetMode::MENU_WIPE_DATA] = [](const std::string &) { return 0; }; + int ret = factoryResetProcess->GetInstance().FactoryResetFunc(FactoryResetMode::MENU_WIPE_DATA, "/data"); + EXPECT_EQ(ret, 1); +} +} \ No newline at end of file -- Gitee From 95e4e256f8107c9dc3b3bf868ad527035975d24b Mon Sep 17 00:00:00 2001 From: LeonShu Date: Tue, 6 Aug 2024 09:45:11 +0800 Subject: [PATCH 11/21] Signed-off-by: LeonShu --- test/unittest/updater_binary/update_partitions_unittest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/updater_binary/update_partitions_unittest.cpp b/test/unittest/updater_binary/update_partitions_unittest.cpp index 335dc230..157c727c 100755 --- a/test/unittest/updater_binary/update_partitions_unittest.cpp +++ b/test/unittest/updater_binary/update_partitions_unittest.cpp @@ -97,6 +97,6 @@ HWTEST_F(UpdatePartitionsUnitTest, UpdatePartitions_Unitest02, TestSize.Level1) delete env; ScriptManager::ReleaseScriptManager(); PkgManager::ReleasePackageInstance(pkgManager); - EXPECT_EQ(partRet, USCRIPT_ERROR_EXECUTE); + EXPECT_EQ(partRet, USCRIPT_SUCCESS); } } // namespace updater_ut -- Gitee From b994b2bc54f584955c5175949f72c50a4cc9739b Mon Sep 17 00:00:00 2001 From: LeonShu Date: Tue, 6 Aug 2024 11:26:42 +0800 Subject: [PATCH 12/21] Signed-off-by: LeonShu --- services/updater_main.h | 2 +- test/unittest/factory_reset_test/factory_reset_unittest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/updater_main.h b/services/updater_main.h index 6ff76fe1..29e0e41e 100644 --- a/services/updater_main.h +++ b/services/updater_main.h @@ -26,7 +26,7 @@ enum FactoryResetMode { USER_WIPE_DATA = 0, FACTORY_WIPE_DATA, MENU_WIPE_DATA, - INVALID, + INVALID_MODE, }; int UpdaterMain(int argc, char **argv); diff --git a/test/unittest/factory_reset_test/factory_reset_unittest.cpp b/test/unittest/factory_reset_test/factory_reset_unittest.cpp index 8f0c5adc..25bb4e3d 100644 --- a/test/unittest/factory_reset_test/factory_reset_unittest.cpp +++ b/test/unittest/factory_reset_test/factory_reset_unittest.cpp @@ -49,7 +49,7 @@ public: HWTEST_F(FactoryResetUnitTest, FactoryResetFunc01, TestSize.Level0) { - int ret = factoryResetProcess->GetInstance().FactoryResetFunc(FactoryResetMode::INVALID, "/data"); + int ret = factoryResetProcess->GetInstance().FactoryResetFunc(FactoryResetMode::INVALID_MODE, "/data"); EXPECT_EQ(ret, 1); } -- Gitee From 0109f9e7e101092d5e1bfdb802395e4a0e437227 Mon Sep 17 00:00:00 2001 From: liaoxianyi Date: Wed, 7 Aug 2024 06:59:46 +0000 Subject: [PATCH 13/21] =?UTF-8?q?sd=E5=8D=A1=E5=8D=87=E7=BA=A7=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoxianyi --- services/include/updater/updater_const.h | 2 ++ services/sdcard_update/sdcard_update.cpp | 12 ++++++++++++ services/sdcard_update/sdcard_update.h | 1 + services/updater.cpp | 3 ++- services/updater_main.cpp | 4 +++- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/services/include/updater/updater_const.h b/services/include/updater/updater_const.h index 9466c8bd..981a8991 100644 --- a/services/include/updater/updater_const.h +++ b/services/include/updater/updater_const.h @@ -51,11 +51,13 @@ constexpr const char *OTA_MODE = "update_package"; constexpr const char *USB_MODE = "usb_update"; constexpr const char *SDCARD_INTRAL_MODE = "sdcard_intral_update"; constexpr const char *UPDATRE_SCRIPT_ZIP = "/etc/updater_script.zip"; +constexpr const char *FACTORY_INTERNAL_MODE = "factory_internal_update"; // sd update ext mode constexpr const char *SDCARD_NORMAL_UPDATE = "sdUpdate"; constexpr const char *SDCARD_UPDATE_FROM_DEV = "sdUpdateFromDev"; constexpr const char *SDCARD_MAINIMG = "mainUpdate"; +constexpr const char *SDCARD_FACTORY_INTERNAL_MODE = "FactoryInternalUpdate"; #ifndef UPDATER_UT constexpr const char *SDCARD_CARD_PATH = "/sdcard/updater"; diff --git a/services/sdcard_update/sdcard_update.cpp b/services/sdcard_update/sdcard_update.cpp index ef0d4766..bc57796d 100644 --- a/services/sdcard_update/sdcard_update.cpp +++ b/services/sdcard_update/sdcard_update.cpp @@ -98,6 +98,12 @@ UpdaterStatus CheckSdcardPkgs(UpdaterParams &upParams) LOG(INFO) << "get sd card from dev succeed, skip get package from sd card"; return UPDATE_SUCCESS; } + + if (upParams.sdExtMode == SDCARD_NORMAL_UPDATE && GetFactoryInternalPkgs(upParams) == UPDATE_SUCCESS) { + LOG(INFO) << "get factory internal sdcard pkgs succeed"; + return UPDATE_SUCCESS; + } + std::string mountPoint = std::string(SDCARD_PATH); std::vector sdcardStr = GetBlockDevicesByMountPoint(mountPoint); if (sdcardStr.empty()) { @@ -125,4 +131,10 @@ UpdaterStatus CheckSdcardPkgs(UpdaterParams &upParams) } return UPDATE_SUCCESS; } + +__attribute__((weak)) UpdaterStatus GetFactoryInternalPkgs(UpdaterParams &upParams) +{ + LOG(INFO) << "not implemented get normal update sdcard pkgs"; + return UPDATE_ERROR; +} } // Updater diff --git a/services/sdcard_update/sdcard_update.h b/services/sdcard_update/sdcard_update.h index 5e607594..84f7622d 100644 --- a/services/sdcard_update/sdcard_update.h +++ b/services/sdcard_update/sdcard_update.h @@ -29,6 +29,7 @@ extern "C" { #endif UpdaterStatus GetSdcardPkgsPath(UpdaterParams &upParams); UpdaterStatus GetSdcardPkgsFromDev(UpdaterParams &upParams); +UpdaterStatus GetFactoryInternalPkgs(UpdaterParams &upParams); #ifdef __cplusplus #if __cplusplus } diff --git a/services/updater.cpp b/services/updater.cpp index 36f90f3f..5ad56223 100644 --- a/services/updater.cpp +++ b/services/updater.cpp @@ -258,7 +258,8 @@ UpdaterStatus DoInstallUpdaterPackage(PkgManager::PkgManagerPtr pkgManager, Upda } if (SetupPartitions(updateMode != SDCARD_UPDATE || upParams.sdExtMode == SDCARD_UPDATE_FROM_DEV || - Utils::CheckUpdateMode(Updater::SDCARD_INTRAL_MODE)) != 0) { + Utils::CheckUpdateMode(Updater::SDCARD_INTRAL_MODE) || + Utils::CheckUpdateMode(Updater::FACTORY_INTERNAL_MODE)) != 0) { UPDATER_UI_INSTANCE.ShowUpdInfo(TR(UPD_SETPART_FAIL), true); UPDATER_LAST_WORD(UPDATE_ERROR); return UPDATE_ERROR; diff --git a/services/updater_main.cpp b/services/updater_main.cpp index b0d12d7d..61a3b810 100644 --- a/services/updater_main.cpp +++ b/services/updater_main.cpp @@ -793,7 +793,9 @@ __attribute__((weak)) bool IsNeedWipe() void RebootAfterUpdateSuccess(const UpdaterParams &upParams) { - if (IsNeedWipe() || upParams.sdExtMode == SDCARD_UPDATE_FROM_DEV) { + if (IsNeedWipe() || + upParams.sdExtMode == SDCARD_UPDATE_FROM_DEV || + upParams.sdExtMode == SDCARD_FACTORY_INTERNAL_MODE) { Utils::UpdaterDoReboot("updater", "--user_wipe_data"); return; } -- Gitee From 179de4c8d289ed9c9b2b783ccf906917db72e12f Mon Sep 17 00:00:00 2001 From: bluesky_wang Date: Wed, 7 Aug 2024 17:51:37 +0800 Subject: [PATCH 14/21] =?UTF-8?q?Description:EMMC=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BC=98=E5=8C=96=20IssueNo:https://gitee.co?= =?UTF-8?q?m/openharmony/update=5Fupdater/issues/IAHM5N=20Binary=20Source:?= =?UTF-8?q?No=20Signed-off-by:bluesky=5Fwang=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/include/updater/updater_const.h | 2 +- services/ptable_parse/emmc_ptable.cpp | 32 +++++++++++++----------- services/ptable_parse/emmc_ptable.h | 4 +-- services/sdcard_update/sdcard_update.cpp | 6 ++--- services/sdcard_update/sdcard_update.h | 2 +- services/updater.cpp | 2 +- services/updater_main.cpp | 2 +- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/services/include/updater/updater_const.h b/services/include/updater/updater_const.h index 981a8991..672f6383 100644 --- a/services/include/updater/updater_const.h +++ b/services/include/updater/updater_const.h @@ -57,7 +57,7 @@ constexpr const char *FACTORY_INTERNAL_MODE = "factory_internal_update"; constexpr const char *SDCARD_NORMAL_UPDATE = "sdUpdate"; constexpr const char *SDCARD_UPDATE_FROM_DEV = "sdUpdateFromDev"; constexpr const char *SDCARD_MAINIMG = "mainUpdate"; -constexpr const char *SDCARD_FACTORY_INTERNAL_MODE = "FactoryInternalUpdate"; +constexpr const char *SDCARD_UPDATE_FROM_DATA = "sdUpdateFromData"; #ifndef UPDATER_UT constexpr const char *SDCARD_CARD_PATH = "/sdcard/updater"; diff --git a/services/ptable_parse/emmc_ptable.cpp b/services/ptable_parse/emmc_ptable.cpp index 8bce4a2a..4c398ee6 100644 --- a/services/ptable_parse/emmc_ptable.cpp +++ b/services/ptable_parse/emmc_ptable.cpp @@ -123,7 +123,7 @@ bool EmmcPtable::ParsePartitionFromBuffer(uint8_t *ptbImgBuffer, const uint32_t bool EmmcPtable::ParseGptHeaderByEmmc(uint8_t *gptImage, const uint32_t len) { GPTHeaderInfo gptHeaderInfo; - uint32_t blockSize = ptableData_.blockSize; // 4096 + uint32_t blockSize = EMMC_BLOCK_SIZE; (void)memset_s(&gptHeaderInfo, sizeof(GPTHeaderInfo), 0, sizeof(GPTHeaderInfo)); if (!GetPartitionGptHeaderInfo(gptImage + blockSize, blockSize, gptHeaderInfo)) { LOG(ERROR) << "GetPartitionGptHeaderInfo fail"; @@ -138,9 +138,15 @@ bool EmmcPtable::ParseGptHeaderByEmmc(uint8_t *gptImage, const uint32_t len) return PartitionCheckGptHeader(gptImage, len, lbaNum, blockSize, gptHeaderInfo); } -bool EmmcPtable::EmmcReadGpt(uint8_t *ptableData) +bool EmmcPtable::EmmcReadGpt(uint8_t *ptableData, uint32_t len) { uint32_t number = 0; + + partitionInfo_.clear(); + if (!ParseGptHeaderByEmmc(emmcPtnDataInfo_.data, len)) { + LOG(ERROR) << "Primary signature invalid"; + return false; + } for (uint32_t i = 0; i < MAX_PARTITION_NUM; i++) { uint8_t *startLbaOffset = ptableData + GPT_PARTITION_START_LBA_OFFSET; uint8_t *endLbaOffset = ptableData + GPT_PARTITION_START_LBA_OFFSET + GPT_PARTITION_END_LBA_OFFSET; @@ -159,6 +165,8 @@ bool EmmcPtable::EmmcReadGpt(uint8_t *ptableData) LOG(ERROR) << "memcpy guid fail"; } newPtnInfo.startAddr = startLba * LBA_LENGTH; + newPtnInfo.writePath = MMC_BLOCK_DEV_NAME; + newPtnInfo.writeMode = "WRITE_RAW"; /* General algorithm : calculate partition size by lba */ newPtnInfo.partitionSize = (endLba - startLba + 1) * LBA_LENGTH; ptableData += GPT_PARTITION_INFO_LENGTH; @@ -176,7 +184,7 @@ bool EmmcPtable::UpdateCommInitializeGptPartition(uint8_t *gptImage, const uint3 return false; } uint32_t imgBlockSize = ptableData_.lbaLen; // 512 - uint32_t deviceBlockSize = ptableData_.blockSize; // 4096 + uint32_t deviceBlockSize = EMMC_BLOCK_SIZE; uint8_t *gptHeaderStart = gptImage + imgBlockSize; uint8_t *ptableData = gptImage + PROTECTIVE_MBR_SIZE + LBA_LENGTH; /* skip MBR and gpt header */ @@ -204,14 +212,10 @@ bool EmmcPtable::UpdateCommInitializeGptPartition(uint8_t *gptImage, const uint3 return false; } emmcPtnDataInfo_.writeDataLen = len; - if (!ParseGptHeaderByEmmc(emmcPtnDataInfo_.data, len)) { - LOG(ERROR) << "Primary signature invalid"; - return false; - } EmmcPatchGptHeader(emmcPtnDataInfo_, deviceBlockSize); emmcPtnDataInfo_.isGptVaild = true; - return EmmcReadGpt(ptableData); + return EmmcReadGpt(emmcPtnDataInfo_.data + 2 * deviceBlockSize, len); // 2: skip 2 lba length to set gpt entry } bool EmmcPtable::ReadEmmcGptImageToRam() @@ -224,7 +228,7 @@ bool EmmcPtable::ReadEmmcGptImageToRam() int32_t imgLen = GPT_PARTITION_SIZE; auto buf = std::make_unique(imgLen); uint8_t *buffer = buf.get(); - uint32_t deviceBlockSize = ptableData_.blockSize; // 4096 + uint32_t deviceBlockSize = EMMC_BLOCK_SIZE; if (buffer == nullptr) { LOG(ERROR) << "new buffer failed!"; return false; @@ -251,7 +255,7 @@ bool EmmcPtable::ReadEmmcGptImageToRam() emmcPtnDataInfo_.isGptVaild = true; uint8_t *ptableData = buffer + 2 * deviceBlockSize; /* skip MBR and gpt header */ - return EmmcReadGpt(ptableData); + return EmmcReadGpt(ptableData, imgLen); } bool EmmcPtable::LoadPtableFromDevice() @@ -282,7 +286,7 @@ bool EmmcPtable::GetPtableImageBuffer(uint8_t *imageBuf, const uint32_t imgBufSi bool EmmcPtable::EditPartitionBuf(uint8_t *imageBuf, uint64_t imgBufSize, std::vector &modifyList) { - if (imageBuf == nullptr || imgBufSize == 0 || modifyList.empty() == 0) { + if (imageBuf == nullptr || imgBufSize == 0 || modifyList.empty()) { LOG(ERROR) << "input invalid"; return false; } @@ -291,9 +295,9 @@ bool EmmcPtable::EditPartitionBuf(uint8_t *imageBuf, uint64_t imgBufSize, std::v uint8_t *gptHeader = gptImage + imgBlockSize; uint32_t maxPtnCnt = GET_LWORD_FROM_BYTE(&gptHeader[PARTITION_COUNT_OFFSET]); uint32_t ptnEntrySize = GET_LWORD_FROM_BYTE(&gptHeader[PENTRY_SIZE_OFFSET]); - uint32_t gptHeaderLen = EMMC_BLOCK_SIZE; - uint32_t gptSize = static_cast(maxPtnCnt) * ptnEntrySize + imgBlockSize + gptHeaderLen; - uint32_t devDensity = GetDeviceCapacity(); + uint64_t gptHeaderLen = EMMC_BLOCK_SIZE; + uint64_t gptSize = static_cast(maxPtnCnt) * ptnEntrySize + imgBlockSize + gptHeaderLen; + uint64_t devDensity = GetDeviceCapacity(); if (devDensity == 0) { LOG(ERROR) << "get emmc capacity fail"; return false; diff --git a/services/ptable_parse/emmc_ptable.h b/services/ptable_parse/emmc_ptable.h index fcec50f7..60963db1 100644 --- a/services/ptable_parse/emmc_ptable.h +++ b/services/ptable_parse/emmc_ptable.h @@ -42,7 +42,7 @@ private: static constexpr uint32_t LBA_LENGTH = 512; static constexpr uint32_t GPT_PARTITION_INFO_LENGTH = 128; static constexpr uint32_t PROTECTIVE_MBR_SIZE = 512; - static constexpr uint32_t MIN_EMMC_WRITE_SIZE = 4096; + static constexpr uint32_t MIN_EMMC_WRITE_SIZE = 512; static constexpr uint32_t EMMC_BLOCK_SIZE = 512; struct EmmcPartitionDataInfo { @@ -53,7 +53,7 @@ private: struct EmmcPartitionDataInfo emmcPtnDataInfo_; - bool EmmcReadGpt(uint8_t *ptableData); + bool EmmcReadGpt(uint8_t *ptableData, uint32_t len); bool UpdateCommInitializeGptPartition(uint8_t *gptImage, const uint32_t len); bool ReadEmmcGptImageToRam(); uint64_t GetDeviceCapacity(); diff --git a/services/sdcard_update/sdcard_update.cpp b/services/sdcard_update/sdcard_update.cpp index bc57796d..f13bf526 100644 --- a/services/sdcard_update/sdcard_update.cpp +++ b/services/sdcard_update/sdcard_update.cpp @@ -99,8 +99,8 @@ UpdaterStatus CheckSdcardPkgs(UpdaterParams &upParams) return UPDATE_SUCCESS; } - if (upParams.sdExtMode == SDCARD_NORMAL_UPDATE && GetFactoryInternalPkgs(upParams) == UPDATE_SUCCESS) { - LOG(INFO) << "get factory internal sdcard pkgs succeed"; + if (GetSdcardInternalPkgs(upParams) == UPDATE_SUCCESS) { + LOG(INFO) << "get sdcard internal pkgs succeed"; return UPDATE_SUCCESS; } @@ -132,7 +132,7 @@ UpdaterStatus CheckSdcardPkgs(UpdaterParams &upParams) return UPDATE_SUCCESS; } -__attribute__((weak)) UpdaterStatus GetFactoryInternalPkgs(UpdaterParams &upParams) +__attribute__((weak)) UpdaterStatus GetSdcardInternalPkgs(UpdaterParams &upParams) { LOG(INFO) << "not implemented get normal update sdcard pkgs"; return UPDATE_ERROR; diff --git a/services/sdcard_update/sdcard_update.h b/services/sdcard_update/sdcard_update.h index 84f7622d..9f238b03 100644 --- a/services/sdcard_update/sdcard_update.h +++ b/services/sdcard_update/sdcard_update.h @@ -29,7 +29,7 @@ extern "C" { #endif UpdaterStatus GetSdcardPkgsPath(UpdaterParams &upParams); UpdaterStatus GetSdcardPkgsFromDev(UpdaterParams &upParams); -UpdaterStatus GetFactoryInternalPkgs(UpdaterParams &upParams); +UpdaterStatus GetSdcardInternalPkgs(UpdaterParams &upParams); #ifdef __cplusplus #if __cplusplus } diff --git a/services/updater.cpp b/services/updater.cpp index 5ad56223..2bf70ddd 100644 --- a/services/updater.cpp +++ b/services/updater.cpp @@ -258,7 +258,7 @@ UpdaterStatus DoInstallUpdaterPackage(PkgManager::PkgManagerPtr pkgManager, Upda } if (SetupPartitions(updateMode != SDCARD_UPDATE || upParams.sdExtMode == SDCARD_UPDATE_FROM_DEV || - Utils::CheckUpdateMode(Updater::SDCARD_INTRAL_MODE) || + upParams.sdExtMode == SDCARD_UPDATE_FROM_DATA || Utils::CheckUpdateMode(Updater::SDCARD_INTRAL_MODE) || Utils::CheckUpdateMode(Updater::FACTORY_INTERNAL_MODE)) != 0) { UPDATER_UI_INSTANCE.ShowUpdInfo(TR(UPD_SETPART_FAIL), true); UPDATER_LAST_WORD(UPDATE_ERROR); diff --git a/services/updater_main.cpp b/services/updater_main.cpp index 61a3b810..a3e85267 100644 --- a/services/updater_main.cpp +++ b/services/updater_main.cpp @@ -795,7 +795,7 @@ void RebootAfterUpdateSuccess(const UpdaterParams &upParams) { if (IsNeedWipe() || upParams.sdExtMode == SDCARD_UPDATE_FROM_DEV || - upParams.sdExtMode == SDCARD_FACTORY_INTERNAL_MODE) { + upParams.sdExtMode == SDCARD_UPDATE_FROM_DATA) { Utils::UpdaterDoReboot("updater", "--user_wipe_data"); return; } -- Gitee From 3e38d5f3a2049b1e33d0ddfdc6fedc2cc4844649 Mon Sep 17 00:00:00 2001 From: like2001 Date: Fri, 9 Aug 2024 17:15:10 +0800 Subject: [PATCH 15/21] =?UTF-8?q?=E5=B7=AE=E5=88=86=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: like2001 --- .../updater_binary/update_image_block.cpp | 20 +++++++++++-------- services/updater_binary/update_image_block.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/services/updater_binary/update_image_block.cpp b/services/updater_binary/update_image_block.cpp index 4530b324..2bbcfcb5 100644 --- a/services/updater_binary/update_image_block.cpp +++ b/services/updater_binary/update_image_block.cpp @@ -471,19 +471,23 @@ int32_t UScriptInstructionBlockCheck::Execute(Uscript::UScriptEnv &env, Uscript: return USCRIPT_SUCCESS; } +bool UScriptInstructionShaCheck::IsTargetShaDiff(const std::string &devPath, const ShaInfo &shaInfo) +{ + std::string tgtResultSha = CalculateBlockSha(devPath, shaInfo.targetPairs); + if (tgtResultSha.empty()) { + LOG(WARNING) << "target sha is empty"; + return true; + } + LOG(INFO) << "tgtResultSha: " << tgtResultSha << " shaInfo.targetSha: " << shaInfo.targetSha; + return (tgtResultSha != shaInfo.targetSha); +} + int UScriptInstructionShaCheck::ExecReadShaInfo(Uscript::UScriptEnv &env, const std::string &devPath, const ShaInfo &shaInfo) { UPDATER_INIT_RECORD; std::string resultSha = CalculateBlockSha(devPath, shaInfo.blockPairs); - std::string tgtResultSha = CalculateBlockSha(devPath, shaInfo.targetPairs); - if (resultSha.empty() && tgtResultSha.empty()) { - LOG(ERROR) << "All sha is empty"; - return USCRIPT_ERROR_EXECUTE; - } - - bool isTargetDiff = tgtResultSha.empty() ? true : (tgtResultSha != shaInfo.targetSha); - if (resultSha != shaInfo.contrastSha && isTargetDiff) { + if (resultSha != shaInfo.contrastSha && IsTargetShaDiff()) { LOG(ERROR) << "Different sha256, cannot continue"; LOG(ERROR) << "blockPairs:" << shaInfo.blockPairs; PrintAbnormalBlockHash(devPath, shaInfo.blockPairs); diff --git a/services/updater_binary/update_image_block.h b/services/updater_binary/update_image_block.h index 2006b5ae..fe2e39bd 100644 --- a/services/updater_binary/update_image_block.h +++ b/services/updater_binary/update_image_block.h @@ -53,6 +53,7 @@ private: void PrintAbnormalBlockHash(const std::string &devPath, const std::string &blockPairs); std::string CalculateBlockSha(const std::string &devPath, const std::string &blockPairs); int32_t SetShaInfo(Uscript::UScriptContext &context, ShaInfo &shaInfo); + bool IsTargetShaDiff(const std::string &devPath, const ShaInfo &shaInfo); }; } -- Gitee From f354ab55223f06a90035be58de00c3bb567ea66f Mon Sep 17 00:00:00 2001 From: like2001 Date: Fri, 9 Aug 2024 17:15:10 +0800 Subject: [PATCH 16/21] =?UTF-8?q?=E5=B7=AE=E5=88=86=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: like2001 --- .../updater_binary/update_image_block.cpp | 20 +++++++++++-------- services/updater_binary/update_image_block.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/services/updater_binary/update_image_block.cpp b/services/updater_binary/update_image_block.cpp index 4530b324..5b902dd2 100644 --- a/services/updater_binary/update_image_block.cpp +++ b/services/updater_binary/update_image_block.cpp @@ -471,19 +471,23 @@ int32_t UScriptInstructionBlockCheck::Execute(Uscript::UScriptEnv &env, Uscript: return USCRIPT_SUCCESS; } +bool UScriptInstructionShaCheck::IsTargetShaDiff(const std::string &devPath, const ShaInfo &shaInfo) +{ + std::string tgtResultSha = CalculateBlockSha(devPath, shaInfo.targetPairs); + if (tgtResultSha.empty()) { + LOG(WARNING) << "target sha is empty"; + return true; + } + LOG(INFO) << "tgtResultSha: " << tgtResultSha << " shaInfo.targetSha: " << shaInfo.targetSha; + return (tgtResultSha != shaInfo.targetSha); +} + int UScriptInstructionShaCheck::ExecReadShaInfo(Uscript::UScriptEnv &env, const std::string &devPath, const ShaInfo &shaInfo) { UPDATER_INIT_RECORD; std::string resultSha = CalculateBlockSha(devPath, shaInfo.blockPairs); - std::string tgtResultSha = CalculateBlockSha(devPath, shaInfo.targetPairs); - if (resultSha.empty() && tgtResultSha.empty()) { - LOG(ERROR) << "All sha is empty"; - return USCRIPT_ERROR_EXECUTE; - } - - bool isTargetDiff = tgtResultSha.empty() ? true : (tgtResultSha != shaInfo.targetSha); - if (resultSha != shaInfo.contrastSha && isTargetDiff) { + if (resultSha != shaInfo.contrastSha && IsTargetShaDiff(devPath, shaInfo)) { LOG(ERROR) << "Different sha256, cannot continue"; LOG(ERROR) << "blockPairs:" << shaInfo.blockPairs; PrintAbnormalBlockHash(devPath, shaInfo.blockPairs); diff --git a/services/updater_binary/update_image_block.h b/services/updater_binary/update_image_block.h index 2006b5ae..fe2e39bd 100644 --- a/services/updater_binary/update_image_block.h +++ b/services/updater_binary/update_image_block.h @@ -53,6 +53,7 @@ private: void PrintAbnormalBlockHash(const std::string &devPath, const std::string &blockPairs); std::string CalculateBlockSha(const std::string &devPath, const std::string &blockPairs); int32_t SetShaInfo(Uscript::UScriptContext &context, ShaInfo &shaInfo); + bool IsTargetShaDiff(const std::string &devPath, const ShaInfo &shaInfo); }; } -- Gitee From f12c0c53bc8810e29ccb305923cff5b59c8a1b44 Mon Sep 17 00:00:00 2001 From: chenzihan Date: Mon, 12 Aug 2024 14:58:09 +0800 Subject: [PATCH 17/21] Signed-off-by: chenzihan fix:clear misc after sdcard updater failed --- services/updater_ui.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/updater_ui.cpp b/services/updater_ui.cpp index bc081932..c1fa1cbc 100644 --- a/services/updater_ui.cpp +++ b/services/updater_ui.cpp @@ -108,6 +108,7 @@ DEFINE_ASYN_CALLBACK(OnLabelSDCardNoDelayEvt) UpdaterParams upParams; upParams.updateMode = SDCARD_UPDATE; if (auto res = UpdaterFromSdcard(upParams); res != UPDATE_SUCCESS) { + Utils::RemoveUpdateInfoFromMisc("sdcard_update"); GetFacade().ShowLogRes(res == UPDATE_CORRUPT ? TR(LOGRES_VERIFY_FAILED) : TR(LOGRES_UPDATE_FAILED)); GetFacade().ShowFailedPage(); Utils::UsSleep(FAIL_DELAY); -- Gitee From 983fe409e4d160f1499d6eba5400b8cd1ec969d4 Mon Sep 17 00:00:00 2001 From: chenzihan Date: Fri, 16 Aug 2024 15:01:07 +0800 Subject: [PATCH 18/21] Signed-off-by: chenzihan fix:add CompressFiles --- utils/include/utils.h | 1 + utils/utils.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/utils/include/utils.h b/utils/include/utils.h index 4de915bf..59bba7ca 100644 --- a/utils/include/utils.h +++ b/utils/include/utils.h @@ -65,6 +65,7 @@ bool CopyFile(const std::string &src, const std::string &dest, bool isAppend = f bool WriteStringToFile(int fd, const std::string& content); std::string GetLocalBoardId(); bool CopyUpdaterLogs(const std::string &sLog, const std::string &dLog); +void CompressFiles(std::vector &files, std::vector &zipFile); void CompressLogs(const std::string &name); bool CheckResultFail(); void WriteDumpResult(const std::string &result, const std::string &fileName); diff --git a/utils/utils.cpp b/utils/utils.cpp index e5b50430..2c40bab3 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -413,6 +413,29 @@ int32_t CreateCompressLogFile(const std::string &pkgName, std::vector &files, std::vector &zipFile) +{ + (void)DeleteFile(zipFile); + std::vector> zipFiles {}; + for (auto path : files) { + ZipFileInfo file; + file.fileInfo.identity = path.substr(logName.find_last_of("/") + 1);; + file.fileInfo.packMethod = PKG_COMPRESS_METHOD_ZIP; + file.fileInfo.digestMethod = PKG_DIGEST_TYPE_CRC; + files.push_back(std::pair(path, file)); + } + + int32_t ret = CreateCompressLogFile(zipFile, zipFiles); + if (ret != 0) { + LOG(WARNING) << "CompressFiles failed: " << zipFile; + return; + } + mode_t mode = 0660; +#ifndef __WIN32 + SetFileAttributes(pkgName, USER_UPDATE_AUTHORITY, GROUP_SYS_AUTHORITY, mode); +#endif +} + void CompressLogs(const std::string &logName) { std::vector> files; -- Gitee From 1f14d089452f55ee4d6a814ef7cf33ada42490f2 Mon Sep 17 00:00:00 2001 From: chenzihan Date: Fri, 16 Aug 2024 16:40:56 +0800 Subject: [PATCH 19/21] Signed-off-by: chenzihan fix:add CompressFiles --- utils/include/utils.h | 2 +- utils/utils.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/include/utils.h b/utils/include/utils.h index 59bba7ca..018d8d08 100644 --- a/utils/include/utils.h +++ b/utils/include/utils.h @@ -65,7 +65,7 @@ bool CopyFile(const std::string &src, const std::string &dest, bool isAppend = f bool WriteStringToFile(int fd, const std::string& content); std::string GetLocalBoardId(); bool CopyUpdaterLogs(const std::string &sLog, const std::string &dLog); -void CompressFiles(std::vector &files, std::vector &zipFile); +void CompressFiles(std::vector &files, const std::string &zipFile); void CompressLogs(const std::string &name); bool CheckResultFail(); void WriteDumpResult(const std::string &result, const std::string &fileName); diff --git a/utils/utils.cpp b/utils/utils.cpp index 2c40bab3..3db5fd29 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -413,7 +413,7 @@ int32_t CreateCompressLogFile(const std::string &pkgName, std::vector &files, std::vector &zipFile) +void CompressFiles(std::vector &files, const std::string &zipFile) { (void)DeleteFile(zipFile); std::vector> zipFiles {}; -- Gitee From c08cb318b2320027e35eb6e66730d02c64118b7b Mon Sep 17 00:00:00 2001 From: chenzihan Date: Fri, 16 Aug 2024 17:28:09 +0800 Subject: [PATCH 20/21] Signed-off-by: chenzihan fix:add CompressFiles --- utils/utils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/utils.cpp b/utils/utils.cpp index 3db5fd29..9761eccc 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -419,10 +419,10 @@ void CompressFiles(std::vector &files, const std::string &zipFile) std::vector> zipFiles {}; for (auto path : files) { ZipFileInfo file; - file.fileInfo.identity = path.substr(logName.find_last_of("/") + 1);; + file.fileInfo.identity = path.substr(path.find_last_of("/") + 1);; file.fileInfo.packMethod = PKG_COMPRESS_METHOD_ZIP; file.fileInfo.digestMethod = PKG_DIGEST_TYPE_CRC; - files.push_back(std::pair(path, file)); + zipFiles.push_back(std::pair(path, file)); } int32_t ret = CreateCompressLogFile(zipFile, zipFiles); @@ -432,7 +432,7 @@ void CompressFiles(std::vector &files, const std::string &zipFile) } mode_t mode = 0660; #ifndef __WIN32 - SetFileAttributes(pkgName, USER_UPDATE_AUTHORITY, GROUP_SYS_AUTHORITY, mode); + SetFileAttributes(zipFile, USER_UPDATE_AUTHORITY, GROUP_SYS_AUTHORITY, mode); #endif } -- Gitee From 8a45bd80d654c2a2c1db542710cc9b2a3fbedd86 Mon Sep 17 00:00:00 2001 From: chenzihan Date: Fri, 16 Aug 2024 20:29:49 +0800 Subject: [PATCH 21/21] Signed-off-by: chenzihan fix:add CompressFiles --- utils/utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/utils.cpp b/utils/utils.cpp index 9761eccc..d5d6b6ab 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -418,8 +418,8 @@ void CompressFiles(std::vector &files, const std::string &zipFile) (void)DeleteFile(zipFile); std::vector> zipFiles {}; for (auto path : files) { - ZipFileInfo file; - file.fileInfo.identity = path.substr(path.find_last_of("/") + 1);; + ZipFileInfo file {}; + file.fileInfo.identity = path.substr(path.find_last_of("/") + 1); file.fileInfo.packMethod = PKG_COMPRESS_METHOD_ZIP; file.fileInfo.digestMethod = PKG_DIGEST_TYPE_CRC; zipFiles.push_back(std::pair(path, file)); -- Gitee