Description:annoy string and fix code style

Match-id-b35226016f866ae3aae1dba6b3a328f717b64e50
This commit is contained in:
xxxx
2022-05-30 09:12:32 +08:00
parent 79fcf6c23d
commit 8271d9cf8a
30 changed files with 215 additions and 268 deletions
+14 -17
View File
@@ -95,7 +95,7 @@ int32_t InputHub::Release()
size_t InputHub::CollectInputEvents(RawEvent* buffer, size_t bufferSize)
{
size_t count;
for (; ;) {
for (;;) {
if (needToScanDevices_) {
needToScanDevices_ = false;
ScanInputDevices(DEVICE_PATH);
@@ -104,11 +104,11 @@ size_t InputHub::CollectInputEvents(RawEvent* buffer, size_t bufferSize)
std::unique_lock<std::mutex> deviceLock(visitMutex_);
std::unique_ptr<Device> device = std::move(*openingDevices_.rbegin());
openingDevices_.pop_back();
DHLOGI("Reporting device opened: id=%d, name=%s\n",
device->id, device->path.c_str());
DHLOGI("Reporting device opened: id=%s, name=%s\n",
GetAnonyInt32(device->id).c_str(), device->path.c_str());
auto [dev_it, inserted] = devices_.insert_or_assign(device->id, std::move(device));
if (!inserted) {
DHLOGI("Device id %d exists, replaced. \n", device->id);
DHLOGI("Device id %s exists, replaced. \n", GetAnonyInt32(device->id).c_str());
}
}
deviceChanged_ = false;
@@ -232,14 +232,15 @@ void InputHub::DeviceIsExists(InputDeviceEvent* event, size_t capacity)
std::unique_lock<std::mutex> deviceLock(visitMutex_);
std::unique_ptr<Device> device = std::move(*openingDevices_.rbegin());
openingDevices_.pop_back();
DHLOGI("Reporting device opened: id=%d, name=%s\n", device->id, device->path.c_str());
DHLOGI("Reporting device opened: id=%s, name=%s\n",
GetAnonyInt32(device->id).c_str(), device->path.c_str());
event->type = DeviceType::DEVICE_ADDED;
event->deviceInfo = device->identifier;
event += 1;
auto [dev_it, inserted] = devices_.insert_or_assign(device->id, std::move(device));
if (!inserted) {
DHLOGI("Device id %d exists, replaced. \n", device->id);
DHLOGI("Device id %s exists, replaced. \n", GetAnonyInt32(device->id).c_str());
}
if (--capacity == 0) {
@@ -254,11 +255,12 @@ size_t InputHub::CollectInputHandler(InputDeviceEvent* buffer, size_t bufferSize
{
InputDeviceEvent* event = buffer;
size_t capacity = bufferSize;
for (; ;) {
for (;;) {
// Report any devices that had last been added/removed.
for (auto it = closingDevices_.begin(); it != closingDevices_.end();) {
std::unique_ptr<Device> device = std::move(*it);
DHLOGI("Reporting device closed: id=%d, name=%s\n", device->id, device->path.c_str());
DHLOGI("Reporting device closed: id=%s, name=%s\n",
GetAnonyInt32(device->id).c_str(), device->path.c_str());
event->type = DeviceType::DEVICE_REMOVED;
event->deviceInfo = device->identifier;
event += 1;
@@ -494,10 +496,6 @@ int32_t InputHub::MakeInputDevice(int fd, InputDevice& identifier)
buffer[sizeof(buffer) - 1] = '\0';
identifier.uniqueId = buffer;
}
DHLOGI(" driver: v%d.%d.%d\n",
driverVersion >> MOVE_POSITION_SIXTEEN,
(driverVersion >> DRIVER_VERSION_MOVE) & DRIVER_VERSION_MAX,
driverVersion & DRIVER_VERSION_MAX);
return DH_SUCCESS;
}
@@ -651,8 +649,8 @@ void InputHub::AddDeviceLocked(std::unique_ptr<Device> device)
void InputHub::CloseDeviceLocked(Device& device)
{
DHLOGI(
"Removed device: path=%s name=%s id=%d fd=%d classes=0x%x",
device.path.c_str(), device.identifier.name.c_str(), device.id,
"Removed device: path=%s name=%s id=%s fd=%d classes=0x%x",
device.path.c_str(), device.identifier.name.c_str(), GetAnonyInt32(device.id).c_str(),
device.fd, device.classes);
UnregisterDeviceFromEpollLocked(device);
@@ -668,7 +666,7 @@ int32_t InputHub::UnregisterDeviceFromEpollLocked(const Device& device) const
int32_t result = UnregisterFdFromEpoll(device.fd);
if (result != DH_SUCCESS) {
DHLOGE(
"Could not remove input device fd from epoll for device %d", device.id);
"Could not remove input device fd from epoll for device %s", GetAnonyInt32(device.id).c_str());
return result;
}
}
@@ -861,8 +859,7 @@ int32_t InputHub::Device::Enable()
chmod(path.c_str(), S_IWRITE | S_IREAD);
fd = open(path.c_str(), O_RDWR | O_CLOEXEC | O_NONBLOCK);
if (fd < 0) {
DHLOGE(
"could not open %s, %s\n", path.c_str(), strerror(errno));
DHLOGE("could not open %s, %s\n", path.c_str(), strerror(errno));
return ERR_DH_INPUT_HUB_DEVICE_ENABLE_FAIL;
}
enabled = true;
+9 -56
View File
@@ -19,6 +19,7 @@
#include <fstream>
#include <sstream>
#include "anonymous_string.h"
#include "distributed_hardware_log.h"
#include "dinput_errcode.h"
@@ -48,7 +49,7 @@ WhiteListUtil &WhiteListUtil::GetInstance(void)
int32_t WhiteListUtil::Init(const std::string &deviceId)
{
DHLOGI("%s called, deviceId=%s", __func__, deviceId.c_str());
DHLOGI("start, deviceId=%s", GetAnonyString(deviceId).c_str());
ClearWhiteList();
if (deviceId.empty()) {
@@ -107,8 +108,7 @@ int32_t WhiteListUtil::Init(const std::string &deviceId)
std::lock_guard<std::mutex> lock(mutex_);
mapDeviceWhiteList_[deviceId] = vecWhiteList;
DHLOGI("%s called success, deviceId=%s", __func__, deviceId.c_str());
PrintWhiteList();
DHLOGI("success, deviceId=%s", GetAnonyString(deviceId).c_str());
return DH_SUCCESS;
}
@@ -151,19 +151,16 @@ void WhiteListUtil::ReadLineDataStepOne(std::string &column, TYPE_KEY_CODE_VEC &
int32_t WhiteListUtil::SyncWhiteList(const std::string &deviceId, const TYPE_WHITE_LIST_VEC &vecWhiteList)
{
DHLOGI("%s called, deviceId=%s",
__func__, deviceId.c_str());
DHLOGI("deviceId=%s", GetAnonyString(deviceId).c_str());
std::lock_guard<std::mutex> lock(mutex_);
mapDeviceWhiteList_[deviceId] = vecWhiteList;
PrintWhiteList();
return DH_SUCCESS;
}
int32_t WhiteListUtil::ClearWhiteList(const std::string &deviceId)
{
DHLOGI("%s called, deviceId=%s",
__func__, deviceId.c_str());
DHLOGI("deviceId=%s", GetAnonyString(deviceId).c_str());
std::lock_guard<std::mutex> lock(mutex_);
mapDeviceWhiteList_.erase(deviceId);
@@ -179,20 +176,17 @@ int32_t WhiteListUtil::ClearWhiteList(void)
int32_t WhiteListUtil::GetWhiteList(const std::string &deviceId, TYPE_WHITE_LIST_VEC &vecWhiteList)
{
DHLOGI("%s called, deviceId=%s",
__func__, deviceId.c_str());
DHLOGI("start, deviceId=%s", GetAnonyString(deviceId).c_str());
std::lock_guard<std::mutex> lock(mutex_);
TYPE_DEVICE_WHITE_LIST_MAP::iterator iter = mapDeviceWhiteList_.find(deviceId);
if (iter != mapDeviceWhiteList_.end()) {
vecWhiteList = iter->second;
DHLOGI("%s called success, deviceId=%s",
__func__, deviceId.c_str());
DHLOGI("GetWhiteList success, deviceId=%s", GetAnonyString(deviceId).c_str());
return DH_SUCCESS;
}
DHLOGE("%s called failure, deviceId=%s",
__func__, deviceId.c_str());
DHLOGI("GetWhiteList fail, deviceId=%s", GetAnonyString(deviceId).c_str());
return ERR_DH_INPUT_WHILTELIST_GET_WHILTELIST_FAIL;
}
@@ -211,9 +205,7 @@ bool WhiteListUtil::CheckSubVecData(const TYPE_COMBINATION_KEY_VEC::iterator &it
bool WhiteListUtil::IsNeedFilterOut(const std::string &deviceId, const BusinessEvent &event)
{
DHLOGI("%s called!", __func__);
PrintWhiteList();
DHLOGI("start, deviceId=%s", GetAnonyString(deviceId).c_str());
std::lock_guard<std::mutex> lock(mutex_);
if (mapDeviceWhiteList_.empty()) {
@@ -227,10 +219,6 @@ bool WhiteListUtil::IsNeedFilterOut(const std::string &deviceId, const BusinessE
return false;
}
DHLOGI(
"%s called, deviceId=%s, keyCode=%d, keyAction=%d",
__func__, deviceId.c_str(), event.keyCode, event.keyAction);
TYPE_KEY_CODE_VEC vecKeyCode = event.pressedKeys;
vecKeyCode.push_back(event.keyCode);
vecKeyCode.push_back(event.keyAction);
@@ -266,41 +254,6 @@ bool WhiteListUtil::IsNeedFilterOut(const std::string &deviceId, const BusinessE
DHLOGI("%s called, bIsMatching=%d", __func__, bIsMatching);
return bIsMatching;
}
void WhiteListUtil::SubPrintWhiteList(const TYPE_WHITE_LIST_VEC &vecWhiteList) const
{
for (int32_t iIndex = 0; iIndex < vecWhiteList.size(); ++iIndex) {
TYPE_COMBINATION_KEY_VEC vecCombinationKey = vecWhiteList[iIndex];
for (int32_t jIndex = 0; jIndex < vecCombinationKey.size(); ++jIndex) {
TYPE_KEY_CODE_VEC vecKeyCode = vecCombinationKey[jIndex];
for (int32_t kIndex = 0; kIndex < vecKeyCode.size(); ++kIndex) {
DHLOGI(
"PrintWhiteList [%d][%d][%d]=[%d]",
iIndex, jIndex, kIndex, vecKeyCode[kIndex]);
}
}
}
}
void WhiteListUtil::PrintWhiteList(void)
{
if (mapDeviceWhiteList_.empty()) {
DHLOGI("%s called, mapDeviceWhiteList_ is empty!", __func__);
return;
}
DHLOGI("%s begin!", __func__);
for (TYPE_DEVICE_WHITE_LIST_MAP::iterator iter = mapDeviceWhiteList_.begin();
iter != mapDeviceWhiteList_.end();
++iter) {
DHLOGI("deviceId=%s", iter->first.c_str());
TYPE_WHITE_LIST_VEC vecWhiteList = iter->second;
SubPrintWhiteList(vecWhiteList);
DHLOGI("%s next!", __func__);
}
DHLOGI("%s end!", __func__);
return;
}
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
-2
View File
@@ -42,8 +42,6 @@ private:
~WhiteListUtil();
WhiteListUtil(const WhiteListUtil &other) = delete;
const WhiteListUtil &operator=(const WhiteListUtil &other) = delete;
void PrintWhiteList(void);
void SubPrintWhiteList(const TYPE_WHITE_LIST_VEC &vecWhiteList) const;
void ReadLineDataStepOne(std::string &column, TYPE_KEY_CODE_VEC &vecKeyCode,
TYPE_COMBINATION_KEY_VEC &vecCombinationKey) const;
bool CheckSubVecData(const TYPE_COMBINATION_KEY_VEC::iterator &iter2,
@@ -129,7 +129,7 @@ int32_t DistributedInputHandler::GetDeviceInfo(std::string& deviceId)
}
deviceId = localNode->networkId;
DHLOGI("device id is %s", deviceId.c_str());
DHLOGI("device id is %s", GetAnonyString(deviceId).c_str());
return DH_SUCCESS;
}
@@ -27,7 +27,7 @@
#include "i_stop_d_input_call_back.h"
#include "i_unregister_d_input_call_back.h"
#include "i_prepare_d_input_call_back.h"
#include "i_unprepare_d_input_call_back.h
#include "i_unprepare_d_input_call_back.h"
namespace OHOS {
namespace DistributedHardware {
@@ -41,28 +41,28 @@ void DistributedInputInnerTest::TearDownTestCase()
void DistributedInputInnerTest::TestPrepareDInputCallback::OnResult(
const std::string& deviceId, const int32_t& status)
const std::string& deviceId, const int32_t& status) const
{
return;
}
void DistributedInputInnerTest::TestUnprepareDInputCallback::OnResult(
const std::string& deviceId, const int32_t& status)
const std::string& deviceId, const int32_t& status) const
{
return;
}
void DistributedInputInnerTest::TestStartDInputCallback::OnResult(
const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status)
const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status) const
{
return;
}
void DistributedInputInnerTest::TestStopDInputCallback::OnResult(
const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status)
const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status) const
{
return;
@@ -52,7 +52,7 @@ public:
public:
TestPrepareDInputCallback() = default;
virtual ~TestPrepareDInputCallback() = default;
void OnResult(const std::string& deviceId, const int32_t& status);
void OnResult(const std::string& deviceId, const int32_t& status) const;
};
class TestUnprepareDInputCallback : public
@@ -60,7 +60,7 @@ public:
public:
TestUnprepareDInputCallback() = default;
virtual ~TestUnprepareDInputCallback() = default;
void OnResult(const std::string& deviceId, const int32_t& status);
void OnResult(const std::string& deviceId, const int32_t& status) const;
};
class TestStartDInputCallback : public
@@ -68,7 +68,7 @@ public:
public:
TestStartDInputCallback() = default;
virtual ~TestStartDInputCallback() = default;
void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status);
void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status) const;
};
class TestStopDInputCallback : public
@@ -76,7 +76,7 @@ public:
public:
TestStopDInputCallback() = default;
virtual ~TestStopDInputCallback() = default;
void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status);
void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status) const;
};
};
} // namespace DistributedInput
@@ -34,7 +34,7 @@ public:
virtual void OnResult(const std::string& deviceId, const std::string& strJson) override;
private:
static inline BrokerDelegator<AddWhiteListInfosCallbackProxy> g_delegator;
static inline BrokerDelegator<AddWhiteListInfosCallbackProxy> delegator_;
};
} // namespace DistributedHardware
} // namespace DistributedInput
@@ -34,7 +34,7 @@ public:
virtual void OnResult(const std::string& deviceId) override;
private:
static inline BrokerDelegator<DelWhiteListInfosCallbackProxy> g_delegator;
static inline BrokerDelegator<DelWhiteListInfosCallbackProxy> delegator_;
};
} // namespace DistributedHardware
} // namespace DistributedInput
@@ -42,7 +42,7 @@ public:
private:
bool SendRequest(IDistributedSinkInput::MessageCode code, MessageParcel &data, MessageParcel &reply);
static inline BrokerDelegator<DistributedInputSinkProxy> g_delegator;
static inline BrokerDelegator<DistributedInputSinkProxy> delegator_;
};
} // namespace DistributedInput
} // namespace DistributedHardware
@@ -60,7 +60,7 @@ public:
private:
bool SendRequest(const IDistributedSourceInput::MessageCode code, MessageParcel &data, MessageParcel &reply);
static inline BrokerDelegator<DistributedInputSourceProxy> g_delegator;
static inline BrokerDelegator<DistributedInputSourceProxy> delegator_;
};
} // namespace DistributedInput
} // namespace DistributedHardware
@@ -34,7 +34,7 @@ public:
virtual void OnResult(const std::string& deviceId, const int32_t& status) override;
private:
static inline BrokerDelegator<PrepareDInputCallbackProxy> g_delegator;
static inline BrokerDelegator<PrepareDInputCallbackProxy> delegator_;
};
} // namespace DistributedHardware
} // namespace DistributedInput
@@ -34,7 +34,7 @@ public:
virtual void OnResult(const std::string& devId, const std::string& dhId, const int32_t& status) override;
private:
static inline BrokerDelegator<RegisterDInputCallbackProxy> g_delegator;
static inline BrokerDelegator<RegisterDInputCallbackProxy> delegator_;
};
} // namespace DistributedHardware
} // namespace DistributedInput
@@ -34,7 +34,7 @@ public:
virtual void OnResult(const std::string& devId, const uint32_t& inputTypes, const int32_t& status) override;
private:
static inline BrokerDelegator<StartDInputCallbackProxy> g_delegator;
static inline BrokerDelegator<StartDInputCallbackProxy> delegator_;
};
} // namespace DistributedHardware
} // namespace DistributedInput
@@ -34,7 +34,7 @@ public:
virtual void OnResult(const int32_t& status, const uint32_t& inputTypes) override;
private:
static inline BrokerDelegator<StartDInputServerCallbackProxy> g_delegator;
static inline BrokerDelegator<StartDInputServerCallbackProxy> delegator_;
};
} // namespace DistributedHardware
} // namespace DistributedInput
@@ -34,7 +34,7 @@ public:
virtual void OnResult(const std::string& devId, const uint32_t& inputTypes, const int32_t& status) override;
private:
static inline BrokerDelegator<StopDInputCallbackProxy> g_delegator;
static inline BrokerDelegator<StopDInputCallbackProxy> delegator_;
};
} // namespace DistributedHardware
} // namespace DistributedInput
@@ -34,7 +34,7 @@ public:
virtual void OnResult(const std::string& deviceId, const int32_t& status) override;
private:
static inline BrokerDelegator<UnprepareDInputCallbackProxy> g_delegator;
static inline BrokerDelegator<UnprepareDInputCallbackProxy> delegator_;
};
} // namespace DistributedHardware
} // namespace DistributedInput
@@ -34,7 +34,7 @@ public:
virtual void OnResult(const std::string& devId, const std::string& dhId, const int32_t& status) override;
private:
static inline BrokerDelegator<UnregisterDInputCallbackProxy> g_delegator;
static inline BrokerDelegator<UnregisterDInputCallbackProxy> delegator_;
};
} // namespace DistributedHardware
} // namespace DistributedInput
+10 -15
View File
@@ -48,7 +48,6 @@ void DistributedInputClient::RegisterDInputCb::OnResult(
return;
}
}
DHLOGI("dinputtest 13");
}
void DistributedInputClient::UnregisterDInputCb::OnResult(
@@ -83,14 +82,9 @@ void DistributedInputClient::StartDInputServerCb::OnResult(const int32_t& status
void DistributedInputClient::AddWhiteListInfosCb::OnResult(const std::string &deviceId, const std::string &strJson)
{
DHLOGI("AddWhiteListInfosCb deviceId :%s. \n", deviceId.c_str());
if (strJson.empty()) {
DHLOGI("AddWhiteListInfosCb whitelist is empty.\n", deviceId.c_str());
return;
if (!strJson.empty()) {
DistributedInputClient::GetInstance().AddWhiteListInfos(deviceId, strJson);
}
DistributedInputClient::GetInstance().AddWhiteListInfos(deviceId, strJson);
}
void DistributedInputClient::DelWhiteListInfosCb::OnResult(const std::string& deviceId)
@@ -150,7 +144,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__, devId.c_str(), devId.c_str(), parameters.c_str());
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), parameters.c_str());
if (!GetDInputSourceProxy()) {
DHLOGE("RegisterDistributedHardware client fail");
@@ -180,7 +174,8 @@ int32_t DistributedInputClient::RegisterDistributedHardware(const std::string& d
int32_t DistributedInputClient::UnregisterDistributedHardware(const std::string& devId, const std::string& dhId,
const std::shared_ptr<UnregisterCallback>& callback)
{
DHLOGI("%s called, deviceId: %s, dhId: %s", __func__, devId.c_str(), devId.c_str());
DHLOGI("%s called, deviceId: %s, dhId: %s",
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str());
if (!GetDInputSourceProxy()) {
DHLOGE("UnregisterDistributedHardware client fail");
@@ -210,7 +205,7 @@ int32_t DistributedInputClient::UnregisterDistributedHardware(const std::string&
int32_t DistributedInputClient::PrepareRemoteInput(
const std::string& deviceId, sptr<IPrepareDInputCallback> callback)
{
DHLOGI("%s called, deviceId: %s", __func__, deviceId.c_str());
DHLOGI("%s called, deviceId: %s", __func__, GetAnonyString(deviceId).c_str());
if (!GetDInputSourceProxy()) {
DHLOGE("PrepareRemoteInput client fail");
@@ -228,7 +223,7 @@ int32_t DistributedInputClient::PrepareRemoteInput(
int32_t DistributedInputClient::UnprepareRemoteInput(
const std::string& deviceId, sptr<IUnprepareDInputCallback> callback)
{
DHLOGI("%s called, deviceId: %s", __func__, deviceId.c_str());
DHLOGI("%s called, deviceId: %s", __func__, GetAnonyString(deviceId).c_str());
if (!GetDInputSourceProxy()) {
DHLOGE("PrepareRemoteInput client fail");
@@ -246,7 +241,7 @@ int32_t DistributedInputClient::UnprepareRemoteInput(
int32_t DistributedInputClient::StartRemoteInput(
const std::string& deviceId, const uint32_t& inputTypes, sptr<IStartDInputCallback> callback)
{
DHLOGI("%s called, deviceId: %s, inputTypes: %d", __func__, deviceId.c_str(), inputTypes);
DHLOGI("%s called, deviceId: %s, inputTypes: %d", __func__, GetAnonyString(deviceId).c_str(), inputTypes);
if (!GetDInputSourceProxy()) {
DHLOGE("StartRemoteInput client fail");
@@ -265,7 +260,7 @@ int32_t DistributedInputClient::StartRemoteInput(
int32_t DistributedInputClient::StopRemoteInput(
const std::string& deviceId, const uint32_t& inputTypes, sptr<IStopDInputCallback> callback)
{
DHLOGI("%s called, deviceId: %s, inputTypes: %d", __func__, deviceId.c_str(), inputTypes);
DHLOGI("%s called, deviceId: %s, inputTypes: %d", __func__, GetAnonyString(deviceId).c_str(), inputTypes);
if (!GetDInputSourceProxy()) {
DHLOGE("StopRemoteInput client fail");
@@ -283,7 +278,7 @@ int32_t DistributedInputClient::StopRemoteInput(
bool DistributedInputClient::IsNeedFilterOut(const std::string& deviceId, const BusinessEvent& event)
{
DHLOGI("%s called, deviceId: %s", __func__, deviceId.c_str());
DHLOGI("%s called, deviceId: %s", __func__, GetAnonyString(deviceId).c_str());
if (serverType == DInputServerType::NULL_SERVER_TYPE) {
DHLOGE("No sa start using.");
return true;
@@ -110,7 +110,7 @@ void DistributedInputCollector::StartCollectEventsThread()
// The RawEvent obtained by the controlled end calls transport and is
// sent to the main control end.
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
std::unique_ptr<nlohmann::json> jsonArrayMsg = std::make_unique<nlohmann::json>();
for (int ind = 0; ind < count; ind++) {
nlohmann::json tmpJson;
tmpJson[INPUT_KEY_WHEN] = mEventBuffer[ind].when;
@@ -57,7 +57,7 @@ DistributedInputSinkManager::DInputSinkListener::~DInputSinkListener()
void DistributedInputSinkManager::DInputSinkListener::onPrepareRemoteInput(
const int32_t& sessionId, const std::string &deviceId)
{
DHLOGI("onPrepareRemoteInput called, sessionId: %d", sessionId);
DHLOGI("onPrepareRemoteInput called, sessionId: %s", GetAnonyInt32(sessionId).c_str());
nlohmann::json jsonStr;
jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ONPREPARE;
@@ -108,7 +108,7 @@ void DistributedInputSinkManager::DInputSinkListener::onPrepareRemoteInput(
void DistributedInputSinkManager::DInputSinkListener::onUnprepareRemoteInput(const int32_t& sessionId)
{
DHLOGI("onUnprepareRemoteInput called, sessionId: %d", sessionId);
DHLOGI("onUnprepareRemoteInput called, sessionId: %s", GetAnonyInt32(sessionId).c_str());
onStopRemoteInput(sessionId, INPUT_TYPE_ALL);
DistributedInputSinkSwitch::GetInstance().RemoveSession(sessionId);
@@ -123,8 +123,8 @@ void DistributedInputSinkManager::DInputSinkListener::onStartRemoteInput(
const int32_t& sessionId, const uint32_t& inputTypes)
{
int32_t curSessionId = DistributedInputSinkSwitch::GetInstance().GetSwitchOpenedSession();
DHLOGI("onStartRemoteInput called, curSessionId:%d, new sessionId: %d",
curSessionId, sessionId);
DHLOGI("onStartRemoteInput called, curSessionId:%s, new sessionId: %s",
GetAnonyInt32(curSessionId).c_str(), GetAnonyInt32(sessionId).c_str());
// set new session
int32_t startRes = DistributedInputSinkSwitch::GetInstance().StartSwitch(sessionId);
@@ -145,7 +145,8 @@ void DistributedInputSinkManager::DInputSinkListener::onStartRemoteInput(
if (curSessionId == ERR_DH_INPUT_SERVER_SINK_GET_OPEN_SESSION_FAIL) {
DHLOGI("onStartRemoteInput called, this is the only session.");
} else if (result) {
DHLOGI("onStartRemoteInput called, notify curSessionId:%d Interrupted.", curSessionId);
DHLOGI("onStartRemoteInput called, notify curSessionId:%s Interrupted.",
GetAnonyInt32(curSessionId).c_str());
nlohmann::json jsonStrStp;
jsonStrStp[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ONSTOP;
jsonStrStp[DINPUT_SOFTBUS_KEY_INPUT_TYPE] = inputTypes;
@@ -176,7 +177,8 @@ void DistributedInputSinkManager::DInputSinkListener::onStartRemoteInput(
void DistributedInputSinkManager::DInputSinkListener::onStopRemoteInput(
const int32_t& sessionId, const uint32_t& inputTypes)
{
DHLOGI("onStopRemoteInput called, sessionId: %d, inputTypes: %d", sessionId, inputTypes);
DHLOGI("onStopRemoteInput called, sessionId: %s, inputTypes: %d",
GetAnonyInt32(sessionId).c_str(), inputTypes);
sinkManagerObj_->SetInputTypes(sinkManagerObj_->GetInputTypes() -
(sinkManagerObj_->GetInputTypes() & inputTypes));
@@ -286,10 +288,8 @@ int32_t DistributedInputSinkManager::Release()
DistributedInputSinkSwitch::GetInstance().StopAllSwitch();
// 2.close all session
DistributedInputSinkTransport::GetInstance().CloseAllSession();
// 3.stop event collect
// DistributedInputCollector::GetInstance().;
// 4.notify callback servertype
// 3.notify callback servertype
SetStartTransFlag(DInputServerType::NULL_SERVER_TYPE);
IStartDInputServerCallback *startServerCB = GetStartDInputServerCback();
if (startServerCB == nullptr) {
@@ -65,10 +65,10 @@ int32_t DistributedInputSinkSwitch::StartSwitch(int32_t sessionId)
}
if (findOld) {
DHLOGI("StartSwitch sessionId:%d is find.", sessionId);
DHLOGI("StartSwitch sessionId:%s is find.", GetAnonyInt32(sessionId).c_str());
return DH_SUCCESS;
} else {
DHLOGE("StartSwitch sessionId:%d fail, not found.", sessionId);
DHLOGE("StartSwitch sessionId:%s fail, not found.", GetAnonyInt32(sessionId).c_str());
return ERR_DH_INPUT_SERVER_SINK_START_SWITCH_FAIL;
}
}
@@ -78,7 +78,7 @@ void DistributedInputSinkSwitch::StopSwitch(int32_t sessionId)
{
std::unique_lock<std::mutex> switchLock(operationMutex_);
if (switchVector_.empty()) {
DHLOGE("StopSwitch sessionId:%d fail,switchVector_ is null.", sessionId);
DHLOGE("StopSwitch sessionId:%s fail,switchVector_ is null.", GetAnonyInt32(sessionId).c_str());
} else {
bool findOld = false;
for (std::vector<SwitchStateData>::iterator it = switchVector_.begin(); it < switchVector_.end(); it++) {
@@ -90,9 +90,9 @@ void DistributedInputSinkSwitch::StopSwitch(int32_t sessionId)
}
if (findOld) {
DHLOGI("StopSwitch sessionId:%d is success.", sessionId);
DHLOGI("StopSwitch sessionId:%s is success.", GetAnonyInt32(sessionId).c_str());
} else {
DHLOGE("StopSwitch sessionId:%d fail,not find it.", sessionId);
DHLOGE("StopSwitch sessionId:%s fail,not find it.", GetAnonyInt32(sessionId).c_str());
}
}
}
@@ -116,7 +116,7 @@ void DistributedInputSinkSwitch::AddSession(int32_t sessionId)
if (switchVector_.empty()) {
SwitchStateData tmp(sessionId, false);
switchVector_.push_back(tmp);
DHLOGI("AddSession sessionId:%d add first.", sessionId);
DHLOGI("AddSession sessionId:%s add first.", GetAnonyInt32(sessionId).c_str());
} else {
bool findOld = false;
for (std::vector<SwitchStateData>::iterator it = switchVector_.begin(); it < switchVector_.end(); it++) {
@@ -128,11 +128,11 @@ void DistributedInputSinkSwitch::AddSession(int32_t sessionId)
}
if (findOld) {
DHLOGI("AddSession sessionId:%d is find.", sessionId);
DHLOGI("AddSession sessionId:%s is find.", GetAnonyInt32(sessionId).c_str());
} else {
SwitchStateData tmp(sessionId, false);
switchVector_.push_back(tmp);
DHLOGI("AddSession sessionId:%d add new.", sessionId);
DHLOGI("AddSession sessionId:%s add new.", GetAnonyInt32(sessionId).c_str());
}
}
}
@@ -141,7 +141,7 @@ void DistributedInputSinkSwitch::RemoveSession(int32_t sessionId)
{
std::unique_lock<std::mutex> switchLock(operationMutex_);
if (switchVector_.empty()) {
DHLOGE("RemoveSession sessionId:%d fail,switch_vector is null.", sessionId);
DHLOGE("RemoveSession sessionId:%s fail,switch_vector is null.", GetAnonyInt32(sessionId).c_str());
} else {
bool findOld = false;
for (std::vector<SwitchStateData>::iterator it = switchVector_.begin(); it < switchVector_.end();) {
@@ -154,9 +154,9 @@ void DistributedInputSinkSwitch::RemoveSession(int32_t sessionId)
}
}
if (findOld) {
DHLOGI("RemoveSession sessionId:%d is success.", sessionId);
DHLOGI("RemoveSession sessionId:%s is success.", GetAnonyInt32(sessionId).c_str());
} else {
DHLOGE("RemoveSession sessionId:%d fail,not find it.", sessionId);
DHLOGE("RemoveSession sessionId:%s fail,not find it.", GetAnonyInt32(sessionId).c_str());
}
}
}
@@ -71,7 +71,7 @@ static void MessageReceived(int32_t sessionId, const void *data, uint32_t dataLe
(void)sessionId;
(void)data;
(void)dataLen;
DHLOGI("sessionId:%d, dataLen:%d", sessionId, dataLen);
DHLOGI("sessionId:%s, dataLen:%d", GetAnonyInt32(sessionId).c_str(), dataLen);
}
static void StreamReceived(int32_t sessionId, const StreamData *data, const StreamData *ext,
@@ -81,7 +81,7 @@ static void StreamReceived(int32_t sessionId, const StreamData *data, const Stre
(void)data;
(void)ext;
(void)param;
DHLOGI("sessionId:%d", sessionId);
DHLOGI("sessionId:%s", GetAnonyInt32(sessionId).c_str());
}
DistributedInputSinkTransport &DistributedInputSinkTransport::GetInstance()
{
@@ -151,7 +151,7 @@ int32_t DistributedInputSinkTransport::Init()
return ERR_DH_INPUT_SERVER_SINK_TRANSPORT_INIT_FAIL;
}
std::string networkId = localNode->networkId;
DHLOGI("Init device networkId is %s", networkId.c_str());
DHLOGI("Init device networkId is %s", GetAnonyString(networkId).c_str());
mySessionName_ = SESSION_NAME_SINK + networkId.substr(0, INTERCEPT_STRING_LENGTH);
int32_t ret = CreateSessionServer(DINPUT_PKG_NAME.c_str(), mySessionName_.c_str(), &iSessionListener);
@@ -178,7 +178,7 @@ int32_t DistributedInputSinkTransport::RespPrepareRemoteInput(
const int32_t sessionId, std::string &smsg)
{
if (sessionId > 0) {
DHLOGI("RespPrepareRemoteInput session:%d, smsg:%s.", sessionId, smsg.c_str());
DHLOGI("RespPrepareRemoteInput session:%s, smsg:%s.", GetAnonyInt32(sessionId).c_str(), smsg.c_str());
int32_t ret = SendMessage(sessionId, smsg);
if (ret != DH_SUCCESS) {
DHLOGE("RespPrepareRemoteInput error, SendMessage fail.");
@@ -195,7 +195,7 @@ int32_t DistributedInputSinkTransport::RespUnprepareRemoteInput(
const int32_t sessionId, std::string &smsg)
{
if (sessionId > 0) {
DHLOGI("RespUnprepareRemoteInput sessionId:%d, smsg:%s.", sessionId, smsg.c_str());
DHLOGI("RespUnprepareRemoteInput sessionId:%s, smsg:%s.", GetAnonyInt32(sessionId).c_str(), smsg.c_str());
int32_t ret = SendMessage(sessionId, smsg);
if (ret != DH_SUCCESS) {
DHLOGE("RespUnprepareRemoteInput error, SendMessage fail.");
@@ -212,7 +212,8 @@ int32_t DistributedInputSinkTransport::RespStartRemoteInput(
const int32_t sessionId, std::string &smsg)
{
if (sessionId > 0) {
DHLOGI("RespStartRemoteInput sessionId:%d, result:%d, smsg:%s.", sessionId, smsg.c_str());
DHLOGI("RespStartRemoteInput sessionId:%s, result:%d, smsg:%s.",
GetAnonyInt32(sessionId).c_str(), smsg.c_str());
int32_t ret = SendMessage(sessionId, smsg);
if (ret != DH_SUCCESS) {
DHLOGE("RespStartRemoteInput error, SendMessage fail.");
@@ -229,7 +230,7 @@ int32_t DistributedInputSinkTransport::RespStopRemoteInput(
const int32_t sessionId, std::string &smsg)
{
if (sessionId > 0) {
DHLOGI("RespStopRemoteInput sessionId:%d, smsg:%s.", sessionId, smsg.c_str());
DHLOGI("RespStopRemoteInput sessionId:%s, smsg:%s.", GetAnonyInt32(sessionId).c_str(), smsg.c_str());
int32_t ret = SendMessage(sessionId, smsg);
if (ret != DH_SUCCESS) {
DHLOGE("RespStopRemoteInput error, SendMessage fail.");
@@ -269,7 +270,7 @@ int32_t DistributedInputSinkTransport::SendMessage(int32_t sessionId, std::strin
int32_t DistributedInputSinkTransport::OnSessionOpened(int32_t sessionId, int32_t result)
{
if (result != DH_SUCCESS) {
DHLOGE("session open failed, sessionId %d", sessionId);
DHLOGE("session open failed, sessionId %s", GetAnonyInt32(sessionId).c_str());
if (sessionIdSet_.count(sessionId) > 0) {
sessionIdSet_.erase(sessionId);
}
@@ -278,34 +279,34 @@ int32_t DistributedInputSinkTransport::OnSessionOpened(int32_t sessionId, int32_
// return 1 is client
int32_t sessionSide = GetSessionSide(sessionId);
DHLOGI("session open succeed, sessionId %d, sessionSide %d", sessionId, sessionSide);
DHLOGI("session open succeed, sessionId %s, sessionSide %d", GetAnonyInt32(sessionId).c_str(), sessionSide);
char mySessionName[SESSION_NAME_SIZE_MAX] = "";
char peerSessionName[SESSION_NAME_SIZE_MAX] = "";
char peerDevId[DEVICE_ID_SIZE_MAX] = "";
int ret = GetMySessionName(sessionId, mySessionName, sizeof(mySessionName));
if (ret != DH_SUCCESS) {
DHLOGI("get my session name failed, session id is %d.", sessionId);
DHLOGI("get my session name failed, session id is %s", GetAnonyInt32(sessionId).c_str());
}
// get other device session name
ret = GetPeerSessionName(sessionId, peerSessionName, sizeof(peerSessionName));
if (ret != DH_SUCCESS) {
DHLOGI("get my peer session name failed, session id is %d.", sessionId);
DHLOGI("get my peer session name failed, session id is %s", GetAnonyInt32(sessionId).c_str());
}
ret = GetPeerDeviceId(sessionId, peerDevId, sizeof(peerDevId));
if (ret != DH_SUCCESS) {
DHLOGI("get my peer device id failed, session id is %d.", sessionId);
DHLOGI("get my peer device id failed, session id is %s", GetAnonyInt32(sessionId).c_str());
}
DHLOGI("mySessionName:%s, peerSessionName:%s, peerDevId:%s.",
mySessionName, peerSessionName, peerDevId);
DHLOGI("mySessionName:%s, peerSessionName:%s, peerDevId:%s",
mySessionName, peerSessionName, GetAnonyString(peerDevId).c_str());
return DH_SUCCESS;
}
void DistributedInputSinkTransport::OnSessionClosed(int32_t sessionId)
{
DHLOGI("OnSessionClosed, sessionId:%d", sessionId);
DHLOGI("OnSessionClosed, sessionId:%s", GetAnonyInt32(sessionId).c_str());
if (sessionIdSet_.count(sessionId) > 0) {
sessionIdSet_.erase(sessionId);
}
@@ -315,7 +316,7 @@ void DistributedInputSinkTransport::OnSessionClosed(int32_t sessionId)
void DistributedInputSinkTransport::OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen)
{
DHLOGI("OnBytesReceived, sessionId:%d, dataLen:%d", sessionId, dataLen);
DHLOGI("OnBytesReceived, sessionId:%s, dataLen:%d", GetAnonyInt32(sessionId).c_str(), dataLen);
if (sessionId < 0 || data == nullptr || dataLen <= 0) {
DHLOGE("OnBytesReceived param check failed");
return;
@@ -351,7 +352,7 @@ void DistributedInputSinkTransport::NotifyPrepareRemoteInput(int32_t sessionId,
}
std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID];
DHLOGI("OnBytesReceived cmdType is TRANS_SOURCE_MSG_PREPARE deviceId:%s.",
deviceId.c_str());
GetAnonyString(deviceId).c_str());
callback_->onPrepareRemoteInput(sessionId, deviceId);
}
@@ -363,7 +364,7 @@ void DistributedInputSinkTransport::NotifyUnprepareRemoteInput(int32_t sessionId
}
std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID];
DHLOGI("OnBytesReceived cmdType TRANS_SOURCE_MSG_UNPREPARE deviceId:%s.",
deviceId.c_str());
GetAnonyString(deviceId).c_str());
callback_->onUnprepareRemoteInput(sessionId);
}
@@ -376,7 +377,7 @@ void DistributedInputSinkTransport::NotifyStartRemoteInput(int32_t sessionId, co
std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID];
uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE];
DHLOGI("OnBytesRecei,ved cmdType is TRANS_SOURCE_MSG_START deviceId:%s inputTypes:%d .",
deviceId.c_str(), inputTypes);
GetAnonyString(deviceId).c_str(), inputTypes);
callback_->onStartRemoteInput(sessionId, inputTypes);
}
@@ -388,7 +389,7 @@ void DistributedInputSinkTransport::NotifyStopRemoteInput(int32_t sessionId, con
}
std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID];
uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE];
DHLOGI("OnBytesReceived cmdType is TRANS_SOURCE_MSG_STOP deviceId:%s.", deviceId.c_str());
DHLOGI("OnBytesReceived cmdType is TRANS_SOURCE_MSG_STOP deviceId:%s.", GetAnonyString(deviceId).c_str());
callback_->onStopRemoteInput(sessionId, inputTypes);
}
@@ -442,10 +443,10 @@ void DistributedInputSinkTransport::HandleSessionData(int32_t sessionId, const s
void DistributedInputSinkTransport::CloseAllSession()
{
std::vector<int32_t> vecSession = DistributedInputSinkSwitch::GetInstance().GetAllSessionId();
DHLOGI("CloseAllSession session vector size is %d.", vecSession.size());
DHLOGI("CloseAllSession session vector size is %d", vecSession.size());
for (int32_t kIndex = 0; kIndex < vecSession.size(); ++kIndex) {
CloseSession(vecSession[kIndex]);
DHLOGI("CloseAllSession [%d] sessionid is %d.", kIndex, vecSession[kIndex]);
DHLOGI("CloseAllSession [%d] sessionid is %s", kIndex, GetAnonyInt32(vecSession[kIndex]).c_str());
}
// clear session data
@@ -45,10 +45,8 @@ DistributedInputInject &DistributedInputInject::GetInstance()
int32_t DistributedInputInject::RegisterDistributedHardware(const std::string& devId, const std::string& dhId,
const std::string& parameters)
{
DHLOGI("%s called", __func__);
DHLOGI("deviveId:%s", devId.c_str());
DHLOGI("hardwareId:%s", dhId.c_str());
DHLOGI("describe:%s", parameters.c_str());
DHLOGI("%s called, deviceId: %s, dhId: %s, parameters: %s",
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), parameters.c_str());
if (inputNodeManager_ == nullptr) {
DHLOGE("the DistributedInputNodeManager is null\n");
@@ -63,8 +61,8 @@ int32_t DistributedInputInject::RegisterDistributedHardware(const std::string& d
int32_t DistributedInputInject::UnregisterDistributedHardware(const std::string& devId, const std::string& dhId)
{
DHLOGI("%s called deviveId:%s hardwareId:%s\n",
__func__, devId.c_str(), dhId.c_str());
DHLOGI("%s called, deviceId: %s, dhId: %s",
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str());
if (inputNodeManager_ == nullptr) {
DHLOGE("the DistributedInputNodeManager is null\n");
return ERR_DH_INPUT_SERVER_SOURCE_INJECT_NODE_MANAGER_IS_NULL;
@@ -113,19 +113,19 @@ void DistributedInputNodeManager::AddDeviceLocked(const std::string& dhId, std::
{
auto [dev_it, inserted] = devices_.insert_or_assign(dhId, std::move(device));
if (!inserted) {
DHLOGI("Device id %s exists, replaced. \n", dhId.c_str());
DHLOGI("Device id %s exists, replaced. \n", GetAnonyString(dhId).c_str());
}
}
int32_t DistributedInputNodeManager::CloseDeviceLocked(const std::string &dhId)
{
DHLOGI("%s called, dhId=%s", __func__, dhId.c_str());
DHLOGI("%s called, dhId=%s", __func__, GetAnonyString(dhId).c_str());
std::map<std::string, std::unique_ptr<VirtualDevice>>::iterator iter = devices_.find(dhId);
if (iter != devices_.end()) {
devices_.erase(iter);
return DH_SUCCESS;
}
DHLOGE("%s called failure, dhId=%s", __func__, dhId.c_str());
DHLOGE("%s called failure, dhId=%s", __func__, GetAnonyString(dhId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_CLOSE_DEVICE_FAIL;
}
@@ -203,7 +203,7 @@ void DistributedInputNodeManager::ProcessInjectEvent(const std::shared_ptr<RawEv
.value = rawEvent->value
};
DHLOGI("InjectEvent dhId: %s, eventType: %d, eventCode: %d, eventValue: %d, when: " PRId64"",
dhId.c_str(), event.type, event.code, event.value, rawEvent->when);
GetAnonyString(dhId).c_str(), event.type, event.code, event.value, rawEvent->when);
VirtualDevice* device = nullptr;
if (getDevice(dhId, device) < 0) {
DHLOGE("could not find the device");
@@ -139,7 +139,7 @@ bool VirtualDevice::SetUp()
if (ioctl(fd_, UI_GET_SYSNAME(sizeof(sysfs_device_name)), sysfs_device_name) < 0) {
DHLOGE("Unable to get input device name: %s", __func__);
}
DHLOGI("get input device name: %s", sysfs_device_name);
DHLOGI("get input device name: %s", GetAnonyString(sysfs_device_name).c_str());
return true;
}
@@ -170,7 +170,7 @@ bool VirtualDevice::InjectInputEvent(const input_event& event)
void VirtualDevice::SetNetWorkId(const std::string netWorkId)
{
DHLOGI("SetNetWorkId %s\n", netWorkId.c_str());
DHLOGI("SetNetWorkId %s\n", GetAnonyString(netWorkId).c_str());
netWorkId_.append(netWorkId);
}
} // namespace DistributedInput
@@ -56,7 +56,7 @@ void DistributedInputSourceManager::DInputSourceListener::onResponseRegisterDist
const std::string deviceId, const std::string dhId, bool result)
{
DHLOGI("onResponseRegisterDistributedHardware called, deviceId: %s, "
"result: %d.", deviceId.c_str(), result);
"result: %s.", GetAnonyString(deviceId).c_str(), result);
if (sourceManagerObj_ == nullptr) {
DHLOGE("onResponseRegisterDistributedHardware sourceManagerObj_ is null.");
return;
@@ -68,7 +68,7 @@ void DistributedInputSourceManager::DInputSourceListener::onResponseRegisterDist
return;
}
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
std::unique_ptr<nlohmann::json> jsonArrayMsg = std::make_unique<nlohmann::json>();
nlohmann::json tmpJson;
tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId;
@@ -84,7 +84,7 @@ void DistributedInputSourceManager::DInputSourceListener::onResponsePrepareRemot
bool result, const std::string &object)
{
DHLOGI("onResponsePrepareRemoteInput called, deviceId: %s, result: %d.",
deviceId.c_str(), result);
GetAnonyString(deviceId).c_str(), result);
if (sourceManagerObj_ == nullptr) {
DHLOGE("onResponsePrepareRemoteInput sourceManagerObj_ is null.");
@@ -96,7 +96,7 @@ void DistributedInputSourceManager::DInputSourceListener::onResponsePrepareRemot
DHLOGE("onResponsePrepareRemoteInput GetCallbackEventHandler is null.");
return;
}
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
std::unique_ptr<nlohmann::json> jsonArrayMsg = std::make_unique<nlohmann::json>();
nlohmann::json tmpJson;
tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId;
@@ -112,7 +112,7 @@ void DistributedInputSourceManager::DInputSourceListener::onResponseUnprepareRem
const std::string deviceId, bool result)
{
DHLOGI("onResponseUnprepareRemoteInput called, deviceId: %s, "
"result: %d.", deviceId.c_str(), result);
"result: %d.", GetAnonyString(deviceId).c_str(), result);
if (sourceManagerObj_ == nullptr) {
DHLOGE("onResponseUnprepareRemoteInput sourceManagerObj_ is null.");
@@ -124,7 +124,7 @@ void DistributedInputSourceManager::DInputSourceListener::onResponseUnprepareRem
DHLOGE("onResponseUnprepareRemoteInput GetCallbackEventHandler is null.");
return;
}
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
std::unique_ptr<nlohmann::json> jsonArrayMsg = std::make_unique<nlohmann::json>();
nlohmann::json tmpJson;
tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId;
@@ -139,7 +139,7 @@ void DistributedInputSourceManager::DInputSourceListener::onResponseStartRemoteI
const std::string deviceId, const uint32_t inputTypes, bool result)
{
DHLOGI("onResponseStartRemoteInput called, deviceId: %s, inputTypes: %d, result: %d.",
deviceId.c_str(), inputTypes, result);
GetAnonyString(deviceId).c_str(), inputTypes, result);
if (sourceManagerObj_ == nullptr) {
DHLOGE("onResponseStartRemoteInput sourceManagerObj_ is null.");
@@ -155,7 +155,7 @@ void DistributedInputSourceManager::DInputSourceListener::onResponseStartRemoteI
sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_ON);
}
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
std::unique_ptr<nlohmann::json> jsonArrayMsg = std::make_unique<nlohmann::json>();
if (jsonArrayMsg == nullptr) {
DHLOGE("onResponseStartRemoteInput jsonArrayMsg is null.");
return;
@@ -175,7 +175,7 @@ void DistributedInputSourceManager::DInputSourceListener::onResponseStopRemoteIn
const std::string deviceId, const uint32_t inputTypes, bool result)
{
DHLOGI("onResponseStopRemoteInput called, deviceId: %s, inputTypes: %d, result: %d.",
deviceId.c_str(), inputTypes, result);
GetAnonyString(deviceId).c_str(), inputTypes, result);
if (sourceManagerObj_ == nullptr) {
DHLOGE("onResponseStopRemoteInput sourceManagerObj_ is null.");
@@ -187,7 +187,7 @@ void DistributedInputSourceManager::DInputSourceListener::onResponseStopRemoteIn
ERR_DH_INPUT_SERVER_SOURCE_MANAGERGET_CALLBACK_HANDLER_FAIL);
return;
}
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
std::unique_ptr<nlohmann::json> jsonArrayMsg = std::make_unique<nlohmann::json>();
nlohmann::json tmpJson;
tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = deviceId;
@@ -205,7 +205,7 @@ void DistributedInputSourceManager::DInputSourceListener::onReceivedEventRemoteI
nlohmann::json inputData = nlohmann::json::parse(event);
int jsonSize = inputData.size();
DHLOGI("onReceivedEventRemoteInput called, deviceId: %s, json size:%d.",
deviceId.c_str(), jsonSize);
GetAnonyString(deviceId).c_str(), jsonSize);
RawEvent mEventBuffer[jsonSize];
int idx = 0;
@@ -255,7 +255,7 @@ void DistributedInputSourceManager::OnStart()
return;
}
DHLOGI("DistributedInputSourceManager start success.");
DHLOGI("DistributedInputSourceManager start success.");
}
bool DistributedInputSourceManager::InitAuto()
@@ -303,7 +303,7 @@ void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyRegis
}
} else {
DHLOGW("ProcessEvent DINPUT_SOURCE_MANAGER_RIGISTER_MSG the "
"devId[%s] dhId[%s] is bad data.", deviceId.c_str(), dhId.c_str());
"devId[%s] dhId[%s] is bad data.", GetAnonyString(deviceId).c_str(), GetAnonyString(dhId).c_str());
}
sourceManagerObj_->RunRegisterCallback(deviceId, dhId,
@@ -368,7 +368,7 @@ void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyStart
sourceManagerObj_->SetInputTypesMap(
deviceId, sourceManagerObj_->GetInputTypesMap(deviceId) | inputTypes);
}
sourceManagerObj_->SetStartTransFlag(result && sourceManagerObj_->GetInputTypesMap(deviceId) > 0 ?
sourceManagerObj_->SetStartTransFlag((result && (sourceManagerObj_->GetInputTypesMap(deviceId) > 0)) ?
DInputServerType::SOURCE_SERVER_TYPE : DInputServerType::NULL_SERVER_TYPE);
if (sourceManagerObj_->GetStartDInputServerCback() != nullptr) {
sourceManagerObj_->GetStartDInputServerCback()->OnResult(
@@ -504,7 +504,7 @@ int32_t DistributedInputSourceManager::Release()
for (std::vector<InputDeviceId>::iterator iter = inputDevice_.begin(); iter != inputDevice_.end(); ++iter) {
std::string devId = iter->devId;
std::string dhId = iter->dhId;
DHLOGI("Release() devId[%s] dhId[%s]", devId.c_str(), dhId.c_str());
DHLOGI("Release() devId[%s] dhId[%s]", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str());
int32_t ret = DistributedInputInject::GetInstance().UnregisterDistributedHardware(devId, dhId);
if (ret != DH_SUCCESS) {
DHLOGW("%s called, remove node fail.", __func__);
@@ -521,7 +521,7 @@ int32_t DistributedInputSourceManager::Release()
InputTypesMap_.clear();
// 4. isStart callback
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
std::unique_ptr<nlohmann::json> jsonArrayMsg = std::make_unique<nlohmann::json>();
nlohmann::json tmpJson;
tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = static_cast<int32_t>(DInputServerType::NULL_SERVER_TYPE);
jsonArrayMsg->push_back(tmpJson);
@@ -544,12 +544,12 @@ int32_t DistributedInputSourceManager::RegisterDistributedHardware(const std::st
const std::string& parameters, sptr<IRegisterDInputCallback> callback)
{
DHLOGI("%s called, deviceId: %s, dhId: %s, parameters: %s",
__func__, devId.c_str(), dhId.c_str(), parameters.c_str());
__func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str(), parameters.c_str());
if (callback == nullptr) {
DHLOGE(
"%s called, deviceId: %s callback is null.",
__func__, devId.c_str());
__func__, GetAnonyString(devId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_FAIL;
}
@@ -611,7 +611,7 @@ void DistributedInputSourceManager::handleStartServerCallback(const std::string&
}
}
if (isAllDevSwitchOff) {
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
std::unique_ptr<nlohmann::json> jsonArrayMsg = std::make_unique<nlohmann::json>();
nlohmann::json tmpJson;
tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = static_cast<int32_t>(DInputServerType::NULL_SERVER_TYPE);
jsonArrayMsg->push_back(tmpJson);
@@ -648,7 +648,7 @@ int32_t DistributedInputSourceManager::RemoveInputNode(const std::string& devId,
int32_t DistributedInputSourceManager::DeleteDevice(const std::string& devId, const std::string& dhId)
{
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
std::unique_ptr<nlohmann::json> jsonArrayMsg = std::make_unique<nlohmann::json>();
nlohmann::json tmpJson;
tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = devId;
tmpJson[INPUT_SOURCEMANAGER_KEY_HWID] = dhId;
@@ -668,10 +668,10 @@ int32_t DistributedInputSourceManager::DeleteDevice(const std::string& devId, co
int32_t DistributedInputSourceManager::UnregisterDistributedHardware(const std::string& devId, const std::string& dhId,
sptr<IUnregisterDInputCallback> callback)
{
DHLOGI("%s called, deviceId: %s, dhId: %s", __func__, devId.c_str(), dhId.c_str());
DHLOGI("%s called, deviceId: %s, dhId: %s", __func__, GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str());
if (callback == nullptr) {
DHLOGE("%s called, deviceId: %s callback is null.", __func__, devId.c_str());
DHLOGE("%s called, deviceId: %s callback is null.", __func__, GetAnonyString(devId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_FAIL;
}
@@ -685,7 +685,7 @@ int32_t DistributedInputSourceManager::UnregisterDistributedHardware(const std::
std::vector<InputDeviceId>::iterator it = std::find(inputDevice_.begin(), inputDevice_.end(), inputDeviceId);
if (it == inputDevice_.end()) {
DHLOGE("%s called, deviceId: %s is not exist.", __func__, devId.c_str());
DHLOGE("%s called, deviceId: %s is not exist.", __func__, GetAnonyString(devId).c_str());
for (std::vector<DInputClientUnregistInfo>::iterator iter =
unregCallbacks_.begin(); iter != unregCallbacks_.end(); iter++) {
if (iter->devId == devId && iter->dhId == dhId) {
@@ -718,9 +718,9 @@ int32_t DistributedInputSourceManager::UnregisterDistributedHardware(const std::
int32_t DistributedInputSourceManager::PrepareRemoteInput(const std::string& deviceId,
sptr<IPrepareDInputCallback> callback, sptr<IAddWhiteListInfosCallback> addWhiteListCallback)
{
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__, deviceId.c_str());
DHLOGE("%s called, deviceId: %s callback is null.", __func__, GetAnonyString(deviceId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL;
}
@@ -763,7 +763,7 @@ int32_t DistributedInputSourceManager::UnprepareRemoteInput(const std::string& d
DHLOGI("%s called, deviceId: %s", __func__, deviceId.c_str());
if (callback == nullptr) {
DHLOGE("%s called, deviceId: %s callback is null.", __func__, deviceId.c_str());
DHLOGE("%s called, deviceId: %s callback is null.", __func__, GetAnonyString(deviceId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL;
}
@@ -799,10 +799,10 @@ int32_t DistributedInputSourceManager::UnprepareRemoteInput(const std::string& d
int32_t DistributedInputSourceManager::StartRemoteInput(
const std::string& deviceId, const uint32_t& inputTypes, sptr<IStartDInputCallback> callback)
{
DHLOGI("%s called, deviceId: %s, inputTypes: %d", __func__, deviceId.c_str(), inputTypes);
DHLOGI("%s called, deviceId: %s, inputTypes: %d", __func__, GetAnonyString(deviceId).c_str(), inputTypes);
if (callback == nullptr) {
DHLOGE("%s called, deviceId: %s callback is null.", __func__, deviceId.c_str());
DHLOGE("%s called, deviceId: %s callback is null.", __func__, GetAnonyString(deviceId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL;
}
@@ -840,10 +840,10 @@ int32_t DistributedInputSourceManager::StartRemoteInput(
int32_t DistributedInputSourceManager::StopRemoteInput(
const std::string& deviceId, const uint32_t& inputTypes, sptr<IStopDInputCallback> callback)
{
DHLOGI("%s called, deviceId: %s, inputTypes: %d", __func__, deviceId.c_str(), inputTypes);
DHLOGI("%s called, deviceId: %s, inputTypes: %d", __func__, GetAnonyString(deviceId).c_str(), inputTypes);
if (callback == nullptr) {
DHLOGE("%s called, deviceId: %s callback is null.", __func__, deviceId.c_str());
DHLOGE("%s called, deviceId: %s callback is null.", __func__, GetAnonyString(deviceId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL;
}
@@ -61,66 +61,66 @@ void DistributedInputSourceManagerTest::TearDownTestCase()
}
void DistributedInputSourceManagerTest::TestRegisterDInputCb::OnResult(
const std::string& devId, const std::string& dhId, const int32_t& status)
const std::string& devId, const std::string& dhId, const int32_t& status) const
{
return;
}
void DistributedInputSourceManagerTest::TestUnregisterDInputCb::OnResult(
const std::string& devId, const std::string& dhId, const int32_t& status)
const std::string& devId, const std::string& dhId, const int32_t& status) const
{
return;
}
void DistributedInputSourceManagerTest::TestPrepareDInputCallback::OnResult(
const std::string& deviceId, const int32_t& status)
const std::string& deviceId, const int32_t& status) const
{
return;
}
void DistributedInputSourceManagerTest::TestUnprepareDInputCallback::OnResult(
const std::string& deviceId, const int32_t& status)
const std::string& deviceId, const int32_t& status) const
{
return;
}
void DistributedInputSourceManagerTest::TestStartDInputCallback::OnResult(
const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status)
const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status) const
{
return;
}
void DistributedInputSourceManagerTest::TestStopDInputCallback::OnResult(
const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status)
const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status) const
{
return;
}
void DistributedInputSourceManagerTest::TestAddWhiteListInfosCb::OnResult(
const std::string &deviceId, const std::string &strJson)
const std::string &deviceId, const std::string &strJson) const
{
return;
}
void DistributedInputSourceManagerTest::TestDelWhiteListInfosCb::OnResult(
const std::string& deviceId)
const std::string& deviceId) const
{
return;
}
int32_t DistributedInputSourceManagerTest::StructTransJson(const InputDevice* pBuf, std::string& strDescriptor)
int32_t DistributedInputSourceManagerTest::StructTransJson(const InputDevice& pBuf, std::string& strDescriptor) const
{
nlohmann::json tmpJson;
tmpJson["name"] = pBuf->name;
tmpJson["location"] = pBuf->location;
tmpJson["uniqueId"] = pBuf->uniqueId;
tmpJson["bus"] = pBuf->bus;
tmpJson["vendor"] = pBuf->vendor;
tmpJson["product"] = pBuf->product;
tmpJson["version"] = pBuf->version;
tmpJson["descriptor"] = pBuf->descriptor;
tmpJson["nonce"] = pBuf->nonce;
tmpJson["classes"] = pBuf->classes;
tmpJson["name"] = pBuf.name;
tmpJson["location"] = pBuf.location;
tmpJson["uniqueId"] = pBuf.uniqueId;
tmpJson["bus"] = pBuf.bus;
tmpJson["vendor"] = pBuf.vendor;
tmpJson["product"] = pBuf.product;
tmpJson["version"] = pBuf.version;
tmpJson["descriptor"] = pBuf.descriptor;
tmpJson["nonce"] = pBuf.nonce;
tmpJson["classes"] = pBuf.classes;
std::ostringstream stream;
stream << tmpJson.dump();
@@ -152,11 +152,11 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterDistributedHardware01, testi
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
std::string dhId = pBuffer.descriptor;
std::string parameters;
StructTransJson(&pBuffer, parameters);
StructTransJson(pBuffer, parameters);
sptr<TestRegisterDInputCb> callback = new TestRegisterDInputCb();
int32_t ret = sourceManager_->RegisterDistributedHardware(devId, dhId, parameters, callback);
EXPECT_EQ(SUCCESS, ret);
}
@@ -179,7 +179,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterDistributedHardware02, testi
std::string dhId = pBuffer.descriptor;
std::string parameters;
std::cout << "RegisterDistributedHardware2"<< std::endl;
StructTransJson(&pBuffer, parameters);
StructTransJson(pBuffer, parameters);
std::cout << "RegisterDistributedHardware3"<< std::endl;
sptr<TestRegisterDInputCb> callback = new TestRegisterDInputCb();
int32_t ret = sourceManager_->RegisterDistributedHardware(devId, dhId, parameters, callback);
@@ -206,7 +206,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterDistributedHardware03, testi
std::string dhId = pBuffer.descriptor;
std::string parameters;
std::cout << "RegisterDistributedHardware12"<< std::endl;
StructTransJson(&pBuffer, parameters);
StructTransJson(pBuffer, parameters);
std::cout << "RegisterDistributedHardware13"<< std::endl;
sptr<TestRegisterDInputCb> callback = new TestRegisterDInputCb();
int32_t ret = sourceManager_->RegisterDistributedHardware(devId, dhId, parameters, callback);
@@ -49,7 +49,7 @@ public:
public:
TestPrepareDInputCallback() = default;
virtual ~TestPrepareDInputCallback() = default;
void OnResult(const std::string& deviceId, const int32_t& status);
void OnResult(const std::string& deviceId, const int32_t& status) const;
};
class TestUnprepareDInputCallback : public
@@ -57,7 +57,7 @@ public:
public:
TestUnprepareDInputCallback() = default;
virtual ~TestUnprepareDInputCallback() = default;
void OnResult(const std::string& deviceId, const int32_t& status);
void OnResult(const std::string& deviceId, const int32_t& status) const;
};
class TestStartDInputCallback : public
@@ -65,7 +65,7 @@ public:
public:
TestStartDInputCallback() = default;
virtual ~TestStartDInputCallback() = default;
void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status);
void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status) const;
};
class TestStopDInputCallback : public
@@ -73,39 +73,39 @@ public:
public:
TestStopDInputCallback() = default;
virtual ~TestStopDInputCallback() = default;
void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status);
void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status) const;
};
class TestRegisterDInputCb : public OHOS::DistributedHardware::DistributedInput::RegisterDInputCallbackStub {
public:
TestRegisterDInputCb() = default;
virtual ~TestRegisterDInputCb() = default;
void OnResult(const std::string& devId, const std::string& dhId, const int32_t& status);
void OnResult(const std::string& devId, const std::string& dhId, const int32_t& status) const;
};
class TestUnregisterDInputCb : public OHOS::DistributedHardware::DistributedInput::UnregisterDInputCallbackStub {
public:
TestUnregisterDInputCb() = default;
virtual ~TestUnregisterDInputCb() = default;
void OnResult(const std::string& devId, const std::string& dhId, const int32_t& status);
void OnResult(const std::string& devId, const std::string& dhId, const int32_t& status) const;
};
class TestAddWhiteListInfosCb : public OHOS::DistributedHardware::DistributedInput::AddWhiteListInfosCallbackStub {
public:
TestAddWhiteListInfosCb() = default;
virtual ~TestAddWhiteListInfosCb() = default;
void OnResult(const std::string &deviceId, const std::string &strJson);
void OnResult(const std::string &deviceId, const std::string &strJson) const;
};
class TestDelWhiteListInfosCb : public OHOS::DistributedHardware::DistributedInput::DelWhiteListInfosCallbackStub {
public:
TestDelWhiteListInfosCb() = default;
virtual ~TestDelWhiteListInfosCb() = default;
void OnResult(const std::string &deviceId);
void OnResult(const std::string &deviceId) const;
};
private:
int32_t StructTransJson(const InputDevice* pBuf, std::string& strDescriptor);
int32_t StructTransJson(const InputDevice& pBuf, std::string& strDescriptor) const;
DistributedInputSourceManager* sourceManager_;
};
} // namespace DistributedInput
@@ -72,7 +72,7 @@ static void MessageReceived(int32_t sessionId, const void *data, uint32_t dataLe
(void)sessionId;
(void)data;
(void)dataLen;
DHLOGI("sessionId:%d, dataLen:%d", sessionId, dataLen);
DHLOGI("sessionId:%s, dataLen:%d", GetAnonyInt32(sessionId).c_str(), dataLen);
}
static void StreamReceived(int32_t sessionId, const StreamData *data, const StreamData *ext,
@@ -82,7 +82,7 @@ static void StreamReceived(int32_t sessionId, const StreamData *data, const Stre
(void)data;
(void)ext;
(void)param;
DHLOGI("sessionId:%d", sessionId);
DHLOGI("sessionId:%s", GetAnonyInt32(sessionId).c_str());
}
DistributedInputSourceTransport &DistributedInputSourceTransport::GetInstance()
{
@@ -108,7 +108,7 @@ int32_t DistributedInputSourceTransport::Init()
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_INIT_FAIL;
}
std::string networkId = localNode->networkId;
DHLOGI("Init device local networkId is %s", networkId.c_str());
DHLOGI("Init device local networkId is %s", GetAnonyString(networkId).c_str());
mySessionName_ = SESSION_NAME_SOURCE + networkId.substr(0, INTERCEPT_STRING_LENGTH);
int32_t ret = CreateSessionServer(DINPUT_PKG_NAME.c_str(), mySessionName_.c_str(), &iSessionListener);
@@ -133,7 +133,7 @@ int32_t DistributedInputSourceTransport::CheckDeviceSessionState(const std::stri
{
std::unique_lock<std::mutex> sessionLock(operationMutex_);
if (sessionDevMap_.count(devId) != 0) {
DHLOGI("CheckDeviceSessionState has opened %s", devId.c_str());
DHLOGI("CheckDeviceSessionState has opened %s", GetAnonyString(devId).c_str());
return DH_SUCCESS;
} else {
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_DEVICE_SESSION_STATE;
@@ -144,7 +144,7 @@ int32_t DistributedInputSourceTransport::OpenInputSoftbus(const std::string &rem
{
int32_t ret = CheckDeviceSessionState(remoteDevId);
if (ret == DH_SUCCESS) {
DHLOGE("Softbus session has already opened, deviceId: %s", remoteDevId.c_str());
DHLOGE("Softbus session has already opened, deviceId: %s", GetAnonyString(remoteDevId).c_str());
return DH_SUCCESS;
}
@@ -154,7 +154,8 @@ int32_t DistributedInputSourceTransport::OpenInputSoftbus(const std::string &rem
int sessionId = OpenSession(mySessionName_.c_str(), peerSessionName.c_str(), remoteDevId.c_str(),
GROUP_ID.c_str(), &g_sessionAttr);
if (sessionId < 0) {
DHLOGE("OpenSession fail, remoteDevId: %s, sessionId: %d", remoteDevId.c_str(), sessionId);
DHLOGE("OpenSession fail, remoteDevId: %s, sessionId: %s",
GetAnonyString(remoteDevId).c_str(), GetAnonyInt32(sessionId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_OPEN_SESSION_FAIL;
}
@@ -164,12 +165,14 @@ int32_t DistributedInputSourceTransport::OpenInputSoftbus(const std::string &rem
auto status = openSessionWaitCond_.wait_for(waitLock, std::chrono::seconds(SESSION_WAIT_TIMEOUT_SECOND),
[this, remoteDevId] () { return channelStatusMap_[remoteDevId]; });
if (!status) {
DHLOGE("OpenSession timeout, remoteDevId: %s, sessionId: %d", remoteDevId.c_str(), sessionId);
DHLOGE("OpenSession timeout, remoteDevId: %s, sessionId: %s",
GetAnonyString(remoteDevId).c_str(), GetAnonyInt32(sessionId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_OPEN_SESSION_TIMEOUT;
}
}
DHLOGI("OpenSession success, remoteDevId:%s, sessionId:%d", remoteDevId.c_str(), sessionId);
DHLOGI("OpenSession success, remoteDevId:%s, sessionId:%s",
GetAnonyString(remoteDevId).c_str(), GetAnonyInt32(sessionId).c_str());
{
std::unique_lock<std::mutex> sessionLock(operationMutex_);
sessionDevMap_[remoteDevId] = sessionId;
@@ -183,12 +186,12 @@ void DistributedInputSourceTransport::CloseInputSoftbus(const std::string &remot
// check this device's all hd is close,this device session close.
if (sessionDevMap_.count(remoteDevId) == 0) {
DHLOGI("SessionDevIdMap Not find remoteDevId: %s", remoteDevId.c_str());
DHLOGI("SessionDevIdMap Not find remoteDevId: %s", GetAnonyString(remoteDevId).c_str());
return;
}
int32_t sessionId = sessionDevMap_[remoteDevId];
DHLOGI("RemoteDevId: %s, sessionId: %d", remoteDevId.c_str(), sessionId);
DHLOGI("RemoteDevId: %s, sessionId: %s", GetAnonyString(remoteDevId).c_str(), GetAnonyInt32(sessionId).c_str());
CloseSession(sessionId);
sessionDevMap_.erase(remoteDevId);
channelStatusMap_.erase(remoteDevId);
@@ -218,16 +221,16 @@ int32_t DistributedInputSourceTransport::PrepareRemoteInput(const std::string& d
std::string smsg = jsonStr.dump();
int32_t ret = SendMsg(sessionId, smsg);
if (ret != DH_SUCCESS) {
DHLOGE("PrepareRemoteInput deviceId:%s, sessionId:%d, smsg:%s, SendMsg error, ret:%d.",
deviceId.c_str(), sessionId, smsg.c_str(), ret);
DHLOGE("PrepareRemoteInput deviceId:%s, sessionId:%s, smsg:%s, SendMsg error, ret:%d.",
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str(), ret);
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_PREPARE_FAIL;
}
DHLOGI("PrepareRemoteInput devId:%s, sessionId:%d, msg:%s.",
deviceId.c_str(), sessionId, smsg.c_str());
DHLOGI("PrepareRemoteInput devId:%s, sessionId:%s, msg:%s.",
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str());
return DH_SUCCESS;
} else {
DHLOGE("PrepareRemoteInput error, not find this device:%s.",
deviceId.c_str());
GetAnonyString(deviceId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_PREPARE_FAIL;
}
}
@@ -244,16 +247,16 @@ int32_t DistributedInputSourceTransport::UnprepareRemoteInput(const std::string&
std::string smsg = jsonStr.dump();
int32_t ret = SendMsg(sessionId, smsg);
if (ret != DH_SUCCESS) {
DHLOGE("UnprepareRemoteInput deviceId:%s, sessionId:%d, smsg:%s, SendMsg error, ret:%d.",
deviceId.c_str(), sessionId, smsg.c_str(), ret);
DHLOGE("UnprepareRemoteInput deviceId:%s, sessionId:%s, smsg:%s, SendMsg error, ret:%d.",
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str(), ret);
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_UNPREPARE_FAIL;
}
DHLOGI("UnprepareRemoteInput deviceId:%s, sessionId:%d, smsg:%s.",
deviceId.c_str(), sessionId, smsg.c_str());
DHLOGI("UnprepareRemoteInput deviceId:%s, sessionId:%s, smsg:%s.",
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str());
return DH_SUCCESS;
} else {
DHLOGE("UnprepareRemoteInput error, not find this device:%s.",
deviceId.c_str());
GetAnonyString(deviceId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_UNPREPARE_FAIL;
}
}
@@ -272,15 +275,16 @@ int32_t DistributedInputSourceTransport::StartRemoteInput(
std::string smsg = jsonStr.dump();
int32_t ret = SendMsg(sessionId, smsg);
if (ret != DH_SUCCESS) {
DHLOGE("StartRemoteInput deviceId:%s, sessionId:%d, smsg:%s, SendMsg error, ret:%d.",
deviceId.c_str(), sessionId, smsg.c_str(), ret);
DHLOGE("StartRemoteInput deviceId:%s, sessionId:%s, smsg:%s, SendMsg error, ret:%d.",
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str(), ret);
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL;
}
DHLOGI("StartRemoteInput deviceId:%s, sessionId:%d, smsg:%s.", deviceId.c_str(), sessionId, smsg.c_str());
DHLOGI("StartRemoteInput deviceId:%s, sessionId:%s, smsg:%s.",
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str());
return DH_SUCCESS;
} else {
DHLOGE("StartRemoteInput error, not find this device:%s.",
deviceId.c_str());
GetAnonyString(deviceId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_START_FAIL;
}
}
@@ -299,14 +303,15 @@ int32_t DistributedInputSourceTransport::StopRemoteInput(
std::string smsg = jsonStr.dump();
int32_t ret = SendMsg(sessionId, smsg);
if (ret != DH_SUCCESS) {
DHLOGE("StopRemoteInput deviceId:%s, sessionId:%d, smsg:%s, SendMsg error, ret:%d.",
deviceId.c_str(), sessionId, smsg.c_str(), ret);
DHLOGE("StopRemoteInput deviceId:%s, sessionId:%s, smsg:%s, SendMsg error, ret:%d.",
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str(), ret);
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL;
}
DHLOGI("StopRemoteInput deviceId:%s, sessionId:%d, smsg:%s.", deviceId.c_str(), sessionId, smsg.c_str());
DHLOGI("StopRemoteInput deviceId:%s, sessionId:%s, smsg:%s.",
GetAnonyString(deviceId).c_str(), GetAnonyInt32(sessionId).c_str(), smsg.c_str());
return DH_SUCCESS;
} else {
DHLOGE("StopRemoteInput error, not find this device:%s.", deviceId.c_str());
DHLOGE("StopRemoteInput error, not find this device:%s.", GetAnonyString(deviceId).c_str());
return ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_STOP_FAIL;
}
}
@@ -332,8 +337,8 @@ int32_t DistributedInputSourceTransport::OnSessionOpened(int32_t sessionId, int3
{
if (result != DH_SUCCESS) {
std::string deviceId = FindDeviceBySession(sessionId);
DHLOGE("session open failed, sessionId:%d, result:%d, "
"deviceId:%s", sessionId, result, deviceId.c_str());
DHLOGE("session open failed, sessionId:%s, result:%d, "
"deviceId:%s", GetAnonyInt32(sessionId).c_str(), result, GetAnonyString(deviceId).c_str());
std::unique_lock<std::mutex> sessionLock(operationMutex_);
if (sessionDevMap_.count(deviceId) > 0) {
sessionDevMap_.erase(deviceId);
@@ -343,26 +348,26 @@ int32_t DistributedInputSourceTransport::OnSessionOpened(int32_t sessionId, int3
std::string deviceId = FindDeviceBySession(sessionId);
int32_t sessionSide = GetSessionSide(sessionId);
DHLOGI("session open succeed, sessionId:%d, sessionSide:%d(1 is "
"client side), deviceId:%s", sessionId, sessionSide, deviceId.c_str());
DHLOGI("session open succeed, sessionId:%s, sessionSide:%d(1 is "
"client side), deviceId:%s", GetAnonyInt32(sessionId).c_str(), sessionSide, GetAnonyString(deviceId).c_str());
char mySessionName[SESSION_NAME_SIZE_MAX] = "";
char peerSessionName[SESSION_NAME_SIZE_MAX] = "";
char peerDevId[DEVICE_ID_SIZE_MAX] = "";
int ret = GetMySessionName(sessionId, mySessionName, sizeof(mySessionName));
if (ret != DH_SUCCESS) {
DHLOGI("get my session name failed, session id is %d.", sessionId);
DHLOGI("get my session name failed, session id is %s", GetAnonyInt32(sessionId).c_str());
}
ret = GetPeerSessionName(sessionId, peerSessionName, sizeof(peerSessionName));
if (ret != DH_SUCCESS) {
DHLOGI("get peer session name failed, session id is %d.", sessionId);
DHLOGI("get peer session name failed, session id is %s", GetAnonyInt32(sessionId).c_str());
}
ret = GetPeerDeviceId(sessionId, peerDevId, sizeof(peerDevId));
if (ret != DH_SUCCESS) {
DHLOGI("get peer device id failed, session id is %d.", sessionId);
DHLOGI("get peer device id failed, session id is %s", GetAnonyInt32(sessionId).c_str());
}
DHLOGI("mySessionName:%s, peerSessionName:%s, peerDevId:%s.",
mySessionName, peerSessionName, peerDevId);
DHLOGI("mySessionName:%s, peerSessionName:%s, peerDevId:%s",
mySessionName, peerSessionName, GetAnonyString(peerDevId).c_str());
{
std::lock_guard<std::mutex> notifyLock(operationMutex_);
channelStatusMap_[peerDevId] = true;
@@ -375,8 +380,8 @@ int32_t DistributedInputSourceTransport::OnSessionOpened(int32_t sessionId, int3
void DistributedInputSourceTransport::OnSessionClosed(int32_t sessionId)
{
std::string deviceId = FindDeviceBySession(sessionId);
DHLOGI("OnSessionClosed, sessionId:%d, deviceId:%s",
sessionId, deviceId.c_str());
DHLOGI("OnSessionClosed, sessionId:%s, deviceId:%s",
GetAnonyInt32(sessionId).c_str(), GetAnonyString(deviceId).c_str());
std::unique_lock<std::mutex> sessionLock(operationMutex_);
if (sessionDevMap_.count(deviceId) > 0) {
sessionDevMap_.erase(deviceId);
@@ -523,7 +528,7 @@ void DistributedInputSourceTransport::HandleSessionData(int32_t sessionId, const
void DistributedInputSourceTransport::OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen)
{
DHLOGI("OnBytesReceived, sessionId:%d, dataLen:%d", sessionId, dataLen);
DHLOGI("OnBytesReceived, sessionId:%s, dataLen:%d", GetAnonyInt32(sessionId).c_str(), dataLen);
if (sessionId < 0 || data == nullptr || dataLen <= 0) {
DHLOGE("OnBytesReceived param check failed");
return;