mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
fix hml continueAbility hits error mismatch
Signed-off-by: t00605578 <tongyuejiao@huawei.com>
This commit is contained in:
parent
5395892c90
commit
4d514c9592
@ -79,7 +79,6 @@ private:
|
||||
int32_t CheckContinuationLimit(const std::string& srcDeviceId, const std::string& dstDeviceId);
|
||||
void SetTimeOut(const DSchedContinueInfo& info, int32_t timeout);
|
||||
void RemoveTimeout(const DSchedContinueInfo& info);
|
||||
bool GetLocalDeviceId(std::string& localDeviceId);
|
||||
|
||||
class SoftbusListener : public IDataListener {
|
||||
void OnBind(int32_t socket, PeerSocketInfo info);
|
||||
|
@ -125,7 +125,7 @@ void DSchedContinueManager::HandleContinueMission(const std::string& srcDeviceId
|
||||
}
|
||||
|
||||
std::string localDevId;
|
||||
if (!GetLocalDeviceId(localDevId)) {
|
||||
if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDevId)) {
|
||||
HILOGE("get local deviceId failed!");
|
||||
return;
|
||||
}
|
||||
@ -146,6 +146,34 @@ int32_t DSchedContinueManager::ContinueMission(const std::string& srcDeviceId, c
|
||||
std::string bundleName, const std::string& continueType,
|
||||
const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
|
||||
{
|
||||
if (srcDeviceId.empty() || dstDeviceId.empty() || callback == nullptr) {
|
||||
HILOGE("srcDeviceId or dstDeviceId or callback is null!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
std::string localDevId;
|
||||
if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDevId)) {
|
||||
HILOGE("get local deviceId failed!");
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(
|
||||
localDevId == srcDeviceId ? dstDeviceId : srcDeviceId) == nullptr) {
|
||||
HILOGE("GetDeviceInfoById fail, locDevId: %{public}s, srcDevId: %{public}s, dstDevId: %{public}s.",
|
||||
GetAnonymStr(localDevId).c_str(), GetAnonymStr(srcDeviceId).c_str(), GetAnonymStr(dstDeviceId).c_str());
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
|
||||
if (localDevId == srcDeviceId) {
|
||||
int32_t missionId = -1;
|
||||
int32_t ret = DMSContinueSendMgr::GetInstance().GetMissionIdByBundleName(bundleName, missionId);
|
||||
if (ret != ERR_OK) {
|
||||
HILOGE("get missionId fail, ret %{public}d.", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
auto func = [this, srcDeviceId, dstDeviceId, bundleName, continueType, callback, wantParams]() {
|
||||
HandleContinueMission(srcDeviceId, dstDeviceId, bundleName, continueType, callback, wantParams);
|
||||
};
|
||||
@ -255,7 +283,7 @@ std::shared_ptr<DSchedContinue> DSchedContinueManager::GetDSchedContinueByWant(
|
||||
const OHOS::AAFwk::Want& want, int32_t missionId)
|
||||
{
|
||||
std::string srcDeviceId;
|
||||
if (!GetLocalDeviceId(srcDeviceId)) {
|
||||
if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId)) {
|
||||
HILOGE("get local deviceId failed!");
|
||||
return nullptr;
|
||||
}
|
||||
@ -389,7 +417,7 @@ void DSchedContinueManager::HandleContinueEnd(const DSchedContinueInfo& info)
|
||||
ContinueSceneSessionHandler::GetInstance().ClearContinueSessionId();
|
||||
|
||||
std::string localDevId;
|
||||
if (!GetLocalDeviceId(localDevId)) {
|
||||
if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDevId)) {
|
||||
HILOGE("get local deviceId failed!");
|
||||
return;
|
||||
}
|
||||
@ -503,7 +531,7 @@ int32_t DSchedContinueManager::CheckContinuationLimit(const std::string& srcDevi
|
||||
const std::string& dstDeviceId)
|
||||
{
|
||||
std::string localDevId;
|
||||
if (!GetLocalDeviceId(localDevId)) {
|
||||
if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDevId)) {
|
||||
HILOGE("get local deviceId failed!");
|
||||
return GET_LOCAL_DEVICE_ERR;
|
||||
}
|
||||
@ -535,15 +563,6 @@ int32_t DSchedContinueManager::CheckContinuationLimit(const std::string& srcDevi
|
||||
return direction;
|
||||
}
|
||||
|
||||
bool DSchedContinueManager::GetLocalDeviceId(std::string& localDeviceId)
|
||||
{
|
||||
if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId)) {
|
||||
HILOGE("GetLocalDeviceId failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t DSchedContinueManager::GetContinueInfo(std::string &srcDeviceId, std::string &dstDeviceId)
|
||||
{
|
||||
HILOGI("called");
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "dsched_continue_manager_test.h"
|
||||
|
||||
#include "datetime_ex.h"
|
||||
|
||||
#include "dtbschedmgr_device_info_storage.h"
|
||||
#include "test_log.h"
|
||||
#include "mock_distributed_sched.h"
|
||||
|
||||
@ -137,22 +139,40 @@ HWTEST_F(DSchedContinueManagerTest, ContinueMission_002, TestSize.Level3)
|
||||
HWTEST_F(DSchedContinueManagerTest, ContinueMission_003, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DSchedContinueManagerTest ContinueMission_003 begin" << std::endl;
|
||||
auto callback = GetDSchedService();
|
||||
OHOS::AAFwk::WantParams wantParams;
|
||||
int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, BUNDLE_NAME,
|
||||
int32_t ret = DSchedContinueManager::GetInstance().ContinueMission("", "", BUNDLE_NAME,
|
||||
CONTINUETYPE, nullptr, wantParams);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
|
||||
ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, "", BUNDLE_NAME,
|
||||
CONTINUETYPE, nullptr, wantParams);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
|
||||
ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, BUNDLE_NAME,
|
||||
CONTINUETYPE, nullptr, wantParams);
|
||||
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
|
||||
|
||||
auto callback = GetDSchedService();
|
||||
ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, BUNDLE_NAME,
|
||||
CONTINUETYPE, callback, wantParams);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
|
||||
|
||||
std::string locDevId;
|
||||
EXPECT_EQ(true, DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(locDevId));
|
||||
ret = DSchedContinueManager::GetInstance().ContinueMission(locDevId, REMOTE_DEVICEID, BUNDLE_NAME,
|
||||
CONTINUETYPE, callback, wantParams);
|
||||
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DSchedContinueManagerTest ContinueMission_003 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ContinueMission_004
|
||||
* @tc.desc: test ContinueMission func
|
||||
* @tc.name: HandleContinueMission_001
|
||||
* @tc.desc: test HandleContinueMission func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DSchedContinueManagerTest, ContinueMission_004, TestSize.Level3)
|
||||
HWTEST_F(DSchedContinueManagerTest, HandleContinueMission_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DSchedContinueManagerTest ContinueMission_004 begin" << std::endl;
|
||||
DTEST_LOG << "DSchedContinueManagerTest HandleContinueMission_001 begin" << std::endl;
|
||||
OHOS::AAFwk::WantParams wantParams;
|
||||
auto callback = GetDSchedService();
|
||||
DSchedContinueManager::GetInstance().HandleContinueMission("", REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE,
|
||||
@ -162,10 +182,9 @@ HWTEST_F(DSchedContinueManagerTest, ContinueMission_004, TestSize.Level3)
|
||||
DSchedContinueManager::GetInstance().HandleContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, BUNDLE_NAME,
|
||||
CONTINUETYPE, nullptr, wantParams);
|
||||
|
||||
int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, BUNDLE_NAME,
|
||||
DSchedContinueManager::GetInstance().HandleContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, BUNDLE_NAME,
|
||||
CONTINUETYPE, callback, wantParams);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
DTEST_LOG << "DSchedContinueManagerTest ContinueMission_004 end" << std::endl;
|
||||
DTEST_LOG << "DSchedContinueManagerTest HandleContinueMission_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,20 +235,6 @@ HWTEST_F(DSchedContinueManagerTest, CheckContinuationLimit_001, TestSize.Level3)
|
||||
DTEST_LOG << "DSchedContinueManagerTest CheckContinuationLimit_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetLocalDeviceId_001
|
||||
* @tc.desc: test GetLocalDeviceId func
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DSchedContinueManagerTest, GetLocalDeviceId_001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DSchedContinueManagerTest GetLocalDeviceId_001 begin" << std::endl;
|
||||
std::string localDeviceId = "localdeviceid";
|
||||
int32_t ret = DSchedContinueManager::GetInstance().GetLocalDeviceId(localDeviceId);
|
||||
EXPECT_EQ(ret, false);
|
||||
DTEST_LOG << "DSchedContinueManagerTest GetLocalDeviceId_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetContinueInfo_001
|
||||
* @tc.desc: test GetContinueInfo func
|
||||
|
Loading…
Reference in New Issue
Block a user