diff --git a/services/implementation/include/device_manager_service_impl.h b/services/implementation/include/device_manager_service_impl.h index aa1feb4256306513d1f185522e36d9142417fcb1..4820c4d9eb782f14a1efcefa82ef66cb73e7ab8d 100644 --- a/services/implementation/include/device_manager_service_impl.h +++ b/services/implementation/include/device_manager_service_impl.h @@ -137,8 +137,6 @@ public: int32_t ImportAuthCode(const std::string &pkgName, const std::string &authCode); - int32_t ExportAuthCode(std::string &authCode); - int32_t BindTarget(const std::string &pkgName, const PeerTargetId &targetId, const std::map &bindParam); diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index 844e3e3d1853ba78a1ece0766a711681cc88036c..0fa9d666a3290ab7181c654f1f4a7bb2b33850de 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -50,8 +50,6 @@ namespace { // One year 365 * 24 * 60 * 60 constexpr int32_t MAX_ALWAYS_ALLOW_SECONDS = 31536000; constexpr int32_t BROADCAST_CREDID_LENGTH = 6; -constexpr int32_t MIN_PIN_CODE = 100000; -constexpr int32_t MAX_PIN_CODE = 999999; // New protocol field definition. To avoid dependency on the new protocol header file, // do not directly depend on the new protocol header file. constexpr int32_t MSG_TYPE_REQ_ACL_NEGOTIATE = 80; @@ -1376,14 +1374,6 @@ int32_t DeviceManagerServiceImpl::ImportAuthCode(const std::string &pkgName, con return DM_OK; } -int32_t DeviceManagerServiceImpl::ExportAuthCode(std::string &authCode) -{ - int32_t ret = GenRandInt(MIN_PIN_CODE, MAX_PIN_CODE); - authCode = std::to_string(ret); - LOGI("ExportAuthCode success, authCode: %{public}s.", GetAnonyString(authCode).c_str()); - return DM_OK; -} - static JsonObject GetExtraJsonObject(const std::map &bindParam) { std::string extra; diff --git a/services/service/include/idevice_manager_service_impl.h b/services/service/include/idevice_manager_service_impl.h index 7825f64767874a83cf6cd8920bbcc630b49d1d70..7c07f181c8db7a8e4b0bfecd4fe845b56e12f2c1 100644 --- a/services/service/include/idevice_manager_service_impl.h +++ b/services/service/include/idevice_manager_service_impl.h @@ -182,13 +182,6 @@ public: */ virtual int32_t ImportAuthCode(const std::string &pkgName, const std::string &authCode) = 0; - /** - * @tc.name: IDeviceManagerServiceImpl::ExportAuthCode - * @tc.desc: ExportAuthCode - * @tc.type: FUNC - */ - virtual int32_t ExportAuthCode(std::string &authCode) = 0; - /** * @tc.name: IDeviceManagerServiceImpl::BindTarget * @tc.desc: BindTarget diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp index a1785e60012d6d97e71548c7ef72354f3a77b64d..7c615b89e5ea4e7b9317ebbf4a3e5762607557fa 100644 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -87,6 +87,8 @@ namespace { constexpr const char* USER_STOP_BY_WIFI_TIMEOUT_TASK = "deviceManagerTimer:userStopByWifi"; constexpr const char* ACCOUNT_COMMON_EVENT_BY_WIFI_TIMEOUT_TASK = "deviceManagerTimer:accountCommonEventByWifi"; const int32_t USER_SWITCH_BY_WIFI_TIMEOUT_S = 2; + constexpr int32_t MIN_PIN_CODE = 100000; + constexpr int32_t MAX_PIN_CODE = 999999; #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) && !defined(DEVICE_MANAGER_COMMON_FLAG) const std::string GET_LOCAL_DEVICE_NAME_API_NAME = "GetLocalDeviceName"; #endif @@ -1369,12 +1371,13 @@ int32_t DeviceManagerService::ExportAuthCode(std::string &authCode) LOGE("The caller: %{public}s is not in white list.", processName.c_str()); return ERR_DM_INPUT_PARA_INVALID; } - if (!IsDMServiceImplReady()) { - LOGE("ExportAuthCode failed, instance not init or init failed."); - return ERR_DM_NOT_INIT; - } LOGI("DeviceManagerService::ExportAuthCode begin."); - return dmServiceImpl_->ExportAuthCode(authCode); +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) + int32_t ret = GenRandInt(MIN_PIN_CODE, MAX_PIN_CODE); + authCode = std::to_string(ret); + LOGI("ExportAuthCode success, authCode: %{public}s.", GetAnonyString(authCode).c_str()); +#endif + return DM_OK; } void DeviceManagerService::UnloadDMServiceImplSo() diff --git a/test/commonfuzztest/authenticatedeviceserviceimpl_fuzzer/authenticate_device_service_impl_fuzzer.cpp b/test/commonfuzztest/authenticatedeviceserviceimpl_fuzzer/authenticate_device_service_impl_fuzzer.cpp index c53e1d1575af3dedcc22db8a3e69f4d906c4db8c..a846643bfc6b5757a2ddd15d39d95cbd83461c40 100644 --- a/test/commonfuzztest/authenticatedeviceserviceimpl_fuzzer/authenticate_device_service_impl_fuzzer.cpp +++ b/test/commonfuzztest/authenticatedeviceserviceimpl_fuzzer/authenticate_device_service_impl_fuzzer.cpp @@ -149,7 +149,6 @@ void AuthenticateDeviceServiceImplFuzzTest(const uint8_t* data, size_t size) deviceManagerServiceImpl->GetGroupType(deviceList); deviceManagerServiceImpl->GetUdidHashByNetWorkId(str.c_str(), str); deviceManagerServiceImpl->ImportAuthCode(str, str); - deviceManagerServiceImpl->ExportAuthCode(str); deviceManagerServiceImpl->BindTarget(str, peerTargetId, bindParam); deviceManagerServiceImpl->UnRegisterCredentialCallback(str); deviceManagerServiceImpl->UnRegisterUiStateCallback(str); diff --git a/test/unittest/UTTest_device_manager_service_impl.cpp b/test/unittest/UTTest_device_manager_service_impl.cpp index ae1f15b2934e3ad0a3eed435083a4e9e866a7aae..9060a9f26b89112829041e2a41306a28b1f76373 100644 --- a/test/unittest/UTTest_device_manager_service_impl.cpp +++ b/test/unittest/UTTest_device_manager_service_impl.cpp @@ -1262,20 +1262,6 @@ HWTEST_F(DeviceManagerServiceImplTest, ImportAuthCode_003, testing::ext::TestSiz EXPECT_EQ(ret, DM_OK); } -/** - * @tc.name: ExportAuthCode_001 - * @tc.type: FUNC - */ -HWTEST_F(DeviceManagerServiceImplTest, ExportAuthCode_001, testing::ext::TestSize.Level1) -{ - std::string authCode = "authCode"; - if (deviceManagerServiceImpl_ == nullptr) { - deviceManagerServiceImpl_ = std::make_shared(); - } - int32_t ret = deviceManagerServiceImpl_->ExportAuthCode(authCode); - EXPECT_EQ(ret, DM_OK); -} - /** * @tc.name: BindTarget_001 * @tc.type: FUNC