diff --git a/services/distributed_file.para b/services/distributed_file.para index 114ed94516da7e800ff66c7050d88bba65d83948..8feb36a638b4e67c930d9fa9a49283d98cd00f47 100644 --- a/services/distributed_file.para +++ b/services/distributed_file.para @@ -13,4 +13,5 @@ const.distributed_file_property.enabled=true +const.distributed_file_only_for_same_account_test=false diff --git a/services/distributedfiledaemon/BUILD.gn b/services/distributedfiledaemon/BUILD.gn index eb28773d252ad2e4b2b598a1ab07e6e8c75651c7..9eb3e42373d3cf238e6a9ae9ee2eefee6b996888 100755 --- a/services/distributedfiledaemon/BUILD.gn +++ b/services/distributedfiledaemon/BUILD.gn @@ -48,6 +48,7 @@ ohos_shared_library("libdistributedfiledaemon") { "os_account_standard:os_account_innerkits", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] configs = [ "${utils_path}:compiler_configs" ] diff --git a/services/distributedfiledaemon/include/device/device_manager_agent.h b/services/distributedfiledaemon/include/device/device_manager_agent.h index f777529be09c0e7148bf4fad25115377679aa223..27617ac03f75f3a50d67f2f15eb89765aa12b1c1 100644 --- a/services/distributedfiledaemon/include/device/device_manager_agent.h +++ b/services/distributedfiledaemon/include/device/device_manager_agent.h @@ -83,7 +83,7 @@ private: void UnregisterFromExternalDm(); void QueryRelatedGroups(const std::string &udid, const std::string &networkId); - bool CheckIsAuthGroup(const GroupInfo &group); + bool CheckIsAccountless(const GroupInfo &group); std::shared_ptr FindNetworkBaseTrustRelation(bool isAccountless); // We use a mutex instead of a shared_mutex to serialize online/offline procedures std::mutex mpToNetworksMutex_; diff --git a/services/distributedfiledaemon/src/device/device_manager_agent.cpp b/services/distributedfiledaemon/src/device/device_manager_agent.cpp index 23689c6c13671c98a622a5d0e54af0528ad8d487..2921acb4f2c625e807c11fed5ad10448d902378c 100644 --- a/services/distributedfiledaemon/src/device/device_manager_agent.cpp +++ b/services/distributedfiledaemon/src/device/device_manager_agent.cpp @@ -26,6 +26,7 @@ #include "softbus_bus_center.h" #include "utils_exception.h" #include "utils_log.h" +#include "parameters.h" namespace OHOS { namespace Storage { @@ -34,6 +35,7 @@ namespace { constexpr int MAX_RETRY_COUNT = 7; constexpr int PEER_TO_PEER_GROUP = 256; constexpr int ACROSS_ACCOUNT_AUTHORIZE_GROUP = 1282; +const std::string SAME_ACCOUNT_MARK = "const.distributed_file_only_for_same_account_test"; } // namespace using namespace std; @@ -256,7 +258,7 @@ void DeviceManagerAgent::QueryRelatedGroups(const std::string &udid, const std:: unique_lock lock(mpToNetworksMutex_); for (const auto &group : groupList) { - if (CheckIsAuthGroup(group)) { + if (CheckIsAccountless(group)) { cidNetTypeRecord_.insert({ networkId, FindNetworkBaseTrustRelation(true) }); } else { cidNetTypeRecord_.insert({ networkId, FindNetworkBaseTrustRelation(false) }); @@ -266,8 +268,17 @@ void DeviceManagerAgent::QueryRelatedGroups(const std::string &udid, const std:: return; } -bool DeviceManagerAgent::CheckIsAuthGroup(const GroupInfo &group) +bool DeviceManagerAgent::CheckIsAccountless(const GroupInfo &group) { + // because of there no same_account, only for test, del later + LOGI("SAME_ACCOUNT_MARK val is %{public}d", system::GetBoolParameter(SAME_ACCOUNT_MARK, false)); + if (system::GetBoolParameter(SAME_ACCOUNT_MARK, false) == true) { // isaccountless == false + LOGI("SAME_ACCOUNT_MARK val is true(same account)"); + return false; + } else { // isaccountless == true + return true; + } + if (group.groupType == PEER_TO_PEER_GROUP || group.groupType == ACROSS_ACCOUNT_AUTHORIZE_GROUP) { return true; } diff --git a/services/distributedfiledaemon/test/unittest/BUILD.gn b/services/distributedfiledaemon/test/unittest/BUILD.gn index 5b8cf02272d9309d59f008c8257a5051e8141480..eaa7641fda57269fc6c5c721800cbf5b8c253203 100644 --- a/services/distributedfiledaemon/test/unittest/BUILD.gn +++ b/services/distributedfiledaemon/test/unittest/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("DeviceManagerAgentTest") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] defines = [ "private=public" ] diff --git a/test/moduletest/BUILD.gn b/test/moduletest/BUILD.gn index 0d88bc1e0a930622d6b4e07fd6c79b12b2198652..ca23fabc3935b713faf21fdb026a547dc0c46b0a 100644 --- a/test/moduletest/BUILD.gn +++ b/test/moduletest/BUILD.gn @@ -72,5 +72,6 @@ ohos_moduletest("DistributedFileDaemonServiceTest") { "os_account_standard:os_account_innerkits", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", + "startup_l2:syspara", ] }