mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
!1002 send unfocus mission abnormal cancel
Merge pull request !1002 from 仝月姣/master
This commit is contained in:
commit
67816e5954
@ -539,7 +539,7 @@ bool DistributedAbilityManagerService::IsTokenRegistered(uint32_t accessToken, i
|
||||
std::lock_guard<std::mutex> tokenMapLock(tokenMapMutex_);
|
||||
auto iter = tokenMap_.find(accessToken);
|
||||
if (iter == tokenMap_.end()) {
|
||||
HILOGE("accessToken %{public}u has not registered", accessToken);
|
||||
HILOGE("accessToken has not registered in token map.");
|
||||
return false;
|
||||
}
|
||||
for (auto it = iter->second.begin(); it != iter->second.end(); it++) {
|
||||
@ -556,7 +556,7 @@ bool DistributedAbilityManagerService::IsNotifierRegistered(int32_t token)
|
||||
// must be in callbackMapLock scope
|
||||
auto iter = callbackMap_.find(token);
|
||||
if (iter == callbackMap_.end()) {
|
||||
HILOGE("never registered, token: %{public}d ", token);
|
||||
HILOGE("accessToken has not registered in callback map.");
|
||||
return false;
|
||||
}
|
||||
if (iter->second == nullptr) {
|
||||
|
@ -110,6 +110,23 @@ void DSchedContinueManager::NotifyAllConnectDecision(std::string peerDeviceId, b
|
||||
int32_t DSchedContinueManager::ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
|
||||
int32_t missionId, 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;
|
||||
}
|
||||
|
||||
auto func = [this, srcDeviceId, dstDeviceId, missionId, callback, wantParams]() {
|
||||
HandleContinueMission(srcDeviceId, dstDeviceId, missionId, callback, wantParams);
|
||||
};
|
||||
@ -296,6 +313,17 @@ void DSchedContinueManager::SetTimeOut(const DSchedContinueInfo &info, int32_t t
|
||||
int32_t DSchedContinueManager::StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId,
|
||||
int32_t callerUid, int32_t status, uint32_t accessToken)
|
||||
{
|
||||
std::string dstDeviceId = want.GetElement().GetDeviceID();
|
||||
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(dstDeviceId) == nullptr) {
|
||||
HILOGE("GetDeviceInfoById fail, dstDevId: %{public}s.", GetAnonymStr(dstDeviceId).c_str());
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
if (GetDSchedContinueByWant(want, missionId) == nullptr) {
|
||||
HILOGE("GetDSchedContinueByWant fail, dstDevId: %{public}s, missionId: %{public}d.",
|
||||
GetAnonymStr(dstDeviceId).c_str(), missionId);
|
||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
auto func = [this, want, missionId, callerUid, status, accessToken]() {
|
||||
HandleStartContinuation(want, missionId, callerUid, status, accessToken);
|
||||
};
|
||||
@ -327,8 +355,8 @@ std::shared_ptr<DSchedContinue> DSchedContinueManager::GetDSchedContinueByWant(
|
||||
HILOGE("get local deviceId failed!");
|
||||
return nullptr;
|
||||
}
|
||||
std::string dstDeviceId = want.GetElement().GetDeviceID().c_str();
|
||||
std::string bundleName = want.GetElement().GetBundleName().c_str();
|
||||
std::string dstDeviceId = want.GetElement().GetDeviceID();
|
||||
std::string bundleName = want.GetElement().GetBundleName();
|
||||
auto info = DSchedContinueInfo(srcDeviceId, bundleName, dstDeviceId, bundleName, "");
|
||||
|
||||
HILOGI("continue info: %{public}s.", info.toString().c_str());
|
||||
|
@ -25,10 +25,7 @@
|
||||
#include "base_obj.h"
|
||||
#include "bool_wrapper.h"
|
||||
#include "byte_wrapper.h"
|
||||
#include "distributed_operation_builder.h"
|
||||
#include "distributed_want_params_wrapper.h"
|
||||
#include "double_wrapper.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "float_wrapper.h"
|
||||
#include "int_wrapper.h"
|
||||
#include "long_wrapper.h"
|
||||
@ -39,6 +36,10 @@
|
||||
#include "string_wrapper.h"
|
||||
#include "zchar_wrapper.h"
|
||||
|
||||
#include "distributed_operation_builder.h"
|
||||
#include "distributed_want_params_wrapper.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
|
||||
using namespace OHOS::AppExecFwk;
|
||||
using OHOS::AppExecFwk::ElementName;
|
||||
namespace OHOS {
|
||||
@ -896,51 +897,48 @@ DistributedWant* DistributedWant::ParseUri(const std::string& uri)
|
||||
if (!CheckParams(uri)) {
|
||||
return nullptr;
|
||||
}
|
||||
bool ret = true;
|
||||
std::size_t begin = WANT_HEADER.length();
|
||||
ElementName element;
|
||||
DistributedWant* want = new (std::nothrow) DistributedWant();
|
||||
if (want == nullptr) {
|
||||
|
||||
DistributedWant* baseWant = new (std::nothrow) DistributedWant();
|
||||
if (baseWant == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
DistributedWant* pickWant = new (std::nothrow) DistributedWant();
|
||||
if (pickWant == nullptr) {
|
||||
delete baseWant;
|
||||
return nullptr;
|
||||
}
|
||||
DistributedWant* baseWant = want;
|
||||
bool inPicker = false;
|
||||
bool ret = true;
|
||||
ElementName element;
|
||||
std::size_t begin = WANT_HEADER.length();
|
||||
std::size_t pos = uri.find_first_of(";", begin);
|
||||
do {
|
||||
if (pos == std::string::npos) {
|
||||
break;
|
||||
}
|
||||
for (; pos != std::string::npos; pos = uri.find(";", begin)) {
|
||||
std::string content = uri.substr(begin, pos - begin);
|
||||
if (content.compare("PICK") == 0) {
|
||||
if (want != nullptr) {
|
||||
delete want;
|
||||
}
|
||||
want = new (std::nothrow) DistributedWant();
|
||||
if (want == nullptr) {
|
||||
delete baseWant;
|
||||
return nullptr;
|
||||
}
|
||||
inPicker = true;
|
||||
begin = pos + 1;
|
||||
continue;
|
||||
}
|
||||
ret = ParseUriInternal(content, element, *want);
|
||||
|
||||
ret = inPicker ? ParseUriInternal(content, element, *pickWant) : ParseUriInternal(content, element, *baseWant);
|
||||
if (!ret) {
|
||||
HILOGE("Parse uri internal fail, pos %{public}zu, inPicker %{public}d.", pos, inPicker);
|
||||
break;
|
||||
}
|
||||
begin = pos + 1;
|
||||
pos = uri.find(";", begin);
|
||||
if (pos == std::string::npos) {
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
want = inPicker ? baseWant : want;
|
||||
if (ret) {
|
||||
want->SetElement(element);
|
||||
} else {
|
||||
delete want;
|
||||
want = nullptr;
|
||||
};
|
||||
|
||||
if (!ret) {
|
||||
delete pickWant;
|
||||
delete baseWant;
|
||||
return nullptr;
|
||||
}
|
||||
return want;
|
||||
|
||||
DistributedWant* retWant = inPicker ? pickWant : baseWant;
|
||||
DistributedWant* delWant = inPicker ? baseWant : pickWant;
|
||||
delete delWant;
|
||||
retWant->SetElement(element);
|
||||
return retWant;
|
||||
}
|
||||
|
||||
DistributedWant* DistributedWant::WantParseUri(const char* uri)
|
||||
|
@ -208,7 +208,7 @@ bool DistributedSchedPermission::CheckDstSameAccount(const std::string& dstNetwo
|
||||
.accountId = dmsAccountInfo.activeAccountId,
|
||||
.networkId = callerInfo.sourceDeviceId,
|
||||
.userId = dmsAccountInfo.userId,
|
||||
.tokenId = 0,
|
||||
.tokenId = callerInfo.accessToken,
|
||||
};
|
||||
DmAccessCallee dmDstCallee = {
|
||||
.networkId = dstNetworkId,
|
||||
@ -239,7 +239,7 @@ bool DistributedSchedPermission::CheckAclList(const std::string& dstNetworkId,
|
||||
.accountId = dmsAccountInfo.activeAccountId,
|
||||
.networkId = callerInfo.sourceDeviceId,
|
||||
.userId = dmsAccountInfo.userId,
|
||||
.tokenId = 0,
|
||||
.tokenId = callerInfo.accessToken,
|
||||
};
|
||||
DmAccessCallee dmDstCallee = {
|
||||
.networkId = dstNetworkId,
|
||||
@ -497,7 +497,7 @@ bool DistributedSchedPermission::CheckAccountAccessPermission(const CallerInfo&
|
||||
.pkgName = targetBundleName,
|
||||
.networkId = callerInfo.sourceDeviceId,
|
||||
.userId = accountInfo.userId,
|
||||
.tokenId = 0,
|
||||
.tokenId = callerInfo.accessToken,
|
||||
};
|
||||
DmAccessCallee dmDstCallee = {
|
||||
.networkId = dstNetworkId,
|
||||
|
@ -118,14 +118,16 @@ void DMSContinueSendMgr::PostUnfocusedTaskWithDelay(const int32_t missionId, Unf
|
||||
DmsRadar::GetInstance().RecordTime("funcOut");
|
||||
DealUnfocusedBusiness(missionId, UnfocusedReason::TIMEOUT);
|
||||
};
|
||||
eventHandler_->RemoveTask(TIMEOUT_UNFOCUSED_TASK);
|
||||
eventHandler_->PostTask(funcOut, TIMEOUT_UNFOCUSED_TASK, CANCEL_FOCUSED_DELAYED);
|
||||
std::string timeoutTaskName = TIMEOUT_UNFOCUSED_TASK + std::to_string(missionId);
|
||||
eventHandler_->RemoveTask(timeoutTaskName);
|
||||
eventHandler_->PostTask(funcOut, timeoutTaskName, CANCEL_FOCUSED_DELAYED);
|
||||
} else if (reason == UnfocusedReason::SCREENOFF) {
|
||||
auto funcOff = [this]() {
|
||||
SendScreenOffEvent(DMS_UNFOCUSED_TYPE);
|
||||
};
|
||||
eventHandler_->RemoveTask(SCREEN_OFF_UNFOCUSED_TASK);
|
||||
eventHandler_->PostTask(funcOff, SCREEN_OFF_UNFOCUSED_TASK, SCREEN_OFF_DELAY_TIME);
|
||||
std::string scrOffTaskName = SCREEN_OFF_UNFOCUSED_TASK + std::to_string(missionId);
|
||||
eventHandler_->RemoveTask(scrOffTaskName);
|
||||
eventHandler_->PostTask(funcOff, scrOffTaskName, SCREEN_OFF_DELAY_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,8 +156,8 @@ void DMSContinueSendMgr::NotifyMissionFocused(const int32_t missionId, FocusedRe
|
||||
HILOGE("eventHandler_ is nullptr");
|
||||
return;
|
||||
}
|
||||
eventHandler_->RemoveTask(TIMEOUT_UNFOCUSED_TASK);
|
||||
eventHandler_->RemoveTask(SCREEN_OFF_UNFOCUSED_TASK);
|
||||
eventHandler_->RemoveTask(TIMEOUT_UNFOCUSED_TASK + std::to_string(missionId));
|
||||
eventHandler_->RemoveTask(SCREEN_OFF_UNFOCUSED_TASK + std::to_string(missionId));
|
||||
eventHandler_->PostTask(feedfunc);
|
||||
}
|
||||
|
||||
@ -171,7 +173,7 @@ void DMSContinueSendMgr::NotifyMissionUnfocused(const int32_t missionId, Unfocus
|
||||
DealUnfocusedBusiness(missionId, reason);
|
||||
};
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_->RemoveTask(TIMEOUT_UNFOCUSED_TASK);
|
||||
eventHandler_->RemoveTask(TIMEOUT_UNFOCUSED_TASK + std::to_string(missionId));
|
||||
eventHandler_->PostTask(feedfunc);
|
||||
} else {
|
||||
HILOGE("eventHandler_ is nullptr");
|
||||
@ -521,7 +523,7 @@ int32_t DMSContinueSendMgr::SetMissionContinueState(const int32_t missionId,
|
||||
}
|
||||
};
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_->RemoveTask(TIMEOUT_UNFOCUSED_TASK);
|
||||
eventHandler_->RemoveTask(TIMEOUT_UNFOCUSED_TASK + std::to_string(missionId));
|
||||
eventHandler_->PostTask(feedfunc);
|
||||
} else {
|
||||
HILOGE("eventHandler_ is nullptr");
|
||||
|
@ -115,7 +115,7 @@ HWTEST_F(DSchedContinueManagerTest, ContinueMission_001, TestSize.Level3)
|
||||
OHOS::AAFwk::WantParams wantParams;
|
||||
int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
|
||||
callback, wantParams);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DSchedContinueManagerTest ContinueMission_001 end" << std::endl;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ HWTEST_F(DSchedContinueManagerTest, ContinueMission_002, TestSize.Level3)
|
||||
|
||||
int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
|
||||
callback, wantParams);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DSchedContinueManagerTest ContinueMission_002 end" << std::endl;
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ HWTEST_F(DSchedContinueManagerTest, StartContinuation_001, TestSize.Level3)
|
||||
uint32_t accessToken = 0;
|
||||
int32_t ret1 = DSchedContinueManager::GetInstance().StartContinuation(want, missionId,
|
||||
callerUid, status, accessToken);
|
||||
EXPECT_EQ(ret1, ERR_OK);
|
||||
EXPECT_EQ(ret1, INVALID_REMOTE_PARAMETERS_ERR);
|
||||
DTEST_LOG << "DSchedContinueManagerTest StartContinuation_001 end" << std::endl;
|
||||
}
|
||||
|
||||
|
@ -4469,9 +4469,7 @@ HWTEST_F(DistributedWantBaseTest, WantParseUri_test_001, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "WantParseUri_test_001 start";
|
||||
char* uri = nullptr;
|
||||
DistributedWant* newWant = nullptr;
|
||||
newWant->WantParseUri(uri);
|
||||
EXPECT_EQ(uri, nullptr);
|
||||
EXPECT_EQ(DistributedWant::WantParseUri(uri), nullptr);
|
||||
GTEST_LOG_(INFO) << "WantParseUri_test_001 end";
|
||||
}
|
||||
} // namespace DistributedSchedule
|
||||
|
Loading…
Reference in New Issue
Block a user