mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2024-11-27 17:51:04 +00:00
commit
b3c6eabdff
@ -70,7 +70,7 @@ public:
|
||||
static napi_value GetStopInfo(sptr<CallbackInfo> cb);
|
||||
static napi_value GetStateInfo(sptr<CallbackInfo> cb);
|
||||
static napi_value GetStateResult(napi_env env, bool result);
|
||||
static napi_value GetResult(napi_env env, bool result, int32_t errCode);
|
||||
static napi_value GetResult(napi_env env, bool result, int32_t errorCode);
|
||||
static bool IsSameHandle(napi_env env, napi_value handle, napi_ref ref);
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
|
@ -41,7 +41,7 @@ JsEventCooperateTarget::JsEventCooperateTarget()
|
||||
auto ret = coordinationListeners_.insert({ COORDINATION,
|
||||
std::vector<sptr<JsUtilCooperate::CallbackInfo>>()});
|
||||
if (!ret.second) {
|
||||
FI_HILOGW("Failed to insert, errCode:%{public}d", static_cast<int32_t>(DeviceStatus::VAL_NOT_EXP));
|
||||
FI_HILOGW("Failed to add listener, errCode:%{public}d", static_cast<int32_t>(DeviceStatus::VAL_NOT_EXP));
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,15 +59,15 @@ void JsEventCooperateTarget::EmitJsEnable(sptr<JsUtilCooperate::CallbackInfo> cb
|
||||
CHKPV(work);
|
||||
cb->IncStrongRef(nullptr);
|
||||
work->data = cb.GetRefPtr();
|
||||
int32_t result = 0;
|
||||
int32_t ret = 0;
|
||||
if (cb->ref == nullptr) {
|
||||
result = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallEnablePromiseWork, uv_qos_default);
|
||||
ret = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallEnablePromiseWork, uv_qos_default);
|
||||
} else {
|
||||
result = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallEnableAsyncWork, uv_qos_default);
|
||||
ret = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallEnableAsyncWork, uv_qos_default);
|
||||
}
|
||||
|
||||
if (result != 0) {
|
||||
FI_HILOGE("uv_queue_work_with_qos failed");
|
||||
if (ret != 0) {
|
||||
FI_HILOGE("Failed to execute uv_queue_work_with_qos");
|
||||
JsUtilCooperate::DeletePtr<uv_work_t*>(work);
|
||||
cb->DecStrongRef(nullptr);
|
||||
}
|
||||
@ -87,15 +87,15 @@ void JsEventCooperateTarget::EmitJsStart(sptr<JsUtilCooperate::CallbackInfo> cb,
|
||||
CHKPV(work);
|
||||
cb->IncStrongRef(nullptr);
|
||||
work->data = cb.GetRefPtr();
|
||||
int32_t result = 0;
|
||||
int32_t ret = 0;
|
||||
if (cb->ref == nullptr) {
|
||||
result = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallStartPromiseWork, uv_qos_default);
|
||||
ret = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallStartPromiseWork, uv_qos_default);
|
||||
} else {
|
||||
result = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallStartAsyncWork, uv_qos_default);
|
||||
ret = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallStartAsyncWork, uv_qos_default);
|
||||
}
|
||||
|
||||
if (result != 0) {
|
||||
FI_HILOGE("uv_queue_work_with_qos failed");
|
||||
if (ret != 0) {
|
||||
FI_HILOGE("Failed to execute uv_queue_work_with_qos");
|
||||
JsUtilCooperate::DeletePtr<uv_work_t*>(work);
|
||||
cb->DecStrongRef(nullptr);
|
||||
}
|
||||
@ -115,15 +115,15 @@ void JsEventCooperateTarget::EmitJsStop(sptr<JsUtilCooperate::CallbackInfo> cb,
|
||||
CHKPV(work);
|
||||
cb->IncStrongRef(nullptr);
|
||||
work->data = cb.GetRefPtr();
|
||||
int32_t result = 0;
|
||||
int32_t ret = 0;
|
||||
if (cb->ref == nullptr) {
|
||||
result = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallStopPromiseWork, uv_qos_default);
|
||||
ret = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallStopPromiseWork, uv_qos_default);
|
||||
} else {
|
||||
result = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallStopAsyncWork, uv_qos_default);
|
||||
ret = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallStopAsyncWork, uv_qos_default);
|
||||
}
|
||||
|
||||
if (result != 0) {
|
||||
FI_HILOGE("uv_queue_work_with_qos failed");
|
||||
if (ret != 0) {
|
||||
FI_HILOGE("Failed to execute uv_queue_work_with_qos");
|
||||
JsUtilCooperate::DeletePtr<uv_work_t*>(work);
|
||||
cb->DecStrongRef(nullptr);
|
||||
}
|
||||
@ -141,15 +141,15 @@ void JsEventCooperateTarget::EmitJsGetState(sptr<JsUtilCooperate::CallbackInfo>
|
||||
CHKPV(work);
|
||||
cb->IncStrongRef(nullptr);
|
||||
work->data = cb.GetRefPtr();
|
||||
int32_t result = 0;
|
||||
int32_t ret = 0;
|
||||
if (cb->ref == nullptr) {
|
||||
result = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallGetStatePromiseWork, uv_qos_default);
|
||||
ret = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallGetStatePromiseWork, uv_qos_default);
|
||||
} else {
|
||||
result = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallGetStateAsyncWork, uv_qos_default);
|
||||
ret = uv_queue_work_with_qos(loop, work, [](uv_work_t *work) {}, CallGetStateAsyncWork, uv_qos_default);
|
||||
}
|
||||
|
||||
if (result != 0) {
|
||||
FI_HILOGE("uv_queue_work_with_qos failed");
|
||||
if (ret != 0) {
|
||||
FI_HILOGE("Failed to execute uv_queue_work_with_qos");
|
||||
JsUtilCooperate::DeletePtr<uv_work_t*>(work);
|
||||
cb->DecStrongRef(nullptr);
|
||||
}
|
||||
@ -161,7 +161,7 @@ void JsEventCooperateTarget::AddListener(napi_env env, const std::string &type,
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
auto iter = coordinationListeners_.find(type);
|
||||
if (iter == coordinationListeners_.end()) {
|
||||
FI_HILOGE("Find %{public}s failed", type.c_str());
|
||||
FI_HILOGE("Failed to add listener, type:%{public}s", type.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ void JsEventCooperateTarget::RemoveListener(napi_env env, const std::string &typ
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
auto iter = coordinationListeners_.find(type);
|
||||
if (iter == coordinationListeners_.end()) {
|
||||
FI_HILOGE("Find %{public}s failed", type.c_str());
|
||||
FI_HILOGE("Failed to remove listener, type:%{public}s", type.c_str());
|
||||
return;
|
||||
}
|
||||
if (handle == nullptr) {
|
||||
@ -200,7 +200,7 @@ void JsEventCooperateTarget::RemoveListener(napi_env env, const std::string &typ
|
||||
}
|
||||
for (auto it = iter->second.begin(); it != iter->second.end(); ++it) {
|
||||
if (JsUtilCooperate::IsSameHandle(env, handle, (*it)->ref)) {
|
||||
FI_HILOGE("Success in removing monitor");
|
||||
FI_HILOGE("Successfully removed the listener");
|
||||
iter->second.erase(it);
|
||||
goto MONITOR_TAG;
|
||||
}
|
||||
@ -241,7 +241,7 @@ void JsEventCooperateTarget::OnCoordinationMessage(const std::string &networkId,
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
auto changeEvent = coordinationListeners_.find(COORDINATION);
|
||||
if (changeEvent == coordinationListeners_.end()) {
|
||||
FI_HILOGE("Find %{public}s failed", std::string(COORDINATION).c_str());
|
||||
FI_HILOGE("Failed to find the %{public}s", std::string(COORDINATION).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -256,10 +256,10 @@ void JsEventCooperateTarget::OnCoordinationMessage(const std::string &networkId,
|
||||
item->data.deviceDescriptor = networkId;
|
||||
item->IncStrongRef(nullptr);
|
||||
uvWork->data = item.GetRefPtr();
|
||||
int32_t result = uv_queue_work_with_qos(loop, uvWork, [](uv_work_t *uvWork) {},
|
||||
int32_t ret = uv_queue_work_with_qos(loop, uvWork, [](uv_work_t *uvWork) {},
|
||||
EmitCoordinationMessageEvent, uv_qos_default);
|
||||
if (result != 0) {
|
||||
FI_HILOGE("uv_queue_work_with_qos failed");
|
||||
if (ret != 0) {
|
||||
FI_HILOGE("Failed to execute uv_queue_work_with_qos");
|
||||
item->DecStrongRef(nullptr);
|
||||
JsUtilCooperate::DeletePtr<uv_work_t*>(uvWork);
|
||||
}
|
||||
@ -338,8 +338,8 @@ void JsEventCooperateTarget::CallEnableAsyncWork(uv_work_t *work, int32_t status
|
||||
}
|
||||
napi_value processor = nullptr;
|
||||
CHKRV_SCOPE(cb->env, napi_get_reference_value(cb->env, cb->ref, & processor), GET_REFERENCE_VALUE, scope);
|
||||
napi_value result = nullptr;
|
||||
CHKRV_SCOPE(cb->env, napi_call_function(cb->env, nullptr, processor, 1, &object, &result), CALL_FUNCTION, scope);
|
||||
napi_value ret = nullptr;
|
||||
CHKRV_SCOPE(cb->env, napi_call_function(cb->env, nullptr, processor, 1, &object, &ret), CALL_FUNCTION, scope);
|
||||
RELEASE_CALLBACKINFO(cb->env, cb->ref);
|
||||
napi_close_handle_scope(cb->env, scope);
|
||||
}
|
||||
@ -495,8 +495,8 @@ void JsEventCooperateTarget::CallStopAsyncWork(uv_work_t *work, int32_t status)
|
||||
}
|
||||
napi_value handler = nullptr;
|
||||
CHKRV_SCOPE(cb->env, napi_get_reference_value(cb->env, cb->ref, &handler), GET_REFERENCE_VALUE, scope);
|
||||
napi_value result = nullptr;
|
||||
CHKRV_SCOPE(cb->env, napi_call_function(cb->env, nullptr, handler, 1, &object, &result), CALL_FUNCTION, scope);
|
||||
napi_value ret = nullptr;
|
||||
CHKRV_SCOPE(cb->env, napi_call_function(cb->env, nullptr, handler, 1, &object, &ret), CALL_FUNCTION, scope);
|
||||
RELEASE_CALLBACKINFO(cb->env, cb->ref);
|
||||
napi_close_handle_scope(cb->env, scope);
|
||||
}
|
||||
@ -562,9 +562,9 @@ void JsEventCooperateTarget::CallGetStateAsyncWork(uv_work_t *work, int32_t stat
|
||||
}
|
||||
napi_value handlerInfo = nullptr;
|
||||
CHKRV_SCOPE(cb->env, napi_get_reference_value(cb->env, cb->ref, &handlerInfo), GET_REFERENCE_VALUE, scope);
|
||||
napi_value result = nullptr;
|
||||
napi_value ret = nullptr;
|
||||
size_t argc = TWO_PARAM;
|
||||
CHKRV_SCOPE(cb->env, napi_call_function(cb->env, nullptr, handlerInfo, argc, resultObj, &result),
|
||||
CHKRV_SCOPE(cb->env, napi_call_function(cb->env, nullptr, handlerInfo, argc, resultObj, &ret),
|
||||
CALL_FUNCTION, scope);
|
||||
RELEASE_CALLBACKINFO(cb->env, cb->ref);
|
||||
napi_close_handle_scope(cb->env, scope);
|
||||
@ -577,19 +577,19 @@ void JsEventCooperateTarget::EmitCoordinationMessageEvent(uv_work_t *work, int32
|
||||
CHKPV(work);
|
||||
if (work->data == nullptr) {
|
||||
JsUtilCooperate::DeletePtr<uv_work_t*>(work);
|
||||
FI_HILOGE("Check data is nullptr");
|
||||
FI_HILOGE("The data is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
sptr<JsUtilCooperate::CallbackInfo> temp(static_cast<JsUtilCooperate::CallbackInfo*>(work->data));
|
||||
JsUtilCooperate::DeletePtr<uv_work_t*>(work);
|
||||
temp->DecStrongRef(nullptr);
|
||||
auto messageEvent = coordinationListeners_.find(COORDINATION);
|
||||
if (messageEvent == coordinationListeners_.end()) {
|
||||
FI_HILOGE("Find messageEvent failed");
|
||||
auto msgEvent = coordinationListeners_.find(COORDINATION);
|
||||
if (msgEvent == coordinationListeners_.end()) {
|
||||
FI_HILOGE("Failed to find the msgEvent");
|
||||
return;
|
||||
}
|
||||
for (const auto &item : messageEvent->second) {
|
||||
for (const auto &item : msgEvent->second) {
|
||||
napi_handle_scope scope = nullptr;
|
||||
napi_open_handle_scope(item->env, &scope);
|
||||
CHKPC(item->env);
|
||||
@ -602,7 +602,7 @@ void JsEventCooperateTarget::EmitCoordinationMessageEvent(uv_work_t *work, int32
|
||||
napi_value eventMsg = nullptr;
|
||||
auto iter = messageTransform.find(item->data.msg);
|
||||
if (iter == messageTransform.end()) {
|
||||
FI_HILOGE("Find message code failed");
|
||||
FI_HILOGE("Failed to find the message code");
|
||||
CHKRV(napi_close_handle_scope(item->env, scope), CLOSE_SCOPE);
|
||||
return;
|
||||
}
|
||||
@ -627,7 +627,7 @@ void JsEventCooperateTarget::HandleExecuteResult(napi_env env, int32_t errCode)
|
||||
if (errCode != OTHER_ERROR && errCode != RET_OK) {
|
||||
NapiError napiError;
|
||||
if (!UtilNapiError::GetApiError(errCode, napiError)) {
|
||||
FI_HILOGE("This error code could not be found");
|
||||
FI_HILOGE("Failed to find the error code");
|
||||
return;
|
||||
}
|
||||
THROWERR_CUSTOM(env, COMMON_PARAMETER_ERROR, napiError.msg.c_str());
|
||||
|
@ -62,7 +62,7 @@ napi_value JsUtilCooperate::GetStateInfo(sptr<CallbackInfo> cb)
|
||||
return state;
|
||||
}
|
||||
|
||||
napi_value JsUtilCooperate::GetResult(napi_env env, bool result, int32_t errCode)
|
||||
napi_value JsUtilCooperate::GetResult(napi_env env, bool result, int32_t errorCode)
|
||||
{
|
||||
CHKPP(env);
|
||||
napi_value object = nullptr;
|
||||
@ -71,12 +71,12 @@ napi_value JsUtilCooperate::GetResult(napi_env env, bool result, int32_t errCode
|
||||
return object;
|
||||
}
|
||||
NapiError napiError;
|
||||
if (!UtilNapiError::GetApiError(errCode, napiError)) {
|
||||
FI_HILOGE("This error code could not be found");
|
||||
if (!UtilNapiError::GetApiError(errorCode, napiError)) {
|
||||
FI_HILOGE("This errCode could not be found");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value resultCode = nullptr;
|
||||
CHKRP(napi_create_int32(env, errCode, &resultCode), CREATE_INT32);
|
||||
CHKRP(napi_create_int32(env, errorCode, &resultCode), CREATE_INT32);
|
||||
napi_value resultMessage = nullptr;
|
||||
CHKRP(napi_create_string_utf8(env, napiError.msg.data(), NAPI_AUTO_LENGTH, &resultMessage),
|
||||
CREATE_STRING_UTF8);
|
||||
|
@ -36,9 +36,9 @@ public:
|
||||
napi_value handle = nullptr);
|
||||
napi_value Deactivate(napi_env env, bool isUnchained, napi_value handle = nullptr);
|
||||
napi_value GetCrossingSwitchState(napi_env env, const std::string &networkId, napi_value handle = nullptr);
|
||||
void UnregisterListener(napi_env env, const std::string &type, napi_value handle = nullptr);
|
||||
void ResetEnv();
|
||||
void RegisterListener(napi_env env, const std::string &type, napi_value handle);
|
||||
void UnregisterListener(napi_env env, const std::string &type, napi_value handle = nullptr);
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
|
@ -504,7 +504,7 @@ void JsEventTarget::CallGetCrossingSwitchStatePromiseWork(uv_work_t *work, int32
|
||||
CHKPV(work);
|
||||
if (work->data == nullptr) {
|
||||
JsUtil::DeletePtr<uv_work_t*>(work);
|
||||
FI_HILOGE("Check data is nullptr");
|
||||
FI_HILOGE("Switch state, check data is nullptr");
|
||||
return;
|
||||
}
|
||||
sptr<JsUtil::CallbackInfo> cb(static_cast<JsUtil::CallbackInfo *>(work->data));
|
||||
@ -514,13 +514,13 @@ void JsEventTarget::CallGetCrossingSwitchStatePromiseWork(uv_work_t *work, int32
|
||||
napi_handle_scope scope = nullptr;
|
||||
napi_open_handle_scope(cb->env, &scope);
|
||||
if (scope == nullptr) {
|
||||
FI_HILOGE("scope is nullptr");
|
||||
FI_HILOGE("Switch state, scope is nullptr");
|
||||
RELEASE_CALLBACKINFO(cb->env, cb->ref);
|
||||
return;
|
||||
}
|
||||
napi_value state = JsUtil::GetCrossingSwitchStateInfo(cb);
|
||||
if (state == nullptr) {
|
||||
FI_HILOGE("state is nullptr");
|
||||
FI_HILOGE("Switch state, state is nullptr");
|
||||
RELEASE_CALLBACKINFO(cb->env, cb->ref);
|
||||
napi_close_handle_scope(cb->env, scope);
|
||||
return;
|
||||
@ -536,35 +536,35 @@ void JsEventTarget::CallGetCrossingSwitchStateAsyncWork(uv_work_t *work, int32_t
|
||||
CHKPV(work);
|
||||
if (work->data == nullptr) {
|
||||
JsUtil::DeletePtr<uv_work_t*>(work);
|
||||
FI_HILOGE("Check data is nullptr");
|
||||
FI_HILOGE("Switch state asyn, check data is nullptr");
|
||||
return;
|
||||
}
|
||||
sptr<JsUtil::CallbackInfo> cb(static_cast<JsUtil::CallbackInfo *>(work->data));
|
||||
JsUtil::DeletePtr<uv_work_t*>(work);
|
||||
cb->DecStrongRef(nullptr);
|
||||
CHKPV(cb->env);
|
||||
napi_handle_scope handleScope = nullptr;
|
||||
napi_open_handle_scope(cb->env, &handleScope);
|
||||
if (handleScope == nullptr) {
|
||||
FI_HILOGE("handleScope is nullptr");
|
||||
napi_handle_scope scope = nullptr;
|
||||
napi_open_handle_scope(cb->env, &scope);
|
||||
if (scope == nullptr) {
|
||||
FI_HILOGE("The scope is nullptr");
|
||||
RELEASE_CALLBACKINFO(cb->env, cb->ref);
|
||||
return;
|
||||
}
|
||||
napi_value resultObj[2];
|
||||
CHKRV_SCOPE(cb->env, napi_get_undefined(cb->env, &resultObj[0]), GET_UNDEFINED, handleScope);
|
||||
CHKRV_SCOPE(cb->env, napi_get_undefined(cb->env, &resultObj[0]), GET_UNDEFINED, scope);
|
||||
resultObj[1] = JsUtil::GetCrossingSwitchStateInfo(cb);
|
||||
if (resultObj[1] == nullptr) {
|
||||
FI_HILOGE("Object is nullptr");
|
||||
napi_close_handle_scope(cb->env, handleScope);
|
||||
FI_HILOGE("The object is nullptr");
|
||||
napi_close_handle_scope(cb->env, scope);
|
||||
}
|
||||
napi_value handler = nullptr;
|
||||
CHKRV_SCOPE(cb->env, napi_get_reference_value(cb->env, cb->ref, &handler), GET_REFERENCE_VALUE, handleScope);
|
||||
CHKRV_SCOPE(cb->env, napi_get_reference_value(cb->env, cb->ref, &handler), GET_REFERENCE_VALUE, scope);
|
||||
napi_value result = nullptr;
|
||||
size_t argc = TWO_PARAM;
|
||||
CHKRV_SCOPE(cb->env, napi_call_function(cb->env, nullptr, handler, argc, resultObj, &result),
|
||||
CALL_FUNCTION, handleScope);
|
||||
CALL_FUNCTION, scope);
|
||||
RELEASE_CALLBACKINFO(cb->env, cb->ref);
|
||||
napi_close_handle_scope(cb->env, handleScope);
|
||||
napi_close_handle_scope(cb->env, scope);
|
||||
}
|
||||
|
||||
void JsEventTarget::EmitCoordinationMessageEvent(uv_work_t *work, int32_t status)
|
||||
|
@ -40,9 +40,9 @@ napi_value CreateNapiError(const napi_env &env, int32_t errCode, const std::stri
|
||||
|
||||
std::optional <std::string> GetErrMsg(int32_t errorCode)
|
||||
{
|
||||
auto iter = ERROR_MESSAGES.find(errorCode);
|
||||
if (iter != ERROR_MESSAGES.end()) {
|
||||
return iter->second;
|
||||
auto emiter = ERROR_MESSAGES.find(errorCode);
|
||||
if (emiter != ERROR_MESSAGES.end()) {
|
||||
return emiter->second;
|
||||
}
|
||||
FI_HILOGE("Error messages not found");
|
||||
return std::nullopt;
|
||||
|
@ -51,7 +51,7 @@ int32_t DragManagerImpl::StartDrag(const DragData &dragData, std::function<void(
|
||||
}
|
||||
if ((dragData.dragNum <= 0) || (dragData.buffer.size() > MAX_BUFFER_SIZE) ||
|
||||
(dragData.displayX < 0) || (dragData.displayY < 0)) {
|
||||
FI_HILOGE("Start drag, invalid parameter, dragNum:%{public}d, bufferSize:%{public}zu, "
|
||||
FI_HILOGE("Start drag, invalid argument, dragNum:%{public}d, bufferSize:%{public}zu, "
|
||||
"displayX:%{public}d, displayY:%{public}d",
|
||||
dragData.dragNum, dragData.buffer.size(), dragData.displayX, dragData.displayY);
|
||||
return RET_ERR;
|
||||
@ -144,7 +144,7 @@ int32_t DragManagerImpl::AddDraglistener(DragListenerPtr listener)
|
||||
FI_HILOGI("Start monitoring");
|
||||
int32_t ret = DeviceStatusClient::GetInstance().AddDraglistener();
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Failed to register");
|
||||
FI_HILOGE("Failed to register draglistener");
|
||||
return ret;
|
||||
}
|
||||
hasRegistered_ = true;
|
||||
@ -155,7 +155,7 @@ int32_t DragManagerImpl::AddDraglistener(DragListenerPtr listener)
|
||||
})) {
|
||||
dragListener_.push_back(listener);
|
||||
} else {
|
||||
FI_HILOGW("The listener already exists");
|
||||
FI_HILOGW("The draglistener already exists");
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
@ -168,8 +168,8 @@ int32_t DragManagerImpl::RemoveDraglistener(DragListenerPtr listener)
|
||||
dragListener_.clear();
|
||||
} else {
|
||||
dragListener_.erase(std::remove_if(dragListener_.begin(), dragListener_.end(),
|
||||
[listener] (auto iter) {
|
||||
return iter == listener;
|
||||
[listener] (auto lIter) {
|
||||
return lIter == listener;
|
||||
})
|
||||
);
|
||||
}
|
||||
@ -277,4 +277,4 @@ int32_t DragManagerImpl::GetDropType(DropType& dropType)
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
@ -83,12 +83,12 @@ std::shared_ptr<Media::PixelMap> InteractionDragDrawingTest::CreatePixelMap(int3
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (width <= 0 || width > MAX_PIXEL_MAP_WIDTH || height <= 0 || height > MAX_PIXEL_MAP_HEIGHT) {
|
||||
FI_HILOGE("Invalid size, height:%{public}d, width:%{public}d", height, width);
|
||||
FI_HILOGE("Size invalid, height:%{public}d, width:%{public}d", height, width);
|
||||
return nullptr;
|
||||
}
|
||||
Media::InitializationOptions opts;
|
||||
opts.size.width = width;
|
||||
opts.size.height = height;
|
||||
opts.size.width = width;
|
||||
opts.pixelFormat = Media::PixelFormat::BGRA_8888;
|
||||
opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
|
||||
opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE;
|
||||
|
@ -1060,7 +1060,7 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StartDrag_Touch, TestSiz
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
FI_HILOGD("Start drag, displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
@ -1111,7 +1111,7 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StopDrag_Touch, TestSize
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_GetDragTargetPid
|
||||
* @tc.name: GetDragTargetPid_Mouse
|
||||
* @tc.desc: Get the target pid dragged by the mouse
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
@ -1150,7 +1150,7 @@ HWTEST_F(InteractionManagerTest, GetDragTargetPid_Mouse, TestSize.Level1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_GetDragTargetPid
|
||||
* @tc.name: GetDragTargetPid_Touch
|
||||
* @tc.desc: Get the target pid dragged by the touchscreen
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
@ -1190,7 +1190,7 @@ HWTEST_F(InteractionManagerTest, GetDragTargetPid_Touch, TestSize.Level1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_TouchEventDispatch
|
||||
* @tc.name: TouchEventDispatch
|
||||
* @tc.desc: Dispatch the touchscreen events
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
@ -1231,7 +1231,7 @@ HWTEST_F(InteractionManagerTest, TouchEventDispatch, TestSize.Level1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_MouseEventDispatch
|
||||
* @tc.name: MouseEventDispatch
|
||||
* @tc.desc: Dispatch the mouse events
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
@ -1325,7 +1325,7 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_GetShadowOffset, TestSiz
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_GetUdKey
|
||||
* @tc.name: GetUdKey_Mouse
|
||||
* @tc.desc: Get the udKey dragged by the mouse
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
@ -1343,7 +1343,7 @@ HWTEST_F(InteractionManagerTest, GetUdKey_Mouse, TestSize.Level1)
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
FI_HILOGD("Get ud key, displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
@ -1362,7 +1362,7 @@ HWTEST_F(InteractionManagerTest, GetUdKey_Mouse, TestSize.Level1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_GetUdKey
|
||||
* @tc.name: GetUdKey_Touch
|
||||
* @tc.desc: Get the udKey dragged by the touchscreen
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
@ -1400,7 +1400,7 @@ HWTEST_F(InteractionManagerTest, GetUdKey_Touch, TestSize.Level1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_GetDragData_Success
|
||||
* @tc.name: GetDragData_Success
|
||||
* @tc.desc: Get the dragData from interface successfully
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
@ -1414,7 +1414,7 @@ HWTEST_F(InteractionManagerTest, GetDragData_Success, TestSize.Level1)
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
FI_HILOGD("Get drag data, displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
@ -1451,7 +1451,7 @@ HWTEST_F(InteractionManagerTest, GetDragData_Success, TestSize.Level1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_GetDragData_Failed
|
||||
* @tc.name: GetDragData_Failed
|
||||
* @tc.desc: Get the dragData from interface failed
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
@ -1472,7 +1472,7 @@ HWTEST_F(InteractionManagerTest, GetDragData_Failed, TestSize.Level1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_GetDragState
|
||||
* @tc.name: GetDragState
|
||||
* @tc.desc: Get the dragState from interface
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
@ -1483,7 +1483,7 @@ HWTEST_F(InteractionManagerTest, GetDragState, TestSize.Level1)
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
FI_HILOGD("Drag state, displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
@ -1496,7 +1496,7 @@ HWTEST_F(InteractionManagerTest, GetDragState, TestSize.Level1)
|
||||
|
||||
DragState dragState;
|
||||
ret = InteractionManager::GetInstance()->GetDragState(dragState);
|
||||
FI_HILOGD("dragState:%{public}d", dragState);
|
||||
FI_HILOGD("InteractionManager::dragState:%{public}d", dragState);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
EXPECT_EQ(dragState, DragState::START);
|
||||
|
||||
|
@ -51,15 +51,15 @@ void Client::MarkIsEventHandlerChanged(EventHandlerPtr eventHandler)
|
||||
CHKPV(eventHandler_);
|
||||
auto currentRunner = eventHandler_->GetEventRunner();
|
||||
CHKPV(currentRunner);
|
||||
auto newRunner = eventHandler->GetEventRunner();
|
||||
CHKPV(newRunner);
|
||||
auto newEventRunner = eventHandler->GetEventRunner();
|
||||
CHKPV(newEventRunner);
|
||||
isEventHandlerChanged_ = false;
|
||||
if (currentRunner->GetRunnerThreadName() != newRunner->GetRunnerThreadName()) {
|
||||
if (currentRunner->GetRunnerThreadName() != newEventRunner->GetRunnerThreadName()) {
|
||||
isEventHandlerChanged_ = true;
|
||||
FI_HILOGD("Event handler changed");
|
||||
}
|
||||
FI_HILOGD("Current handler name:%{public}s, New handler name:%{public}s",
|
||||
currentRunner->GetRunnerThreadName().c_str(), newRunner->GetRunnerThreadName().c_str());
|
||||
currentRunner->GetRunnerThreadName().c_str(), newEventRunner->GetRunnerThreadName().c_str());
|
||||
}
|
||||
|
||||
bool Client::SendMessage(const NetPacket &pkt) const
|
||||
|
@ -72,4 +72,4 @@ private:
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
#endif // DEVICESTATUS_SRV_PROXY_H
|
||||
#endif // DEVICESTATUS_SRV_PROXY_H
|
@ -137,10 +137,10 @@ int32_t DeviceStatusSrvProxy::RegisterCoordinationListener()
|
||||
FI_HILOGE("Failed to write descriptor");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
CHKPR(remote, RET_ERR);
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
CHKPR(remote, RET_ERR);
|
||||
int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_COORDINATION_MONITOR),
|
||||
data, reply, option);
|
||||
if (ret != RET_OK) {
|
||||
|
@ -82,7 +82,7 @@ void DeviceStatusSrvStub::InitCoordination()
|
||||
void DeviceStatusSrvStub::InitDrag()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
std::map<uint32_t, ConnFunc> dragFuncs_ = {
|
||||
std::map<uint32_t, ConnFunc> dragFuncs = {
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::ALLOC_SOCKET_FD),
|
||||
&DeviceStatusSrvStub::HandleAllocSocketFdStub },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::START_DRAG),
|
||||
@ -114,7 +114,7 @@ void DeviceStatusSrvStub::InitDrag()
|
||||
{static_cast<uint32_t>(DeviceInterfaceCode::GET_DROP_TYPE),
|
||||
&DeviceStatusSrvStub::GetDropTypeStub }
|
||||
};
|
||||
connFuncs_.insert(dragFuncs_.begin(), dragFuncs_.end());
|
||||
connFuncs_.insert(dragFuncs.begin(), dragFuncs.end());
|
||||
}
|
||||
|
||||
bool DeviceStatusSrvStub::CheckCooperatePermission()
|
||||
@ -384,13 +384,13 @@ int32_t DeviceStatusSrvStub::StartDragStub(MessageParcel& data, MessageParcel& r
|
||||
if ((dragData.shadowInfo.x > 0) || (dragData.shadowInfo.y > 0) ||
|
||||
(dragData.shadowInfo.x < -dragData.shadowInfo.pixelMap->GetWidth()) ||
|
||||
(dragData.shadowInfo.y < -dragData.shadowInfo.pixelMap->GetHeight())) {
|
||||
FI_HILOGE("Invalid parameter, shadowInfox:%{public}d, shadowInfoy:%{public}d",
|
||||
FI_HILOGE("Start drag invalid parameter, shadowInfox:%{public}d, shadowInfoy:%{public}d",
|
||||
dragData.shadowInfo.x, dragData.shadowInfo.y);
|
||||
return RET_ERR;
|
||||
}
|
||||
if ((dragData.dragNum <= 0) || (dragData.buffer.size() > MAX_BUFFER_SIZE) ||
|
||||
(dragData.displayX < 0) || (dragData.displayY < 0)) {
|
||||
FI_HILOGE("Invalid parameter, dragNum:%{public}d, bufferSize:%{public}zu, "
|
||||
FI_HILOGE("Start drag invalid parameter, dragNum:%{public}d, bufferSize:%{public}zu, "
|
||||
"displayX:%{public}d, displayY:%{public}d",
|
||||
dragData.dragNum, dragData.buffer.size(), dragData.displayX, dragData.displayY);
|
||||
return RET_ERR;
|
||||
|
@ -79,14 +79,16 @@ public:
|
||||
int32_t PostAsyncTask(DTaskCallback callback) override;
|
||||
void ProcessTasks();
|
||||
|
||||
int32_t GetReadFd() const
|
||||
{
|
||||
return fds_[0];
|
||||
}
|
||||
void SetWorkerThreadId(uint64_t tid)
|
||||
{
|
||||
workerTid_ = tid;
|
||||
}
|
||||
|
||||
int32_t GetReadFd() const
|
||||
{
|
||||
return fds_[0];
|
||||
}
|
||||
|
||||
bool IsCallFromWorkerThread() const
|
||||
{
|
||||
return (GetThisThreadId() == workerTid_);
|
||||
@ -97,10 +99,10 @@ private:
|
||||
TaskPtr PostTask(DTaskCallback callback, Promise *promise = nullptr);
|
||||
|
||||
private:
|
||||
uint64_t workerTid_ { 0 };
|
||||
int32_t fds_[2] {};
|
||||
std::mutex mux_;
|
||||
std::queue<TaskPtr> tasks_;
|
||||
std::mutex mux_;
|
||||
int32_t fds_[2] {};
|
||||
uint64_t workerTid_ { 0 };
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
|
@ -120,10 +120,10 @@ void DelegateTasks::PopPendingTaskList(std::vector<TaskPtr> &tasks)
|
||||
if (tasks_.empty()) {
|
||||
break;
|
||||
}
|
||||
auto duty = tasks_.front();
|
||||
CHKPB(duty);
|
||||
RecoveryId(duty->GetId());
|
||||
tasks.push_back(duty->GetSharedPtr());
|
||||
auto taskDuty = tasks_.front();
|
||||
CHKPB(taskDuty);
|
||||
RecoveryId(taskDuty->GetId());
|
||||
tasks.push_back(taskDuty->GetSharedPtr());
|
||||
tasks_.pop();
|
||||
}
|
||||
}
|
||||
@ -143,13 +143,13 @@ DelegateTasks::TaskPtr DelegateTasks::PostTask(DTaskCallback callback, Promise *
|
||||
ssize_t res = write(fds_[1], &data, sizeof(data));
|
||||
if (res == -1) {
|
||||
RecoveryId(id);
|
||||
FI_HILOGE("Pipe write failed, errno:%{public}d", errno);
|
||||
FI_HILOGE("Write to pipe failed, errno:%{public}d", errno);
|
||||
return nullptr;
|
||||
}
|
||||
TaskPtr task = std::make_shared<Task>(id, callback, promise);
|
||||
tasks_.push(task);
|
||||
std::string taskType = ((promise == nullptr) ? "Async" : "Sync");
|
||||
FI_HILOGD("Post %{public}s", taskType.c_str());
|
||||
FI_HILOGD("TaskType post %{public}s", taskType.c_str());
|
||||
return task->GetSharedPtr();
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
|
@ -32,9 +32,9 @@ namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
inline constexpr size_t BIT_PER_UINT8 { 8 };
|
||||
|
||||
inline constexpr size_t OFFSET(size_t bit)
|
||||
inline constexpr size_t NBYTES(size_t nbits)
|
||||
{
|
||||
return (bit % BIT_PER_UINT8);
|
||||
return (nbits + BIT_PER_UINT8 - 1) / BIT_PER_UINT8;
|
||||
}
|
||||
|
||||
inline constexpr size_t BYTE(size_t bit)
|
||||
@ -42,16 +42,16 @@ inline constexpr size_t BYTE(size_t bit)
|
||||
return (bit / BIT_PER_UINT8);
|
||||
}
|
||||
|
||||
inline constexpr size_t OFFSET(size_t bit)
|
||||
{
|
||||
return (bit % BIT_PER_UINT8);
|
||||
}
|
||||
|
||||
inline bool TestBit(size_t bit, const uint8_t *array)
|
||||
{
|
||||
return ((array)[BYTE(bit)] & (1 << OFFSET(bit)));
|
||||
}
|
||||
|
||||
inline constexpr size_t NBYTES(size_t nbits)
|
||||
{
|
||||
return (nbits + BIT_PER_UINT8 - 1) / BIT_PER_UINT8;
|
||||
}
|
||||
|
||||
class Device final : public IDevice,
|
||||
public IEpollEventSource {
|
||||
public:
|
||||
|
@ -83,12 +83,12 @@ int32_t Device::Open()
|
||||
if (nRetries-- > 0) {
|
||||
static constexpr int32_t DEFAULT_WAIT_TIME { 500 };
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(DEFAULT_WAIT_TIME));
|
||||
FI_HILOGI("Retry opening device \'%{public}s\'", buf);
|
||||
FI_HILOGI("Retry opening the device \'%{public}s\'", buf);
|
||||
} else {
|
||||
return RET_ERR;
|
||||
}
|
||||
} else {
|
||||
FI_HILOGD("Opening \'%{public}s\' successfully", buf);
|
||||
FI_HILOGD("Successful opening \'%{public}s\'", buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -33,16 +33,16 @@ public:
|
||||
public:
|
||||
explicit Device(std::shared_ptr<IDevice> dev);
|
||||
int32_t GetId() const;
|
||||
std::string GetName() const;
|
||||
std::string GetDhid() const;
|
||||
std::string GetName() const;
|
||||
std::string GetNetworkId() const;
|
||||
bool IsRemote();
|
||||
int32_t GetProduct() const;
|
||||
int32_t GetVendor() const;
|
||||
std::string GetPhys() const;
|
||||
std::string GetUniq() const;
|
||||
bool IsPointerDevice() const;
|
||||
bool IsKeyboard() const;
|
||||
bool IsPointerDevice() const;
|
||||
IDevice::KeyboardType GetKeyboardType() const;
|
||||
|
||||
private:
|
||||
@ -51,8 +51,8 @@ public:
|
||||
std::string GenerateDescriptor();
|
||||
std::string Sha256(const std::string &in) const;
|
||||
std::shared_ptr<IDevice> device_ { nullptr };
|
||||
std::string dhid_;
|
||||
std::string networkId_;
|
||||
std::string dhid_;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -22,15 +22,15 @@
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
constexpr int32_t ENCRYPT_TAG_LEN { 32 };
|
||||
constexpr size_t MSG_MAX_SIZE { 45 * 1024 };
|
||||
constexpr uint32_t SESSION_NAME_SIZE_MAX { 256 };
|
||||
constexpr int32_t FILTER_WAIT_TIMEOUT_SECOND { 1 };
|
||||
constexpr int32_t SESSION_SIDE_CLIENT { 1 };
|
||||
constexpr int32_t SESSION_SIDE_SERVER { 0 };
|
||||
constexpr int32_t SESSION_WAIT_TIMEOUT_SECOND { 5 };
|
||||
constexpr uint32_t DEVICE_ID_SIZE_MAX { 65 };
|
||||
constexpr uint32_t INTERCEPT_STRING_LENGTH { 20 };
|
||||
constexpr int32_t SESSION_WAIT_TIMEOUT_SECOND { 5 };
|
||||
constexpr int32_t SESSION_SIDE_SERVER { 0 };
|
||||
constexpr int32_t SESSION_SIDE_CLIENT { 1 };
|
||||
constexpr int32_t FILTER_WAIT_TIMEOUT_SECOND { 1 };
|
||||
constexpr uint32_t SESSION_NAME_SIZE_MAX { 256 };
|
||||
constexpr size_t MSG_MAX_SIZE { 45 * 1024 };
|
||||
constexpr int32_t ENCRYPT_TAG_LEN { 32 };
|
||||
|
||||
#define FI_SOFTBUS_KEY_CMD_TYPE "fi_softbus_key_cmd_type"
|
||||
#define FI_SOFTBUS_KEY_LOCAL_DEVICE_ID "fi_softbus_key_local_device_id"
|
||||
@ -38,8 +38,8 @@ constexpr int32_t FILTER_WAIT_TIMEOUT_SECOND { 1 };
|
||||
#define FI_SOFTBUS_KEY_POINTER_X "fi_softbus_key_pointer_x"
|
||||
#define FI_SOFTBUS_KEY_POINTER_Y "fi_softbus_key_pointer_y"
|
||||
#define FI_SOFTBUS_KEY_RESULT "fi_softbus_key_result"
|
||||
#define FI_SOFTBUS_KEY_OTHER_DEVICE_ID "fi_softbus_key_other_device_id"
|
||||
#define FI_SOFTBUS_KEY_SESSION_ID "fi_softbus_key_session_id"
|
||||
#define FI_SOFTBUS_KEY_OTHER_DEVICE_ID "fi_softbus_key_other_device_id"
|
||||
#define FI_SOFTBUS_POINTER_BUTTON_IS_PRESS "fi_softbus_pointer_button_is_press"
|
||||
|
||||
enum {
|
||||
|
@ -31,26 +31,26 @@ class DeviceProfileAdapter final {
|
||||
DECLARE_DELAYED_SINGLETON(DeviceProfileAdapter);
|
||||
class ProfileEventCallbackImpl final : public DeviceProfile::IProfileEventCallback {
|
||||
public:
|
||||
void OnSyncCompleted(const DeviceProfile::SyncResult &syncResults) override;
|
||||
void OnProfileChanged(const DeviceProfile::ProfileChangeNotification &changeNotification) override;
|
||||
void OnSyncCompleted(const DeviceProfile::SyncResult &syncResults) override;
|
||||
};
|
||||
public:
|
||||
using ProfileEventCallback = std::shared_ptr<DeviceProfile::IProfileEventCallback>;
|
||||
using DPCallback = std::function<void(const std::string &, bool)>;
|
||||
using ProfileEventCallback = std::shared_ptr<DeviceProfile::IProfileEventCallback>;
|
||||
DISALLOW_COPY_AND_MOVE(DeviceProfileAdapter);
|
||||
|
||||
int32_t UpdateCrossingSwitchState(bool state);
|
||||
int32_t UpdateCrossingSwitchState(bool state, const std::vector<std::string> &deviceIds);
|
||||
int32_t UpdateCrossingSwitchState(bool state);
|
||||
bool GetCrossingSwitchState(const std::string &networkId);
|
||||
int32_t RegisterCrossingStateListener(const std::string &networkId, DPCallback callback);
|
||||
int32_t UnregisterCrossingStateListener(const std::string &networkId);
|
||||
int32_t RegisterCrossingStateListener(const std::string &networkId, DPCallback callback);
|
||||
|
||||
private:
|
||||
int32_t RegisterProfileListener(const std::string &networkId);
|
||||
void OnProfileChanged(const std::string &networkId);
|
||||
std::map<std::string, DeviceProfileAdapter::ProfileEventCallback> profileEventCallbacks_;
|
||||
int32_t RegisterProfileListener(const std::string &networkId);
|
||||
std::mutex adapterLock_;
|
||||
std::map<std::string, DeviceProfileAdapter::DPCallback> callbacks_;
|
||||
std::map<std::string, DeviceProfileAdapter::ProfileEventCallback> profileEventCallbacks_;
|
||||
const std::string characteristicsName_ { "currentStatus" };
|
||||
};
|
||||
|
||||
|
@ -42,13 +42,13 @@ public:
|
||||
{
|
||||
return static_cast<int32_t>(CoordinationMessage::COORDINATION_FAIL);
|
||||
}
|
||||
virtual void OnKeyboardOnline(const std::string &dhid, const std::pair<std::string, std::string> &networkIds) {}
|
||||
virtual void SetStartDeviceDhid(const std::string &startDeviceDhid) {}
|
||||
virtual void OnKeyboardOnline(const std::string &dhid, const std::pair<std::string, std::string> &networkIds) {}
|
||||
|
||||
protected:
|
||||
int32_t PrepareAndStart(const std::string &remoteNetworkId, int32_t startDeviceId);
|
||||
bool NeedPrepare(const std::string &remoteNetworkId, const std::string &originNetworkId);
|
||||
void OnPrepareDistributedInput(bool isSuccess, const std::string &remoteNetworkId, int32_t startDeviceId);
|
||||
bool NeedPrepare(const std::string &remoteNetworkId, const std::string &originNetworkId);
|
||||
int32_t StartRemoteInput(int32_t startDeviceId);
|
||||
virtual void OnStartRemoteInput(bool isSuccess, const std::string &remoteNetworkId, int32_t startDeviceId);
|
||||
|
||||
|
@ -139,7 +139,7 @@ std::string CoordinationDeviceManager::Device::GenerateDescriptor()
|
||||
const std::string DH_ID_PREFIX { "Input_" };
|
||||
std::string descriptor;
|
||||
if (IsRemote() && !phys.empty()) {
|
||||
FI_HILOGD("physicalPath:%{public}s", phys.c_str());
|
||||
FI_HILOGD("Generate descriptor, physicalPath:%{public}s", phys.c_str());
|
||||
std::vector<std::string> idParts;
|
||||
StringSplit(phys.c_str(), SPLIT_SYMBOL, idParts);
|
||||
if (idParts.size() == NETWORK_ID_NUMS) {
|
||||
@ -148,8 +148,8 @@ std::string CoordinationDeviceManager::Device::GenerateDescriptor()
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
const std::string name = GetName();
|
||||
const std::string uniq = GetUniq();
|
||||
const std::string name = GetName();
|
||||
std::string rawDescriptor = StringPrintf(":%04x:%04x:", GetVendor(), GetProduct());
|
||||
|
||||
if (!uniq.empty()) {
|
||||
@ -162,7 +162,7 @@ std::string CoordinationDeviceManager::Device::GenerateDescriptor()
|
||||
rawDescriptor += "name:" + std::regex_replace(name, std::regex(" "), "");
|
||||
}
|
||||
descriptor = DH_ID_PREFIX + Sha256(rawDescriptor);
|
||||
FI_HILOGD("Created descriptor raw:%{public}s", rawDescriptor.c_str());
|
||||
FI_HILOGD("Generate descriptor, created descriptor raw:%{public}s", rawDescriptor.c_str());
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@ -307,11 +307,11 @@ bool CoordinationDeviceManager::HasLocalPointerDevice() const
|
||||
for (const auto &[id, dev] : devices_) {
|
||||
CHKPC(dev);
|
||||
if (!dev->IsRemote() && dev->IsPointerDevice()) {
|
||||
FI_HILOGD("It is currently a mouse device");
|
||||
FI_HILOGD("Local pointer, it is currently a mouse device");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
FI_HILOGD("Not currently a mouse device");
|
||||
FI_HILOGD("Local pointer, not currently a mouse device");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ void CoordinationDeviceManager::OnDeviceRemoved(std::shared_ptr<IDevice> device)
|
||||
CHKPV(device);
|
||||
auto iter = devices_.find(device->GetId());
|
||||
if (iter == devices_.end()) {
|
||||
FI_HILOGE("The device corresponding to the current id:%{public}d cannot be found", device->GetId());
|
||||
FI_HILOGE("Device removed, the device corresponding to the current id:%{public}d cannot be found", device->GetId());
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<Device> dev = iter->second;
|
||||
|
@ -160,11 +160,11 @@ void CoordinationEventManager::NotifyCoordinationState(SessionPtr sess, MessageI
|
||||
NetPacket pkt(msgId);
|
||||
pkt << userData << state;
|
||||
if (pkt.ChkRWError()) {
|
||||
FI_HILOGE("Packet write data failed");
|
||||
FI_HILOGE("Coordination state, packet write data failed");
|
||||
return;
|
||||
}
|
||||
if (!sess->SendMsg(pkt)) {
|
||||
FI_HILOGE("Sending failed");
|
||||
FI_HILOGE("Coordination state, sending failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ void ResponseStartRemoteCoordination(int32_t sessionId, const JsonParser &parser
|
||||
cJSON* networkId = cJSON_GetObjectItemCaseSensitive(parser.json, FI_SOFTBUS_KEY_LOCAL_DEVICE_ID);
|
||||
cJSON* buttonIsPressed = cJSON_GetObjectItemCaseSensitive(parser.json, FI_SOFTBUS_POINTER_BUTTON_IS_PRESS);
|
||||
if (!cJSON_IsString(networkId) || !cJSON_IsBool(buttonIsPressed)) {
|
||||
FI_HILOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ONPREPARE, data type is error");
|
||||
FI_HILOGE("The data type of CJSON is incorrect");
|
||||
return;
|
||||
}
|
||||
COOR_SM->StartRemoteCoordination(networkId->valuestring, cJSON_IsTrue(buttonIsPressed));
|
||||
@ -67,7 +67,7 @@ void ResponseStartRemoteCoordinationResult(int32_t sessionId, const JsonParser &
|
||||
cJSON* x = cJSON_GetObjectItemCaseSensitive(parser.json, FI_SOFTBUS_KEY_POINTER_X);
|
||||
cJSON* y = cJSON_GetObjectItemCaseSensitive(parser.json, FI_SOFTBUS_KEY_POINTER_Y);
|
||||
if (!cJSON_IsBool(result) || !cJSON_IsString(dhid) || !cJSON_IsNumber(x) || !cJSON_IsNumber(y)) {
|
||||
FI_HILOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ONPREPARE, data type is error");
|
||||
FI_HILOGE("The data type of CJSON is incorrect");
|
||||
return;
|
||||
}
|
||||
COOR_SM->StartRemoteCoordinationResult(cJSON_IsTrue(result), dhid->valuestring, x->valueint, y->valueint);
|
||||
@ -79,7 +79,7 @@ void ResponseStopRemoteCoordination(int32_t sessionId, const JsonParser &parser)
|
||||
cJSON* result = cJSON_GetObjectItemCaseSensitive(parser.json, FI_SOFTBUS_KEY_RESULT);
|
||||
|
||||
if (!cJSON_IsBool(result)) {
|
||||
FI_HILOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ONPREPARE, data type is error");
|
||||
FI_HILOGE("The data type of CJSON is incorrect");
|
||||
return;
|
||||
}
|
||||
COOR_SM->StopRemoteCoordination(cJSON_IsTrue(result));
|
||||
@ -91,7 +91,7 @@ void ResponseStopRemoteCoordinationResult(int32_t sessionId, const JsonParser &p
|
||||
cJSON* result = cJSON_GetObjectItemCaseSensitive(parser.json, FI_SOFTBUS_KEY_RESULT);
|
||||
|
||||
if (!cJSON_IsBool(result)) {
|
||||
FI_HILOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ONPREPARE, data type is error");
|
||||
FI_HILOGE("The data type of CJSON is incorrect");
|
||||
return;
|
||||
}
|
||||
COOR_SM->StopRemoteCoordinationResult(cJSON_IsTrue(result));
|
||||
@ -103,7 +103,7 @@ void ResponseNotifyUnchainedResult(int32_t sessionId, const JsonParser &parser)
|
||||
cJSON* networkId = cJSON_GetObjectItemCaseSensitive(parser.json, FI_SOFTBUS_KEY_LOCAL_DEVICE_ID);
|
||||
cJSON* result = cJSON_GetObjectItemCaseSensitive(parser.json, FI_SOFTBUS_KEY_RESULT);
|
||||
if (!cJSON_IsString(networkId) || !cJSON_IsBool(result)) {
|
||||
FI_HILOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ONPREPARE, data type is error");
|
||||
FI_HILOGE("The data type of CJSON is incorrect");
|
||||
return;
|
||||
}
|
||||
COOR_SM->NotifyUnchainedResult(networkId->valuestring, cJSON_IsTrue(result));
|
||||
@ -115,7 +115,7 @@ void ResponseStartCoordinationOtherResult(int32_t sessionId, const JsonParser &p
|
||||
cJSON* networkId = cJSON_GetObjectItemCaseSensitive(parser.json, FI_SOFTBUS_KEY_OTHER_DEVICE_ID);
|
||||
|
||||
if (!cJSON_IsString(networkId)) {
|
||||
FI_HILOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ONPREPARE, data type is error");
|
||||
FI_HILOGE("The data type of CJSON is incorrect");
|
||||
return;
|
||||
}
|
||||
COOR_SM->StartCoordinationOtherResult(networkId->valuestring);
|
||||
@ -157,7 +157,7 @@ int32_t CoordinationSoftbusAdapter::Init()
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
const std::string SESSION_NAME = "ohos.msdp.device_status.";
|
||||
const std::string SESS_NAME = "ohos.msdp.device_status.";
|
||||
sessListener_ = {
|
||||
.OnSessionOpened = SessionOpened,
|
||||
.OnSessionClosed = SessionClosed,
|
||||
@ -170,9 +170,9 @@ int32_t CoordinationSoftbusAdapter::Init()
|
||||
FI_HILOGE("Local network id is empty");
|
||||
return RET_ERR;
|
||||
}
|
||||
std::string sessionName = SESSION_NAME + localNetworkId.substr(0, INTERCEPT_STRING_LENGTH);
|
||||
std::string sessionName = SESS_NAME + localNetworkId.substr(0, INTERCEPT_STRING_LENGTH);
|
||||
if (sessionName == localSessionName_) {
|
||||
FI_HILOGI("Session server has already created");
|
||||
FI_HILOGI("Softbus session server has already created");
|
||||
return RET_OK;
|
||||
}
|
||||
int32_t ret = RET_ERR;
|
||||
@ -180,14 +180,14 @@ int32_t CoordinationSoftbusAdapter::Init()
|
||||
FI_HILOGD("Remove last sesison server, sessionName:%{public}s", localSessionName_.c_str());
|
||||
ret = RemoveSessionServer(FI_PKG_NAME, localSessionName_.c_str());
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Remove session server failed, error code:%{public}d", ret);
|
||||
FI_HILOGE("Remove softbus session server failed, error code:%{public}d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
localSessionName_ = sessionName;
|
||||
ret = CreateSessionServer(FI_PKG_NAME, localSessionName_.c_str(), &sessListener_);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Create session server failed, error code:%{public}d", ret);
|
||||
FI_HILOGE("Create softbus session server failed, error code:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
@ -204,10 +204,10 @@ void CoordinationSoftbusAdapter::Release()
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
std::for_each(sessionDevs_.begin(), sessionDevs_.end(), [](auto item) {
|
||||
CloseSession(item.second);
|
||||
FI_HILOGD("Close session success");
|
||||
FI_HILOGD("Session closed successful");
|
||||
});
|
||||
int32_t ret = RemoveSessionServer(FI_PKG_NAME, localSessionName_.c_str());
|
||||
FI_HILOGD("RemoveSessionServer ret:%{public}d", ret);
|
||||
FI_HILOGD("Release removeSessionServer ret:%{public}d", ret);
|
||||
sessionDevs_.clear();
|
||||
channelStatuss_.clear();
|
||||
}
|
||||
@ -295,7 +295,7 @@ int32_t CoordinationSoftbusAdapter::StartRemoteCoordination(const std::string &l
|
||||
CALL_DEBUG_ENTER;
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
if (sessionDevs_.find(remoteNetworkId) == sessionDevs_.end()) {
|
||||
FI_HILOGE("Start remote coordination error, not found this device");
|
||||
FI_HILOGE("Failed to discover the remote device");
|
||||
return RET_ERR;
|
||||
}
|
||||
int32_t sessionId = sessionDevs_[remoteNetworkId];
|
||||
@ -315,12 +315,12 @@ int32_t CoordinationSoftbusAdapter::StartRemoteCoordination(const std::string &l
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_LOCAL_DEVICE_ID, cJSON_CreateString(localNetworkId.c_str()));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_SESSION_ID, cJSON_CreateNumber(sessionId));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_POINTER_BUTTON_IS_PRESS, cJSON_CreateBool(isPointerButtonPressed));
|
||||
char *smsg = cJSON_Print(jsonStr);
|
||||
char *sendMsg = cJSON_Print(jsonStr);
|
||||
cJSON_Delete(jsonStr);
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
cJSON_free(smsg);
|
||||
int32_t ret = SendMsg(sessionId, sendMsg);
|
||||
cJSON_free(sendMsg);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Start remote coordination send session msg failed, ret:%{public}d", ret);
|
||||
FI_HILOGE("Failed to send the sendMsg, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
if (isPointerButtonPressed) {
|
||||
@ -340,7 +340,7 @@ int32_t CoordinationSoftbusAdapter::StartRemoteCoordinationResult(const std::str
|
||||
CALL_DEBUG_ENTER;
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
if (sessionDevs_.find(remoteNetworkId) == sessionDevs_.end()) {
|
||||
FI_HILOGE("Stop remote coordination error, not found this device");
|
||||
FI_HILOGE("Failed to discover the remote device");
|
||||
return RET_ERR;
|
||||
}
|
||||
int32_t sessionId = sessionDevs_[remoteNetworkId];
|
||||
@ -351,12 +351,12 @@ int32_t CoordinationSoftbusAdapter::StartRemoteCoordinationResult(const std::str
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_POINTER_X, cJSON_CreateNumber(xPercent));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_POINTER_Y, cJSON_CreateNumber(yPercent));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_SESSION_ID, cJSON_CreateNumber(sessionId));
|
||||
char *smsg = cJSON_Print(jsonStr);
|
||||
char *sendMsg = cJSON_Print(jsonStr);
|
||||
cJSON_Delete(jsonStr);
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
cJSON_free(smsg);
|
||||
int32_t ret = SendMsg(sessionId, sendMsg);
|
||||
cJSON_free(sendMsg);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Start remote coordination result send session msg failed");
|
||||
FI_HILOGE("Failed to send the sendMsg, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
@ -367,7 +367,7 @@ int32_t CoordinationSoftbusAdapter::StopRemoteCoordination(const std::string &re
|
||||
CALL_DEBUG_ENTER;
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
if (sessionDevs_.find(remoteNetworkId) == sessionDevs_.end()) {
|
||||
FI_HILOGE("Stop remote coordination error, not found this device");
|
||||
FI_HILOGE("Failed to discover the remote device");
|
||||
return RET_ERR;
|
||||
}
|
||||
int32_t sessionId = sessionDevs_[remoteNetworkId];
|
||||
@ -375,12 +375,12 @@ int32_t CoordinationSoftbusAdapter::StopRemoteCoordination(const std::string &re
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_CMD_TYPE, cJSON_CreateNumber(REMOTE_COORDINATION_STOP));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_RESULT, cJSON_CreateBool(isUnchained));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_SESSION_ID, cJSON_CreateNumber(sessionId));
|
||||
char *smsg = cJSON_Print(jsonStr);
|
||||
char *sendMsg = cJSON_Print(jsonStr);
|
||||
cJSON_Delete(jsonStr);
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
cJSON_free(smsg);
|
||||
int32_t ret = SendMsg(sessionId, sendMsg);
|
||||
cJSON_free(sendMsg);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Stop remote coordination send session msg failed");
|
||||
FI_HILOGE("Failed to send the sendMsg, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
@ -392,7 +392,7 @@ int32_t CoordinationSoftbusAdapter::StopRemoteCoordinationResult(const std::stri
|
||||
CALL_DEBUG_ENTER;
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
if (sessionDevs_.find(remoteNetworkId) == sessionDevs_.end()) {
|
||||
FI_HILOGE("Stop remote coordination result error, not found this device");
|
||||
FI_HILOGE("Failed to discover the remote device");
|
||||
return RET_ERR;
|
||||
}
|
||||
int32_t sessionId = sessionDevs_[remoteNetworkId];
|
||||
@ -400,12 +400,12 @@ int32_t CoordinationSoftbusAdapter::StopRemoteCoordinationResult(const std::stri
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_CMD_TYPE, cJSON_CreateNumber(REMOTE_COORDINATION_STOP_RES));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_RESULT, cJSON_CreateBool(isSuccess));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_SESSION_ID, cJSON_CreateNumber(sessionId));
|
||||
char *smsg = cJSON_Print(jsonStr);
|
||||
char *sendMsg = cJSON_Print(jsonStr);
|
||||
cJSON_Delete(jsonStr);
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
cJSON_free(smsg);
|
||||
int32_t ret = SendMsg(sessionId, sendMsg);
|
||||
cJSON_free(sendMsg);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Stop remote coordination result send session msg failed");
|
||||
FI_HILOGE("Failed to send the sendMsg, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
@ -417,7 +417,7 @@ int32_t CoordinationSoftbusAdapter::NotifyUnchainedResult(const std::string &loc
|
||||
CALL_DEBUG_ENTER;
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
if (sessionDevs_.find(remoteNetworkId) == sessionDevs_.end()) {
|
||||
FI_HILOGE("Stop remote coordination result err, not found this device");
|
||||
FI_HILOGE("Failed to discover the remote device");
|
||||
return RET_ERR;
|
||||
}
|
||||
int32_t sessionId = sessionDevs_[remoteNetworkId];
|
||||
@ -427,13 +427,13 @@ int32_t CoordinationSoftbusAdapter::NotifyUnchainedResult(const std::string &loc
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_LOCAL_DEVICE_ID, cJSON_CreateString(localNetworkId.c_str()));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_RESULT, cJSON_CreateBool(result));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_SESSION_ID, cJSON_CreateNumber(sessionId));
|
||||
char *smsg = cJSON_Print(jsonStr);
|
||||
char *sendmsg = cJSON_Print(jsonStr);
|
||||
cJSON_Delete(jsonStr);
|
||||
CHKPR(smsg, RET_ERR);
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
cJSON_free(smsg);
|
||||
CHKPR(sendmsg, RET_ERR);
|
||||
int32_t ret = SendMsg(sessionId, sendmsg);
|
||||
cJSON_free(sendmsg);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Unchained result send session msg failed");
|
||||
FI_HILOGE("Failed to send the sendMsg, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
@ -444,20 +444,20 @@ int32_t CoordinationSoftbusAdapter::NotifyFilterAdded(const std::string &remoteN
|
||||
CALL_DEBUG_ENTER;
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
if (sessionDevs_.find(remoteNetworkId) == sessionDevs_.end()) {
|
||||
FI_HILOGE("Stop remote coordination result error, not found this device");
|
||||
FI_HILOGE("Failed to discover the remote device");
|
||||
return RET_ERR;
|
||||
}
|
||||
int32_t sessionId = sessionDevs_[remoteNetworkId];
|
||||
cJSON *jsonStr = cJSON_CreateObject();
|
||||
CHKPR(jsonStr, RET_ERR);
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_CMD_TYPE, cJSON_CreateNumber(NOTIFY_FILTER_ADDED));
|
||||
char *smsg = cJSON_Print(jsonStr);
|
||||
char *sendmsg = cJSON_Print(jsonStr);
|
||||
cJSON_Delete(jsonStr);
|
||||
CHKPR(smsg, RET_ERR);
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
cJSON_free(smsg);
|
||||
CHKPR(sendmsg, RET_ERR);
|
||||
int32_t ret = SendMsg(sessionId, sendmsg);
|
||||
cJSON_free(sendmsg);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Send filter added msg failed");
|
||||
FI_HILOGE("Failed to send the sendMsg, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
@ -469,7 +469,7 @@ int32_t CoordinationSoftbusAdapter::StartCoordinationOtherResult(const std::stri
|
||||
CALL_DEBUG_ENTER;
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
if (sessionDevs_.find(originNetworkId) == sessionDevs_.end()) {
|
||||
FI_HILOGE("Start coordination other result error, not found this device");
|
||||
FI_HILOGE("Failed to discover the origin device");
|
||||
return RET_ERR;
|
||||
}
|
||||
int32_t sessionId = sessionDevs_[originNetworkId];
|
||||
@ -477,12 +477,12 @@ int32_t CoordinationSoftbusAdapter::StartCoordinationOtherResult(const std::stri
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_CMD_TYPE, cJSON_CreateNumber(REMOTE_COORDINATION_STOP_OTHER_RES));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_OTHER_DEVICE_ID, cJSON_CreateString(remoteNetworkId.c_str()));
|
||||
cJSON_AddItemToObject(jsonStr, FI_SOFTBUS_KEY_SESSION_ID, cJSON_CreateNumber(sessionId));
|
||||
char *smsg = cJSON_Print(jsonStr);
|
||||
char *sendMsg = cJSON_Print(jsonStr);
|
||||
cJSON_Delete(jsonStr);
|
||||
int32_t ret = SendMsg(sessionId, smsg);
|
||||
cJSON_free(smsg);
|
||||
int32_t ret = SendMsg(sessionId, sendMsg);
|
||||
cJSON_free(sendMsg);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Start coordination other result send session msg failed");
|
||||
FI_HILOGE("Failed to send the sendMsg, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
@ -491,27 +491,27 @@ int32_t CoordinationSoftbusAdapter::StartCoordinationOtherResult(const std::stri
|
||||
void CoordinationSoftbusAdapter::HandleSessionData(int32_t sessionId, const std::string &message)
|
||||
{
|
||||
if (message.empty()) {
|
||||
FI_HILOGE("Message is empty");
|
||||
FI_HILOGE("Handle session data, message is empty");
|
||||
return;
|
||||
}
|
||||
JsonParser parser;
|
||||
parser.json = cJSON_Parse(message.c_str());
|
||||
if (!cJSON_IsObject(parser.json)) {
|
||||
FI_HILOGI("Parser json is not object");
|
||||
FI_HILOGI("Handle session data, parser json is not object");
|
||||
if (message.size() < sizeof(DataPacket)) {
|
||||
FI_HILOGE("Data packet is incomplete");
|
||||
FI_HILOGE("Handle session data, data packet is incomplete");
|
||||
return;
|
||||
}
|
||||
DataPacket* dataPacket = reinterpret_cast<DataPacket *>(const_cast<char*>(message.c_str()));
|
||||
if ((message.size() - sizeof(DataPacket)) < dataPacket->dataLen) {
|
||||
FI_HILOGE("Data is corrupt");
|
||||
FI_HILOGE("Handle session data, data is corrupt");
|
||||
return;
|
||||
}
|
||||
if (registerRecvs_.find(dataPacket->messageId) == registerRecvs_.end()) {
|
||||
FI_HILOGW("Message:%{public}d does not register", dataPacket->messageId);
|
||||
FI_HILOGW("Handle session data, message:%{public}d does not register", dataPacket->messageId);
|
||||
return;
|
||||
}
|
||||
FI_HILOGI("Message:%{public}d", dataPacket->messageId);
|
||||
FI_HILOGI("Handle session data, message:%{public}d", dataPacket->messageId);
|
||||
if ((dataPacket->messageId == DRAGGING_DATA) ||
|
||||
(dataPacket->messageId == STOPDRAG_DATA) ||
|
||||
(dataPacket->messageId == IS_PULL_UP) ||
|
||||
@ -553,7 +553,7 @@ std::string CoordinationSoftbusAdapter::FindDevice(int32_t sessionId)
|
||||
return item.second == sessionId;
|
||||
});
|
||||
if (find_item == sessionDevs_.end()) {
|
||||
FI_HILOGE("FindDevice error");
|
||||
FI_HILOGE("Find device error");
|
||||
return {};
|
||||
}
|
||||
return find_item->first;
|
||||
@ -568,7 +568,7 @@ int32_t CoordinationSoftbusAdapter::OnSessionOpened(int32_t sessionId, int32_t r
|
||||
FI_HILOGD("Get peer device id ret:%{public}d", getPeerDeviceIdResult);
|
||||
if (result != RET_OK) {
|
||||
std::string networkId = FindDevice(sessionId);
|
||||
FI_HILOGE("Session open failed result:%{public}d", result);
|
||||
FI_HILOGE("Failed to open session, result:%{public}d", result);
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
if (sessionDevs_.find(networkId) != sessionDevs_.end()) {
|
||||
sessionDevs_.erase(networkId);
|
||||
@ -580,11 +580,11 @@ int32_t CoordinationSoftbusAdapter::OnSessionOpened(int32_t sessionId, int32_t r
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t sessionSide = GetSessionSide(sessionId);
|
||||
FI_HILOGI("Session open succeed, sessionId:%{public}d, sessionSide:%{public}d(1 is client side)",
|
||||
sessionId, sessionSide);
|
||||
int32_t sessSide = GetSessionSide(sessionId);
|
||||
FI_HILOGI("SoftbusSession open succeed, sessionId:%{public}d, sessionSide:%{public}d(1 is client side)",
|
||||
sessionId, sessSide);
|
||||
std::lock_guard<std::mutex> notifyLock(operationMutex_);
|
||||
if (sessionSide == SESSION_SIDE_SERVER) {
|
||||
if (sessSide == SESSION_SIDE_SERVER) {
|
||||
if (getPeerDeviceIdResult == RET_OK) {
|
||||
sessionDevs_[peerDevId] = sessionId;
|
||||
}
|
||||
@ -629,11 +629,11 @@ int32_t CoordinationSoftbusAdapter::SendData(const std::string &networkId, Messa
|
||||
CALL_DEBUG_ENTER;
|
||||
DataPacket* dataPacket = (DataPacket*)malloc(sizeof(DataPacket) + dataLen);
|
||||
CHKPR(dataPacket, RET_ERR);
|
||||
dataPacket->messageId = messageId;
|
||||
dataPacket->dataLen = dataLen;
|
||||
dataPacket->messageId = messageId;
|
||||
errno_t ret = memcpy_s(dataPacket->data, dataPacket->dataLen, data, dataPacket->dataLen);
|
||||
if (ret != EOK) {
|
||||
FI_HILOGE("Memcpy data packet failed");
|
||||
FI_HILOGE("Memory copy data packet failed");
|
||||
free(dataPacket);
|
||||
return RET_ERR;
|
||||
}
|
||||
@ -657,7 +657,7 @@ void CoordinationSoftbusAdapter::HandleCoordinationSessionData(int32_t sessionId
|
||||
{
|
||||
cJSON* comType = cJSON_GetObjectItemCaseSensitive(parser.json, FI_SOFTBUS_KEY_CMD_TYPE);
|
||||
if (!cJSON_IsNumber(comType)) {
|
||||
FI_HILOGE("OnBytesReceived cmdType is not number type");
|
||||
FI_HILOGE("The data type of CJSON is incorrect");
|
||||
return;
|
||||
}
|
||||
FI_HILOGD("valueint:%{public}d", comType->valueint);
|
||||
@ -691,7 +691,7 @@ void CoordinationSoftbusAdapter::HandleCoordinationSessionData(int32_t sessionId
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
FI_HILOGE("OnBytesReceived cmdType is undefined");
|
||||
FI_HILOGE("The cmdType is undefined");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -701,37 +701,37 @@ void CoordinationSoftbusAdapter::ConfigTcpAlive()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (sessionId_ < 0) {
|
||||
FI_HILOGW("Invalid sessionId");
|
||||
FI_HILOGW("Config tcp alive, invalid sessionId");
|
||||
return;
|
||||
}
|
||||
int32_t handle { -1 };
|
||||
int32_t ret = GetSessionHandle(sessionId_, &handle);
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("GetSessionHandle falied sessionId:%{public}d, handle:%{public}d", sessionId_, handle);
|
||||
int32_t result = GetSessionHandle(sessionId_, &handle);
|
||||
if (result != RET_OK) {
|
||||
FI_HILOGE("Failed to get the session handle, sessionId:%{public}d, handle:%{public}d", sessionId_, handle);
|
||||
return;
|
||||
}
|
||||
int32_t keepAliveTimeout { 10 };
|
||||
ret = setsockopt(handle, IPPROTO_TCP, TCP_KEEPIDLE, &keepAliveTimeout, sizeof(keepAliveTimeout));
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Setsockopt set idle falied");
|
||||
result = setsockopt(handle, IPPROTO_TCP, TCP_KEEPIDLE, &keepAliveTimeout, sizeof(keepAliveTimeout));
|
||||
if (result != RET_OK) {
|
||||
FI_HILOGE("Config tcp alive, setsockopt set idle falied");
|
||||
return;
|
||||
}
|
||||
int32_t keepAliveCount { 5 };
|
||||
ret = setsockopt(handle, IPPROTO_TCP, TCP_KEEPCNT, &keepAliveCount, sizeof(keepAliveCount));
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Setsockopt set cnt falied");
|
||||
result = setsockopt(handle, IPPROTO_TCP, TCP_KEEPCNT, &keepAliveCount, sizeof(keepAliveCount));
|
||||
if (result != RET_OK) {
|
||||
FI_HILOGE("Config tcp alive, setsockopt set cnt falied");
|
||||
return;
|
||||
}
|
||||
int32_t interval { 1 };
|
||||
ret = setsockopt(handle, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval));
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Setsockopt set intvl falied");
|
||||
result = setsockopt(handle, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval));
|
||||
if (result != RET_OK) {
|
||||
FI_HILOGE("Config tcp alive, setsockopt set intvl falied");
|
||||
return;
|
||||
}
|
||||
int32_t enable { 1 };
|
||||
ret = setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE, &enable, sizeof(enable));
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Setsockopt enable alive falied");
|
||||
result = setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE, &enable, sizeof(enable));
|
||||
if (result != RET_OK) {
|
||||
FI_HILOGE("Config tcp alive, setsockopt enable alive falied");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ std::string GetLocalNetworkId()
|
||||
auto localNode = std::make_unique<NodeBasicInfo>();
|
||||
int32_t ret = GetLocalNodeDeviceInfo(FI_PKG_NAME, localNode.get());
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("GetLocalNodeDeviceInfo ret:%{public}d", ret);
|
||||
FI_HILOGE("Get local node device info, ret:%{public}d", ret);
|
||||
return {};
|
||||
}
|
||||
std::string networkId(localNode->networkId, sizeof(localNode->networkId));
|
||||
FI_HILOGD("GetLocalNodeDeviceInfo networkId:%{public}s", networkId.substr(0, SUBSTR_NETWORKID_LEN).c_str());
|
||||
FI_HILOGD("Get local node device info, networkId:%{public}s", networkId.substr(0, SUBSTR_NETWORKID_LEN).c_str());
|
||||
return localNode->networkId;
|
||||
}
|
||||
} // namespace COORDINATION
|
||||
|
@ -43,6 +43,21 @@ DeviceProfileAdapter::~DeviceProfileAdapter()
|
||||
callbacks_.clear();
|
||||
}
|
||||
|
||||
void DeviceProfileAdapter::ProfileEventCallbackImpl::OnSyncCompleted(const DeviceProfile::SyncResult &syncResults)
|
||||
{
|
||||
std::for_each(syncResults.begin(), syncResults.end(), [](const auto &syncResult) {
|
||||
FI_HILOGD("Synchronized result:%{public}d", syncResult.second);
|
||||
});
|
||||
}
|
||||
|
||||
void DeviceProfileAdapter::ProfileEventCallbackImpl::OnProfileChanged(
|
||||
const ProfileChangeNotification &changeNotification)
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
std::string networkId = changeNotification.GetDeviceId();
|
||||
DP_ADAPTER->OnProfileChanged(networkId);
|
||||
}
|
||||
|
||||
int32_t DeviceProfileAdapter::UpdateCrossingSwitchState(bool state, const std::vector<std::string> &deviceIds)
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
@ -59,7 +74,7 @@ int32_t DeviceProfileAdapter::UpdateCrossingSwitchState(bool state, const std::v
|
||||
|
||||
int32_t ret = DistributedDeviceProfileClient::GetInstance().PutDeviceProfile(profile);
|
||||
if (ret != 0) {
|
||||
FI_HILOGE("Put device profile failed, ret:%{public}d", ret);
|
||||
FI_HILOGE("Failed to put the device profile, ret:%{public}d", ret);
|
||||
return ret;
|
||||
}
|
||||
SyncOptions syncOptions;
|
||||
@ -72,7 +87,7 @@ int32_t DeviceProfileAdapter::UpdateCrossingSwitchState(bool state, const std::v
|
||||
ret =
|
||||
DistributedDeviceProfileClient::GetInstance().SyncDeviceProfile(syncOptions, syncCallback);
|
||||
if (ret != 0) {
|
||||
FI_HILOGE("Sync device profile failed");
|
||||
FI_HILOGE("Failed to synchronize the device profile");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -203,21 +218,6 @@ void DeviceProfileAdapter::OnProfileChanged(const std::string &networkId)
|
||||
callbacks_.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceProfileAdapter::ProfileEventCallbackImpl::OnProfileChanged(
|
||||
const ProfileChangeNotification &changeNotification)
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
std::string networkId = changeNotification.GetDeviceId();
|
||||
DP_ADAPTER->OnProfileChanged(networkId);
|
||||
}
|
||||
|
||||
void DeviceProfileAdapter::ProfileEventCallbackImpl::OnSyncCompleted(const DeviceProfile::SyncResult &syncResults)
|
||||
{
|
||||
std::for_each(syncResults.begin(), syncResults.end(), [](const auto &syncResult) {
|
||||
FI_HILOGD("Sync result:%{public}d", syncResult.second);
|
||||
});
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
|
@ -28,8 +28,8 @@ namespace DeviceStatus {
|
||||
using namespace DistributedHardware::DistributedInput;
|
||||
namespace {
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DistributedInputAdapter" };
|
||||
constexpr int32_t DEFAULT_DELAY_TIME { 4000 };
|
||||
constexpr int32_t RETRY_TIME { 2 };
|
||||
constexpr int32_t DEFAULT_DELAY_TIME { 4000 };
|
||||
} // namespace
|
||||
DistributedInputAdapter::DistributedInputAdapter() = default;
|
||||
|
||||
|
@ -34,28 +34,28 @@ public:
|
||||
DISALLOW_MOVE(DragDataManager);
|
||||
|
||||
void Init(const DragData &dragData);
|
||||
DragData GetDragData() const;
|
||||
void SetDragStyle(DragCursorStyle style);
|
||||
void SetShadowInfo(const ShadowInfo &shadowInfo);
|
||||
DragCursorStyle GetDragStyle() const;
|
||||
void SetDragWindowVisible(bool visible);
|
||||
bool GetDragWindowVisible() const;
|
||||
int32_t GetShadowOffset(int32_t& offsetX, int32_t& offsetY, int32_t& width, int32_t& height) const;
|
||||
void ResetDragData();
|
||||
void SetTargetTid(int32_t tokenId);
|
||||
int32_t GetTargetTid() const;
|
||||
void SetTargetPid(int32_t pid);
|
||||
int32_t GetTargetPid() const;
|
||||
void SetMotionDrag(bool isMotionDrag);
|
||||
bool IsMotionDrag() const;
|
||||
void ResetDragData();
|
||||
DragData GetDragData() const;
|
||||
void SetMotionDrag(bool isMotionDrag);
|
||||
private:
|
||||
DragData dragData_;
|
||||
DragCursorStyle dragStyle_ { DragCursorStyle::DEFAULT };
|
||||
std::u16string dragMessage_;
|
||||
bool visible_ { false };
|
||||
int32_t targetTid_ { -1 };
|
||||
int32_t targetPid_ { -1 };
|
||||
bool isMotionDrag_ { false };
|
||||
bool visible_ { false };
|
||||
int32_t targetPid_ { -1 };
|
||||
int32_t targetTid_ { -1 };
|
||||
std::u16string dragMessage_;
|
||||
DragCursorStyle dragStyle_ { DragCursorStyle::DEFAULT };
|
||||
DragData dragData_;
|
||||
};
|
||||
|
||||
#define DRAG_DATA_MGR OHOS::Singleton<DragDataManager>::GetInstance()
|
||||
|
@ -32,20 +32,20 @@ constexpr int32_t DEFAULT_DISPLAY_ID { 0 };
|
||||
DragDataManager::DragDataManager() = default;
|
||||
DragDataManager::~DragDataManager() = default;
|
||||
|
||||
void DragDataManager::SetDragStyle(DragCursorStyle style)
|
||||
{
|
||||
dragStyle_ = style;
|
||||
}
|
||||
|
||||
void DragDataManager::Init(const DragData &dragData)
|
||||
{
|
||||
dragData_ = dragData;
|
||||
if (dragData.displayId < DEFAULT_DISPLAY_ID) {
|
||||
dragData_.displayId = DEFAULT_DISPLAY_ID;
|
||||
FI_HILOGW("The value of displayId(%{public}d) is correcting to 0", dragData.displayId);
|
||||
FI_HILOGW("Correct the value of displayId(%{public}d) to 0", dragData.displayId);
|
||||
}
|
||||
targetTid_ = -1;
|
||||
targetPid_ = -1;
|
||||
}
|
||||
|
||||
void DragDataManager::SetDragStyle(DragCursorStyle style)
|
||||
{
|
||||
dragStyle_ = style;
|
||||
targetTid_ = -1;
|
||||
}
|
||||
|
||||
void DragDataManager::SetShadowInfo(const ShadowInfo &shadowInfo)
|
||||
|
@ -111,9 +111,9 @@ const std::string DRAG_ANIMATION_EXTENSION_SO_PATH { "/system/lib/drag_drop_ext/
|
||||
const std::string BIG_FOLDER_LABEL { "scb_folder" };
|
||||
struct DrawingInfo g_drawingInfo;
|
||||
|
||||
struct JsonParser {
|
||||
JsonParser() = default;
|
||||
~JsonParser()
|
||||
struct JsonDataParser {
|
||||
JsonDataParser() = default;
|
||||
~JsonDataParser()
|
||||
{
|
||||
if (json != nullptr) {
|
||||
cJSON_Delete(json);
|
||||
@ -1133,7 +1133,7 @@ bool DragDrawing::ParserFilterInfo(FilterInfo& filterInfo)
|
||||
FI_HILOGD("FilterInfo is empty");
|
||||
return false;
|
||||
}
|
||||
JsonParser filterParser;
|
||||
JsonDataParser filterParser;
|
||||
filterParser.json = cJSON_Parse(g_drawingInfo.filterInfo.c_str());
|
||||
FI_HILOGD("FilterInfo size:%{public}zu, filterInfo:%{public}s",
|
||||
g_drawingInfo.filterInfo.size(), g_drawingInfo.filterInfo.c_str());
|
||||
@ -1160,7 +1160,7 @@ bool DragDrawing::ParserFilterInfo(FilterInfo& filterInfo)
|
||||
FI_HILOGD("ExtraInfo is empty");
|
||||
return false;
|
||||
}
|
||||
JsonParser extraInfoParser;
|
||||
JsonDataParser extraInfoParser;
|
||||
extraInfoParser.json = cJSON_Parse(g_drawingInfo.extraInfo.c_str());
|
||||
FI_HILOGD("ExtraInfo size:%{public}zu, extraInfo:%{public}s",
|
||||
g_drawingInfo.extraInfo.size(), g_drawingInfo.extraInfo.c_str());
|
||||
|
@ -66,7 +66,7 @@ int32_t StateChangeNotify::StyleChangedNotify(DragCursorStyle style)
|
||||
it != msgInfos_[MessageType::NOTIFY_STYLE].end(); ++it) {
|
||||
auto info = *it;
|
||||
CHKPC(info);
|
||||
OnDragInfoNotify(info->session, info->msgId, info->style);
|
||||
OnDragInfoNotify(info->session, info->msgId, style);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
@ -82,7 +82,7 @@ int32_t StateChangeNotify::StateChangedNotify(DragState state)
|
||||
it != msgInfos_[MessageType::NOTIFY_STATE].end(); ++it) {
|
||||
auto info = *it;
|
||||
CHKPC(info);
|
||||
OnDragInfoNotify(info->session, info->msgId, info->state);
|
||||
OnDragInfoNotify(info->session, info->msgId, state);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
void SetUp();
|
||||
void TearDown() {}
|
||||
void AddPermission();
|
||||
void SetAceessTokenPermission(const std::string &processName, const char** perms, size_t permCount);
|
||||
void SetAceessTokenPermission(const char** perms, size_t permAmount);
|
||||
};
|
||||
|
||||
void CoordinationSMTest::SetUp()
|
||||
@ -105,23 +105,23 @@ void CoordinationSMTest::SetUp()
|
||||
void CoordinationSMTest::AddPermission()
|
||||
{
|
||||
const char *perms[] = { "ohos.permission.DISTRIBUTED_DATASYNC" };
|
||||
SetAceessTokenPermission("CoordinationSMTest", perms, sizeof(perms) / sizeof(perms[0]));
|
||||
SetAceessTokenPermission(perms, sizeof(perms) / sizeof(perms[0]));
|
||||
}
|
||||
|
||||
void CoordinationSMTest::SetAceessTokenPermission(const std::string &processName, const char** perms, size_t permCount)
|
||||
void CoordinationSMTest::SetAceessTokenPermission(const char** perms, size_t permAmount)
|
||||
{
|
||||
if (perms == nullptr || permCount == 0) {
|
||||
FI_HILOGE("perms is nullptr or permCount is 0");
|
||||
if (perms == nullptr || permAmount == 0) {
|
||||
FI_HILOGE("The perms is empty");
|
||||
return;
|
||||
}
|
||||
NativeTokenInfoParams infoInstance = {
|
||||
.dcapsNum = 0,
|
||||
.permsNum = permCount,
|
||||
.permsNum = permAmount,
|
||||
.aclsNum = 0,
|
||||
.dcaps = nullptr,
|
||||
.perms = perms,
|
||||
.acls = nullptr,
|
||||
.processName = processName.c_str(),
|
||||
.processName = "CoordinationSMTest",
|
||||
.aplStr = "system_basic",
|
||||
};
|
||||
uint64_t tokenId = GetAccessTokenId(&infoInstance);
|
||||
|
@ -36,8 +36,8 @@ public:
|
||||
|
||||
int32_t Init(IContext *context);
|
||||
int32_t AddTimer(int32_t intervalMs, int32_t repeatCount, std::function<void()> callback) override;
|
||||
int32_t RemoveTimer(int32_t timerId) override;
|
||||
int32_t ResetTimer(int32_t timerId);
|
||||
int32_t RemoveTimer(int32_t timerId) override;
|
||||
bool IsExist(int32_t timerId) const;
|
||||
void ProcessTimers();
|
||||
int32_t GetTimerFd() const;
|
||||
@ -46,17 +46,17 @@ private:
|
||||
struct TimerItem {
|
||||
int32_t id { 0 };
|
||||
int32_t intervalMs { 0 };
|
||||
int32_t repeatCount { 0 };
|
||||
int32_t callbackCount { 0 };
|
||||
int32_t repeatCount { 0 };
|
||||
int64_t nextCallTime { 0 };
|
||||
std::function<void()> callback { nullptr };
|
||||
};
|
||||
|
||||
int32_t OnInit(IContext *context);
|
||||
int32_t OnAddTimer(int32_t intervalMs, int32_t repeatCount, std::function<void()> callback);
|
||||
int32_t OnProcessTimers();
|
||||
int32_t OnResetTimer(int32_t timerId);
|
||||
int32_t OnRemoveTimer(int32_t timerId);
|
||||
int32_t OnProcessTimers();
|
||||
bool OnIsExist(int32_t timerId) const;
|
||||
int32_t RunIsExist(std::packaged_task<bool(int32_t)> &task, int32_t timerId) const;
|
||||
int32_t TakeNextTimerId();
|
||||
@ -64,8 +64,8 @@ private:
|
||||
int32_t ResetTimerInternal(int32_t timerId);
|
||||
int32_t RemoveTimerInternal(int32_t timerId);
|
||||
void InsertTimerInternal(std::unique_ptr<TimerItem>& timer);
|
||||
int64_t CalcNextDelayInternal();
|
||||
void ProcessTimersInternal();
|
||||
int64_t CalcNextDelayInternal();
|
||||
int32_t ArmTimer();
|
||||
|
||||
int32_t timerFd_ { -1 };
|
||||
|
@ -102,8 +102,8 @@ int32_t TimerManager::ResetTimer(int32_t timerId)
|
||||
|
||||
bool TimerManager::OnIsExist(int32_t timerId) const
|
||||
{
|
||||
for (auto tIter = timers_.begin(); tIter != timers_.end(); ++tIter) {
|
||||
if ((*tIter)->id == timerId) {
|
||||
for (auto iter = timers_.begin(); iter != timers_.end(); ++iter) {
|
||||
if ((*iter)->id == timerId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -151,9 +151,9 @@ int32_t TimerManager::TakeNextTimerId()
|
||||
[] (uint64_t s, const auto &timer) {
|
||||
return (s |= (uint64_t(1U) << timer->id));
|
||||
});
|
||||
for (size_t count = 0; count < MAX_TIMER_COUNT; ++count) {
|
||||
if ((timerSlot & (uint64_t(1U) << count)) == 0) {
|
||||
return count;
|
||||
for (size_t tmpCount = 0; tmpCount < MAX_TIMER_COUNT; ++tmpCount) {
|
||||
if ((timerSlot & (uint64_t(1U) << tmpCount)) == 0) {
|
||||
return tmpCount;
|
||||
}
|
||||
}
|
||||
return NONEXISTENT_ID;
|
||||
|
@ -61,13 +61,13 @@ private:
|
||||
using InterfaceParameterLess = void(*)();
|
||||
using InterfaceParameterOne = void(*)(const char*);
|
||||
using InterfaceParameterTwo = void(*)(int32_t, char**);
|
||||
inline static std::map<const char, InterfaceParameterLess> regularActions_ {
|
||||
inline static std::map<const char, InterfaceParameterLess> ruleMouseActions_ {
|
||||
{ 'd', &ReadDownAction }, { 'u', &ReadUpAction }, { 's', &ReadScrollAction }
|
||||
};
|
||||
inline static std::map<const char, InterfaceParameterOne> readActions_ {
|
||||
inline static std::map<const char, InterfaceParameterOne> readMouseActions_ {
|
||||
{ 'f', &ReadActions }, { 'r', &ReadRawInput}
|
||||
};
|
||||
inline static std::map<const char, InterfaceParameterTwo> moveActions_{
|
||||
inline static std::map<const char, InterfaceParameterTwo> moveMouseActions_{
|
||||
{ 'm', &ReadMoveAction }, { 'M', &ReadMoveToAction }, { 'D', &ReadDragToAction }
|
||||
};
|
||||
};
|
||||
|
@ -60,13 +60,13 @@ private:
|
||||
using InterfaceParameterLess = void(*)();
|
||||
using InterfaceParameterOne = void(*)(const char*);
|
||||
using InterfaceParameterTwo = void(*)(int32_t, char**);
|
||||
inline static std::map<const char, InterfaceParameterLess> regularActions_ {
|
||||
inline static std::map<const char, InterfaceParameterLess> ruleTscrnActions_ {
|
||||
{ 'u', &ReadUpAction }
|
||||
};
|
||||
inline static std::map<const char, InterfaceParameterOne> readActions_ {
|
||||
inline static std::map<const char, InterfaceParameterOne> readTscrnActions_ {
|
||||
{ 'f', &ReadActions }, { 'r', &ReadRawInput}
|
||||
};
|
||||
inline static std::map<const char, InterfaceParameterTwo> moveActions_ {
|
||||
inline static std::map<const char, InterfaceParameterTwo> moveTscrnActions_ {
|
||||
{ 'd', &ReadDownAction }, { 'm', &ReadMoveAction },
|
||||
{ 'D', &ReadDragToAction }, { 'M', &ReadMoveToAction }
|
||||
};
|
||||
|
@ -212,22 +212,22 @@ void VirtualMouseBuilder::Act(int32_t argc, char *argv[])
|
||||
}
|
||||
do {
|
||||
{
|
||||
auto action = regularActions_.find(opt);
|
||||
if (action != regularActions_.end()) {
|
||||
auto action = ruleMouseActions_.find(opt);
|
||||
if (action != ruleMouseActions_.end()) {
|
||||
action->second();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
{
|
||||
auto action = readActions_.find(opt);
|
||||
if (action != readActions_.end()) {
|
||||
auto action = readMouseActions_.find(opt);
|
||||
if (action != readMouseActions_.end()) {
|
||||
action->second(optarg);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
{
|
||||
auto action = moveActions_.find(opt);
|
||||
if (action != moveActions_.end()) {
|
||||
auto action = moveMouseActions_.find(opt);
|
||||
if (action != moveMouseActions_.end()) {
|
||||
action->second(argc, argv);
|
||||
continue;
|
||||
}
|
||||
@ -358,9 +358,9 @@ void VirtualMouseBuilder::ReadActions(const char *path)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
json model;
|
||||
int32_t ret = VirtualDeviceBuilder::ReadFile(path, model);
|
||||
if (ret == RET_ERR) {
|
||||
FI_HILOGE("Failed to read the file");
|
||||
int32_t result = VirtualDeviceBuilder::ReadFile(path, model);
|
||||
if (result == RET_ERR) {
|
||||
FI_HILOGE("Failed to read mouse data from the files");
|
||||
return;
|
||||
}
|
||||
ReadModel(model, MAXIMUM_LEVEL_ALLOWED);
|
||||
@ -474,9 +474,9 @@ void VirtualMouseBuilder::ReadRawInput(const char *path)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
json model;
|
||||
int32_t ret = VirtualDeviceBuilder::ReadFile(path, model);
|
||||
if (ret == RET_ERR) {
|
||||
FI_HILOGE("Failed to read raw input data");
|
||||
int32_t result = VirtualDeviceBuilder::ReadFile(path, model);
|
||||
if (result == RET_ERR) {
|
||||
FI_HILOGE("Failed to read the raw mouse data");
|
||||
return;
|
||||
}
|
||||
ReadRawModel(model, MAXIMUM_LEVEL_ALLOWED);
|
||||
|
@ -243,22 +243,22 @@ void VirtualTouchScreenBuilder::Act(int32_t argc, char *argv[])
|
||||
}
|
||||
do {
|
||||
{
|
||||
auto action = regularActions_.find(opt);
|
||||
if (action != regularActions_.end()) {
|
||||
auto action = ruleTscrnActions_.find(opt);
|
||||
if (action != ruleTscrnActions_.end()) {
|
||||
action->second();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
{
|
||||
auto action = readActions_.find(opt);
|
||||
if (action != readActions_.end()) {
|
||||
auto action = readTscrnActions_.find(opt);
|
||||
if (action != readTscrnActions_.end()) {
|
||||
action->second(optarg);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
{
|
||||
auto action = moveActions_.find(opt);
|
||||
if (action != moveActions_.end()) {
|
||||
auto action = moveTscrnActions_.find(opt);
|
||||
if (action != moveTscrnActions_.end()) {
|
||||
action->second(argc, argv);
|
||||
continue;
|
||||
}
|
||||
@ -385,7 +385,7 @@ void VirtualTouchScreenBuilder::ReadActions(const char *path)
|
||||
json model;
|
||||
int32_t ret = VirtualDeviceBuilder::ReadFile(path, model);
|
||||
if (ret == RET_ERR) {
|
||||
FI_HILOGE("Failed to read the file");
|
||||
FI_HILOGE("Failed to read touchscreen data from the files");
|
||||
return;
|
||||
}
|
||||
ReadModel(model, MAXIMUM_LEVEL_ALLOWED);
|
||||
@ -499,7 +499,7 @@ void VirtualTouchScreenBuilder::ReadRawInput(const char *path)
|
||||
json model;
|
||||
int32_t ret = VirtualDeviceBuilder::ReadFile(path, model);
|
||||
if (ret == RET_ERR) {
|
||||
FI_HILOGE("Failed to read raw input data");
|
||||
FI_HILOGE("Failed to read the raw touchscreen data");
|
||||
return;
|
||||
}
|
||||
ReadRawModel(model, MAXIMUM_LEVEL_ALLOWED);
|
||||
|
@ -98,31 +98,31 @@ void SetThreadName(const std::string &name)
|
||||
prctl(PR_SET_NAME, name.c_str());
|
||||
}
|
||||
|
||||
static size_t StringToken(std::string &str, const std::string &sep, std::string &token)
|
||||
static size_t StringToken(std::string &strs, const std::string &sep, std::string &token)
|
||||
{
|
||||
token = "";
|
||||
if (str.empty()) {
|
||||
return str.npos;
|
||||
if (strs.empty()) {
|
||||
return strs.npos;
|
||||
}
|
||||
size_t seat = str.npos;
|
||||
size_t seat = strs.npos;
|
||||
size_t temp = 0;
|
||||
for (auto &item : sep) {
|
||||
temp = str.find(item);
|
||||
if (str.npos != temp) {
|
||||
temp = strs.find(item);
|
||||
if (strs.npos != temp) {
|
||||
seat = (std::min)(seat, temp);
|
||||
}
|
||||
}
|
||||
if (str.npos != seat) {
|
||||
token = str.substr(0, seat);
|
||||
if (str.npos != seat + 1) {
|
||||
str = str.substr(seat + 1, str.npos);
|
||||
if (strs.npos != seat) {
|
||||
token = strs.substr(0, seat);
|
||||
if (strs.npos != seat + 1) {
|
||||
strs = strs.substr(seat + 1, strs.npos);
|
||||
}
|
||||
if (seat == 0) {
|
||||
return StringToken(str, sep, token);
|
||||
return StringToken(strs, sep, token);
|
||||
}
|
||||
} else {
|
||||
token = str;
|
||||
str = "";
|
||||
token = strs;
|
||||
strs = "";
|
||||
}
|
||||
return token.size();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user