diff --git a/0001-cut-access_token-common_event-ability.patch b/0001-cut-access_token-common_event-ability.patch new file mode 100644 index 0000000000000000000000000000000000000000..f32684d01e4536ba6fb0f20364cb2d197fef19f6 --- /dev/null +++ b/0001-cut-access_token-common_event-ability.patch @@ -0,0 +1,351 @@ +From 00ecd978bb1a86affa333a4a2cc67db8d49c8113 Mon Sep 17 00:00:00 2001 +From: heppen +Date: Mon, 19 Jun 2023 22:41:56 +0800 +Subject: [PATCH] cut access_token, common_event, ability + +--- + services/distributedfiledaemon/BUILD.gn | 6 ++- + .../include/multiuser/os_account_observer.h | 12 ++--- + .../src/device/device_manager_agent.cpp | 8 ++-- + .../distributedfiledaemon/src/ipc/daemon.cpp | 35 +++++++------- + .../src/multiuser/os_account_observer.cpp | 47 +++++++++---------- + .../src/network/kernel_talker.cpp | 2 +- + .../src/network/network_agent_template.cpp | 6 +-- + .../src/network/softbus/softbus_agent.cpp | 2 +- + utils/BUILD.gn | 2 +- + utils/system/src/utils_directory.cpp | 1 + + 10 files changed, 62 insertions(+), 59 deletions(-) + +diff --git a/services/distributedfiledaemon/BUILD.gn b/services/distributedfiledaemon/BUILD.gn +index ea0db9b..60f1696 100644 +--- a/services/distributedfiledaemon/BUILD.gn ++++ b/services/distributedfiledaemon/BUILD.gn +@@ -19,6 +19,8 @@ ohos_shared_library("libdistributedfiledaemon") { + "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include", + "//base/security/device_auth/interfaces/innerkits", + "//third_party/json/include", ++ "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", ++ "//foundation/systemabilitymgr/samgr/interfaces/innerkits/common/include", + ] + + sources = [ +@@ -39,13 +41,13 @@ ohos_shared_library("libdistributedfiledaemon") { + ] + + deps = [ ++ "//third_party/bounds_checking_function:libsec_shared", + "${utils_path}:libdistributedfileutils", + "//base/security/device_auth/services:deviceauth_sdk", + "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk", + ] + external_deps = [ +- "ability_base:want", +- "common_event_service:cesfwk_innerkits", ++ # "common_event_service:cesfwk_innerkits", + "dataclassification:data_transit_mgr", + "dsoftbus:softbus_client", + "init:libbegetutil", +diff --git a/services/distributedfiledaemon/include/multiuser/os_account_observer.h b/services/distributedfiledaemon/include/multiuser/os_account_observer.h +index aabb010..6611e1f 100644 +--- a/services/distributedfiledaemon/include/multiuser/os_account_observer.h ++++ b/services/distributedfiledaemon/include/multiuser/os_account_observer.h +@@ -20,21 +20,21 @@ + #include + #include + +-#include "common_event_subscribe_info.h" +-#include "common_event_subscriber.h" ++// #include "common_event_subscribe_info.h" ++// #include "common_event_subscriber.h" + #include "mountpoint/mount_point.h" + + namespace OHOS { + namespace Storage { + namespace DistributedFile { + static constexpr int MOUNT_POINT_NUM = 2; +-class OsAccountObserver final : public EventFwk::CommonEventSubscriber { ++class OsAccountObserver { + public: +- OsAccountObserver() = default; ++ // OsAccountObserver() = default; + ~OsAccountObserver(); +- explicit OsAccountObserver(const EventFwk::CommonEventSubscribeInfo &subscribeInfo); ++ explicit OsAccountObserver(); + +- virtual void OnReceiveEvent(const EventFwk::CommonEventData &eventData) override; ++ // virtual void OnReceiveEvent(const EventFwk::CommonEventData &eventData) override; + private: + void RemoveMPInfo(const int id); + void AddMPInfo(const int id, const std::string &relativePath); +diff --git a/services/distributedfiledaemon/src/device/device_manager_agent.cpp b/services/distributedfiledaemon/src/device/device_manager_agent.cpp +index 2947a60..0b4e312 100644 +--- a/services/distributedfiledaemon/src/device/device_manager_agent.cpp ++++ b/services/distributedfiledaemon/src/device/device_manager_agent.cpp +@@ -128,7 +128,7 @@ void DeviceManagerAgent::OfflineAllDevice() + unique_lock lock(mpToNetworksMutex_); + for (auto [ignore, net] : cidNetTypeRecord_) { + auto cmd = make_unique>(&NetworkAgentTemplate::DisconnectAllDevices); +- net->Recv(move(cmd)); ++ net->Recv(std::move(cmd)); + } + } + +@@ -140,7 +140,7 @@ void DeviceManagerAgent::ReconnectOnlineDevices() + cmd->UpdateOption({ + .tryTimes_ = MAX_RETRY_COUNT, + }); +- net->Recv(move(cmd)); ++ net->Recv(std::move(cmd)); + } + } + +@@ -177,7 +177,7 @@ void DeviceManagerAgent::OnDeviceOnline(const DistributedHardware::DmDeviceInfo + auto cmd = + make_unique>(&NetworkAgentTemplate::ConnectDeviceAsync, info); + cmd->UpdateOption({.tryTimes_ = MAX_RETRY_COUNT}); +- networkAgent->Recv(move(cmd)); ++ networkAgent->Recv(std::move(cmd)); + + LOGI("OnDeviceOnline end"); + } +@@ -196,7 +196,7 @@ void DeviceManagerAgent::OnDeviceOffline(const DistributedHardware::DmDeviceInfo + + auto cmd = + make_unique>(&NetworkAgentTemplate::DisconnectDevice, info); +- networkAgent->Recv(move(cmd)); ++ networkAgent->Recv(std::move(cmd)); + cidNetTypeRecord_.erase(info.cid_); + LOGI("OnDeviceOffline end"); + } +diff --git a/services/distributedfiledaemon/src/ipc/daemon.cpp b/services/distributedfiledaemon/src/ipc/daemon.cpp +index 194fb0d..5819b1d 100644 +--- a/services/distributedfiledaemon/src/ipc/daemon.cpp ++++ b/services/distributedfiledaemon/src/ipc/daemon.cpp +@@ -18,8 +18,8 @@ + #include + #include + +-#include "common_event_manager.h" +-#include "common_event_support.h" ++// #include "common_event_manager.h" ++// #include "common_event_support.h" + #include "iremote_object.h" + #include "mountpoint/mount_manager.h" + #include "system_ability_definition.h" +@@ -47,14 +47,14 @@ void Daemon::PublishSA() + + void Daemon::RegisterOsAccount() + { +- EventFwk::MatchingSkills matchingSkills; +- matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED); +- EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills); +- subScriber_ = std::make_shared(subscribeInfo); +- bool subRet = EventFwk::CommonEventManager::SubscribeCommonEvent(subScriber_); +- if (!subRet) { +- LOGE("Subscribe common event failed"); +- } ++ // EventFwk::MatchingSkills matchingSkills; ++ // matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED); ++ // EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills); ++ subScriber_ = std::make_shared(); ++ // bool subRet = EventFwk::CommonEventManager::SubscribeCommonEvent(subScriber_); ++ // if (!subRet) { ++ // LOGE("Subscribe common event failed"); ++ // } + } + + void Daemon::OnStart() +@@ -67,7 +67,8 @@ void Daemon::OnStart() + + try { + PublishSA(); +- AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); ++ // AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); ++ AddSystemAbilityListener(FILEMANAGEMENT_DISTRIBUTED_FILE_DAEMON_SA_ID); + } catch (const exception &e) { + LOGE("%{public}s", e.what()); + } +@@ -81,10 +82,10 @@ void Daemon::OnStop() + LOGI("Begin to stop"); + state_ = ServiceRunningState::STATE_NOT_START; + registerToService_ = false; +- bool subRet = EventFwk::CommonEventManager::UnSubscribeCommonEvent(subScriber_); +- if (!subRet) { +- LOGE("UnSubscribe common event failed"); +- } ++ // bool subRet = EventFwk::CommonEventManager::UnSubscribeCommonEvent(subScriber_); ++ // if (!subRet) { ++ // LOGE("UnSubscribe common event failed"); ++ // } + subScriber_ = nullptr; + LOGI("Stop finished successfully"); + } +@@ -109,8 +110,8 @@ void Daemon::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &d + return; + } + +- bool subscribeResult = EventFwk::CommonEventManager::UnSubscribeCommonEvent(subScriber_); +- LOGI("Daemon::OnRemoveSystemAbility subscribeResult = %{public}d", subscribeResult); ++ // bool subscribeResult = EventFwk::CommonEventManager::UnSubscribeCommonEvent(subScriber_); ++ LOGI("Daemon::OnRemoveSystemAbility"); + subScriber_ = nullptr; + } + +diff --git a/services/distributedfiledaemon/src/multiuser/os_account_observer.cpp b/services/distributedfiledaemon/src/multiuser/os_account_observer.cpp +index 198d1cd..776c7e5 100644 +--- a/services/distributedfiledaemon/src/multiuser/os_account_observer.cpp ++++ b/services/distributedfiledaemon/src/multiuser/os_account_observer.cpp +@@ -15,8 +15,8 @@ + + #include "multiuser/os_account_observer.h" + +-#include "common_event_manager.h" +-#include "common_event_support.h" ++// #include "common_event_manager.h" ++// #include "common_event_support.h" + #include "device/device_manager_agent.h" + #include "dfsu_mount_argument_descriptors.h" + #include "utils_log.h" +@@ -31,8 +31,7 @@ static const std::string ACCOUNT_LESS = "non_account"; + static constexpr int DEFAULT_ACCOUNT = 100; + } // namespace + +-OsAccountObserver::OsAccountObserver(const EventFwk::CommonEventSubscribeInfo &subscribeInfo) +- : EventFwk::CommonEventSubscriber(subscribeInfo) ++OsAccountObserver::OsAccountObserver() + { + LOGI("init first to create network of default user"); + lock_guard lock(serializer_); +@@ -54,27 +53,27 @@ void OsAccountObserver::AddMPInfo(const int id, const std::string &relativePath) + mountPoints_[id].emplace_back(smp); + } + +-void OsAccountObserver::OnReceiveEvent(const EventFwk::CommonEventData &eventData) +-{ +- const AAFwk::Want& want = eventData.GetWant(); +- std::string action = want.GetAction(); +- LOGI("AccountSubscriber: OnReceiveEvent action:%{public}s.", action.c_str()); +- if (action == EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED) { +- int32_t id = eventData.GetCode(); +- LOGI("user id changed to %{public}d", id); +- lock_guard lock(serializer_); +- if (curUsrId != -1 && curUsrId != id) { +- // first stop curUsrId network +- RemoveMPInfo(curUsrId); +- } ++// void OsAccountObserver::OnReceiveEvent(const EventFwk::CommonEventData &eventData) ++// { ++// const AAFwk::Want& want = eventData.GetWant(); ++// std::string action = want.GetAction(); ++// LOGI("AccountSubscriber: OnReceiveEvent action:%{public}s.", action.c_str()); ++// if (action == EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED) { ++// int32_t id = eventData.GetCode(); ++// LOGI("user id changed to %{public}d", id); ++// lock_guard lock(serializer_); ++// if (curUsrId != -1 && curUsrId != id) { ++// // first stop curUsrId network ++// RemoveMPInfo(curUsrId); ++// } + +- // then start new network +- curUsrId = id; +- AddMPInfo(id, SAME_ACCOUNT); +- AddMPInfo(id, ACCOUNT_LESS); +- LOGI("user id %{public}d, add network done", curUsrId); +- } +-} ++// // then start new network ++// curUsrId = id; ++// AddMPInfo(id, SAME_ACCOUNT); ++// AddMPInfo(id, ACCOUNT_LESS); ++// LOGI("user id %{public}d, add network done", curUsrId); ++// } ++// } + + void OsAccountObserver::RemoveMPInfo(const int id) + { +diff --git a/services/distributedfiledaemon/src/network/kernel_talker.cpp b/services/distributedfiledaemon/src/network/kernel_talker.cpp +index 6228e23..bb53d50 100644 +--- a/services/distributedfiledaemon/src/network/kernel_talker.cpp ++++ b/services/distributedfiledaemon/src/network/kernel_talker.cpp +@@ -95,7 +95,7 @@ void KernelTalker::SinkSessionTokernel(shared_ptr session) + } + SetCmd(cmd); + +- DevslDispatcher::DevslGetRegister(cid, shared_from_this()); ++ // DevslDispatcher::DevslGetRegister(cid, shared_from_this()); + } + + void KernelTalker::SinkDevslTokernel(const std::string &cid, uint32_t devsl) +diff --git a/services/distributedfiledaemon/src/network/network_agent_template.cpp b/services/distributedfiledaemon/src/network/network_agent_template.cpp +index 1b81ed0..7068334 100644 +--- a/services/distributedfiledaemon/src/network/network_agent_template.cpp ++++ b/services/distributedfiledaemon/src/network/network_agent_template.cpp +@@ -57,7 +57,7 @@ void NetworkAgentTemplate::ConnectOnlineDevices() + auto cmd = make_unique>( + &NetworkAgentTemplate::ConnectDeviceAsync, info); + cmd->UpdateOption({.tryTimes_ = MAX_RETRY_COUNT}); +- Recv(move(cmd)); ++ Recv(std::move(cmd)); + } + } + +@@ -83,7 +83,7 @@ void NetworkAgentTemplate::AcceptSession(shared_ptr session) + auto cmd = make_unique>>( + &NetworkAgentTemplate::AcceptSessionInner, session); + cmd->UpdateOption({.tryTimes_ = 1}); +- Recv(move(cmd)); ++ Recv(std::move(cmd)); + } + + void NetworkAgentTemplate::AcceptSessionInner(shared_ptr session) +@@ -98,7 +98,7 @@ void NetworkAgentTemplate::GetSessionProcess(NotifyParam ¶m) + auto cmd = make_unique>( + &NetworkAgentTemplate::GetSessionProcessInner, param); + cmd->UpdateOption({.tryTimes_ = 1}); +- Recv(move(cmd)); ++ Recv(std::move(cmd)); + } + + void NetworkAgentTemplate::GetSessionProcessInner(NotifyParam param) +diff --git a/services/distributedfiledaemon/src/network/softbus/softbus_agent.cpp b/services/distributedfiledaemon/src/network/softbus/softbus_agent.cpp +index efd334b..44bdf10 100644 +--- a/services/distributedfiledaemon/src/network/softbus/softbus_agent.cpp ++++ b/services/distributedfiledaemon/src/network/softbus/softbus_agent.cpp +@@ -143,7 +143,7 @@ int SoftbusAgent::OnSessionOpened(const int sessionId, const int result) + auto cmd = make_unique>( + &NetworkAgentTemplate::ConnectDeviceAsync, info); + cmd->UpdateOption({.tryTimes_ = 1}); +- Recv(move(cmd)); ++ Recv(std::move(cmd)); + } else { + LOGE("Exceeded the maximum number of retries, not retry"); + } +diff --git a/utils/BUILD.gn b/utils/BUILD.gn +index 87f35b1..5fd75e7 100644 +--- a/utils/BUILD.gn ++++ b/utils/BUILD.gn +@@ -15,7 +15,7 @@ import("//build/ohos.gni") + import("//foundation/filemanagement/dfs_service/distributedfile.gni") + + config("compiler_configs") { +- visibility = [ ":*" ] ++ visibility = [ "*" ] + + cflags = [ + "-Wall", +diff --git a/utils/system/src/utils_directory.cpp b/utils/system/src/utils_directory.cpp +index 463f133..cf216cd 100644 +--- a/utils/system/src/utils_directory.cpp ++++ b/utils/system/src/utils_directory.cpp +@@ -18,6 +18,7 @@ + #include + #include + #include ++#include + + #include "directory_ex.h" + +-- +2.33.0 + diff --git a/dfs_service.spec b/dfs_service.spec new file mode 100644 index 0000000000000000000000000000000000000000..abdaeb7648d43a0ebfb9b3d906a9665ab174d49b --- /dev/null +++ b/dfs_service.spec @@ -0,0 +1,61 @@ +%define debug_package %{nil} +%global openHarmony_source_release OpenHarmony-v3.2-Release +%global dfs_service_dir %{_builddir}/foundation/filemanagement +%global build_opt /opt/distributed-middleware-build + +Name: dfs_service +Version: 1.0.0 +Release: 1 +Summary: The distributed file service. +License: Apache License 2.0 +Url: https://gitee.com/openharmony/filemanagement_dfs_service +Source0: https://gitee.com/openharmony/filemanagement_dfs_service/repository/archive/%{openHarmony_source_release}.tar.gz #/filemanagement_dfs_service-%{openHarmony_source_release}.tar.gz +Patch0: 0001-cut-access_token-common_event-ability.patch + +BuildRequires: distributed-build, libboundscheck, libatomic, distributed-utils +Requires: libboundscheck, libatomic, distributed-utils + +%description +The distributed file service provides cross -device access capabilities that meet the POSIX specifications. + +%prep +#clean %{_builddir} +rm -rf %{_builddir}/* + +# build directory +cd %{_builddir} +cp -rp %{build_opt} %{_builddir}/build +[ ! -L "%{_builddir}/build.sh" ] && ln -s %{_builddir}/build/build_scripts/build.sh %{_builddir}/build.sh +[ ! -L "%{_builddir}/.gn" ] && ln -s %{_builddir}/build/core/gn/dotfile.gn %{_builddir}/.gn +[ ! -L "%{_builddir}/build.py" ] && ln -s %{_builddir}/build/lite/build.py %{_builddir}/build.py +cp -r %{_builddir}/build/openeuler/vendor %{_builddir}/ +cp -r %{_builddir}/build/openeuler/compiler_gn/* %{_builddir}/ + +%setup -q -T -a 0 -c -n %{dfs_service_dir} +%patch0 -p1 -d %{dfs_service_dir}/dfs_service + + +%build +cd %{_builddir} +rm -rf %{_builddir}/out + +%ifarch x86_64 +./build.sh --product-name openeuler --target-cpu x86_64 +%endif + +%ifarch aarch64 +./build.sh --product-name openeuler --target-cpu arm64 +%endif + +%install +install -d %{buildroot}/%{_libdir} + +# prepare so +install -m 0755 %{_builddir}/out/openeuler/packages/phone/system/lib64/libdistributedfile*.so %{buildroot}/%{_libdir} + +%files +%{_libdir}/*.so + +%changelog +* Sun Jun 18 2023 hepeng - 1.0.0-1 +- Cut access_token, common_event, ability. diff --git a/filemanagement_dfs_service-OpenHarmony-v3.2-Release.tar.gz b/filemanagement_dfs_service-OpenHarmony-v3.2-Release.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..948ee572d274e43adfdb873ec06947c9390fcef8 Binary files /dev/null and b/filemanagement_dfs_service-OpenHarmony-v3.2-Release.tar.gz differ