From ec09152f8e39584eb008a01af5ae70e8ace662ee Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Fri, 13 Jun 2025 16:07:45 +0800 Subject: [PATCH] =?UTF-8?q?RPC=E5=AE=89=E5=85=A8=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- .../src/distributed_hardware_stub.cpp | 20 ++++++------------- .../src/distributed_hardware_stub_test.cpp | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp index 19c8d505..d4dc326e 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp @@ -281,33 +281,25 @@ int32_t DistributedHardwareStub::RegisterControlCenterCallbackInner(MessageParce int32_t OHOS::DistributedHardware::DistributedHardwareStub::HandleNotifySourceRemoteSinkStarted(MessageParcel &data, MessageParcel &reply) { - Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID(); + DHLOGI("HandleNotifySourceRemoteSinkStarted Start."); std::string udid = data.ReadString(); if (!IsIdLengthValid(udid)) { - DHLOGE("the udid is invalid, %{public}s", GetAnonyString(udid).c_str()); - return ERR_DH_FWK_ACCESS_PERMISSION_CHECK_FAIL; + DHLOGE("the udid: %{public}s is invalid.", GetAnonyString(udid).c_str()); + return ERR_DH_FWK_PARA_INVALID; } std::string networkId = ""; DeviceManager::GetInstance().GetNetworkIdByUdid(DH_FWK_PKG_NAME, udid, networkId); if (!IsIdLengthValid(networkId)) { - DHLOGE("the networkId is invalid, %{public}s", GetAnonyString(networkId).c_str()); - return ERR_DH_FWK_ACCESS_PERMISSION_CHECK_FAIL; - } - uint32_t dAccessToken = Security::AccessToken::AccessTokenKit::AllocLocalTokenID(networkId, callerToken); - const std::string permissionName = "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE"; - int32_t result = Security::AccessToken::AccessTokenKit::VerifyAccessToken(dAccessToken, permissionName); - if (result != Security::AccessToken::PERMISSION_GRANTED) { - DHLOGE("The caller has no ACCESS_DISTRIBUTED_HARDWARE permission."); - return ERR_DH_FWK_ACCESS_PERMISSION_CHECK_FAIL; + DHLOGE("the networkId: %{public}s is invalid, not a trusted device.", GetAnonyString(networkId).c_str()); + return ERR_DH_FWK_PARA_INVALID; } - DHLOGI("DistributedHardwareStub HandleNotifySourceRemoteSinkStarted Start."); int32_t ret = NotifySourceRemoteSinkStarted(udid); if (!reply.WriteInt32(ret)) { DHLOGE("write ret failed."); return ERR_DH_FWK_SERVICE_WRITE_INFO_FAIL; } - DHLOGI("DistributedHardwareStub HandleNotifySourceRemoteSinkStarted End."); + DHLOGI("HandleNotifySourceRemoteSinkStarted End."); return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/src/distributed_hardware_stub_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/src/distributed_hardware_stub_test.cpp index 4e39062c..53953807 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/src/distributed_hardware_stub_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/src/distributed_hardware_stub_test.cpp @@ -195,7 +195,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_010, TestSize.Level1) std::string deviceId = "deviceId_test"; data.WriteString(deviceId); auto ret = stubTest_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ERR_DH_FWK_ACCESS_PERMISSION_CHECK_FAIL, ret); + EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, ret); } HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_011, TestSize.Level1) -- Gitee