From 6221a103bdf77ce5db3abb62dd7c7067a274bf4d Mon Sep 17 00:00:00 2001 From: wangyb0625 Date: Thu, 30 Jun 2022 10:46:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86=E6=84=8F?= =?UTF-8?q?=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyb0625 --- .../include/softbus/softbus_listener.h | 1 - .../service/src/device_manager_service.cpp | 5 +-- .../service/src/softbus/softbus_listener.cpp | 38 ------------------- utils/include/dfx/lite/dm_hidumper.h | 2 +- utils/include/dfx/standard/dm_hidumper.h | 3 +- utils/src/dfx/lite/dm_hidumper.cpp | 2 +- utils/src/dfx/standard/dm_hidumper.cpp | 21 ++++------ 7 files changed, 13 insertions(+), 59 deletions(-) diff --git a/services/service/include/softbus/softbus_listener.h b/services/service/include/softbus/softbus_listener.h index ce039152..526a6917 100644 --- a/services/service/include/softbus/softbus_listener.h +++ b/services/service/include/softbus/softbus_listener.h @@ -101,7 +101,6 @@ public: ~SoftbusListener(); int32_t GetTrustedDeviceList(std::vector &deviceInfoList); int32_t GetLocalDeviceInfo(DmDeviceInfo &deviceInfo); - bool IsDeviceOnline(const std::string &deviceId); private: int32_t Init(); diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp index 7c1de2c6..8a9a802f 100644 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -286,10 +286,9 @@ int32_t DeviceManagerService::DmHiDumper(const std::vector& args, s LOGE("HiDumpHelper GetTrustedDeviceList failed"); return ERR_DM_FAILED; } - bool deviceState = false; + for (unsigned int j = 0; j < deviceList.size(); j++) { - deviceState = softbusListener_->IsDeviceOnline(deviceList[j].deviceId); - HiDumpHelper::GetInstance().SetNodeInfo(deviceList[j], deviceState); + HiDumpHelper::GetInstance().SetNodeInfo(deviceList[j]); LOGI("DeviceManagerService::DmHiDumper SetNodeInfo."); } } diff --git a/services/service/src/softbus/softbus_listener.cpp b/services/service/src/softbus/softbus_listener.cpp index ea141118..e4b5c5e1 100644 --- a/services/service/src/softbus/softbus_listener.cpp +++ b/services/service/src/softbus/softbus_listener.cpp @@ -175,44 +175,6 @@ int32_t SoftbusListener::GetTrustedDeviceList(std::vector &deviceI return DM_OK; } -bool SoftbusListener::IsDeviceOnline(const std::string &deviceId) -{ - NodeBasicInfo *info = nullptr; - int32_t infoNum = 0; - if (GetAllNodeDeviceInfo(DM_PKG_NAME.c_str(), &info, &infoNum) != DM_OK) { - LOGE("GetAllNodeDeviceInfo failed"); - return false; - } - bool bDeviceOnline = false; - for (int32_t i = 0; i < infoNum; ++i) { - NodeBasicInfo *nodeBasicInfo = info + i; - if (nodeBasicInfo == nullptr) { - LOGE("nodeBasicInfo is empty for index %d, infoNum %d.", i, infoNum); - continue; - } - std::string networkId = nodeBasicInfo->networkId; - if (networkId == deviceId) { - LOGI("DM_IsDeviceOnLine device %s online", GetAnonyString(deviceId).c_str()); - bDeviceOnline = true; - break; - } - uint8_t udid[UDID_BUF_LEN] = {0}; - int32_t ret = GetNodeKeyInfo(DM_PKG_NAME.c_str(), networkId.c_str(), NodeDeviceInfoKey::NODE_KEY_UDID, udid, - sizeof(udid)); - if (ret != DM_OK) { - LOGE("DM_IsDeviceOnLine GetNodeKeyInfo failed"); - break; - } - if (strcmp((char *)udid, deviceId.c_str()) == 0) { - LOGI("DM_IsDeviceOnLine device %s online", GetAnonyString(deviceId).c_str()); - bDeviceOnline = true; - break; - } - } - FreeNodeInfo(info); - return bDeviceOnline; -} - int32_t SoftbusListener::GetLocalDeviceInfo(DmDeviceInfo &deviceInfo) { LOGI("SoftbusListener::GetLocalDeviceInfo start"); diff --git a/utils/include/dfx/lite/dm_hidumper.h b/utils/include/dfx/lite/dm_hidumper.h index 298d6154..559af335 100644 --- a/utils/include/dfx/lite/dm_hidumper.h +++ b/utils/include/dfx/lite/dm_hidumper.h @@ -35,7 +35,7 @@ class HiDumpHelper { public: int32_t HiDump(const std::vector& args, std::string &result); int32_t GetArgsType(const std::vector& args, std::vector &Flag); - void SetNodeInfo(const DmDeviceInfo& deviceInfo, const bool deviceStates); + void SetNodeInfo(const DmDeviceInfo& deviceInfo); }; } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/include/dfx/standard/dm_hidumper.h b/utils/include/dfx/standard/dm_hidumper.h index dc1bf5b4..cf866ef8 100644 --- a/utils/include/dfx/standard/dm_hidumper.h +++ b/utils/include/dfx/standard/dm_hidumper.h @@ -34,7 +34,7 @@ DECLARE_SINGLE_INSTANCE(HiDumpHelper); public: int32_t HiDump(const std::vector& args, std::string &result); int32_t GetArgsType(const std::vector& args, std::vector &Flag); - void SetNodeInfo(const DmDeviceInfo& deviceInfo, const bool deviceStates); + void SetNodeInfo(const DmDeviceInfo& deviceInfo); private: int32_t ProcessDump(const HidumperFlag &flag, std::string &result); @@ -44,7 +44,6 @@ private: private: std::vector nodeInfos_; - std::vector deviceState_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/utils/src/dfx/lite/dm_hidumper.cpp b/utils/src/dfx/lite/dm_hidumper.cpp index ca6ab992..b6aff1c8 100644 --- a/utils/src/dfx/lite/dm_hidumper.cpp +++ b/utils/src/dfx/lite/dm_hidumper.cpp @@ -28,7 +28,7 @@ int32_t HiDumpHelper::GetArgsType(const std::vector& args, std::vec return DM_OK; } -void HiDumpHelper::SetNodeInfo(const DmDeviceInfo& deviceInfo, const bool deviceStates) +void HiDumpHelper::SetNodeInfo(const DmDeviceInfo& deviceInfo) { return; } diff --git a/utils/src/dfx/standard/dm_hidumper.cpp b/utils/src/dfx/standard/dm_hidumper.cpp index fc72bef1..78b989e1 100644 --- a/utils/src/dfx/standard/dm_hidumper.cpp +++ b/utils/src/dfx/standard/dm_hidumper.cpp @@ -41,15 +41,10 @@ int32_t HiDumpHelper::HiDump(const std::vector& args, std::string & return errCode; } -void HiDumpHelper::SetNodeInfo(const DmDeviceInfo& deviceInfo, const bool deviceStates) +void HiDumpHelper::SetNodeInfo(const DmDeviceInfo& deviceInfo) { LOGI("HiDumpHelper::SetNodeInfo"); nodeInfos_.push_back(deviceInfo); - std::string deviceState = "offline"; - if (deviceStates) { - deviceState = "online"; - } - deviceState_.push_back(deviceState); } int32_t HiDumpHelper::ProcessDump(const HidumperFlag &flag, std::string &result) @@ -75,18 +70,18 @@ int32_t HiDumpHelper::ProcessDump(const HidumperFlag &flag, std::string &result) int32_t HiDumpHelper::ShowAllLoadTrustedList(std::string &result) { - LOGI("Dump Show All Load Trust List"); + LOGI("dump all trusted device List"); int32_t ret = DM_OK; if (nodeInfos_.size() == 0) { - LOGE("Hidumper get trusted list is empty"); - result.append("Hidumper get trusted list is empty"); + LOGE("dump trusted device list is empty"); + result.append("dump trusted device list is empty"); } for (unsigned int i = 0; i < nodeInfos_.size(); ++i) { result.append("\n{\n deviceId : ").append(GetAnonyString(nodeInfos_[i].deviceId).c_str()); result.append("\n{\n deviceName : ").append(nodeInfos_[i].deviceName); result.append("\n{\n networkId : ").append(GetAnonyString(nodeInfos_[i].networkId).c_str()); - result.append("\n{\n deviceState : ").append(deviceState_[i]); + result.append("\n{\n deviceTypeId : ").append(std::to_string(nodeInfos_[i].deviceTypeId)); } nodeInfos_.clear(); @@ -99,9 +94,9 @@ int32_t HiDumpHelper::ShowHelp(std::string &result) LOGI("Show hidumper help"); result.append("DistributedHardwareDeviceManager hidumper options:\n"); result.append(" -help "); - result.append(": Show help\n"); + result.append(": show help\n"); result.append(" -getTrustlist "); - result.append(": Show all get trusted list:\n\n"); + result.append(": show all get trusted list:\n\n"); LOGI("result is %s", result.c_str()); return DM_OK; } @@ -110,7 +105,7 @@ int32_t HiDumpHelper::ShowIllealInfomation(std::string &result) { LOGI("ShowIllealInfomation Dump"); result.clear(); - result.append("Unrecognized option, -h for help."); + result.append("unrecognized option, -h for help."); return DM_OK; }