diff --git a/services/efficiency_resources/src/bg_efficiency_resources_mgr.cpp b/services/efficiency_resources/src/bg_efficiency_resources_mgr.cpp index 40a0aed2c945950367d2f1a8bc77c6fd8376c5ac..bdfbd7ebb7e5f4982ee5d592d650db5003baaaf5 100644 --- a/services/efficiency_resources/src/bg_efficiency_resources_mgr.cpp +++ b/services/efficiency_resources/src/bg_efficiency_resources_mgr.cpp @@ -93,7 +93,14 @@ void BgEfficiencyResourcesMgr::OnAddSystemAbility(int32_t systemAbilityId, const } if (dependsReady_ == ALL_DEPENDS_READY) { BGTASK_LOGI("necessary system service has been satisfied!"); - auto task = [this]() { this->InitNecessaryState(); }; + auto task = [weak = weak_from_this()]() { + auto self = weak.lock(); + if (!self) { + BGTASK_LOGE("weak.lock return null"); + return; + } + self->InitNecessaryState(); + }; handler_->PostSyncTask(task); } }