352 lines
14 KiB
Diff
352 lines
14 KiB
Diff
From 00ecd978bb1a86affa333a4a2cc67db8d49c8113 Mon Sep 17 00:00:00 2001
|
|
From: heppen <hepeng68@huawei.com>
|
|
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 <mutex>
|
|
#include <vector>
|
|
|
|
-#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<mutex> lock(mpToNetworksMutex_);
|
|
for (auto [ignore, net] : cidNetTypeRecord_) {
|
|
auto cmd = make_unique<DfsuCmd<NetworkAgentTemplate>>(&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<DfsuCmd<NetworkAgentTemplate, const DeviceInfo>>(&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<DfsuCmd<NetworkAgentTemplate, const DeviceInfo>>(&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 <exception>
|
|
#include <stdexcept>
|
|
|
|
-#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<OsAccountObserver>(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<OsAccountObserver>();
|
|
+ // 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<mutex> 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<mutex> 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<mutex> 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<BaseSession> 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<DfsuCmd<NetworkAgentTemplate, const DeviceInfo>>(
|
|
&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<BaseSession> session)
|
|
auto cmd = make_unique<DfsuCmd<NetworkAgentTemplate, shared_ptr<BaseSession>>>(
|
|
&NetworkAgentTemplate::AcceptSessionInner, session);
|
|
cmd->UpdateOption({.tryTimes_ = 1});
|
|
- Recv(move(cmd));
|
|
+ Recv(std::move(cmd));
|
|
}
|
|
|
|
void NetworkAgentTemplate::AcceptSessionInner(shared_ptr<BaseSession> session)
|
|
@@ -98,7 +98,7 @@ void NetworkAgentTemplate::GetSessionProcess(NotifyParam ¶m)
|
|
auto cmd = make_unique<DfsuCmd<NetworkAgentTemplate, NotifyParam>>(
|
|
&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<DfsuCmd<NetworkAgentTemplate, const DeviceInfo>>(
|
|
&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 <sys/types.h>
|
|
#include <unistd.h>
|
|
#include <system_error>
|
|
+#include <functional>
|
|
|
|
#include "directory_ex.h"
|
|
|
|
--
|
|
2.33.0
|
|
|