From 5eaa92ee65b11ada76a95462b1f0f84c9e28c9bf Mon Sep 17 00:00:00 2001 From: lvyuanyuan Date: Mon, 4 Dec 2023 14:36:07 +0800 Subject: [PATCH] mod device manager quote Signed-off-by: lvyuanyuan Change-Id: Ic1a064051a105a57dc75307ac2b9094365955941 --- interfaces/innerkits/native/BUILD.gn | 6 +++++- .../remote_file_share/src/remote_file_share.cpp | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/native/BUILD.gn b/interfaces/innerkits/native/BUILD.gn index bc2f205ea..3287bf74f 100644 --- a/interfaces/innerkits/native/BUILD.gn +++ b/interfaces/innerkits/native/BUILD.gn @@ -121,10 +121,14 @@ ohos_shared_library("remote_file_share_native") { external_deps = [ "ability_base:zuri", "c_utils:utils", - "device_manager:devicemanagersdk", "hilog:libhilog", ] + if (defined(global_parts_info) && defined(global_parts_info.device_manager)) { + external_deps += [ "device_manager:devicemanagersdk" ] + defines = [ "ENABLE_DEVICE_MANAGER" ] + } + innerapi_tags = [ "platformsdk_indirect" ] part_name = "app_file_service" subsystem_name = "filemanagement" diff --git a/interfaces/innerkits/native/remote_file_share/src/remote_file_share.cpp b/interfaces/innerkits/native/remote_file_share/src/remote_file_share.cpp index 7911c4620..362800abe 100644 --- a/interfaces/innerkits/native/remote_file_share/src/remote_file_share.cpp +++ b/interfaces/innerkits/native/remote_file_share/src/remote_file_share.cpp @@ -24,8 +24,10 @@ #include #include "log.h" +#ifdef ENABLE_DEVICE_MANAGER #include "device_manager.h" #include "device_manager_callback.h" +#endif #include "sandbox_helper.h" #include "securec.h" #include "uri.h" @@ -33,7 +35,9 @@ namespace OHOS { namespace AppFileService { namespace ModuleRemoteFileShare { +#ifdef ENABLE_DEVICE_MANAGER using namespace OHOS::DistributedHardware; +#endif namespace { const int HMDFS_CID_SIZE = 64; const int USER_ID_INIT = 100; @@ -72,12 +76,14 @@ struct HmdfsDstInfo { uint64_t size; }; +#ifdef ENABLE_DEVICE_MANAGER class InitDMCallback : public DmInitCallback { public: InitDMCallback() = default; ~InitDMCallback() override = default; void OnRemoteDied() override {}; }; +#endif static std::string GetProcessName() { @@ -302,6 +308,9 @@ static void InitHmdfsInfo(struct HmdfsDstInfo &hdi, const std::string &physicalP static std::string GetLocalNetworkId() { + const std::string LOCAL = "local"; + std::string networkId = LOCAL; + #ifdef ENABLE_DEVICE_MANAGER auto callback = std::make_shared(); int32_t ret = DeviceManager::GetInstance().InitDeviceManager(PACKAGE_NAME, callback); if (ret != 0) { @@ -310,11 +319,12 @@ static std::string GetLocalNetworkId() DmDeviceInfo info; ret = DeviceManager::GetInstance().GetLocalDeviceInfo(PACKAGE_NAME, info); - auto networkId = std::string(info.networkId); + networkId = std::string(info.networkId); LOGD("GetLocalNetworkId :%{private}s", networkId.c_str()); if (ret != 0 || networkId.empty()) { return ""; } + #endif return networkId; } -- Gitee