#include "gfx_utils/vector.h"
#include "graphic_mutex.h"
+#include "utils/utils_list.h"
+#include <vector>
+#include "TransitionType.h"
+#include "soc_osal.h"
+#include "stack"
+#include "AppViewIDs.h"
namespace OHOS {
-const static uint16_t gSliceInvalid = 0;
+const static uint16_t gSliceInvalid = 0;
const static uint16_t gSliceDefaultPriority = 4; // 页面默认是最低优先级
+const static uint16_t gMaxHistorySlices = 10; // 默认最多保存三个历史记录
+
class Ability {
public:
void AddSliceProxy(const uint16_t sliceId, SliceProxy* proxy);
void StopPrevSlice();
void StopSliceTransition();
void BackToPreSlice();
+
+ /* -------------------------------------------------------------------------- */
+ /// @brief 当从一个切片(Slice)进入另一个切片时被调用。
+ /// @param sliceId sliceId
+ /// @param transitionId 切换的动画类型
+ /// @param priority 切换优先级
+ void EnterSlice(uint16_t sliceId,const TransitionType transitionId = TransitionType::TRANSITION_INVALID,
+ const uint16_t priority = gSliceDefaultPriority) {
+ // 获取当前SliceID
+ uint16_t curSliceId = GetCurSliceId();
+ if (curSliceId != defaultSliceId_) { // 假定defaultSliceId_是“主页”或启动Slice的ID
+ backStack_.push(curSliceId);
+ }
+ ChangeSlice(sliceId,transitionId,priority); // 切换到新的Slice
+ }
+
+ uint16_t GettopSliceId(void) {
+ if (!backStack_.empty() ) {
+ return backStack_.top();
+ }
+ return 0;
+ }
+
+
+ // 处理后退操作
+
+ /// @brief 处理后退操作。
+ /// @param transitionId 切换的动画类型
+ /// @param priority 切换优先级
+ bool Back(const TransitionType transitionId = TransitionType::TRANSITION_INVALID,
+ const uint16_t priority = gSliceDefaultPriority) {
+
+ if (!backStack_.empty()) {
+ uint16_t preSlice = backStack_.top();
+ backStack_.pop();
+ ChangeSlice(preSlice,transitionId,priority);
+ return true;
+ }
+ else
+ {
+ backStack_.push(defaultSliceId_); // 将默认主界面的 ID 推入栈中
+ // 退回到defaultSliceId_
+ ChangeSlice(defaultSliceId_, transitionId, priority);
+ return false; // 返回false表示无前一个slice,退回到默认slice
+ }
+ }
+
+ /// @brief 处理后退多级切片的操作。
+ /// @param count 指定的后退级数
+ /// @param transitionId 切换的动画类型
+ /// @param priority 切换优先级
+ bool BackCountSlice(int count,const TransitionType transitionId = TransitionType::TRANSITION_INVALID,
+ const uint16_t priority = gSliceDefaultPriority) {
+ //如果指定的后退级数 count 为 0 ,直接返回 false 。
+ // if(count == 0) {
+ // return false;
+ // }
+ while(!backStack_.empty() && count != 0) //当 count 不为 0 且 backStack_ 栈不为空时,弹出栈顶元素 count 次。
+ {
+ backStack_.pop();
+ count--;
+ }
+ if(!backStack_.empty())
+ {
+ // 如果此时 backStack_ 栈不为空,取出栈顶的切片 ID ,并调用 ChangeSlice 切换到该切片,返回 true 。
+ uint16_t preSlice = backStack_.top();
+ ChangeSlice(preSlice,transitionId,priority);
+ backStack_.pop();
+ return true;
+ }
+ else
+ {
+ //如果 backStack_ 栈为空,切换到默认切片,返回 false 。
+ ChangeSlice(defaultSliceId_, transitionId, priority);
+ return false; // 返回false表示无前一个slice,退回到默认slice
+ }
+ }
+ //仅用于打电话结束恢复时使用
+ bool Back_CountSlice_make_phone(const TransitionType transitionId = TransitionType::TRANSITION_INVALID,
+ const uint16_t priority = gSliceDefaultPriority);
+
+
+ bool make_phone_push(uint16_t preSlice) {
+ if(backStack_.empty())
+ {
+ backStack_.push(preSlice);
+ }
+ else
+ {
+ uint8_t top_id= backStack_.top();
+ if(top_id!=preSlice)
+ backStack_.push(preSlice);
+ }
+
+ return false;
+ }
+
+ /*清空后退栈*/
+ void ClearSliceIdStack(void)
+ {
+ while(!backStack_.empty())
+ {
+ backStack_.pop();
+ }
+ if (backStack_.empty()) {
+ backStack_.push(defaultSliceId_); // 将默认主界面的 ID 推入栈中
+ }
+ }
+
+ /*打印栈中元素*/
+ void showsStackSliceId()
+ {
+ printf("\n%d\n",backStack_.size());
+ std::stack<uint16_t> tempStack = backStack_;
+ printf("\n[");
+ while(!tempStack.empty())
+ {
+ printf("%d,",tempStack.top());
+ tempStack.pop();
+ }
+ printf("]\n");
+ printf("\n%d\n",backStack_.size());
+ }
+ /* -------------------------------------------------------------------------- */
protected:
Ability() = default;
void PostChangeSlice(const uint16_t targetSliceId, TransitionType type,
const uint16_t priority, bool enableSlideBack);
Ability::ProxyStruct* Find(const uint16_t sliceId);
+private:
+ std::stack<uint16_t> backStack_;//这个栈会在每次进入一个新的Slice时将其ID压入栈顶,当用户请求后退时,栈顶的Slice ID会被弹出,以此来访问前一个Slice。
};
}
#endif // NATIVEABILITYFWK_ABILITY_H
-/*\r
- * Copyright (c) CompanyNameMagicTag.\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef NATIVEABILITYFWK_UTILS_LIST_H\r
-#define NATIVEABILITYFWK_UTILS_LIST_H\r
-\r
-#include <cstdint>\r
-\r
-namespace OHOS {\r
-template<typename T>\r
-class ListsNode {\r
-public:\r
- ListsNode() = default;\r
- ListsNode(T value) : value_(value), next_(nullptr), prev_(nullptr) {}\r
-\r
- T value_;\r
- ListsNode<T> *next_;\r
- ListsNode<T> *prev_;\r
-};\r
-\r
-template<typename T>\r
-class Lists {\r
-public:\r
- Lists() : count_(0)\r
- {\r
- head_ = new ListsNode<T>();\r
- head_->next_ = head_;\r
- head_->prev_ = head_;\r
- }\r
-\r
- ~Lists()\r
- {\r
- RemoveAll();\r
- delete head_;\r
- head_ = nullptr;\r
- }\r
-\r
- const T Front() const\r
- {\r
- if (count_ == 0) {\r
- return head_->value_;\r
- }\r
-\r
- return head_->next_->value_;\r
- }\r
-\r
- void PushFront(T value)\r
- {\r
- auto node = new ListsNode<T>(value);\r
- if (node == nullptr) {\r
- return;\r
- }\r
-\r
- node->prev_ = head_;\r
- node->next_ = head_->next_;\r
- head_->next_->prev_ = node;\r
- head_->next_ = node;\r
- count_++;\r
- }\r
-\r
- void PopFront()\r
- {\r
- if (count_ == 0) {\r
- return;\r
- }\r
-\r
- ListsNode<T> *node = head_->next_;\r
- node->next_->prev_ = head_;\r
- head_->next_ = node->next_;\r
- delete node;\r
- count_--;\r
- }\r
-\r
- const T Back() const\r
- {\r
- if (count_ == 0) {\r
- return head_->value_;\r
- }\r
-\r
- return head_->prev_->value_;\r
- }\r
-\r
- void PushBack(T value)\r
- {\r
- auto node = new ListsNode<T>(value);\r
-\r
- node->next_ = head_;\r
- node->prev_ = head_->prev_;\r
- head_->prev_->next_ = node;\r
- head_->prev_ = node;\r
- count_++;\r
- }\r
-\r
- void PopBack()\r
- {\r
- if (count_ == 0) {\r
- return;\r
- }\r
-\r
- ListsNode<T> *node = head_->prev_;\r
- node->prev_->next_ = head_;\r
- head_->prev_ = node->prev_;\r
- delete node;\r
- count_--;\r
- }\r
-\r
- void Remove(ListsNode<T> *node)\r
- {\r
- if ((count_ == 0) || (node == nullptr)) {\r
- return;\r
- }\r
-\r
- node->prev_->next_ = node->next_;\r
- node->next_->prev_ = node->prev_;\r
-\r
- delete node;\r
- count_--;\r
- }\r
-\r
- void RemoveAll()\r
- {\r
- ListsNode<T> *node = head_->next_;\r
- while (node != head_) {\r
- ListsNode<T> *temp = node;\r
- node = node->next_;\r
- delete temp;\r
- }\r
- head_->next_ = head_;\r
- head_->prev_ = head_;\r
- count_ = 0;\r
- }\r
-\r
- ListsNode<T> *Begin() const\r
- {\r
- return head_->next_;\r
- }\r
-\r
- const ListsNode<T> *End() const\r
- {\r
- return head_;\r
- }\r
-\r
- uint16_t Size() const\r
- {\r
- return count_;\r
- }\r
-\r
- bool IsEmpty() const\r
- {\r
- return count_ == 0;\r
- }\r
-\r
-private:\r
- ListsNode<T> *head_;\r
- uint16_t count_;\r
-};\r
-} // namespace OHOS\r
-#endif // NATIVEABILITYFWK_UTILS_LIST_H\r
+/*
+ * Copyright (c) CompanyNameMagicTag.
+ * 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 NATIVEABILITYFWK_UTILS_LIST_H
+#define NATIVEABILITYFWK_UTILS_LIST_H
+
+#include <cstdint>
+
+namespace OHOS {
+template<typename T>
+class ListsNode {
+public:
+ ListsNode() = default;
+ ListsNode(T value) : value_(value), next_(nullptr), prev_(nullptr) {}
+
+ T value_;
+ ListsNode<T> *next_;
+ ListsNode<T> *prev_;
+};
+
+template<typename T>
+class Lists {
+public:
+ Lists() : count_(0)
+ {
+ head_ = new ListsNode<T>();
+ head_->next_ = head_;
+ head_->prev_ = head_;
+ }
+
+ ~Lists()
+ {
+ RemoveAll();
+ delete head_;
+ head_ = nullptr;
+ }
+
+ const T Front() const
+ {
+ if (count_ == 0) {
+ return head_->value_;
+ }
+
+ return head_->next_->value_;
+ }
+
+ void PushFront(T value)
+ {
+ auto node = new ListsNode<T>(value);
+ if (node == nullptr) {
+ return;
+ }
+
+ node->prev_ = head_;
+ node->next_ = head_->next_;
+ head_->next_->prev_ = node;
+ head_->next_ = node;
+ count_++;
+ }
+
+ void PopFront()
+ {
+ if (count_ == 0) {
+ return;
+ }
+
+ ListsNode<T> *node = head_->next_;
+ node->next_->prev_ = head_;
+ head_->next_ = node->next_;
+ delete node;
+ count_--;
+ }
+
+ const T Back() const
+ {
+ if (count_ == 0) {
+ return head_->value_;
+ }
+
+ return head_->prev_->value_;
+ }
+
+ void PushBack(T value)
+ {
+ auto node = new ListsNode<T>(value);
+
+ node->next_ = head_;
+ node->prev_ = head_->prev_;
+ head_->prev_->next_ = node;
+ head_->prev_ = node;
+ count_++;
+ }
+
+ void PopBack()
+ {
+ if (count_ == 0) {
+ return;
+ }
+
+ ListsNode<T> *node = head_->prev_;
+ node->prev_->next_ = head_;
+ head_->prev_ = node->prev_;
+ delete node;
+ count_--;
+ }
+
+ void Remove(ListsNode<T> *node)
+ {
+ if ((count_ == 0) || (node == nullptr)) {
+ return;
+ }
+
+ node->prev_->next_ = node->next_;
+ node->next_->prev_ = node->prev_;
+
+ delete node;
+ count_--;
+ }
+
+ void RemoveAll()
+ {
+ ListsNode<T> *node = head_->next_;
+ while (node != head_) {
+ ListsNode<T> *temp = node;
+ node = node->next_;
+ delete temp;
+ }
+ head_->next_ = head_;
+ head_->prev_ = head_;
+ count_ = 0;
+ }
+
+ ListsNode<T> *Begin() const
+ {
+ return head_->next_;
+ }
+
+ const ListsNode<T> *End() const
+ {
+ return head_;
+ }
+
+ uint16_t Size() const
+ {
+ return count_;
+ }
+
+ bool IsEmpty() const
+ {
+ return count_ == 0;
+ }
+
+private:
+ ListsNode<T> *head_;
+ uint16_t count_;
+};
+} // namespace OHOS
+#endif // NATIVEABILITYFWK_UTILS_LIST_H
}
FreeElement(elementName);
#endif
+ if (targetSliceId == VIEW_MAIN)
+ {
+ ClearSliceIdStack(); /*凡是回到主界面都要清空栈*/
+ }
+
+ if (targetSliceId == VIEW_INCOMING_CALL)
+ {
+ uint16_t id=GetCurSliceId();
+ if(id==VIEW_REBOOTANDSHUTDOWN && VIEW_INCOMING_CALL==GettopSliceId() )
+ {
+ ClearSliceIdStack();
+ }
+
+ if(id!=VIEW_INCOMING_CALL && id!=VIEW_BLUETOOTH_EARPHONE)
+ make_phone_push(id);
+ }
TransitionTarget target;
target.sliceInfo = targetSliceId | (priority << 16);
bool runImmed = PageTransitionMgr::GetInstance().BeginTransition(TransitionCaller::CHANGE_SLICE, target,
#include "notification_manager.h"
#include "PageTransitionMgr.h"
#include "hal_tick.h"
-
+#include "custom_runtime.h"
#ifdef __cplusplus
extern "C"
{
InstallNativeAbility(nullptr, this);
// 初始化Launcher
- NativeLauncher::GetInstance().InitNativeLauncher();
+ if(uapi_dev_runtime_get_safemode_flag())
+ {
+ NativeLauncher::GetInstance().InitNativeLauncher(LaunchMode::SAFE_MODE);
+ }
+ else
+ {
+ NativeLauncher::GetInstance().InitNativeLauncher(LaunchMode::NORMAL_MODE);
+ }
+
HideGraphicLogo();
return;
}
#include "adapter.h"
void StartNative() {
- OHOS::NativeLauncher::GetInstance().InitNativeLauncher();
+ OHOS::NativeLauncher::GetInstance().InitNativeLauncher(OHOS::LaunchMode::NORMAL_MODE);
HideGraphicLogo();
+ HideGraphicOtaLogo();
Want *info = static_cast<Want *>(AdapterMalloc(sizeof(Want)));
memset_s(info, sizeof(Want), 0, sizeof(Want));
OHOS::NativeAbility::GetInstance().OnActive(*info);
#include "AppViewIDs.h"
namespace OHOS {
+enum class LaunchMode
+{
+ NORMAL_MODE, // 普通模式
+ SAFE_MODE // 安全模式
+};
class NativeLauncher {
public:
static NativeLauncher &GetInstance(void);
- void InitNativeLauncher(void);
+ void InitNativeLauncher(LaunchMode mode);
private:
void InitAllNativeSlices(void);
return instance;
}
-void NativeLauncher::InitNativeLauncher()
+void NativeLauncher::InitNativeLauncher(LaunchMode mode)
{
#ifdef JS_ENABLE
ACELite::ProductAdapter::SetScreenSize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
*/
void GpuResetEnd(void);
+
+/* -------------------------------------------------------------------------- */
+void ShowGraphicOTALogo(void);
+void HideGraphicOtaLogo(void);
+/* -------------------------------------------------------------------------- */
+
#ifdef __cplusplus
};
#endif
#include "common/screen.h"
#include "components/root_view.h"
#include "components/ui_image_view.h"
+#include "thread_init.h"
+#include "custom_utils.h"
+#include "components/ui_image_animator.h"
+#include "wearable_log.h"
+#include "uicomponents/UIComponents.h"
#ifdef __cplusplus
extern "C" {
static OHOS::UIImageView* g_logo = nullptr;
static OHOS::ImageInfo* g_imgInfo = nullptr;
+static bool g_showOtaLogo = false;
+static OHOS::UIImageView* g_ota_logo = nullptr;
+static OHOS::ImageInfo* g_ota_imgInfo = nullptr;
+static uint32_t *g_boot_animation_task_handle = NULL;
+static OHOS::UIViewGroup* group=nullptr;
+static OHOS::UIViewGroup* boot_group=nullptr;
+static OHOS::UIImageAnimatorView* ReBootImageAnimatorView=nullptr;
+#ifdef CUSTOM_Z1
+static const char *ReBootPaths = "/user/res/RebootAndShutDown/ReBoot/"; //开机图片路径
+static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 30; // 图片帧数
+#else
+static const char *ReBootPaths = "/user/res/RebootAndShutDown/ReBoot/"; //开机图片路径
+static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 36; // 图片帧数
+#endif
+static constexpr int16_t REBOOT_IMAGE_ANIMATOR_TIME = 150; // 图片更新间隔
+static OHOS::ImageAnimatorInfo ReBootImageInfo[REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 开机图像的信息
+static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_X = 0;
+static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_Y = 0;
+static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_W = 466;
+static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_H = 466;
+const OHOS::ImageInfo **ReBootPathsArray{nullptr}; // 开机图片路径数组
+static OHOS::UIImageAnimatorView::AnimatorStopListener *bootStoplistener{nullptr};
+static bool boot_animation_flag = false;
+static app_task_definition_t taskcfg={0};
+
#ifdef QSPI_DISPLAY
#define IMAGE_OPEN_LOGO_PATH "/user/res/OPEN_LOGO_QSPI.bin"
#else
#endif
#endif
+#ifdef CUSTOM_Z1
+#ifdef IMAGE_OPEN_LOGO_PATH
+#undef IMAGE_OPEN_LOGO_PATH
+#endif
+#ifdef SINGLE_USER_PARTITION
+#define IMAGE_OPEN_LOGO_PATH "/user/system/z1bootlogo.bin"
+#else
+#define IMAGE_OPEN_LOGO_PATH "/system/z1bootlogo.bin"
+#endif
+#endif
+
+
+static void FreeImagePathsArray(const char **imagePaths, const int numImages)
+{
+ for (int i = 0; i < numImages; i++)
+ {
+ delete imagePaths[i];
+ imagePaths[i] = nullptr;
+ }
+}
+
+static void ClearAll(void)
+{
+ if(group!=nullptr)
+ {
+ OHOS::RootView::GetInstance()->Remove(group);
+ group->RemoveAll();
+
+ if (ReBootImageAnimatorView != nullptr)
+ {
+ delete ReBootImageAnimatorView;
+ ReBootImageAnimatorView = nullptr;
+ }
+
+ if(bootStoplistener!=nullptr)
+ {
+ delete bootStoplistener;
+ bootStoplistener = nullptr;
+ }
+
+ // FreeImagePathsArray(ReBootPathsArray, REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+ OHOS::FreeImageInfoArray(ReBootPathsArray, ReBootPaths, REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+
+ delete group;
+ group = nullptr;
+ }
+}
+
+class BootAnimatorListener:public OHOS::UIImageAnimatorView::AnimatorStopListener
+{
+public:
+BootAnimatorListener(){}
+~BootAnimatorListener(){}
+
+private:
+ void OnAnimatorStop(OHOS::UIView &view)
+ {
+ boot_animation_flag = true;
+
+ ClearAll();
+
+ //boot_group->SetVisible(false);
+ OHOS::RootView::GetInstance()->Remove(boot_group);
+ delete boot_group;
+ boot_group = nullptr;
+ }
+
+};
+
+
+static const char ** CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)
+{
+ const char **imagePaths = new const char *[numImages];
+ char buffer[256];
+ for (int i = 0; i < numImages; i++)
+ {
+#ifdef CUSTOM_Z1
+ snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, numImages - i , fileExtension);
+#else
+ snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1 , fileExtension);
+#endif
+
+ imagePaths[i] = strdup(buffer);
+ }
+ return imagePaths;
+}
+
+bool ShowReBootAnimatorView()
+{
+ ReBootPathsArray = OHOS::CreateImageInfoArray(ReBootPaths, REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+
+ if (ReBootImageAnimatorView == nullptr)
+ {
+ ReBootImageAnimatorView = new OHOS::UIImageAnimatorView();
+ if (ReBootImageAnimatorView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new ReBootImageAnimatorView fail");
+ return false;
+ }
+ for (uint8_t i = 0; i < REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)
+ {
+ ReBootImageInfo[i].imageInfo = (ReBootPathsArray[i]);
+ ReBootImageInfo[i].imageType = OHOS::IMG_SRC_IMAGE_INFO;
+ ReBootImageInfo[i].pos.x = REBOOT_IMAGE_ANIMATOR_VIEW_X;
+ ReBootImageInfo[i].pos.y = REBOOT_IMAGE_ANIMATOR_VIEW_Y;
+ ReBootImageInfo[i].width = REBOOT_IMAGE_ANIMATOR_VIEW_W;
+ ReBootImageInfo[i].height = REBOOT_IMAGE_ANIMATOR_VIEW_H;
+ }
+ ReBootImageAnimatorView->SetPosition(REBOOT_IMAGE_ANIMATOR_VIEW_X, REBOOT_IMAGE_ANIMATOR_VIEW_Y, REBOOT_IMAGE_ANIMATOR_VIEW_W, REBOOT_IMAGE_ANIMATOR_VIEW_H);
+ ReBootImageAnimatorView->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xffffffff);
+ ReBootImageAnimatorView->SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
+ ReBootImageAnimatorView->SetImageAnimatorSrc(ReBootImageInfo, REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, 100);
+ ReBootImageAnimatorView->SetRepeat(false);
+ ReBootImageAnimatorView->SetRepeatTimes(1);
+
+ bootStoplistener = static_cast<OHOS::UIImageAnimatorView::AnimatorStopListener *>(new BootAnimatorListener());
+ if (bootStoplistener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create bootStoplistener!!");
+ return false;
+ }
+ ReBootImageAnimatorView->SetAnimatorStopListener(bootStoplistener);
+ }
+
+
+ return true;
+}
+
+OHOS::UIViewGroup* ReBootAnimatorViewInit(void)
+{
+ bool ret;
+ group = new OHOS::UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP," group new fail");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
+ group->SetStyle(OHOS::STYLE_BACKGROUND_OPA, OHOS::OPA_OPAQUE);
+ ret = ShowReBootAnimatorView();
+
+ if (ret == false)
+ {
+ return nullptr;
+ }
+
+ group->Add(ReBootImageAnimatorView);
+ return group;
+}
+
static void UikitRTCCallBack(uintptr_t data)
{
(void)(data);
g_initialized = true;
}
-void ShowGraphicLogo()
+void HideGraphicLogo()
+{
+ if (!g_showLogo) {
+ return;
+ }
+
+ g_showLogo = false;
+ GraphicService::GetInstance()->PostGraphicEvent(
+ [] {
+ if (g_logo != nullptr) {
+ OHOS::RootView::GetInstance()->Remove(g_logo);
+ delete g_logo;
+ g_logo = nullptr;
+ OHOS::ImageCacheManager::GetInstance().UnloadSingleRes(IMAGE_OPEN_LOGO_PATH);
+ g_imgInfo = nullptr;
+ }
+ });
+}
+
+void HideGraphicOtaLogo()
+{
+ if (!g_showOtaLogo) {
+ return;
+ }
+ g_showOtaLogo = false;
+ GraphicService::GetInstance()->PostGraphicEvent(
+ [] {
+ if (g_ota_logo != nullptr) {
+ OHOS::RootView::GetInstance()->Remove(g_ota_logo);
+ delete g_ota_logo;
+ g_ota_logo = nullptr;
+ OHOS::ImageCacheManager::GetInstance().UnloadSingleRes(IMAGE_OTA_LOGO_PATH);
+ g_ota_imgInfo = nullptr;
+ }
+ });
+}
+
+static void boot_animation_task(void *arg)
+{
+ unused(arg);
+
+ boot_group = ReBootAnimatorViewInit();
+ if (boot_group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP," boot_group nullptr fail");
+ return;
+ }
+ HideGraphicLogo();
+ HideGraphicOtaLogo();
+ OHOS::GraphicEventHandler::GetInstance()->PostGraphicEvent(
+ [] {
+ OHOS::RootView::GetInstance()->Add(boot_group);
+ ReBootImageAnimatorView->Start();
+ },
+ false);
+
+}
+
+void wait_animation_stop(void)
+{
+ while(boot_animation_flag == false)
+ {
+ LOS_Msleep(1000);
+ }
+}
+
+void ShowGraphicLogo(void)
{
if (g_showLogo) {
return;
OHOS::RootView::GetInstance()->Add(g_logo);
OHOS::RootView::GetInstance()->Invalidate();
});
+ LOS_Msleep(500);
}
-void HideGraphicLogo()
+void ShowGraphicOTALogo(void)
{
- if (!g_showLogo) {
+
+ if (g_showOtaLogo) {
return;
}
- g_showLogo = false;
+ g_showOtaLogo = true;
+ g_ota_logo = new OHOS::UIImageView();
+ g_ota_logo->SetPosition(0, 0, OHOS::Screen::GetInstance().GetWidth(), OHOS::Screen::GetInstance().GetHeight());
+ g_ota_logo->SetAutoEnable(false);
+ g_ota_logo->SetResizeMode(OHOS::UIImageView::CENTER);
+ g_ota_imgInfo = OHOS::ImageCacheManager::GetInstance().LoadSingleRes(IMAGE_OTA_LOGO_PATH);
+ g_ota_logo->SetSrc(g_ota_imgInfo);
GraphicService::GetInstance()->PostGraphicEvent(
[] {
- if (g_logo != nullptr) {
- OHOS::RootView::GetInstance()->Remove(g_logo);
- delete g_logo;
- g_logo = nullptr;
- OHOS::ImageCacheManager::GetInstance().UnloadSingleRes(IMAGE_OPEN_LOGO_PATH);
- g_imgInfo = nullptr;
- }
+ OHOS::RootView::GetInstance()->Add(g_ota_logo);
+ OHOS::RootView::GetInstance()->Invalidate();
});
+ LOS_Msleep(500);
+
+}
+
+void boot_animation_init_deinit(void)
+{
+ errcode_t ret = uapi_terminate_thread(taskcfg.task_handle);
+
+ if(ret != ERRCODE_SUCC)
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"kill boot_animation_task failed %d!",ret);
+ else
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"kill boot_animation_task succed !");
+
+ if(taskcfg.attr.stack_mem != NULL)
+ {
+ free(taskcfg.attr.stack_mem);
+ taskcfg.attr.stack_mem = NULL;
+ }
+ if(taskcfg.task_handle != NULL)
+ taskcfg.task_handle = NULL;
}
+void boot_animation_init(void)
+{
+ taskcfg.task_handle = g_boot_animation_task_handle;
+ taskcfg.attr.name="boot_animation_service";
+ taskcfg.attr.priority = TASK_PRIORITY_APP;
+ taskcfg.attr.stack_size = 0x1000;
+ taskcfg.func = boot_animation_task;
+ taskcfg.use_mem = USE_EXTEND_MEM;
+
+ errcode_t ret=uapi_create_osThread_custom(&taskcfg);
+ if(ret != ERRCODE_SUCC)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"create boot_animation_task failed %d!",ret);
+ return ;
+ }
+}
void PostGraphicEvent(GraphicEventCb eventCb, void* userData)
{
GraphicService::GetInstance()->PostGraphicEvent(