mirror of
https://github.com/openharmony/ace_engine_lite.git
synced 2026-07-18 18:34:29 -04:00
Description: improve async work dispatching protecting
IssueNo: I4H2AG Feature or Bugfix: Feature Binary Source:No Signed-off-by: jiadexiang <jiadexiang@huawei.com>
This commit is contained in:
@@ -24,15 +24,21 @@ FatalHandleFunc JsAsyncWork::isAppExiting_ = nullptr;
|
||||
#if (defined(__LINUX__) || defined(__LITEOS_A__))
|
||||
PostUITaskFunc JsAsyncWork::postUITask_ = nullptr;
|
||||
#endif
|
||||
bool JsAsyncWork::isEnvInitialized_ = false;
|
||||
|
||||
void JsAsyncWork::SetAppQueueHandler(const QueueHandler handler)
|
||||
{
|
||||
appQueuehandler_ = handler;
|
||||
}
|
||||
|
||||
void JsAsyncWork::SetEnvStatus(bool envInitialized)
|
||||
{
|
||||
isEnvInitialized_ = envInitialized;
|
||||
}
|
||||
|
||||
bool JsAsyncWork::DispatchToLoop(AbilityMsgId msgId, void *data)
|
||||
{
|
||||
if (appQueuehandler_ == nullptr) {
|
||||
if (appQueuehandler_ == nullptr || !isEnvInitialized_) {
|
||||
HILOG_ERROR(HILOG_MODULE_ACE, "JsAsyncWork:DispatchAsyncWork app not launched yet!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -114,6 +114,10 @@ void JSAbility::Launch(const char * const abilityPath, const char * const bundle
|
||||
ACE_EVENT_PRINT(MT_ACE_FWK_LAUNCHING, 0);
|
||||
FatalHandler::GetInstance().RegisterFatalHandler(this);
|
||||
jsAbilityImpl->DeliverCreate(pageInfo);
|
||||
#ifndef MOCK_JS_ASYNC_WORK
|
||||
// simulator uses the self-implementation for async work, this interface is not included
|
||||
JsAsyncWork::SetEnvStatus(true);
|
||||
#endif
|
||||
STOP_TRACING();
|
||||
OUTPUT_TRACE();
|
||||
}
|
||||
@@ -156,6 +160,10 @@ void JSAbility::TransferToDestroy()
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef MOCK_JS_ASYNC_WORK
|
||||
// simulator uses the self-implementation for async work, this interface is not included
|
||||
JsAsyncWork::SetEnvStatus(false);
|
||||
#endif
|
||||
HILOG_INFO(HILOG_MODULE_ACE, "LIFECYCLE: JS Ability is exiting");
|
||||
ACE_EVENT_PRINT(MT_ACE_FWK_DESTROYING, 0);
|
||||
JSAbilityImpl *jsAbilityImpl = CastAbilityImpl(jsAbilityImpl_);
|
||||
|
||||
@@ -114,6 +114,7 @@ public:
|
||||
|
||||
static void SetFatalHandleFunc(FatalHandleFunc isFatalErrorHitted, FatalHandleFunc isAppExiting);
|
||||
|
||||
static void SetEnvStatus(bool envInitialized);
|
||||
#if (defined(__LINUX__) || defined(__LITEOS_A__))
|
||||
static void SetPostUITaskFunc(PostUITaskFunc postUITask);
|
||||
#endif
|
||||
@@ -130,6 +131,7 @@ private:
|
||||
#if (defined(__LINUX__) || defined(__LITEOS_A__))
|
||||
static PostUITaskFunc postUITask_;
|
||||
#endif
|
||||
static bool isEnvInitialized_;
|
||||
};
|
||||
} // namespace ACELite
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user