Description:Anony deviceId

Match-id-4b9ce9fb954750060d98d7c431fd9dda39989a31
This commit is contained in:
xxxx
2022-08-05 15:51:41 +08:00
parent 2d8d1a0469
commit 8fe2c9b665
12 changed files with 51 additions and 21 deletions
+19 -1
View File
@@ -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