--- /dev/null
+#ifndef THUNDERBIRD_SHUTDOWN_VIEW_H
+#define THUNDERBIRD_SHUTDOWN_VIEW_H
+
+#include "components/ui_view_group.h"
+#include "components/ui_image_animator.h"
+
+namespace OHOS
+{
+ static constexpr int16_t TB_SHUTDOWN_ANIM_X = 0;
+ static constexpr int16_t TB_SHUTDOWN_ANIM_Y = 0;
+ static constexpr int16_t TB_SHUTDOWN_ANIM_W = 466;
+ static constexpr int16_t TB_SHUTDOWN_ANIM_H = 466;
+ static constexpr int16_t TB_SHUTDOWN_ANIM_FRAMES = 95;
+ static constexpr int16_t TB_SHUTDOWN_ANIM_INTERVAL = 150;
+ static constexpr const char *TB_SHUTDOWN_ANIM_PATH = "/user/res/RebootAndShutDown/ShutDown/";
+
+ class ThunderBirdShutdownView : public UIImageAnimatorView::AnimatorStopListener
+ {
+ public:
+ ThunderBirdShutdownView();
+ virtual ~ThunderBirdShutdownView();
+
+ static ThunderBirdShutdownView *GetInstance();
+
+ UIViewGroup *ThunderBirdShutdownViewInit();
+ UIImageAnimatorView *GetAnimator();
+
+ void StartShutdownAnimation();
+
+ private:
+ void OnAnimatorStop(UIView &view) override;
+ void ClearAll();
+ bool EnsureAnimator();
+
+ private:
+ UIViewGroup *group{nullptr};
+ UIImageAnimatorView *shutdownAnimator{nullptr};
+ ImageAnimatorInfo shutdownImageInfo[TB_SHUTDOWN_ANIM_FRAMES];
+ const char **shutdownPathsArray{nullptr};
+ };
+}
+
+#endif
+
+
--- /dev/null
+#include "thunderbird/include/ThunderBirdShutdownView.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include "custom_runtime.h"
+#include "custom_utils.h"
+#include "uiservice/include/ui_service.h"
+#include "vibrator_service.h"
+#include "thunderbird/include/ThunderBirdMainView.h"
+
+namespace OHOS
+{
+ static ThunderBirdShutdownView *g_tbShutdownView{nullptr};
+
+ ThunderBirdShutdownView::ThunderBirdShutdownView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::ThunderBirdShutdownView");
+ g_tbShutdownView = this;
+ }
+
+ ThunderBirdShutdownView::~ThunderBirdShutdownView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::~ThunderBirdShutdownView");
+ ClearAll();
+ g_tbShutdownView = nullptr;
+ }
+
+ ThunderBirdShutdownView *ThunderBirdShutdownView::GetInstance()
+ {
+ return g_tbShutdownView;
+ }
+
+ void ThunderBirdShutdownView::ClearAll()
+ {
+ if (group != nullptr)
+ {
+ group->RemoveAll();
+ if (shutdownAnimator != nullptr)
+ {
+ delete shutdownAnimator;
+ shutdownAnimator = nullptr;
+ }
+ FreeImagePathsArray(shutdownPathsArray, TB_SHUTDOWN_ANIM_FRAMES);
+ delete group;
+ group = nullptr;
+ }
+ }
+
+ void ThunderBirdShutdownView::OnAnimatorStop(UIView &view)
+ {
+ UNUSED(view);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::OnAnimatorStop");
+ // 关机前释放 thunderbird 视频与相关资源
+ if (ThunderBirdMainView::GetInstance())
+ {
+ ThunderBirdMainView::GetInstance()->CloseVideo();
+ }
+ shutdown_reboot_prejobs(SHUTDOWN_TYPE);
+ }
+
+ bool ThunderBirdShutdownView::EnsureAnimator()
+ {
+ if (shutdownAnimator == nullptr)
+ {
+ shutdownPathsArray = CreateImagePathsArray(TB_SHUTDOWN_ANIM_PATH, TB_SHUTDOWN_ANIM_FRAMES);
+ shutdownAnimator = new UIImageAnimatorView();
+ if (shutdownAnimator == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView new UIImageAnimatorView fail");
+ return false;
+ }
+ shutdownAnimator->SetAutoEnable(false);
+ for (uint8_t i = 0; i < TB_SHUTDOWN_ANIM_FRAMES; i++)
+ {
+ shutdownImageInfo[i].imagePath = (shutdownPathsArray[i]);
+ shutdownImageInfo[i].imageType = IMG_SRC_FILE_PATH;
+ shutdownImageInfo[i].pos.x = TB_SHUTDOWN_ANIM_X;
+ shutdownImageInfo[i].pos.y = TB_SHUTDOWN_ANIM_Y;
+ shutdownImageInfo[i].width = TB_SHUTDOWN_ANIM_W;
+ shutdownImageInfo[i].height = TB_SHUTDOWN_ANIM_H;
+ }
+ shutdownAnimator->SetPosition(TB_SHUTDOWN_ANIM_X, TB_SHUTDOWN_ANIM_Y, TB_SHUTDOWN_ANIM_W, TB_SHUTDOWN_ANIM_H);
+ shutdownAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ shutdownAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ shutdownAnimator->SetImageAnimatorSrc(shutdownImageInfo, TB_SHUTDOWN_ANIM_FRAMES, TB_SHUTDOWN_ANIM_INTERVAL);
+ shutdownAnimator->SetRepeat(false);
+ shutdownAnimator->SetRepeatTimes(1);
+ shutdownAnimator->SetResizeMode(UIImageView::COVER);
+ shutdownAnimator->SetAnimatorStopListener(this);
+ }
+ return true;
+ }
+
+ UIViewGroup *ThunderBirdShutdownView::ThunderBirdShutdownViewInit()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::ThunderBirdShutdownViewInit");
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView group new fail");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ if (!EnsureAnimator())
+ {
+ return nullptr;
+ }
+ group->Add(shutdownAnimator);
+ return group;
+ }
+
+ UIImageAnimatorView *ThunderBirdShutdownView::GetAnimator()
+ {
+ return shutdownAnimator;
+ }
+
+ void ThunderBirdShutdownView::StartShutdownAnimation()
+ {
+ if (!EnsureAnimator())
+ {
+ return;
+ }
+ shutdownAnimator->Start();
+ uapi_dev_runtime_set_shutting_down_status(1);
+ ScreenOffEnable(false);
+ uapi_set_screen_on_api();
+ custom_VibratorFunc_int(0);
+ }
+}
+
+