mirror of
https://github.com/openharmony/device_manager.git
synced 2026-07-19 18:13:32 -04:00
@@ -101,7 +101,6 @@ public:
|
||||
~SoftbusListener();
|
||||
int32_t GetTrustedDeviceList(std::vector<DmDeviceInfo> &deviceInfoList);
|
||||
int32_t GetLocalDeviceInfo(DmDeviceInfo &deviceInfo);
|
||||
bool IsDeviceOnline(const std::string &deviceId);
|
||||
|
||||
private:
|
||||
int32_t Init();
|
||||
|
||||
@@ -286,10 +286,9 @@ int32_t DeviceManagerService::DmHiDumper(const std::vector<std::string>& 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.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,44 +175,6 @@ int32_t SoftbusListener::GetTrustedDeviceList(std::vector<DmDeviceInfo> &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");
|
||||
|
||||
@@ -35,7 +35,7 @@ class HiDumpHelper {
|
||||
public:
|
||||
int32_t HiDump(const std::vector<std::string>& args, std::string &result);
|
||||
int32_t GetArgsType(const std::vector<std::string>& args, std::vector<HidumperFlag> &Flag);
|
||||
void SetNodeInfo(const DmDeviceInfo& deviceInfo, const bool deviceStates);
|
||||
void SetNodeInfo(const DmDeviceInfo& deviceInfo);
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -34,7 +34,7 @@ DECLARE_SINGLE_INSTANCE(HiDumpHelper);
|
||||
public:
|
||||
int32_t HiDump(const std::vector<std::string>& args, std::string &result);
|
||||
int32_t GetArgsType(const std::vector<std::string>& args, std::vector<HidumperFlag> &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<DmDeviceInfo> nodeInfos_;
|
||||
std::vector<std::string> deviceState_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -28,7 +28,7 @@ int32_t HiDumpHelper::GetArgsType(const std::vector<std::string>& args, std::vec
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
void HiDumpHelper::SetNodeInfo(const DmDeviceInfo& deviceInfo, const bool deviceStates)
|
||||
void HiDumpHelper::SetNodeInfo(const DmDeviceInfo& deviceInfo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,15 +41,10 @@ int32_t HiDumpHelper::HiDump(const std::vector<std::string>& 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user