Signed-off-by: zjucx <chengxiang4@huawei.com>
This commit is contained in:
zjucx 2023-06-19 10:50:44 +08:00
parent 1a3080d0e4
commit 99fdbebd4d
7 changed files with 24 additions and 29 deletions

View File

@ -60,7 +60,8 @@
"os_account",
"safwk",
"samgr",
"startup_l2"
"startup_l2",
"ffrt"
],
"third_party": []
},

View File

@ -62,6 +62,7 @@ ohos_shared_library("distributed_ability_manager_svr") {
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hiviewdfx_hilog_native:libhilog",
"init:libbegetutil",
"ipc:ipc_core",

View File

@ -21,6 +21,7 @@
#include "continuation_manager/notifier_info.h"
#include "distributed_ability_manager_stub.h"
#include "event_handler.h"
#include "ffrt.h"
#include "single_instance.h"
#include "system_ability.h"
@ -89,7 +90,7 @@ private:
sptr<IRemoteObject> connect_;
std::mutex appProxyMutex_;
sptr<IRemoteObject> appProxy_;
std::shared_ptr<AppExecFwk::EventHandler> continuationHandler_;
std::shared_ptr<ffrt::queue> continuationHandler_;
};
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -68,8 +68,7 @@ void DistributedAbilityManagerService::OnStart()
}
notifierDeathRecipient_ = sptr<IRemoteObject::DeathRecipient>(new NotifierDeathRecipient());
if (continuationHandler_ == nullptr) {
auto runner = AppExecFwk::EventRunner::Create("ContinuationMgr");
continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
continuationHandler_ = std::make_shared<ffrt::queue>("ContinuationMgr");
}
Publish(this);
}
@ -491,7 +490,7 @@ bool DistributedAbilityManagerService::HandleDisconnectAbility()
return;
}
};
continuationHandler_->PostTask(func);
continuationHandler_->submit(func);
return true;
}
@ -584,7 +583,7 @@ bool DistributedAbilityManagerService::HandleDeviceConnect(const sptr<IRemoteObj
auto proxy = std::make_unique<DeviceSelectionNotifierProxy>(notifier);
proxy->OnDeviceConnect(continuationResults);
};
continuationHandler_->PostTask(func);
continuationHandler_->submit(func);
return true;
}
@ -600,7 +599,7 @@ bool DistributedAbilityManagerService::HandleDeviceDisconnect(const sptr<IRemote
auto proxy = std::make_unique<DeviceSelectionNotifierProxy>(notifier);
proxy->OnDeviceDisconnect(continuationResults);
};
continuationHandler_->PostTask(func);
continuationHandler_->submit(func);
return true;
}
@ -661,7 +660,7 @@ void DistributedAbilityManagerService::HandleStartDeviceManager(int32_t token,
int32_t result = appProxy->SendRequest(START_DEVICE_MANAGER_CODE, data, reply, option);
HILOGD("result is %{public}d", result);
};
continuationHandler_->PostTask(func);
continuationHandler_->submit(func);
}
void DistributedAbilityManagerService::HandleUpdateConnectStatus(int32_t token, std::string deviceId,
@ -687,7 +686,7 @@ void DistributedAbilityManagerService::HandleUpdateConnectStatus(int32_t token,
int32_t result = appProxy->SendRequest(UPDATE_CONNECT_STATUS_CODE, data, reply, option);
HILOGD("result is %{public}d", result);
};
continuationHandler_->PostTask(func);
continuationHandler_->submit(func);
}
bool DistributedAbilityManagerService::QueryTokenByNotifier(const sptr<IRemoteObject>& notifier, int32_t& token)
@ -753,7 +752,7 @@ void DistributedAbilityManagerService::HandleNotifierDied(const sptr<IRemoteObje
// disconnect to app when third-party app died
(void)HandleDisconnectAbility();
};
continuationHandler_->PostTask(func);
continuationHandler_->submit(func);
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -47,6 +47,7 @@ dtbabilitymgr_external_deps = [
"dmsfwk:common_sdk",
"dmsfwk:continuation_manager",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hiviewdfx_hilog_native:libhilog",
"init:libbegetutil",
"ipc:ipc_core",

View File

@ -70,7 +70,7 @@ void DistributedAbilityManagerServiceTest::TearDownTestCase()
caseDoneCondition_.notify_one();
};
if (dtbabilitymgrService_->continuationHandler_ != nullptr) {
dtbabilitymgrService_->continuationHandler_->PostTask(caseDoneNotifyTask);
dtbabilitymgrService_->continuationHandler_->submit(caseDoneNotifyTask);
}
std::unique_lock<std::mutex> lock(caseDoneLock_);
caseDoneCondition_.wait_for(lock, std::chrono::milliseconds(MAX_WAIT_TIME),
@ -618,8 +618,7 @@ HWTEST_F(DistributedAbilityManagerServiceTest, OnDeviceDisconnect_001, TestSize.
* @tc.steps: step1. test OnDeviceDisconnect when callback has not registered.
*/
if (dtbabilitymgrService_->continuationHandler_ == nullptr) {
auto runner = AppExecFwk::EventRunner::Create("ContinuationMgr");
dtbabilitymgrService_->continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
dtbabilitymgrService_->continuationHandler_ = std::make_shared<ffrt::queue>("ContinuationMgr");
}
std::vector<ContinuationResult> continuationResults;
int32_t ret = dtbabilitymgrService_->OnDeviceDisconnect(INVALID_CODE, continuationResults);
@ -734,8 +733,7 @@ HWTEST_F(DistributedAbilityManagerServiceTest, HandleDeviceDisconnect_001, TestS
dtbabilitymgrService_->HandleStartDeviceManager(1, continuationExtraParams);
dtbabilitymgrService_->HandleStartDeviceManager(1, nullptr);
if (dtbabilitymgrService_->continuationHandler_ == nullptr) {
auto runner = AppExecFwk::EventRunner::Create("ContinuationMgr");
dtbabilitymgrService_->continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
dtbabilitymgrService_->continuationHandler_ = std::make_shared<ffrt::queue>("ContinuationMgr");
}
bool result = dtbabilitymgrService_->HandleDeviceConnect(dtbabilitymgrService_, continuationResults);
dtbabilitymgrService_->HandleStartDeviceManager(1, continuationExtraParams);
@ -765,8 +763,7 @@ HWTEST_F(DistributedAbilityManagerServiceTest, HandleDeviceDisconnect_002, TestS
/**
* @tc.steps: step2. test HandleDeviceConnect when continuationHandler_ is not nullptr.
*/
auto runner = AppExecFwk::EventRunner::Create("ContinuationMgr");
dtbabilitymgrService_->continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
dtbabilitymgrService_->continuationHandler_ = std::make_shared<ffrt::queue>("ContinuationMgr");
sptr<DeviceSelectionNotifierTest> notifier = new DeviceSelectionNotifierTest();
std::vector<ContinuationResult> continuationResults;
bool ret = dtbabilitymgrService_->HandleDeviceDisconnect(notifier, continuationResults);
@ -833,8 +830,7 @@ HWTEST_F(DistributedAbilityManagerServiceTest, QueryTokenByNotifier_001, TestSiz
/**
* @tc.steps: step4. test HandleNotifierDied when QueryTokenByNotifier returns true.
*/
auto runner = AppExecFwk::EventRunner::Create("ContinuationMgr");
dtbabilitymgrService_->continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
dtbabilitymgrService_->continuationHandler_ = std::make_shared<ffrt::queue>("ContinuationMgr");
std::unique_ptr<NotifierInfo> notifierInfo = std::make_unique<NotifierInfo>();
notifierInfo->SetNotifier(EVENT_CONNECT, notifier);
{
@ -913,8 +909,7 @@ HWTEST_F(DistributedAbilityManagerServiceTest, HandleUpdateConnectStatus_001, Te
DeviceConnectStatus deviceConnectStatus = DeviceConnectStatus::CONNECTING;
dtbabilitymgrService_->HandleUpdateConnectStatus(1, DEVICE_ID, deviceConnectStatus);
if (dtbabilitymgrService_->continuationHandler_ == nullptr) {
auto runner = AppExecFwk::EventRunner::Create("ContinuationMgr");
dtbabilitymgrService_->continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
dtbabilitymgrService_->continuationHandler_ = std::make_shared<ffrt::queue>("ContinuationMgr");
}
dtbabilitymgrService_->HandleUpdateConnectStatus(1, DEVICE_ID, deviceConnectStatus);
DTEST_LOG << "DistributedAbilityManagerServiceTest HandleUpdateConnectStatus_001 end" << std::endl;
@ -1121,8 +1116,7 @@ HWTEST_F(DistributedAbilityManagerServiceTest, OnDeviceConnect_001, TestSize.Lev
return;
}
if (dtbabilitymgrService_->continuationHandler_ == nullptr) {
auto runner = AppExecFwk::EventRunner::Create("ContinuationMgr");
dtbabilitymgrService_->continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
dtbabilitymgrService_->continuationHandler_ = std::make_shared<ffrt::queue>("ContinuationMgr");
}
int32_t token = 0;
std::vector<ContinuationResult> continuationResults;
@ -1145,8 +1139,7 @@ HWTEST_F(DistributedAbilityManagerServiceTest, OnDeviceConnect_002, TestSize.Lev
return;
}
if (dtbabilitymgrService_->continuationHandler_ == nullptr) {
auto runner = AppExecFwk::EventRunner::Create("ContinuationMgr");
dtbabilitymgrService_->continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
dtbabilitymgrService_->continuationHandler_ = std::make_shared<ffrt::queue>("ContinuationMgr");
}
int32_t token = 0;
std::vector<ContinuationResult> continuationResults;
@ -1181,8 +1174,7 @@ HWTEST_F(DistributedAbilityManagerServiceTest, HandleStartDeviceManager_001, Tes
return;
}
if (dtbabilitymgrService_->continuationHandler_ == nullptr) {
auto runner = AppExecFwk::EventRunner::Create("ContinuationMgr");
dtbabilitymgrService_->continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
dtbabilitymgrService_->continuationHandler_ = std::make_shared<ffrt::queue>("ContinuationMgr");
}
int32_t token = 0;
dtbabilitymgrService_->HandleStartDeviceManager(token, nullptr);
@ -1204,8 +1196,7 @@ HWTEST_F(DistributedAbilityManagerServiceTest, HandleStartDeviceManager_002, Tes
return;
}
if (dtbabilitymgrService_->continuationHandler_ == nullptr) {
auto runner = AppExecFwk::EventRunner::Create("ContinuationMgr");
dtbabilitymgrService_->continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
dtbabilitymgrService_->continuationHandler_ = std::make_shared<ffrt::queue>("ContinuationMgr");
}
int32_t token = 0;
std::shared_ptr<ContinuationExtraParams> continuationExtraParams = std::make_shared<ContinuationExtraParams>();

View File

@ -52,6 +52,7 @@ dtbabilitymgr_external_deps = [
"c_utils:utils",
"device_manager:devicemanagersdk",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hiviewdfx_hilog_native:libhilog",
"init:libbegetutil",
"ipc:ipc_core",