mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-21 05:45:23 -04:00
Description:Anony deviceId
Match-id-4b9ce9fb954750060d98d7c431fd9dda39989a31
This commit is contained in:
@@ -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