mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 00:20:44 +00:00
相同应用使用不同moduleName适配不同设备场景下,接续失败
Signed-off-by: MisterE <smart_e@126.com>
This commit is contained in:
commit
ce66450cb3
@ -63,6 +63,8 @@ public:
|
||||
std::string& bundleName);
|
||||
bool GetDistributedBundleInfo(const std::string &networkId, const uint16_t &bundleNameId,
|
||||
DmsBundleInfo &distributeBundleInfo);
|
||||
bool GetDistributedBundleInfo(const std::string &networkId, const std::string &bundleName,
|
||||
DmsBundleInfo &distributeBundleInfo);
|
||||
bool GetBundleNameId(const std::string& bundleName, uint16_t &bundleNameId);
|
||||
std::string GetContinueType(const std::string &networkId, std::string &bundleName, uint8_t continueTypeId);
|
||||
std::string GetAbilityName(const std::string &networkId, std::string &bundleName, std::string &continueType);
|
||||
|
@ -390,6 +390,58 @@ int32_t DSchedContinue::OnContinueDataCmd(std::shared_ptr<DSchedContinueDataCmd>
|
||||
int32_t DSchedContinue::PostContinueDataTask(std::shared_ptr<DSchedContinueDataCmd> cmd)
|
||||
{
|
||||
DSchedContinueEventType eventType = DSCHED_CONTINUE_DATA_EVENT;
|
||||
cmd->want_.SetBundle(cmd->dstBundleName_);
|
||||
std::string senderNetWorkId = cmd->callerInfo_.sourceDeviceId;
|
||||
std::string continueType = cmd->continueType_;
|
||||
std::string moduleName = cmd->want_.GetModuleName();
|
||||
DmsBundleInfo distributedBundleInfo;
|
||||
if (!DmsBmStorage::GetInstance()->GetDistributedBundleInfo(senderNetWorkId, cmd->dstBundleName_,
|
||||
distributedBundleInfo)) {
|
||||
HILOGE("PostContinueDataTask can not found bundle info for bundle name: %{public}s",
|
||||
cmd->dstBundleName_.c_str());
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
std::vector<DmsAbilityInfo> dmsAbilityInfos = distributedBundleInfo.dmsAbilityInfos;
|
||||
std::vector<DmsAbilityInfo> result;
|
||||
bool sameAbilityGot = false;
|
||||
bool hasSameModule = false;
|
||||
for (const auto &abilityInfoElement: dmsAbilityInfos) {
|
||||
std::vector<std::string> continueTypes = abilityInfoElement.continueType;
|
||||
for (const auto &continueTypeElement: continueTypes) {
|
||||
if (continueTypeElement == continueType) {
|
||||
if (continueTypeElement == abilityInfoElement.abilityName &&
|
||||
moduleName == abilityInfoElement.moduleName) {
|
||||
sameAbilityGot = true;
|
||||
result.push_back(abilityInfoElement);
|
||||
break;
|
||||
} else if (continueTypeElement != abilityInfoElement.abilityName &&
|
||||
moduleName == abilityInfoElement.moduleName) {
|
||||
hasSameModule = true;
|
||||
result.clear();
|
||||
result.push_back(abilityInfoElement);
|
||||
break;
|
||||
} else if (continueTypeElement != abilityInfoElement.abilityName) {
|
||||
result.push_back(abilityInfoElement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sameAbilityGot || hasSameModule) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.empty()) {
|
||||
HILOGE("PostContinueDataTask can not found bundle info for bundle name: %{public}s",
|
||||
cmd->dstBundleName_.c_str());
|
||||
return INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
|
||||
auto element = cmd->want_.GetElement();
|
||||
cmd->want_.SetElementName(element.GetDeviceId(), element.GetBundleName(), element.GetAbilityName(),
|
||||
result[0].moduleName);
|
||||
|
||||
HILOGI("PostContinueDataTask %{public}d, continueInfo %{public}s", eventType, continueInfo_.toString().c_str());
|
||||
if (eventHandler_ == nullptr) {
|
||||
HILOGE("PostContinueDataTask eventHandler is nullptr");
|
||||
|
@ -453,6 +453,56 @@ bool DmsBmStorage::GetDistributedBundleInfo(const std::string &networkId,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetDistributedBundleInfo(const std::string &networkId, const std::string &bundleName,
|
||||
DmsBundleInfo &distributeBundleInfo){
|
||||
HILOGD("networkId: %{public}s bundleNameId: %{public}s", GetAnonymStr(networkId).c_str(), bundleName.c_str());
|
||||
if (!CheckKvStore()) {
|
||||
HILOGE("kvStore is nullptr");
|
||||
return false;
|
||||
}
|
||||
std::string udid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUdidByNetworkId(networkId);
|
||||
std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(networkId);
|
||||
if (udid == "" || uuid == "") {
|
||||
HILOGE("can not get udid or uuid");
|
||||
return false;
|
||||
}
|
||||
HILOGI("uuid: %{public}s", GetAnonymStr(uuid).c_str());
|
||||
std::vector<Entry> remoteEntries;
|
||||
Status status = kvStorePtr_->GetDeviceEntries(uuid, remoteEntries);
|
||||
if (remoteEntries.empty() || status != Status::SUCCESS) {
|
||||
HILOGE("GetDeviceEntries error: %{public}d or remoteEntries is empty", status);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<Entry> reduRiskEntries;
|
||||
std::string keyOfPublic = udid + AppExecFwk::Constants::FILE_UNDERLINE + PUBLIC_RECORDS;
|
||||
for (auto entry: remoteEntries) {
|
||||
std::string key = entry.key.ToString();
|
||||
std::string value = entry.value.ToString();
|
||||
if (key.find(keyOfPublic) != std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
DmsBundleInfo distributedBundleInfoTmp;
|
||||
if (distributedBundleInfoTmp.FromJsonString(value)
|
||||
&& distributedBundleInfoTmp.bundleName == bundleName) {
|
||||
distributeBundleInfo = distributedBundleInfoTmp;
|
||||
reduRiskEntries.push_back(entry);
|
||||
}
|
||||
}
|
||||
if (reduRiskEntries.size() > 1) {
|
||||
HILOGE("Redundant data needs to be deleted.");
|
||||
DelReduData(networkId, reduRiskEntries);
|
||||
distributeBundleInfo = DmsBundleInfo();
|
||||
return false;
|
||||
}
|
||||
if (reduRiskEntries.empty()) {
|
||||
HILOGE("get distributedBundleInfo failed.");
|
||||
return false;
|
||||
}
|
||||
HILOGD("end.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Status DmsBmStorage::GetResultSatus(std::promise<OHOS::DistributedKv::Status> &resultStatusSignal)
|
||||
{
|
||||
auto future = resultStatusSignal.get_future();
|
||||
|
@ -15,6 +15,10 @@
|
||||
|
||||
#include "dms_continue_manager_test.h"
|
||||
|
||||
#ifdef DMSFWK_INTERACTIVE_ADAPTER
|
||||
#include "broadcast.h"
|
||||
#endif
|
||||
|
||||
#include "datetime_ex.h"
|
||||
#include "distributed_sched_test_util.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
@ -28,6 +32,13 @@
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
#ifdef DMSFWK_INTERACTIVE_ADAPTER
|
||||
int32_t SendEvent(const char* pkgName, BroadCastAddr target, EventData *event)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
namespace {
|
||||
|
Loading…
Reference in New Issue
Block a user