From f717aca34404c5a6d88a1ae172be83f683d76f83 Mon Sep 17 00:00:00 2001 From: weimingjin Date: Mon, 18 Nov 2024 19:39:09 +0800 Subject: [PATCH 1/6] add bundle scan progress Signed-off-by: weimingjin --- .../include/boot_animation_strategy.h | 1 + .../include/boot_compile_progress.h | 13 ++- .../src/boot_animation_strategy.cpp | 10 +++ .../src/boot_associative_display_strategy.cpp | 6 +- .../src/boot_compatible_display_strategy.cpp | 6 +- .../src/boot_compile_progress.cpp | 85 ++++++++++++++++++- .../src/boot_independent_display_strategy.cpp | 6 +- 7 files changed, 116 insertions(+), 11 deletions(-) diff --git a/frameworks/bootanimation/include/boot_animation_strategy.h b/frameworks/bootanimation/include/boot_animation_strategy.h index e68776243f..e5069ddac3 100644 --- a/frameworks/bootanimation/include/boot_animation_strategy.h +++ b/frameworks/bootanimation/include/boot_animation_strategy.h @@ -31,6 +31,7 @@ public: bool CheckExitAnimation(); bool CheckNeedOtaCompile() const; + bool CheckNeedBundleScan() const; public: std::shared_ptr bootCompileProgress_; diff --git a/frameworks/bootanimation/include/boot_compile_progress.h b/frameworks/bootanimation/include/boot_compile_progress.h index ecc265973d..42262224a0 100644 --- a/frameworks/bootanimation/include/boot_compile_progress.h +++ b/frameworks/bootanimation/include/boot_compile_progress.h @@ -30,7 +30,7 @@ namespace OHOS { class BootCompileProgress { public: - void Init(const BootAnimationConfig& config); + void Init(const BootAnimationConfig& config, bool needOtaCompile, bool needBundleScan); private: void OnVsync(); @@ -40,6 +40,11 @@ private: bool CreateCanvasNode(); bool RegisterVsyncCallback(); Rosen::Drawing::Brush DrawProgressPoint(int32_t idx, int32_t frameNum); + bool WaitParamsIfNeeded(); + bool WaitBundleScanIfNeeded(); + bool CheckParams(); + bool CheckBundleScanParam(); + bool CheckBmsStartParam(); int32_t windowWidth_ = 0; int32_t windowHeight_ = 0; @@ -53,7 +58,7 @@ private: Rosen::ScreenId screenId_; std::string displayInfo_ = ""; - bool isBmsCompileDone_ = false; + //bool isBmsCompileDone_ = false; volatile bool isUpdateOptEnd_ = false; std::shared_ptr rsSurfaceNode_; @@ -63,6 +68,10 @@ private: std::shared_ptr compileHandler_; std::shared_ptr compileRunner_; std::shared_ptr sharpCurve_; + + bool needOtaCompile_ = false; + bool needBundleScan_ = false; + std::set paramNeeded_; }; } // namespace OHOS diff --git a/frameworks/bootanimation/src/boot_animation_strategy.cpp b/frameworks/bootanimation/src/boot_animation_strategy.cpp index 549b0d9ede..dcc57daf9e 100644 --- a/frameworks/bootanimation/src/boot_animation_strategy.cpp +++ b/frameworks/bootanimation/src/boot_animation_strategy.cpp @@ -98,4 +98,14 @@ bool BootAnimationStrategy::CheckNeedOtaCompile() const } return false; } + +bool BootAnimationStrategy::CheckNeedBundleScan() const +{ + LOGI("CheckNeedBundleScan"); + if (system::GetParameter("bms.scanning_apps.status", "-1") == "1") { + LOGI("bundle scan is already done."); + return false; + } + return true; +} } // namespace OHOS diff --git a/frameworks/bootanimation/src/boot_associative_display_strategy.cpp b/frameworks/bootanimation/src/boot_associative_display_strategy.cpp index d2fc33e99b..a9464c0973 100644 --- a/frameworks/bootanimation/src/boot_associative_display_strategy.cpp +++ b/frameworks/bootanimation/src/boot_associative_display_strategy.cpp @@ -56,9 +56,11 @@ void BootAssociativeDisplayStrategy::Display(int32_t duration, std::vectorInit(config, screenWidth, screenHeight, duration); operator_->GetThread().join(); - if (CheckNeedOtaCompile()) { + bool needOtaCompile = CheckNeedOtaCompile(); + bool needBundleScan = CheckNeedBundleScan(); + if (needOtaCompile || needBundleScan) { bootCompileProgress_ = std::make_shared(); - bootCompileProgress_->Init(config); + bootCompileProgress_->Init(config, needOtaCompile, needBundleScan); } while (!CheckExitAnimation()) { diff --git a/frameworks/bootanimation/src/boot_compatible_display_strategy.cpp b/frameworks/bootanimation/src/boot_compatible_display_strategy.cpp index f0ad379e47..39f27f15a4 100644 --- a/frameworks/bootanimation/src/boot_compatible_display_strategy.cpp +++ b/frameworks/bootanimation/src/boot_compatible_display_strategy.cpp @@ -50,9 +50,11 @@ void BootCompatibleDisplayStrategy::Display(int32_t duration, std::vectorInit(config, screenWidth, screenHeight, duration); operator_->GetThread().join(); - if (CheckNeedOtaCompile()) { + bool needOtaCompile = CheckNeedOtaCompile(); + bool needBundleScan = CheckNeedBundleScan(); + if (needOtaCompile || needBundleScan) { bootCompileProgress_ = std::make_shared(); - bootCompileProgress_->Init(config); + bootCompileProgress_->Init(config, needOtaCompile, needBundleScan); } } diff --git a/frameworks/bootanimation/src/boot_compile_progress.cpp b/frameworks/bootanimation/src/boot_compile_progress.cpp index ec31e443f6..b23503b569 100644 --- a/frameworks/bootanimation/src/boot_compile_progress.cpp +++ b/frameworks/bootanimation/src/boot_compile_progress.cpp @@ -59,11 +59,21 @@ namespace { { { 0.5f, 0.2f }, { 0.2f, 1.0f }, { 1.0f, 0.5f } }, { { 1.0f, 0.5f }, { 0.5f, 0.2f }, { 0.2f, 1.0f } }, }; + constexpr const char* BUNDLE_SCAN_PARAM_NAME = "bms.scanning_apps.status"; } -void BootCompileProgress::Init(const BootAnimationConfig& config) +void BootCompileProgress::Init(const BootAnimationConfig& config, bool needOtaCompile, bool needBundleScan) { LOGI("ota compile, screenId: " BPUBU64 "", config.screenId); + needOtaCompile_ = needOtaCompile; + needBundleScan_ = needBundleScan; + paramNeeded_.clear(); + if (needOtaCompile_) { + paramNeeded_.insert(BMS_COMPILE_STATUS); + } + if (needBundleScan_) { + paramNeeded_.insert(BUNDLE_SCAN_PARAM_NAME); + } screenId_ = config.screenId; rotateDegree_ = config.rotateDegree; Rosen::RSInterfaces& interface = Rosen::RSInterfaces::GetInstance(); @@ -121,6 +131,7 @@ bool BootCompileProgress::CreateCanvasNode() bool BootCompileProgress::RegisterVsyncCallback() { + /* if (system::GetParameter(BMS_COMPILE_STATUS, "-1") == BMS_COMPILE_STATUS_END) { LOGI("bms compile is already done."); compileRunner_->Stop(); @@ -131,6 +142,17 @@ bool BootCompileProgress::RegisterVsyncCallback() compileRunner_->Stop(); return false; } + */ + if(CheckParams()){ + LOGI("all param status are COMPLETED"); + compileRunner_->Stop(); + return false; + } + if(!WaitParamsIfNeeded()){ + LOGI("no param is ready, progress bar stop"); + compileRunner_->Stop(); + return false; + } auto& rsClient = Rosen::RSInterfaces::GetInstance(); int32_t retry = 0; @@ -170,9 +192,65 @@ bool BootCompileProgress::RegisterVsyncCallback() return true; } +bool BootCompileProgress::CheckParams() +{ + bool check1 = CheckBmsStartParam(); + bool check2 = CheckBundleScanParam(); + if (check1 && check2) { + return true; + } + return false; +} +bool BootCompileProgress::CheckBundleScanParam() +{ + if (!needBundleScan_) { + return true; + } + if (system::GetParameter(BUNDLE_SCAN_PARAM_NAME, "-1") == "1"){ + paramNeeded_.erase(BUNDLE_SCAN_PARAM_NAME); + return true; + } + return false; +} +bool BootCompileProgress::CheckBmsStartParam() +{ + if (!needOtaCompile_) { + return true; + } + if (system::GetParameter(BMS_COMPILE_STATUS, "-1") == BMS_COMPILE_STATUS_END) { + paramNeeded_.erase(BMS_COMPILE_STATUS); + return true; + } + return false; +} +bool BootCompileProgress::WaitParamsIfNeeded() +{ + bool wait1 = WaitBmsStartIfNeeded(); + bool wait2 = WaitBundleScanIfNeeded(); + if (!wait1 && !wait2) { + return false; + } + return true; +} +bool BootCompileProgress::WaitBundleScanIfNeeded() +{ + if (!needBundleScan_) { + return true; + } + if (WaitParameter(BUNDLE_SCAN_PARAM_NAME, "0", 3) != 0) { + paramNeeded_.erase(BUNDLE_SCAN_PARAM_NAME); + LOGE("waiting bundle scan failed."); + return false; + } + return true; +} bool BootCompileProgress::WaitBmsStartIfNeeded() { + if (!needBundleScan_) { + return true; + } if (WaitParameter(BMS_COMPILE_STATUS, BMS_COMPILE_STATUS_BEGIN.c_str(), WAITING_BMS_TIMEOUT) != 0) { + paramNeeded_.erase(BMS_COMPILE_STATUS); LOGE("waiting bms start oat compile failed."); return false; } @@ -250,8 +328,9 @@ void BootCompileProgress::DrawCompileProgress() void BootCompileProgress::UpdateCompileProgress() { - if (!isBmsCompileDone_) { - isBmsCompileDone_ = system::GetParameter(BMS_COMPILE_STATUS, "-1") == BMS_COMPILE_STATUS_END; + (void)CheckParams(); + if (paramNeeded_.size() > 0) { + //isBmsCompileDone_ = system::GetParameter(BMS_COMPILE_STATUS, "-1") == BMS_COMPILE_STATUS_END; int64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()) .count(); diff --git a/frameworks/bootanimation/src/boot_independent_display_strategy.cpp b/frameworks/bootanimation/src/boot_independent_display_strategy.cpp index 9df4f286af..c666656153 100644 --- a/frameworks/bootanimation/src/boot_independent_display_strategy.cpp +++ b/frameworks/bootanimation/src/boot_independent_display_strategy.cpp @@ -44,9 +44,11 @@ void BootIndependentDisplayStrategy::Display(int32_t duration, std::vectorGetThread().join(); } - if (CheckNeedOtaCompile()) { + bool needOtaCompile = CheckNeedOtaCompile(); + bool needBundleScan = CheckNeedBundleScan(); + if (needOtaCompile || needBundleScan) { bootCompileProgress_ = std::make_shared(); - bootCompileProgress_->Init(screenConfig); + bootCompileProgress_->Init(screenConfig, needOtaCompile, needBundleScan); } while (!CheckExitAnimation()) { From eb3bc91d887a87513ac2cdd253fa569dba1bb7f1 Mon Sep 17 00:00:00 2001 From: weimingjin Date: Mon, 18 Nov 2024 20:45:30 +0800 Subject: [PATCH 2/6] add bundle scan progress Signed-off-by: weimingjin --- frameworks/bootanimation/src/boot_compile_progress.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/bootanimation/src/boot_compile_progress.cpp b/frameworks/bootanimation/src/boot_compile_progress.cpp index b23503b569..c338dc2141 100644 --- a/frameworks/bootanimation/src/boot_compile_progress.cpp +++ b/frameworks/bootanimation/src/boot_compile_progress.cpp @@ -246,7 +246,7 @@ bool BootCompileProgress::WaitBundleScanIfNeeded() } bool BootCompileProgress::WaitBmsStartIfNeeded() { - if (!needBundleScan_) { + if (!needOtaCompile_) { return true; } if (WaitParameter(BMS_COMPILE_STATUS, BMS_COMPILE_STATUS_BEGIN.c_str(), WAITING_BMS_TIMEOUT) != 0) { From 7333bd084c3fad34cf7e4d109dba113935826d50 Mon Sep 17 00:00:00 2001 From: weimingjin Date: Tue, 19 Nov 2024 17:55:31 +0800 Subject: [PATCH 3/6] add bundle scan progress Signed-off-by: weimingjin --- .../include/boot_compile_progress.h | 1 - .../src/boot_compile_progress.cpp | 18 +++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/frameworks/bootanimation/include/boot_compile_progress.h b/frameworks/bootanimation/include/boot_compile_progress.h index 42262224a0..c52ba2959c 100644 --- a/frameworks/bootanimation/include/boot_compile_progress.h +++ b/frameworks/bootanimation/include/boot_compile_progress.h @@ -58,7 +58,6 @@ private: Rosen::ScreenId screenId_; std::string displayInfo_ = ""; - //bool isBmsCompileDone_ = false; volatile bool isUpdateOptEnd_ = false; std::shared_ptr rsSurfaceNode_; diff --git a/frameworks/bootanimation/src/boot_compile_progress.cpp b/frameworks/bootanimation/src/boot_compile_progress.cpp index c338dc2141..1c9996d80f 100644 --- a/frameworks/bootanimation/src/boot_compile_progress.cpp +++ b/frameworks/bootanimation/src/boot_compile_progress.cpp @@ -131,24 +131,12 @@ bool BootCompileProgress::CreateCanvasNode() bool BootCompileProgress::RegisterVsyncCallback() { - /* - if (system::GetParameter(BMS_COMPILE_STATUS, "-1") == BMS_COMPILE_STATUS_END) { - LOGI("bms compile is already done."); - compileRunner_->Stop(); - return false; - } - - if (!WaitBmsStartIfNeeded()) { - compileRunner_->Stop(); - return false; - } - */ - if(CheckParams()){ + if (CheckParams()) { LOGI("all param status are COMPLETED"); compileRunner_->Stop(); return false; } - if(!WaitParamsIfNeeded()){ + if (!WaitParamsIfNeeded()) { LOGI("no param is ready, progress bar stop"); compileRunner_->Stop(); return false; @@ -206,7 +194,7 @@ bool BootCompileProgress::CheckBundleScanParam() if (!needBundleScan_) { return true; } - if (system::GetParameter(BUNDLE_SCAN_PARAM_NAME, "-1") == "1"){ + if (system::GetParameter(BUNDLE_SCAN_PARAM_NAME, "-1") == "1") { paramNeeded_.erase(BUNDLE_SCAN_PARAM_NAME); return true; } From 8ee237948374c085623e59bc5d470de7d13ee12e Mon Sep 17 00:00:00 2001 From: weimingjin Date: Tue, 19 Nov 2024 20:02:52 +0800 Subject: [PATCH 4/6] add bundle scan progress Signed-off-by: weimingjin --- frameworks/bootanimation/src/boot_compile_progress.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/bootanimation/src/boot_compile_progress.cpp b/frameworks/bootanimation/src/boot_compile_progress.cpp index 1c9996d80f..464f0b90df 100644 --- a/frameworks/bootanimation/src/boot_compile_progress.cpp +++ b/frameworks/bootanimation/src/boot_compile_progress.cpp @@ -60,6 +60,7 @@ namespace { { { 1.0f, 0.5f }, { 0.5f, 0.2f }, { 0.2f, 1.0f } }, }; constexpr const char* BUNDLE_SCAN_PARAM_NAME = "bms.scanning_apps.status"; + constexpr const int BUNDLE_SCAN_WAITING_TIMEOUT = 3; } void BootCompileProgress::Init(const BootAnimationConfig& config, bool needOtaCompile, bool needBundleScan) @@ -225,7 +226,7 @@ bool BootCompileProgress::WaitBundleScanIfNeeded() if (!needBundleScan_) { return true; } - if (WaitParameter(BUNDLE_SCAN_PARAM_NAME, "0", 3) != 0) { + if (WaitParameter(BUNDLE_SCAN_PARAM_NAME, "0", BUNDLE_SCAN_WAITING_TIMEOUT) != 0) { paramNeeded_.erase(BUNDLE_SCAN_PARAM_NAME); LOGE("waiting bundle scan failed."); return false; From b8bfcd843ba14547a3ed2d9c8263b900a96553ef Mon Sep 17 00:00:00 2001 From: weimingjin Date: Tue, 19 Nov 2024 20:05:35 +0800 Subject: [PATCH 5/6] add bundle scan progress Signed-off-by: weimingjin --- frameworks/bootanimation/src/boot_compile_progress.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/bootanimation/src/boot_compile_progress.cpp b/frameworks/bootanimation/src/boot_compile_progress.cpp index 464f0b90df..40ddc9b625 100644 --- a/frameworks/bootanimation/src/boot_compile_progress.cpp +++ b/frameworks/bootanimation/src/boot_compile_progress.cpp @@ -319,7 +319,6 @@ void BootCompileProgress::UpdateCompileProgress() { (void)CheckParams(); if (paramNeeded_.size() > 0) { - //isBmsCompileDone_ = system::GetParameter(BMS_COMPILE_STATUS, "-1") == BMS_COMPILE_STATUS_END; int64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()) .count(); From 10110ed1b91c4cac7d79059fa6c1eb5084166ff9 Mon Sep 17 00:00:00 2001 From: weimingjin Date: Wed, 20 Nov 2024 09:56:28 +0800 Subject: [PATCH 6/6] add bundle scan progress Signed-off-by: weimingjin --- frameworks/bootanimation/src/boot_compile_progress.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frameworks/bootanimation/src/boot_compile_progress.cpp b/frameworks/bootanimation/src/boot_compile_progress.cpp index 40ddc9b625..8a21b3168b 100644 --- a/frameworks/bootanimation/src/boot_compile_progress.cpp +++ b/frameworks/bootanimation/src/boot_compile_progress.cpp @@ -190,6 +190,7 @@ bool BootCompileProgress::CheckParams() } return false; } + bool BootCompileProgress::CheckBundleScanParam() { if (!needBundleScan_) { @@ -201,6 +202,7 @@ bool BootCompileProgress::CheckBundleScanParam() } return false; } + bool BootCompileProgress::CheckBmsStartParam() { if (!needOtaCompile_) { @@ -212,6 +214,7 @@ bool BootCompileProgress::CheckBmsStartParam() } return false; } + bool BootCompileProgress::WaitParamsIfNeeded() { bool wait1 = WaitBmsStartIfNeeded(); @@ -221,6 +224,7 @@ bool BootCompileProgress::WaitParamsIfNeeded() } return true; } + bool BootCompileProgress::WaitBundleScanIfNeeded() { if (!needBundleScan_) { @@ -233,6 +237,7 @@ bool BootCompileProgress::WaitBundleScanIfNeeded() } return true; } + bool BootCompileProgress::WaitBmsStartIfNeeded() { if (!needOtaCompile_) {