gn modify

Signed-off-by: wangxuanxuan <wangxuanxuan9@huawei.com>
This commit is contained in:
wangxuanxuan
2023-06-13 14:57:08 +08:00
parent 132fbfe328
commit 636eb0d3f3
60 changed files with 119 additions and 89 deletions
+10 -3
View File
@@ -7,7 +7,7 @@
"license":"Apache License 2.0",
"publishAs":"code-segment",
"segment":{
"destPath":"foundation/distributedhardware/distributed_input/"
"destPath":"foundation/distributedhardware/distributed_input"
},
"dirs":{},
"scripts":{},
@@ -36,12 +36,19 @@
"samgr",
"dsoftbus",
"c_utils",
"distributed_hardware_fwk"
"distributed_hardware_fwk",
"config_policy",
"hisysevent_native",
"hitrace_native",
"graphic_standard",
"window_manager"
],
"third_party":[
"jsoncpp",
"googletest",
"libcrypto_static"
"libcrypto_static",
"libevdev",
"openssl"
]
},
"build":{
+1 -2
View File
@@ -28,13 +28,12 @@
#include <unistd.h>
#include <utility>
#include "anonymous_string.h"
#include "constants_dinput.h"
#include "dinput_context.h"
#include "dinput_errcode.h"
#include "dinput_log.h"
#include "dh_utils_tool.h"
#include "dinput_utils_tool.h"
namespace OHOS {
namespace DistributedHardware {
@@ -62,7 +62,6 @@ ohos_unittest("distributed_input_white_list_test") {
]
deps = [
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
]
-1
View File
@@ -20,7 +20,6 @@
#include <fstream>
#include <sstream>
#include "anonymous_string.h"
#include "config_policy_utils.h"
#include "dinput_errcode.h"
+1 -1
View File
@@ -42,7 +42,7 @@ ohos_shared_library("libdinput_dfx_utils") {
]
deps = [
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"//third_party/openssl:libcrypto_static",
]
+1 -2
View File
@@ -15,11 +15,10 @@
#include "hidumper.h"
#include "anonymous_string.h"
#include "dinput_errcode.h"
#include "dinput_log.h"
#include "dinput_softbus_define.h"
#include "dinput_utils_tool.h"
namespace OHOS {
namespace DistributedHardware {
+1 -1
View File
@@ -15,9 +15,9 @@
#include "hisysevent_util.h"
#include "anonymous_string.h"
#include "dinput_errcode.h"
#include "dinput_log.h"
#include "dinput_utils_tool.h"
namespace OHOS {
namespace DistributedHardware {
-1
View File
@@ -62,7 +62,6 @@ ohos_unittest("distributed_input_dfx_test") {
]
deps = [
"${fwk_utils_path}:distributedhardwareutils",
"//third_party/openssl:libcrypto_static",
]
-1
View File
@@ -43,7 +43,6 @@ ohos_shared_library("libdinput_handler") {
]
deps = [
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
"//third_party/openssl:libcrypto_static",
@@ -28,13 +28,13 @@
#include <linux/input.h>
#include <linux/uinput.h>
#include "anonymous_string.h"
#include "nlohmann/json.hpp"
#include "constants_dinput.h"
#include "dinput_errcode.h"
#include "dinput_log.h"
#include "dinput_softbus_define.h"
#include "dinput_utils_tool.h"
#include "softbus_bus_center.h"
namespace OHOS {
@@ -63,7 +63,6 @@ ohos_unittest("distributed_input_handler_test") {
]
deps = [
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
"//third_party/openssl:libcrypto_static",
-1
View File
@@ -77,7 +77,6 @@ ohos_shared_library("libdinput_sdk") {
]
deps = [
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
]
@@ -97,7 +97,6 @@ ohos_unittest("distributed_input_inner_test") {
]
deps = [
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
]
@@ -15,7 +15,6 @@
#include "distributed_input_client.h"
#include "anonymous_string.h"
#include "iservice_registry.h"
#include "nlohmann/json.hpp"
#include "system_ability_definition.h"
@@ -15,8 +15,6 @@
#include "distributed_input_sink_proxy.h"
#include "anonymous_string.h"
#include "dinput_errcode.h"
#include "dinput_ipc_interface_code.h"
#include "dinput_log.h"
@@ -15,12 +15,11 @@
#include "distributed_input_sink_stub.h"
#include "anonymous_string.h"
#include "constants_dinput.h"
#include "dinput_errcode.h"
#include "dinput_ipc_interface_code.h"
#include "dinput_log.h"
#include "dinput_utils_tool.h"
#include "i_sharing_dhid_listener.h"
namespace OHOS {
@@ -90,12 +90,11 @@ ohos_unittest("add_white_list_infos_callbackl_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
+1 -2
View File
@@ -108,8 +108,6 @@ ohos_unittest("distributed_input_client_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${services_sink_path}/sinkmanager:libdinput_sink",
"${services_source_path}/inputinject:libdinput_inject",
"${services_source_path}/sourcemanager:libdinput_source",
@@ -118,6 +116,7 @@ ohos_unittest("distributed_input_client_test") {
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"config_policy:configpolicy_util",
"dsoftbus:softbus_client",
@@ -66,12 +66,11 @@ ohos_unittest("del_white_list_infos_callbackl_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
@@ -90,12 +90,11 @@ ohos_unittest("dinput_source_callback_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
+1 -2
View File
@@ -100,12 +100,11 @@ ohos_unittest("distributed_input_ipc_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"config_policy:configpolicy_util",
"dsoftbus:softbus_client",
@@ -66,12 +66,11 @@ ohos_unittest("unprepare_d_input_call_back_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
@@ -66,12 +66,11 @@ ohos_unittest("unregister_d_input_call_back_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
-1
View File
@@ -42,7 +42,6 @@ ohos_shared_library("libdinput_collector") {
]
deps = [
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
"//third_party/openssl:libcrypto_static",
@@ -27,11 +27,11 @@
#include <sys/inotify.h>
#include <linux/input.h>
#include "anonymous_string.h"
#include "nlohmann/json.hpp"
#include "dinput_errcode.h"
#include "dinput_log.h"
#include "dinput_utils_tool.h"
namespace OHOS {
namespace DistributedHardware {
@@ -62,7 +62,6 @@ ohos_unittest("distributed_input_inner_sinkcollector_test") {
]
deps = [
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
"//third_party/openssl:libcrypto_static",
+1 -2
View File
@@ -53,8 +53,6 @@ ohos_shared_library("libdinput_sink") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${innerkits_path}:libdinput_sdk",
"${services_sink_path}/inputcollector:libdinput_collector",
"${services_sink_path}/transport:libdinput_sink_trans",
@@ -63,6 +61,7 @@ ohos_shared_library("libdinput_sink") {
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"config_policy:configpolicy_util",
"eventhandler:libeventhandler",
@@ -21,7 +21,6 @@
#include <thread>
#include <linux/input.h>
#include "anonymous_string.h"
#include "dinput_softbus_define.h"
#include "distributed_hardware_fwk_kit.h"
#include "if_system_ability_manager.h"
@@ -86,8 +86,6 @@ ohos_unittest("distributed_input_sinkmanager_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${distributedinput_path}/services/transportbase:libdinput_trans_base",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${services_sink_path}/transport:libdinput_sink_trans",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
@@ -95,6 +93,7 @@ ohos_unittest("distributed_input_sinkmanager_test") {
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"access_token:libaccesstoken_sdk",
"access_token:libnativetoken",
"access_token:libtoken_setproc",
+1 -2
View File
@@ -48,13 +48,12 @@ ohos_shared_library("libdinput_sink_trans") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${distributedinput_path}/services/transportbase:libdinput_trans_base",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
@@ -15,11 +15,10 @@
#include "distributed_input_sink_switch.h"
#include "anonymous_string.h"
#include "constants_dinput.h"
#include "dinput_errcode.h"
#include "dinput_log.h"
#include "dinput_utils_tool.h"
namespace OHOS {
namespace DistributedHardware {
@@ -19,7 +19,6 @@
#include "linux/input.h"
#include "anonymous_string.h"
#include "distributed_hardware_fwk_kit.h"
#include "securec.h"
@@ -80,8 +80,6 @@ ohos_unittest("distributed_input_sinktrans_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${services_sink_path}/inputcollector:libdinput_collector",
"${services_sink_path}/sinkmanager:libdinput_sink",
"${utils_path}:libdinput_utils",
@@ -89,6 +87,7 @@ ohos_unittest("distributed_input_sinktrans_test") {
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"eventhandler:libeventhandler",
"graphic_standard:surface",
-1
View File
@@ -48,7 +48,6 @@ ohos_shared_library("libdinput_inject") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
"//third_party/openssl:libcrypto_static",
@@ -17,7 +17,6 @@
#include <sstream>
#include "anonymous_string.h"
#include "dh_utils_tool.h"
#include "nlohmann/json.hpp"
@@ -22,7 +22,6 @@
#include <pthread.h>
#include <unistd.h>
#include "anonymous_string.h"
#include "softbus_bus_center.h"
#include "dinput_context.h"
@@ -17,11 +17,10 @@
#include <securec.h>
#include "anonymous_string.h"
#include "constants_dinput.h"
#include "dinput_log.h"
#include "hidumper.h"
#include "dinput_utils_tool.h"
namespace OHOS {
namespace DistributedHardware {
@@ -74,7 +74,6 @@ ohos_unittest("distributed_input_inner_sourceinject_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_utils_path}:distributedhardwareutils",
"${innerkits_path}:libdinput_sdk",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
+1 -2
View File
@@ -88,8 +88,6 @@ ohos_shared_library("libdinput_source") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${innerkits_path}:libdinput_sdk",
"${services_source_path}/inputinject:libdinput_inject",
"${services_source_path}/transport:libdinput_source_trans",
@@ -98,6 +96,7 @@ ohos_shared_library("libdinput_source") {
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"config_policy:configpolicy_util",
"dsoftbus:softbus_client",
@@ -20,7 +20,6 @@
#include <dlfcn.h>
#include <fstream>
#include "anonymous_string.h"
#include "dinput_softbus_define.h"
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
@@ -19,9 +19,8 @@
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "anonymous_string.h"
#include "dinput_log.h"
#include "dinput_utils_tool.h"
namespace OHOS {
namespace DistributedHardware {
@@ -110,8 +110,6 @@ ohos_unittest("distributed_input_sourcemanager_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${innerkits_path}:libdinput_sdk",
"${services_source_path}/transport:libdinput_source_trans",
"//third_party/libevdev:libevdev",
@@ -119,6 +117,7 @@ ohos_unittest("distributed_input_sourcemanager_test") {
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"access_token:libaccesstoken_sdk",
"access_token:libnativetoken",
"access_token:libtoken_setproc",
+1 -2
View File
@@ -45,14 +45,13 @@ ohos_shared_library("libdinput_source_trans") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${distributedinput_path}/services/transportbase:libdinput_trans_base",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${services_source_path}/inputinject:libdinput_inject",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"eventhandler:libeventhandler",
"hitrace_native:hitrace_meter",
@@ -19,7 +19,6 @@
#include <cstring>
#include <pthread.h>
#include "anonymous_string.h"
#include "distributed_hardware_fwk_kit.h"
#include "ipc_skeleton.h"
#include "iservice_registry.h"
@@ -77,8 +77,6 @@ ohos_unittest("distributed_input_sourcetrans_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${services_source_path}/inputinject:libdinput_inject",
"${services_source_path}/sourcemanager:libdinput_source",
"${utils_path}:libdinput_utils",
@@ -86,6 +84,7 @@ ohos_unittest("distributed_input_sourcetrans_test") {
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"eventhandler:libeventhandler",
"hitrace_native:hitrace_meter",
+1 -2
View File
@@ -45,14 +45,13 @@ ohos_shared_library("libdinput_trans_base") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${services_source_path}/inputinject:libdinput_inject",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
@@ -18,7 +18,6 @@
#include <algorithm>
#include <cstring>
#include "anonymous_string.h"
#include "distributed_hardware_fwk_kit.h"
#include "ipc_skeleton.h"
#include "iservice_registry.h"
@@ -74,14 +74,13 @@ ohos_unittest("distributed_input_transbase_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${services_source_path}/inputinject:libdinput_inject",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"eventhandler:libeventhandler",
"hitrace_native:hitrace_meter",
+1 -1
View File
@@ -49,8 +49,8 @@ ohos_shared_library("libdinput_sink_handler") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_utils_path}:distributedhardwareutils",
"${innerkits_path}:libdinput_sdk",
"${utils_path}:libdinput_utils",
]
external_deps = [
+1 -1
View File
@@ -72,8 +72,8 @@ ohos_unittest("distributed_input_sink_handler_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_utils_path}:distributedhardwareutils",
"${innerkits_path}:libdinput_sdk",
"${utils_path}:libdinput_utils",
]
external_deps = [
+1 -1
View File
@@ -50,7 +50,7 @@ ohos_shared_library("libdinput_source_handler") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"${innerkits_path}:libdinput_sdk",
"//third_party/libevdev:libevdev",
]
+1 -1
View File
@@ -72,7 +72,7 @@ ohos_unittest("distributed_input_source_handler_test") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"${innerkits_path}:libdinput_sdk",
"//third_party/libevdev:libevdev",
]
@@ -54,13 +54,12 @@ ohos_fuzztest("DistributedInputSinkTransportFuzzTest") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${distributedinput_path}/services/transportbase:libdinput_trans_base",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
@@ -57,14 +57,13 @@ ohos_fuzztest("DistributedInputSourceTransportFuzzTest") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${distributedinput_path}/services/transportbase:libdinput_trans_base",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${services_source_path}/inputinject:libdinput_inject",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
@@ -57,14 +57,13 @@ ohos_fuzztest("DistributedInputTransportBaseFuzzTest") {
deps = [
"${dfx_utils_path}:libdinput_dfx_utils",
"${distributedinput_path}/services/transportbase:libdinput_trans_base",
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"${services_source_path}/inputinject:libdinput_inject",
"${utils_path}:libdinput_utils",
"//third_party/libevdev:libevdev",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
+1 -2
View File
@@ -45,12 +45,11 @@ ohos_shared_library("libdinput_utils") {
]
deps = [
"${fwk_interfaces_path}:libdhfwk_sdk",
"${fwk_utils_path}:distributedhardwareutils",
"//third_party/openssl:libcrypto_static",
]
external_deps = [
"distributed_hardware_fwk:libdhfwk_sdk",
"c_utils:utils",
"dsoftbus:softbus_client",
"hisysevent_native:libhisysevent",
+3
View File
@@ -47,6 +47,9 @@ bool IsUInt32(const nlohmann::json& jsonObj, const std::string& key);
bool IsUInt64(const nlohmann::json& jsonObj, const std::string& key);
bool IsArray(const nlohmann::json& jsonObj, const std::string& key);
std::string GetNodeDesc(std::string parameters);
std::string GetAnonyString(const std::string &value);
std::string GetAnonyInt32(const int32_t value);
std::string Sha256(const std::string& string);
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
+1 -1
View File
@@ -15,10 +15,10 @@
#include "dinput_context.h"
#include "anonymous_string.h"
#include "constants.h"
#include "dinput_errcode.h"
#include "dinput_utils_tool.h"
namespace OHOS {
namespace DistributedHardware {
+69 -1
View File
@@ -21,8 +21,8 @@
#include <openssl/sha.h>
#include "anonymous_string.h"
#include "nlohmann/json.hpp"
#include "securec.h"
#ifndef COMPILE_TEST_MODE
#include "softbus_bus_center.h"
@@ -214,6 +214,74 @@ std::string GetNodeDesc(std::string parameters)
return "{ nodeName: " + nodeName + ", physicalPath: " + physicalPath + ", classes: " +
std::to_string(classes) + " }";
}
std::string GetAnonyString(const std::string &value)
{
constexpr size_t INT32_SHORT_ID_LENGTH = 20;
constexpr size_t INT32_PLAINTEXT_LENGTH = 4;
constexpr size_t INT32_MIN_ID_LENGTH = 3;
std::string res;
std::string tmpStr("******");
size_t strLen = value.length();
if (strLen < INT32_MIN_ID_LENGTH) {
return tmpStr;
}
if (strLen <= INT32_SHORT_ID_LENGTH) {
res += value[0];
res += tmpStr;
res += value[strLen - 1];
} else {
res.append(value, 0, INT32_PLAINTEXT_LENGTH);
res += tmpStr;
res.append(value, strLen - INT32_PLAINTEXT_LENGTH, INT32_PLAINTEXT_LENGTH);
}
return res;
}
std::string GetAnonyInt32(const int32_t value)
{
constexpr int32_t INT32_STRING_LENGTH = 40;
char tempBuffer[INT32_STRING_LENGTH] = "";
int32_t secRet = sprintf_s(tempBuffer, INT32_STRING_LENGTH, "%d", value);
if (secRet <= 0) {
std::string nullString("");
return nullString;
}
size_t length = strlen(tempBuffer);
for (size_t i = 1; i <= length - 1; i++) {
tempBuffer[i] = '*';
}
if (length == 0x01) {
tempBuffer[0] = '*';
}
std::string tempString(tempBuffer);
return tempString;
}
std::string Sha256(const std::string& in)
{
unsigned char out[SHA256_DIGEST_LENGTH * 2 + 1] = {0};
SHA256_CTX ctx;
SHA256_Init(&ctx);
SHA256_Update(&ctx, in.data(), in.size());
SHA256_Final(&out[SHA256_DIGEST_LENGTH], &ctx);
// here we translate sha256 hash to hexadecimal. each 8-bit char will be presented by two characters([0-9a-f])
constexpr int32_t WIDTH = 4;
constexpr unsigned char MASK = 0x0F;
const char* hexCode = "0123456789abcdef";
constexpr int32_t DOUBLE_TIMES = 2;
for (int32_t i = 0; i < SHA256_DIGEST_LENGTH; ++i) {
unsigned char value = out[SHA256_DIGEST_LENGTH + i];
// uint8_t is 2 digits in hexadecimal.
out[i * DOUBLE_TIMES] = hexCode[(value >> WIDTH) & MASK];
out[i * DOUBLE_TIMES + 1] = hexCode[value & MASK];
}
out[SHA256_DIGEST_LENGTH * DOUBLE_TIMES] = 0;
return reinterpret_cast<char*>(out);
}
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
+1 -1
View File
@@ -67,7 +67,7 @@ ohos_unittest("distributed_input_utils_test") {
]
deps = [
"${fwk_utils_path}:distributedhardwareutils",
"${utils_path}:libdinput_utils",
"//third_party/openssl:libcrypto_static",
]