From: luozheng <1732036298@qq.com> Date: Tue, 30 Jul 2024 02:31:08 +0000 (+0800) Subject: 解决刚刚进入关机动画按power键会取消关机或重启操作 X-Git-Tag: release_V1.2.70_20241020_135402~725^2~10 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=9b3a0fe92009c0268c7326685702a98db1e99265;p=mirrors%2FFD230.git 解决刚刚进入关机动画按power键会取消关机或重启操作 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h index b62307505..9b3df5468 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-18 14:26:31 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-20 11:15:27 + * @LastEditTime: 2024-07-30 10:25:25 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h */ @@ -35,6 +35,9 @@ namespace OHOS void OnPause() override; void OnStop() override; + private: + void handleSlider(UISlider *slider, bool isShutdown); + private: bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; @@ -47,6 +50,7 @@ namespace OHOS RebootAndShutdownModel *model; bool X_DRAG_FLAG{false}; bool isShutDownOperation{false}; + bool isShutDownImageAnimatorStart{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp index 02cbd14f9..8bbf6e0a6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:11:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-27 13:03:52 + * @LastEditTime: 2024-07-30 10:23:45 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/RebootAndShutdownPresenter.cpp */ #include "AppViewIDs.h" @@ -88,7 +88,7 @@ namespace OHOS { RebootAndShutdownView::GetInstance()->ChangeView(FACTORYRESET, REBOOTANDSHUTDOWN); } - else if (strcmp(view.GetViewId(), SHUTDOWN_SLIDER_VIEWID) == 0) + else if (strcmp(view.GetViewId(), SHUTDOWN_SLIDER_VIEWID) == 0) { auto shutdownSlider = view_->GetShutdownSlider(); if (shutdownSlider != nullptr) @@ -96,7 +96,7 @@ namespace OHOS shutdownSlider->SetValue(SLIDER_VALUE_MIN); } } - else if (strcmp(view.GetViewId(), REBOOT_SLIDER_VIEWID) == 0) + else if (strcmp(view.GetViewId(), REBOOT_SLIDER_VIEWID) == 0) { auto rebootSlider = view_->GetRebootSlider(); if (rebootSlider != nullptr) @@ -173,40 +173,35 @@ namespace OHOS auto shutdownSlider = view_->GetShutdownSlider(); auto rebootSlider = view_->GetRebootSlider(); - if (shutdownSlider->GetValue() < SLIDER_VALUE_MAX) - { - shutdownSlider->SetValue(SLIDER_VALUE_MIN); - } - else - { - shutdownSlider->SetValue(SLIDER_VALUE_MAX); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "关机!!"); - - RebootAndShutdownView::GetInstance()->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR); - - start_shutdown_or_reboot(); - shutdown_reboot_prejobs(); - - ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start(); + handleSlider(shutdownSlider, true); + handleSlider(rebootSlider, false); + } - isShutDownOperation = true; + void RebootAndShutdownPresenter::handleSlider(UISlider *slider, bool isShutdown) + { + if (!slider) + { + return; } - if (rebootSlider->GetValue() < SLIDER_VALUE_MAX) + if (slider->GetValue() < SLIDER_VALUE_MAX) { - rebootSlider->SetValue(SLIDER_VALUE_MIN); + slider->SetValue(SLIDER_VALUE_MIN); } else { - rebootSlider->SetValue(SLIDER_VALUE_MAX); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "重启!!"); - RebootAndShutdownView::GetInstance()->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR); + slider->SetValue(SLIDER_VALUE_MAX); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s!!", isShutdown ? "关机" : "重启"); + view_->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR); start_shutdown_or_reboot(); shutdown_reboot_prejobs(); - ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start(); - - isShutDownOperation = false; + if (ShutDownImageAnimatorView::GetInstance() != nullptr && ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView() != nullptr) + { + ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start(); + isShutDownImageAnimatorStart = true; + } + isShutDownOperation = isShutdown; } } @@ -219,7 +214,10 @@ namespace OHOS // 如果是power键,且是亮屏状态,按键释放就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + if (!isShutDownImageAnimatorStart) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } } return true; }