From bec730e46ebd3b4457d9d6be59069709a78c99a3 Mon Sep 17 00:00:00 2001 From: fengyang Date: Fri, 13 Oct 2023 11:06:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=B8=E9=A9=BB=E7=BA=BF=E7=A8=8B=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengyang --- BUILD.gn | 1 + bundle.json | 3 ++- interfaces/innerkits/include/bundle_active_client.h | 1 - interfaces/innerkits/src/bundle_active_client.cpp | 10 +++------- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index d6ec655..a48f3c2 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -57,6 +57,7 @@ ohos_shared_library("usagestatsinner") { "hilog:libhilog", "ipc:ipc_single", "samgr:samgr_proxy", + "ffrt:libffrt" ] part_name = "${device_usage_statistics_part_name}" diff --git a/bundle.json b/bundle.json index 4f74c95..524fc90 100644 --- a/bundle.json +++ b/bundle.json @@ -40,7 +40,8 @@ "eventhandler", "power_manager", "time_service", - "init" + "init", + "ffrt" ], "third_party": [] }, diff --git a/interfaces/innerkits/include/bundle_active_client.h b/interfaces/innerkits/include/bundle_active_client.h index 1985b2b..c945339 100644 --- a/interfaces/innerkits/include/bundle_active_client.h +++ b/interfaces/innerkits/include/bundle_active_client.h @@ -220,7 +220,6 @@ private: sptr bundleActiveProxy_; sptr recipient_; std::shared_ptr bundleClientRunner_ {nullptr}; - std::shared_ptr bundleClientHandler_ {nullptr}; std::recursive_mutex mutex_; }; } // namespace DeviceUsageStats diff --git a/interfaces/innerkits/src/bundle_active_client.cpp b/interfaces/innerkits/src/bundle_active_client.cpp index c24711d..63fefb2 100644 --- a/interfaces/innerkits/src/bundle_active_client.cpp +++ b/interfaces/innerkits/src/bundle_active_client.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ #include "unistd.h" +#include "ffrt.h" #include "bundle_active_client.h" @@ -63,11 +64,6 @@ ErrCode BundleActiveClient::GetBundleActiveProxy() BUNDLE_ACTIVE_LOGE("BundleActiveClient runner create failed!"); return ERR_MEMORY_OPERATION_FAILED; } - bundleClientHandler_ = std::make_shared(bundleClientRunner_); - if (!bundleClientHandler_) { - BUNDLE_ACTIVE_LOGE("BundleActiveClient handler create failed!"); - return ERR_MEMORY_OPERATION_FAILED; - } return ERR_OK; } @@ -244,9 +240,9 @@ void BundleActiveClient::BundleActiveClientDeathRecipient::OnRemoteDied(const wp (void)object; std::lock_guard lock(BundleActiveClient::GetInstance().mutex_); BundleActiveClient::GetInstance().bundleActiveProxy_ = nullptr; - BundleActiveClient::GetInstance().bundleClientHandler_->PostTask([this]() { + ffrt::submit([this]() { this->OnServiceDiedInner(); - }, DELAY_TIME); + }, {}, {}, ffrt::task_attr().delay(DELAY_TIME)); } void BundleActiveClient::BundleActiveClientDeathRecipient::OnServiceDiedInner() -- Gitee