Signed-off-by: MisterE <smart_e@126.com>
This commit is contained in:
MisterE 2024-08-26 18:03:57 +08:00
commit b24ff02e11
5 changed files with 59 additions and 40 deletions

View File

@ -185,7 +185,8 @@ bool BundleManagerInternal::IsSameAppId(const std::string& callerAppId, const st
}
bool BundleManagerInternal::IsSameDeveloperId(const std::string &callerDeveloperId,
const std::string &targetBundleName) {
const std::string &targetBundleName)
{
if (targetBundleName.empty() || callerDeveloperId.empty()) {
HILOGE("targetBundleName:%{public}s or callerDeveloperId:%{public}s is empty",
targetBundleName.c_str(), GetAnonymStr(callerDeveloperId).c_str());
@ -248,7 +249,8 @@ int32_t BundleManagerInternal::GetLocalBundleInfoV9(const std::string& bundleNam
}
bool BundleManagerInternal::GetContinueBundle4Src(const std::string &srcBundleName,
std::vector<std::string> &bundleNameList) {
std::vector<std::string> &bundleNameList)
{
auto bundleMgr = GetBundleManager();
if (bundleMgr == nullptr) {
HILOGE("get bundle manager failed");

View File

@ -747,7 +747,8 @@ int32_t DSchedContinue::ExecuteContinueReply()
return ERR_OK;
}
bool DSchedContinue::MakeCallerInfo(std::shared_ptr<ContinueAbilityData> data, CallerInfo &callerInfo) {
bool DSchedContinue::MakeCallerInfo(std::shared_ptr<ContinueAbilityData> data, CallerInfo &callerInfo)
{
callerInfo.sourceDeviceId = continueInfo_.sourceDeviceId_;
callerInfo.uid = data->callerUid;
callerInfo.accessToken = data->accessToken;
@ -765,7 +766,8 @@ bool DSchedContinue::MakeCallerInfo(std::shared_ptr<ContinueAbilityData> data, C
return true;
}
int32_t DSchedContinue::ExecuteContinueSend(std::shared_ptr<ContinueAbilityData> data) {
int32_t DSchedContinue::ExecuteContinueSend(std::shared_ptr<ContinueAbilityData> data)
{
HILOGI("ExecuteContinueSend start, continueInfo: %{public}s", continueInfo_.toString().c_str());
if (data == nullptr) {
return INVALID_PARAMETERS_ERR;

View File

@ -336,7 +336,8 @@ bool DistributedSchedPermission::GetTargetAbility(const AAFwk::Want& want,
}
bool DistributedSchedPermission::isSameAppIdOrDeveloperId(const CallerInfo &callerInfo,
AppExecFwk::AbilityInfo &targetAbility) {
AppExecFwk::AbilityInfo &targetAbility)
{
if (targetAbility.bundleName == callerInfo.callerBundleName &&
!BundleManagerInternal::IsSameAppId(callerInfo.callerAppId, targetAbility.bundleName)) {
HILOGE("the appId is different, check permission denied!");
@ -351,7 +352,8 @@ bool DistributedSchedPermission::isSameAppIdOrDeveloperId(const CallerInfo &call
}
int32_t DistributedSchedPermission::CheckGetCallerPermission(const AAFwk::Want& want, const CallerInfo& callerInfo,
const AccountInfo& accountInfo, AppExecFwk::AbilityInfo& targetAbility) {
const AccountInfo& accountInfo, AppExecFwk::AbilityInfo& targetAbility)
{
// 1.check account access permission in no account networking environment.
if (!CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName)) {
HILOGE("CheckAccountAccessPermission denied or failed!");

View File

@ -399,7 +399,8 @@ bool DmsBmStorage::GetDistributedBundleName(const std::string &networkId, const
}
bool DmsBmStorage::GetDistributedBundleInfo(const std::string &networkId,
const uint16_t &bundleNameId, DmsBundleInfo &distributeBundleInfo) {
const uint16_t &bundleNameId, DmsBundleInfo &distributeBundleInfo)
{
HILOGI("networkId: %{public}s bundleNameId: %{public}d", GetAnonymStr(networkId).c_str(), bundleNameId);
if (!CheckKvStore()) {
HILOGE("kvStore is nullptr");
@ -665,7 +666,8 @@ bool DmsBmStorage::RebuildLocalData()
DmsBundleInfo DmsBmStorage::ConvertToDistributedBundleInfo(const AppExecFwk::BundleInfo &bundleInfo,
AppExecFwk::AppProvisionInfo appProvisionInfo,
bool isPackageChange) {
bool isPackageChange)
{
DmsBundleInfo distributedBundleInfo;
if (bundleInfo.name == "") {
HILOGE("The bundleName is empty and does not require conversion!");
@ -736,7 +738,8 @@ int32_t DmsBmStorage::CloudSync()
return static_cast<int32_t>(status);
}
void DmsBmStorage::UpdateDistributedData() {
void DmsBmStorage::UpdateDistributedData()
{
HILOGI("called.");
auto bundleMgr = DmsBmStorage::GetInstance()->GetBundleMgr();
if (bundleMgr == nullptr) {

View File

@ -253,51 +253,58 @@ int32_t DMSContinueRecvMgr::RetryPostBroadcast(const std::string& senderNetworkI
}
bool DMSContinueRecvMgr::GetFinalBundleName(const std::string &senderNetworkId, uint8_t continueTypeId, DmsBundleInfo distributedBundleInfo,
std::string &finalBundleName, AppExecFwk::BundleInfo localBundleInfo, std::string& continueType) {
bool DMSContinueRecvMgr::GetFinalBundleName(const std::string &senderNetworkId, uint8_t continueTypeId,
DmsBundleInfo distributedBundleInfo,
std::string &finalBundleName, AppExecFwk::BundleInfo localBundleInfo,
std::string &continueType)
{
std::string bundleName = distributedBundleInfo.bundleName;
continueType = BundleManagerInternal::GetContinueType(senderNetworkId, bundleName, continueTypeId);
if (continueType.empty()) {
if (BundleManagerInternal::GetLocalBundleInfoV9(bundleName, localBundleInfo) == ERR_OK) {
finalBundleName = bundleName;
return true;
}else {
return false;
}
} else {
bool continueTypeGot = continueTypeCheck(distributedBundleInfo, continueType);
if (continueTypeGot && BundleManagerInternal::GetLocalBundleInfoV9(bundleName, localBundleInfo) == ERR_OK) {
finalBundleName = bundleName;
return true;
}
bool continueTypeGot = continueTypeCheck(distributedBundleInfo, continueType);
if (continueTypeGot && BundleManagerInternal::GetLocalBundleInfoV9(bundleName, localBundleInfo) == ERR_OK) {
finalBundleName = bundleName;
return true;
}
std::vector<std::string> bundleNameList;
bool continueBundleGot = BundleManagerInternal::GetContinueBundle4Src(bundleName, bundleNameList);
if (continueBundleGot) {
sptr<AppExecFwk::IBundleMgr> bundleMgr = BundleManagerInternal::GetBundleManager();
if (bundleMgr == nullptr) {
HILOGE("get bundle manager failed");
return false;
}
std::vector<std::string> bundleNameList;
bool continueBundleGot = BundleManagerInternal::GetContinueBundle4Src(bundleName, bundleNameList);
if (continueBundleGot) {
sptr<AppExecFwk::IBundleMgr> bundleMgr = BundleManagerInternal::GetBundleManager();
if (bundleMgr == nullptr) {
HILOGE("get bundle manager failed");
return false;
for (std::string &bundleNameItem: bundleNameList) {
continueType = BundleManagerInternal::GetContinueType(
senderNetworkId, bundleNameItem, continueTypeId);
if (continueType.empty() || !continueTypeCheck(distributedBundleInfo, continueType)
|| BundleManagerInternal::GetLocalBundleInfoV9(bundleNameItem, localBundleInfo) != ERR_OK) {
continue;
}
for (std::string &bundleNameItem: bundleNameList) {
continueType = BundleManagerInternal::GetContinueType(
senderNetworkId, bundleNameItem, continueTypeId);
if (continueType.empty() || !continueTypeCheck(distributedBundleInfo, continueType)
|| BundleManagerInternal::GetLocalBundleInfoV9(bundleNameItem, localBundleInfo) != ERR_OK) {
continue;
}
AppExecFwk::AppProvisionInfo appProvisionInfo;
if (bundleMgr->GetAppProvisionInfo(bundleNameItem, appProvisionInfo)
&& appProvisionInfo.developerId == distributedBundleInfo.developerId) {
finalBundleName = bundleNameItem;
return true;
}
AppExecFwk::AppProvisionInfo appProvisionInfo;
if (bundleMgr->GetAppProvisionInfo(bundleNameItem, appProvisionInfo)
&& appProvisionInfo.developerId == distributedBundleInfo.developerId) {
finalBundleName = bundleNameItem;
return true;
}
}
}
return false;
}
int32_t DMSContinueRecvMgr::DealOnBroadcastBusiness(const std::string &senderNetworkId,
uint16_t bundleNameId, uint8_t continueTypeId, const int32_t state,
const int32_t retry) {
const int32_t retry)
{
HILOGI("DealOnBroadcastBusiness start, senderNetworkId: %{public}s, bundleNameId: %{public}u, state: %{public}d.",
GetAnonymStr(senderNetworkId).c_str(), bundleNameId, state);
DmsBundleInfo distributedBundleInfo;
@ -318,7 +325,8 @@ int32_t DMSContinueRecvMgr::DealOnBroadcastBusiness(const std::string &senderNet
std::string finalBundleName;
AppExecFwk::BundleInfo localBundleInfo;
std::string continueType;
if (!GetFinalBundleName(senderNetworkId, continueTypeId, distributedBundleInfo, finalBundleName, localBundleInfo, continueType)) {
if (!GetFinalBundleName(senderNetworkId, continueTypeId,
distributedBundleInfo, finalBundleName, localBundleInfo, continueType)) {
HILOGE("The app is not installed on the local device.");
return INVALID_PARAMETERS_ERR;
}
@ -349,7 +357,8 @@ int32_t DMSContinueRecvMgr::DealOnBroadcastBusiness(const std::string &senderNet
}
bool DMSContinueRecvMgr::continueTypeCheck(const DmsBundleInfo &distributedBundleInfo,
const std::string &continueType) {
const std::string &continueType)
{
std::vector<DmsAbilityInfo> dmsAbilityInfos = distributedBundleInfo.dmsAbilityInfos;
bool continueTyoeGot = false;
for (const auto &abilityInfo: dmsAbilityInfos) {
@ -508,7 +517,8 @@ void DMSContinueRecvMgr::OnContinueSwitchOff()
eventHandler_->PostTask(func);
}
void DMSContinueRecvMgr::CleanContinueReadyCache(std::string senderNetworkId, std::string bundleName) {
void DMSContinueRecvMgr::CleanContinueReadyCache(std::string senderNetworkId, std::string bundleName)
{
auto itr = continueReady_.begin();
while (itr != continueReady_.end()) {
if (itr->sourceDeviceId_ == senderNetworkId && itr->sinkBundleName_ == bundleName) {