已合并
visable device id问题修复 #970
pantong创建于 3月18日
visable device id问题修复 #970
已合并
共 2 个文件变更+23-28
| @@ -50,17 +50,20 @@ SchedMode ClientManager::aicpuSchedMode_ = AICPU_SCHED_MODE_INTERRUPT; | |||
| 50 | 50 | ||
| 51 | bool ClientManager::CheckDestructFlag(const uint32_t &logicDevId) | 51 | bool ClientManager::CheckDestructFlag(const uint32_t &logicDevId) |
| 52 | { | 52 | { |
| 53 | - // logicDevId is actually user device id | 53 | + const uint32_t inputDeviceId = logicDevId; |
| 54 | - if (!g_hadGetPlatformInfo && (ClientManager::GetPlatformInfo(logicDevId) != TSD_OK)) { | 54 | + uint32_t logicDeviceId = logicDevId; |
| 55 | + const auto ret = ChangeUserDeviceIdToLogicDeviceId(logicDevId, logicDeviceId); | ||
| 56 | + if (ret != TSD_OK) { | ||
| 55 | return false; | 57 | return false; |
| 56 | } | 58 | } |
| 57 | 59 | ||
| 58 | - uint32_t logicDeviceId = logicDevId; | 60 | + // logicDevId is actually user device id |
| 59 | - if (IsSupportSetVisibleDevices()) { | 61 | + if (!g_hadGetPlatformInfo && (ClientManager::GetPlatformInfo(logicDeviceId) != TSD_OK)) { |
| 60 | - const auto ret = ChangeUserDeviceIdToLogicDeviceId(logicDevId, logicDeviceId); | 62 | + return false; |
| 61 | - if (ret != TSD_OK) { | 63 | + } |
| 62 | - return false; | 64 | + |
| 63 | - } | 65 | + if (!IsSupportSetVisibleDevices()) { |
| 66 | + logicDeviceId = inputDeviceId; | ||
| 64 | } | 67 | } |
| 65 | 68 | ||
| 66 | const std::lock_guard<std::mutex> lk(g_destructFlagMut); | 69 | const std::lock_guard<std::mutex> lk(g_destructFlagMut); |
| @@ -110,16 +113,23 @@ TSD_StatusT ClientManager::GetHdcConctStatus(int32_t &hdcSessStat) | |||
| 110 | 113 | ||
| 111 | std::shared_ptr<ClientManager> ClientManager::GetInstance(const uint32_t &deviceId, const uint32_t deviceMode, const bool transDevIdFlag) | 114 | std::shared_ptr<ClientManager> ClientManager::GetInstance(const uint32_t &deviceId, const uint32_t deviceMode, const bool transDevIdFlag) |
| 112 | { | 115 | { |
| 113 | - if (!g_hadGetPlatformInfo && (ClientManager::GetPlatformInfo(deviceId) != TSD_OK)) { | 116 | + const uint32_t inputDeviceId = deviceId; |
| 114 | - return nullptr; | ||
| 115 | - } | ||
| 116 | uint32_t logicDeviceId = deviceId; | 117 | uint32_t logicDeviceId = deviceId; |
| 117 | - if (IsSupportSetVisibleDevices() && transDevIdFlag) { | 118 | + if (transDevIdFlag) { |
| 118 | const auto ret = ChangeUserDeviceIdToLogicDeviceId(deviceId, logicDeviceId); | 119 | const auto ret = ChangeUserDeviceIdToLogicDeviceId(deviceId, logicDeviceId); |
| 119 | if (ret != TSD_OK) { | 120 | if (ret != TSD_OK) { |
| 120 | return nullptr; | 121 | return nullptr; |
| 121 | } | 122 | } |
| 122 | } | 123 | } |
| 124 | + | ||
| 125 | + if (!g_hadGetPlatformInfo && (ClientManager::GetPlatformInfo(logicDeviceId) != TSD_OK)) { | ||
| 126 | + return nullptr; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + if (!IsSupportSetVisibleDevices()) { | ||
| 130 | + logicDeviceId = inputDeviceId; | ||
| 131 | + } | ||
| 132 | + | ||
| 123 | const std::lock_guard<std::mutex> lk(g_tsdClientMut); | 133 | const std::lock_guard<std::mutex> lk(g_tsdClientMut); |
| 124 | std::shared_ptr<ClientManager> clientManager = nullptr; | 134 | std::shared_ptr<ClientManager> clientManager = nullptr; |
| 125 | const std::map<const uint32_t, std::shared_ptr<ClientManager>>::const_iterator iter = | 135 | const std::map<const uint32_t, std::shared_ptr<ClientManager>>::const_iterator iter = |
| @@ -630,6 +640,7 @@ TSD_StatusT ClientManager::ChangeUserDeviceIdToLogicDeviceId(const uint32_t user | |||
| 630 | if (g_userDeviceInfo == nullptr || g_userDeviceInfo->empty()) { | 640 | if (g_userDeviceInfo == nullptr || g_userDeviceInfo->empty()) { |
| 631 | return TSD_OK; | 641 | return TSD_OK; |
| 632 | } | 642 | } |
| 643 | + | ||
| 633 | const std::map<const uint32_t, uint32_t>::const_iterator iter = g_userDeviceInfo->find(userDevId); | 644 | const std::map<const uint32_t, uint32_t>::const_iterator iter = g_userDeviceInfo->find(userDevId); |
| 634 | if (iter != g_userDeviceInfo->end()) { | 645 | if (iter != g_userDeviceInfo->end()) { |
| 635 | logicDevId = iter->second; | 646 | logicDevId = iter->second; |
| @@ -438,22 +438,6 @@ TEST_F(ClientManagerTest, TestChangeUserDeviceIdToLogicDeviceIdSuccess002) | |||
| 438 | auto ret = ClientManager::ChangeUserDeviceIdToLogicDeviceId(userDevId, logicDevId); | 438 | auto ret = ClientManager::ChangeUserDeviceIdToLogicDeviceId(userDevId, logicDevId); |
| 439 | EXPECT_EQ(ret, TSD_OK); | 439 | EXPECT_EQ(ret, TSD_OK); |
| 440 | } | 440 | } |
| 441 | - | ||
| 442 | -TEST_F(ClientManagerTest, TestChangeUserDeviceIdToLogicDeviceIdSuccess001) | ||
| 443 | -{ | ||
| 444 | - MOCKER_CPP(&ClientManager::IsSupportSetVisibleDevices).stubs().will(returnValue(true)); | ||
| 445 | - char_t env[] = "7,6,5,4"; | ||
| 446 | - MOCKER(mmSysGetEnv).stubs().will(returnValue(&env[0U])); | ||
| 447 | - MOCKER(drvGetDevNum).stubs().will(invoke(fake_drvGetDevNum)); | ||
| 448 | - uint32_t userDevId = 1; | ||
| 449 | - uint32_t logicDevId; | ||
| 450 | - auto ret = ClientManager::ChangeUserDeviceIdToLogicDeviceId(userDevId, logicDevId); | ||
| 451 | - EXPECT_EQ(logicDevId, 6U); | ||
| 452 | - | ||
| 453 | - userDevId = 4; | ||
| 454 | - ret = ClientManager::ChangeUserDeviceIdToLogicDeviceId(userDevId, logicDevId); | ||
| 455 | - EXPECT_EQ(ret, TSD_PARAMETER_INVALID); | ||
| 456 | -} | ||
| 457 | 441 | ||
| 458 | TEST_F(ClientManagerTest, TestGetVisibleDevices01) | 442 | TEST_F(ClientManagerTest, TestGetVisibleDevices01) |
| 459 | { | 443 | { |