From 9121a97d5fe916dcf0e267508b7de5ff9cde3004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cry521=E2=80=9D?= Date: Tue, 26 Sep 2023 11:59:37 +0800 Subject: [PATCH 01/27] =?UTF-8?q?=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: “ry521” --- bundle.json | 2 + interfaces/inner_kits/BUILD.gn | 2 + .../ipc/src/distributed_input_sink_stub.cpp | 40 +- .../ipc/src/distributed_input_source_stub.cpp | 666 +++++++++++------- services/sink/sinkmanager/BUILD.gn | 2 + services/source/sourcemanager/BUILD.gn | 2 + 6 files changed, 443 insertions(+), 271 deletions(-) diff --git a/bundle.json b/bundle.json index 049b1f8..e3174fa 100755 --- a/bundle.json +++ b/bundle.json @@ -28,6 +28,8 @@ ], "deps": { "components": [ + "access_token", + "accessibility", "eventhandler", "hilog", "ipc", diff --git a/interfaces/inner_kits/BUILD.gn b/interfaces/inner_kits/BUILD.gn index 9ee637c..4900ec4 100644 --- a/interfaces/inner_kits/BUILD.gn +++ b/interfaces/inner_kits/BUILD.gn @@ -88,6 +88,8 @@ ohos_shared_library("libdinput_sdk") { ] external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", "c_utils:utils", "config_policy:configpolicy_util", "dsoftbus:softbus_client", diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index 767b7d2..fb3bca1 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -21,6 +21,8 @@ #include "dinput_log.h" #include "dinput_utils_tool.h" #include "i_sharing_dhid_listener.h" +#include "ipc_skeleton.h" +#include "accesstoken_kit.h" namespace OHOS { namespace DistributedHardware { @@ -66,23 +68,39 @@ int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel & int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { - DHLOGI("DistributedInputSinkStub InitInner start"); - int32_t ret = Init(); - if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + DHLOGI("DistributedInputSinkStub InitInner start"); + int32_t ret = Init(); + if (!reply.WriteInt32(ret)) { + DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + DHLOGE("Enable Permission vailable"); + return ret; } - return ret; + DHLOGE("Enable Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSinkStub::ReleaseInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { - int32_t ret = Release(); - if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + int32_t ret = Release(); + if (!reply.WriteInt32(ret)) { + DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + DHLOGE("Enable Permission vailable"); + return ret; } - return ret; + DHLOGE("Enable Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSinkStub::NotifyStartDScreenInner(MessageParcel &data, MessageParcel &reply, diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 6ead0d0..cf44543 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -19,6 +19,8 @@ #include "dinput_errcode.h" #include "dinput_ipc_interface_code.h" #include "dinput_log.h" +#include "ipc_skeleton.h" +#include "accesstoken_kit.h" namespace OHOS { namespace DistributedHardware { @@ -84,339 +86,467 @@ void DistributedInputSourceStub::RegRespFunMap() } int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel &reply) { - std::unique_lock lock(operatorMutex_); - if (sourceManagerInitFlag_.load()) { - DHLOGE("DistributedInputSourceStub already init."); + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::unique_lock lock(operatorMutex_); + if (sourceManagerInitFlag_.load()) { + DHLOGE("DistributedInputSourceStub already init."); + return DH_SUCCESS; + } + int32_t ret = Init(); + if (!reply.WriteInt32(ret)) { + DHLOGE("DistributedInputSourceStub Init write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + sourceManagerInitFlag_.store(true); + DHLOGE("Enable Permission vailable"); return DH_SUCCESS; } - int32_t ret = Init(); - if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSourceStub Init write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - sourceManagerInitFlag_.store(true); - return DH_SUCCESS; + DHLOGE("Enable Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParcel &reply) { - std::unique_lock lock(operatorMutex_); - if (!sourceManagerInitFlag_.load()) { - DHLOGE("DistributedInputSourceStub already Release."); + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::unique_lock lock(operatorMutex_); + if (!sourceManagerInitFlag_.load()) { + DHLOGE("DistributedInputSourceStub already Release."); + return DH_SUCCESS; + } + int32_t ret = Release(); + if (!reply.WriteInt32(ret)) { + DHLOGE("DistributedInputSourceStub release write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + sourceManagerInitFlag_.store(false); + DHLOGE("Enable Permission vailable"); return DH_SUCCESS; } - int32_t ret = Release(); - if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSourceStub release write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - sourceManagerInitFlag_.store(false); - return DH_SUCCESS; + DHLOGE("Enable Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { - std::string devId = data.ReadString(); - std::string dhId = data.ReadString(); - std::string params = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleRegisterDistributedHardware failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = RegisterDistributedHardware(devId, dhId, params, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleRegisterDistributedHardware write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string devId = data.ReadString(); + std::string dhId = data.ReadString(); + std::string params = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleRegisterDistributedHardware failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = RegisterDistributedHardware(devId, dhId, params, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleRegisterDistributedHardware write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + DHLOGE("Enable Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Enable Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { - std::string devId = data.ReadString(); - std::string dhId = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleUnregisterDistributedHardware failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = UnregisterDistributedHardware(devId, dhId, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleUnregisterDistributedHardware write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string devId = data.ReadString(); + std::string dhId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnregisterDistributedHardware failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = UnregisterDistributedHardware(devId, dhId, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleUnregisterDistributedHardware write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + DHLOGE("Enable Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Enable Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string deviceId = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandlePrepareRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = PrepareRemoteInput(deviceId, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandlePrepareRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string deviceId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandlePrepareRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = PrepareRemoteInput(deviceId, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandlePrepareRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string deviceId = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleUnprepareRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = UnprepareRemoteInput(deviceId, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleUnprepareRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string deviceId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnprepareRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = UnprepareRemoteInput(deviceId, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleUnprepareRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string deviceId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStartRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StartRemoteInput(deviceId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStartRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string deviceId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StartRemoteInput(deviceId, inputTypes, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStartRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string deviceId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStopRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StopRemoteInput(deviceId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStopRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string deviceId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StopRemoteInput(deviceId, inputTypes, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStopRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStartRelayTypeRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StartRemoteInput(srcId, sinkId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStartRelayTypeRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartRelayTypeRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StartRemoteInput(srcId, sinkId, inputTypes, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStartRelayTypeRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStopRelayTypeRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StopRemoteInput(srcId, sinkId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStopRelayTypeRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopRelayTypeRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StopRemoteInput(srcId, sinkId, inputTypes, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStopRelayTypeRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandlePrepareRelayRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = PrepareRemoteInput(srcId, sinkId, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandlePrepareRelayRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandlePrepareRelayRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = PrepareRemoteInput(srcId, sinkId, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandlePrepareRelayRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleUnprepareRelayRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = UnprepareRemoteInput(srcId, sinkId, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleUnprepareRelayRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnprepareRelayRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = UnprepareRemoteInput(srcId, sinkId, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleUnprepareRelayRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string sinkId = data.ReadString(); - - std::vector tempVector; - uint32_t vecSize = data.ReadUint32(); - if (vecSize > IPC_VECTOR_MAX_SIZE) { - DHLOGE("HandleStartDhidRemoteInput vecSize too large"); - return ERR_DH_INPUT_IPC_READ_VALID_FAIL; - } + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string sinkId = data.ReadString(); + + std::vector tempVector; + uint32_t vecSize = data.ReadUint32(); + if (vecSize > IPC_VECTOR_MAX_SIZE) { + DHLOGE("HandleStartDhidRemoteInput vecSize too large"); + return ERR_DH_INPUT_IPC_READ_VALID_FAIL; + } - for (uint32_t i = 0; i < vecSize; i++) { - std::string dhid = data.ReadString(); - if (dhid.empty()) { - DHLOGE("HandleStartDhidRemoteInput dhid is empty"); - continue; + for (uint32_t i = 0; i < vecSize; i++) { + std::string dhid = data.ReadString(); + if (dhid.empty()) { + DHLOGE("HandleStartDhidRemoteInput dhid is empty"); + continue; + } + tempVector.push_back(dhid); } - tempVector.push_back(dhid); - } - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStartDhidRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StartRemoteInput(sinkId, tempVector, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStartDhidRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StartRemoteInput(sinkId, tempVector, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStartDhidRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string sinkId = data.ReadString(); - - std::vector tempVector; - uint32_t vecSize = data.ReadUint32(); - if (vecSize > IPC_VECTOR_MAX_SIZE) { - DHLOGE("HandleStopDhidRemoteInput vecSize too large"); - return ERR_DH_INPUT_IPC_READ_VALID_FAIL; - } + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string sinkId = data.ReadString(); + + std::vector tempVector; + uint32_t vecSize = data.ReadUint32(); + if (vecSize > IPC_VECTOR_MAX_SIZE) { + DHLOGE("HandleStopDhidRemoteInput vecSize too large"); + return ERR_DH_INPUT_IPC_READ_VALID_FAIL; + } - for (uint32_t i = 0; i < vecSize; i++) { - std::string dhid = data.ReadString(); - if (dhid.empty()) { - DHLOGE("HandleStopDhidRemoteInput dhid is empty"); - continue; + for (uint32_t i = 0; i < vecSize; i++) { + std::string dhid = data.ReadString(); + if (dhid.empty()) { + DHLOGE("HandleStopDhidRemoteInput dhid is empty"); + continue; + } + tempVector.push_back(dhid); } - tempVector.push_back(dhid); - } - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStopDhidRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StopRemoteInput(sinkId, tempVector, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStopDhidRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StopRemoteInput(sinkId, tempVector, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStopDhidRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - - std::vector tempVector; - uint32_t vecSize = data.ReadUint32(); - if (vecSize > IPC_VECTOR_MAX_SIZE) { - DHLOGE("HandleStartRelayDhidRemoteInput vecSize too large"); - return ERR_DH_INPUT_IPC_READ_VALID_FAIL; - } + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); + + std::vector tempVector; + uint32_t vecSize = data.ReadUint32(); + if (vecSize > IPC_VECTOR_MAX_SIZE) { + DHLOGE("HandleStartRelayDhidRemoteInput vecSize too large"); + return ERR_DH_INPUT_IPC_READ_VALID_FAIL; + } - for (uint32_t i = 0; i < vecSize; i++) { - std::string dhid = data.ReadString(); - if (dhid.empty()) { - DHLOGE("HandleStartRelayDhidRemoteInput dhid is empty"); - continue; + for (uint32_t i = 0; i < vecSize; i++) { + std::string dhid = data.ReadString(); + if (dhid.empty()) { + DHLOGE("HandleStartRelayDhidRemoteInput dhid is empty"); + continue; + } + tempVector.push_back(dhid); } - tempVector.push_back(dhid); - } - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStartRelayDhidRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StartRemoteInput(srcId, sinkId, tempVector, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStartRelayDhidRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartRelayDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StartRemoteInput(srcId, sinkId, tempVector, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStartRelayDhidRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - - std::vector tempVector; - uint32_t vecSize = data.ReadUint32(); - if (vecSize > IPC_VECTOR_MAX_SIZE) { - DHLOGE("HandleStopRelayDhidRemoteInput vecSize too large"); - return ERR_DH_INPUT_IPC_READ_VALID_FAIL; - } + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); + + std::vector tempVector; + uint32_t vecSize = data.ReadUint32(); + if (vecSize > IPC_VECTOR_MAX_SIZE) { + DHLOGE("HandleStopRelayDhidRemoteInput vecSize too large"); + return ERR_DH_INPUT_IPC_READ_VALID_FAIL; + } - for (uint32_t i = 0; i < vecSize; i++) { - std::string dhid = data.ReadString(); - if (dhid.empty()) { - DHLOGE("HandleStopRelayDhidRemoteInput dhid is empty"); - continue; + for (uint32_t i = 0; i < vecSize; i++) { + std::string dhid = data.ReadString(); + if (dhid.empty()) { + DHLOGE("HandleStopRelayDhidRemoteInput dhid is empty"); + continue; + } + tempVector.push_back(dhid); } - tempVector.push_back(dhid); - } - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStopRelayDhidRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StopRemoteInput(srcId, sinkId, tempVector, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStopRelayDhidRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopRelayDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StopRemoteInput(srcId, sinkId, tempVector, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStopRelayDhidRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } - return DH_SUCCESS; + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleSyncNodeInfoRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -529,29 +659,45 @@ int32_t DistributedInputSourceStub::HandleUnregisterSimulationEventListener(Mess int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel &data, MessageParcel &reply) { - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleRegisterSessionStateCb failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = RegisterSessionStateCb(callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleRegisterSessionStateCb write ret failed, ret = %d", ret); - return ERR_DH_INPUT_SRC_STUB_REGISTER_SESSION_STATE_FAIL; - } + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleRegisterSessionStateCb failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = RegisterSessionStateCb(callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleRegisterSessionStateCb write ret failed, ret = %d", ret); + return ERR_DH_INPUT_SRC_STUB_REGISTER_SESSION_STATE_FAIL; + } - return DH_SUCCESS; + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; + } + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel &data, MessageParcel &reply) { - int32_t ret = UnregisterSessionStateCb(); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleUnregisterSessionStateCb write ret failed, ret = %d", ret); - return ERR_DH_INPUT_SRC_STUB_UNREGISTER_SESSION_STATE_FAIL; - } + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); + if (result == Security::AccessToken::PERMISSION_GRANTED) { + int32_t ret = UnregisterSessionStateCb(); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleUnregisterSessionStateCb write ret failed, ret = %d", ret); + return ERR_DH_INPUT_SRC_STUB_UNREGISTER_SESSION_STATE_FAIL; + } - return DH_SUCCESS; + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; + } + DHLOGE("Access Permission invailable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::OnRemoteRequest( diff --git a/services/sink/sinkmanager/BUILD.gn b/services/sink/sinkmanager/BUILD.gn index 2a8aa04..6dc1280 100644 --- a/services/sink/sinkmanager/BUILD.gn +++ b/services/sink/sinkmanager/BUILD.gn @@ -64,6 +64,8 @@ ohos_shared_library("libdinput_sink") { ] external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", "c_utils:utils", "config_policy:configpolicy_util", "distributed_hardware_fwk:libdhfwk_sdk", diff --git a/services/source/sourcemanager/BUILD.gn b/services/source/sourcemanager/BUILD.gn index fc1defb..7bfd57f 100644 --- a/services/source/sourcemanager/BUILD.gn +++ b/services/source/sourcemanager/BUILD.gn @@ -102,6 +102,8 @@ ohos_shared_library("libdinput_source") { ] external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", "c_utils:utils", "config_policy:configpolicy_util", "distributed_hardware_fwk:libdhfwk_sdk", -- Gitee From 3b6743db133ab187c89157764b5b69e11aca1404 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 26 Sep 2023 06:23:26 +0000 Subject: [PATCH 02/27] update interfaces/ipc/src/distributed_input_source_stub.cpp. Signed-off-by: ry521 --- .../ipc/src/distributed_input_source_stub.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index cf44543..2b83e21 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -155,7 +155,7 @@ int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessagePar return DH_SUCCESS; } DHLOGE("Enable Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageParcel &data, MessageParcel &reply) @@ -180,7 +180,7 @@ int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageP return DH_SUCCESS; } DHLOGE("Enable Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -204,7 +204,7 @@ int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -228,7 +228,7 @@ int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &da return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -253,7 +253,7 @@ int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -278,7 +278,7 @@ int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, M return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -304,7 +304,7 @@ int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParce return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -330,7 +330,7 @@ int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -355,7 +355,7 @@ int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -380,7 +380,7 @@ int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParce return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -421,7 +421,7 @@ int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &da return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -462,7 +462,7 @@ int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &dat return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -504,7 +504,7 @@ int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParce return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -546,7 +546,7 @@ int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleSyncNodeInfoRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -678,7 +678,7 @@ int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel & return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel &data, MessageParcel &reply) @@ -697,7 +697,7 @@ int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel return DH_SUCCESS; } DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t DistributedInputSourceStub::OnRemoteRequest( -- Gitee From eeaa9b7121e5f013013508f8499bfa7f93fb1c0a Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 26 Sep 2023 07:40:40 +0000 Subject: [PATCH 03/27] update interfaces/ipc/src/distributed_input_sink_stub.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_sink_stub.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index fb3bca1..1937239 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -69,7 +69,7 @@ int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel & int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { DHLOGI("DistributedInputSinkStub InitInner start"); @@ -88,7 +88,7 @@ int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel & int32_t DistributedInputSinkStub::ReleaseInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { int32_t ret = Release(); -- Gitee From 1432751e72d678a565da10d5d5c22900b4f79b33 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 26 Sep 2023 07:42:51 +0000 Subject: [PATCH 04/27] update interfaces/ipc/src/distributed_input_source_stub.cpp. Signed-off-by: ry521 --- .../ipc/src/distributed_input_source_stub.cpp | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 2b83e21..345a77b 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -87,7 +87,7 @@ void DistributedInputSourceStub::RegRespFunMap() int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::unique_lock lock(operatorMutex_); @@ -111,7 +111,7 @@ int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::unique_lock lock(operatorMutex_); @@ -135,7 +135,7 @@ int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParc int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string devId = data.ReadString(); @@ -161,7 +161,7 @@ int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessagePar int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string devId = data.ReadString(); @@ -186,7 +186,7 @@ int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageP int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string deviceId = data.ReadString(); @@ -210,7 +210,7 @@ int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string deviceId = data.ReadString(); @@ -234,7 +234,7 @@ int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &da int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string deviceId = data.ReadString(); @@ -259,7 +259,7 @@ int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string deviceId = data.ReadString(); @@ -284,7 +284,7 @@ int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, M int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string srcId = data.ReadString(); @@ -310,7 +310,7 @@ int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string srcId = data.ReadString(); @@ -336,7 +336,7 @@ int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string srcId = data.ReadString(); @@ -361,7 +361,7 @@ int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string srcId = data.ReadString(); @@ -386,7 +386,7 @@ int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string sinkId = data.ReadString(); @@ -427,7 +427,7 @@ int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &da int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string sinkId = data.ReadString(); @@ -468,7 +468,7 @@ int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &dat int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string srcId = data.ReadString(); @@ -510,7 +510,7 @@ int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { std::string srcId = data.ReadString(); @@ -660,7 +660,7 @@ int32_t DistributedInputSourceStub::HandleUnregisterSimulationEventListener(Mess int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { sptr callback = iface_cast(data.ReadRemoteObject()); @@ -684,7 +684,7 @@ int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel & int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel &data, MessageParcel &reply) { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); if (result == Security::AccessToken::PERMISSION_GRANTED) { int32_t ret = UnregisterSessionStateCb(); -- Gitee From a6b429589df5c2bec23b97724269ef8295d30f36 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 26 Sep 2023 08:24:40 +0000 Subject: [PATCH 05/27] update interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn. Signed-off-by: ry521 --- interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn index 1179c3c..eecbd18 100644 --- a/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn +++ b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn @@ -92,6 +92,8 @@ ohos_unittest("add_white_list_infos_callbackl_test") { ] external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", "c_utils:utils", "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", -- Gitee From 6eacd3501d13dd0baffb9caf83b3888a80d2ff32 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 26 Sep 2023 08:25:13 +0000 Subject: [PATCH 06/27] update interfaces/ipc/test/clientunittest/BUILD.gn. Signed-off-by: ry521 --- interfaces/ipc/test/clientunittest/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interfaces/ipc/test/clientunittest/BUILD.gn b/interfaces/ipc/test/clientunittest/BUILD.gn index a1a38e9..4a838f5 100644 --- a/interfaces/ipc/test/clientunittest/BUILD.gn +++ b/interfaces/ipc/test/clientunittest/BUILD.gn @@ -116,6 +116,8 @@ ohos_unittest("distributed_input_client_test") { ] external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", "c_utils:utils", "config_policy:configpolicy_util", "distributed_hardware_fwk:libdhfwk_sdk", -- Gitee From 239a4f1f8e5301aa6f908b55fb4a633cdd1afa16 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 26 Sep 2023 08:25:56 +0000 Subject: [PATCH 07/27] update interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn. Signed-off-by: ry521 --- interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn b/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn index a9181fc..13dfbe5 100644 --- a/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn +++ b/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn @@ -92,6 +92,8 @@ ohos_unittest("dinput_source_callback_test") { ] external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", "c_utils:utils", "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", -- Gitee From b0f219e1ed19bee21dab19ebf4087c1e8c7f6e84 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 26 Sep 2023 08:26:44 +0000 Subject: [PATCH 08/27] update interfaces/ipc/test/ipcunittest/BUILD.gn. Signed-off-by: ry521 --- interfaces/ipc/test/ipcunittest/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interfaces/ipc/test/ipcunittest/BUILD.gn b/interfaces/ipc/test/ipcunittest/BUILD.gn index 8f0d33b..8314577 100644 --- a/interfaces/ipc/test/ipcunittest/BUILD.gn +++ b/interfaces/ipc/test/ipcunittest/BUILD.gn @@ -103,6 +103,8 @@ ohos_unittest("distributed_input_ipc_test") { ] external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", "c_utils:utils", "config_policy:configpolicy_util", "distributed_hardware_fwk:libdhfwk_sdk", -- Gitee From 6aed11ceeabf7335e408392b025177c6b3519baa Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 26 Sep 2023 08:27:55 +0000 Subject: [PATCH 09/27] update services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn. Signed-off-by: ry521 --- .../source/sourcemanager/test/sourcemanagerunittest/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn b/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn index 46761e9..a41b892 100755 --- a/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn +++ b/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn @@ -119,6 +119,7 @@ ohos_unittest("distributed_input_sourcemanager_test") { ] external_deps = [ + "access_token:libtokenid_sdk", "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", -- Gitee From bfbd11266f3eeea8f221c4d50d1137d3e4fd2914 Mon Sep 17 00:00:00 2001 From: ry521 Date: Tue, 26 Sep 2023 09:01:01 +0000 Subject: [PATCH 10/27] update services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn. Signed-off-by: ry521 --- .../source/sourcemanager/test/sourcemanagerunittest/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn b/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn index a41b892..f3b3755 100755 --- a/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn +++ b/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn @@ -119,10 +119,10 @@ ohos_unittest("distributed_input_sourcemanager_test") { ] external_deps = [ - "access_token:libtokenid_sdk", "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", + "access_token:libtokenid_sdk", "c_utils:utils", "distributed_hardware_fwk:libdhfwk_sdk", "eventhandler:libeventhandler", -- Gitee From 80c25dea0095b57bc58fd775da85ef0e179a4264 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 09:18:21 +0000 Subject: [PATCH 11/27] update interfaces/ipc/include/distributed_input_sink_stub.h. Signed-off-by: ry521 --- interfaces/ipc/include/distributed_input_sink_stub.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interfaces/ipc/include/distributed_input_sink_stub.h b/interfaces/ipc/include/distributed_input_sink_stub.h index 3d13969..9b6a1ea 100644 --- a/interfaces/ipc/include/distributed_input_sink_stub.h +++ b/interfaces/ipc/include/distributed_input_sink_stub.h @@ -44,6 +44,8 @@ public: int32_t RegisterSharingDhIdListenerInner(MessageParcel &data, MessageParcel &reply, MessageOption &option); + bool HasEnableDHPermission(); + private: DISALLOW_COPY_AND_MOVE(DistributedInputSinkStub); using DistributedInputSinkFunc = int32_t (DistributedInputSinkStub::*)(MessageParcel &data, MessageParcel &reply, -- Gitee From f3184795466e098476b5822ebd5fc13378f6ea3c Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 09:35:35 +0000 Subject: [PATCH 12/27] update interfaces/ipc/src/distributed_input_sink_stub.cpp. Signed-off-by: ry521 --- .../ipc/src/distributed_input_sink_stub.cpp | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index 1937239..7c1f2ca 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -50,6 +50,15 @@ DistributedInputSinkStub::~DistributedInputSinkStub() memberFuncMap_.clear(); } +bool DistributedInputSinkStub::HasEnableDHPermission() +{ + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + const std::string permissionName = "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"; + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + permissionName); + return (result = Security::AccessToken::PERMISSION_GRANTED); +} + int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { @@ -68,39 +77,33 @@ int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel & int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - DHLOGI("DistributedInputSinkStub InitInner start"); - int32_t ret = Init(); - if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - DHLOGE("Enable Permission vailable"); - return ret; + if (!HasEnableDHPermission()) { + DHLOGE("Enable Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } - DHLOGE("Enable Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + DHLOGI("DistributedInputSinkStub InitInner start"); + int32_t ret = Init(); + if (!reply.WriteInt32(ret)) { + DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + DHLOGE("Enable Permission vailable"); + return ret; } int32_t DistributedInputSinkStub::ReleaseInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - int32_t ret = Release(); - if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - DHLOGE("Enable Permission vailable"); - return ret; + if (!HasEnableDHPermission()) { + DHLOGE("Enable Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } - DHLOGE("Enable Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + int32_t ret = Release(); + if (!reply.WriteInt32(ret)) { + DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + DHLOGE("Enable Permission vailable"); + return ret; } int32_t DistributedInputSinkStub::NotifyStartDScreenInner(MessageParcel &data, MessageParcel &reply, -- Gitee From 39ad2f911cec843857779893d73e1baed614b517 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 09:38:10 +0000 Subject: [PATCH 13/27] update interfaces/ipc/include/distributed_input_source_proxy.h. Signed-off-by: ry521 --- interfaces/ipc/include/distributed_input_source_proxy.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interfaces/ipc/include/distributed_input_source_proxy.h b/interfaces/ipc/include/distributed_input_source_proxy.h index 4824e30..4828ff2 100644 --- a/interfaces/ipc/include/distributed_input_source_proxy.h +++ b/interfaces/ipc/include/distributed_input_source_proxy.h @@ -87,6 +87,9 @@ public: int32_t RegisterSessionStateCb(sptr callback) override; int32_t UnregisterSessionStateCb() override; + bool HasEnableDHPermission(); + bool HasAccessDHPermission(); + private: bool SendRequest(const uint32_t code, MessageParcel &data, MessageParcel &reply); -- Gitee From afdc98be596c62b7b7cf278f210b83d93c90c4f4 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 09:49:55 +0000 Subject: [PATCH 14/27] update interfaces/ipc/src/distributed_input_source_stub.cpp. Signed-off-by: ry521 --- .../ipc/src/distributed_input_source_stub.cpp | 771 +++++++++--------- 1 file changed, 368 insertions(+), 403 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 345a77b..f8571e6 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -84,469 +84,440 @@ void DistributedInputSourceStub::RegRespFunMap() memberFuncMap_[static_cast(IDInputSourceInterfaceCode::UNREGISTER_SESSION_STATE_CB)] = &DistributedInputSourceStub::HandleUnregisterSessionStateCb; } -int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel &reply) + +bool DScreenSourceStub::HasEnableDHPermission() { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + const std::string permissionName = "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"; int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::unique_lock lock(operatorMutex_); - if (sourceManagerInitFlag_.load()) { - DHLOGE("DistributedInputSourceStub already init."); - return DH_SUCCESS; - } - int32_t ret = Init(); - if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSourceStub Init write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - sourceManagerInitFlag_.store(true); - DHLOGE("Enable Permission vailable"); + permissionName); + return (result == Security::AccessToken::PERMISSION_GRANTED); +} + +bool DScreenSourceStub::HasAccessDHPermission() +{ + Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + const std::string permissionName = "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"; + int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, + permissionName); + return (result == Security::AccessToken::PERMISSION_GRANTED); +} + +int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel &reply) +{ + if (!HasEnableDHPermission()) { + DHLOGE("Enable Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::unique_lock lock(operatorMutex_); + if (sourceManagerInitFlag_.load()) { + DHLOGE("DistributedInputSourceStub already init."); return DH_SUCCESS; } - DHLOGE("Enable Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + int32_t ret = Init(); + if (!reply.WriteInt32(ret)) { + DHLOGE("DistributedInputSourceStub Init write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + sourceManagerInitFlag_.store(true); + DHLOGE("Enable Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::unique_lock lock(operatorMutex_); - if (!sourceManagerInitFlag_.load()) { - DHLOGE("DistributedInputSourceStub already Release."); - return DH_SUCCESS; - } - int32_t ret = Release(); - if (!reply.WriteInt32(ret)) { - DHLOGE("DistributedInputSourceStub release write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - sourceManagerInitFlag_.store(false); - DHLOGE("Enable Permission vailable"); + if (!HasEnableDHPermission()) { + DHLOGE("Enable Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::unique_lock lock(operatorMutex_); + if (!sourceManagerInitFlag_.load()) { + DHLOGE("DistributedInputSourceStub already Release."); return DH_SUCCESS; } - DHLOGE("Enable Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + int32_t ret = Release(); + if (!reply.WriteInt32(ret)) { + DHLOGE("DistributedInputSourceStub release write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + sourceManagerInitFlag_.store(false); + DHLOGE("Enable Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string devId = data.ReadString(); - std::string dhId = data.ReadString(); - std::string params = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleRegisterDistributedHardware failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = RegisterDistributedHardware(devId, dhId, params, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleRegisterDistributedHardware write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - DHLOGE("Enable Permission vailable"); - return DH_SUCCESS; + if (!HasEnableDHPermission()) { + DHLOGE("Enable Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string devId = data.ReadString(); + std::string dhId = data.ReadString(); + std::string params = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleRegisterDistributedHardware failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = RegisterDistributedHardware(devId, dhId, params, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleRegisterDistributedHardware write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } - DHLOGE("Enable Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + DHLOGE("Enable Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string devId = data.ReadString(); - std::string dhId = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleUnregisterDistributedHardware failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = UnregisterDistributedHardware(devId, dhId, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleUnregisterDistributedHardware write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - DHLOGE("Enable Permission vailable"); - return DH_SUCCESS; + if (!HasEnableDHPermission()) { + DHLOGE("Enable Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } - DHLOGE("Enable Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + std::string devId = data.ReadString(); + std::string dhId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnregisterDistributedHardware failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = UnregisterDistributedHardware(devId, dhId, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleUnregisterDistributedHardware write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + DHLOGE("Enable Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string deviceId = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandlePrepareRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = PrepareRemoteInput(deviceId, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandlePrepareRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; - } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string deviceId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandlePrepareRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + int32_t ret = PrepareRemoteInput(deviceId, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandlePrepareRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string deviceId = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleUnprepareRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = UnprepareRemoteInput(deviceId, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleUnprepareRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string deviceId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnprepareRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = UnprepareRemoteInput(deviceId, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleUnprepareRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string deviceId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStartRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StartRemoteInput(deviceId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStartRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string deviceId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + int32_t ret = StartRemoteInput(deviceId, inputTypes, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStartRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string deviceId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStopRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StopRemoteInput(deviceId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStopRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string deviceId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + int32_t ret = StopRemoteInput(deviceId, inputTypes, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStopRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStartRelayTypeRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StartRemoteInput(srcId, sinkId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStartRelayTypeRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartRelayTypeRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StartRemoteInput(srcId, sinkId, inputTypes, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStartRelayTypeRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - uint32_t inputTypes = data.ReadUint32(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStopRelayTypeRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StopRemoteInput(srcId, sinkId, inputTypes, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStopRelayTypeRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopRelayTypeRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StopRemoteInput(srcId, sinkId, inputTypes, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStopRelayTypeRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandlePrepareRelayRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = PrepareRemoteInput(srcId, sinkId, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandlePrepareRelayRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandlePrepareRelayRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = PrepareRemoteInput(srcId, sinkId, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandlePrepareRelayRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleUnprepareRelayRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = UnprepareRemoteInput(srcId, sinkId, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleUnprepareRelayRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleUnprepareRelayRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = UnprepareRemoteInput(srcId, sinkId, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleUnprepareRelayRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string sinkId = data.ReadString(); - - std::vector tempVector; - uint32_t vecSize = data.ReadUint32(); - if (vecSize > IPC_VECTOR_MAX_SIZE) { - DHLOGE("HandleStartDhidRemoteInput vecSize too large"); - return ERR_DH_INPUT_IPC_READ_VALID_FAIL; - } + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string sinkId = data.ReadString(); - for (uint32_t i = 0; i < vecSize; i++) { - std::string dhid = data.ReadString(); - if (dhid.empty()) { - DHLOGE("HandleStartDhidRemoteInput dhid is empty"); - continue; - } - tempVector.push_back(dhid); - } + std::vector tempVector; + uint32_t vecSize = data.ReadUint32(); + if (vecSize > IPC_VECTOR_MAX_SIZE) { + DHLOGE("HandleStartDhidRemoteInput vecSize too large"); + return ERR_DH_INPUT_IPC_READ_VALID_FAIL; + } - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStartDhidRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; + for (uint32_t i = 0; i < vecSize; i++) { + std::string dhid = data.ReadString(); + if (dhid.empty()) { + DHLOGE("HandleStartDhidRemoteInput dhid is empty"); + continue; } - int32_t ret = StartRemoteInput(sinkId, tempVector, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStartDhidRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + tempVector.push_back(dhid); + } + + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StartRemoteInput(sinkId, tempVector, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStartDhidRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string sinkId = data.ReadString(); - - std::vector tempVector; - uint32_t vecSize = data.ReadUint32(); - if (vecSize > IPC_VECTOR_MAX_SIZE) { - DHLOGE("HandleStopDhidRemoteInput vecSize too large"); - return ERR_DH_INPUT_IPC_READ_VALID_FAIL; - } + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string sinkId = data.ReadString(); - for (uint32_t i = 0; i < vecSize; i++) { - std::string dhid = data.ReadString(); - if (dhid.empty()) { - DHLOGE("HandleStopDhidRemoteInput dhid is empty"); - continue; - } - tempVector.push_back(dhid); - } + std::vector tempVector; + uint32_t vecSize = data.ReadUint32(); + if (vecSize > IPC_VECTOR_MAX_SIZE) { + DHLOGE("HandleStopDhidRemoteInput vecSize too large"); + return ERR_DH_INPUT_IPC_READ_VALID_FAIL; + } - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStopDhidRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; + for (uint32_t i = 0; i < vecSize; i++) { + std::string dhid = data.ReadString(); + if (dhid.empty()) { + DHLOGE("HandleStopDhidRemoteInput dhid is empty"); + continue; } - int32_t ret = StopRemoteInput(sinkId, tempVector, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStopDhidRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; - } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + tempVector.push_back(dhid); } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StopRemoteInput(sinkId, tempVector, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStopDhidRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - - std::vector tempVector; - uint32_t vecSize = data.ReadUint32(); - if (vecSize > IPC_VECTOR_MAX_SIZE) { - DHLOGE("HandleStartRelayDhidRemoteInput vecSize too large"); - return ERR_DH_INPUT_IPC_READ_VALID_FAIL; - } + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); - for (uint32_t i = 0; i < vecSize; i++) { - std::string dhid = data.ReadString(); - if (dhid.empty()) { - DHLOGE("HandleStartRelayDhidRemoteInput dhid is empty"); - continue; - } - tempVector.push_back(dhid); - } + std::vector tempVector; + uint32_t vecSize = data.ReadUint32(); + if (vecSize > IPC_VECTOR_MAX_SIZE) { + DHLOGE("HandleStartRelayDhidRemoteInput vecSize too large"); + return ERR_DH_INPUT_IPC_READ_VALID_FAIL; + } - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStartRelayDhidRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StartRemoteInput(srcId, sinkId, tempVector, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStartRelayDhidRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + for (uint32_t i = 0; i < vecSize; i++) { + std::string dhid = data.ReadString(); + if (dhid.empty()) { + DHLOGE("HandleStartRelayDhidRemoteInput dhid is empty"); + continue; } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + tempVector.push_back(dhid); + } + + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStartRelayDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + int32_t ret = StartRemoteInput(srcId, sinkId, tempVector, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStartRelayDhidRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - std::string srcId = data.ReadString(); - std::string sinkId = data.ReadString(); - - std::vector tempVector; - uint32_t vecSize = data.ReadUint32(); - if (vecSize > IPC_VECTOR_MAX_SIZE) { - DHLOGE("HandleStopRelayDhidRemoteInput vecSize too large"); - return ERR_DH_INPUT_IPC_READ_VALID_FAIL; - } + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + std::string srcId = data.ReadString(); + std::string sinkId = data.ReadString(); - for (uint32_t i = 0; i < vecSize; i++) { - std::string dhid = data.ReadString(); - if (dhid.empty()) { - DHLOGE("HandleStopRelayDhidRemoteInput dhid is empty"); - continue; - } - tempVector.push_back(dhid); - } + std::vector tempVector; + uint32_t vecSize = data.ReadUint32(); + if (vecSize > IPC_VECTOR_MAX_SIZE) { + DHLOGE("HandleStopRelayDhidRemoteInput vecSize too large"); + return ERR_DH_INPUT_IPC_READ_VALID_FAIL; + } - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleStopRelayDhidRemoteInput failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = StopRemoteInput(srcId, sinkId, tempVector, callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleStopRelayDhidRemoteInput write ret failed"); - return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + for (uint32_t i = 0; i < vecSize; i++) { + std::string dhid = data.ReadString(); + if (dhid.empty()) { + DHLOGE("HandleStopRelayDhidRemoteInput dhid is empty"); + continue; } - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + tempVector.push_back(dhid); } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleStopRelayDhidRemoteInput failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = StopRemoteInput(srcId, sinkId, tempVector, callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleStopRelayDhidRemoteInput write ret failed"); + return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; + } + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleSyncNodeInfoRemoteInput(MessageParcel &data, MessageParcel &reply) @@ -659,45 +630,39 @@ int32_t DistributedInputSourceStub::HandleUnregisterSimulationEventListener(Mess int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - sptr callback = iface_cast(data.ReadRemoteObject()); - if (callback == nullptr) { - DHLOGE("HandleRegisterSessionStateCb failed, callback is nullptr."); - return ERR_DH_INPUT_POINTER_NULL; - } - int32_t ret = RegisterSessionStateCb(callback); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleRegisterSessionStateCb write ret failed, ret = %d", ret); - return ERR_DH_INPUT_SRC_STUB_REGISTER_SESSION_STATE_FAIL; - } - - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; + } + sptr callback = iface_cast(data.ReadRemoteObject()); + if (callback == nullptr) { + DHLOGE("HandleRegisterSessionStateCb failed, callback is nullptr."); + return ERR_DH_INPUT_POINTER_NULL; + } + int32_t ret = RegisterSessionStateCb(callback); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleRegisterSessionStateCb write ret failed, ret = %d", ret); + return ERR_DH_INPUT_SRC_STUB_REGISTER_SESSION_STATE_FAIL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, - "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"); - if (result == Security::AccessToken::PERMISSION_GRANTED) { - int32_t ret = UnregisterSessionStateCb(); - if (!reply.WriteInt32(ret)) { - DHLOGE("HandleUnregisterSessionStateCb write ret failed, ret = %d", ret); - return ERR_DH_INPUT_SRC_STUB_UNREGISTER_SESSION_STATE_FAIL; - } - - DHLOGE("Access Permission vailable"); - return DH_SUCCESS; + if (!HasAccessDHPermission()) { + DHLOGE("Access Permission inlvaliable"); + return ERR_DH_INPUT_CLIENT_STOP_FAIL; } - DHLOGE("Access Permission invailable"); - return ERR_DH_INPUT_CLIENT_STOP_FAIL; + int32_t ret = UnregisterSessionStateCb(); + if (!reply.WriteInt32(ret)) { + DHLOGE("HandleUnregisterSessionStateCb write ret failed, ret = %d", ret); + return ERR_DH_INPUT_SRC_STUB_UNREGISTER_SESSION_STATE_FAIL; + } + + DHLOGE("Access Permission vailable"); + return DH_SUCCESS; } int32_t DistributedInputSourceStub::OnRemoteRequest( -- Gitee From 51948366feb6e237a4d1ff6aa7d1cbcdb013dbfb Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 09:57:21 +0000 Subject: [PATCH 15/27] update interfaces/ipc/src/distributed_input_source_stub.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_source_stub.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index f8571e6..434f56f 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -85,7 +85,7 @@ void DistributedInputSourceStub::RegRespFunMap() &DistributedInputSourceStub::HandleUnregisterSessionStateCb; } -bool DScreenSourceStub::HasEnableDHPermission() +bool DistributedInputSourceStub::HasEnableDHPermission() { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); const std::string permissionName = "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"; @@ -94,7 +94,7 @@ bool DScreenSourceStub::HasEnableDHPermission() return (result == Security::AccessToken::PERMISSION_GRANTED); } -bool DScreenSourceStub::HasAccessDHPermission() +bool DistributedInputSourceStub::HasAccessDHPermission() { Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); const std::string permissionName = "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"; -- Gitee From b8f525e8e24c803b6353d026db6a6cf946c3bba8 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 11:19:53 +0000 Subject: [PATCH 16/27] update interfaces/ipc/include/distributed_input_source_proxy.h. Signed-off-by: ry521 --- interfaces/ipc/include/distributed_input_source_proxy.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/interfaces/ipc/include/distributed_input_source_proxy.h b/interfaces/ipc/include/distributed_input_source_proxy.h index 4828ff2..4824e30 100644 --- a/interfaces/ipc/include/distributed_input_source_proxy.h +++ b/interfaces/ipc/include/distributed_input_source_proxy.h @@ -87,9 +87,6 @@ public: int32_t RegisterSessionStateCb(sptr callback) override; int32_t UnregisterSessionStateCb() override; - bool HasEnableDHPermission(); - bool HasAccessDHPermission(); - private: bool SendRequest(const uint32_t code, MessageParcel &data, MessageParcel &reply); -- Gitee From 8c616d71947cec44972cdaf58b609429a83433c0 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 11:21:16 +0000 Subject: [PATCH 17/27] update interfaces/ipc/include/distributed_input_source_stub.h. Signed-off-by: ry521 --- interfaces/ipc/include/distributed_input_source_stub.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interfaces/ipc/include/distributed_input_source_stub.h b/interfaces/ipc/include/distributed_input_source_stub.h index eca2be5..19d3aa2 100644 --- a/interfaces/ipc/include/distributed_input_source_stub.h +++ b/interfaces/ipc/include/distributed_input_source_stub.h @@ -61,6 +61,8 @@ private: int32_t HandleUnregisterSimulationEventListener(MessageParcel &data, MessageParcel &reply); int32_t HandleRegisterSessionStateCb(MessageParcel &data, MessageParcel &reply); int32_t HandleUnregisterSessionStateCb(MessageParcel &data, MessageParcel &reply); + bool HasEnableDHPermission(); + bool HasAccessDHPermission(); DISALLOW_COPY_AND_MOVE(DistributedInputSourceStub); private: std::atomic sourceManagerInitFlag_ {false}; -- Gitee From cbacb589f7282f146a58f8afa98636c2180af0da Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 12:22:07 +0000 Subject: [PATCH 18/27] update interfaces/ipc/src/distributed_input_sink_stub.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_sink_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index 7c1f2ca..bde3aed 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -56,7 +56,7 @@ bool DistributedInputSinkStub::HasEnableDHPermission() const std::string permissionName = "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE"; int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, permissionName); - return (result = Security::AccessToken::PERMISSION_GRANTED); + return (result == Security::AccessToken::PERMISSION_GRANTED); } int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, -- Gitee From b8aaadf60615d4c9006dd56dc49c81c09ee8246f Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 12:31:06 +0000 Subject: [PATCH 19/27] update interfaces/ipc/src/distributed_input_sink_stub.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_sink_stub.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index bde3aed..a47f98b 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -87,7 +87,7 @@ int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel & DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } - DHLOGE("Enable Permission vailable"); + DHLOGI("Enable Permission vailable"); return ret; } @@ -102,7 +102,7 @@ int32_t DistributedInputSinkStub::ReleaseInner(MessageParcel &data, MessageParce DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } - DHLOGE("Enable Permission vailable"); + DHLOGI("Enable Permission vailable"); return ret; } -- Gitee From 53976f28e8651bd88b757a6b0d0431db991078f0 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 12:36:22 +0000 Subject: [PATCH 20/27] update interfaces/ipc/src/distributed_input_source_stub.cpp. Signed-off-by: ry521 --- .../ipc/src/distributed_input_source_stub.cpp | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 434f56f..b6f742c 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "accesstoken_kit.h" #include "distributed_input_source_stub.h" #include "constants_dinput.h" @@ -20,7 +21,6 @@ #include "dinput_ipc_interface_code.h" #include "dinput_log.h" #include "ipc_skeleton.h" -#include "accesstoken_kit.h" namespace OHOS { namespace DistributedHardware { @@ -120,7 +120,6 @@ int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } sourceManagerInitFlag_.store(true); - DHLOGE("Enable Permission vailable"); return DH_SUCCESS; } @@ -141,7 +140,6 @@ int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParc return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } sourceManagerInitFlag_.store(false); - DHLOGE("Enable Permission vailable"); return DH_SUCCESS; } @@ -164,7 +162,6 @@ int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessagePar DHLOGE("HandleRegisterDistributedHardware write ret failed"); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } - DHLOGE("Enable Permission vailable"); return DH_SUCCESS; } @@ -186,7 +183,6 @@ int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageP DHLOGE("HandleUnregisterDistributedHardware write ret failed"); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } - DHLOGE("Enable Permission vailable"); return DH_SUCCESS; } @@ -207,7 +203,6 @@ int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data DHLOGE("HandlePrepareRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -228,7 +223,6 @@ int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &da DHLOGE("HandleUnprepareRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -250,7 +244,6 @@ int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, DHLOGE("HandleStartRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -272,7 +265,6 @@ int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, M DHLOGE("HandleStopRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -295,7 +287,6 @@ int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParce DHLOGE("HandleStartRelayTypeRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -318,7 +309,6 @@ int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel DHLOGE("HandleStopRelayTypeRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -340,7 +330,6 @@ int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel DHLOGE("HandlePrepareRelayRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -362,7 +351,6 @@ int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParce DHLOGE("HandleUnprepareRelayRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -400,7 +388,6 @@ int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &da DHLOGE("HandleStartDhidRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -438,7 +425,6 @@ int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &dat DHLOGE("HandleStopDhidRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -477,7 +463,6 @@ int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParce DHLOGE("HandleStartRelayDhidRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -516,7 +501,6 @@ int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel DHLOGE("HandleStopRelayDhidRemoteInput write ret failed"); return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -645,7 +629,6 @@ int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel & return ERR_DH_INPUT_SRC_STUB_REGISTER_SESSION_STATE_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } @@ -661,7 +644,6 @@ int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel return ERR_DH_INPUT_SRC_STUB_UNREGISTER_SESSION_STATE_FAIL; } - DHLOGE("Access Permission vailable"); return DH_SUCCESS; } -- Gitee From 6010cde5014ada8095300346fd80001ca60d3be2 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 12:37:13 +0000 Subject: [PATCH 21/27] update interfaces/ipc/src/distributed_input_sink_stub.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_sink_stub.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index a47f98b..4b945ab 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "accesstoken_kit.h" #include "distributed_input_sink_stub.h" #include "constants_dinput.h" @@ -22,7 +23,6 @@ #include "dinput_utils_tool.h" #include "i_sharing_dhid_listener.h" #include "ipc_skeleton.h" -#include "accesstoken_kit.h" namespace OHOS { namespace DistributedHardware { @@ -87,7 +87,6 @@ int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel & DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } - DHLOGI("Enable Permission vailable"); return ret; } @@ -102,7 +101,6 @@ int32_t DistributedInputSinkStub::ReleaseInner(MessageParcel &data, MessageParce DHLOGE("DistributedInputSinkStub write ret failed, ret = %d", ret); return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL; } - DHLOGI("Enable Permission vailable"); return ret; } -- Gitee From 55f5da6c0b1b947b91ff5c0899ae0a6f25b1fa0d Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 12:38:50 +0000 Subject: [PATCH 22/27] update interfaces/ipc/src/distributed_input_sink_stub.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_sink_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index 4b945ab..bd0fdf2 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -13,9 +13,9 @@ * limitations under the License. */ -#include "accesstoken_kit.h" #include "distributed_input_sink_stub.h" +#include "accesstoken_kit.h" #include "constants_dinput.h" #include "dinput_errcode.h" #include "dinput_ipc_interface_code.h" -- Gitee From 868596796f8ff5d3c68cf5325e572b3aae22bcac Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 12:39:15 +0000 Subject: [PATCH 23/27] update interfaces/ipc/src/distributed_input_source_stub.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_source_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index b6f742c..d809de7 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -13,9 +13,9 @@ * limitations under the License. */ -#include "accesstoken_kit.h" #include "distributed_input_source_stub.h" +#include "accesstoken_kit.h" #include "constants_dinput.h" #include "dinput_errcode.h" #include "dinput_ipc_interface_code.h" -- Gitee From b05e4552ce8e252cab2900dab33d1335ca3fe2a5 Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 12:44:34 +0000 Subject: [PATCH 24/27] update interfaces/ipc/src/distributed_input_source_stub.cpp. Signed-off-by: ry521 --- .../ipc/src/distributed_input_source_stub.cpp | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index d809de7..0a36121 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -126,7 +126,7 @@ int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParcel &reply) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission inlvaliable"); + DHLOGE("Enable Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::unique_lock lock(operatorMutex_); @@ -146,7 +146,7 @@ int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParc int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission inlvaliable"); + DHLOGE("Enable Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string devId = data.ReadString(); @@ -168,7 +168,7 @@ int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessagePar int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission inlvaliable"); + DHLOGE("Enable Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string devId = data.ReadString(); @@ -189,7 +189,7 @@ int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageP int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string deviceId = data.ReadString(); @@ -209,7 +209,7 @@ int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string deviceId = data.ReadString(); @@ -229,7 +229,7 @@ int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &da int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string deviceId = data.ReadString(); @@ -250,7 +250,7 @@ int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string deviceId = data.ReadString(); @@ -271,7 +271,7 @@ int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, M int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -293,7 +293,7 @@ int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -315,7 +315,7 @@ int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -336,7 +336,7 @@ int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -357,7 +357,7 @@ int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string sinkId = data.ReadString(); @@ -394,7 +394,7 @@ int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &da int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string sinkId = data.ReadString(); @@ -431,7 +431,7 @@ int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &dat int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -469,7 +469,7 @@ int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -615,7 +615,7 @@ int32_t DistributedInputSourceStub::HandleUnregisterSimulationEventListener(Mess int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } sptr callback = iface_cast(data.ReadRemoteObject()); @@ -635,7 +635,7 @@ int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel & int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission inlvaliable"); + DHLOGE("Access Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t ret = UnregisterSessionStateCb(); -- Gitee From 8ed20b4f0d1f9929a9fb67d46402efbc9e02095c Mon Sep 17 00:00:00 2001 From: ry521 Date: Wed, 27 Sep 2023 12:44:58 +0000 Subject: [PATCH 25/27] update interfaces/ipc/src/distributed_input_sink_stub.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_sink_stub.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index bd0fdf2..bbd3426 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -78,7 +78,7 @@ int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel & int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission inlvaliable"); + DHLOGE("Enable Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } DHLOGI("DistributedInputSinkStub InitInner start"); @@ -93,7 +93,7 @@ int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel & int32_t DistributedInputSinkStub::ReleaseInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission inlvaliable"); + DHLOGE("Enable Permission invalid"); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t ret = Release(); -- Gitee From a3a8659811b3b98b63df8c77397cee34f703c159 Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 28 Sep 2023 02:17:46 +0000 Subject: [PATCH 26/27] update interfaces/ipc/src/distributed_input_sink_stub.cpp. Signed-off-by: ry521 --- interfaces/ipc/src/distributed_input_sink_stub.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index bbd3426..300de42 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -78,7 +78,7 @@ int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel & int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission invalid"); + DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } DHLOGI("DistributedInputSinkStub InitInner start"); @@ -93,7 +93,7 @@ int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel & int32_t DistributedInputSinkStub::ReleaseInner(MessageParcel &data, MessageParcel &reply, MessageOption &option) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission invalid"); + DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t ret = Release(); -- Gitee From 113190d1fb37b4abc3c93ac51e0a9944b641e7cc Mon Sep 17 00:00:00 2001 From: ry521 Date: Thu, 28 Sep 2023 02:21:23 +0000 Subject: [PATCH 27/27] update interfaces/ipc/src/distributed_input_source_stub.cpp. Signed-off-by: ry521 --- .../ipc/src/distributed_input_source_stub.cpp | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 0a36121..ec8200d 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -106,7 +106,7 @@ bool DistributedInputSourceStub::HasAccessDHPermission() int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel &reply) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission inlvaliable"); + DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::unique_lock lock(operatorMutex_); @@ -126,7 +126,7 @@ int32_t DistributedInputSourceStub::HandleInitDistributedHardware(MessageParcel int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParcel &reply) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission invalid"); + DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::unique_lock lock(operatorMutex_); @@ -146,7 +146,7 @@ int32_t DistributedInputSourceStub::HandleReleaseDistributedHardware(MessageParc int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission invalid"); + DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string devId = data.ReadString(); @@ -168,7 +168,7 @@ int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessagePar int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageParcel &data, MessageParcel &reply) { if (!HasEnableDHPermission()) { - DHLOGE("Enable Permission invalid"); + DHLOGE("The caller has no ENABLE_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string devId = data.ReadString(); @@ -189,7 +189,7 @@ int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageP int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string deviceId = data.ReadString(); @@ -209,7 +209,7 @@ int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string deviceId = data.ReadString(); @@ -229,7 +229,7 @@ int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &da int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string deviceId = data.ReadString(); @@ -250,7 +250,7 @@ int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string deviceId = data.ReadString(); @@ -271,7 +271,7 @@ int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, M int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -293,7 +293,7 @@ int32_t DistributedInputSourceStub::HandleStartRelayTypeRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -315,7 +315,7 @@ int32_t DistributedInputSourceStub::HandleStopRelayTypeRemoteInput(MessageParcel int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -336,7 +336,7 @@ int32_t DistributedInputSourceStub::HandlePrepareRelayRemoteInput(MessageParcel int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -357,7 +357,7 @@ int32_t DistributedInputSourceStub::HandleUnprepareRelayRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string sinkId = data.ReadString(); @@ -394,7 +394,7 @@ int32_t DistributedInputSourceStub::HandleStartDhidRemoteInput(MessageParcel &da int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string sinkId = data.ReadString(); @@ -431,7 +431,7 @@ int32_t DistributedInputSourceStub::HandleStopDhidRemoteInput(MessageParcel &dat int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -469,7 +469,7 @@ int32_t DistributedInputSourceStub::HandleStartRelayDhidRemoteInput(MessageParce int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } std::string srcId = data.ReadString(); @@ -615,7 +615,7 @@ int32_t DistributedInputSourceStub::HandleUnregisterSimulationEventListener(Mess int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } sptr callback = iface_cast(data.ReadRemoteObject()); @@ -635,7 +635,7 @@ int32_t DistributedInputSourceStub::HandleRegisterSessionStateCb(MessageParcel & int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel &data, MessageParcel &reply) { if (!HasAccessDHPermission()) { - DHLOGE("Access Permission invalid"); + DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); return ERR_DH_INPUT_CLIENT_STOP_FAIL; } int32_t ret = UnregisterSessionStateCb(); -- Gitee