From fcaf29f6f10bdaf4d7a51f414266617529b45f38 Mon Sep 17 00:00:00 2001 From: houdisheng Date: Tue, 7 Jun 2022 14:27:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E9=80=BB=E8=BE=91=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=9C=A8=E6=9C=AA=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6=EF=BC=8C?= =?UTF-8?q?native=E6=8E=A5=E5=8F=A3=E8=A2=AB=E8=B0=83=E7=94=A8=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E8=BF=9B=E7=A8=8Bcrash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- .../innerkits/src/bundle_active_client.cpp | 2 +- services/common/src/bundle_active_service.cpp | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/interfaces/innerkits/src/bundle_active_client.cpp b/interfaces/innerkits/src/bundle_active_client.cpp index efaf269..25bc813 100644 --- a/interfaces/innerkits/src/bundle_active_client.cpp +++ b/interfaces/innerkits/src/bundle_active_client.cpp @@ -38,7 +38,7 @@ bool BundleActiveClient::GetBundleActiveProxy() sptr object = samgr->GetSystemAbility(DEVICE_USAGE_STATISTICS_SYS_ABILITY_ID); if (!object) { - BUNDLE_ACTIVE_LOGE("Failed to get SystemAbility[1920] ."); + BUNDLE_ACTIVE_LOGE("Failed to get SystemAbility[1907] ."); return false; } diff --git a/services/common/src/bundle_active_service.cpp b/services/common/src/bundle_active_service.cpp index d38c0de..fd6e68a 100644 --- a/services/common/src/bundle_active_service.cpp +++ b/services/common/src/bundle_active_service.cpp @@ -62,15 +62,8 @@ void BundleActiveService::OnStart() BUNDLE_ACTIVE_LOGI("BundleActiveService handler create failed!"); return; } - - InitNecessaryState(); - int32_t ret = Publish(DelayedSingleton::GetInstance().get()); - if (!ret) { - BUNDLE_ACTIVE_LOGE("[Server] OnStart, Register SystemAbility[1907] FAIL."); - return; - } - BUNDLE_ACTIVE_LOGI("[Server] OnStart, Register SystemAbility[1907] SUCCESS."); - return; + auto registerTask = [this]() { this->InitNecessaryState(); }; + handler_->PostSyncTask(registerTask); } void BundleActiveService::InitNecessaryState() @@ -103,6 +96,12 @@ void BundleActiveService::InitNecessaryState() } InitService(); ready_ = true; + int32_t ret = Publish(DelayedSingleton::GetInstance().get()); + if (!ret) { + BUNDLE_ACTIVE_LOGE("[Server] OnStart, Register SystemAbility[1907] FAIL."); + return; + } + BUNDLE_ACTIVE_LOGI("[Server] OnStart, Register SystemAbility[1907] SUCCESS."); } void BundleActiveService::InitService() @@ -470,7 +469,7 @@ int32_t BundleActiveService::UnregisterGroupCallBack(const sptr