mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-20 21:41:02 -04:00
Description:Anony deviceId
Match-id-4b9ce9fb954750060d98d7c431fd9dda39989a31
This commit is contained in:
@@ -625,7 +625,8 @@ void InputHub::GenerateDescriptor(InputDevice& identifier) const
|
||||
}
|
||||
}
|
||||
identifier.descriptor = DH_ID_PREFIX + Sha256(rawDescriptor);
|
||||
DHLOGI("Created descriptor: raw=%s, cooked=%s", rawDescriptor.c_str(), identifier.descriptor.c_str());
|
||||
DHLOGI("Created descriptor: raw=%s, cooked=%s", rawDescriptor.c_str(),
|
||||
GetAnonyString(identifier.descriptor).c_str());
|
||||
}
|
||||
|
||||
int32_t InputHub::RegisterDeviceForEpollLocked(const Device& device)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "constants_dinput.h"
|
||||
#include "dinput_errcode.h"
|
||||
#include "dinput_utils_tool.h"
|
||||
#include "softbus_bus_center.h"
|
||||
#include "white_list_util.h"
|
||||
|
||||
@@ -148,7 +149,7 @@ int32_t DistributedInputClient::RegisterDistributedHardware(const std::string& d
|
||||
const std::string& parameters, const std::shared_ptr<RegisterCallback>& callback)
|
||||
{
|
||||
DHLOGI("%s called, deviceId: %s, dhId: %s, parameters: %s",
|
||||
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), parameters.c_str());
|
||||
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), SetAnonyId(parameters).c_str());
|
||||
|
||||
if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) {
|
||||
DHLOGE("RegisterDistributedHardware client fail");
|
||||
|
||||
@@ -52,7 +52,7 @@ int32_t DistributedInputSinkSwitch::StartSwitch(int32_t sessionId)
|
||||
{
|
||||
std::unique_lock<std::mutex> switchLock(operationMutex_);
|
||||
if (switchVector_.empty()) {
|
||||
DHLOGE("StartSwitch sessionId:%d fail,switchVector_ is null.", sessionId);
|
||||
DHLOGE("StartSwitch sessionId:%s fail,switchVector_ is null.", GetAnonyInt32(sessionId).c_str());
|
||||
return ERR_DH_INPUT_SERVER_SINK_START_SWITCH_FAIL;
|
||||
} else {
|
||||
bool findOld = false;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "constants_dinput.h"
|
||||
#include "dinput_errcode.h"
|
||||
#include "dinput_low_latency.h"
|
||||
#include "dinput_utils_tool.h"
|
||||
#include "hidumper.h"
|
||||
#include "session.h"
|
||||
#include "softbus_bus_center.h"
|
||||
@@ -344,7 +345,7 @@ void DistributedInputSinkTransport::OnBytesReceived(int32_t sessionId, const voi
|
||||
}
|
||||
|
||||
std::string message(buf, buf + dataLen);
|
||||
DHLOGI("OnBytesReceived message:%s.", message.c_str());
|
||||
DHLOGI("OnBytesReceived message:%s.", SetAnonyId(message).c_str());
|
||||
HandleSessionData(sessionId, message);
|
||||
|
||||
free(buf);
|
||||
@@ -424,7 +425,7 @@ void DistributedInputSinkTransport::NotifyLatency(int32_t sessionId, const nlohm
|
||||
void DistributedInputSinkTransport::HandleSessionData(int32_t sessionId, const std::string& message)
|
||||
{
|
||||
if (callback_ == nullptr) {
|
||||
DHLOGE("OnBytesReceived the callback_ is null, the message:%s abort.", message.c_str());
|
||||
DHLOGE("OnBytesReceived the callback_ is null, the message:%s abort.", SetAnonyId(message).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -435,7 +436,7 @@ void DistributedInputSinkTransport::HandleSessionData(int32_t sessionId, const s
|
||||
}
|
||||
|
||||
if (recMsg.contains(DINPUT_SOFTBUS_KEY_CMD_TYPE) != true) {
|
||||
DHLOGE("OnBytesReceived message:%s is error, not contain cmdType.", message.c_str());
|
||||
DHLOGE("OnBytesReceived message:%s is error, not contain cmdType.", SetAnonyId(message).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ ohos_shared_library("libdinput_inject") {
|
||||
"${fwk_utils_path}/include",
|
||||
"//third_party/json/include",
|
||||
"${dfx_utils_path}/include",
|
||||
"${utils_path}/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -50,6 +51,7 @@ ohos_shared_library("libdinput_inject") {
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//third_party/openssl:libcrypto_static",
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${utils_path}:libdinput_utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#include "dinput_errcode.h"
|
||||
#include "dinput_utils_tool.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -46,7 +47,7 @@ int32_t DistributedInputInject::RegisterDistributedHardware(const std::string& d
|
||||
const std::string& parameters)
|
||||
{
|
||||
DHLOGI("%s called, deviceId: %s, dhId: %s, parameters: %s",
|
||||
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), parameters.c_str());
|
||||
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), SetAnonyId(parameters).c_str());
|
||||
|
||||
if (inputNodeManager_ == nullptr) {
|
||||
DHLOGE("the DistributedInputNodeManager is null\n");
|
||||
|
||||
@@ -43,6 +43,7 @@ ohos_unittest("distributed_input_inner_sourceinject_test") {
|
||||
"//third_party/json/include",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/transport",
|
||||
"${dfx_utils_path}/include",
|
||||
"${utils_path}/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -76,6 +77,7 @@ ohos_unittest("distributed_input_inner_sourceinject_test") {
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${utils_path}:libdinput_utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "dinput_sa_process_state.h"
|
||||
#include "distributed_input_inject.h"
|
||||
#include "distributed_input_source_transport.h"
|
||||
#include "dinput_utils_tool.h"
|
||||
#include "hisysevent_util.h"
|
||||
#include "hidumper.h"
|
||||
#include "white_list_util.h"
|
||||
@@ -547,7 +548,7 @@ int32_t DistributedInputSourceManager::RegisterDistributedHardware(const std::st
|
||||
{
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_REGISTER, devId, dhId, "dinput register call.");
|
||||
DHLOGI("%s called, deviceId: %s, dhId: %s, parameters: %s",
|
||||
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), parameters.c_str());
|
||||
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), SetAnonyId(parameters).c_str());
|
||||
if (callback == nullptr) {
|
||||
DHLOGE(
|
||||
"%s called, deviceId: %s callback is null.",
|
||||
@@ -801,7 +802,7 @@ int32_t DistributedInputSourceManager::UnprepareRemoteInput(const std::string& d
|
||||
{
|
||||
StartAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_UNPREPARE_START, DINPUT_UNPREPARE_TASK);
|
||||
HisyseventUtil::GetInstance().SysEventWriteBehavior(DINPUT_UNPREPARE, deviceId, "dinput unprepare call");
|
||||
DHLOGI("%s called, deviceId: %s", __func__, deviceId.c_str());
|
||||
DHLOGI("%s called, deviceId: %s", __func__, GetAnonyString(deviceId).c_str());
|
||||
|
||||
if (callback == nullptr) {
|
||||
DHLOGE("%s called, deviceId: %s callback is null.", __func__, GetAnonyString(deviceId).c_str());
|
||||
|
||||
@@ -249,11 +249,11 @@ int32_t DistributedInputSourceTransport::PrepareRemoteInput(const std::string& d
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
if (ret != DH_SUCCESS) {
|
||||
DHLOGE("PrepareRemoteInput deviceId:%s, sessionId:%s, smsg:%s, SendMsg error, ret:%d.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str(), ret);
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), SetAnonyId(smsg).c_str(), ret);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_PREPARE_FAIL;
|
||||
}
|
||||
DHLOGI("PrepareRemoteInput devId:%s, sessionId:%s, msg:%s.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str());
|
||||
DHLOGI("PrepareRemoteInput devId:%s, sessionId:%s, smsg:%s.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), SetAnonyId(smsg).c_str());
|
||||
return DH_SUCCESS;
|
||||
} else {
|
||||
DHLOGE("PrepareRemoteInput error, not find this device:%s.",
|
||||
@@ -275,11 +275,11 @@ int32_t DistributedInputSourceTransport::UnprepareRemoteInput(const std::string&
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
if (ret != DH_SUCCESS) {
|
||||
DHLOGE("UnprepareRemoteInput deviceId:%s, sessionId:%s, smsg:%s, SendMsg error, ret:%d.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str(), ret);
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), SetAnonyId(smsg).c_str(), ret);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_UNPREPARE_FAIL;
|
||||
}
|
||||
DHLOGI("UnprepareRemoteInput deviceId:%s, sessionId:%s, smsg:%s.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str());
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), SetAnonyId(smsg).c_str());
|
||||
return DH_SUCCESS;
|
||||
} else {
|
||||
DHLOGE("UnprepareRemoteInput error, not find this device:%s.",
|
||||
@@ -303,11 +303,11 @@ int32_t DistributedInputSourceTransport::StartRemoteInput(
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
if (ret != DH_SUCCESS) {
|
||||
DHLOGE("StartRemoteInput deviceId:%s, sessionId:%s, smsg:%s, SendMsg error, ret:%d.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str(), ret);
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), SetAnonyId(smsg).c_str(), ret);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL;
|
||||
}
|
||||
DHLOGI("StartRemoteInput deviceId:%s, sessionId:%s, smsg:%s.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str());
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), SetAnonyId(smsg).c_str());
|
||||
return DH_SUCCESS;
|
||||
} else {
|
||||
DHLOGE("StartRemoteInput error, not find this device:%s.",
|
||||
@@ -331,11 +331,11 @@ int32_t DistributedInputSourceTransport::StopRemoteInput(
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
if (ret != DH_SUCCESS) {
|
||||
DHLOGE("StopRemoteInput deviceId:%s, sessionId:%s, smsg:%s, SendMsg error, ret:%d.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str(), ret);
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), SetAnonyId(smsg).c_str(), ret);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL;
|
||||
}
|
||||
DHLOGI("StopRemoteInput deviceId:%s, sessionId:%s, smsg:%s.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str());
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), SetAnonyId(smsg).c_str());
|
||||
return DH_SUCCESS;
|
||||
} else {
|
||||
DHLOGE("StopRemoteInput error, not find this device:%s.", GetAnonyString(deviceId).c_str());
|
||||
@@ -360,12 +360,12 @@ int32_t DistributedInputSourceTransport::LatencyCount(const std::string& deviceI
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
if (ret != DH_SUCCESS) {
|
||||
DHLOGE("LatencyCount deviceId:%s, sessionId:%s, smsg:%s, SendMsg error, ret:%d.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str(), ret);
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), SetAnonyId(smsg).c_str(), ret);
|
||||
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_LATENCY_FAIL;
|
||||
}
|
||||
|
||||
DHLOGI("LatencyCount deviceId:%s, sessionId:%s, smsg:%s.",
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str());
|
||||
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), SetAnonyId(smsg).c_str());
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,10 @@ ohos_shared_library("libdinput_utils") {
|
||||
"${fwk_common_path}/log/include",
|
||||
"${fwk_utils_path}/include",
|
||||
"${fwk_utils_path}/include/log",
|
||||
"//third_party/json/include",
|
||||
"${utils_path}/include",
|
||||
"${common_path}/include",
|
||||
"${service_common}/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
|
||||
@@ -32,6 +32,7 @@ struct DevInfo {
|
||||
|
||||
DevInfo GetLocalDeviceInfo();
|
||||
uint64_t GetCurrentTime();
|
||||
std::string SetAnonyId(const std::string &message);
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -15,16 +15,19 @@
|
||||
|
||||
#include "dinput_utils_tool.h"
|
||||
|
||||
#include "anonymous_string.h"
|
||||
#include <sys/time.h>
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#include "dinput_softbus_define.h"
|
||||
#include "softbus_bus_center.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
namespace {
|
||||
const std::string DINPUT_PKG_NAME = "ohos.dhardware.dinput";
|
||||
constexpr int32_t MS_ONE_SECOND = 1000;
|
||||
const char *const DESCRIPTOR = "descriptor";
|
||||
}
|
||||
|
||||
DevInfo GetLocalDeviceInfo()
|
||||
@@ -50,6 +53,21 @@ uint64_t GetCurrentTime()
|
||||
gettimeofday(&tv, nullptr);
|
||||
return tv.tv_sec * MS_ONE_SECOND + tv.tv_usec / MS_ONE_SECOND;
|
||||
}
|
||||
|
||||
std::string SetAnonyId(const std::string &message)
|
||||
{
|
||||
nlohmann::json jsonStr = nlohmann::json::parse(message);
|
||||
if (jsonStr.contains(DINPUT_SOFTBUS_KEY_DEVICE_ID)) {
|
||||
jsonStr[DINPUT_SOFTBUS_KEY_DEVICE_ID] = GetAnonyString(jsonStr[DINPUT_SOFTBUS_KEY_DEVICE_ID]);
|
||||
}
|
||||
if (jsonStr.contains(DINPUT_SOFTBUS_KEY_SESSION_ID)) {
|
||||
jsonStr[DINPUT_SOFTBUS_KEY_SESSION_ID] = GetAnonyInt32(jsonStr[DINPUT_SOFTBUS_KEY_SESSION_ID]);
|
||||
}
|
||||
if (jsonStr.contains(DESCRIPTOR)) {
|
||||
jsonStr[DESCRIPTOR] = GetAnonyString(jsonStr[DESCRIPTOR]);
|
||||
}
|
||||
return jsonStr.dump();
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
Reference in New Issue
Block a user