diff --git a/commondependency/src/deviceprofile_connector.cpp b/commondependency/src/deviceprofile_connector.cpp index 111b38c1243c23de640e54327a3d9d196eb7b2bd..67c2797a80c980947b4c164a01fb43efd90fa701 100644 --- a/commondependency/src/deviceprofile_connector.cpp +++ b/commondependency/src/deviceprofile_connector.cpp @@ -676,10 +676,10 @@ std::unordered_map DeviceProfileConnector::GetAuthFormM deviceIdMap[trustDeviceId] = DmAuthForm::IDENTICAL_ACCOUNT; continue; } else if (highestBindType == SHARE_TYPE) { - if (CheckSinkShareType(item, userId, deviceId, trustDeviceId, DmAuthForm::ACROSS_ACCOUNT)) { + if (CheckSinkShareType(item, userId, deviceId, trustDeviceId, DmAuthForm::SHARE)) { continue; } - deviceIdMap[trustDeviceId] = DmAuthForm::ACROSS_ACCOUNT; + deviceIdMap[trustDeviceId] = DmAuthForm::SHARE; continue; } else if (highestBindType == DEVICE_PEER_TO_PEER_TYPE || highestBindType == APP_PEER_TO_PEER_TYPE || highestBindType == SERVICE_PEER_TO_PEER_TYPE) { @@ -703,7 +703,7 @@ bool DeviceProfileConnector::CheckSinkShareType(const DistributedDeviceProfile:: if (profile.GetAccessee().GetAccesseeUserId() == userId && profile.GetAccessee().GetAccesseeDeviceId() == deviceId && profile.GetAccesser().GetAccesserDeviceId() == trustDeviceId && - bindType == DmAuthForm::ACROSS_ACCOUNT) { + bindType == DmAuthForm::SHARE) { return true; } return false; @@ -789,7 +789,7 @@ int32_t DeviceProfileConnector::HandleDmAuthForm(AccessControlProfile profiles, return CheckAuthForm(DmAuthForm::PEER_TO_PEER, profiles, discoveryInfo); } if (profiles.GetBindType() == DM_SHARE) { - return CheckAuthForm(DmAuthForm::ACROSS_ACCOUNT, profiles, discoveryInfo); + return CheckAuthForm(DmAuthForm::SHARE, profiles, discoveryInfo); } return DmAuthForm::INVALID_TYPE; } diff --git a/interfaces/inner_kits/native_cpp/include/dm_device_info.h b/interfaces/inner_kits/native_cpp/include/dm_device_info.h index f4d1ea3d6dbc5a8b7b104d186cc23a0406bf9920..8db1977579e0ac4cd65cef75cc3fb54f2cd48da2 100644 --- a/interfaces/inner_kits/native_cpp/include/dm_device_info.h +++ b/interfaces/inner_kits/native_cpp/include/dm_device_info.h @@ -149,6 +149,10 @@ typedef enum DmAuthForm { * Across Account Device auth. */ ACROSS_ACCOUNT = 2, + /** + * Share + */ + SHARE = 3, } DmAuthForm; /** diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index 844e3e3d1853ba78a1ece0766a711681cc88036c..11f5a8a69c68662b630cee32ccf1b1db060d7469 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -640,7 +640,7 @@ void DeviceManagerServiceImpl::HandleOffline(DmDeviceState devState, DmDeviceInf softbusConnector_->SetProcessInfo(processInfo); } else if (static_cast(item.second) == USER && bindType == SHARE_TYPE) { LOGI("The offline device is device bind level and share bind type."); - devInfo.authForm = DmAuthForm::ACROSS_ACCOUNT; + devInfo.authForm = DmAuthForm::SHARE; processInfo.userId = item.first; softbusConnector_->SetProcessInfo(processInfo); } else if (static_cast(item.second) == USER && bindType != SHARE_TYPE) { @@ -713,7 +713,7 @@ void DeviceManagerServiceImpl::SetOnlineProcessInfo(const uint32_t &bindType, Pr LOGI("ProcessDeviceStateChange authForm is share, peer is src."); return; } - devInfo.authForm = DmAuthForm::ACROSS_ACCOUNT; + devInfo.authForm = DmAuthForm::SHARE; softbusConnector_->SetProcessInfo(processInfo); } LOGI("DeviceManagerServiceImpl::HandleOnline success devInfo authForm is %{public}d.", devInfo.authForm); diff --git a/services/service/src/relationshipsyncmgr/relationship_sync_mgr.cpp b/services/service/src/relationshipsyncmgr/relationship_sync_mgr.cpp index 723e43fc3583b0143ede6eabf3d48166b750d62b..9276bf6798773dafc7856043a8d4512fe0ba07a2 100644 --- a/services/service/src/relationshipsyncmgr/relationship_sync_mgr.cpp +++ b/services/service/src/relationshipsyncmgr/relationship_sync_mgr.cpp @@ -147,7 +147,7 @@ bool RelationShipChangeMsg::ToBroadcastPayLoad(uint8_t *&msg, uint32_t &len) con void RelationShipChangeMsg::ToShareUnbindPayLoad(uint8_t *&msg, uint32_t &len) const { - if (credId.length() != (CREDID_PAYLOAD_LEN - USERID_PAYLOAD_LEN)) { + if (credId.length() <= (CREDID_PAYLOAD_LEN - USERID_PAYLOAD_LEN)) { LOGE("ToShareUnbindPayLoad credId length is invalid."); len = 0; return; diff --git a/test/commonunittest/UTTest_dm_deviceprofile_connector.cpp b/test/commonunittest/UTTest_dm_deviceprofile_connector.cpp index 3731b851f7f6f5c0041ddf7acb502eab066fbd2f..ffcd923065687a446b53457cd21c52586f4f057c 100644 --- a/test/commonunittest/UTTest_dm_deviceprofile_connector.cpp +++ b/test/commonunittest/UTTest_dm_deviceprofile_connector.cpp @@ -727,7 +727,7 @@ HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_005, testing::ext::TestSiz profiles.SetBindLevel(USER); DmDiscoveryInfo discoveryInfo; int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo); - EXPECT_EQ(ret, ACROSS_ACCOUNT); + EXPECT_EQ(ret, PEER_TO_PEER); } HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_006, testing::ext::TestSize.Level1) @@ -741,7 +741,7 @@ HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_006, testing::ext::TestSiz discoveryInfo.pkgname = "pkgName"; discoveryInfo.localDeviceId = "localDeviceId"; int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo); - EXPECT_EQ(ret, ACROSS_ACCOUNT); + EXPECT_EQ(ret, PEER_TO_PEER); } HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_007, testing::ext::TestSize.Level1) @@ -755,7 +755,7 @@ HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_007, testing::ext::TestSiz discoveryInfo.pkgname = "pkgName"; discoveryInfo.localDeviceId = "localDeviceId"; int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo); - EXPECT_EQ(ret, ACROSS_ACCOUNT); + EXPECT_EQ(ret, PEER_TO_PEER); } HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_008, testing::ext::TestSize.Level1) diff --git a/test/commonunittest/UTTest_dm_deviceprofile_connector_second.cpp b/test/commonunittest/UTTest_dm_deviceprofile_connector_second.cpp index a7afeaccc7cb203d440262e146694bcec47553cf..b8d4deb1a6a256fc24adc40a441af2eab9c60ffd 100644 --- a/test/commonunittest/UTTest_dm_deviceprofile_connector_second.cpp +++ b/test/commonunittest/UTTest_dm_deviceprofile_connector_second.cpp @@ -592,7 +592,7 @@ HWTEST_F(DeviceProfileConnectorSecondTest, HandleDmAuthForm_009, testing::ext::T profiles.SetBindLevel(USER); DmDiscoveryInfo discoveryInfo; int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo); - EXPECT_EQ(ret, ACROSS_ACCOUNT); + EXPECT_EQ(ret, SHARE); } HWTEST_F(DeviceProfileConnectorSecondTest, HandleDmAuthForm_010, testing::ext::TestSize.Level1) @@ -606,7 +606,7 @@ HWTEST_F(DeviceProfileConnectorSecondTest, HandleDmAuthForm_010, testing::ext::T discoveryInfo.pkgname = "ohos_test"; discoveryInfo.localDeviceId = "localDeviceId"; int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo); - EXPECT_EQ(ret, ACROSS_ACCOUNT); + EXPECT_EQ(ret, SHARE); } HWTEST_F(DeviceProfileConnectorSecondTest, HandleDmAuthForm_011, testing::ext::TestSize.Level1) @@ -620,7 +620,7 @@ HWTEST_F(DeviceProfileConnectorSecondTest, HandleDmAuthForm_011, testing::ext::T discoveryInfo.pkgname = "pkgName"; discoveryInfo.localDeviceId = "localDeviceId"; int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo); - EXPECT_EQ(ret, ACROSS_ACCOUNT); + EXPECT_EQ(ret, SHARE); } HWTEST_F(DeviceProfileConnectorSecondTest, CheckSinkShareType_001, testing::ext::TestSize.Level1) @@ -629,7 +629,7 @@ HWTEST_F(DeviceProfileConnectorSecondTest, CheckSinkShareType_001, testing::ext: int32_t userId = 123456; std::string deviceId = "deviceId"; std::string trustDeviceId = "trustDeviceId"; - int32_t bindType = DmAuthForm::ACROSS_ACCOUNT; + int32_t bindType = DmAuthForm::SHARE; DistributedDeviceProfile::Accessee accessee; accessee.SetAccesseeUserId(userId); @@ -651,7 +651,7 @@ HWTEST_F(DeviceProfileConnectorSecondTest, CheckSinkShareType_002, testing::ext: int32_t userId = 123456; std::string deviceId = "deviceId"; std::string trustDeviceId = "trustDeviceId"; - int32_t bindType = DmAuthForm::ACROSS_ACCOUNT; + int32_t bindType = DmAuthForm::SHARE; DistributedDeviceProfile::Accessee accessee; accessee.SetAccesseeUserId(0); @@ -664,7 +664,7 @@ HWTEST_F(DeviceProfileConnectorSecondTest, CheckSinkShareType_002, testing::ext: bool ret = DeviceProfileConnector::GetInstance().CheckSinkShareType( profile, userId, deviceId, trustDeviceId, bindType); - EXPECT_TRUE(ret); + EXPECT_FALSE(ret); } HWTEST_F(DeviceProfileConnectorSecondTest, CheckSinkShareType_003, testing::ext::TestSize.Level1) @@ -673,7 +673,7 @@ HWTEST_F(DeviceProfileConnectorSecondTest, CheckSinkShareType_003, testing::ext: int32_t userId = 123456; std::string deviceId = "deviceId"; std::string trustDeviceId = "trustDeviceId"; - int32_t bindType = DmAuthForm::ACROSS_ACCOUNT; + int32_t bindType = DmAuthForm::SHARE; DistributedDeviceProfile::Accessee accessee; accessee.SetAccesseeUserId(-1); @@ -685,7 +685,7 @@ HWTEST_F(DeviceProfileConnectorSecondTest, CheckSinkShareType_003, testing::ext: profile.SetAccesser(accesser); bool ret = DeviceProfileConnector::GetInstance().CheckSinkShareType( profile, userId, deviceId, trustDeviceId, bindType); - EXPECT_TRUE(ret); + EXPECT_FALSE(ret); } HWTEST_F(DeviceProfileConnectorSecondTest, CheckSinkShareType_004, testing::ext::TestSize.Level1) diff --git a/test/unittest/UTTest_device_manager_service_impl_first.cpp b/test/unittest/UTTest_device_manager_service_impl_first.cpp index 13b4a1d106b91a2eaabe5bdd75494b1fc23388f8..0d7ef000be23d053895f004d476ee6931c2430c7 100644 --- a/test/unittest/UTTest_device_manager_service_impl_first.cpp +++ b/test/unittest/UTTest_device_manager_service_impl_first.cpp @@ -526,7 +526,7 @@ HWTEST_F(DeviceManagerServiceImplFirstTest, SetOnlineProcessInfo_006, testing::e deviceManagerServiceImpl_->SetOnlineProcessInfo( bindType, processInfo, devInfo, requestDeviceId, trustDeviceId, devState); - EXPECT_EQ(devInfo.authForm, DmAuthForm::ACROSS_ACCOUNT); + EXPECT_EQ(devInfo.authForm, DmAuthForm::SHARE); } } // namespace } // namespace DistributedHardware diff --git a/test/unittest/UTTest_relationship_sync_mgr.cpp b/test/unittest/UTTest_relationship_sync_mgr.cpp index 0121fe018e05017c1dc8ae45f937047a1736ba24..fe46bd0d1c566765c3e0d2e5b64574c40cb22983 100644 --- a/test/unittest/UTTest_relationship_sync_mgr.cpp +++ b/test/unittest/UTTest_relationship_sync_mgr.cpp @@ -1214,8 +1214,7 @@ HWTEST_F(ReleationShipSyncMgrTest, ToBroadcastPayLoad_010, testing::ext::TestSiz bool result = msg.ToBroadcastPayLoad(msgPtr, len); ASSERT_TRUE(result); - ASSERT_NE(msgPtr, nullptr); - ASSERT_GT(len, 0); + ASSERT_EQ(msgPtr, nullptr); delete[] msgPtr; } @@ -1261,7 +1260,7 @@ HWTEST_F(ReleationShipSyncMgrTest, ToShareUnbindPayLoad_001, testing::ext::TestS { RelationShipChangeMsg msg; msg.userId = 12345; - msg.credId = "cred123"; + msg.credId = "123456"; uint8_t* msgPtr = nullptr; uint32_t len = 0; @@ -1285,7 +1284,7 @@ HWTEST_F(ReleationShipSyncMgrTest, ToShareUnbindPayLoad_002, testing::ext::TestS { RelationShipChangeMsg msg; msg.userId = 12345; - msg.credId = ""; + msg.credId = "123456"; uint8_t* msgPtr = nullptr; uint32_t len = 0; @@ -1299,7 +1298,7 @@ HWTEST_F(ReleationShipSyncMgrTest, ToShareUnbindPayLoad_002, testing::ext::TestS ASSERT_EQ(msgPtr[1], static_cast((msg.userId >> 8) & 0xFF)); for (int i = USERID_PAYLOAD_LEN; i < SHARE_UNBIND_PAYLOAD_LEN; i++) { - ASSERT_EQ(msgPtr[i], 0); + ASSERT_NE(msgPtr[i], 0); } delete[] msgPtr; @@ -1309,7 +1308,7 @@ HWTEST_F(ReleationShipSyncMgrTest, ToShareUnbindPayLoad_003, testing::ext::TestS { RelationShipChangeMsg msg; msg.userId = UINT16_MAX; - msg.credId = "cred123"; + msg.credId = "123456"; uint8_t* msgPtr = nullptr; uint32_t len = 0;