diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index dfe15cc42f..683b6701b3 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -158,7 +158,6 @@ constexpr int32_t UNSPECIFIED_USERID = -2; constexpr int32_t JS_ERROR_EXIT = -2; constexpr int32_t TIME_OUT = 120; constexpr int32_t DEFAULT_SLEEP_TIME = 100000; -constexpr int32_t REPORT_TEMPLATE_PROCESS_READY_DELAY_TIME = 2000; constexpr int32_t SNAPSHOT_START = 0; constexpr int32_t SNAPSHOT_FAILURE = 1; @@ -4734,8 +4733,6 @@ void MainThread::DelayedReportNotifyFFRTToRss() needToNotifyFFRTForNewIpc_ = true; } TAG_LOGI(AAFwkTag::APPKIT, "After notify ffrt snapshot start"); - std::this_thread::sleep_for(std::chrono::milliseconds(REPORT_TEMPLATE_PROCESS_READY_DELAY_TIME)); - TAG_LOGI(AAFwkTag::APPKIT, "template process ready"); if (appMgr_ != nullptr) { appMgr_->NotifyTemplateProcessReadyDone(); } diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 5e01725f7a..0881e83fc2 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -67,6 +67,8 @@ constexpr const int BASE_TEN = 10; constexpr const char SIGN_TERMINAL = '\0'; constexpr int32_t DEFAULT_CONCURRENT_NUMBER = 1; constexpr int32_t HIPROFILER_UID = 3063; +constexpr int32_t REPORT_TEMPLATE_PROCESS_READY_DELAY_TIME = 2000; + namespace { #define CHECK_CALLER_IS_SYSTEM_APP \ if (!AAFwk::PermissionVerification::GetInstance()->JudgeCallerIsAllowedToUseSystemAPI()) { \ @@ -363,7 +365,14 @@ int32_t AppMgrService::NotifyTemplateProcessReadyDone() return ERR_INVALID_OPERATION; } pid_t callingPid = IPCSkeleton::GetCallingPid(); - appMgrServiceInner_->HandleNotifyTemplateProcessReadyDone(callingPid); + auto task = [appMgrServiceInner = appMgrServiceInner_, callingPid]() { + appMgrServiceInner->HandleNotifyTemplateProcessReadyDone(callingPid); + }; + AAFwk::TaskHandlerWrap::GetFfrtHandler()->SubmitTask(task, AAFwk::TaskAttribute{ + .taskName_ = TASK_NOTIFY_TEMPLATE_PROCESS_READY_DONE, + .delayMillis_ = REPORT_TEMPLATE_PROCESS_READY_DELAY_TIME, + .taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE + }); return ERR_OK; }