!643 【任务】整改dfx hidump设备类型id转换

Merge pull request !643 from 王移波/master
This commit is contained in:
openharmony_ci
2022-07-04 11:19:15 +00:00
committed by Gitee
5 changed files with 68 additions and 53 deletions
+21 -23
View File
@@ -76,29 +76,27 @@ if (defined(ohos_lite)) {
]
sources = [
"${services_path}/src/ability/lite/dm_ability_manager.cpp",
"${services_path}/src/adapter/standard/dm_adapter_manager.cpp",
"${services_path}/src/authentication/auth_message_processor.cpp",
"${services_path}/src/authentication/auth_request_state.cpp",
"${services_path}/src/authentication/auth_response_state.cpp",
"${services_path}/src/authentication/dm_auth_manager.cpp",
"${services_path}/src/authentication/showconfirm/lite/show_confirm.cpp",
"${services_path}/src/config/mini/dm_config_manager.cpp",
"${services_path}/src/config/mini/pin_auth.cpp",
"${services_path}/src/dependency/hichain/hichain_connector.cpp",
"${services_path}/src/dependency/mini/dm_mutex.cpp",
"${services_path}/src/dependency/mini/dm_thread.cpp",
"${services_path}/src/dependency/multipleuser/multiple_user_connector.cpp",
"${services_path}/src/dependency/softbus/softbus_connector.cpp",
"${services_path}/src/dependency/softbus/softbus_session.cpp",
"${services_path}/src/dependency/timer/mini/dm_timer.cpp",
"${services_path}/src/device_manager_service.cpp",
"${services_path}/src/deviceinfo/dm_device_info_manager.cpp",
"${services_path}/src/devicestate/dm_device_state_manager.cpp",
"${services_path}/src/discovery/dm_discovery_manager.cpp",
"${services_path}/src/dispatch/command_dispatch.cpp",
"${services_path}/src/dispatch/device_manager_service_listener_mini.cpp",
"${services_path}/src/dispatch/server_stub.cpp",
"${servicesimpl_path}/src/ability/lite/dm_ability_manager.cpp",
"${servicesimpl_path}/src/adapter/standard/dm_adapter_manager.cpp",
"${servicesimpl_path}/src/authentication/auth_message_processor.cpp",
"${servicesimpl_path}/src/authentication/auth_request_state.cpp",
"${servicesimpl_path}/src/authentication/auth_response_state.cpp",
"${servicesimpl_path}/src/authentication/dm_auth_manager.cpp",
"${servicesimpl_path}/src/authentication/showconfirm/lite/show_confirm.cpp",
"${servicesimpl_path}/src/config/mini/dm_config_manager.cpp",
"${servicesimpl_path}/src/config/mini/pin_auth.cpp",
"${servicesimpl_path}/src/dependency/hichain/hichain_connector.cpp",
"${servicesimpl_path}/src/dependency/mini/dm_mutex.cpp",
"${servicesimpl_path}/src/dependency/mini/dm_thread.cpp",
"${servicesimpl_path}/src/dependency/multipleuser/multiple_user_connector.cpp",
"${servicesimpl_path}/src/dependency/softbus/softbus_connector.cpp",
"${servicesimpl_path}/src/dependency/softbus/softbus_session.cpp",
"${servicesimpl_path}/src/dependency/timer/mini/dm_timer.cpp",
"${servicesimpl_path}/src/devicestate/dm_device_state_manager.cpp",
"${servicesimpl_path}/src/discovery/dm_discovery_manager.cpp",
"${servicesimpl_path}/src/dispatch/command_dispatch.cpp",
"${servicesimpl_path}/src/dispatch/device_manager_service_listener_mini.cpp",
"${servicesimpl_path}/src/dispatch/server_stub.cpp",
]
defines = [
+7 -23
View File
@@ -76,29 +76,13 @@ if (defined(ohos_lite)) {
]
sources = [
"${services_path}/src/ability/lite/dm_ability_manager.cpp",
"${services_path}/src/adapter/standard/dm_adapter_manager.cpp",
"${services_path}/src/authentication/auth_message_processor.cpp",
"${services_path}/src/authentication/auth_request_state.cpp",
"${services_path}/src/authentication/auth_response_state.cpp",
"${services_path}/src/authentication/dm_auth_manager.cpp",
"${services_path}/src/authentication/showconfirm/lite/show_confirm.cpp",
"${services_path}/src/config/mini/dm_config_manager.cpp",
"${services_path}/src/config/mini/pin_auth.cpp",
"${services_path}/src/dependency/hichain/hichain_connector.cpp",
"${services_path}/src/dependency/mini/dm_mutex.cpp",
"${services_path}/src/dependency/mini/dm_thread.cpp",
"${services_path}/src/dependency/multipleuser/multiple_user_connector.cpp",
"${services_path}/src/dependency/softbus/softbus_listener.cpp",
"${services_path}/src/dependency/softbus/softbus_session.cpp",
"${services_path}/src/dependency/timer/mini/dm_timer.cpp",
"${services_path}/src/device_manager_service.cpp",
"${services_path}/src/deviceinfo/dm_device_info_manager.cpp",
"${services_path}/src/devicestate/dm_device_state_manager.cpp",
"${services_path}/src/discovery/dm_discovery_manager.cpp",
"${services_path}/src/dispatch/command_dispatch.cpp",
"${services_path}/src/dispatch/device_manager_service_listener_mini.cpp",
"${services_path}/src/dispatch/server_stub.cpp",
"src/device_manager_service.cpp",
"src/device_manager_service_listener.cpp",
"src/ipc/lite/ipc_cmd_parser.cpp",
"src/ipc/lite/ipc_server_listener.cpp",
"src/ipc/lite/ipc_server_main",
"src/ipc/lite/ipc_server_stub.cpp",
"src/softbus/softbus_listener.cpp",
]
defines = [
+23 -3
View File
@@ -15,6 +15,8 @@
#ifndef OHOS_DM_DFX_CONSTANTS_H
#define OHOS_DM_DFX_CONSTANTS_H
#include "dm_device_info.h"
#include <string>
#include <unordered_map>
@@ -26,7 +28,7 @@ const int DM_HISYEVENT_STATISTIC = 2;
const int DM_HISYEVENT_SECURITY = 3;
const int DM_HISYEVENT_BEHAVIOR = 4;
// state
// HisysEvent state
const std::string DM_INIT_DEVICE_MANAGER_SUCCESS = "DM_INIT_DEVICE_MANAGER_SUCCESS";
const std::string DM_INIT_DEVICE_MANAGER_FAILED = "DM_INIT_DEVICE_MANAGER_FAILED";
const std::string START_DEVICE_DISCOVERY_SUCCESS = "START_DEVICE_DISCOVERY_SUCCESS";
@@ -42,7 +44,7 @@ const std::string DM_CREATE_GROUP_FAILED = "DM_CREATE_GROUP_FAILED";
const std::string UNAUTHENTICATE_DEVICE_SUCCESS = "UNAUTHENTICATE_DEVICE_SUCCESS";
const std::string UNAUTHENTICATE_DEVICE_FAILED = "UNAUTHENTICATE_DEVICE_FAILED";
// msg
// HisysEvent msg
const std::string DM_INIT_DEVICE_MANAGER_SUCCESS_MSG = "init devicemanager success.";
const std::string DM_INIT_DEVICE_MANAGER_FAILED_MSG = "init devicemanager failed.";
const std::string START_DEVICE_DISCOVERY_SUCCESS_MSG = "device manager discovery success.";
@@ -63,7 +65,6 @@ const std::string DM_HITRACE_START_DEVICE = "DM_HITRACE_START_DEVICE";
const std::string DM_HITRACE_GET_LOCAL_DEVICE_INFO = "DM_HITRACE_GET_LOCAL_DEVICE_INFO";
const std::string DM_HITRACE_AUTH_TO_CONSULT = "DM_HITRACE_AUTH_TO_CONSULT";
const std::string DM_HITRACE_AUTH_TO_OPPEN_SESSION = "DM_HITRACE_AUTH_TO_OPPEN_SESSION";
const std::string DM_HITRACE_DEVICE_ONLINE = "DM_HITRACE_DEVICE_ONLINE";
const std::string DM_HITRACE_INIT = "DM_HITRACE_INIT";
// HiDumper Flag
@@ -78,10 +79,29 @@ enum class HidumperFlag {
const std::string ARGS_HELP_INFO = "-help";
const std::string HIDUMPER_GET_TRUSTED_LIST_INFO = "-getTrustlist";
// HiDumper command
const std::unordered_map<std::string, HidumperFlag> MAP_ARGS = {
{ ARGS_HELP_INFO, HidumperFlag::HIDUMPER_GET_HELP },
{ HIDUMPER_GET_TRUSTED_LIST_INFO, HidumperFlag::HIDUMPER_GET_TRUSTED_LIST },
};
// HiDumper device type
typedef struct DumperInfo {
DmDeviceType deviceTypeId;
std::string deviceTypeInfo;
} DumperInfo;
static DumperInfo dumperDeviceType[] = {
{DEVICE_TYPE_UNKNOWN, "DEVICE_TYPE_UNKNOWN"},
{DEVICE_TYPE_WIFI_CAMERA, "DEVICE_TYPE_WIFI_CAMERA"},
{DEVICE_TYPE_AUDIO, "DEVICE_TYPE_AUDIO"},
{DEVICE_TYPE_PC, "DEVICE_TYPE_PC"},
{DEVICE_TYPE_PHONE, "DEVICE_TYPE_PHONE"},
{DEVICE_TYPE_PAD, "DEVICE_TYPE_PAD"},
{DEVICE_TYPE_WATCH, "DEVICE_TYPE_WATCH"},
{DEVICE_TYPE_CAR, "DEVICE_TYPE_CAR"},
{DEVICE_TYPE_TV, "DEVICE_TYPE_TV"},
};
} // namespace DistributedHardware
} // namespace OHOS
#endif // OHOS_DM_DFX_CONSTANTS_H
+1
View File
@@ -41,6 +41,7 @@ private:
int32_t ShowAllLoadTrustedList(std::string &result);
int32_t ShowHelp(std::string &result);
int32_t ShowIllealInfomation(std::string &result);
std::string GetDeviceType(int32_t deviceTypeId);
private:
std::vector<DmDeviceInfo> nodeInfos_;
+16 -4
View File
@@ -81,7 +81,8 @@ int32_t HiDumpHelper::ShowAllLoadTrustedList(std::string &result)
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 deviceTypeId : ").append(std::to_string(nodeInfos_[i].deviceTypeId));
std::string deviceType = GetDeviceType(nodeInfos_[i].deviceTypeId);
result.append("\n{\n deviceType : ").append(deviceType);
}
nodeInfos_.clear();
@@ -89,6 +90,18 @@ int32_t HiDumpHelper::ShowAllLoadTrustedList(std::string &result)
return ret;
}
std::string HiDumpHelper::GetDeviceType(int32_t deviceTypeId)
{
std::string dmDeviceTypeIdString = "";
for (int32_t i = 0; i < (sizeof(dumperDeviceType) / sizeof(dumperDeviceType[0])); i++) {
if (deviceTypeId == dumperDeviceType[i].deviceTypeId) {
dmDeviceTypeIdString = dumperDeviceType[i].deviceTypeInfo;
break;
}
}
return dmDeviceTypeIdString;
}
int32_t HiDumpHelper::ShowHelp(std::string &result)
{
LOGI("Show hidumper help");
@@ -96,8 +109,7 @@ int32_t HiDumpHelper::ShowHelp(std::string &result)
result.append(" -help ");
result.append(": show help\n");
result.append(" -getTrustlist ");
result.append(": show all get trusted list:\n\n");
LOGI("result is %s", result.c_str());
result.append(": show all trusted device list\n\n");
return DM_OK;
}
@@ -105,7 +117,7 @@ int32_t HiDumpHelper::ShowIllealInfomation(std::string &result)
{
LOGI("ShowIllealInfomation Dump");
result.clear();
result.append("unrecognized option, -h for help.");
result.append("unrecognized option, -help for help.");
return DM_OK;
}