diff --git a/frameworks/include/base/product_adapter.h b/frameworks/include/base/product_adapter.h index 6d6117e..cf3101a 100644 --- a/frameworks/include/base/product_adapter.h +++ b/frameworks/include/base/product_adapter.h @@ -123,7 +123,7 @@ public: static void NotifyRenderEnd(); static const char *GetDefaultFontFamilyName(); static uint8_t GetDefaultFontSize(); - static void UpdateShowingState(bool forground); + static void UpdateRenderTickAcceptable(bool acceptable); static void GetScreenSize(uint16_t &width, uint16_t &height); static bool SetScreenOnVisible(bool visible); }; diff --git a/frameworks/src/core/base/product_adapter.cpp b/frameworks/src/core/base/product_adapter.cpp index 08a0df7..893a512 100644 --- a/frameworks/src/core/base/product_adapter.cpp +++ b/frameworks/src/core/base/product_adapter.cpp @@ -59,7 +59,7 @@ static uint16_t g_screenWidth = 454; static uint16_t g_screenHeight = 454; // indicating if the ace application is on forground -static bool g_isAceForground = false; +static bool g_isRenderTickAcceptable = false; void ProductAdapter::InitAceTags(uint8_t *aceTags, uint8_t tagCount) { @@ -150,7 +150,7 @@ void ProductAdapter::RegTEHandlers(const TEHandlingHooks &teHandlingHooks) TEDispatchingResult ProductAdapter::DispatchTEMessage() { #ifdef OHOS_ACELITE_PRODUCT_WATCH // only some specific products support TE dispatching - if (!g_isAceForground) { + if (!g_isRenderTickAcceptable) { return TEDispatchingResult::REFUSED; } @@ -206,9 +206,9 @@ uint8_t ProductAdapter::GetDefaultFontSize() return g_defaultFontSize; } -void ProductAdapter::UpdateShowingState(bool forground) +void ProductAdapter::UpdateRenderTickAcceptable(bool acceptable) { - g_isAceForground = forground; + g_isRenderTickAcceptable = acceptable; } void ProductAdapter::SetScreenSize(uint16_t width, uint16_t height) diff --git a/frameworks/src/core/context/js_ability.cpp b/frameworks/src/core/context/js_ability.cpp index 19edf62..776c6fc 100644 --- a/frameworks/src/core/context/js_ability.cpp +++ b/frameworks/src/core/context/js_ability.cpp @@ -80,6 +80,8 @@ void JSAbility::Launch(const char * const abilityPath, const char * const bundle return; } START_TRACING(LAUNCH); + // mark the flag in advance to make sure we can take over render tick as soon as possible + ProductAdapter::UpdateRenderTickAcceptable(true); JSAbilityImpl *jsAbilityImpl = CastAbilityImpl(jsAbilityImpl_); jsAbilityImpl->InitEnvironment(abilityPath, bundleName, token); FatalHandler::GetInstance().RegisterFatalHandler(this); @@ -98,7 +100,7 @@ void JSAbility::Show() JSAbilityImpl *jsAbilityImpl = CastAbilityImpl(jsAbilityImpl_); jsAbilityImpl->Show(); AsyncTaskManager::GetInstance().SetFront(true); - ProductAdapter::UpdateShowingState(true); + ProductAdapter::UpdateRenderTickAcceptable(true); isActived_ = true; } @@ -112,7 +114,7 @@ void JSAbility::Hide() JSAbilityImpl *jsAbilityImpl = CastAbilityImpl(jsAbilityImpl_); jsAbilityImpl->Hide(); AsyncTaskManager::GetInstance().SetFront(false); - ProductAdapter::UpdateShowingState(false); + ProductAdapter::UpdateRenderTickAcceptable(false); isActived_ = false; } @@ -127,7 +129,7 @@ void JSAbility::TransferToDestroy() jsAbilityImpl->CleanUp(); // Reset render flag or low layer task mutex in case we are during the rendering process, // this situation might happen if the destroy function is called outside of JS thread, such as AMS. - ProductAdapter::UpdateShowingState(false); + ProductAdapter::UpdateRenderTickAcceptable(false); FatalHandler::GetInstance().ResetRendering(); FatalHandler::GetInstance().SetExitingFlag(false); #ifdef FEATURE_SCREEN_ON_VISIBLE